@yawlabs/mcp 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  MIN_OAM_VERSION,
13
13
  acquireUpgradeLock,
14
14
  applyClientConfigEdits,
15
+ atomicWriteFile,
15
16
  blockedContainerFix,
16
17
  buildLaunchEntry,
17
18
  buildUpgradePlan,
@@ -40,6 +41,7 @@ import {
40
41
  isProjectLocalEntry,
41
42
  isRegistrySpec,
42
43
  isUnderHome,
44
+ isWin32TransientFsError,
43
45
  log,
44
46
  maybeAutoUpgrade,
45
47
  nodeLaunchKind,
@@ -57,6 +59,7 @@ import {
57
59
  parseUpgradeArgs,
58
60
  prepareClaudeCodeSettingsPatch,
59
61
  probeOam,
62
+ quoteArgForDisplay,
60
63
  readClientConfigFile,
61
64
  readClientEnv,
62
65
  readStrictJson,
@@ -88,7 +91,7 @@ import {
88
91
  unparseableConfigFix,
89
92
  userConfigDir,
90
93
  yawModeOverlay
91
- } from "./chunk-PAUBVL2N.js";
94
+ } from "./chunk-YYZYSCOI.js";
92
95
 
93
96
  // src/audit-cmd.ts
94
97
  import { homedir as homedir6 } from "os";
@@ -426,100 +429,10 @@ Target: ${url}
426
429
  }
427
430
 
428
431
  // src/grades-cache.ts
429
- import { mkdir as mkdir2, open, readFile as readFile2, rename as rename2, rm, stat as stat2 } from "fs/promises";
432
+ import { mkdir, open, readFile as readFile2, rename, rm, stat } from "fs/promises";
430
433
  import { homedir } from "os";
431
434
  import { dirname as dirname2, join as join2 } from "path";
432
- import { setTimeout as delay2 } from "timers/promises";
433
-
434
- // src/atomic-write.ts
435
- import { chmod, lstat, mkdir, realpath, rename, stat, unlink, writeFile } from "fs/promises";
436
- import path from "path";
437
435
  import { setTimeout as delay } from "timers/promises";
438
- var RENAME_RETRY_CODES = /* @__PURE__ */ new Set(["EPERM", "EBUSY", "EACCES"]);
439
- var RENAME_RETRY_DELAYS_MS = [10, 50, 100];
440
- async function renameWithRetry(tmp, target) {
441
- if (process.platform !== "win32") {
442
- await rename(tmp, target);
443
- return;
444
- }
445
- for (const ms of RENAME_RETRY_DELAYS_MS) {
446
- try {
447
- await rename(tmp, target);
448
- return;
449
- } catch (err) {
450
- const code = err.code;
451
- if (code === void 0 || !RENAME_RETRY_CODES.has(code)) throw err;
452
- await delay(ms);
453
- }
454
- }
455
- await rename(tmp, target);
456
- }
457
- var tmpSeq = 0;
458
- async function atomicWriteFile(filePath, contents, encoding = "utf8", mode, dirMode) {
459
- const target = await resolveSymlinkTarget(filePath);
460
- const dir = path.dirname(target);
461
- const tmp = `${target}.tmp-${process.pid}-${Date.now()}-${++tmpSeq}`;
462
- await mkdirpWithMode(dir, dirMode);
463
- let preserved;
464
- if (mode === void 0 && process.platform !== "win32") {
465
- try {
466
- preserved = (await stat(target)).mode & 511;
467
- } catch {
468
- }
469
- }
470
- const birthMode = mode ?? preserved;
471
- try {
472
- await writeFile(tmp, contents, birthMode === void 0 ? { encoding } : { encoding, mode: birthMode });
473
- if (preserved !== void 0) {
474
- try {
475
- await chmod(tmp, preserved);
476
- } catch {
477
- }
478
- }
479
- await renameWithRetry(tmp, target);
480
- } catch (err) {
481
- await unlink(tmp).catch(() => void 0);
482
- throw err;
483
- }
484
- }
485
- async function resolveSymlinkTarget(filePath) {
486
- try {
487
- if (!(await lstat(filePath)).isSymbolicLink()) return filePath;
488
- return await realpath(filePath);
489
- } catch {
490
- return filePath;
491
- }
492
- }
493
- async function mkdirpWithMode(dir, dirMode) {
494
- if (dirMode === void 0 || process.platform === "win32") {
495
- await mkdir(dir, { recursive: true });
496
- return;
497
- }
498
- const resolved = path.resolve(dir);
499
- const toCreate = [];
500
- let cursor = resolved;
501
- while (true) {
502
- let exists2 = true;
503
- try {
504
- await stat(cursor);
505
- } catch {
506
- exists2 = false;
507
- }
508
- if (exists2) break;
509
- toCreate.unshift(cursor);
510
- const parent = path.dirname(cursor);
511
- if (parent === cursor) break;
512
- cursor = parent;
513
- }
514
- if (toCreate.length === 0) return;
515
- await mkdir(resolved, { recursive: true, mode: dirMode });
516
- for (const created of toCreate) {
517
- try {
518
- await chmod(created, dirMode);
519
- } catch {
520
- }
521
- }
522
- }
523
436
 
524
437
  // src/json-key.ts
525
438
  function setJsonKey(target, key, value) {
@@ -555,10 +468,10 @@ async function readGradesCache(home = homedir()) {
555
468
  return readGradesCacheImpl(home, { strictRead: false });
556
469
  }
557
470
  async function readGradesCacheImpl(home, opts) {
558
- const path6 = gradesCachePath(home);
471
+ const path5 = gradesCachePath(home);
559
472
  let raw;
560
473
  try {
561
- raw = await readFile2(path6, "utf8");
474
+ raw = await readFile2(path5, "utf8");
562
475
  } catch (err) {
563
476
  const code = err.code;
564
477
  if (opts.strictRead && code !== "ENOENT" && code !== "ENOTDIR") throw err;
@@ -569,14 +482,14 @@ async function readGradesCacheImpl(home, opts) {
569
482
  parsed = parseJsonc(raw);
570
483
  } catch (err) {
571
484
  log("warn", "grades.json is not valid JSON; ignoring", {
572
- path: path6,
485
+ path: path5,
573
486
  error: err instanceof Error ? err.message : String(err)
574
487
  });
575
488
  return {};
576
489
  }
577
490
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
578
491
  log("warn", "grades.json is not a JSON object of namespace -> grade; ignoring", {
579
- path: path6,
492
+ path: path5,
580
493
  rootType: Array.isArray(parsed) ? "array" : parsed === null ? "null" : typeof parsed
581
494
  });
582
495
  return {};
@@ -592,6 +505,7 @@ var GRADES_LOCK_SUFFIX = ".lock";
592
505
  var GRADES_LOCK_STALE_MS = 1e4;
593
506
  var GRADES_LOCK_WAIT_MS = 15e3;
594
507
  var GRADES_LOCK_POLL_MS = 25;
508
+ var GRADES_LOCK_TRANSIENT_MS = 1e3;
595
509
  var GRADES_LOCK_FUTURE_SKEW_MS = 5e3;
596
510
  var lockSeq = 0;
597
511
  async function takeLock(lockPath, token) {
@@ -617,13 +531,13 @@ async function takeLock(lockPath, token) {
617
531
  async function stealStaleLock(lockPath, isLive) {
618
532
  const stolenPath = `${lockPath}.stale-${process.pid}-${++lockSeq}`;
619
533
  try {
620
- await rename2(lockPath, stolenPath);
534
+ await rename(lockPath, stolenPath);
621
535
  } catch (err) {
622
536
  return err.code === "ENOENT";
623
537
  }
624
538
  let holder = null;
625
539
  try {
626
- if (isLive(Date.now() - (await stat2(stolenPath)).mtimeMs)) holder = await readFile2(stolenPath, "utf8");
540
+ if (isLive(Date.now() - (await stat(stolenPath)).mtimeMs)) holder = await readFile2(stolenPath, "utf8");
627
541
  } catch {
628
542
  }
629
543
  if (holder !== null) {
@@ -643,25 +557,40 @@ function lockTimeout(_path, lockPath, ageMs) {
643
557
  const held = ageMs === null ? "" : ` for ${Math.round(ageMs / 1e3)}s`;
644
558
  return new Error(`locked by another yaw-mcp audit (${lockPath}, held${held}) -- re-run this audit once it finishes`);
645
559
  }
646
- async function withGradesLock(path6, opts, fn) {
647
- const lockPath = `${path6}${GRADES_LOCK_SUFFIX}`;
560
+ async function withGradesLock(path5, opts, fn) {
561
+ const lockPath = `${path5}${GRADES_LOCK_SUFFIX}`;
648
562
  const staleMs = opts.lockStaleMs ?? GRADES_LOCK_STALE_MS;
649
563
  const waitMs = opts.lockWaitMs ?? GRADES_LOCK_WAIT_MS;
564
+ const transientMs = opts.lockTransientMs ?? GRADES_LOCK_TRANSIENT_MS;
650
565
  const token = `${process.pid}-${++lockSeq}
651
566
  `;
652
567
  const isLive = (ageMs) => ageMs > -GRADES_LOCK_FUTURE_SKEW_MS && ageMs < staleMs;
653
- await mkdir2(dirname2(path6), { recursive: true });
568
+ await mkdir(dirname2(path5), { recursive: true });
654
569
  const deadline = Date.now() + waitMs;
655
- while (!await takeLock(lockPath, token)) {
570
+ let transientSince = null;
571
+ for (; ; ) {
572
+ let taken;
573
+ try {
574
+ taken = await takeLock(lockPath, token);
575
+ } catch (err) {
576
+ if (!isWin32TransientFsError(err)) throw err;
577
+ const now = Date.now();
578
+ transientSince ??= now;
579
+ if (now >= deadline || now - transientSince >= transientMs) throw err;
580
+ await delay(GRADES_LOCK_POLL_MS);
581
+ continue;
582
+ }
583
+ if (taken) break;
584
+ transientSince = null;
656
585
  let ageMs;
657
586
  try {
658
- ageMs = Date.now() - (await stat2(lockPath)).mtimeMs;
587
+ ageMs = Date.now() - (await stat(lockPath)).mtimeMs;
659
588
  } catch {
660
589
  ageMs = null;
661
590
  }
662
591
  if (ageMs !== null && !isLive(ageMs) && await stealStaleLock(lockPath, isLive)) continue;
663
- if (Date.now() >= deadline) throw lockTimeout(path6, lockPath, ageMs);
664
- await delay2(GRADES_LOCK_POLL_MS);
592
+ if (Date.now() >= deadline) throw lockTimeout(path5, lockPath, ageMs);
593
+ await delay(GRADES_LOCK_POLL_MS);
665
594
  }
666
595
  try {
667
596
  return await fn();
@@ -670,14 +599,14 @@ async function withGradesLock(path6, opts, fn) {
670
599
  }
671
600
  }
672
601
  async function writeGrade(namespace, grade, home = homedir(), opts = {}) {
673
- const path6 = gradesCachePath(home);
674
- await withGradesLock(path6, opts, async () => {
602
+ const path5 = gradesCachePath(home);
603
+ await withGradesLock(path5, opts, async () => {
675
604
  const cache = await readGradesCacheImpl(home, { strictRead: true });
676
605
  setJsonKey(cache, namespace, grade);
677
- await atomicWriteFile(path6, `${JSON.stringify(cache, null, 2)}
606
+ await atomicWriteFile(path5, `${JSON.stringify(cache, null, 2)}
678
607
  `);
679
608
  });
680
- return path6;
609
+ return path5;
681
610
  }
682
611
 
683
612
  // src/health-score.ts
@@ -815,13 +744,13 @@ function truncateForWarning(msg) {
815
744
  // src/local-bundles.ts
816
745
  import { createHash as createHash2 } from "crypto";
817
746
  import { existsSync as existsSync2, statSync } from "fs";
818
- import { chmod as chmod3, mkdir as mkdir3, readFile as readFile4 } from "fs/promises";
747
+ import { chmod as chmod2, mkdir as mkdir2, readFile as readFile4 } from "fs/promises";
819
748
  import { homedir as homedir3 } from "os";
820
749
  import { join as join4 } from "path";
821
750
 
822
751
  // src/trust.ts
823
752
  import { createHash } from "crypto";
824
- import { chmod as chmod2, readFile as readFile3 } from "fs/promises";
753
+ import { chmod, readFile as readFile3 } from "fs/promises";
825
754
  import { homedir as homedir2 } from "os";
826
755
  import { basename, dirname as dirname3, join as join3, resolve } from "path";
827
756
  var TRUST_FILENAME = "trusted.json";
@@ -873,60 +802,60 @@ function emptyStore(kind = null, reason = null, errorCode = null, version = TRUS
873
802
  };
874
803
  }
875
804
  async function readTrustStore(home = homedir2(), platform = process.platform) {
876
- const path6 = trustStorePath(home);
805
+ const path5 = trustStorePath(home);
877
806
  let raw;
878
807
  try {
879
- raw = await readFile3(path6, "utf8");
808
+ raw = await readFile3(path5, "utf8");
880
809
  } catch (err) {
881
810
  const code = err.code;
882
811
  if (code === "ENOENT") return emptyStore();
883
812
  const msg = err instanceof Error ? err.message : String(err);
884
- log("warn", "Trust store unreadable; nothing is trusted", { path: path6, error: msg, code });
885
- return emptyStore("io", `could not read ${path6} (${msg})`, code ?? null);
813
+ log("warn", "Trust store unreadable; nothing is trusted", { path: path5, error: msg, code });
814
+ return emptyStore("io", `could not read ${path5} (${msg})`, code ?? null);
886
815
  }
887
816
  let parsed;
888
817
  try {
889
818
  parsed = JSON.parse(raw);
890
819
  } catch (err) {
891
820
  const msg = err instanceof Error ? err.message : String(err);
892
- log("warn", "Trust store is not valid JSON; nothing is trusted", { path: path6, error: msg });
893
- return emptyStore("parse", `${path6} is not valid JSON (${msg})`);
821
+ log("warn", "Trust store is not valid JSON; nothing is trusted", { path: path5, error: msg });
822
+ return emptyStore("parse", `${path5} is not valid JSON (${msg})`);
894
823
  }
895
824
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
896
- return emptyStore("parse", `${path6} root must be a JSON object`);
825
+ return emptyStore("parse", `${path5} root must be a JSON object`);
897
826
  }
898
827
  const obj = parsed;
899
828
  if (obj.version !== void 0 && typeof obj.version !== "number") {
900
- log("warn", "Trust store has a non-numeric version; nothing is trusted", { path: path6 });
901
- return emptyStore("parse", `${path6} has a non-numeric "version" field; the store is corrupt`);
829
+ log("warn", "Trust store has a non-numeric version; nothing is trusted", { path: path5 });
830
+ return emptyStore("parse", `${path5} has a non-numeric "version" field; the store is corrupt`);
902
831
  }
903
832
  const version = typeof obj.version === "number" ? obj.version : TRUST_SCHEMA_VERSION;
904
833
  if (!Number.isInteger(version) || version < 1) {
905
- log("warn", "Trust store has an out-of-range version; nothing is trusted", { path: path6, version });
906
- return emptyStore("parse", `${path6} has an invalid "version" (${version}); the store is corrupt`);
834
+ log("warn", "Trust store has an out-of-range version; nothing is trusted", { path: path5, version });
835
+ return emptyStore("parse", `${path5} has an invalid "version" (${version}); the store is corrupt`);
907
836
  }
908
837
  if (version > TRUST_SCHEMA_VERSION) {
909
- log("warn", "Trust store was written by a newer yaw-mcp; nothing is trusted", { path: path6, version });
838
+ log("warn", "Trust store was written by a newer yaw-mcp; nothing is trusted", { path: path5, version });
910
839
  return emptyStore(
911
840
  "schema",
912
- `${path6} was written by a newer yaw-mcp (schema version ${version}; this build understands ${TRUST_SCHEMA_VERSION})`,
841
+ `${path5} was written by a newer yaw-mcp (schema version ${version}; this build understands ${TRUST_SCHEMA_VERSION})`,
913
842
  null,
914
843
  version
915
844
  );
916
845
  }
917
846
  const rawEntries = obj.trusted;
918
847
  if (!rawEntries || typeof rawEntries !== "object" || Array.isArray(rawEntries)) {
919
- return emptyStore("parse", `${path6} is missing a 'trusted' object`, null, version);
848
+ return emptyStore("parse", `${path5} is missing a 'trusted' object`, null, version);
920
849
  }
921
850
  const entries = {};
922
851
  for (const [key, value] of Object.entries(rawEntries)) {
923
852
  if (!value || typeof value !== "object" || Array.isArray(value)) {
924
- log("warn", "Dropping malformed trust entry", { path: path6, key });
853
+ log("warn", "Dropping malformed trust entry", { path: path5, key });
925
854
  continue;
926
855
  }
927
856
  const v = value;
928
857
  if (typeof v.sha256 !== "string" || !/^[0-9a-f]{64}$/.test(v.sha256)) {
929
- log("warn", "Dropping trust entry with a missing or malformed sha256", { path: path6, key });
858
+ log("warn", "Dropping trust entry with a missing or malformed sha256", { path: path5, key });
930
859
  continue;
931
860
  }
932
861
  setJsonKey(entries, normalizeTrustKey(key, platform), {
@@ -937,39 +866,39 @@ async function readTrustStore(home = homedir2(), platform = process.platform) {
937
866
  }
938
867
  return { version, entries, malformed: false, malformedReason: null, malformedKind: null, errorCode: null };
939
868
  }
940
- function trustStatusFor(path6, contents, store) {
869
+ function trustStatusFor(path5, contents, store) {
941
870
  if (store.malformed) return "store-unreadable";
942
- const record = store.entries[normalizeTrustKey(path6)];
871
+ const record = store.entries[normalizeTrustKey(path5)];
943
872
  if (!record) return "untrusted";
944
873
  return record.sha256 === hashTrustContent(contents) ? "trusted" : "changed";
945
874
  }
946
875
  async function writeTrustStore(home, entries) {
947
- const path6 = trustStorePath(home);
876
+ const path5 = trustStorePath(home);
948
877
  const body = { version: TRUST_SCHEMA_VERSION, trusted: entries };
949
- await atomicWriteFile(path6, `${JSON.stringify(body, null, 2)}
878
+ await atomicWriteFile(path5, `${JSON.stringify(body, null, 2)}
950
879
  `, "utf8", 384, 448);
951
880
  if (process.platform !== "win32") {
952
881
  try {
953
- await chmod2(path6, 384);
882
+ await chmod(path5, 384);
954
883
  } catch {
955
884
  }
956
885
  }
957
- return path6;
886
+ return path5;
958
887
  }
959
- async function grantTrust(path6, contents, opts = {}) {
888
+ async function grantTrust(path5, contents, opts = {}) {
960
889
  const home = opts.home ?? homedir2();
961
890
  const platform = opts.platform ?? process.platform;
962
891
  const store = await readTrustStore(home, platform);
963
892
  refuseUnusableStore(home, store);
964
893
  const record = {
965
- path: resolve(path6),
894
+ path: resolve(path5),
966
895
  sha256: hashTrustContent(contents),
967
896
  grantedAt: new Date(opts.now ? opts.now() : Date.now()).toISOString()
968
897
  };
969
898
  const fresh = await readTrustStore(home, platform);
970
899
  refuseUnusableStore(home, fresh);
971
900
  const entries = fresh.malformed ? {} : { ...fresh.entries };
972
- setJsonKey(entries, normalizeTrustKey(path6, platform), record);
901
+ setJsonKey(entries, normalizeTrustKey(path5, platform), record);
973
902
  const storePath = await writeTrustStore(home, entries);
974
903
  log("info", "Granted project bundles.json trust", { path: record.path, sha256: record.sha256 });
975
904
  return { storePath, record, storeWasMalformed: store.malformed || fresh.malformed };
@@ -990,7 +919,7 @@ async function revokeKeyCandidates(p, platform) {
990
919
  const physical = normalizeTrustKey(join3(await realpathOrSelf(dirname3(resolved)), basename(resolved)), platform);
991
920
  return physical === lexical ? [lexical] : [lexical, physical];
992
921
  }
993
- async function revokeTrust(path6, opts = {}) {
922
+ async function revokeTrust(path5, opts = {}) {
994
923
  const home = opts.home ?? homedir2();
995
924
  const platform = opts.platform ?? process.platform;
996
925
  const store = await readTrustStore(home, platform);
@@ -1010,7 +939,7 @@ async function revokeTrust(path6, opts = {}) {
1010
939
  malformedReason: null
1011
940
  });
1012
941
  if (store.malformed) return refused(store);
1013
- const candidates = await revokeKeyCandidates(path6, platform);
942
+ const candidates = await revokeKeyCandidates(path5, platform);
1014
943
  const keys = candidates.filter((c) => Object.hasOwn(store.entries, c));
1015
944
  if (keys.length === 0) return done(false);
1016
945
  const fresh = await readTrustStore(home, platform);
@@ -1020,7 +949,7 @@ async function revokeTrust(path6, opts = {}) {
1020
949
  const entries = { ...fresh.entries };
1021
950
  for (const k of present) delete entries[k];
1022
951
  await writeTrustStore(home, entries);
1023
- log("info", "Revoked project bundles.json trust", { path: resolve(path6) });
952
+ log("info", "Revoked project bundles.json trust", { path: resolve(path5) });
1024
953
  return done(true);
1025
954
  }
1026
955
  function trustedRecords(store) {
@@ -1158,9 +1087,9 @@ function validateEntry2(entry, warnings) {
1158
1087
  };
1159
1088
  }
1160
1089
  var IS_A_DIRECTORY_DETAIL = "the path is a directory, not a file";
1161
- async function readBundlesRawAt(path6) {
1090
+ async function readBundlesRawAt(path5) {
1162
1091
  try {
1163
- return { kind: "ok", raw: await readFile4(path6) };
1092
+ return { kind: "ok", raw: await readFile4(path5) };
1164
1093
  } catch (err) {
1165
1094
  const code = err.code;
1166
1095
  if (code === "ENOENT") return { kind: "absent" };
@@ -1169,41 +1098,41 @@ async function readBundlesRawAt(path6) {
1169
1098
  }
1170
1099
  }
1171
1100
  var READ_FAILURE_MARKER = "could not read file (";
1172
- async function readBundlesAt(path6, warnings) {
1173
- const r = await readBundlesRawAt(path6);
1101
+ async function readBundlesAt(path5, warnings) {
1102
+ const r = await readBundlesRawAt(path5);
1174
1103
  if (r.kind === "absent") return { exists: false, file: null };
1175
1104
  if (r.kind === "error") {
1176
- warnings.push(`${path6}: ${READ_FAILURE_MARKER}${r.message}) -- skipping`);
1177
- log("warn", "Could not read bundles.json", { path: path6, error: r.message, code: r.code });
1105
+ warnings.push(`${path5}: ${READ_FAILURE_MARKER}${r.message}) -- skipping`);
1106
+ log("warn", "Could not read bundles.json", { path: path5, error: r.message, code: r.code });
1178
1107
  return { exists: true, file: null };
1179
1108
  }
1180
- return { exists: true, file: parseBundlesContent(path6, r.raw, warnings) };
1109
+ return { exists: true, file: parseBundlesContent(path5, r.raw, warnings) };
1181
1110
  }
1182
- function parseBundlesContent(path6, rawBytes, warnings) {
1111
+ function parseBundlesContent(path5, rawBytes, warnings) {
1183
1112
  const raw = rawBytes.toString("utf8");
1184
1113
  let parsed;
1185
1114
  try {
1186
1115
  parsed = parseJsonc(raw);
1187
1116
  } catch (err) {
1188
1117
  const msg = err instanceof Error ? err.message : String(err);
1189
- warnings.push(`${path6}: invalid JSON (${msg}) -- file ignored`);
1190
- log("warn", "bundles.json is not valid JSON; ignoring", { path: path6, error: msg });
1118
+ warnings.push(`${path5}: invalid JSON (${msg}) -- file ignored`);
1119
+ log("warn", "bundles.json is not valid JSON; ignoring", { path: path5, error: msg });
1191
1120
  return null;
1192
1121
  }
1193
1122
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
1194
- warnings.push(`${path6}: root must be a JSON object -- file ignored`);
1123
+ warnings.push(`${path5}: root must be a JSON object -- file ignored`);
1195
1124
  return null;
1196
1125
  }
1197
1126
  const obj = parsed;
1198
1127
  const version = typeof obj.version === "number" ? obj.version : void 0;
1199
1128
  if (version !== void 0 && version > CURRENT_BUNDLES_SCHEMA_VERSION) {
1200
1129
  warnings.push(
1201
- `${path6}: schema version ${version} is newer than this yaw-mcp (${CURRENT_BUNDLES_SCHEMA_VERSION}); upgrade with \`npm i -g @yawlabs/mcp@latest\`. Loading best-effort.`
1130
+ `${path5}: schema version ${version} is newer than this yaw-mcp (${CURRENT_BUNDLES_SCHEMA_VERSION}); upgrade with \`npm i -g @yawlabs/mcp@latest\`. Loading best-effort.`
1202
1131
  );
1203
1132
  }
1204
1133
  const rawServers = obj.servers;
1205
1134
  if (!Array.isArray(rawServers)) {
1206
- warnings.push(`${path6}: 'servers' must be an array -- file ignored`);
1135
+ warnings.push(`${path5}: 'servers' must be an array -- file ignored`);
1207
1136
  return null;
1208
1137
  }
1209
1138
  let defaultRuntime2;
@@ -1211,14 +1140,14 @@ function parseBundlesContent(path6, rawBytes, warnings) {
1211
1140
  defaultRuntime2 = obj.defaultRuntime;
1212
1141
  } else if (obj.defaultRuntime !== void 0) {
1213
1142
  warnings.push(
1214
- `${path6}: ignoring invalid 'defaultRuntime' ${JSON.stringify(obj.defaultRuntime)} (expected "oam" or "node")`
1143
+ `${path5}: ignoring invalid 'defaultRuntime' ${JSON.stringify(obj.defaultRuntime)} (expected "oam" or "node")`
1215
1144
  );
1216
1145
  }
1217
1146
  return { version, servers: rawServers, defaultRuntime: defaultRuntime2 };
1218
1147
  }
1219
- function previewBundlesContent(path6, rawBytes) {
1148
+ function previewBundlesContent(path5, rawBytes) {
1220
1149
  const warnings = [];
1221
- const file = parseBundlesContent(path6, rawBytes, warnings);
1150
+ const file = parseBundlesContent(path5, rawBytes, warnings);
1222
1151
  if (!file) return { ok: false, servers: [], warnings };
1223
1152
  const servers = [];
1224
1153
  for (const entry of file.servers) {
@@ -1239,8 +1168,8 @@ async function probeProjectTrust(opts = {}) {
1239
1168
  const bypassed = isTrustBypassEnabled(env);
1240
1169
  const storePath = trustStorePath(home);
1241
1170
  const projectDir = await findProjectConfigDir(cwd, home, env).catch(() => null);
1242
- const path6 = projectDir ? localBundlesPath(projectDir) : null;
1243
- if (path6 === null) {
1171
+ const path5 = projectDir ? localBundlesPath(projectDir) : null;
1172
+ if (path5 === null) {
1244
1173
  return {
1245
1174
  path: null,
1246
1175
  status: "none",
@@ -1252,15 +1181,15 @@ async function probeProjectTrust(opts = {}) {
1252
1181
  pathTrusted: false
1253
1182
  };
1254
1183
  }
1255
- const read = await readBundlesRawAt(path6);
1184
+ const read = await readBundlesRawAt(path5);
1256
1185
  if (read.kind === "absent") {
1257
- return { path: path6, status: "none", bypassed, raw: null, sha256: null, error: null, storePath, pathTrusted: false };
1186
+ return { path: path5, status: "none", bypassed, raw: null, sha256: null, error: null, storePath, pathTrusted: false };
1258
1187
  }
1259
1188
  const store = await readTrustStore(home);
1260
- const pathTrusted = !store.malformed && normalizeTrustKey(path6) in store.entries;
1189
+ const pathTrusted = !store.malformed && normalizeTrustKey(path5) in store.entries;
1261
1190
  if (read.kind === "error") {
1262
1191
  return {
1263
- path: path6,
1192
+ path: path5,
1264
1193
  status: "unreadable",
1265
1194
  bypassed,
1266
1195
  raw: null,
@@ -1271,8 +1200,8 @@ async function probeProjectTrust(opts = {}) {
1271
1200
  };
1272
1201
  }
1273
1202
  return {
1274
- path: path6,
1275
- status: trustStatusFor(path6, read.raw, store),
1203
+ path: path5,
1204
+ status: trustStatusFor(path5, read.raw, store),
1276
1205
  bypassed,
1277
1206
  raw: read.raw,
1278
1207
  sha256: hashTrustContent(read.raw),
@@ -1282,25 +1211,25 @@ async function probeProjectTrust(opts = {}) {
1282
1211
  };
1283
1212
  }
1284
1213
  function untrustedProjectWarning(probe, opts = {}) {
1285
- const path6 = probe.path ?? "(unknown)";
1214
+ const path5 = probe.path ?? "(unknown)";
1286
1215
  const approve = "`yaw-mcp trust` to approve";
1287
1216
  const detail = opts.detail === true;
1288
1217
  const fallback = detail ? " Falling back to your user-global ~/.yaw-mcp/bundles.json." : " Using user-global instead.";
1289
1218
  const escapeHatch = detail ? ` Set ${TRUST_BYPASS_ENV}=1 to skip this check (CI/automation only -- it lets any repo you run inside spawn commands as you).` : ` (${TRUST_BYPASS_ENV}=1 skips this check; CI only.)`;
1290
1219
  if (probe.status === "changed") {
1291
1220
  const why2 = detail ? " The new contents could spawn commands you never reviewed." : "";
1292
- return `${path6}: project bundles.json CHANGED since you approved it -- IGNORED.${why2}${fallback} Re-review, then run ${approve}.${escapeHatch}`;
1221
+ return `${path5}: project bundles.json CHANGED since you approved it -- IGNORED.${why2}${fallback} Re-review, then run ${approve}.${escapeHatch}`;
1293
1222
  }
1294
1223
  if (probe.status === "store-unreadable") {
1295
1224
  const fix = detail ? " Fix or delete that file, then re-approve from inside this project." : "";
1296
- return `${path6}: project bundles.json IGNORED -- the trust store at ${probe.storePath} could not be read, so nothing is trusted (fail-closed).${fallback}${fix} Then run ${approve}.${escapeHatch}`;
1225
+ return `${path5}: project bundles.json IGNORED -- the trust store at ${probe.storePath} could not be read, so nothing is trusted (fail-closed).${fallback}${fix} Then run ${approve}.${escapeHatch}`;
1297
1226
  }
1298
1227
  if (probe.status === "unreadable") {
1299
1228
  const why2 = detail ? " An unreadable project file that has never been approved is treated as absent rather than as authoritative -- otherwise a repo could blank out your servers just by committing something yaw-mcp cannot read." : "";
1300
- return `${path6}: project bundles.json could not be read (${probe.error}) and was never approved -- IGNORED.${why2}${fallback} Fix the file, then run ${approve}.`;
1229
+ return `${path5}: project bundles.json could not be read (${probe.error}) and was never approved -- IGNORED.${why2}${fallback} Fix the file, then run ${approve}.`;
1301
1230
  }
1302
1231
  const why = detail ? " A project file is usually committed to the repo and can spawn arbitrary commands as you, so it has to be approved first." : "";
1303
- return `${path6}: untrusted project bundles.json -- IGNORED.${why}${fallback} Review the servers, then run ${approve}.${escapeHatch}`;
1232
+ return `${path5}: untrusted project bundles.json -- IGNORED.${why}${fallback} Review the servers, then run ${approve}.${escapeHatch}`;
1304
1233
  }
1305
1234
  function projectFileIsHonoured(probe) {
1306
1235
  if (probe.status === "none") return false;
@@ -1308,12 +1237,12 @@ function projectFileIsHonoured(probe) {
1308
1237
  return probe.bypassed || probe.status === "trusted";
1309
1238
  }
1310
1239
  function bundlesSignature(paths) {
1311
- return paths.map((path6) => {
1240
+ return paths.map((path5) => {
1312
1241
  try {
1313
- const s = statSync(path6);
1314
- return `${path6}=${s.mtimeMs}:${s.size}`;
1242
+ const s = statSync(path5);
1243
+ return `${path5}=${s.mtimeMs}:${s.size}`;
1315
1244
  } catch {
1316
- return `${path6}=absent`;
1245
+ return `${path5}=absent`;
1317
1246
  }
1318
1247
  }).join("|");
1319
1248
  }
@@ -1404,7 +1333,7 @@ var BUNDLES_LOCK_WAIT_MS = 5e3;
1404
1333
  var BUNDLES_LOCK_POLL_MS = 20;
1405
1334
  async function withBundlesLock(home, fn) {
1406
1335
  const dir = userConfigDir(home);
1407
- await mkdir3(dir, { recursive: true, mode: 448 });
1336
+ await mkdir2(dir, { recursive: true, mode: 448 });
1408
1337
  const lockPath = join4(dir, BUNDLES_LOCK_NAME);
1409
1338
  const deadline = Date.now() + BUNDLES_LOCK_WAIT_MS;
1410
1339
  let release = acquireUpgradeLock(dir, BUNDLES_LOCK_NAME, { probeHolder: true });
@@ -1443,20 +1372,20 @@ function deriveNamespace(name) {
1443
1372
  return ns;
1444
1373
  }
1445
1374
  async function readRawUserBundles(home, warnings) {
1446
- const path6 = localBundlesPath(userConfigDir(home));
1447
- const r = await readBundlesAt(path6, warnings);
1375
+ const path5 = localBundlesPath(userConfigDir(home));
1376
+ const r = await readBundlesAt(path5, warnings);
1448
1377
  if (!r.exists) return { version: CURRENT_BUNDLES_SCHEMA_VERSION, servers: [] };
1449
1378
  if (!r.file) {
1450
1379
  const warningText = warnings.join("; ");
1451
- const readWarning = warnings.find((w) => w.startsWith(`${path6}: ${READ_FAILURE_MARKER}`));
1380
+ const readWarning = warnings.find((w) => w.startsWith(`${path5}: ${READ_FAILURE_MARKER}`));
1452
1381
  if (readWarning) {
1453
1382
  if (readWarning.includes(IS_A_DIRECTORY_DETAIL)) {
1454
- throw new Error(`${path6} is a directory, not a file -- move or remove it before adding servers.`);
1383
+ throw new Error(`${path5} is a directory, not a file -- move or remove it before adding servers.`);
1455
1384
  }
1456
- throw new Error(`${path6} could not be read (${warningText}) -- check file permissions before adding servers.`);
1385
+ throw new Error(`${path5} could not be read (${warningText}) -- check file permissions before adding servers.`);
1457
1386
  }
1458
1387
  const detail = warnings.length > 0 ? ` (${warningText})` : "";
1459
- throw new Error(`${path6} could not be parsed -- fix the JSON${detail} before adding servers.`);
1388
+ throw new Error(`${path5} could not be parsed -- fix the JSON${detail} before adding servers.`);
1460
1389
  }
1461
1390
  for (const w of warnings) {
1462
1391
  log("debug", "bundles.json warning (write path)", { warning: w });
@@ -1605,7 +1534,7 @@ async function previewUpsertUserBundle(entry, opts = {}) {
1605
1534
  }
1606
1535
  async function doUpsertUserBundle(entry, opts) {
1607
1536
  const home = opts.home ?? homedir3();
1608
- const path6 = localBundlesPath(userConfigDir(home));
1537
+ const path5 = localBundlesPath(userConfigDir(home));
1609
1538
  return withBundlesLock(home, async () => {
1610
1539
  const warnings = [];
1611
1540
  const file = await readRawUserBundles(home, warnings);
@@ -1616,15 +1545,15 @@ async function doUpsertUserBundle(entry, opts) {
1616
1545
  const written = mergedUpsertEntry(file.servers, entry, target);
1617
1546
  if (replaced) file.servers[idx] = written;
1618
1547
  else file.servers.push(written);
1619
- await atomicWriteFile(path6, `${JSON.stringify(file, null, 2)}
1548
+ await atomicWriteFile(path5, `${JSON.stringify(file, null, 2)}
1620
1549
  `, "utf8", 384, 448);
1621
1550
  if (process.platform !== "win32") {
1622
1551
  try {
1623
- await chmod3(path6, 384);
1552
+ await chmod2(path5, 384);
1624
1553
  } catch {
1625
1554
  }
1626
1555
  }
1627
- return { path: path6, replaced, entry: written, launchChanged: target.launchChanged, warnings };
1556
+ return { path: path5, replaced, entry: written, launchChanged: target.launchChanged, warnings };
1628
1557
  });
1629
1558
  }
1630
1559
  function removeUserBundle(namespace, opts = {}) {
@@ -1637,23 +1566,23 @@ function removeUserBundle(namespace, opts = {}) {
1637
1566
  }
1638
1567
  async function doRemoveUserBundle(namespace, opts) {
1639
1568
  const home = opts.home ?? homedir3();
1640
- const path6 = localBundlesPath(userConfigDir(home));
1641
- if (!existsSync2(path6)) return { path: path6, removed: false, warnings: [] };
1569
+ const path5 = localBundlesPath(userConfigDir(home));
1570
+ if (!existsSync2(path5)) return { path: path5, removed: false, warnings: [] };
1642
1571
  return withBundlesLock(home, async () => {
1643
1572
  const warnings = [];
1644
1573
  const file = await readRawUserBundles(home, warnings);
1645
1574
  const before = file.servers.length;
1646
1575
  file.servers = file.servers.filter((s) => s?.namespace !== namespace);
1647
- if (file.servers.length === before) return { path: path6, removed: false, warnings };
1648
- await atomicWriteFile(path6, `${JSON.stringify(file, null, 2)}
1576
+ if (file.servers.length === before) return { path: path5, removed: false, warnings };
1577
+ await atomicWriteFile(path5, `${JSON.stringify(file, null, 2)}
1649
1578
  `, "utf8", 384, 448);
1650
1579
  if (process.platform !== "win32") {
1651
1580
  try {
1652
- await chmod3(path6, 384);
1581
+ await chmod2(path5, 384);
1653
1582
  } catch {
1654
1583
  }
1655
1584
  }
1656
- return { path: path6, removed: true, warnings };
1585
+ return { path: path5, removed: true, warnings };
1657
1586
  });
1658
1587
  }
1659
1588
  async function findShadowingProjectBundles(cwd, home = homedir3(), env = process.env) {
@@ -1663,7 +1592,7 @@ async function findShadowingProjectBundles(cwd, home = homedir3(), env = process
1663
1592
 
1664
1593
  // src/secrets-vault.ts
1665
1594
  import { createHmac, randomBytes as randomBytes2, timingSafeEqual } from "crypto";
1666
- import { chmod as chmod4, readFile as readFile5 } from "fs/promises";
1595
+ import { chmod as chmod3, readFile as readFile5 } from "fs/promises";
1667
1596
  import { homedir as homedir4 } from "os";
1668
1597
  import { dirname as dirname4, join as join5 } from "path";
1669
1598
 
@@ -1769,43 +1698,43 @@ var VaultEntryCorruptError = class extends Error {
1769
1698
  this.entryName = entryName;
1770
1699
  }
1771
1700
  };
1772
- async function loadVault(path6) {
1701
+ async function loadVault(path5) {
1773
1702
  let raw;
1774
1703
  try {
1775
- raw = await readFile5(path6, "utf8");
1704
+ raw = await readFile5(path5, "utf8");
1776
1705
  } catch (err) {
1777
1706
  const code = err.code;
1778
1707
  if (code === "ENOENT") return null;
1779
- log("warn", "Failed to read vault", { path: path6, error: err instanceof Error ? err.message : String(err), code });
1708
+ log("warn", "Failed to read vault", { path: path5, error: err instanceof Error ? err.message : String(err), code });
1780
1709
  throw err;
1781
1710
  }
1782
1711
  let parsed;
1783
1712
  try {
1784
1713
  parsed = JSON.parse(raw);
1785
1714
  } catch (err) {
1786
- log("warn", "Vault file is not valid JSON", { path: path6, error: err instanceof Error ? err.message : String(err) });
1787
- throw new Error(`vault at ${path6} is not valid JSON: ${err instanceof Error ? err.message : String(err)}`);
1715
+ log("warn", "Vault file is not valid JSON", { path: path5, error: err instanceof Error ? err.message : String(err) });
1716
+ throw new Error(`vault at ${path5} is not valid JSON: ${err instanceof Error ? err.message : String(err)}`);
1788
1717
  }
1789
1718
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
1790
- throw new Error(`vault at ${path6} is corrupt: root must be a JSON object`);
1719
+ throw new Error(`vault at ${path5} is corrupt: root must be a JSON object`);
1791
1720
  }
1792
1721
  const obj = parsed;
1793
1722
  if (typeof obj.salt !== "string" || !obj.entries || typeof obj.entries !== "object") {
1794
- throw new Error(`vault at ${path6} is corrupt: missing or invalid salt/entries`);
1723
+ throw new Error(`vault at ${path5} is corrupt: missing or invalid salt/entries`);
1795
1724
  }
1796
1725
  if (Buffer.from(obj.salt, "base64").length !== SALT_LEN) {
1797
- throw new Error(`vault at ${path6} is corrupt: salt (expected ${SALT_LEN} bytes)`);
1726
+ throw new Error(`vault at ${path5} is corrupt: salt (expected ${SALT_LEN} bytes)`);
1798
1727
  }
1799
1728
  if (obj.version !== void 0 && typeof obj.version !== "number") {
1800
- throw new Error(`vault at ${path6} is corrupt: "version" must be a number`);
1729
+ throw new Error(`vault at ${path5} is corrupt: "version" must be a number`);
1801
1730
  }
1802
1731
  if (typeof obj.version === "number" && obj.version > SECRETS_SCHEMA_VERSION) {
1803
1732
  throw new Error(
1804
- `vault at ${path6} was written by a newer yaw-mcp (schema version ${obj.version} > ${SECRETS_SCHEMA_VERSION}); upgrade yaw-mcp to read it`
1733
+ `vault at ${path5} was written by a newer yaw-mcp (schema version ${obj.version} > ${SECRETS_SCHEMA_VERSION}); upgrade yaw-mcp to read it`
1805
1734
  );
1806
1735
  }
1807
1736
  if (obj.kdf !== void 0 && !isValidKdfParams(obj.kdf)) {
1808
- throw new Error(`vault at ${path6} is corrupt: invalid kdf parameters`);
1737
+ throw new Error(`vault at ${path5} is corrupt: invalid kdf parameters`);
1809
1738
  }
1810
1739
  const entries = obj.entries;
1811
1740
  for (const [name, entry] of Object.entries(entries)) {
@@ -1814,7 +1743,7 @@ async function loadVault(path6) {
1814
1743
  }
1815
1744
  }
1816
1745
  if (obj.check !== void 0 && !isEncryptedEntry(obj.check)) {
1817
- log("warn", "Vault verification token is malformed; ignoring it (the next write re-stamps it)", { path: path6 });
1746
+ log("warn", "Vault verification token is malformed; ignoring it (the next write re-stamps it)", { path: path5 });
1818
1747
  }
1819
1748
  const check = isEncryptedEntry(obj.check) ? obj.check : void 0;
1820
1749
  return {
@@ -1830,16 +1759,16 @@ function isEncryptedEntry(v) {
1830
1759
  const e = v;
1831
1760
  return typeof e.iv === "string" && typeof e.ciphertext === "string" && typeof e.authTag === "string";
1832
1761
  }
1833
- async function saveVault(path6, vault) {
1834
- await atomicWriteFile(path6, `${JSON.stringify(vault, null, 2)}
1762
+ async function saveVault(path5, vault) {
1763
+ await atomicWriteFile(path5, `${JSON.stringify(vault, null, 2)}
1835
1764
  `, "utf8", 384, 448);
1836
1765
  if (process.platform !== "win32") {
1837
1766
  try {
1838
- await chmod4(dirname4(path6), 448);
1767
+ await chmod3(dirname4(path5), 448);
1839
1768
  } catch {
1840
1769
  }
1841
1770
  try {
1842
- await chmod4(path6, 384);
1771
+ await chmod3(path5, 384);
1843
1772
  } catch {
1844
1773
  }
1845
1774
  }
@@ -2230,9 +2159,9 @@ var inflight = null;
2230
2159
  var degradedProbe = null;
2231
2160
  var DEGRADED_RECHECK_MS = 5e3;
2232
2161
  var warnedDegradedBundles = false;
2233
- function statSignature(path6) {
2162
+ function statSignature(path5) {
2234
2163
  try {
2235
- const s = statSync2(path6);
2164
+ const s = statSync2(path5);
2236
2165
  return `${s.mtimeMs}:${s.size}`;
2237
2166
  } catch {
2238
2167
  return null;
@@ -2276,12 +2205,12 @@ async function resolveBundlesDefault(opts) {
2276
2205
  const degraded = bundles === null || bundles.config === null && bundles.path !== null;
2277
2206
  const resolved = bundles?.defaultRuntime ?? null;
2278
2207
  if (degraded && resolved === null) {
2279
- const path6 = bundles?.path ?? null;
2280
- const signature = path6 === null ? null : statSignature(path6);
2281
- if (path6 === null || signature === null) {
2208
+ const path5 = bundles?.path ?? null;
2209
+ const signature = path5 === null ? null : statSignature(path5);
2210
+ if (path5 === null || signature === null) {
2282
2211
  degradedProbe = null;
2283
2212
  } else {
2284
- const watched = bundles?.consultedPaths?.length ? bundles.consultedPaths : [path6];
2213
+ const watched = bundles?.consultedPaths?.length ? bundles.consultedPaths : [path5];
2285
2214
  degradedProbe = {
2286
2215
  files: watched.map((f) => ({ path: f, signature: statSignature(f) })),
2287
2216
  at: now()
@@ -2290,7 +2219,7 @@ async function resolveBundlesDefault(opts) {
2290
2219
  if (!warnedDegradedBundles) {
2291
2220
  warnedDegradedBundles = true;
2292
2221
  log("warn", "bundles.json could not be read for the default runtime; using the fallback until the file changes", {
2293
- path: path6 ?? "(unknown)"
2222
+ path: path5 ?? "(unknown)"
2294
2223
  });
2295
2224
  }
2296
2225
  return null;
@@ -2381,7 +2310,7 @@ function describeServerRuntime(server, configDefault, probe) {
2381
2310
 
2382
2311
  // src/secrets-audit.ts
2383
2312
  import { existsSync as existsSync3 } from "fs";
2384
- import { appendFile, chmod as chmod5, readFile as readFile6, stat as stat3 } from "fs/promises";
2313
+ import { appendFile, chmod as chmod4, readFile as readFile6, stat as stat2 } from "fs/promises";
2385
2314
  import { homedir as homedir5 } from "os";
2386
2315
  import { join as join6 } from "path";
2387
2316
  var SECRETS_AUDIT_FILENAME = "secrets-audit.log";
@@ -2398,41 +2327,41 @@ async function appendAuditEvent(input, home = homedir5()) {
2398
2327
  secret: input.secret,
2399
2328
  event: input.event
2400
2329
  };
2401
- const path6 = auditLogPath(home);
2330
+ const path5 = auditLogPath(home);
2402
2331
  const line = `${JSON.stringify(event)}
2403
2332
  `;
2404
- if (!existsSync3(path6)) {
2405
- await atomicWriteFile(path6, line, "utf8", 384, 448);
2333
+ if (!existsSync3(path5)) {
2334
+ await atomicWriteFile(path5, line, "utf8", 384, 448);
2406
2335
  } else {
2407
- await appendFile(path6, line, "utf8");
2336
+ await appendFile(path5, line, "utf8");
2408
2337
  }
2409
2338
  if (process.platform !== "win32") {
2410
- await chmod5(path6, 384).catch(() => void 0);
2339
+ await chmod4(path5, 384).catch(() => void 0);
2411
2340
  }
2412
- await trimToTailCap(path6);
2341
+ await trimToTailCap(path5);
2413
2342
  } catch {
2414
2343
  }
2415
2344
  }
2416
2345
  var MIN_AUDIT_LINE_BYTES = 64;
2417
- async function trimToTailCap(path6) {
2418
- const { size } = await stat3(path6);
2346
+ async function trimToTailCap(path5) {
2347
+ const { size } = await stat2(path5);
2419
2348
  if (size < AUDIT_TAIL_CAP * MIN_AUDIT_LINE_BYTES) return;
2420
- const raw = await readFile6(path6, "utf8");
2349
+ const raw = await readFile6(path5, "utf8");
2421
2350
  const lines = raw.split("\n").filter((l) => l.length > 0);
2422
2351
  if (lines.length <= AUDIT_TAIL_CAP) return;
2423
2352
  const kept = lines.slice(lines.length - AUDIT_TRIM_TO);
2424
- await atomicWriteFile(path6, `${kept.join("\n")}
2353
+ await atomicWriteFile(path5, `${kept.join("\n")}
2425
2354
  `, "utf8", 384);
2426
2355
  }
2427
2356
  async function readAuditLog(filter = {}, home = homedir5()) {
2428
- const path6 = auditLogPath(home);
2357
+ const path5 = auditLogPath(home);
2429
2358
  let raw;
2430
2359
  try {
2431
- raw = await readFile6(path6, "utf8");
2360
+ raw = await readFile6(path5, "utf8");
2432
2361
  } catch (err) {
2433
2362
  const e = err;
2434
2363
  if (e.code === "ENOENT") return [];
2435
- throw new Error(`could not read the audit log at ${path6} (${e.code ?? e.message})`);
2364
+ throw new Error(`could not read the audit log at ${path5} (${e.code ?? e.message})`);
2436
2365
  }
2437
2366
  const out = [];
2438
2367
  for (const line of raw.split("\n")) {
@@ -2600,7 +2529,7 @@ import { spawn as spawn2 } from "child_process";
2600
2529
  import { createHash as createHash3 } from "crypto";
2601
2530
  import { createWriteStream } from "fs";
2602
2531
  import fs from "fs/promises";
2603
- import path2 from "path";
2532
+ import path from "path";
2604
2533
  import { pipeline } from "stream/promises";
2605
2534
  import { request } from "undici";
2606
2535
  var UV_VERSION = "0.12.10";
@@ -2830,7 +2759,7 @@ function runCommand(cmd, args, timeoutMs = UV_EXTRACT_TIMEOUT_MS) {
2830
2759
  async function findBinary(root, name) {
2831
2760
  const entries = await fs.readdir(root, { withFileTypes: true });
2832
2761
  for (const e of entries) {
2833
- const full = path2.join(root, e.name);
2762
+ const full = path.join(root, e.name);
2834
2763
  if (e.isFile() && e.name === name) return full;
2835
2764
  if (e.isDirectory()) {
2836
2765
  const found = await findBinary(full, name);
@@ -2869,8 +2798,8 @@ async function resolveUv() {
2869
2798
  `No prebuilt uv binary for ${process.platform}/${process.arch}. Install uv manually: https://docs.astral.sh/uv/`
2870
2799
  );
2871
2800
  }
2872
- const installDir = path2.join(cacheDir(), "uv", UV_VERSION, target);
2873
- const finalBin = path2.join(installDir, binName());
2801
+ const installDir = path.join(cacheDir(), "uv", UV_VERSION, target);
2802
+ const finalBin = path.join(installDir, binName());
2874
2803
  const cached = await fs.stat(finalBin).catch(() => null);
2875
2804
  if (cached?.isFile() && cached.size > 0) return finalBin;
2876
2805
  await fs.mkdir(installDir, { recursive: true });
@@ -2886,11 +2815,11 @@ async function resolveUv() {
2886
2815
  throw new Error(`uv archive checksum mismatch (expected ${expected}, got ${actual})`);
2887
2816
  }
2888
2817
  const archiveBase = archiveName.endsWith(".tar.gz") ? `${archiveName.slice(0, -".tar.gz".length)}.${process.pid}.tar.gz` : archiveName.endsWith(".zip") ? `${archiveName.slice(0, -".zip".length)}.${process.pid}.zip` : `${archiveName}.${process.pid}`;
2889
- const archivePath = path2.join(installDir, archiveBase);
2818
+ const archivePath = path.join(installDir, archiveBase);
2890
2819
  await pipeline(async function* () {
2891
2820
  yield archiveBuf;
2892
2821
  }, createWriteStream(archivePath));
2893
- const extractDir = path2.join(installDir, `extract-${process.pid}-${Date.now()}`);
2822
+ const extractDir = path.join(installDir, `extract-${process.pid}-${Date.now()}`);
2894
2823
  try {
2895
2824
  await extractArchive(archivePath, extractDir);
2896
2825
  const extracted = await findBinary(extractDir, binName());
@@ -3265,7 +3194,7 @@ async function connectToUpstreamOnce(config, onDisconnect, onListChanged, bridge
3265
3194
  if (downstreamCaps?.sampling) capabilities.sampling = downstreamCaps.sampling;
3266
3195
  if (downstreamCaps?.roots) capabilities.roots = {};
3267
3196
  const client = new Client(
3268
- { name: "yaw-mcp", version: true ? "1.0.2" : "dev" },
3197
+ { name: "yaw-mcp", version: true ? "1.0.4" : "dev" },
3269
3198
  { capabilities }
3270
3199
  );
3271
3200
  if (bridge && capabilities.elicitation) {
@@ -3891,12 +3820,12 @@ async function runAudit(opts = {}) {
3891
3820
  return { exitCode: 2 };
3892
3821
  }
3893
3822
  const home = opts.home ?? homedir6();
3894
- const { config, path: path6, warnings } = await loadLocalBundles({ cwd: opts.cwd, home });
3823
+ const { config, path: path5, warnings } = await loadLocalBundles({ cwd: opts.cwd, home });
3895
3824
  for (const w of warnings) printErr(`warning: ${w}`);
3896
3825
  const servers = config?.servers ?? [];
3897
3826
  const server = findServer(servers, namespace);
3898
3827
  if (!server) {
3899
- const where = path6 ? ` (${path6})` : "";
3828
+ const where = path5 ? ` (${path5})` : "";
3900
3829
  printErr(
3901
3830
  `yaw-mcp audit: no server named "${namespace}" in bundles.json${where}. Run \`yaw-mcp list\` to see configured servers.`
3902
3831
  );
@@ -4080,16 +4009,16 @@ import { homedir as homedir7 } from "os";
4080
4009
  import { join as join8, resolve as resolve3 } from "path";
4081
4010
 
4082
4011
  // src/migrate.ts
4083
- import { lstat as lstat2, mkdir as mkdir4, rename as rename3, stat as stat4 } from "fs/promises";
4012
+ import { lstat, mkdir as mkdir3, rename as rename2, stat as stat3 } from "fs/promises";
4084
4013
  import { dirname as dirname5, join as join7, resolve as resolve2 } from "path";
4085
4014
  var LEGACY_GLOBAL_FILENAME = ".yaw-mcp.json";
4086
4015
  var LEGACY_PROJECT_FILENAME = ".yaw-mcp.json";
4087
4016
  var LEGACY_LOCAL_FILENAME = ".yaw-mcp.local.json";
4088
4017
  var NEW_CONFIG_FILENAME = "config.json";
4089
4018
  var NEW_LOCAL_FILENAME = "config.local.json";
4090
- async function exists(path6) {
4019
+ async function exists(path5) {
4091
4020
  try {
4092
- await stat4(path6);
4021
+ await stat3(path5);
4093
4022
  return true;
4094
4023
  } catch {
4095
4024
  return false;
@@ -4098,7 +4027,7 @@ async function exists(path6) {
4098
4027
  async function migrateFile(legacy, target, scope) {
4099
4028
  let st;
4100
4029
  try {
4101
- st = await lstat2(legacy);
4030
+ st = await lstat(legacy);
4102
4031
  } catch {
4103
4032
  return;
4104
4033
  }
@@ -4136,8 +4065,8 @@ async function migrateFile(legacy, target, scope) {
4136
4065
  return;
4137
4066
  }
4138
4067
  try {
4139
- await mkdir4(dirname5(target), { recursive: true });
4140
- await rename3(legacy, target);
4068
+ await mkdir3(dirname5(target), { recursive: true });
4069
+ await rename2(legacy, target);
4141
4070
  log("info", "yaw-mcp config: migrated legacy file into .yaw-mcp/ directory", {
4142
4071
  scope,
4143
4072
  from: legacy,
@@ -4213,32 +4142,32 @@ var KNOWN_CONFIG_KEYS = /* @__PURE__ */ new Set([
4213
4142
  "installNudge"
4214
4143
  ]);
4215
4144
  var CONFIG_SCHEMA_URL = "https://raw.githubusercontent.com/YawLabs/mcp/main/schemas/yaw-mcp.config.v1.json";
4216
- function deprecatedKeyWarning(path6, keys) {
4145
+ function deprecatedKeyWarning(path5, keys) {
4217
4146
  const quoted = keys.map((k) => `'${k}'`).join(" and ");
4218
4147
  const isAre = keys.length > 1 ? "are" : "is";
4219
4148
  const them = keys.length > 1 ? "them" : "it";
4220
4149
  const revoke = keys.includes("token") ? ` Revoke that PAT at its source -- deleting it here does not deactivate it.` : "";
4221
- return `${path6}: ${quoted} ${isAre} no longer used -- yaw-mcp is local-only and never contacts a hosted API. Delete ${them} from ${path6}.${revoke}`;
4150
+ return `${path5}: ${quoted} ${isAre} no longer used -- yaw-mcp is local-only and never contacts a hosted API. Delete ${them} from ${path5}.${revoke}`;
4222
4151
  }
4223
- var namespaceEntry = (entry, field, path6) => NAMESPACE_RE.test(entry) ? null : `${path6}: '${field}' entry '${entry}' is not a valid namespace (a lowercase letter followed by [a-z0-9_]) -- it can never match an installed server.`;
4152
+ var namespaceEntry = (entry, field, path5) => NAMESPACE_RE.test(entry) ? null : `${path5}: '${field}' entry '${entry}' is not a valid namespace (a lowercase letter followed by [a-z0-9_]) -- it can never match an installed server.`;
4224
4153
  var TOOL_ENTRY_RE = /^[A-Za-z0-9_.:-]+\*?$/;
4225
- var toolEntry = (entry, field, path6) => {
4154
+ var toolEntry = (entry, field, path5) => {
4226
4155
  if (!TOOL_ENTRY_RE.test(entry)) {
4227
- return `${path6}: '${field}' entry '${entry}' is not a valid tool name (letters, digits, '_', '.', ':', '-', with an optional single trailing '*') -- it can never match a tool.`;
4156
+ return `${path5}: '${field}' entry '${entry}' is not a valid tool name (letters, digits, '_', '.', ':', '-', with an optional single trailing '*') -- it can never match a tool.`;
4228
4157
  }
4229
4158
  if (entry.startsWith("mcp_connect_")) {
4230
- return `${path6}: '${field}' entry '${entry}' names a yaw-mcp meta-tool, which cannot be blocked -- remove it, or block the upstream server with 'blocked'.`;
4159
+ return `${path5}: '${field}' entry '${entry}' names a yaw-mcp meta-tool, which cannot be blocked -- remove it, or block the upstream server with 'blocked'.`;
4231
4160
  }
4232
4161
  if (!entry.includes("_")) {
4233
- return `${path6}: '${field}' entry '${entry}' has no '_' separator, so it cannot be a '<namespace>_<tool>' name -- to block a whole server use 'blocked'.`;
4162
+ return `${path5}: '${field}' entry '${entry}' has no '_' separator, so it cannot be a '<namespace>_<tool>' name -- to block a whole server use 'blocked'.`;
4234
4163
  }
4235
4164
  return null;
4236
4165
  };
4237
- function filterStringArray(raw, field, path6, warnings, validate = namespaceEntry, dropInvalid = false) {
4166
+ function filterStringArray(raw, field, path5, warnings, validate = namespaceEntry, dropInvalid = false) {
4238
4167
  if (!Array.isArray(raw)) {
4239
4168
  if (raw !== void 0) {
4240
4169
  warnings.push(
4241
- `${path6}: '${field}' must be an array of namespace strings (found ${raw === null ? "null" : typeof raw}) -- ignored.`
4170
+ `${path5}: '${field}' must be an array of namespace strings (found ${raw === null ? "null" : typeof raw}) -- ignored.`
4242
4171
  );
4243
4172
  }
4244
4173
  return void 0;
@@ -4247,28 +4176,28 @@ function filterStringArray(raw, field, path6, warnings, validate = namespaceEntr
4247
4176
  const dropped = raw.length - strings.length;
4248
4177
  if (dropped > 0) {
4249
4178
  warnings.push(
4250
- `${path6}: '${field}' dropped ${dropped} non-string or empty ${dropped === 1 ? "entry" : "entries"} -- only non-empty string namespaces are honored.`
4179
+ `${path5}: '${field}' dropped ${dropped} non-string or empty ${dropped === 1 ? "entry" : "entries"} -- only non-empty string namespaces are honored.`
4251
4180
  );
4252
4181
  }
4253
4182
  const kept = [];
4254
4183
  for (const s of strings) {
4255
- const problem = validate(s, field, path6);
4184
+ const problem = validate(s, field, path5);
4256
4185
  if (problem) warnings.push(problem);
4257
4186
  if (!problem || !dropInvalid) kept.push(s);
4258
4187
  }
4259
4188
  if (strings.length === 0 && raw.length > 0) return void 0;
4260
4189
  return kept;
4261
4190
  }
4262
- async function readConfigAt(path6, scope, warnings) {
4191
+ async function readConfigAt(path5, scope, warnings) {
4263
4192
  let raw;
4264
4193
  try {
4265
- raw = await readFile7(path6, "utf8");
4194
+ raw = await readFile7(path5, "utf8");
4266
4195
  } catch (err) {
4267
4196
  const code = err.code;
4268
4197
  if (code === "ENOENT" || code === "ENOTDIR") return null;
4269
4198
  const msg = err instanceof Error ? err.message : String(err);
4270
- warnings.push(`${path6}: unreadable (${code ?? msg}) -- file ignored`);
4271
- log("warn", "Config file exists but could not be read; ignoring", { path: path6, error: msg, code });
4199
+ warnings.push(`${path5}: unreadable (${code ?? msg}) -- file ignored`);
4200
+ log("warn", "Config file exists but could not be read; ignoring", { path: path5, error: msg, code });
4272
4201
  return null;
4273
4202
  }
4274
4203
  let parsed;
@@ -4276,49 +4205,49 @@ async function readConfigAt(path6, scope, warnings) {
4276
4205
  parsed = parseJsonc(raw);
4277
4206
  } catch (err) {
4278
4207
  const msg = err instanceof Error ? err.message : String(err);
4279
- warnings.push(`${path6}: invalid JSON (${msg}) -- file ignored`);
4280
- log("warn", "Config file is not valid JSON; ignoring", { path: path6, error: msg });
4208
+ warnings.push(`${path5}: invalid JSON (${msg}) -- file ignored`);
4209
+ log("warn", "Config file is not valid JSON; ignoring", { path: path5, error: msg });
4281
4210
  return null;
4282
4211
  }
4283
4212
  if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
4284
- warnings.push(`${path6}: root must be a JSON object -- file ignored`);
4213
+ warnings.push(`${path5}: root must be a JSON object -- file ignored`);
4285
4214
  return null;
4286
4215
  }
4287
4216
  const obj = parsed;
4288
4217
  const version = typeof obj.version === "number" ? obj.version : void 0;
4289
4218
  if ("version" in obj && version === void 0) {
4290
4219
  warnings.push(
4291
- `${path6}: 'version' must be a number (found ${obj.version === null ? "null" : typeof obj.version}) -- ignored; schema-version checks are skipped for this file.`
4220
+ `${path5}: 'version' must be a number (found ${obj.version === null ? "null" : typeof obj.version}) -- ignored; schema-version checks are skipped for this file.`
4292
4221
  );
4293
4222
  }
4294
4223
  if (version !== void 0 && version > CURRENT_SCHEMA_VERSION) {
4295
4224
  warnings.push(
4296
- `${path6}: schema version ${version} is newer than this yaw-mcp (${CURRENT_SCHEMA_VERSION}); upgrade with \`npm i -g @yawlabs/mcp@latest\`. Loading best-effort.`
4225
+ `${path5}: schema version ${version} is newer than this yaw-mcp (${CURRENT_SCHEMA_VERSION}); upgrade with \`npm i -g @yawlabs/mcp@latest\`. Loading best-effort.`
4297
4226
  );
4298
4227
  }
4299
4228
  const staleKeys = DEPRECATED_KEYS.filter((k) => k in obj);
4300
4229
  if (staleKeys.length > 0) {
4301
- warnings.push(deprecatedKeyWarning(path6, [...staleKeys]));
4302
- log("warn", "Config file carries retired hosted-backend keys", { path: path6, keys: staleKeys.join(",") });
4230
+ warnings.push(deprecatedKeyWarning(path5, [...staleKeys]));
4231
+ log("warn", "Config file carries retired hosted-backend keys", { path: path5, keys: staleKeys.join(",") });
4303
4232
  }
4304
4233
  const unknownKeys = Object.keys(obj).filter(
4305
4234
  (k) => !KNOWN_CONFIG_KEYS.has(k) && !DEPRECATED_KEYS.includes(k)
4306
4235
  );
4307
4236
  if (unknownKeys.length > 0) {
4308
4237
  warnings.push(
4309
- `${path6}: unknown ${unknownKeys.length === 1 ? "key" : "keys"} ${unknownKeys.map((k) => `'${k}'`).join(", ")} ignored -- known keys: ${[...KNOWN_CONFIG_KEYS].join(", ")}. Full schema: ${CONFIG_SCHEMA_URL}`
4238
+ `${path5}: unknown ${unknownKeys.length === 1 ? "key" : "keys"} ${unknownKeys.map((k) => `'${k}'`).join(", ")} ignored -- known keys: ${[...KNOWN_CONFIG_KEYS].join(", ")}. Full schema: ${CONFIG_SCHEMA_URL}`
4310
4239
  );
4311
4240
  }
4312
- const servers = filterStringArray(obj.servers, "servers", path6, warnings);
4313
- const blocked = filterStringArray(obj.blocked, "blocked", path6, warnings);
4314
- const blockedTools = filterStringArray(obj.blockedTools, "blockedTools", path6, warnings, toolEntry, true);
4241
+ const servers = filterStringArray(obj.servers, "servers", path5, warnings);
4242
+ const blocked = filterStringArray(obj.blocked, "blocked", path5, warnings);
4243
+ const blockedTools = filterStringArray(obj.blockedTools, "blockedTools", path5, warnings, toolEntry, true);
4315
4244
  const installNudge = typeof obj.installNudge === "boolean" ? obj.installNudge : void 0;
4316
4245
  if ("installNudge" in obj && installNudge === void 0) {
4317
4246
  warnings.push(
4318
- `${path6}: 'installNudge' must be a boolean (found ${obj.installNudge === null ? "null" : typeof obj.installNudge}) -- ignored; the nudge stays off for this file.`
4247
+ `${path5}: 'installNudge' must be a boolean (found ${obj.installNudge === null ? "null" : typeof obj.installNudge}) -- ignored; the nudge stays off for this file.`
4319
4248
  );
4320
4249
  }
4321
- return { path: path6, scope, version, servers, blocked, blockedTools, installNudge };
4250
+ return { path: path5, scope, version, servers, blocked, blockedTools, installNudge };
4322
4251
  }
4323
4252
  function pickServers(files) {
4324
4253
  const local = files.find((f) => f.scope === "local")?.servers;
@@ -4810,7 +4739,7 @@ async function withTransientUpstream(config, use, opts = {}) {
4810
4739
  }
4811
4740
 
4812
4741
  // src/trust-cmd.ts
4813
- import { readFile as readFile9, stat as stat5 } from "fs/promises";
4742
+ import { readFile as readFile9, stat as stat4 } from "fs/promises";
4814
4743
  import { homedir as homedir9 } from "os";
4815
4744
  import { basename as basename2, isAbsolute, join as join9, resolve as resolve4 } from "path";
4816
4745
 
@@ -5014,13 +4943,13 @@ ${SECRETS_USAGE}`
5014
4943
  }
5015
4944
  return { ok: true, options: opts };
5016
4945
  }
5017
- async function safeLoadVault(path6, io, json, action) {
4946
+ async function safeLoadVault(path5, io, json, action) {
5018
4947
  try {
5019
- return { ok: true, vault: await loadVault(path6) };
4948
+ return { ok: true, vault: await loadVault(path5) };
5020
4949
  } catch (err) {
5021
4950
  const raw = err instanceof Error ? err.message : String(err);
5022
4951
  const name = err instanceof VaultEntryCorruptError ? err.entryName : void 0;
5023
- const msg = name ? `secret entry ${name} is corrupt, and every secrets command fails until it is gone. Delete the "${name}" key from ${path6} by hand (or delete that file to start the vault over), then re-add it with \`yaw-mcp secrets set ${name}\`.` : raw;
4952
+ const msg = name ? `secret entry ${name} is corrupt, and every secrets command fails until it is gone. Delete the "${name}" key from ${path5} by hand (or delete that file to start the vault over), then re-add it with \`yaw-mcp secrets set ${name}\`.` : raw;
5024
4953
  if (json) io.err(`${JSON.stringify({ ok: false, error: msg })}
5025
4954
  `);
5026
4955
  else io.err(`yaw-mcp secrets${action ? ` ${action}` : ""}: ${msg}
@@ -5031,36 +4960,36 @@ async function safeLoadVault(path6, io, json, action) {
5031
4960
  function isVaultUnreadable(fp) {
5032
4961
  return typeof fp === "object" && fp !== null && fp.unreadable === true;
5033
4962
  }
5034
- async function vaultFingerprint(path6) {
4963
+ async function vaultFingerprint(path5) {
5035
4964
  try {
5036
- return createHash4("sha256").update(await readFile8(path6)).digest("hex");
4965
+ return createHash4("sha256").update(await readFile8(path5)).digest("hex");
5037
4966
  } catch (err) {
5038
4967
  const e = err;
5039
4968
  return e.code === "ENOENT" ? null : { unreadable: true, error: e };
5040
4969
  }
5041
4970
  }
5042
- async function vaultChangedSinceLoad(path6, baseline) {
5043
- const now = await vaultFingerprint(path6);
4971
+ async function vaultChangedSinceLoad(path5, baseline) {
4972
+ const now = await vaultFingerprint(path5);
5044
4973
  if (isVaultUnreadable(now) || isVaultUnreadable(baseline)) return true;
5045
4974
  return now !== baseline;
5046
4975
  }
5047
- function vaultUnreadableResult(io, json, action, path6, fp) {
4976
+ function vaultUnreadableResult(io, json, action, path5, fp) {
5048
4977
  const cause = fp.error.code ?? fp.error.message;
5049
- const msg = `could not read the vault file at ${path6} (${cause}) -- fix that and re-run. Nothing was written.`;
4978
+ const msg = `could not read the vault file at ${path5} (${cause}) -- fix that and re-run. Nothing was written.`;
5050
4979
  if (json) io.err(`${JSON.stringify({ ok: false, error: msg })}
5051
4980
  `);
5052
4981
  else io.err(`yaw-mcp secrets${action ? ` ${action}` : ""}: ${msg}
5053
4982
  `);
5054
4983
  return { exitCode: 1 };
5055
4984
  }
5056
- async function saveVaultOrReport(path6, vault, io, json, action) {
4985
+ async function saveVaultOrReport(path5, vault, io, json, action) {
5057
4986
  try {
5058
- await saveVault(path6, vault);
4987
+ await saveVault(path5, vault);
5059
4988
  return null;
5060
4989
  } catch (err) {
5061
4990
  const e = err;
5062
4991
  const cause = e.code ?? (err instanceof Error ? err.message : String(err));
5063
- const msg = `could not write the vault file at ${path6} (${cause}) -- nothing was saved.`;
4992
+ const msg = `could not write the vault file at ${path5} (${cause}) -- nothing was saved.`;
5064
4993
  if (json) io.err(`${JSON.stringify({ ok: false, error: msg })}
5065
4994
  `);
5066
4995
  else io.err(`yaw-mcp secrets${action ? ` ${action}` : ""}: ${msg}
@@ -5076,10 +5005,10 @@ function vaultChangedResult(io, json, action) {
5076
5005
  `);
5077
5006
  return { exitCode: 1 };
5078
5007
  }
5079
- function unlockErrorMessage(err, path6) {
5008
+ function unlockErrorMessage(err, path5) {
5080
5009
  const msg = err instanceof Error ? err.message : String(err);
5081
5010
  if (msg !== VAULT_CHECK_CORRUPT_ERROR) return msg;
5082
- return `${msg}. Your entries are intact: delete the "check" key from ${path6} by hand and re-run -- the next \`yaw-mcp secrets set\` re-stamps it.`;
5011
+ return `${msg}. Your entries are intact: delete the "check" key from ${path5} by hand and re-run -- the next \`yaw-mcp secrets set\` re-stamps it.`;
5083
5012
  }
5084
5013
  var CANCELLED = /* @__PURE__ */ Symbol("yaw-mcp:passphrase-cancelled");
5085
5014
  function cancelledResult(io, json) {
@@ -5136,7 +5065,7 @@ function warnIfShortPassphrase(io, passphrase, subject, hint) {
5136
5065
  `
5137
5066
  );
5138
5067
  }
5139
- function freshVaultNudge(io, path6) {
5068
+ function freshVaultNudge(io, path5) {
5140
5069
  const envSet = (process.env.YAW_MCP_VAULT_PASSPHRASE ?? "").length > 0;
5141
5070
  const lines = envSet ? [
5142
5071
  " YAW_MCP_VAULT_PASSPHRASE is set in THIS shell, but ${secret:NAME} refs are resolved",
@@ -5149,11 +5078,11 @@ function freshVaultNudge(io, path6) {
5149
5078
  " passphrase in-session (on clients that support elicitation) or fails to start.",
5150
5079
  " `yaw-mcp doctor` reports whether it is set."
5151
5080
  ];
5152
- io.err(`yaw-mcp secrets: created the vault at ${path6}.
5081
+ io.err(`yaw-mcp secrets: created the vault at ${path5}.
5153
5082
  ${lines.join("\n")}
5154
5083
  `);
5155
5084
  }
5156
- function schemaBehindNotice(io, vault, path6, json) {
5085
+ function schemaBehindNotice(io, vault, path5, json) {
5157
5086
  if (vault.version >= SECRETS_SCHEMA_VERSION) return;
5158
5087
  if (json) {
5159
5088
  io.err(
@@ -5162,14 +5091,14 @@ function schemaBehindNotice(io, vault, path6, json) {
5162
5091
  schema: vault.version,
5163
5092
  current: SECRETS_SCHEMA_VERSION,
5164
5093
  upgrade: "yaw-mcp secrets rotate",
5165
- path: path6
5094
+ path: path5
5166
5095
  })}
5167
5096
  `
5168
5097
  );
5169
5098
  return;
5170
5099
  }
5171
5100
  io.err(
5172
- `yaw-mcp secrets: warning -- the vault at ${path6} is schema v${vault.version} (this build writes v${SECRETS_SCHEMA_VERSION}); its ciphertexts are not bound to their entry names until \`yaw-mcp secrets rotate\` rewrites it. No other command upgrades the file.
5101
+ `yaw-mcp secrets: warning -- the vault at ${path5} is schema v${vault.version} (this build writes v${SECRETS_SCHEMA_VERSION}); its ciphertexts are not bound to their entry names until \`yaw-mcp secrets rotate\` rewrites it. No other command upgrades the file.
5173
5102
  `
5174
5103
  );
5175
5104
  }
@@ -5350,7 +5279,7 @@ async function runSecrets(opts, io = {
5350
5279
  err: createStreamWriter(process.stderr)
5351
5280
  }) {
5352
5281
  const home = opts.home ?? homedir8();
5353
- const path6 = vaultPath(home);
5282
+ const path5 = vaultPath(home);
5354
5283
  if (opts.action === "lock") {
5355
5284
  lock();
5356
5285
  if (opts.json) {
@@ -5372,30 +5301,30 @@ async function runSecrets(opts, io = {
5372
5301
  return await runSecretsAudit(opts, io);
5373
5302
  }
5374
5303
  if (opts.action === "list") {
5375
- const loaded2 = await safeLoadVault(path6, io, opts.json, "list");
5304
+ const loaded2 = await safeLoadVault(path5, io, opts.json, "list");
5376
5305
  if (!loaded2.ok) return loaded2.result;
5377
5306
  const vault2 = loaded2.vault;
5378
- if (vault2) schemaBehindNotice(io, vault2, path6, opts.json);
5307
+ if (vault2) schemaBehindNotice(io, vault2, path5, opts.json);
5379
5308
  const keys = vault2 ? listKeys(vault2) : [];
5380
5309
  if (opts.json) io.out(`${JSON.stringify({ ok: true, vault: vault2 !== null, keys }, null, 2)}
5381
5310
  `);
5382
- else if (!vault2) io.out(`No vault at ${path6}. Run \`yaw-mcp secrets set <name>\` to create one.
5311
+ else if (!vault2) io.out(`No vault at ${path5}. Run \`yaw-mcp secrets set <name>\` to create one.
5383
5312
  `);
5384
- else if (keys.length === 0) io.out(`Vault at ${path6} is empty.
5313
+ else if (keys.length === 0) io.out(`Vault at ${path5} is empty.
5385
5314
  `);
5386
5315
  else {
5387
- io.out(`Vault at ${path6}
5316
+ io.out(`Vault at ${path5}
5388
5317
  `);
5389
5318
  for (const k of keys) io.out(` ${k}
5390
5319
  `);
5391
5320
  }
5392
5321
  return { exitCode: 0 };
5393
5322
  }
5394
- const baseline = opts.action === "get" ? null : await vaultFingerprint(path6);
5395
- if (isVaultUnreadable(baseline)) return vaultUnreadableResult(io, opts.json, opts.action ?? "", path6, baseline);
5396
- const loaded = await safeLoadVault(path6, io, opts.json, opts.action ?? "");
5323
+ const baseline = opts.action === "get" ? null : await vaultFingerprint(path5);
5324
+ if (isVaultUnreadable(baseline)) return vaultUnreadableResult(io, opts.json, opts.action ?? "", path5, baseline);
5325
+ const loaded = await safeLoadVault(path5, io, opts.json, opts.action ?? "");
5397
5326
  if (!loaded.ok) return loaded.result;
5398
- if (loaded.vault) schemaBehindNotice(io, loaded.vault, path6, opts.json);
5327
+ if (loaded.vault) schemaBehindNotice(io, loaded.vault, path5, opts.json);
5399
5328
  if (opts.action === "get" || opts.action === "remove") {
5400
5329
  const name = opts.name;
5401
5330
  if (!loaded.vault || !Object.hasOwn(loaded.vault.entries, name)) {
@@ -5449,7 +5378,7 @@ async function runSecrets(opts, io = {
5449
5378
  try {
5450
5379
  key = await unlock(vault, passphrase);
5451
5380
  } catch (err) {
5452
- const msg = unlockErrorMessage(err, path6);
5381
+ const msg = unlockErrorMessage(err, path5);
5453
5382
  if (opts.json) io.err(`${JSON.stringify({ ok: false, error: msg })}
5454
5383
  `);
5455
5384
  else io.err(`yaw-mcp secrets: ${msg}
@@ -5491,8 +5420,8 @@ async function runSecrets(opts, io = {
5491
5420
  `);
5492
5421
  return { exitCode: 1 };
5493
5422
  }
5494
- if (await vaultChangedSinceLoad(path6, baseline)) return vaultChangedResult(io, opts.json, "set");
5495
- const failed = await saveVaultOrReport(path6, vault, io, opts.json, "set");
5423
+ if (await vaultChangedSinceLoad(path5, baseline)) return vaultChangedResult(io, opts.json, "set");
5424
+ const failed = await saveVaultOrReport(path5, vault, io, opts.json, "set");
5496
5425
  if (failed) return failed;
5497
5426
  if (opts.json) io.out(`${JSON.stringify({ ok: true, name, fresh_vault: isFresh, replaced: replacing })}
5498
5427
  `);
@@ -5500,7 +5429,7 @@ async function runSecrets(opts, io = {
5500
5429
  `);
5501
5430
  else io.out(`${isFresh ? "Created vault and " : ""}Stored secret "${name}".
5502
5431
  `);
5503
- if (isFresh) freshVaultNudge(io, path6);
5432
+ if (isFresh) freshVaultNudge(io, path5);
5504
5433
  return { exitCode: 0 };
5505
5434
  }
5506
5435
  if (opts.action === "get") {
@@ -5532,9 +5461,9 @@ async function runSecrets(opts, io = {
5532
5461
  }
5533
5462
  if (opts.action === "remove") {
5534
5463
  const name = opts.name;
5535
- if (await vaultChangedSinceLoad(path6, baseline)) return vaultChangedResult(io, opts.json, "remove");
5464
+ if (await vaultChangedSinceLoad(path5, baseline)) return vaultChangedResult(io, opts.json, "remove");
5536
5465
  vault = removeSecret(vault, name);
5537
- const failed = await saveVaultOrReport(path6, vault, io, opts.json, "remove");
5466
+ const failed = await saveVaultOrReport(path5, vault, io, opts.json, "remove");
5538
5467
  if (failed) return failed;
5539
5468
  if (opts.json) io.out(`${JSON.stringify({ ok: true, removed: name })}
5540
5469
  `);
@@ -5548,14 +5477,14 @@ async function runSecrets(opts, io = {
5548
5477
  }
5549
5478
  async function runSecretsRotate(opts, io) {
5550
5479
  const home = opts.home ?? homedir8();
5551
- const path6 = vaultPath(home);
5552
- const baseline = await vaultFingerprint(path6);
5553
- if (isVaultUnreadable(baseline)) return vaultUnreadableResult(io, opts.json, "rotate", path6, baseline);
5554
- const loaded = await safeLoadVault(path6, io, opts.json, "rotate");
5480
+ const path5 = vaultPath(home);
5481
+ const baseline = await vaultFingerprint(path5);
5482
+ if (isVaultUnreadable(baseline)) return vaultUnreadableResult(io, opts.json, "rotate", path5, baseline);
5483
+ const loaded = await safeLoadVault(path5, io, opts.json, "rotate");
5555
5484
  if (!loaded.ok) return loaded.result;
5556
5485
  const vault = loaded.vault;
5557
5486
  if (!vault) {
5558
- const msg = `No vault at ${path6} to rotate. Run \`yaw-mcp secrets set <name>\` first.`;
5487
+ const msg = `No vault at ${path5} to rotate. Run \`yaw-mcp secrets set <name>\` first.`;
5559
5488
  if (opts.json) io.err(`${JSON.stringify({ ok: false, error: msg })}
5560
5489
  `);
5561
5490
  else io.err(`yaw-mcp secrets rotate: ${msg}
@@ -5576,7 +5505,7 @@ async function runSecretsRotate(opts, io) {
5576
5505
  try {
5577
5506
  oldKey = await unlock(vault, currentPassphrase);
5578
5507
  } catch (err) {
5579
- const msg = unlockErrorMessage(err, path6);
5508
+ const msg = unlockErrorMessage(err, path5);
5580
5509
  if (opts.json) io.err(`${JSON.stringify({ ok: false, error: msg })}
5581
5510
  `);
5582
5511
  else io.err(`yaw-mcp secrets rotate: ${msg}
@@ -5609,11 +5538,11 @@ async function runSecretsRotate(opts, io) {
5609
5538
  lock();
5610
5539
  return { exitCode: 1 };
5611
5540
  }
5612
- if (await vaultChangedSinceLoad(path6, baseline)) {
5541
+ if (await vaultChangedSinceLoad(path5, baseline)) {
5613
5542
  lock();
5614
5543
  return vaultChangedResult(io, opts.json, "rotate");
5615
5544
  }
5616
- const failed = await saveVaultOrReport(path6, rotated, io, opts.json, "rotate");
5545
+ const failed = await saveVaultOrReport(path5, rotated, io, opts.json, "rotate");
5617
5546
  if (failed) {
5618
5547
  lock();
5619
5548
  return failed;
@@ -5800,10 +5729,10 @@ async function runTrustGrant(opts) {
5800
5729
  );
5801
5730
  return { exitCode: 1 };
5802
5731
  }
5803
- const path6 = probe.path;
5732
+ const path5 = probe.path;
5804
5733
  const raw = probe.raw;
5805
5734
  if (probe.status === "trusted") {
5806
- print(`Already approved: ${displaySafe(path6)}`);
5735
+ print(`Already approved: ${displaySafe(path5)}`);
5807
5736
  print(` contents unchanged since approval (sha256 ${probe.sha256}) -- nothing to do.`);
5808
5737
  return { exitCode: 0 };
5809
5738
  }
@@ -5819,16 +5748,16 @@ async function runTrustGrant(opts) {
5819
5748
  return { exitCode: 1 };
5820
5749
  }
5821
5750
  }
5822
- const preview = previewBundlesContent(path6, raw);
5751
+ const preview = previewBundlesContent(path5, raw);
5823
5752
  if (!preview.ok) {
5824
- printErr(`yaw-mcp trust: ${displaySafe(path6)} is not a usable bundles.json, so there is nothing to review:`);
5753
+ printErr(`yaw-mcp trust: ${displaySafe(path5)} is not a usable bundles.json, so there is nothing to review:`);
5825
5754
  for (const w of preview.warnings) printErr(` ! ${displaySafe(w)}`);
5826
5755
  printErr("Fix the file, then re-run `yaw-mcp trust`.");
5827
5756
  return { exitCode: 1 };
5828
5757
  }
5829
5758
  const serverCount = preview.servers.length;
5830
5759
  print("");
5831
- print(` Project file: ${displaySafe(path6)}`);
5760
+ print(` Project file: ${displaySafe(path5)}`);
5832
5761
  print(` SHA-256: ${probe.sha256}`);
5833
5762
  print(
5834
5763
  ` Status: ${probe.status === "changed" ? "CHANGED since you approved it" : probe.status === "store-unreadable" ? `trust store unreadable (${displaySafe(probe.storePath)})` : "never approved"}`
@@ -5879,22 +5808,22 @@ async function runTrustGrant(opts) {
5879
5808
  }
5880
5809
  let confirmBytes;
5881
5810
  try {
5882
- confirmBytes = await readFile9(path6);
5811
+ confirmBytes = await readFile9(path5);
5883
5812
  } catch (e) {
5884
5813
  printErr(
5885
- `yaw-mcp trust: ${displaySafe(path6)} could not be re-read before approving (${e.message}). Nothing approved.`
5814
+ `yaw-mcp trust: ${displaySafe(path5)} could not be re-read before approving (${e.message}). Nothing approved.`
5886
5815
  );
5887
5816
  return { exitCode: 1 };
5888
5817
  }
5889
5818
  if (hashTrustContent(confirmBytes) !== probe.sha256) {
5890
5819
  printErr(
5891
- `yaw-mcp trust: ${displaySafe(path6)} changed while you were reviewing it. Nothing approved -- re-run \`yaw-mcp trust\` to see the new contents.`
5820
+ `yaw-mcp trust: ${displaySafe(path5)} changed while you were reviewing it. Nothing approved -- re-run \`yaw-mcp trust\` to see the new contents.`
5892
5821
  );
5893
5822
  return { exitCode: 1 };
5894
5823
  }
5895
5824
  let granted;
5896
5825
  try {
5897
- granted = await grantTrust(path6, raw, { home, now: opts.now });
5826
+ granted = await grantTrust(path5, raw, { home, now: opts.now });
5898
5827
  } catch (e) {
5899
5828
  if (e instanceof TrustStoreUnreadableError) {
5900
5829
  printStoreRefusal(printErr, { storePath: e.storePath, reason: e.reason, code: e.code, kind: e.kind });
@@ -5907,7 +5836,7 @@ async function runTrustGrant(opts) {
5907
5836
  `Note: the previous trust store at ${displaySafe(granted.storePath)} was not valid JSON and has been replaced -- any other project you had approved must be approved again.`
5908
5837
  );
5909
5838
  }
5910
- print(`Approved ${displaySafe(path6)}`);
5839
+ print(`Approved ${displaySafe(path5)}`);
5911
5840
  print(` pinned to sha256 ${granted.record.sha256}`);
5912
5841
  print(` recorded in ${displaySafe(granted.storePath)}`);
5913
5842
  print(" PINNED: the exact bytes of that file -- any later edit to it re-requires approval.");
@@ -6119,9 +6048,9 @@ async function runTrustList(opts) {
6119
6048
  }
6120
6049
  return { exitCode: 0 };
6121
6050
  }
6122
- async function classifyRecord(path6, sha256) {
6051
+ async function classifyRecord(path5, sha256) {
6123
6052
  try {
6124
- const raw = await readFile9(path6);
6053
+ const raw = await readFile9(path5);
6125
6054
  return hashTrustContent(raw) === sha256 ? "ok" : "stale (content changed)";
6126
6055
  } catch (e) {
6127
6056
  const code = e.code;
@@ -6131,7 +6060,7 @@ async function classifyRecord(path6, sha256) {
6131
6060
  async function resolveRevokeTarget(target) {
6132
6061
  let isDir;
6133
6062
  try {
6134
- isDir = (await stat5(target)).isDirectory();
6063
+ isDir = (await stat4(target)).isDirectory();
6135
6064
  } catch {
6136
6065
  return target;
6137
6066
  }
@@ -7108,8 +7037,8 @@ function formatShadowLine(server) {
7108
7037
  import { createReadStream } from "fs";
7109
7038
  var GUIDE_READ_TIMEOUT_MS = 1e3;
7110
7039
  var MAX_GUIDE_BYTES = 256 * 1024;
7111
- async function readCapped(path6, signal) {
7112
- const stream = createReadStream(path6, { start: 0, end: MAX_GUIDE_BYTES, signal });
7040
+ async function readCapped(path5, signal) {
7041
+ const stream = createReadStream(path5, { start: 0, end: MAX_GUIDE_BYTES, signal });
7113
7042
  const chunks = [];
7114
7043
  let total = 0;
7115
7044
  for await (const chunk of stream) {
@@ -7122,20 +7051,20 @@ async function readCapped(path6, signal) {
7122
7051
  truncated: total > MAX_GUIDE_BYTES
7123
7052
  };
7124
7053
  }
7125
- async function readGuide(path6, scope) {
7054
+ async function readGuide(path5, scope) {
7126
7055
  let read;
7127
7056
  const ac = new AbortController();
7128
7057
  const timer = setTimeout(() => ac.abort(new Error("guide read timeout")), GUIDE_READ_TIMEOUT_MS);
7129
7058
  try {
7130
- read = await readCapped(path6, ac.signal);
7059
+ read = await readCapped(path5, ac.signal);
7131
7060
  } catch (err) {
7132
7061
  const code = err.code;
7133
7062
  if (code === "ENOENT" || code === "ENOTDIR") return null;
7134
7063
  if (code === "ABORT_ERR") {
7135
- log("warn", "Guide read timed out", { path: path6 });
7064
+ log("warn", "Guide read timed out", { path: path5 });
7136
7065
  } else {
7137
7066
  log("warn", "Guide exists but could not be read; serving no guide", {
7138
- path: path6,
7067
+ path: path5,
7139
7068
  error: err instanceof Error ? err.message : String(err)
7140
7069
  });
7141
7070
  }
@@ -7145,7 +7074,7 @@ async function readGuide(path6, scope) {
7145
7074
  }
7146
7075
  if (read.truncated) {
7147
7076
  log("warn", "Guide is larger than the size cap; serving the leading portion only", {
7148
- path: path6,
7077
+ path: path5,
7149
7078
  maxBytes: MAX_GUIDE_BYTES
7150
7079
  });
7151
7080
  }
@@ -7153,7 +7082,7 @@ async function readGuide(path6, scope) {
7153
7082
  if (content.length === 0) {
7154
7083
  return null;
7155
7084
  }
7156
- return { scope, path: path6, content };
7085
+ return { scope, path: path5, content };
7157
7086
  }
7158
7087
  async function loadUserGuide(home) {
7159
7088
  const p = guidePath(userConfigDir(home));
@@ -7222,7 +7151,7 @@ function renderActiveServersSection(activeServers) {
7222
7151
 
7223
7152
  // src/persistence.ts
7224
7153
  import { readFile as readFile10 } from "fs/promises";
7225
- import path3 from "path";
7154
+ import path2 from "path";
7226
7155
  var STATE_SCHEMA_VERSION = 2;
7227
7156
  var STATE_FILENAME = "state.json";
7228
7157
  var DISABLE_PERSISTENCE_ENV = "YAW_MCP_DISABLE_PERSISTENCE";
@@ -7240,7 +7169,7 @@ var TOOLCACHE_MAX_TOOLS_PER_NAMESPACE = 512;
7240
7169
  var TOOLCACHE_MAX_DESCRIPTION_CHARS = 2e3;
7241
7170
  var TOOLCACHE_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
7242
7171
  function statePath(configDir = userConfigDir()) {
7243
- return path3.join(configDir, STATE_FILENAME);
7172
+ return path2.join(configDir, STATE_FILENAME);
7244
7173
  }
7245
7174
  function emptyState() {
7246
7175
  return { version: STATE_SCHEMA_VERSION, savedAt: 0, learning: {}, packHistory: [], toolCache: {} };
@@ -7942,9 +7871,9 @@ function defaultReadState(home) {
7942
7871
  async function defaultWriteState(home, patch) {
7943
7872
  if (inUnitTest()) return;
7944
7873
  try {
7945
- const path6 = sidecarRefreshStatePath(home);
7874
+ const path5 = sidecarRefreshStatePath(home);
7946
7875
  const next = mergeSidecarRefreshState(defaultReadState(home), patch);
7947
- await atomicWriteFile(path6, `${JSON.stringify(next, null, 2)}
7876
+ await atomicWriteFile(path5, `${JSON.stringify(next, null, 2)}
7948
7877
  `);
7949
7878
  } catch (err) {
7950
7879
  log("debug", "sidecar-refresh: failed to record the check timestamp", {
@@ -8065,7 +7994,7 @@ async function maybeRefreshSidecars(deps = {}) {
8065
7994
  // src/try-cmd.ts
8066
7995
  import { createHash as createHash5 } from "crypto";
8067
7996
  import { existsSync as existsSync5 } from "fs";
8068
- import { chmod as chmod6, mkdir as mkdir5, readdir, readFile as readFile12, unlink as unlink2 } from "fs/promises";
7997
+ import { chmod as chmod5, mkdir as mkdir4, readdir, readFile as readFile12, unlink } from "fs/promises";
8069
7998
  import { homedir as homedir14 } from "os";
8070
7999
  import { join as join13, resolve as resolve6 } from "path";
8071
8000
  import { createInterface as createInterface2 } from "readline/promises";
@@ -8278,7 +8207,7 @@ function normalizeCatalogGrade(raw) {
8278
8207
  }
8279
8208
 
8280
8209
  // src/install-cmd.ts
8281
- import { readFile as readFile11, stat as stat6 } from "fs/promises";
8210
+ import { readFile as readFile11, stat as stat5 } from "fs/promises";
8282
8211
  import { homedir as homedir13 } from "os";
8283
8212
  import { dirname as dirname7, join as join12, resolve as resolve5, sep } from "path";
8284
8213
  import { createInterface } from "readline/promises";
@@ -8375,11 +8304,11 @@ var USAGE = (
8375
8304
 
8376
8305
  When a different \`` + ENTRY_NAME + "` entry is already in the config, install asks on a TTY\n and refuses without one, showing what differs (exit 2; a real failure, such\n as a malformed config, exits 1). Under --all the run exits 2 when every\n client that did not succeed was refused this way, and 1 if any one failed.\n Answer up front with:\n --force Overwrite whatever is there, env included: the new entry keeps\n none of the old entry's env, and install names each key it drops.\n --repair Replace an entry that has DRIFTED from what install writes,\n keeping the old entry's string-valued env; a no-op when it\n already matches, so a fixup script can run it unconditionally.\n --skip Leave the existing entry untouched and exit 0.\n --dry-run Print the entry (and any permissions patch) that WOULD be\n written, and exit 0 without touching a file.\n\n Deprecated (accepted, ignored, warns): --token <mcp_pat_...>, --no-yaw-mcp-config.\n yaw-mcp is local-only -- it stores no token and never writes ~/.yaw-mcp/config.json.\n Configure servers in ~/.yaw-mcp/bundles.json (see `yaw-mcp add <slug>`)."
8377
8306
  );
8378
- function describeUnreadableConfig(cmd, path6, err) {
8307
+ function describeUnreadableConfig(cmd, path5, err) {
8379
8308
  if (err.code === "EISDIR") {
8380
- return `yaw-mcp ${cmd}: ${path6} is a directory, not a file -- move or remove it, then re-run.`;
8309
+ return `yaw-mcp ${cmd}: ${path5} is a directory, not a file -- move or remove it, then re-run.`;
8381
8310
  }
8382
- return `yaw-mcp ${cmd}: cannot read ${path6}: ${err.message}`;
8311
+ return `yaw-mcp ${cmd}: cannot read ${path5}: ${err.message}`;
8383
8312
  }
8384
8313
  function clientUnavailableMessage(cmd, target, os, genericFix) {
8385
8314
  const reason = target.notConfigurableOn?.[os];
@@ -8823,8 +8752,11 @@ permissions.allow += ${JSON.stringify(settingsPatch.added)}`);
8823
8752
  }
8824
8753
  }
8825
8754
  const freshNote2 = yawFreshPaneNote({
8826
- grant,
8755
+ grantPatches: settingsPatches,
8827
8756
  target,
8757
+ scope,
8758
+ projectDir,
8759
+ yawMode: opts.clientEnv?.yawMode,
8828
8760
  claudeConfigDir: opts.claudeConfigDir,
8829
8761
  entryFile: resolved.absolute,
8830
8762
  wrote: [
@@ -8914,8 +8846,11 @@ permissions.allow += ${JSON.stringify(settingsPatch.added)}`);
8914
8846
  }
8915
8847
  }
8916
8848
  const freshNote = yawFreshPaneNote({
8917
- grant,
8849
+ grantPatches: settingsPatches,
8918
8850
  target,
8851
+ scope,
8852
+ projectDir,
8853
+ yawMode: opts.clientEnv?.yawMode,
8919
8854
  claudeConfigDir: opts.claudeConfigDir,
8920
8855
  entryFile: resolved.absolute,
8921
8856
  wrote: written
@@ -8977,19 +8912,22 @@ async function prepareGrantPatches(args) {
8977
8912
  }
8978
8913
  var YAW_HOME_GRANT_REASON = " -- a Yaw Mode pane's own settings.json does not outlive the pane";
8979
8914
  function yawFreshPaneNote(args) {
8980
- const overlayPatch = args.grant.patches.find((p) => !p.yawHome);
8981
8915
  const cfg = args.claudeConfigDir;
8982
- if (args.grant.overlay !== "fresh" || overlayPatch === void 0 || cfg === void 0) return null;
8983
- const entryInOverlay = samePathKey(args.entryFile).startsWith(`${samePathKey(cfg)}${sep}`);
8984
- const grantWritten = args.wrote.includes(overlayPatch.path);
8916
+ if (cfg === void 0 || yawModeOverlay({ yawMode: args.yawMode, claudeConfigDir: cfg }) !== "fresh") return null;
8917
+ const inOverlay = (file) => samePathKey(file).startsWith(`${samePathKey(cfg)}${sep}`);
8918
+ const overlayPatch = args.grantPatches.find((p) => !p.yawHome && inOverlay(p.path));
8919
+ const entryInOverlay = inOverlay(args.entryFile);
8920
+ const grantWritten = overlayPatch !== void 0 && args.wrote.includes(overlayPatch.path);
8985
8921
  const entryWritten = entryInOverlay && args.wrote.includes(args.entryFile);
8986
8922
  if (!grantWritten && !entryWritten) return null;
8987
8923
  const { label, clientId } = args.target;
8988
- const again = `Run \`yaw-mcp install ${clientId}\` from a normal shell to keep`;
8989
- if (!entryInOverlay) {
8924
+ const projectFlag = args.projectDir === void 0 ? "" : ` --project-dir ${quoteArgForDisplay(args.projectDir) ?? args.projectDir}`;
8925
+ const scopeFlags = args.scope === "user" ? "" : ` --scope ${args.scope}${projectFlag}`;
8926
+ const again = `Run \`yaw-mcp install ${clientId}${scopeFlags}\` from a normal shell to keep`;
8927
+ if (!entryInOverlay && overlayPatch !== void 0) {
8990
8928
  return `Note: a fresh Yaw Mode pane does not keep its settings.json, so the ${CLAUDE_CODE_ALLOW_PATTERN} grant in ${overlayPatch.path} goes when this pane closes. ${again} it.`;
8991
8929
  }
8992
- return overlayPatch.malformed ? `Note: a fresh Yaw Mode pane does not keep its config dir, so the ${label} entry in ${args.entryFile} goes when this pane closes. ${again} it.` : `Note: a fresh Yaw Mode pane does not keep its config dir, so the ${label} entry in ${args.entryFile} and the ${CLAUDE_CODE_ALLOW_PATTERN} grant in ${overlayPatch.path} go when this pane closes. ${again} them.`;
8930
+ return overlayPatch === void 0 || overlayPatch.malformed ? `Note: a fresh Yaw Mode pane does not keep its config dir, so the ${label} entry in ${args.entryFile} goes when this pane closes. ${again} it.` : `Note: a fresh Yaw Mode pane does not keep its config dir, so the ${label} entry in ${args.entryFile} and the ${CLAUDE_CODE_ALLOW_PATTERN} grant in ${overlayPatch.path} go when this pane closes. ${again} them.`;
8993
8931
  }
8994
8932
  async function staleProgramWarning(opts) {
8995
8933
  const probe = resolveProgramProbe(opts);
@@ -9002,9 +8940,9 @@ async function staleProgramWarning(opts) {
9002
8940
  }
9003
8941
  return probe.markers.some((marker) => bytes.includes(marker)) ? null : probe.warning;
9004
8942
  }
9005
- async function fileFingerprint(path6) {
8943
+ async function fileFingerprint(path5) {
9006
8944
  try {
9007
- const st = await stat6(path6);
8945
+ const st = await stat5(path5);
9008
8946
  return { mtimeMs: st.mtimeMs, size: st.size };
9009
8947
  } catch {
9010
8948
  return null;
@@ -9014,14 +8952,14 @@ function sameFingerprint(a, b) {
9014
8952
  if (a === null || b === null) return a === b;
9015
8953
  return a.mtimeMs === b.mtimeMs && a.size === b.size;
9016
8954
  }
9017
- async function promptCollision(path6, diff, io, keptEnvKeys) {
8955
+ async function promptCollision(path5, diff, io, keptEnvKeys) {
9018
8956
  const stdin = io?.stdin ?? process.stdin;
9019
8957
  const stdout = io?.stdout ?? process.stdout;
9020
8958
  const rl = createInterface({ input: stdin, output: stdout, terminal: io?.terminal });
9021
8959
  try {
9022
8960
  const raw = await questionOrEmpty(
9023
8961
  rl,
9024
- `${path6} already has an "${ENTRY_NAME}" entry that differs from the one install would write:
8962
+ `${path5} already has an "${ENTRY_NAME}" entry that differs from the one install would write:
9025
8963
  ${indentDiff(diff, " ")}
9026
8964
  [o]verwrite${keptEnvKeys.length > 0 ? ` (keeping env: ${keptEnvKeys.join(", ")})` : ""}, [s]kip, or [a]bort? (default: skip) `
9027
8965
  );
@@ -9451,8 +9389,8 @@ async function runInstallAll(opts, log2, err, messages) {
9451
9389
  // client (vscode) into the run.
9452
9390
  projectDir: plan.usesProjectDir ? opts.projectDir : void 0
9453
9391
  });
9454
- for (const path6 of result.written) if (!aggregateWritten.includes(path6)) aggregateWritten.push(path6);
9455
- for (const path6 of result.wouldWrite) if (!aggregateWouldWrite.includes(path6)) aggregateWouldWrite.push(path6);
9392
+ for (const path5 of result.written) if (!aggregateWritten.includes(path5)) aggregateWritten.push(path5);
9393
+ for (const path5 of result.wouldWrite) if (!aggregateWouldWrite.includes(path5)) aggregateWouldWrite.push(path5);
9456
9394
  messages.push(...result.messages);
9457
9395
  if (result.exitCode === 0) succeeded += 1;
9458
9396
  else if (result.collisionRefused) refusedClients.push(plan.clientId);
@@ -9861,7 +9799,7 @@ ${UNINSTALL_USAGE}`);
9861
9799
  }
9862
9800
  if (holder !== null) {
9863
9801
  log2(
9864
- holder.unreadable ? `Keeping ${CLAUDE_CODE_ALLOW_PATTERN} in ${settingsPatch.path}: could not read ${holder.file} to tell whether ${holder.label} (${holder.scope}) still uses it.` : carried ? `Keeping ${CLAUDE_CODE_ALLOW_PATTERN} in ${settingsPatch.path}: ${holder.label} (${holder.scope}) still launches yaw-mcp from ${holder.file}, which Yaw carries home when the pane closes.` : `Keeping ${CLAUDE_CODE_ALLOW_PATTERN} in ${settingsPatch.path}: ${holder.label} (${holder.scope}) still launches yaw-mcp from ${holder.file} and reads that grant.`
9802
+ holder.unreadable ? `Keeping ${CLAUDE_CODE_ALLOW_PATTERN} in ${settingsPatch.path}: could not read ${holder.file} to tell whether ${holder.label} (${holder.scope}) still uses it.` : carried ? `Keeping ${CLAUDE_CODE_ALLOW_PATTERN} in ${settingsPatch.path}: ${holder.label} (${holder.scope}) still launches yaw-mcp from ${holder.file}, which Yaw may carry home when the pane closes.` : `Keeping ${CLAUDE_CODE_ALLOW_PATTERN} in ${settingsPatch.path}: ${holder.label} (${holder.scope}) still launches yaw-mcp from ${holder.file} and reads that grant.`
9865
9803
  );
9866
9804
  continue;
9867
9805
  }
@@ -10573,7 +10511,7 @@ async function runTry(opts) {
10573
10511
  }
10574
10512
  const written = [];
10575
10513
  try {
10576
- await mkdir5(trialsDir(home), { recursive: true });
10514
+ await mkdir4(trialsDir(home), { recursive: true });
10577
10515
  await atomicWriteFile(trialMarkerPath(slug, home), markerJson);
10578
10516
  written.push(trialMarkerPath(slug, home));
10579
10517
  } catch (e) {
@@ -10586,7 +10524,7 @@ async function runTry(opts) {
10586
10524
  written.push(resolved.absolute);
10587
10525
  if (tightenPerms) {
10588
10526
  try {
10589
- await chmod6(resolved.absolute, 384);
10527
+ await chmod5(resolved.absolute, 384);
10590
10528
  } catch {
10591
10529
  }
10592
10530
  }
@@ -10595,7 +10533,7 @@ async function runTry(opts) {
10595
10533
  if (previousRead !== null && (!peelsPrevious || previousPeelFailedWhileTrusted)) {
10596
10534
  await atomicWriteFile(trialMarkerPath(slug, home), previousRead.raw).catch(() => void 0);
10597
10535
  } else {
10598
- await unlink2(trialMarkerPath(slug, home)).catch(() => void 0);
10536
+ await unlink(trialMarkerPath(slug, home)).catch(() => void 0);
10599
10537
  }
10600
10538
  return { exitCode: 1, written: [] };
10601
10539
  }
@@ -10727,7 +10665,7 @@ async function runTryCleanup(opts) {
10727
10665
  );
10728
10666
  }
10729
10667
  try {
10730
- await unlink2(markerPath);
10668
+ await unlink(markerPath);
10731
10669
  } catch (e) {
10732
10670
  printErr(`yaw-mcp try-cleanup: couldn't delete marker ${markerPath} (${e.message}).`);
10733
10671
  return { exitCode: 1, written: [] };
@@ -10758,9 +10696,9 @@ async function scanTrials(opts = {}) {
10758
10696
  }
10759
10697
  for (const filename of entries) {
10760
10698
  if (!filename.endsWith(".json")) continue;
10761
- const path6 = join13(dir, filename);
10699
+ const path5 = join13(dir, filename);
10762
10700
  try {
10763
- const raw = await readFile12(path6, "utf8");
10701
+ const raw = await readFile12(path5, "utf8");
10764
10702
  const parsed = JSON.parse(raw);
10765
10703
  if (!parsed || typeof parsed !== "object" || typeof parsed.slug !== "string" || typeof parsed.expiresAt !== "number" || typeof parsed.clientPath !== "string" || // Not consumed by the peel, but doctor PRINTS it verbatim ("demo ->
10766
10704
  // claude-code (expires in 42m)"), so a hand-rolled marker without it
@@ -10772,16 +10710,16 @@ async function scanTrials(opts = {}) {
10772
10710
  // understand -- is surfaced as malformed for the user rather than
10773
10711
  // acted on.
10774
10712
  rejectUntrustedMarker(parsed) !== null) {
10775
- result.malformed.push(path6);
10713
+ result.malformed.push(path5);
10776
10714
  continue;
10777
10715
  }
10778
10716
  const msUntilExpiry = parsed.expiresAt - now;
10779
10717
  const expired = msUntilExpiry <= 0;
10780
- const entry = { marker: parsed, path: path6, msUntilExpiry, expired };
10718
+ const entry = { marker: parsed, path: path5, msUntilExpiry, expired };
10781
10719
  if (expired) result.expired.push(entry);
10782
10720
  else result.live.push(entry);
10783
10721
  } catch {
10784
- result.malformed.push(path6);
10722
+ result.malformed.push(path5);
10785
10723
  }
10786
10724
  }
10787
10725
  return result;
@@ -10792,7 +10730,7 @@ async function gcExpiredTrials(opts) {
10792
10730
  if (scan.expired.length === 0) return { cleared: 0, failed: 0, failures: [] };
10793
10731
  let cleared = 0;
10794
10732
  const failures = [];
10795
- for (const { marker, path: path6 } of scan.expired) {
10733
+ for (const { marker, path: path5 } of scan.expired) {
10796
10734
  let stage = "peel";
10797
10735
  try {
10798
10736
  const outcome = await peelEntryFromConfig(
@@ -10806,19 +10744,19 @@ async function gcExpiredTrials(opts) {
10806
10744
  stage = "replaced";
10807
10745
  let markerRemoved = true;
10808
10746
  try {
10809
- await unlink2(path6);
10747
+ await unlink(path5);
10810
10748
  } catch {
10811
10749
  markerRemoved = false;
10812
10750
  }
10813
10751
  failures.push({
10814
10752
  slug: marker.slug,
10815
10753
  clientPath: marker.clientPath,
10816
- markerPath: path6,
10754
+ markerPath: path5,
10817
10755
  stage,
10818
10756
  // The WHOLE sentence, because the two cases differ in what actually
10819
10757
  // happened -- see trialGcFailureWarning, which prints this verbatim
10820
10758
  // for stage "replaced" rather than adding a tail that could contradict it.
10821
- error: markerRemoved ? `${marker.entryName} in ${marker.clientPath} was replaced since the trial wrote it, so it was left in place; the expired trial marker was deleted -- remove that entry by hand if you do not want it` : `${marker.entryName} in ${marker.clientPath} was replaced since the trial wrote it, so it was left in place; its marker ${path6} could not be deleted either, so this will be reported again -- delete that marker by hand`
10759
+ error: markerRemoved ? `${marker.entryName} in ${marker.clientPath} was replaced since the trial wrote it, so it was left in place; the expired trial marker was deleted -- remove that entry by hand if you do not want it` : `${marker.entryName} in ${marker.clientPath} was replaced since the trial wrote it, so it was left in place; its marker ${path5} could not be deleted either, so this will be reported again -- delete that marker by hand`
10822
10760
  });
10823
10761
  continue;
10824
10762
  }
@@ -10826,12 +10764,12 @@ async function gcExpiredTrials(opts) {
10826
10764
  throw new Error(`${marker.clientPath} is not a JSON object`);
10827
10765
  }
10828
10766
  stage = "unlink";
10829
- await unlink2(path6);
10767
+ await unlink(path5);
10830
10768
  cleared++;
10831
10769
  } catch (e) {
10832
10770
  const error = e.message;
10833
10771
  log("debug", "trial gc failed", { slug: marker.slug, stage, error });
10834
- failures.push({ slug: marker.slug, clientPath: marker.clientPath, markerPath: path6, stage, error });
10772
+ failures.push({ slug: marker.slug, clientPath: marker.clientPath, markerPath: path5, stage, error });
10835
10773
  }
10836
10774
  }
10837
10775
  return { cleared, failed: failures.length, failures };
@@ -11091,7 +11029,7 @@ function foldBundleWarnings(warnings, probe) {
11091
11029
  const prefix = `${probe.path}:`;
11092
11030
  return warnings.filter((w) => !w.startsWith(prefix));
11093
11031
  }
11094
- var VERSION = true ? "1.0.2" : "dev";
11032
+ var VERSION = true ? "1.0.4" : "dev";
11095
11033
  var DOCTOR_USAGE = `Usage: yaw-mcp doctor [--json]
11096
11034
 
11097
11035
  Print a diagnostic of your yaw-mcp setup.
@@ -11554,14 +11492,14 @@ function renderEnvSection(opts) {
11554
11492
  print("");
11555
11493
  }
11556
11494
  async function collectVaultStatus(opts) {
11557
- const path6 = vaultPath(opts.home);
11558
- const exists2 = existsSync6(path6);
11495
+ const path5 = vaultPath(opts.home);
11496
+ const exists2 = existsSync6(path5);
11559
11497
  let entries = exists2 ? null : [];
11560
11498
  let unreadable = null;
11561
11499
  let schemaVersion = null;
11562
11500
  if (exists2) {
11563
11501
  try {
11564
- const vault = await loadVault(path6);
11502
+ const vault = await loadVault(path5);
11565
11503
  entries = vault ? listKeys(vault) : [];
11566
11504
  schemaVersion = vault ? vault.version : null;
11567
11505
  } catch (err) {
@@ -11581,7 +11519,7 @@ async function collectVaultStatus(opts) {
11581
11519
  const referenced = new Set(refs.flatMap((r) => r.secretNames));
11582
11520
  const missing = known === null ? [] : [...referenced].filter((n) => !known.includes(n)).sort();
11583
11521
  return {
11584
- path: path6,
11522
+ path: path5,
11585
11523
  exists: exists2,
11586
11524
  entries,
11587
11525
  unreadable,
@@ -11904,8 +11842,8 @@ async function renderTrialsSection(opts) {
11904
11842
  for (const { marker, msUntilExpiry } of scan.live) {
11905
11843
  print(` ${marker.slug} -> ${marker.clientName} (${marker.clientPath}) -- expires in ${formatTtl(msUntilExpiry)}`);
11906
11844
  }
11907
- for (const path6 of scan.malformed) {
11908
- print(` ! malformed marker at ${path6} (delete by hand)`);
11845
+ for (const path5 of scan.malformed) {
11846
+ print(` ! malformed marker at ${path5} (delete by hand)`);
11909
11847
  }
11910
11848
  print("");
11911
11849
  return warnings;
@@ -12074,9 +12012,9 @@ function probeClients(opts) {
12074
12012
  }
12075
12013
  return out;
12076
12014
  }
12077
- function walkContainer(root, path6) {
12015
+ function walkContainer(root, path5) {
12078
12016
  let cur = root;
12079
- for (const key of path6) {
12017
+ for (const key of path5) {
12080
12018
  if (typeof cur !== "object" || cur === null || Array.isArray(cur)) return null;
12081
12019
  cur = cur[key];
12082
12020
  }
@@ -12293,10 +12231,10 @@ function shellHistorySources(opts) {
12293
12231
  });
12294
12232
  return sources.filter((s, i) => lastIndex.get(normalizeForCompare(resolve7(s.path))) === i);
12295
12233
  }
12296
- function readTailLines(path6, n) {
12234
+ function readTailLines(path5, n) {
12297
12235
  let fd;
12298
12236
  try {
12299
- fd = openSync(path6, "r");
12237
+ fd = openSync(path5, "r");
12300
12238
  const size = fstatSync(fd).size;
12301
12239
  const start = size > SHELL_HISTORY_TAIL_BYTES ? size - SHELL_HISTORY_TAIL_BYTES : 0;
12302
12240
  const length = size - start;
@@ -12351,12 +12289,12 @@ function compareSemver(a, b) {
12351
12289
  // src/foundry-cmd.ts
12352
12290
  import { mkdirSync as mkdirSync2, readFileSync as readFileSync5, writeFileSync } from "fs";
12353
12291
  import { homedir as homedir17 } from "os";
12354
- import path5 from "path";
12292
+ import path4 from "path";
12355
12293
 
12356
12294
  // src/foundry.ts
12357
- import { appendFile as appendFile2, mkdir as mkdir6, stat as stat7 } from "fs/promises";
12295
+ import { appendFile as appendFile2, mkdir as mkdir5, stat as stat6 } from "fs/promises";
12358
12296
  import { homedir as homedir16 } from "os";
12359
- import path4 from "path";
12297
+ import path3 from "path";
12360
12298
 
12361
12299
  // src/relevance.ts
12362
12300
  import { createHash as createHash6 } from "crypto";
@@ -12700,9 +12638,9 @@ async function appendFoundryTrace(trace, home = homedir16()) {
12700
12638
  try {
12701
12639
  if (!isFoundryEnabled()) return;
12702
12640
  const dir = userConfigDir(home);
12703
- const file = path4.join(dir, FOUNDRY_FILENAME);
12641
+ const file = path3.join(dir, FOUNDRY_FILENAME);
12704
12642
  try {
12705
- const info = await stat7(file);
12643
+ const info = await stat6(file);
12706
12644
  if (info.size >= MAX_FOUNDRY_BYTES) return;
12707
12645
  } catch {
12708
12646
  }
@@ -12712,7 +12650,7 @@ async function appendFoundryTrace(trace, home = homedir16()) {
12712
12650
  redactedCount: trace.redactedCount
12713
12651
  })}
12714
12652
  `;
12715
- await mkdir6(dir, { recursive: true, mode: 448 });
12653
+ await mkdir5(dir, { recursive: true, mode: 448 });
12716
12654
  await appendFile2(file, line, { encoding: "utf8", mode: 384 });
12717
12655
  } catch {
12718
12656
  }
@@ -12805,7 +12743,7 @@ function scoreCorpus(corpus) {
12805
12743
  }
12806
12744
 
12807
12745
  // src/foundry-cmd.ts
12808
- var DEFAULT_OUT = path5.join("src", "tests", "fixtures", "foundry-corpus.json");
12746
+ var DEFAULT_OUT = path4.join("src", "tests", "fixtures", "foundry-corpus.json");
12809
12747
  var FOUNDRY_USAGE = `Usage: yaw-mcp foundry export [--out <path>] [--cap <n>] [--json]
12810
12748
 
12811
12749
  Fold the opt-in dispatch harvest (~/.yaw-mcp/foundry.jsonl) into a routing
@@ -12884,7 +12822,7 @@ async function runFoundryExport(opts) {
12884
12822
  `);
12885
12823
  };
12886
12824
  const home = opts.home ?? homedir17();
12887
- const harvestPath = path5.join(userConfigDir(home), FOUNDRY_FILENAME);
12825
+ const harvestPath = path4.join(userConfigDir(home), FOUNDRY_FILENAME);
12888
12826
  const blob = opts.readTraces ? opts.readTraces() : (() => {
12889
12827
  try {
12890
12828
  return readFileSync5(harvestPath, "utf8");
@@ -12923,8 +12861,8 @@ async function runFoundryExport(opts) {
12923
12861
  `yaw-mcp foundry: warning -- ${toolless}/${servers.length} snapshot servers carry no tools (no entry in ~/.yaw-mcp/state.json, or it aged past the tool-cache TTL). Those rank on name + namespace only, which depresses the accuracy printed below; activate them once and re-export.`
12924
12862
  );
12925
12863
  }
12926
- const outPath = path5.resolve(opts.cwd ?? process.cwd(), opts.out);
12927
- mkdirSync2(path5.dirname(outPath), { recursive: true });
12864
+ const outPath = path4.resolve(opts.cwd ?? process.cwd(), opts.out);
12865
+ mkdirSync2(path4.dirname(outPath), { recursive: true });
12928
12866
  writeFileSync(outPath, `${JSON.stringify(corpus, null, 2)}
12929
12867
  `, "utf8");
12930
12868
  const score = scoreCorpus(corpus);
@@ -13867,8 +13805,8 @@ async function anyClientWiredToYawMcp(home, cwd, env, appData) {
13867
13805
  return true;
13868
13806
  }
13869
13807
  }
13870
- function nameBundlesFileOnce(message, path6) {
13871
- return message.split(`${path6}: `).join("");
13808
+ function nameBundlesFileOnce(message, path5) {
13809
+ return message.split(`${path5}: `).join("");
13872
13810
  }
13873
13811
  function renderLaunchChange(change) {
13874
13812
  return ` from: ${renderLaunch3(change.from)}
@@ -14158,10 +14096,10 @@ ${REMOVE_USAGE}` };
14158
14096
  opts.target = positional[0];
14159
14097
  return { ok: true, options: opts };
14160
14098
  }
14161
- async function readRawServers(path6) {
14099
+ async function readRawServers(path5) {
14162
14100
  let raw;
14163
14101
  try {
14164
- raw = await readFile14(path6, "utf8");
14102
+ raw = await readFile14(path5, "utf8");
14165
14103
  } catch {
14166
14104
  return null;
14167
14105
  }
@@ -14201,9 +14139,9 @@ function renderLaunch3(entry) {
14201
14139
  const url = typeof entry.url === "string" ? entry.url : "";
14202
14140
  return url.length > 0 ? `HTTP ${displaySafe(url)}` : "(no command)";
14203
14141
  }
14204
- function printRemovalPreview(print, path6, t) {
14142
+ function printRemovalPreview(print, path5, t) {
14205
14143
  print("");
14206
- print(` Remove from ${displaySafe(path6)}:`);
14144
+ print(` Remove from ${displaySafe(path5)}:`);
14207
14145
  print("");
14208
14146
  print(` namespace: ${t.namespace}`);
14209
14147
  print(` name: ${displaySafe(t.name)}`);
@@ -14247,8 +14185,8 @@ async function runRemove(opts) {
14247
14185
  const home = opts.home ?? homedir19();
14248
14186
  const cwd = opts.cwd ?? process.cwd();
14249
14187
  const env = opts.env ?? process.env;
14250
- const path6 = localBundlesPath(userConfigDir(home));
14251
- const rawServers = await readRawServers(path6);
14188
+ const path5 = localBundlesPath(userConfigDir(home));
14189
+ const rawServers = await readRawServers(path5);
14252
14190
  const byIdentity = namespacesForStoredIdentity(opts.target, rawServers);
14253
14191
  const candidates = [.../* @__PURE__ */ new Set([opts.target, ...byIdentity, deriveNamespace(opts.target)])];
14254
14192
  if (byIdentity.length === 0 && !REMOVE_TARGET_RE.test(opts.target)) {
@@ -14260,7 +14198,7 @@ async function runRemove(opts) {
14260
14198
  if (!opts.force) {
14261
14199
  const doomed = findRemovalTarget(candidates, rawServers);
14262
14200
  if (doomed) {
14263
- printRemovalPreview(print, path6, doomed);
14201
+ printRemovalPreview(print, path5, doomed);
14264
14202
  if (!isInteractive4(opts)) {
14265
14203
  printErr(
14266
14204
  `yaw-mcp remove: refusing to remove "${doomed.namespace}" without a confirmation -- stdin/stdout is not a TTY.`
@@ -14292,12 +14230,12 @@ async function runRemove(opts) {
14292
14230
  }
14293
14231
  }
14294
14232
  } catch (e) {
14295
- printErr(`yaw-mcp remove: ${nameBundlesFileOnce(e.message, path6)}`);
14233
+ printErr(`yaw-mcp remove: ${nameBundlesFileOnce(e.message, path5)}`);
14296
14234
  return { exitCode: 1, written: [] };
14297
14235
  }
14298
14236
  for (const w of warnings) printErr(`warning: ${w}`);
14299
14237
  if (!res?.removed) {
14300
- print(`yaw-mcp remove: no server matching "${opts.target}" in ${path6} (nothing to do).`);
14238
+ print(`yaw-mcp remove: no server matching "${opts.target}" in ${path5} (nothing to do).`);
14301
14239
  const shadow2 = await findShadowingProjectBundles(cwd, home, env).catch(() => null);
14302
14240
  if (shadow2) {
14303
14241
  printErr(
@@ -14329,10 +14267,10 @@ var LIST_USAGE = `Usage: yaw-mcp list [--json]
14329
14267
  configured yet, which is not a fault. Exits 1 when bundles.json is there
14330
14268
  and could not be read or parsed, in both modes, so a script gating on
14331
14269
  \`list\` does not read a broken config as an empty machine.`;
14332
- async function rawEnvKeysByNamespace(path6) {
14270
+ async function rawEnvKeysByNamespace(path5) {
14333
14271
  const out = /* @__PURE__ */ new Map();
14334
- if (!path6) return out;
14335
- const servers = await readRawServers(path6);
14272
+ if (!path5) return out;
14273
+ const servers = await readRawServers(path5);
14336
14274
  if (servers === null) return out;
14337
14275
  for (const s of servers) {
14338
14276
  const e = s;
@@ -14648,23 +14586,23 @@ async function runSet(opts) {
14648
14586
  assignments.push(parsed.value);
14649
14587
  }
14650
14588
  const home = opts.home ?? homedir20();
14651
- const path6 = localBundlesPath(userConfigDir(home));
14652
- if (!existsSync7(path6)) {
14589
+ const path5 = localBundlesPath(userConfigDir(home));
14590
+ if (!existsSync7(path5)) {
14653
14591
  printErr(
14654
- `yaw-mcp ${verb}: no servers configured yet (${path6} does not exist). Add one with \`yaw-mcp add <slug>\`.`
14592
+ `yaw-mcp ${verb}: no servers configured yet (${path5} does not exist). Add one with \`yaw-mcp add <slug>\`.`
14655
14593
  );
14656
14594
  return { exitCode: 1, written: [] };
14657
14595
  }
14658
14596
  return withBundlesLock(home, async () => {
14659
14597
  let rawText;
14660
14598
  try {
14661
- rawText = await readFile15(path6, "utf8");
14599
+ rawText = await readFile15(path5, "utf8");
14662
14600
  } catch (e) {
14663
14601
  if (e.code === "EISDIR") {
14664
- printErr(`yaw-mcp ${verb}: ${path6} is a directory, not a file -- move or remove it, then re-run.`);
14602
+ printErr(`yaw-mcp ${verb}: ${path5} is a directory, not a file -- move or remove it, then re-run.`);
14665
14603
  return { exitCode: 1, written: [] };
14666
14604
  }
14667
- printErr(`yaw-mcp ${verb}: ${path6} could not be read (${e.message}).`);
14605
+ printErr(`yaw-mcp ${verb}: ${path5} could not be read (${e.message}).`);
14668
14606
  return { exitCode: 1, written: [] };
14669
14607
  }
14670
14608
  let parsed;
@@ -14672,13 +14610,13 @@ async function runSet(opts) {
14672
14610
  parsed = parseJsonc(rawText);
14673
14611
  } catch (e) {
14674
14612
  printErr(
14675
- `yaw-mcp ${verb}: ${path6} could not be parsed -- fix the JSON before setting fields (${e.message}).`
14613
+ `yaw-mcp ${verb}: ${path5} could not be parsed -- fix the JSON before setting fields (${e.message}).`
14676
14614
  );
14677
14615
  return { exitCode: 1, written: [] };
14678
14616
  }
14679
14617
  const servers = parsed?.servers;
14680
14618
  if (!Array.isArray(servers)) {
14681
- printErr(`yaw-mcp ${verb}: ${path6} has no "servers" array.`);
14619
+ printErr(`yaw-mcp ${verb}: ${path5} has no "servers" array.`);
14682
14620
  printErr(
14683
14621
  ` Add a top-level "servers": [] to that file (or delete the file, and \`yaw-mcp add <slug>\` will recreate it).`
14684
14622
  );
@@ -14697,7 +14635,7 @@ async function runSet(opts) {
14697
14635
  }
14698
14636
  if (idx < 0) {
14699
14637
  printErr(
14700
- `yaw-mcp ${verb}: no server named "${target}" in ${path6}. Run \`yaw-mcp list\` to see what is configured.`
14638
+ `yaw-mcp ${verb}: no server named "${target}" in ${path5}. Run \`yaw-mcp list\` to see what is configured.`
14701
14639
  );
14702
14640
  return { exitCode: 1, written: [] };
14703
14641
  }
@@ -14708,7 +14646,7 @@ async function runSet(opts) {
14708
14646
  const targeted = envAssignments.map((a) => `env.${a.key}`).join(", ");
14709
14647
  printErr(`yaw-mcp ${verb}: "${namespace}" is a remote server, so ${targeted} would never be read.`);
14710
14648
  printErr(
14711
- ` A remote server spawns no process: its credentials travel in "headers". Re-add it with \`yaw-mcp add ${namespace} --url <url> --header 'Name: value'\`, or edit "headers" in ${path6} by hand.`
14649
+ ` A remote server spawns no process: its credentials travel in "headers". Re-add it with \`yaw-mcp add ${namespace} --url <url> --header 'Name: value'\`, or edit "headers" in ${path5} by hand.`
14712
14650
  );
14713
14651
  return { exitCode: 1, written: [] };
14714
14652
  }
@@ -14716,7 +14654,7 @@ async function runSet(opts) {
14716
14654
  if (!envIsMap && envAssignments.length > 0) {
14717
14655
  const targeted = envAssignments.map((a) => `env.${a.key}`).join(", ");
14718
14656
  printErr(
14719
- `yaw-mcp ${verb}: "${namespace}" in ${path6} has an "env" that is ${describeJsonShape2(entry.env)}, not an object of "NAME": "value" pairs.`
14657
+ `yaw-mcp ${verb}: "${namespace}" in ${path5} has an "env" that is ${describeJsonShape2(entry.env)}, not an object of "NAME": "value" pairs.`
14720
14658
  );
14721
14659
  printErr(` Fix that field by hand (or delete it), then re-run to set ${targeted}.`);
14722
14660
  return { exitCode: 1, written: [] };
@@ -14736,7 +14674,7 @@ async function runSet(opts) {
14736
14674
  const current = projectedEnv[key];
14737
14675
  if (current !== void 0 && typeof current !== "string") {
14738
14676
  printErr(
14739
- `yaw-mcp ${verb}: env.${key} on "${namespace}" is ${describeJsonShape2(current)} in ${path6}, not a string -- remove it by hand.`
14677
+ `yaw-mcp ${verb}: env.${key} on "${namespace}" is ${describeJsonShape2(current)} in ${path5}, not a string -- remove it by hand.`
14740
14678
  );
14741
14679
  printErr(" Nothing was written; re-run once that field is a string or gone.");
14742
14680
  return { exitCode: 1, written: [] };
@@ -14773,7 +14711,7 @@ async function runSet(opts) {
14773
14711
  JSON.stringify({
14774
14712
  ok: false,
14775
14713
  error: `refusing to ${phrase} on "${namespace}" without a confirmation -- stdin/stdout is not a TTY. Re-run with --force (or -y).`,
14776
- path: path6,
14714
+ path: path5,
14777
14715
  namespace,
14778
14716
  // Key NAMES only, like every other env surface here.
14779
14717
  destructive: [...destroyed.keys()]
@@ -14787,12 +14725,12 @@ async function runSet(opts) {
14787
14725
  }
14788
14726
  const answer = await askYesNo5(opts, `${phrase[0].toUpperCase()}${phrase.slice(1)} on "${namespace}"? [y/N] `);
14789
14727
  if (answer === QUESTION_CANCELLED) {
14790
- if (opts.json) printErr(JSON.stringify({ ok: false, error: "Cancelled.", cancelled: true, path: path6, namespace }));
14728
+ if (opts.json) printErr(JSON.stringify({ ok: false, error: "Cancelled.", cancelled: true, path: path5, namespace }));
14791
14729
  else printErr("Aborted.");
14792
14730
  return { exitCode: 130, written: [] };
14793
14731
  }
14794
14732
  if (answer !== "y" && answer !== "yes") {
14795
- if (opts.json) printErr(JSON.stringify({ ok: false, error: "Aborted.", aborted: true, path: path6, namespace }));
14733
+ if (opts.json) printErr(JSON.stringify({ ok: false, error: "Aborted.", aborted: true, path: path5, namespace }));
14796
14734
  else print("Aborted.");
14797
14735
  return { exitCode: 1, written: [] };
14798
14736
  }
@@ -14856,22 +14794,22 @@ async function runSet(opts) {
14856
14794
  }
14857
14795
  const changed = jsonChanges.length > 0;
14858
14796
  if (changed) {
14859
- await atomicWriteFile(path6, text, "utf8", 384, 448);
14797
+ await atomicWriteFile(path5, text, "utf8", 384, 448);
14860
14798
  }
14861
14799
  if (opts.json) {
14862
14800
  print(
14863
14801
  JSON.stringify({
14864
14802
  ok: true,
14865
- path: path6,
14803
+ path: path5,
14866
14804
  namespace,
14867
14805
  changed,
14868
14806
  changes: jsonChanges,
14869
14807
  unchanged: jsonUnchanged
14870
14808
  })
14871
14809
  );
14872
- return { exitCode: 0, written: changed ? [path6] : [] };
14810
+ return { exitCode: 0, written: changed ? [path5] : [] };
14873
14811
  }
14874
- print(changed ? `Updated "${namespace}" in ${path6}` : `No change to "${namespace}" in ${path6}`);
14812
+ print(changed ? `Updated "${namespace}" in ${path5}` : `No change to "${namespace}" in ${path5}`);
14875
14813
  for (const line of applied) print(` ${line}`);
14876
14814
  if (changed) {
14877
14815
  const stillDisabled = isActiveTouched ? assignments.some((a) => a.field === "isActive" && a.value === false) : entry.isActive === false;
@@ -14890,7 +14828,7 @@ async function runSet(opts) {
14890
14828
  }
14891
14829
  print("A running yaw-mcp applies it on its next mcp_connect_* call -- no client restart.");
14892
14830
  }
14893
- return { exitCode: 0, written: changed ? [path6] : [] };
14831
+ return { exitCode: 0, written: changed ? [path5] : [] };
14894
14832
  });
14895
14833
  }
14896
14834
  async function runEnableDisable(opts) {
@@ -14899,7 +14837,7 @@ async function runEnableDisable(opts) {
14899
14837
 
14900
14838
  // src/reset-learning-cmd.ts
14901
14839
  import { existsSync as existsSync8 } from "fs";
14902
- import { unlink as unlink3 } from "fs/promises";
14840
+ import { unlink as unlink2 } from "fs/promises";
14903
14841
  import { homedir as homedir21 } from "os";
14904
14842
  import { createInterface as createInterface6 } from "readline/promises";
14905
14843
  var RESET_LEARNING_USAGE = `Usage: yaw-mcp reset-learning
@@ -15013,7 +14951,7 @@ async function runResetLearning(opts = {}) {
15013
14951
  }
15014
14952
  }
15015
14953
  try {
15016
- await unlink3(filePath);
14954
+ await unlink2(filePath);
15017
14955
  } catch (err) {
15018
14956
  if (isFileNotFound(err)) {
15019
14957
  print("yaw-mcp reset-learning: no persisted state to reset.");
@@ -15713,21 +15651,21 @@ function installNudgeEnabled(env, config) {
15713
15651
  }
15714
15652
  var stateMemo = null;
15715
15653
  function readState(home) {
15716
- const path6 = installNudgeStatePath(home);
15717
- if (!existsSync9(path6)) {
15718
- if (stateMemo?.path === path6) stateMemo = null;
15654
+ const path5 = installNudgeStatePath(home);
15655
+ if (!existsSync9(path5)) {
15656
+ if (stateMemo?.path === path5) stateMemo = null;
15719
15657
  return { nudges: [] };
15720
15658
  }
15721
15659
  try {
15722
- const st = statSync3(path6);
15723
- if (stateMemo && stateMemo.path === path6 && stateMemo.mtimeMs === st.mtimeMs && stateMemo.size === st.size) {
15660
+ const st = statSync3(path5);
15661
+ if (stateMemo && stateMemo.path === path5 && stateMemo.mtimeMs === st.mtimeMs && stateMemo.size === st.size) {
15724
15662
  return stateMemo.state;
15725
15663
  }
15726
15664
  const remember = (state) => {
15727
- stateMemo = { path: path6, mtimeMs: st.mtimeMs, size: st.size, state };
15665
+ stateMemo = { path: path5, mtimeMs: st.mtimeMs, size: st.size, state };
15728
15666
  return state;
15729
15667
  };
15730
- const parsed = JSON.parse(readFileSync6(path6, "utf8"));
15668
+ const parsed = JSON.parse(readFileSync6(path5, "utf8"));
15731
15669
  if (!parsed || typeof parsed !== "object") return remember({ nudges: [] });
15732
15670
  const raw = parsed.nudges;
15733
15671
  if (!Array.isArray(raw)) return remember({ nudges: [] });
@@ -15760,13 +15698,13 @@ function recordNudges(clis, home, now = Date.now) {
15760
15698
  const state = readState(home);
15761
15699
  const kept = state.nudges.filter((n) => !recorded.has(n.cli) && at - clampToNow(n.nudgedAt, at) < INSTALL_NUDGE_COOLDOWN_MS).map((n) => ({ cli: n.cli, nudgedAt: clampToNow(n.nudgedAt, at) }));
15762
15700
  for (const cli of recorded) kept.push({ cli, nudgedAt: at });
15763
- const path6 = installNudgeStatePath(home);
15764
- mkdirSync3(dirname8(path6), { recursive: true });
15765
- writeFileSync2(path6, `${JSON.stringify({ nudges: kept }, null, 2)}
15701
+ const path5 = installNudgeStatePath(home);
15702
+ mkdirSync3(dirname8(path5), { recursive: true });
15703
+ writeFileSync2(path5, `${JSON.stringify({ nudges: kept }, null, 2)}
15766
15704
  `, "utf8");
15767
15705
  try {
15768
- const st = statSync3(path6);
15769
- stateMemo = { path: path6, mtimeMs: st.mtimeMs, size: st.size, state: { nudges: kept } };
15706
+ const st = statSync3(path5);
15707
+ stateMemo = { path: path5, mtimeMs: st.mtimeMs, size: st.size, state: { nudges: kept } };
15770
15708
  } catch {
15771
15709
  stateMemo = null;
15772
15710
  }
@@ -17722,7 +17660,7 @@ var ConnectServer = class _ConnectServer {
17722
17660
  static SHUTDOWN_DRAIN_MS = 2e3;
17723
17661
  constructor() {
17724
17662
  this.server = new Server(
17725
- { name: "yaw-mcp", version: true ? "1.0.2" : "dev" },
17663
+ { name: "yaw-mcp", version: true ? "1.0.4" : "dev" },
17726
17664
  {
17727
17665
  capabilities: {
17728
17666
  tools: { listChanged: true },
@@ -21125,7 +21063,7 @@ function registerShutdownTriggers(shutdown, targets) {
21125
21063
  // src/status-cmd.ts
21126
21064
  import { existsSync as existsSync10 } from "fs";
21127
21065
  import { homedir as homedir23 } from "os";
21128
- var VERSION2 = true ? "1.0.2" : "dev";
21066
+ var VERSION2 = true ? "1.0.4" : "dev";
21129
21067
  var STATUS_SCHEMA_VERSION = 1;
21130
21068
  var STATUS_USAGE = `Usage: yaw-mcp status [--json]
21131
21069
 
@@ -21877,7 +21815,7 @@ if (subcommand === "compliance") {
21877
21815
  `);
21878
21816
  process.exitCode = 0;
21879
21817
  } else if (subcommand === "--version" || subcommand === "-V") {
21880
- process.stdout.write(`yaw-mcp ${true ? "1.0.2" : "dev"}
21818
+ process.stdout.write(`yaw-mcp ${true ? "1.0.4" : "dev"}
21881
21819
  `);
21882
21820
  process.exitCode = 0;
21883
21821
  } else if (subcommand !== void 0 && !subcommand.startsWith("-")) {