@yawlabs/mcp 1.0.18 → 1.0.20

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.
@@ -18,9 +18,11 @@ import { tmpdir } from "os";
18
18
  import { dirname as dirname3, join as join11, sep as sep2 } from "path";
19
19
 
20
20
  // src/atomic-write.ts
21
- import { chmod, lstat, mkdir, realpath, rename, stat, unlink, writeFile } from "fs/promises";
21
+ import { chmod, lstat, mkdir, readdir, realpath, rename, stat, unlink, writeFile } from "fs/promises";
22
22
  import path from "path";
23
23
  import { setTimeout as delay } from "timers/promises";
24
+ var STALE_TMP_AGE_MS = 10 * 60 * 1e3;
25
+ var TMP_SUFFIX = /\.tmp-\d+-\d+-\d+$/;
24
26
  var WIN32_TRANSIENT_CODES = /* @__PURE__ */ new Set(["EPERM", "EBUSY", "EACCES"]);
25
27
  var RENAME_RETRY_DELAYS_MS = [10, 50, 100];
26
28
  function isWin32TransientFsError(err) {
@@ -60,6 +62,7 @@ async function atomicWriteFile(filePath, contents, encoding = "utf8", mode, dirM
60
62
  const birthMode = mode ?? preserved;
61
63
  try {
62
64
  await writeFile(tmp, contents, birthMode === void 0 ? { encoding } : { encoding, mode: birthMode });
65
+ await sweepStaleTmpSiblings(dir, path.basename(target), tmp);
63
66
  if (preserved !== void 0) {
64
67
  try {
65
68
  await chmod(tmp, preserved);
@@ -72,6 +75,28 @@ async function atomicWriteFile(filePath, contents, encoding = "utf8", mode, dirM
72
75
  throw err;
73
76
  }
74
77
  }
78
+ async function sweepStaleTmpSiblings(dir, base, own) {
79
+ const prefix = `${base}.tmp-`;
80
+ let names;
81
+ try {
82
+ names = await readdir(dir);
83
+ } catch {
84
+ return;
85
+ }
86
+ const cutoff = Date.now() - STALE_TMP_AGE_MS;
87
+ const ownResolved = path.resolve(own);
88
+ for (const name of names) {
89
+ if (!name.startsWith(prefix) || !TMP_SUFFIX.test(name)) continue;
90
+ const candidate = path.join(dir, name);
91
+ if (path.resolve(candidate) === ownResolved) continue;
92
+ try {
93
+ const st = await stat(candidate);
94
+ if (!st.isFile() || st.mtimeMs > cutoff) continue;
95
+ await unlink(candidate);
96
+ } catch {
97
+ }
98
+ }
99
+ }
75
100
  async function resolveSymlinkTarget(filePath) {
76
101
  try {
77
102
  if (!(await lstat(filePath)).isSymbolicLink()) return filePath;
@@ -220,6 +245,10 @@ function isFeatureDisabled(name, env = process.env) {
220
245
  if (trimmed === "") return false;
221
246
  return trimmed === "0" || trimmed.toLowerCase() === "false";
222
247
  }
248
+ function isTestSandbox(env = process.env) {
249
+ const raw = env.VITEST;
250
+ return raw !== void 0 && raw !== "";
251
+ }
223
252
 
224
253
  // src/upgrade-cmd.ts
225
254
  import { spawn as spawn2 } from "child_process";
@@ -230,12 +259,12 @@ import { join as join10 } from "path";
230
259
  import { spawn } from "child_process";
231
260
  import { accessSync, constants, existsSync as existsSync2, readdirSync as readdirSync2, readFileSync, statSync } from "fs";
232
261
  import { homedir as homedir4 } from "os";
233
- import { dirname as dirname2, isAbsolute as isAbsolute7, join as join9, sep } from "path";
262
+ import { dirname as dirname2, isAbsolute as isAbsolute8, join as join9, sep } from "path";
234
263
  import { fileURLToPath } from "url";
235
264
 
236
265
  // src/install-targets.ts
237
266
  import { homedir as homedir2 } from "os";
238
- import { isAbsolute as isAbsolute5, join as join8, resolve as resolve5 } from "path";
267
+ import { isAbsolute as isAbsolute6, join as join8, resolve as resolve6 } from "path";
239
268
 
240
269
  // src/client-config.ts
241
270
  import { existsSync } from "fs";
@@ -244,7 +273,61 @@ import { readFile } from "fs/promises";
244
273
  // src/client-config-json.ts
245
274
  import { parseTree as parseTree2 } from "jsonc-parser";
246
275
 
276
+ // src/client-config-values.ts
277
+ function isRecord(value) {
278
+ return typeof value === "object" && value !== null && !Array.isArray(value);
279
+ }
280
+ function stringMap(value) {
281
+ if (!isRecord(value)) return void 0;
282
+ const kept = {};
283
+ for (const [key, v] of Object.entries(value)) {
284
+ if (typeof v === "string") kept[key] = v;
285
+ }
286
+ return Object.keys(kept).length > 0 ? kept : void 0;
287
+ }
288
+ function normalizeEntry(stored, transform) {
289
+ return transform?.normalize === void 0 ? stored : transform.normalize(stored);
290
+ }
291
+ function launchOf(value) {
292
+ if (!isRecord(value)) return null;
293
+ const record = value;
294
+ if (typeof record.command !== "string") return null;
295
+ const args = Array.isArray(record.args) ? record.args.filter((a) => typeof a === "string") : [];
296
+ const env = stringMap(record.env);
297
+ return env === void 0 ? { command: record.command, args } : { command: record.command, args, env };
298
+ }
299
+ function positionAt(raw, offset) {
300
+ const clamped = Math.max(0, Math.min(offset, raw.length));
301
+ let line = 1;
302
+ let lineStart = 0;
303
+ for (let i = 0; i < clamped; i++) {
304
+ if (raw[i] === "\n") {
305
+ line++;
306
+ lineStart = i + 1;
307
+ }
308
+ }
309
+ return { offset: clamped, line, column: clamped - lineStart + 1 };
310
+ }
311
+ function canonicalJson(value) {
312
+ if (typeof value === "bigint") return value.toString();
313
+ if (value === null || typeof value !== "object") return JSON.stringify(value) ?? "null";
314
+ if (value instanceof Date) {
315
+ const iso = Number.isNaN(value.getTime()) ? "invalid" : value.toISOString();
316
+ return `{"$date":${JSON.stringify(iso)}}`;
317
+ }
318
+ if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
319
+ const record = value;
320
+ const keys = Object.keys(record).filter((key) => record[key] !== void 0).sort();
321
+ return `{${keys.map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`).join(",")}}`;
322
+ }
323
+ function describeValueShape(value) {
324
+ if (value === null) return "null";
325
+ if (Array.isArray(value)) return value.length === 0 ? "an empty array" : `an array of ${value.length}`;
326
+ return `a ${typeof value}`;
327
+ }
328
+
247
329
  // src/jsonc.ts
330
+ import * as jsoncParser from "jsonc-parser";
248
331
  import {
249
332
  applyEdits,
250
333
  createScanner,
@@ -258,7 +341,6 @@ function stripJsoncComments(src) {
258
341
  let i = 0;
259
342
  const len = src.length;
260
343
  let inString = false;
261
- let stringChar = "";
262
344
  while (i < len) {
263
345
  const c = src[i];
264
346
  if (inString) {
@@ -268,13 +350,12 @@ function stripJsoncComments(src) {
268
350
  i += 2;
269
351
  continue;
270
352
  }
271
- if (c === stringChar) inString = false;
353
+ if (c === '"') inString = false;
272
354
  i++;
273
355
  continue;
274
356
  }
275
- if (c === '"' || c === "'") {
357
+ if (c === '"') {
276
358
  inString = true;
277
- stringChar = c;
278
359
  out += c;
279
360
  i++;
280
361
  continue;
@@ -303,7 +384,6 @@ function stripTrailingCommas(src) {
303
384
  let i = 0;
304
385
  const len = src.length;
305
386
  let inString = false;
306
- let stringChar = "";
307
387
  while (i < len) {
308
388
  const c = src[i];
309
389
  if (inString) {
@@ -313,13 +393,12 @@ function stripTrailingCommas(src) {
313
393
  i += 2;
314
394
  continue;
315
395
  }
316
- if (c === stringChar) inString = false;
396
+ if (c === '"') inString = false;
317
397
  i++;
318
398
  continue;
319
399
  }
320
- if (c === '"' || c === "'") {
400
+ if (c === '"') {
321
401
  inString = true;
322
- stringChar = c;
323
402
  out += c;
324
403
  i++;
325
404
  continue;
@@ -348,13 +427,14 @@ var FORMATTING_OPTIONS = {
348
427
  tabSize: 2,
349
428
  eol: "\n"
350
429
  };
351
- var TOKEN_CLOSE_BRACE = 2;
352
- var TOKEN_CLOSE_BRACKET = 4;
353
- var TOKEN_COMMA = 5;
354
- var TOKEN_LINE_COMMENT = 12;
355
- var TOKEN_BLOCK_COMMENT = 13;
356
- var TOKEN_LINE_BREAK = 14;
357
- var TOKEN_WHITESPACE = 15;
430
+ var SYNTAX_KIND = jsoncParser.SyntaxKind;
431
+ var TOKEN_CLOSE_BRACE = SYNTAX_KIND.CloseBraceToken;
432
+ var TOKEN_CLOSE_BRACKET = SYNTAX_KIND.CloseBracketToken;
433
+ var TOKEN_COMMA = SYNTAX_KIND.CommaToken;
434
+ var TOKEN_LINE_COMMENT = SYNTAX_KIND.LineCommentTrivia;
435
+ var TOKEN_BLOCK_COMMENT = SYNTAX_KIND.BlockCommentTrivia;
436
+ var TOKEN_LINE_BREAK = SYNTAX_KIND.LineBreakTrivia;
437
+ var TOKEN_WHITESPACE = SYNTAX_KIND.Trivia;
358
438
  var isHorizontalSpace = (c) => c === " " || c === " ";
359
439
  var isLineBreak = (c) => c === "\n" || c === "\r";
360
440
  function lineStartOf(text, pos) {
@@ -668,23 +748,23 @@ var BOM = String.fromCharCode(65279);
668
748
  function stripBom(raw) {
669
749
  return raw.charCodeAt(0) === 65279 ? { text: raw.slice(1), had: true } : { text: raw, had: false };
670
750
  }
671
- function isRecord(value) {
751
+ function isRecord2(value) {
672
752
  return typeof value === "object" && value !== null && !Array.isArray(value);
673
753
  }
674
754
  function containerAt(root, segments) {
675
755
  let cursor = root;
676
756
  for (const key of segments) {
677
- if (!isRecord(cursor)) return null;
757
+ if (!isRecord2(cursor)) return null;
678
758
  cursor = cursor[key];
679
759
  }
680
- return isRecord(cursor) ? cursor : null;
760
+ return isRecord2(cursor) ? cursor : null;
681
761
  }
682
762
  function blockedSegment(root, segments) {
683
763
  let node = root;
684
764
  for (let i = 0; i < segments.length; i++) {
685
765
  const value = node[segments[i]];
686
766
  if (value === void 0) return null;
687
- if (isRecord(value)) {
767
+ if (isRecord2(value)) {
688
768
  node = value;
689
769
  continue;
690
770
  }
@@ -785,7 +865,7 @@ function classifyJson(raw, addr, transform, strict) {
785
865
  };
786
866
  }
787
867
  }
788
- if (!isRecord(parsed)) {
868
+ if (!isRecord2(parsed)) {
789
869
  return { kind: "malformed", syntax: "JSON", reason: "root", detail: describeValueShape(parsed), position: null };
790
870
  }
791
871
  const blocked = blockedSegment(parsed, addr.containerPath);
@@ -808,7 +888,7 @@ function removeJson(raw, addr, key) {
808
888
  } catch {
809
889
  return raw;
810
890
  }
811
- if (!isRecord(parsed)) return raw;
891
+ if (!isRecord2(parsed)) return raw;
812
892
  const container = containerAt(parsed, addr.containerPath);
813
893
  if (container === null || !Object.hasOwn(container, key)) return raw;
814
894
  return removeJsoncEntry(raw, [...addr.containerPath], key);
@@ -822,7 +902,7 @@ function previewJson(addr, key, entry, _creating) {
822
902
  }
823
903
  function canonJson(raw, addr, opts) {
824
904
  const parsed = parseJsonc(raw);
825
- if (!isRecord(parsed)) throw new Error("client-config-json: canon needs a JSON object");
905
+ if (!isRecord2(parsed)) throw new Error("client-config-json: canon needs a JSON object");
826
906
  const clone = JSON.parse(JSON.stringify(parsed));
827
907
  const segments = addr.containerPath;
828
908
  const leaf = segments[segments.length - 1];
@@ -832,7 +912,7 @@ function canonJson(raw, addr, opts) {
832
912
  for (let i = 0; i < segments.length; i++) {
833
913
  cut = i;
834
914
  const value = holder[segments[i]];
835
- if (!isRecord(value) || i === segments.length - 1) break;
915
+ if (!isRecord2(value) || i === segments.length - 1) break;
836
916
  holder = value;
837
917
  }
838
918
  delete holder[segments[cut]];
@@ -840,13 +920,13 @@ function canonJson(raw, addr, opts) {
840
920
  const above = containerAt(clone, segments.slice(0, depth - 1));
841
921
  const key = segments[depth - 1];
842
922
  const value = above === null ? void 0 : above[key];
843
- if (above === null || !isRecord(value) || Object.keys(value).length > 0) break;
923
+ if (above === null || !isRecord2(value) || Object.keys(value).length > 0) break;
844
924
  delete above[key];
845
925
  }
846
926
  } else if (leaf !== void 0) {
847
927
  const parent = containerAt(clone, segments.slice(0, -1));
848
928
  const container = parent === null ? void 0 : parent[leaf];
849
- if (isRecord(container)) {
929
+ if (isRecord2(container)) {
850
930
  for (const key of opts?.drop ?? []) delete container[key];
851
931
  }
852
932
  }
@@ -917,53 +997,19 @@ function selectSites(sites, exists = existsSync) {
917
997
  function addressOf(site) {
918
998
  return { format: site.format, containerPath: site.resolved.containerPath };
919
999
  }
920
- function positionAt(raw, offset) {
921
- const clamped = Math.max(0, Math.min(offset, raw.length));
922
- let line = 1;
923
- let lineStart = 0;
924
- for (let i = 0; i < clamped; i++) {
925
- if (raw[i] === "\n") {
926
- line++;
927
- lineStart = i + 1;
928
- }
929
- }
930
- return { offset: clamped, line, column: clamped - lineStart + 1 };
931
- }
932
1000
  function unloadableConfigProblem(v) {
933
1001
  return `has comments or trailing commas, which its client reads as invalid ${v.syntax} (${v.detail}), so no server in it is loading`;
934
1002
  }
935
1003
  function unloadableConfigFix(then) {
936
1004
  return `remove the comments and trailing commas, or move the file aside, then ${then}`;
937
1005
  }
938
- function isRecord2(value) {
939
- return typeof value === "object" && value !== null && !Array.isArray(value);
940
- }
941
- function normalizeEntry(stored, transform) {
942
- return transform?.normalize === void 0 ? stored : transform.normalize(stored);
943
- }
944
- function launchOf(value) {
945
- if (!isRecord2(value)) return null;
946
- const record = value;
947
- if (typeof record.command !== "string") return null;
948
- const args = Array.isArray(record.args) ? record.args.filter((a) => typeof a === "string") : [];
949
- const env = stringMap(record.env);
950
- return env === void 0 ? { command: record.command, args } : { command: record.command, args, env };
951
- }
952
- function stringMap(value) {
953
- if (!isRecord2(value)) return void 0;
954
- const kept = {};
955
- for (const [key, v] of Object.entries(value)) {
956
- if (typeof v === "string") kept[key] = v;
957
- }
958
- return Object.keys(kept).length > 0 ? kept : void 0;
959
- }
960
1006
  function carryableEnvOf(stored) {
961
- if (!isRecord2(stored)) return void 0;
1007
+ if (!isRecord(stored)) return void 0;
962
1008
  return stringMap(stored.env);
963
1009
  }
964
1010
  function carriedFieldsOf(stored, transform) {
965
1011
  if (transform?.carry === void 0) return {};
966
- if (!isRecord2(stored)) return {};
1012
+ if (!isRecord(stored)) return {};
967
1013
  const carried = { ...transform.carry(stored) };
968
1014
  delete carried.env;
969
1015
  return carried;
@@ -971,7 +1017,7 @@ function carriedFieldsOf(stored, transform) {
971
1017
  function importViewOf(stored, transform) {
972
1018
  if (transform?.forImport !== void 0) return transform.forImport(stored);
973
1019
  const normalized = normalizeEntry(stored, transform);
974
- return { entry: isRecord2(normalized) ? normalized : stored };
1020
+ return { entry: isRecord(normalized) ? normalized : stored };
975
1021
  }
976
1022
  function composeEntry(opts) {
977
1023
  const extra = opts.transform?.extraFields?.({ os: opts.os, purpose: opts.purpose }) ?? {};
@@ -1026,24 +1072,12 @@ function adapterFor(format) {
1026
1072
  if (adapter === void 0) throw new MissingConfigAdapterError(format);
1027
1073
  return adapter;
1028
1074
  }
1029
- function canonicalJson(value) {
1030
- if (typeof value === "bigint") return value.toString();
1031
- if (value === null || typeof value !== "object") return JSON.stringify(value) ?? "null";
1032
- if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
1033
- const record = value;
1034
- const keys = Object.keys(record).filter((key) => record[key] !== void 0).sort();
1035
- return `{${keys.map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`).join(",")}}`;
1036
- }
1037
- function describeValueShape(value) {
1038
- if (value === null) return "null";
1039
- if (Array.isArray(value)) return value.length === 0 ? "an empty array" : `an array of ${value.length}`;
1040
- return `a ${typeof value}`;
1041
- }
1042
1075
  function detectLineEnding(text) {
1043
1076
  const match = /\r\n|\n|\r/.exec(text);
1044
1077
  return match === null ? "\n" : match[0];
1045
1078
  }
1046
1079
  function terminateWithNewline(text) {
1080
+ if (text === "") return text;
1047
1081
  if (text.endsWith("\n")) return text;
1048
1082
  const eol = detectLineEnding(text);
1049
1083
  if (text.endsWith("\r")) return eol === "\r" ? text : `${text}
@@ -1267,6 +1301,14 @@ function applyClientConfigEdits(view, edits, site) {
1267
1301
  }
1268
1302
  } else if (read.kind !== "ok") {
1269
1303
  throw new ClientConfigWriteError(refusalFor(read, where, edits));
1304
+ } else {
1305
+ for (const edit of edits) {
1306
+ if (edit.op !== "upsert" && edit.op !== "remove") continue;
1307
+ const stuck = read.unspliceableEntries?.find((e) => e.key === edit.key);
1308
+ if (stuck !== void 0) {
1309
+ throw new ClientConfigWriteError(refusalFor({ kind: "unspliceable", ...stuck }, where, edits));
1310
+ }
1311
+ }
1270
1312
  }
1271
1313
  const unloadable = view.unloadable();
1272
1314
  if (unloadable !== null && writes) {
@@ -1300,7 +1342,8 @@ function refusalFor(read, where, edits) {
1300
1342
  return read.reason === "root" ? `${where} is not a ${read.syntax} object (it is ${read.detail})` : `${where} is not valid ${read.syntax}${at} (${read.detail})`;
1301
1343
  }
1302
1344
  if (read.kind === "unspliceable") {
1303
- return `the "${read.key}" entry in ${where} is ${read.reason}, so yaw-mcp will not edit it`;
1345
+ const fix = read.fix === void 0 ? "" : `; ${read.fix}, then re-run`;
1346
+ return `the "${read.key}" entry in ${where} is ${read.reason}, so yaw-mcp will not edit it${fix}`;
1304
1347
  }
1305
1348
  if (read.kind === "blocked") {
1306
1349
  const key = read.path.join(".");
@@ -1338,7 +1381,7 @@ function verifyEdits(adapter, address, before, after, edits, where, view) {
1338
1381
  }
1339
1382
  const keptBefore = view.entries().filter((e) => !touched.has(e.key));
1340
1383
  const keptAfter = reread.entries.filter((e) => !touched.has(e.key));
1341
- if (keptAfter.map((e) => e.key).join(" ") !== keptBefore.map((e) => e.key).join(" ")) {
1384
+ if (keptAfter.map((e) => e.key).join("\0") !== keptBefore.map((e) => e.key).join("\0")) {
1342
1385
  throw new ClientConfigWriteError(
1343
1386
  `writing to ${where} would have changed which other servers it holds, or their order -- nothing was written`
1344
1387
  );
@@ -1353,7 +1396,8 @@ function verifyEdits(adapter, address, before, after, edits, where, view) {
1353
1396
  for (const edit of edits) {
1354
1397
  if (edit.op === "upsert") {
1355
1398
  const written = reread.entries.find((e) => e.key === edit.key);
1356
- if (written === void 0 || canonicalJson(written.value) !== canonicalJson(edit.entry)) {
1399
+ const expected = adapter.entryAsWritten === void 0 ? edit.entry : adapter.entryAsWritten(edit.entry);
1400
+ if (written === void 0 || canonicalJson(written.value) !== canonicalJson(expected)) {
1357
1401
  throw new ClientConfigWriteError(
1358
1402
  `the "${edit.key}" entry did not read back from ${where} as it was written -- nothing was written`
1359
1403
  );
@@ -1519,7 +1563,7 @@ function readClientEnv(env = process.env) {
1519
1563
  }
1520
1564
 
1521
1565
  // src/target-cline.ts
1522
- import { join as join2 } from "path";
1566
+ import { isAbsolute, join as join2, resolve } from "path";
1523
1567
  var CLINE_EXTENSION_ID = "saoudrizwan.claude-dev";
1524
1568
  var SETTINGS_FILE = "cline_mcp_settings.json";
1525
1569
  var CLINE_HOSTS = [
@@ -1549,16 +1593,20 @@ function sharedSettingsFile(base) {
1549
1593
  const t = v?.trim();
1550
1594
  return t && t.length > 0 ? t : void 0;
1551
1595
  };
1596
+ const absolutized = (v) => isAbsolute(v) ? v : resolve(v);
1552
1597
  const exact = trimmed(base.env.clineMcpSettingsPath);
1553
- if (exact) return { absolute: exact, display: exact };
1598
+ if (exact) {
1599
+ const absolute = absolutized(exact);
1600
+ return { absolute, display: absolute };
1601
+ }
1554
1602
  const dataDir = trimmed(base.env.clineDataDir);
1555
1603
  if (dataDir) {
1556
- const absolute = join2(dataDir, "settings", SETTINGS_FILE);
1604
+ const absolute = join2(absolutized(dataDir), "settings", SETTINGS_FILE);
1557
1605
  return { absolute, display: absolute };
1558
1606
  }
1559
1607
  const clineDir = trimmed(base.env.clineDir);
1560
1608
  if (clineDir) {
1561
- const absolute = join2(clineDir, "data", "settings", SETTINGS_FILE);
1609
+ const absolute = join2(absolutized(clineDir), "data", "settings", SETTINGS_FILE);
1562
1610
  return { absolute, display: absolute };
1563
1611
  }
1564
1612
  return {
@@ -1657,7 +1705,7 @@ var CLINE_TARGET = defineTarget({
1657
1705
  });
1658
1706
 
1659
1707
  // src/target-codex-cli.ts
1660
- import { isAbsolute, join as join3, resolve } from "path";
1708
+ import { isAbsolute as isAbsolute2, join as join3, resolve as resolve2 } from "path";
1661
1709
 
1662
1710
  // src/client-config-toml.ts
1663
1711
  import { parse as parseTomlText, TomlDate, TomlError } from "smol-toml";
@@ -2189,10 +2237,10 @@ function readTomlConfig(raw, containerPath, entryNames = []) {
2189
2237
  return {
2190
2238
  kind: "malformed",
2191
2239
  syntax: TOML_SYNTAX,
2192
- reason: e.reason,
2240
+ detail: e.reason,
2193
2241
  line: e.line,
2194
2242
  column: e.column,
2195
- detail: e.detail
2243
+ positioned: e.detail
2196
2244
  };
2197
2245
  }
2198
2246
  throw e;
@@ -2219,14 +2267,7 @@ function readTomlConfig(raw, containerPath, entryNames = []) {
2219
2267
  for (const name of entryNames) {
2220
2268
  const problem = entryShapeProblem(scan, parsed, containerPath, name);
2221
2269
  if (problem !== null) {
2222
- return {
2223
- kind: "unspliceable",
2224
- key: name,
2225
- shape: problem.shape,
2226
- remedy: problem.remedy,
2227
- fix: problem.fix,
2228
- removable: problem.removable
2229
- };
2270
+ return { kind: "unspliceable", key: name, shape: problem.shape, remedy: problem.remedy, fix: problem.fix };
2230
2271
  }
2231
2272
  }
2232
2273
  const entries = Object.keys(cursor).map((key) => ({ key, value: cursor[key] }));
@@ -2255,8 +2296,7 @@ function entryShapeProblem(scan, parsed, containerPath, name) {
2255
2296
  return {
2256
2297
  shape: `an array of tables ([[${entryPath.map(tomlKey).join(".")}]])`,
2257
2298
  remedy: `Codex reads a server as a single table, so make it one ${headerLabel} table (or remove it), then re-run`,
2258
- fix: `rewrite it by hand as a single ${headerLabel} table (or delete it)`,
2259
- removable: true
2299
+ fix: `rewrite it by hand as a single ${headerLabel} table (or delete it)`
2260
2300
  };
2261
2301
  }
2262
2302
  if (own.length > 0) return null;
@@ -2267,41 +2307,36 @@ function entryShapeProblem(scan, parsed, containerPath, name) {
2267
2307
  if (rootDotted) {
2268
2308
  return {
2269
2309
  shape: `written as dotted keys at the top level (${entryPath.join(".")}.command = ...)`,
2270
- remedy: `only a ${headerLabel} table can be rewritten in place -- replace those lines with the table below by hand (or delete them and re-run)`,
2271
- fix: `move those lines by hand into a ${headerLabel} table at the end of the file (or delete them)`,
2272
- removable: false
2310
+ remedy: `only a ${headerLabel} table can be rewritten in place -- move those lines by hand into a ${headerLabel} table at the end of the file (or delete them), then re-run`,
2311
+ fix: `move those lines by hand into a ${headerLabel} table at the end of the file (or delete them)`
2273
2312
  };
2274
2313
  }
2275
2314
  const inContainer = scan.assignments.filter((a) => pathEquals(a.section, containerPath) && a.keyPath[0] === name);
2276
2315
  if (inContainer.some((a) => a.keyPath.length > 1)) {
2277
2316
  return {
2278
2317
  shape: `written as dotted keys under [${containerLabel}] (${name}.command = ...)`,
2279
- remedy: `only a ${headerLabel} table can be rewritten in place -- replace those lines with the table below by hand (or delete them and re-run)`,
2280
- fix: `move those lines by hand into a ${headerLabel} table at the end of the file (or delete them)`,
2281
- removable: false
2318
+ remedy: `only a ${headerLabel} table can be rewritten in place -- move those lines by hand into a ${headerLabel} table at the end of the file (or delete them), then re-run`,
2319
+ fix: `move those lines by hand into a ${headerLabel} table at the end of the file (or delete them)`
2282
2320
  };
2283
2321
  }
2284
2322
  if (inContainer.some((a) => a.inlineTable)) {
2285
2323
  return {
2286
2324
  shape: `an inline table under [${containerLabel}] (${name} = { ... })`,
2287
- remedy: `only a ${headerLabel} table can be rewritten in place -- replace that line with the table below by hand (or delete it and re-run)`,
2288
- fix: `move that line by hand into a ${headerLabel} table at the end of the file (or delete it)`,
2289
- removable: false
2325
+ remedy: `only a ${headerLabel} table can be rewritten in place -- move that line by hand into a ${headerLabel} table at the end of the file (or delete it), then re-run`,
2326
+ fix: `move that line by hand into a ${headerLabel} table at the end of the file (or delete it)`
2290
2327
  };
2291
2328
  }
2292
2329
  if (rootContainerIsInline(scan, containerPath)) {
2293
2330
  return {
2294
2331
  shape: `inside the inline table ${containerLabel} = { ... }`,
2295
2332
  remedy: `TOML cannot extend an inline table with a later table, so convert it to ${headerLabel}-style tables by hand, then re-run`,
2296
- fix: `convert the inline ${containerLabel} = { ... } to ${headerLabel}-style tables by hand`,
2297
- removable: false
2333
+ fix: `convert the inline ${containerLabel} = { ... } to ${headerLabel}-style tables by hand`
2298
2334
  };
2299
2335
  }
2300
2336
  return {
2301
2337
  shape: `not written as a ${headerLabel} table`,
2302
- remedy: `only a ${headerLabel} table can be rewritten in place -- replace it with the table below by hand (or delete it and re-run)`,
2303
- fix: `move it by hand into a ${headerLabel} table at the end of the file (or delete it)`,
2304
- removable: false
2338
+ remedy: `only a ${headerLabel} table can be rewritten in place -- move it by hand into a ${headerLabel} table at the end of the file (or delete it), then re-run`,
2339
+ fix: `move it by hand into a ${headerLabel} table at the end of the file (or delete it)`
2305
2340
  };
2306
2341
  }
2307
2342
  function entryExistsInParsed(parsed, entryPath) {
@@ -2354,8 +2389,7 @@ function deleteSectionEdits(text, sections) {
2354
2389
  return { start, end, text: "" };
2355
2390
  });
2356
2391
  }
2357
- function upsertTomlEntry(raw, containerPath, name, entry, options = {}) {
2358
- const legacyNames = options.replaceLegacy ?? [];
2392
+ function upsertTomlEntry(raw, containerPath, name, entry) {
2359
2393
  if (raw === null || raw.trim() === "") {
2360
2394
  const fresh = renderTomlEntry(containerPath, name, entry, raw === null ? "\n" : detectTomlEol(raw));
2361
2395
  verifyTomlSplice("", fresh, containerPath, { upsert: { name, entry } });
@@ -2374,24 +2408,16 @@ function upsertTomlEntry(raw, containerPath, name, entry, options = {}) {
2374
2408
  );
2375
2409
  }
2376
2410
  const scan = scanTomlSections(raw);
2377
- refuseUnspliceable(scan, parsed, containerPath, [name, ...legacyNames]);
2411
+ refuseUnspliceable(scan, parsed, containerPath, [name]);
2378
2412
  const eol = scan.eol;
2379
2413
  const block = renderTomlEntry(containerPath, name, entry, eol);
2380
2414
  const entryPath = [...containerPath, name];
2381
2415
  const edits = [];
2382
2416
  const ownSections = scan.sections.filter((s) => pathStartsWith(s.keyPath, entryPath));
2383
- const legacySections = legacyNames.flatMap(
2384
- (legacy) => scan.sections.filter((s) => pathStartsWith(s.keyPath, [...containerPath, legacy]))
2385
- );
2386
- const anchor = ownSections[0] ?? legacySections[0];
2417
+ const anchor = ownSections[0];
2387
2418
  if (anchor !== void 0) {
2388
2419
  edits.push({ start: anchor.start, end: anchor.contentEnd, text: block });
2389
- edits.push(
2390
- ...deleteSectionEdits(
2391
- raw,
2392
- [...ownSections, ...legacySections].filter((s) => s !== anchor)
2393
- )
2394
- );
2420
+ edits.push(...deleteSectionEdits(raw, ownSections.slice(1)));
2395
2421
  } else {
2396
2422
  if (rootContainerIsInline(scan, containerPath)) {
2397
2423
  throw new TomlSpliceRefusal(
@@ -2403,7 +2429,7 @@ function upsertTomlEntry(raw, containerPath, name, entry, options = {}) {
2403
2429
  edits.push(insertEdit(raw, scan, containerPath, block, eol));
2404
2430
  }
2405
2431
  const next = applyEdits2(raw, edits);
2406
- verifyTomlSplice(raw, next, containerPath, { upsert: { name, entry }, removed: legacyNames });
2432
+ verifyTomlSplice(raw, next, containerPath, { upsert: { name, entry } });
2407
2433
  return next;
2408
2434
  }
2409
2435
  function removeTomlEntry(raw, containerPath, name) {
@@ -2501,7 +2527,7 @@ function verifyTomlSplice(before, after, containerPath, expectation = {}) {
2501
2527
  throw new TomlVerifyError(`the edited text does not parse as TOML (${e.message})`);
2502
2528
  }
2503
2529
  if (afterRead.kind === "malformed") {
2504
- throw new TomlVerifyError(`the edited text does not parse as TOML (${afterRead.detail})`);
2530
+ throw new TomlVerifyError(`the edited text does not parse as TOML (${afterRead.positioned})`);
2505
2531
  }
2506
2532
  if (afterRead.kind === "blocked") {
2507
2533
  throw new TomlVerifyError(`the edit left "${afterRead.path.join(".")}" as ${afterRead.shape}, not a table`);
@@ -2631,6 +2657,15 @@ function tomlPosition(raw, line, column) {
2631
2657
  return { offset: Math.min(offset + column - 1, raw.length), line, column };
2632
2658
  }
2633
2659
  var SPLICEABLE_NAMES = [ENTRY_NAME];
2660
+ function legacyUnspliceable(raw, containerPath, read) {
2661
+ const out = [];
2662
+ for (const legacy of LEGACY_ENTRY_NAMES) {
2663
+ if (!read.entries.some((e) => e.key === legacy)) continue;
2664
+ const probe = readTomlConfig(raw, containerPath, [legacy]);
2665
+ if (probe.kind === "unspliceable") out.push({ key: probe.key, reason: probe.shape, fix: probe.fix });
2666
+ }
2667
+ return out;
2668
+ }
2634
2669
  function entryViewsOf(read, transform) {
2635
2670
  if (read.kind !== "ok") return [];
2636
2671
  return read.entries.map(({ key, value }) => ({ key, value, launch: launchOf(normalizeEntry(value, transform)) }));
@@ -2645,7 +2680,7 @@ function classifyToml(raw, addr, transform) {
2645
2680
  kind: "malformed",
2646
2681
  syntax: TOML_SYNTAX,
2647
2682
  reason: "syntax",
2648
- detail: read.reason,
2683
+ detail: read.detail,
2649
2684
  position: tomlPosition(raw, read.line, read.column)
2650
2685
  };
2651
2686
  case "blocked":
@@ -2655,7 +2690,8 @@ function classifyToml(raw, addr, transform) {
2655
2690
  return { kind: "blocked", path: read.path, shape: read.shape, reparable: false, unloadable: null };
2656
2691
  case "unspliceable":
2657
2692
  return { kind: "unspliceable", key: read.key, reason: read.shape, fix: read.fix };
2658
- default:
2693
+ default: {
2694
+ const unspliceableEntries = legacyUnspliceable(raw, addr.containerPath, read);
2659
2695
  return {
2660
2696
  kind: "ok",
2661
2697
  containerPresent: read.containerPresent,
@@ -2663,8 +2699,10 @@ function classifyToml(raw, addr, transform) {
2663
2699
  unloadable: null,
2664
2700
  ...read.containerUnspliceable === null ? {} : {
2665
2701
  containerUnspliceable: { reason: read.containerUnspliceable.shape, fix: read.containerUnspliceable.fix }
2666
- }
2702
+ },
2703
+ ...unspliceableEntries.length === 0 ? {} : { unspliceableEntries }
2667
2704
  };
2705
+ }
2668
2706
  }
2669
2707
  }
2670
2708
  function upsertToml(raw, addr, key, entry) {
@@ -2706,7 +2744,10 @@ var TOML_ADAPTER = {
2706
2744
  // The two root-key methods: what lets a TOML row declare a top-level
2707
2745
  // default (`ConfigShape.rootDefaults`). The JSON family implements neither.
2708
2746
  readRootKey: readTomlRoot,
2709
- insertRootKey: insertTomlRoot
2747
+ insertRootKey: insertTomlRoot,
2748
+ // The renderer's own omissions (an empty `env: {}` writes no sub-table), so
2749
+ // the facade's read-back check compares against what this syntax writes.
2750
+ entryAsWritten
2710
2751
  };
2711
2752
  registerConfigAdapter("toml", TOML_ADAPTER);
2712
2753
  function resolveCodexPath(base) {
@@ -2719,9 +2760,9 @@ function resolveCodexPath(base) {
2719
2760
  containerPath
2720
2761
  };
2721
2762
  }
2722
- const codexHome = base.env.codexHome;
2763
+ const codexHome = base.env.codexHome?.trim();
2723
2764
  if (codexHome !== void 0 && codexHome.length > 0) {
2724
- const absolute = join3(isAbsolute(codexHome) ? codexHome : resolve(codexHome), "config.toml");
2765
+ const absolute = join3(isAbsolute2(codexHome) ? codexHome : resolve2(codexHome), "config.toml");
2725
2766
  return { absolute, display: absolute, containerPath };
2726
2767
  }
2727
2768
  return {
@@ -2741,7 +2782,7 @@ function isEnvVarItem(item) {
2741
2782
  }
2742
2783
  function carryCodexFields(stored) {
2743
2784
  const out = {};
2744
- if (Array.isArray(stored.env_vars) && stored.env_vars.length > 0 && stored.env_vars.every(isEnvVarItem)) {
2785
+ if (Array.isArray(stored.env_vars) && stored.env_vars.every(isEnvVarItem)) {
2745
2786
  out.env_vars = [...stored.env_vars];
2746
2787
  }
2747
2788
  if (typeof stored.enabled === "boolean") out.enabled = stored.enabled;
@@ -2855,17 +2896,18 @@ var CODEX_CLI_TARGET = defineTarget({
2855
2896
  });
2856
2897
 
2857
2898
  // src/target-continue.ts
2858
- import { isAbsolute as isAbsolute2, join as join4, resolve as resolve2 } from "path";
2899
+ import { isAbsolute as isAbsolute3, join as join4, resolve as resolve3 } from "path";
2859
2900
  var CONTINUE_FILE = "yaw-mcp.json";
2860
2901
  function continueGlobalDir(base) {
2861
- const raw = base.env.continueGlobalDir;
2902
+ const raw = base.env.continueGlobalDir?.trim();
2862
2903
  if (raw && raw.length > 0) {
2863
- const dir = isAbsolute2(raw) ? raw : resolve2(raw);
2864
- return { dir, display: dir };
2904
+ const dir = isAbsolute3(raw) ? raw : resolve3(raw);
2905
+ return { dir, display: dir, envDirected: true };
2865
2906
  }
2866
2907
  return {
2867
2908
  dir: join4(base.home, ".continue"),
2868
- display: base.os === "windows" ? "%USERPROFILE%\\.continue" : "~/.continue"
2909
+ display: base.os === "windows" ? "%USERPROFILE%\\.continue" : "~/.continue",
2910
+ envDirected: false
2869
2911
  };
2870
2912
  }
2871
2913
  function resolveContinuePath(base) {
@@ -2879,7 +2921,7 @@ function resolveContinuePath(base) {
2879
2921
  }
2880
2922
  const global = continueGlobalDir(base);
2881
2923
  const absolute = join4(global.dir, "mcpServers", CONTINUE_FILE);
2882
- const display = global.display === global.dir ? absolute : [global.display, "mcpServers", CONTINUE_FILE].join(sep3);
2924
+ const display = global.envDirected ? absolute : [global.display, "mcpServers", CONTINUE_FILE].join(sep3);
2883
2925
  return { absolute, display, containerPath: ["mcpServers"] };
2884
2926
  }
2885
2927
  var CONTINUE_TARGET = defineTarget({
@@ -2919,17 +2961,21 @@ var CONTINUE_TARGET = defineTarget({
2919
2961
  });
2920
2962
 
2921
2963
  // src/target-typed.ts
2922
- import { isAbsolute as isAbsolute3, join as join5, resolve as resolve3 } from "path";
2964
+ import { isAbsolute as isAbsolute4, join as join5, resolve as resolve4 } from "path";
2923
2965
  var CONTAINER_KEY2 = "mcpServers";
2924
2966
  var WINDOWS_SEP = String.fromCharCode(92);
2925
2967
  var DEFAULT_BUNDLE_SEGMENTS = [".config", "typed", "typed-cli", "cli.mjs"];
2968
+ function typedCliBundleOverride(base) {
2969
+ const trimmed = base.env.typedCliBundle?.trim();
2970
+ return trimmed !== void 0 && trimmed.length > 0 ? trimmed : void 0;
2971
+ }
2926
2972
  function typedCliBundle(base) {
2927
- const override = base.env.typedCliBundle;
2928
- if (override !== void 0) return isAbsolute3(override) ? override : resolve3(override);
2973
+ const override = typedCliBundleOverride(base);
2974
+ if (override !== void 0) return isAbsolute4(override) ? override : resolve4(override);
2929
2975
  return join5(base.home, ...DEFAULT_BUNDLE_SEGMENTS);
2930
2976
  }
2931
2977
  function staleTypedCliWarning(bundle, base) {
2932
- return base.env.typedCliBundle !== void 0 ? `the typed CLI bundle at ${bundle} (TYPED_CLI_BUNDLE) predates ~/.config/typed/mcp.json, so that typed will not load this entry until the bundle is rebuilt or replaced -- \`typed update\` updates only the default ~/.config/typed/typed-cli/cli.mjs.` : `the typed CLI at ${bundle} predates ~/.config/typed/mcp.json, so it will not load this entry until it updates -- run \`typed update\`.`;
2978
+ return typedCliBundleOverride(base) !== void 0 ? `the typed CLI bundle at ${bundle} (TYPED_CLI_BUNDLE) predates ~/.config/typed/mcp.json, so that typed will not load this entry until the bundle is rebuilt or replaced -- \`typed update\` updates only the default ~/.config/typed/typed-cli/cli.mjs.` : `the typed CLI at ${bundle} predates ~/.config/typed/mcp.json, so it will not load this entry until it updates -- run \`typed update\`.`;
2933
2979
  }
2934
2980
  function resolveTypedPath(base) {
2935
2981
  return underHome(base, [".config", "typed", "mcp.json"]);
@@ -2988,13 +3034,13 @@ var TYPED_TARGET = defineTarget({
2988
3034
  });
2989
3035
 
2990
3036
  // src/target-zed.ts
2991
- import { isAbsolute as isAbsolute4, join as join6 } from "path";
3037
+ import { isAbsolute as isAbsolute5, join as join6 } from "path";
2992
3038
  function zedConfigDir(base) {
2993
3039
  if (base.os === "windows") {
2994
3040
  return { dir: join6(base.appData, "Zed"), display: "%APPDATA%\\Zed" };
2995
3041
  }
2996
- const xdg = base.env.xdgConfigHome;
2997
- if (base.os === "linux" && xdg && isAbsolute4(xdg)) {
3042
+ const xdg = base.env.xdgConfigHome?.trim();
3043
+ if (base.os === "linux" && xdg && isAbsolute5(xdg)) {
2998
3044
  return { dir: join6(xdg, "zed"), display: `$XDG_CONFIG_HOME/zed` };
2999
3045
  }
3000
3046
  return { dir: join6(base.home, ".config", "zed"), display: "~/.config/zed" };
@@ -3060,7 +3106,7 @@ var ZED_TARGET = defineTarget({
3060
3106
 
3061
3107
  // src/claude-code-settings.ts
3062
3108
  import { readFile as readFile2, stat as stat2 } from "fs/promises";
3063
- import { basename, join as join7, resolve as resolve4 } from "path";
3109
+ import { basename, join as join7, resolve as resolve5 } from "path";
3064
3110
  var CLAUDE_CODE_ALLOW_PATTERN = "mcp__mcp__*";
3065
3111
  function resolveClaudeCodeSettingsPath(scope, opts) {
3066
3112
  const { home, projectDir, claudeConfigDir } = opts;
@@ -3074,7 +3120,7 @@ function yawModeOverlay(opts) {
3074
3120
  if (opts.yawMode !== "augment" && opts.yawMode !== "fresh") return null;
3075
3121
  const dir = opts.claudeConfigDir;
3076
3122
  if (dir === void 0 || dir.length === 0) return null;
3077
- return basename(resolve4(dir)).startsWith(YAW_MODE_OVERLAY_PREFIX) ? opts.yawMode : null;
3123
+ return basename(resolve5(dir)).startsWith(YAW_MODE_OVERLAY_PREFIX) ? opts.yawMode : null;
3078
3124
  }
3079
3125
  var YAW_MODE_OVERLAY_PREFIX = "yaw-mode-";
3080
3126
  function mergePermissionsAllow(existing, patterns) {
@@ -3425,7 +3471,7 @@ function resolveTargetBase(opts) {
3425
3471
  if (scopeSpec.requiresProjectDir && !projectDir) {
3426
3472
  throw new Error(`Scope ${scope} for ${clientId} requires a project directory`);
3427
3473
  }
3428
- const absoluteProjectDir = projectDir && !isAbsolute5(projectDir) ? resolve5(projectDir) : projectDir;
3474
+ const absoluteProjectDir = projectDir && !isAbsolute6(projectDir) ? resolve6(projectDir) : projectDir;
3429
3475
  const cfgDir = claudeConfigDir && claudeConfigDir.length > 0 ? claudeConfigDir : void 0;
3430
3476
  const env = { ...opts.clientEnv, ...cfgDir ? { claudeConfigDir: cfgDir } : {} };
3431
3477
  const base = {
@@ -3483,6 +3529,17 @@ function claudeCodeContainerPathVariants(containerPath, keysAt) {
3483
3529
  }
3484
3530
  return out;
3485
3531
  }
3532
+ function claudeCodeProjectSites(site, keysAt) {
3533
+ const containerPath = site.resolved.containerPath;
3534
+ if (containerPath.length < 2 || containerPath[0] !== PROJECTS_KEY) return [site];
3535
+ const tail = containerPath.slice(2);
3536
+ const out = [site];
3537
+ for (const key of keysAt([PROJECTS_KEY])) {
3538
+ if (key === containerPath[1]) continue;
3539
+ out.push(siteAt(site, [PROJECTS_KEY, key, ...tail]));
3540
+ }
3541
+ return out;
3542
+ }
3486
3543
  function pathFor(client, scope, os, base) {
3487
3544
  const { home, appData, projectDir, claudeConfigDir } = base;
3488
3545
  const sep3 = os === "windows" ? "\\" : "/";
@@ -3589,7 +3646,8 @@ function pathFor(client, scope, os, base) {
3589
3646
  containerPath: ["mcpServers"]
3590
3647
  };
3591
3648
  }
3592
- throw new Error(`Unhandled client: ${client}`);
3649
+ const unhandled = client;
3650
+ throw new Error(`Unhandled client: ${String(unhandled)}`);
3593
3651
  }
3594
3652
  var CMD_METACHARS = /[&|<>^()]/g;
3595
3653
  var HAS_CMD_METACHAR = /[&|<>^()]/;
@@ -3655,13 +3713,16 @@ function buildLaunchEntry(opts) {
3655
3713
  return entry;
3656
3714
  }
3657
3715
  const pkg = opts.pkg ?? "@yawlabs/mcp@latest";
3658
- if (opts.oamBinPath && isAbsolute5(opts.oamBinPath) && opts.oamEntry && !opts.pkg) {
3716
+ if (opts.oamBinPath && isAbsolute6(opts.oamBinPath) && opts.oamEntry && !opts.pkg) {
3659
3717
  return { command: opts.oamBinPath, args: ["run", "--no-check", opts.oamEntry] };
3660
3718
  }
3661
3719
  return opts.os === "windows" && opts.windowsWrap !== false ? { command: "cmd", args: ["/c", "npx", "-y", pkg] } : { command: "npx", args: ["-y", pkg] };
3662
3720
  }
3663
- function isProjectLocalEntry(entryPath, cwd) {
3664
- const norm = (p) => p.replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();
3721
+ function isProjectLocalEntry(entryPath, cwd, platform = process.platform) {
3722
+ const norm = (p) => {
3723
+ const slashed = p.replace(/\\/g, "/").replace(/\/+$/, "");
3724
+ return platform === "win32" ? slashed.toLowerCase() : slashed;
3725
+ };
3665
3726
  const entry = norm(entryPath);
3666
3727
  const here = norm(cwd);
3667
3728
  const idx = entry.indexOf("/node_modules/");
@@ -3761,7 +3822,15 @@ function isUnderHome(dir, homeResolved) {
3761
3822
  return rel !== ".." && !rel.startsWith(`..${path2.sep}`);
3762
3823
  }
3763
3824
  var ALLOW_UNOWNED_ENV = "YAW_MCP_ALLOW_UNOWNED_PROJECT_DIRS";
3825
+ var WARNED_UNTRUSTED_DIRS_CAP = 256;
3764
3826
  var warnedUntrustedDirs = /* @__PURE__ */ new Set();
3827
+ function rememberWarnedUntrustedDir(candidate) {
3828
+ if (warnedUntrustedDirs.size >= WARNED_UNTRUSTED_DIRS_CAP) {
3829
+ const oldest = warnedUntrustedDirs.values().next().value;
3830
+ if (oldest !== void 0) warnedUntrustedDirs.delete(oldest);
3831
+ }
3832
+ warnedUntrustedDirs.add(candidate);
3833
+ }
3765
3834
  function ownedByCurrentUser(st, env) {
3766
3835
  const geteuid = process.geteuid;
3767
3836
  if (typeof geteuid !== "function") return env[ALLOW_UNOWNED_ENV] === "1";
@@ -3787,7 +3856,7 @@ async function findProjectConfigDir(start, home = homedir3(), env = process.env)
3787
3856
  return candidate;
3788
3857
  } else {
3789
3858
  if (!warnedUntrustedDirs.has(candidate)) {
3790
- warnedUntrustedDirs.add(candidate);
3859
+ rememberWarnedUntrustedDir(candidate);
3791
3860
  log("warn", "Skipping an untrusted .yaw-mcp/ dir outside $HOME", {
3792
3861
  candidate,
3793
3862
  hint: `owned by another user, or ownership is unverifiable on this platform (set ${ALLOW_UNOWNED_ENV}=1 to trust it)`
@@ -3808,7 +3877,7 @@ function guidePath(configDir) {
3808
3877
 
3809
3878
  // src/stable-entry.ts
3810
3879
  import { lstatSync, readdirSync, realpathSync } from "fs";
3811
- import { dirname, isAbsolute as isAbsolute6, resolve as resolve6 } from "path";
3880
+ import { dirname, isAbsolute as isAbsolute7, resolve as resolve7 } from "path";
3812
3881
  function isEphemeralMountPath(p) {
3813
3882
  const posix = p.replace(/\\/g, "/");
3814
3883
  return posix.includes("/AppTranslocation/") || // AppImage's FUSE mount. Anchored on the `.mount_` segment the runtime
@@ -3835,7 +3904,7 @@ function stableSpellingOf(entry, deps = {}) {
3835
3904
  const argv1 = deps.argv1 === void 0 ? process.argv[1] : deps.argv1;
3836
3905
  if (typeof argv1 === "string" && argv1.length > 0) {
3837
3906
  try {
3838
- const abs = isAbsolute6(argv1) ? argv1 : resolve6(argv1);
3907
+ const abs = isAbsolute7(argv1) ? argv1 : resolve7(argv1);
3839
3908
  if (abs !== entry && realpath3(abs) === target) return abs;
3840
3909
  } catch {
3841
3910
  }
@@ -3844,7 +3913,7 @@ function stableSpellingOf(entry, deps = {}) {
3844
3913
  }
3845
3914
  function aliasSpellingOf(entry, target, deps) {
3846
3915
  const realpath3 = deps.realpath ?? realpathSync;
3847
- const readdir = deps.readdir ?? ((p) => readdirSync(p));
3916
+ const readdir2 = deps.readdir ?? ((p) => readdirSync(p));
3848
3917
  const isSymlink = deps.isSymlink ?? ((p) => {
3849
3918
  try {
3850
3919
  return lstatSync(p).isSymbolicLink();
@@ -3860,7 +3929,7 @@ function aliasSpellingOf(entry, target, deps) {
3860
3929
  if (!looksLikeVersionDir(self)) continue;
3861
3930
  let names;
3862
3931
  try {
3863
- names = readdir(parent);
3932
+ names = readdir2(parent);
3864
3933
  } catch {
3865
3934
  continue;
3866
3935
  }
@@ -3939,7 +4008,7 @@ function npxSpec(args) {
3939
4008
  const spec = args[idx];
3940
4009
  return spec.startsWith("-") ? null : spec;
3941
4010
  }
3942
- var MIN_OAM_VERSION = "0.17.0";
4011
+ var MIN_OAM_VERSION = "0.18.0";
3943
4012
  var OAM_INSTALL_SH = "curl -fsSL https://oamjs.org/install.sh | sh";
3944
4013
  var OAM_INSTALL_PS1 = "irm https://oamjs.org/install.ps1 | iex";
3945
4014
  function oamInstallCommand(os) {
@@ -4030,7 +4099,7 @@ function isExecutableFile(candidate, platform) {
4030
4099
  }
4031
4100
  }
4032
4101
  function resolveBinAbsolute(bin, env = process.env, platform = process.platform) {
4033
- if (isAbsolute7(bin)) return isExecutableFile(bin, platform) ? winNormalize(bin, platform) : null;
4102
+ if (isAbsolute8(bin)) return isExecutableFile(bin, platform) ? winNormalize(bin, platform) : null;
4034
4103
  if (bin.includes("/") || platform === "win32" && bin.includes("\\")) return null;
4035
4104
  const pathVar = env.PATH ?? env.Path ?? env.path ?? "";
4036
4105
  if (!pathVar) return null;
@@ -4042,12 +4111,15 @@ function resolveBinAbsolute(bin, env = process.env, platform = process.platform)
4042
4111
  const clean = dir.replace(/^"|"$/g, "");
4043
4112
  for (const ext of exts) {
4044
4113
  const candidate = join9(clean, bin + ext);
4045
- if (!isAbsolute7(candidate)) continue;
4114
+ if (!isAbsolute8(candidate)) continue;
4046
4115
  if (isExecutableFile(candidate, platform)) return winNormalize(candidate, platform);
4047
4116
  }
4048
4117
  }
4049
4118
  return null;
4050
4119
  }
4120
+ function isShellShimSpawnRefusal(code, bin, platform = process.platform) {
4121
+ return code === "EINVAL" && platform === "win32" && /\.(cmd|bat)$/i.test(bin);
4122
+ }
4051
4123
  function classifyProbeFailure(err) {
4052
4124
  const code = err?.code;
4053
4125
  if (code === "ETIMEDOUT") return "timeout";
@@ -4057,7 +4129,7 @@ function classifyProbeFailure(err) {
4057
4129
  var OAM_PROBE_TIMEOUT_MS = 3e3;
4058
4130
  var OAM_PROBE_KILL_SIGNAL = "SIGKILL";
4059
4131
  var OAM_PROBE_MAX_OUTPUT = 8 * 1024;
4060
- var VERSION_CARRY = 32;
4132
+ var VERSION_CARRY = 128;
4061
4133
  function createProbeCollector(max = OAM_PROBE_MAX_OUTPUT) {
4062
4134
  let head = "";
4063
4135
  let carry = "";
@@ -4090,7 +4162,7 @@ function createProbeCollector(max = OAM_PROBE_MAX_OUTPUT) {
4090
4162
  };
4091
4163
  }
4092
4164
  function spawnVersionProbe(bin) {
4093
- return new Promise((resolve7, reject) => {
4165
+ return new Promise((resolve8, reject) => {
4094
4166
  let settled = false;
4095
4167
  let timer;
4096
4168
  const settle = (fn) => {
@@ -4103,6 +4175,11 @@ function spawnVersionProbe(bin) {
4103
4175
  try {
4104
4176
  child = spawn(bin, ["--version"], {
4105
4177
  stdio: ["ignore", "pipe", "ignore"],
4178
+ // No shell, unlike uv-bootstrap's PATH probe: oam ships as a real
4179
+ // executable, and shell:true would wrap an .exe in cmd.exe for
4180
+ // nothing. The cost is that a .cmd/.bat OAM_BIN EINVALs here (Node
4181
+ // refuses batch shims without a shell since the CVE-2024-27980 fix);
4182
+ // probeOamUncached classifies and logs that rather than hiding it.
4106
4183
  windowsHide: process.platform === "win32",
4107
4184
  // oam is a binary yaw-mcp did not write; README promises the vault
4108
4185
  // passphrase is stripped from every child yaw-mcp starts, and this
@@ -4123,7 +4200,7 @@ function spawnVersionProbe(bin) {
4123
4200
  "close",
4124
4201
  (code, signal) => settle(() => {
4125
4202
  if (code === 0) {
4126
- resolve7(collector.result());
4203
+ resolve8(collector.result());
4127
4204
  return;
4128
4205
  }
4129
4206
  const err = new Error(`oam exited ${code ?? signal}`);
@@ -4224,11 +4301,18 @@ async function probeOamUncached(run, generation) {
4224
4301
  } catch (err) {
4225
4302
  const code = err?.code;
4226
4303
  const absent = code === "ENOENT" && !explicit;
4304
+ const shellShim = isShellShimSpawnRefusal(code, bin);
4227
4305
  if (code === "ETIMEDOUT") {
4228
4306
  log("warn", "oam did not respond to --version twice; falling back to node for this process", {
4229
4307
  timeoutMs: OAM_PROBE_TIMEOUT_MS,
4230
4308
  bin
4231
4309
  });
4310
+ } else if (shellShim) {
4311
+ log(
4312
+ "warn",
4313
+ "OAM_BIN names a .cmd/.bat shim, which needs a shell the version probe does not use; falling back to node for this process",
4314
+ { bin, hint: "point OAM_BIN at the oam .exe the shim wraps" }
4315
+ );
4232
4316
  } else if (code !== "ENOENT") {
4233
4317
  log("warn", "oam --version failed; falling back to node for this process", {
4234
4318
  bin,
@@ -4246,7 +4330,7 @@ async function probeOamUncached(run, generation) {
4246
4330
  version: null,
4247
4331
  belowMin: false,
4248
4332
  failure: absent ? null : classifyProbeFailure(err),
4249
- failureDetail: absent ? null : err instanceof Error ? err.message : String(err)
4333
+ failureDetail: absent ? null : shellShim ? `${bin} is a .cmd/.bat shim and the version probe spawns without a shell; point OAM_BIN at the .exe it wraps` : err instanceof Error ? err.message : String(err)
4250
4334
  });
4251
4335
  }
4252
4336
  }
@@ -4466,7 +4550,7 @@ function packageEntry(pkgDir, pkg) {
4466
4550
  }
4467
4551
  if (!rel && typeof j.main === "string") rel = j.main;
4468
4552
  if (typeof rel !== "string" || rel.length === 0) return null;
4469
- const entry = isAbsolute7(rel) ? rel : join9(pkgDir, rel);
4553
+ const entry = isAbsolute8(rel) ? rel : join9(pkgDir, rel);
4470
4554
  if (!existsSync2(entry)) return null;
4471
4555
  return {
4472
4556
  entry,
@@ -4691,6 +4775,7 @@ function classifyEntrypoint(argvPath) {
4691
4775
  if (POSIX_GLOBAL_LIB_PREFIX.test(normalized)) return "global-npm";
4692
4776
  if (MANAGED_NODE_LIB_PREFIX.test(normalized)) return "global-npm";
4693
4777
  if (/\/AppData\/Roaming\/npm\/node_modules\/@yawlabs\/mcp\//.test(normalized)) return "global-npm";
4778
+ if (/\/\.npm-global\/(?:lib\/)?node_modules\/@yawlabs\/mcp\//.test(normalized)) return "global-npm";
4694
4779
  if (/\/bin\/node_modules\/@yawlabs\/mcp\//.test(normalized)) return "global-npm";
4695
4780
  if (/\/pnpm\/global\/\d+\/node_modules\/@yawlabs\/mcp\//.test(normalized)) return "pnpm-global";
4696
4781
  if (/\/\.bun\/install\/global\/node_modules\/@yawlabs\/mcp\//.test(normalized)) return "bun-global";
@@ -4719,7 +4804,7 @@ function packageDirOf(p) {
4719
4804
  return idx === -1 ? null : p.slice(0, idx + marker.length - 1);
4720
4805
  }
4721
4806
  function defaultInstalledVersion(pkgDir) {
4722
- if (process.env.VITEST) return null;
4807
+ if (isTestSandbox()) return null;
4723
4808
  try {
4724
4809
  const parsed = JSON.parse(readFileSync2(join10(pkgDir, "package.json"), "utf8"));
4725
4810
  return typeof parsed.version === "string" ? parsed.version : null;
@@ -4741,9 +4826,9 @@ function killProcessTree(child, platform = process.platform, spawnImpl = spawn2)
4741
4826
  child.kill();
4742
4827
  }
4743
4828
  async function npmGlobalPrefix(spawnImpl) {
4744
- if (process.env.VITEST && !spawnImpl) return null;
4829
+ if (isTestSandbox() && !spawnImpl) return null;
4745
4830
  const spawnFn = spawnImpl ?? spawn2;
4746
- return new Promise((resolve7) => {
4831
+ return new Promise((resolve8) => {
4747
4832
  const child = spawnFn("npm", ["prefix", "-g"], {
4748
4833
  shell: process.platform === "win32",
4749
4834
  stdio: ["ignore", "pipe", "ignore"],
@@ -4754,18 +4839,18 @@ async function npmGlobalPrefix(spawnImpl) {
4754
4839
  let out = "";
4755
4840
  const timer = setTimeout(() => {
4756
4841
  killProcessTree(child);
4757
- resolve7(null);
4842
+ resolve8(null);
4758
4843
  }, 3e3);
4759
4844
  child.stdout?.on("data", (d) => {
4760
4845
  out += String(d);
4761
4846
  });
4762
4847
  child.on("close", (code) => {
4763
4848
  clearTimeout(timer);
4764
- resolve7(code === 0 && out.trim() ? out.trim() : null);
4849
+ resolve8(code === 0 && out.trim() ? out.trim() : null);
4765
4850
  });
4766
4851
  child.on("error", () => {
4767
4852
  clearTimeout(timer);
4768
- resolve7(null);
4853
+ resolve8(null);
4769
4854
  });
4770
4855
  });
4771
4856
  }
@@ -4882,7 +4967,7 @@ async function probeOamQuietly() {
4882
4967
  }
4883
4968
  }
4884
4969
  async function oamFloorLines(probe) {
4885
- if (!probe && process.env.VITEST) return [];
4970
+ if (!probe && isTestSandbox()) return [];
4886
4971
  try {
4887
4972
  const oam = probe ? await probe() : await probeOamQuietly();
4888
4973
  if (!oam.belowMin) return [];
@@ -4904,12 +4989,22 @@ async function oamFloorLines(probe) {
4904
4989
  }
4905
4990
  }
4906
4991
  async function defaultRunningPrefix(argvPath) {
4907
- if (process.env.VITEST) return null;
4908
- const { detectRunningInstallPrefix: detectRunningInstallPrefix2 } = await import("./auto-upgrade-PZQM472F.js");
4992
+ if (isTestSandbox()) return null;
4993
+ const { detectRunningInstallPrefix: detectRunningInstallPrefix2 } = await import("./auto-upgrade-2WRN36F2.js");
4909
4994
  return detectRunningInstallPrefix2(argvPath);
4910
4995
  }
4996
+ async function defaultAcquireLock(prefixDir) {
4997
+ if (isTestSandbox()) return () => {
4998
+ };
4999
+ const { acquireUpgradeLock: acquireUpgradeLock2 } = await import("./auto-upgrade-2WRN36F2.js");
5000
+ return acquireUpgradeLock2(prefixDir);
5001
+ }
5002
+ async function upgradeLockPath(prefixDir) {
5003
+ const { UPGRADE_LOCK_NAME: UPGRADE_LOCK_NAME2 } = await import("./auto-upgrade-2WRN36F2.js");
5004
+ return join10(prefixDir, UPGRADE_LOCK_NAME2);
5005
+ }
4911
5006
  async function defaultSpawn(cmd, args, cwd) {
4912
- return new Promise((resolve7) => {
5007
+ return new Promise((resolve8) => {
4913
5008
  const child = spawn2(cmd, args, {
4914
5009
  stdio: "inherit",
4915
5010
  shell: process.platform === "win32",
@@ -4920,8 +5015,8 @@ async function defaultSpawn(cmd, args, cwd) {
4920
5015
  // them. See internal-secret-env.ts.
4921
5016
  env: stripInternalSecretsFromEnv(process.env)
4922
5017
  });
4923
- child.on("close", (code) => resolve7(typeof code === "number" ? code : 1));
4924
- child.on("error", () => resolve7(1));
5018
+ child.on("close", (code) => resolve8(typeof code === "number" ? code : 1));
5019
+ child.on("error", () => resolve8(1));
4925
5020
  });
4926
5021
  }
4927
5022
  async function detectSea() {
@@ -4949,7 +5044,7 @@ async function runUpgrade(opts = {}) {
4949
5044
  writeErr(`${s}
4950
5045
  `);
4951
5046
  };
4952
- const fetcher = opts.fetchLatest ?? fetchLatestVersion;
5047
+ const fetcher = opts.fetchLatest ?? (isTestSandbox() ? async () => null : fetchLatestVersion);
4953
5048
  const current = opts.currentVersion ?? readCurrentVersion();
4954
5049
  const argvPath = opts.argvPath ?? process.argv[1];
4955
5050
  const sea = opts.isSea ? opts.isSea() : await detectSea();
@@ -4963,10 +5058,11 @@ async function runUpgrade(opts = {}) {
4963
5058
  const plan = buildUpgradePlan({ current, latest, method });
4964
5059
  let globalPrefixArg = null;
4965
5060
  let suggestedCommand = plan.command;
5061
+ let rawPrefix = null;
4966
5062
  if (method === "global-npm") {
4967
- const rawPrefix = await (opts.runningPrefix ?? defaultRunningPrefix)(argvPath);
5063
+ rawPrefix = await (opts.runningPrefix ?? defaultRunningPrefix)(argvPath);
4968
5064
  if (rawPrefix !== null) {
4969
- const { quoteArgForDisplay: quoteArgForDisplay2, quoteShellArgIfNeeded: quoteShellArgIfNeeded2 } = await import("./auto-upgrade-PZQM472F.js");
5065
+ const { quoteArgForDisplay: quoteArgForDisplay2, quoteShellArgIfNeeded: quoteShellArgIfNeeded2 } = await import("./auto-upgrade-2WRN36F2.js");
4970
5066
  const spawnForm = quoteShellArgIfNeeded2(rawPrefix, opts.platform);
4971
5067
  const displayForm = quoteArgForDisplay2(rawPrefix, opts.platform);
4972
5068
  if (spawnForm !== null && displayForm !== null) {
@@ -5049,6 +5145,16 @@ async function runUpgrade(opts = {}) {
5049
5145
  printErr(` ${commandLine}`);
5050
5146
  return { exitCode: 2, lines };
5051
5147
  }
5148
+ let releaseLock = null;
5149
+ if (method === "global-npm" && rawPrefix !== null) {
5150
+ releaseLock = await (opts.acquireLock ?? defaultAcquireLock)(rawPrefix);
5151
+ if (releaseLock === null) {
5152
+ printErr(
5153
+ `yaw-mcp upgrade --run: another yaw-mcp process is upgrading this install (lock: ${await upgradeLockPath(rawPrefix)}); try again once it finishes.`
5154
+ );
5155
+ return { exitCode: 3, lines };
5156
+ }
5157
+ }
5052
5158
  const runner = opts.spawnImpl ?? defaultSpawn;
5053
5159
  if (runSpec.cwd) {
5054
5160
  print(`Running in ${runSpec.cwd}:`);
@@ -5057,7 +5163,12 @@ async function runUpgrade(opts = {}) {
5057
5163
  }
5058
5164
  print(` ${commandLine}`);
5059
5165
  print("");
5060
- const code = await runner(runSpec.cmd, runSpec.args, runSpec.cwd);
5166
+ let code;
5167
+ try {
5168
+ code = await runner(runSpec.cmd, runSpec.args, runSpec.cwd);
5169
+ } finally {
5170
+ releaseLock?.();
5171
+ }
5061
5172
  if (code === 0) {
5062
5173
  print("");
5063
5174
  print(`OK: Upgraded @yawlabs/mcp to ${latest}`);
@@ -5083,7 +5194,7 @@ async function runUpgrade(opts = {}) {
5083
5194
  return { exitCode: 3, lines };
5084
5195
  }
5085
5196
  function readCurrentVersion() {
5086
- return true ? "1.0.18" : "dev";
5197
+ return true ? "1.0.20" : "dev";
5087
5198
  }
5088
5199
 
5089
5200
  // src/auto-upgrade.ts
@@ -5113,6 +5224,13 @@ function detectRunningInstallPrefix(argvPath) {
5113
5224
  if (candidate.endsWith(`${sep2}lib`)) return candidate.slice(0, -`${sep2}lib`.length);
5114
5225
  return candidate;
5115
5226
  }
5227
+ function runsUnderNpmConfigPrefix(argvPath, env = process.env) {
5228
+ const prefix = env.npm_config_prefix;
5229
+ if (!argvPath || prefix === void 0 || prefix.trim() === "") return false;
5230
+ const root = comparablePath(prefix.trim()).replace(/\/+$/, "");
5231
+ const entry = comparablePath(argvPath);
5232
+ return entry.startsWith(`${root}/lib/node_modules/@yawlabs/mcp/`) || entry.startsWith(`${root}/node_modules/@yawlabs/mcp/`);
5233
+ }
5116
5234
  async function compareWithNpmPrefix(detected, probe = npmGlobalPrefix) {
5117
5235
  const npmPrefix = await probe();
5118
5236
  if (!npmPrefix?.trim()) return;
@@ -5233,11 +5351,15 @@ function acquireUpgradeLock(dir, lockName = UPGRADE_LOCK_NAME, opts = {}) {
5233
5351
  const second = take();
5234
5352
  return second === void 0 ? null : second;
5235
5353
  }
5236
- function defaultAcquireLock(dir, lockName) {
5237
- if (process.env.VITEST) return () => {
5354
+ function defaultAcquireLock2(dir, lockName) {
5355
+ if (isTestSandbox()) return () => {
5238
5356
  };
5239
5357
  return acquireUpgradeLock(dir, lockName);
5240
5358
  }
5359
+ function defaultFetchLatest() {
5360
+ if (isTestSandbox()) return Promise.resolve(null);
5361
+ return fetchLatestVersion();
5362
+ }
5241
5363
  var UPGRADE_CHECK_INTERVAL_MS = 60 * 60 * 1e3;
5242
5364
  var UPGRADE_ATTEMPT_COOLDOWN_MS = 6 * 60 * 60 * 1e3;
5243
5365
  function readMemo(path3) {
@@ -5281,19 +5403,19 @@ function attemptMemoFallbackPath(dir, lockName, fallbackDir) {
5281
5403
  return join11(fallbackDir, `.yaw-mcp-upgrade-attempt-${process.getuid?.() ?? "win"}-${scope}.json`);
5282
5404
  }
5283
5405
  function defaultCheckedRecently() {
5284
- if (process.env.VITEST) return null;
5406
+ if (isTestSandbox()) return null;
5285
5407
  return readCheckMemo(checkMemoPath());
5286
5408
  }
5287
5409
  function defaultRecordCheck(latest) {
5288
- if (process.env.VITEST) return;
5410
+ if (isTestSandbox()) return;
5289
5411
  writeCheckMemo(checkMemoPath(), latest);
5290
5412
  }
5291
5413
  function defaultAttemptedRecently(dir, lockName, version) {
5292
- if (process.env.VITEST) return false;
5414
+ if (isTestSandbox()) return false;
5293
5415
  return attemptedRecentlyAt(dir, lockName, version);
5294
5416
  }
5295
5417
  function defaultRecordAttempt(dir, lockName, version) {
5296
- if (process.env.VITEST) return;
5418
+ if (isTestSandbox()) return;
5297
5419
  recordAttemptAt(dir, lockName, version);
5298
5420
  }
5299
5421
  function attemptedRecentlyAt(dir, lockName, version, fallbackDir = tmpdir()) {
@@ -5364,16 +5486,17 @@ function defaultSpawn2(cmd, args, onDone = () => {
5364
5486
  }
5365
5487
  async function maybeAutoUpgrade(deps = {}) {
5366
5488
  if (isFeatureDisabled("YAW_MCP_AUTO_UPGRADE")) return;
5367
- const current = deps.currentVersion ?? (true ? "1.0.18" : "dev");
5489
+ const current = deps.currentVersion ?? (true ? "1.0.20" : "dev");
5368
5490
  if (current === "dev") return;
5369
5491
  const argvPath = deps.argvPath ?? process.argv[1];
5370
- const method = (deps.isSeaImpl ? await deps.isSeaImpl() : await detectSea()) ? "binary" : detectInstallMethod(argvPath, realpathSync3, ["unknown", "local-node-modules"]);
5492
+ let method = (deps.isSeaImpl ? await deps.isSeaImpl() : await detectSea()) ? "binary" : detectInstallMethod(argvPath, realpathSync3, ["unknown", "local-node-modules"]);
5493
+ if (method === "local-node-modules" && runsUnderNpmConfigPrefix(argvPath, deps.env)) method = "global-npm";
5371
5494
  const cached = (deps.checkedRecentlyImpl ?? defaultCheckedRecently)();
5372
5495
  let latest;
5373
5496
  if (cached !== null) {
5374
5497
  latest = cached.latest;
5375
5498
  } else {
5376
- latest = await (deps.fetchLatestImpl ?? fetchLatestVersion)();
5499
+ latest = await (deps.fetchLatestImpl ?? defaultFetchLatest)();
5377
5500
  (deps.recordCheckImpl ?? defaultRecordCheck)(latest);
5378
5501
  }
5379
5502
  if (latest === null) return;
@@ -5394,7 +5517,7 @@ async function maybeAutoUpgrade(deps = {}) {
5394
5517
  });
5395
5518
  return;
5396
5519
  }
5397
- const releaseLock = (deps.acquireLockImpl ?? defaultAcquireLock)(lockDir, lockName);
5520
+ const releaseLock = (deps.acquireLockImpl ?? defaultAcquireLock2)(lockDir, lockName);
5398
5521
  if (releaseLock === null) {
5399
5522
  log("info", "yaw-mcp self-upgrade: another process is already upgrading this install; skipping this one", {
5400
5523
  current,
@@ -5434,11 +5557,7 @@ async function maybeAutoUpgrade(deps = {}) {
5434
5557
  return;
5435
5558
  }
5436
5559
  if (method === "binary") {
5437
- log(
5438
- "info",
5439
- "yaw-mcp (standalone binary) is behind npm; the binary track was retired -- npm install -g @yawlabs/mcp@latest, then delete the old executable",
5440
- { current, latest }
5441
- );
5560
+ log("info", `yaw-mcp (standalone binary) is behind npm; ${BINARY_RETIRED_HINT}`, { current, latest });
5442
5561
  return;
5443
5562
  }
5444
5563
  if (method === "npx") {
@@ -5450,7 +5569,7 @@ async function maybeAutoUpgrade(deps = {}) {
5450
5569
  } else if (method === "local-node-modules") {
5451
5570
  log(
5452
5571
  "info",
5453
- "yaw-mcp is out of date; run `yaw-mcp upgrade --run` to update this install (a restart re-runs the version pinned in your project's node_modules)",
5572
+ "yaw-mcp is out of date; run `yaw-mcp upgrade --run` to update this install (a restart re-runs the version pinned in your project's node_modules; if this copy was installed with `npm install -g` under a custom npm prefix, the background self-upgrade did not recognise that prefix -- `upgrade --run` asks npm for it and does)",
5454
5573
  {
5455
5574
  current,
5456
5575
  latest,
@@ -5494,6 +5613,9 @@ export {
5494
5613
  findProjectConfigDir,
5495
5614
  guidePath,
5496
5615
  isFeatureDisabled,
5616
+ isTestSandbox,
5617
+ launchOf,
5618
+ describeValueShape,
5497
5619
  readStrictJson,
5498
5620
  CURRENT_OS,
5499
5621
  ENTRY_NAME,
@@ -5507,7 +5629,6 @@ export {
5507
5629
  addressOf,
5508
5630
  unloadableConfigProblem,
5509
5631
  unloadableConfigFix,
5510
- launchOf,
5511
5632
  carryableEnvOf,
5512
5633
  carriedFieldsOf,
5513
5634
  importViewOf,
@@ -5515,7 +5636,6 @@ export {
5515
5636
  reloadDoneClause,
5516
5637
  reloadRemovalClause,
5517
5638
  hasConfigAdapter,
5518
- describeValueShape,
5519
5639
  terminateWithNewline,
5520
5640
  classifyClientConfig,
5521
5641
  containerKeysAt,
@@ -5538,6 +5658,7 @@ export {
5538
5658
  resolveAlsoReadSites,
5539
5659
  claudeCodeContainerPaths,
5540
5660
  claudeCodeContainerPathVariants,
5661
+ claudeCodeProjectSites,
5541
5662
  buildLaunchEntry,
5542
5663
  isProjectLocalEntry,
5543
5664
  findLegacyEntry,
@@ -5578,6 +5699,8 @@ export {
5578
5699
  quoteShellArgIfNeeded,
5579
5700
  quoteArgForDisplay,
5580
5701
  detectRunningInstallPrefix,
5702
+ runsUnderNpmConfigPrefix,
5703
+ UPGRADE_LOCK_NAME,
5581
5704
  acquireUpgradeLock,
5582
5705
  readCheckMemo,
5583
5706
  writeCheckMemo,