@yawlabs/mcp 1.0.7 → 1.0.9
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/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@ All notable changes to `@yawlabs/mcp` (formerly `@yawlabs/mcph`) are documented
|
|
|
4
4
|
|
|
5
5
|
## Unreleased -- a fresh Yaw Mode pane names the local-scope entry it will lose
|
|
6
6
|
|
|
7
|
+
**Added -- `YAW_MCP_READONLY_DIAGNOSTICS=1` runs `doctor` and `bundles` without writing anything**
|
|
8
|
+
|
|
9
|
+
Yaw Terminal's MCP panel runs `yaw-mcp doctor --json`, `status --json` and `bundles list --json` on every refresh, and `doctor` is not read-only. It sweeps expired `yaw-mcp try` trials: a read-modify-write of each client config the trial was wired into (`~/.claude.json` among them), taken with no lock against the client that owns the file, which drops a UTF-8 BOM and adds a trailing newline on the way through. It also renames a pre-0.12 `~/.yaw-mcp.json` or project `.yaw-mcp.json` / `.yaw-mcp.local.json` into `.yaw-mcp/` as part of loading config, and so does `bundles match`. A refresh the user did not ask for should not do either.
|
|
10
|
+
|
|
11
|
+
With the variable set (`1` or `true` in any case, surrounding whitespace ignored -- the spellings `YAW_MCP_AUTO_LOAD`, `YAW_MCP_FOUNDRY` and `YAW_MCP_REWARD_GRADER` take):
|
|
12
|
+
|
|
13
|
+
- `doctor`, text and `--json`, does not run the trial sweep. It still scans the trials. An expired one is not listed as live and not dropped: each becomes a warning -- ``trial "<slug>": expired but not swept -- YAW_MCP_READONLY_DIAGNOSTICS is set, so this run edits no client config, and its entry may still be wired into <path>; run `yaw-mcp doctor` with YAW_MCP_READONLY_DIAGNOSTICS unset to sweep it, or `yaw-mcp try-cleanup <slug>` `` -- so the run exits 2, the same as for an expired trial the sweep could not remove. TRIALS prints a count and points at WARNINGS.
|
|
14
|
+
- `doctor` and `bundles match` do not migrate a legacy config file. Each file the migration would have moved is a warning instead, naming the file and where the next ordinary run moves it, because the settings in it are not part of that report. The check runs the migrator's own walk and per-file checks, so it names exactly the files a real run would move.
|
|
15
|
+
- `status` and `bundles list` wrote nothing before and write nothing now.
|
|
16
|
+
|
|
17
|
+
**`doctor --json` gains fields only on a run with the variable set**: a top-level `"readOnly": true`, and `trials.unswept` (`{ slug, clientName, clientPath, markerPath, msSinceExpiry }` per expired trial left in place, possibly empty) with `trials.sweepHint` (one display sentence naming both commands, or `null`). Without the variable, `doctor` (text and `--json`), `bundles` and `status` behave and print exactly as before: the trial sweep and the migration still run, and none of the new fields, lines or warnings appear. The variable is not listed in doctor's ENVIRONMENT section, because its 28-character name would re-pad every line of that section on every ordinary run. A run with it set prints `mode: read-only (YAW_MCP_READONLY_DIAGNOSTICS is set) -- no trial sweep, no config migration` under the header instead.
|
|
18
|
+
|
|
19
|
+
The broker never reads the variable. Its startup config load still migrates legacy files even when the variable has leaked into a client's environment, because it is the process that folds them in.
|
|
20
|
+
|
|
7
21
|
**Added -- a startup pre-warm of `npx -y <pkg>@latest` servers so the first `initialize` of a session does not pay the cold-cache tax**
|
|
8
22
|
|
|
9
23
|
A server entry shaped `{ command: "npx", args: ["-y", "@yawlabs/<x>-mcp@latest"] }` resolves `@latest` on every spawn. On a fresh `~/.npm/_npx/` cache -- which npm keeps per-tarball-URL hash and so flushes whenever a package publishes a new build -- the first spawn does a registry round-trip + a tar download + the child's own `initialize`. Together that is reliably >30s, which exceeds the downstream MCP client's `initialize` deadline and surfaces as the user-visible line "MCP request initialize to server mcp timed out after 30000ms". yaw-mcp's own `MCP_CONNECT_TIMEOUT` is 15s by default, so the user loses the activation AND yaw-mcp spends 15s in the attempt before giving up.
|
|
@@ -42,6 +56,10 @@ A `config.toml` that really does not parse is reported in TOML words by `doctor`
|
|
|
42
56
|
|
|
43
57
|
`MIN_OAM_VERSION` tracks the latest oam release as policy, and v0.16.1 is now current (published 2026-09-15); the floor was 0.15.2. A machine whose oam is older hosts its node/npx sidecars on node instead, and logs a warning naming both versions, `oam self-update` as the fix, and that yaw-mcp needs a restart afterwards. `release.sh` moved the floor and wrote this block; it did not re-run the oam hosting check that `src/oam-spawn.ts` describes.
|
|
44
58
|
|
|
59
|
+
**Changed -- the oam floor moves to 0.16.2**
|
|
60
|
+
|
|
61
|
+
`MIN_OAM_VERSION` tracks the latest oam release as policy, and v0.16.2 is now current (published 2026-09-18); the floor was 0.16.1. A machine whose oam is older hosts its node/npx sidecars on node instead, and logs a warning naming both versions, `oam self-update` as the fix, and that yaw-mcp needs a restart afterwards. `release.sh` moved the floor and wrote this block; it did not re-run the oam hosting check that `src/oam-spawn.ts` describes.
|
|
62
|
+
|
|
45
63
|
## 1.0.2 -- `install --force` stops keeping the env it promised to overwrite, editing a client config stops rewriting the entry next to ours, and the install surfaces stop stating things that are not so
|
|
46
64
|
|
|
47
65
|
An audit of the install surface. Nothing in the install blocks changes how yaw-mcp brokers servers at runtime -- they are `yaw-mcp install` and the commands that share its config-writing code -- and the blocks after the `doctor` block are unrelated changes, each saying what it touches. The `--force` block is first, deliberately: it is the first of this section's script-visible changes, and the one whose difference is a credential that used to survive and no longer does. It is not the only one -- `install --all` now exits 2 where it exited 1 on a refusal-only run, `--force --repair` together now exits 2 instead of writing, and `install --list`'s STATUS column can now read `installed (other drive case)` for a Claude Code project whose entry an older version left under the other drive-letter spelling -- and each such change is called out in the block it belongs to.
|
package/README.md
CHANGED
|
@@ -421,6 +421,7 @@ Common ones (run `yaw-mcp --help` for the full list):
|
|
|
421
421
|
| `MCP_CALL_TIMEOUT` | Milliseconds to wait for a single proxied `tools/call`. Default `60000` (the SDK's own bound); raise it for legitimately slow servers. Same `1..2147483647` whole-millisecond parse, invalid values fall back with one warn. |
|
|
422
422
|
| `YAW_MCP_IDLE_THRESHOLD` | Non-matching tool calls a loaded server tolerates before it is unloaded. Default `10`; bursty servers earn more patience automatically. The older name `MCP_CONNECT_IDLE_THRESHOLD` still works as a fallback. |
|
|
423
423
|
| `YAW_MCP_DISABLE_PERSISTENCE` | `1` keeps learning + pack history process-scoped (CI, containers). Default off. |
|
|
424
|
+
| `YAW_MCP_READONLY_DIAGNOSTICS` | `1` makes `doctor` (text and `--json`) and `bundles` write nothing, for a caller that runs them in the background on a timer. `doctor` still scans `yaw-mcp try` trials but does not sweep expired ones out of your client configs: each is reported as a warning (so the run exits 2) and listed in `--json`'s `trials.unswept`, with `trials.sweepHint` naming the fix -- a plain `yaw-mcp doctor` with the variable unset, or `yaw-mcp try-cleanup <slug>`. A pre-0.12 `~/.yaw-mcp.json` or project `.yaw-mcp.json` / `.yaw-mcp.local.json` is not moved into `.yaw-mcp/`; each is reported as a warning instead (its settings are not loaded for that run). `--json` carries `"readOnly": true` on such a run. `status` never writes, so it is unaffected. Default off. |
|
|
424
425
|
| `LOG_LEVEL` | `debug` \| `info` \| `warn` \| `error`. Default `info`. |
|
|
425
426
|
|
|
426
427
|
## Requirements
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
closeSync,
|
|
8
8
|
openSync,
|
|
9
9
|
readFileSync as readFileSync3,
|
|
10
|
-
realpathSync as
|
|
10
|
+
realpathSync as realpathSync3,
|
|
11
11
|
renameSync,
|
|
12
12
|
statSync as statSync2,
|
|
13
13
|
unlinkSync,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
writeSync
|
|
16
16
|
} from "fs";
|
|
17
17
|
import { tmpdir } from "os";
|
|
18
|
-
import { dirname as
|
|
18
|
+
import { dirname as dirname3, join as join11, sep as sep2 } from "path";
|
|
19
19
|
|
|
20
20
|
// src/atomic-write.ts
|
|
21
21
|
import { chmod, lstat, mkdir, realpath, rename, stat, unlink, writeFile } from "fs/promises";
|
|
@@ -211,14 +211,14 @@ function createStreamWriter(stream) {
|
|
|
211
211
|
|
|
212
212
|
// src/upgrade-cmd.ts
|
|
213
213
|
import { spawn as spawn2 } from "child_process";
|
|
214
|
-
import { readFileSync as readFileSync2, realpathSync } from "fs";
|
|
214
|
+
import { readFileSync as readFileSync2, realpathSync as realpathSync2 } from "fs";
|
|
215
215
|
import { join as join10 } from "path";
|
|
216
216
|
|
|
217
217
|
// src/oam-spawn.ts
|
|
218
218
|
import { spawn } from "child_process";
|
|
219
|
-
import { accessSync, constants, existsSync as existsSync2, readdirSync, readFileSync, statSync } from "fs";
|
|
219
|
+
import { accessSync, constants, existsSync as existsSync2, readdirSync as readdirSync2, readFileSync, statSync } from "fs";
|
|
220
220
|
import { homedir as homedir4 } from "os";
|
|
221
|
-
import { dirname, isAbsolute as
|
|
221
|
+
import { dirname as dirname2, isAbsolute as isAbsolute7, join as join9, sep } from "path";
|
|
222
222
|
import { fileURLToPath } from "url";
|
|
223
223
|
|
|
224
224
|
// src/install-targets.ts
|
|
@@ -3452,6 +3452,104 @@ function guidePath(configDir) {
|
|
|
3452
3452
|
return path2.join(configDir, GUIDE_FILENAME);
|
|
3453
3453
|
}
|
|
3454
3454
|
|
|
3455
|
+
// src/stable-entry.ts
|
|
3456
|
+
import { lstatSync, readdirSync, realpathSync } from "fs";
|
|
3457
|
+
import { dirname, isAbsolute as isAbsolute6, resolve as resolve6 } from "path";
|
|
3458
|
+
function isEphemeralMountPath(p) {
|
|
3459
|
+
const posix = p.replace(/\\/g, "/");
|
|
3460
|
+
return posix.includes("/AppTranslocation/") || // AppImage's FUSE mount. Anchored on the `.mount_` segment the runtime
|
|
3461
|
+
// creates, NOT on `/tmp`: the mount lives under $TMPDIR, which is not
|
|
3462
|
+
// always /tmp. Matching the segment covers a relocated TMPDIR too, without
|
|
3463
|
+
// reading the AppImage runtime's own env var.
|
|
3464
|
+
/(^|\/)\.mount_/.test(posix) || // The OTHER AppImage shape, and the one easy to miss: when FUSE is
|
|
3465
|
+
// unavailable -- a container, a hardened or older distro, `--appimage-
|
|
3466
|
+
// extract-and-run` -- the runtime does not mount at all. It unpacks to
|
|
3467
|
+
// `$TMPDIR/appimage_extracted_<hash>` and deletes that on exit, so the
|
|
3468
|
+
// path is just as temporary while looking nothing like a mount. Covering
|
|
3469
|
+
// only `.mount_` meant those users had an ephemeral path baked into a
|
|
3470
|
+
// machine-global config, and no later pass could converge on it.
|
|
3471
|
+
/(^|\/)appimage_extracted_/i.test(posix);
|
|
3472
|
+
}
|
|
3473
|
+
function stableSpellingOf(entry, deps = {}) {
|
|
3474
|
+
const realpath3 = deps.realpath ?? realpathSync;
|
|
3475
|
+
let target;
|
|
3476
|
+
try {
|
|
3477
|
+
target = realpath3(entry);
|
|
3478
|
+
} catch {
|
|
3479
|
+
return entry;
|
|
3480
|
+
}
|
|
3481
|
+
const argv1 = deps.argv1 === void 0 ? process.argv[1] : deps.argv1;
|
|
3482
|
+
if (typeof argv1 === "string" && argv1.length > 0) {
|
|
3483
|
+
try {
|
|
3484
|
+
const abs = isAbsolute6(argv1) ? argv1 : resolve6(argv1);
|
|
3485
|
+
if (abs !== entry && realpath3(abs) === target) return abs;
|
|
3486
|
+
} catch {
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
return aliasSpellingOf(entry, target, deps) ?? entry;
|
|
3490
|
+
}
|
|
3491
|
+
function aliasSpellingOf(entry, target, deps) {
|
|
3492
|
+
const realpath3 = deps.realpath ?? realpathSync;
|
|
3493
|
+
const readdir = deps.readdir ?? ((p) => readdirSync(p));
|
|
3494
|
+
const isSymlink = deps.isSymlink ?? ((p) => {
|
|
3495
|
+
try {
|
|
3496
|
+
return lstatSync(p).isSymbolicLink();
|
|
3497
|
+
} catch {
|
|
3498
|
+
return false;
|
|
3499
|
+
}
|
|
3500
|
+
});
|
|
3501
|
+
for (const ancestor of ancestorsOf(entry)) {
|
|
3502
|
+
const parent = dirname(ancestor);
|
|
3503
|
+
if (parent === ancestor) continue;
|
|
3504
|
+
const sepChar = endsWithSeparator(parent) ? "" : ancestor.charAt(parent.length);
|
|
3505
|
+
const self = ancestor.slice(parent.length + sepChar.length);
|
|
3506
|
+
if (!looksLikeVersionDir(self)) continue;
|
|
3507
|
+
let names;
|
|
3508
|
+
try {
|
|
3509
|
+
names = readdir(parent);
|
|
3510
|
+
} catch {
|
|
3511
|
+
continue;
|
|
3512
|
+
}
|
|
3513
|
+
let ancestorReal;
|
|
3514
|
+
try {
|
|
3515
|
+
ancestorReal = realpath3(ancestor);
|
|
3516
|
+
} catch {
|
|
3517
|
+
continue;
|
|
3518
|
+
}
|
|
3519
|
+
for (const name of names) {
|
|
3520
|
+
if (name === self) continue;
|
|
3521
|
+
const link = parent + sepChar + name;
|
|
3522
|
+
if (!isSymlink(link)) continue;
|
|
3523
|
+
try {
|
|
3524
|
+
if (realpath3(link) !== ancestorReal) continue;
|
|
3525
|
+
const candidate = link + entry.slice(ancestor.length);
|
|
3526
|
+
if (realpath3(candidate) === target) return candidate;
|
|
3527
|
+
} catch {
|
|
3528
|
+
}
|
|
3529
|
+
}
|
|
3530
|
+
}
|
|
3531
|
+
return null;
|
|
3532
|
+
}
|
|
3533
|
+
function endsWithSeparator(p) {
|
|
3534
|
+
const last = p.charAt(p.length - 1);
|
|
3535
|
+
return last === "/" || last === "\\";
|
|
3536
|
+
}
|
|
3537
|
+
function ancestorsOf(entry) {
|
|
3538
|
+
const out = [];
|
|
3539
|
+
let cur = dirname(entry);
|
|
3540
|
+
while (true) {
|
|
3541
|
+
const parent = dirname(cur);
|
|
3542
|
+
if (parent === cur) break;
|
|
3543
|
+
out.push(cur);
|
|
3544
|
+
cur = parent;
|
|
3545
|
+
}
|
|
3546
|
+
return out;
|
|
3547
|
+
}
|
|
3548
|
+
function looksLikeVersionDir(name) {
|
|
3549
|
+
const body = name.startsWith("v") ? name.slice(1) : name;
|
|
3550
|
+
return /^[0-9][0-9.]*([-+][0-9A-Za-z.-]+)?$/.test(body);
|
|
3551
|
+
}
|
|
3552
|
+
|
|
3455
3553
|
// src/oam-spawn.ts
|
|
3456
3554
|
function packageName(spec) {
|
|
3457
3555
|
const start = spec.startsWith("@") ? 1 : 0;
|
|
@@ -3487,7 +3585,7 @@ function npxSpec(args) {
|
|
|
3487
3585
|
const spec = args[idx];
|
|
3488
3586
|
return spec.startsWith("-") ? null : spec;
|
|
3489
3587
|
}
|
|
3490
|
-
var MIN_OAM_VERSION = "0.16.
|
|
3588
|
+
var MIN_OAM_VERSION = "0.16.2";
|
|
3491
3589
|
var OAM_INSTALL_SH = "curl -fsSL https://oamjs.org/install.sh | sh";
|
|
3492
3590
|
var OAM_INSTALL_PS1 = "irm https://oamjs.org/install.ps1 | iex";
|
|
3493
3591
|
function oamInstallCommand(os) {
|
|
@@ -3578,7 +3676,7 @@ function isExecutableFile(candidate, platform) {
|
|
|
3578
3676
|
}
|
|
3579
3677
|
}
|
|
3580
3678
|
function resolveBinAbsolute(bin, env = process.env, platform = process.platform) {
|
|
3581
|
-
if (
|
|
3679
|
+
if (isAbsolute7(bin)) return isExecutableFile(bin, platform) ? winNormalize(bin, platform) : null;
|
|
3582
3680
|
if (bin.includes("/") || platform === "win32" && bin.includes("\\")) return null;
|
|
3583
3681
|
const pathVar = env.PATH ?? env.Path ?? env.path ?? "";
|
|
3584
3682
|
if (!pathVar) return null;
|
|
@@ -3590,7 +3688,7 @@ function resolveBinAbsolute(bin, env = process.env, platform = process.platform)
|
|
|
3590
3688
|
const clean = dir.replace(/^"|"$/g, "");
|
|
3591
3689
|
for (const ext of exts) {
|
|
3592
3690
|
const candidate = join9(clean, bin + ext);
|
|
3593
|
-
if (!
|
|
3691
|
+
if (!isAbsolute7(candidate)) continue;
|
|
3594
3692
|
if (isExecutableFile(candidate, platform)) return winNormalize(candidate, platform);
|
|
3595
3693
|
}
|
|
3596
3694
|
}
|
|
@@ -3638,7 +3736,7 @@ function createProbeCollector(max = OAM_PROBE_MAX_OUTPUT) {
|
|
|
3638
3736
|
};
|
|
3639
3737
|
}
|
|
3640
3738
|
function spawnVersionProbe(bin) {
|
|
3641
|
-
return new Promise((
|
|
3739
|
+
return new Promise((resolve7, reject) => {
|
|
3642
3740
|
let settled = false;
|
|
3643
3741
|
let timer;
|
|
3644
3742
|
const settle = (fn) => {
|
|
@@ -3671,7 +3769,7 @@ function spawnVersionProbe(bin) {
|
|
|
3671
3769
|
"close",
|
|
3672
3770
|
(code, signal) => settle(() => {
|
|
3673
3771
|
if (code === 0) {
|
|
3674
|
-
|
|
3772
|
+
resolve7(collector.result());
|
|
3675
3773
|
return;
|
|
3676
3774
|
}
|
|
3677
3775
|
const err = new Error(`oam exited ${code ?? signal}`);
|
|
@@ -3854,7 +3952,7 @@ function rewriteForOam(command, args, deps) {
|
|
|
3854
3952
|
var NPX_CACHE_MARKER = `${sep}_npx${sep}`;
|
|
3855
3953
|
function npxHashNodeModules(npxRoot) {
|
|
3856
3954
|
try {
|
|
3857
|
-
return
|
|
3955
|
+
return readdirSync2(npxRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => join9(npxRoot, e.name, "node_modules"));
|
|
3858
3956
|
} catch {
|
|
3859
3957
|
return [];
|
|
3860
3958
|
}
|
|
@@ -3941,15 +4039,15 @@ function resolveNpmCacheDir(fromUrl) {
|
|
|
3941
4039
|
const candidates = [join9(homedir4(), ".npmrc")];
|
|
3942
4040
|
for (const nodeModules of ownNodeModules(fromUrl)) {
|
|
3943
4041
|
candidates.push(
|
|
3944
|
-
join9(
|
|
4042
|
+
join9(dirname2(nodeModules), "etc", "npmrc"),
|
|
3945
4043
|
// <prefix>/node_modules (Windows)
|
|
3946
|
-
join9(
|
|
4044
|
+
join9(dirname2(dirname2(nodeModules)), "etc", "npmrc"),
|
|
3947
4045
|
// <prefix>/lib/node_modules (POSIX)
|
|
3948
4046
|
join9(nodeModules, "npm", "npmrc")
|
|
3949
4047
|
// builtin, beside npm itself
|
|
3950
4048
|
);
|
|
3951
4049
|
}
|
|
3952
|
-
const nodeDir =
|
|
4050
|
+
const nodeDir = dirname2(process.execPath);
|
|
3953
4051
|
candidates.push(
|
|
3954
4052
|
join9(nodeDir, "node_modules", "npm", "npmrc"),
|
|
3955
4053
|
// Windows layout
|
|
@@ -4001,7 +4099,7 @@ function packageEntry(pkgDir, pkg) {
|
|
|
4001
4099
|
}
|
|
4002
4100
|
if (!rel && typeof j.main === "string") rel = j.main;
|
|
4003
4101
|
if (typeof rel !== "string" || rel.length === 0) return null;
|
|
4004
|
-
const entry =
|
|
4102
|
+
const entry = isAbsolute7(rel) ? rel : join9(pkgDir, rel);
|
|
4005
4103
|
if (!existsSync2(entry)) return null;
|
|
4006
4104
|
return {
|
|
4007
4105
|
entry,
|
|
@@ -4094,11 +4192,12 @@ function notePinnedSidecar(pkg, version, source, from) {
|
|
|
4094
4192
|
}
|
|
4095
4193
|
);
|
|
4096
4194
|
}
|
|
4097
|
-
function resolveStableNpmEntry(pkg, fromUrl = import.meta.url) {
|
|
4195
|
+
function resolveStableNpmEntry(pkg, fromUrl = import.meta.url, deps = {}) {
|
|
4098
4196
|
for (const nodeModules of ownNodeModules(fromUrl)) {
|
|
4099
4197
|
if (nodeModules.includes(NPX_CACHE_MARKER)) continue;
|
|
4198
|
+
if (isEphemeralMountPath(nodeModules)) continue;
|
|
4100
4199
|
const hit = packageEntry(join9(nodeModules, ...pkg.split("/")), pkg);
|
|
4101
|
-
if (hit) return hit.entry;
|
|
4200
|
+
if (hit) return stableSpellingOf(hit.entry, deps);
|
|
4102
4201
|
}
|
|
4103
4202
|
return null;
|
|
4104
4203
|
}
|
|
@@ -4149,15 +4248,30 @@ function isOamLaunch(command, args = []) {
|
|
|
4149
4248
|
const first = args.find((a) => !/^\/[a-z]$/i.test(a));
|
|
4150
4249
|
return first !== void 0 && isOamCommand(first);
|
|
4151
4250
|
}
|
|
4152
|
-
if (
|
|
4251
|
+
if (POSIX_SHELL.test(base)) {
|
|
4153
4252
|
const dashC = args.indexOf("-c");
|
|
4154
4253
|
const payload = dashC >= 0 ? args[dashC + 1] : args[0];
|
|
4155
4254
|
if (payload === void 0) return false;
|
|
4156
4255
|
const firstToken = payload.trim().split(/\s+/)[0]?.replace(/^["']|["']$/g, "");
|
|
4157
4256
|
return firstToken !== void 0 && firstToken.length > 0 && isOamCommand(firstToken);
|
|
4158
4257
|
}
|
|
4258
|
+
if (POWERSHELL.test(base)) {
|
|
4259
|
+
const payload = powershellPayload(args);
|
|
4260
|
+
if (payload === null) return false;
|
|
4261
|
+
const firstToken = payload.trim().split(/\s+/)[0]?.replace(/^["']|["']$/g, "");
|
|
4262
|
+
return firstToken !== void 0 && firstToken.length > 0 && isOamCommand(firstToken);
|
|
4263
|
+
}
|
|
4159
4264
|
return false;
|
|
4160
4265
|
}
|
|
4266
|
+
var POSIX_SHELL = /^(sh|bash|zsh|dash|fish)$/i;
|
|
4267
|
+
var POWERSHELL = /^(pwsh|powershell)(\.exe)?$/i;
|
|
4268
|
+
var PS_COMMAND_SWITCH = /^-c(o(m(m(a(n(d)?)?)?)?)?)?$/i;
|
|
4269
|
+
function powershellPayload(args) {
|
|
4270
|
+
const i = args.findIndex((a) => PS_COMMAND_SWITCH.test(a));
|
|
4271
|
+
if (i < 0) return null;
|
|
4272
|
+
const payload = args.slice(i + 1).join(" ");
|
|
4273
|
+
return payload.trim().length > 0 ? payload : null;
|
|
4274
|
+
}
|
|
4161
4275
|
|
|
4162
4276
|
// src/upgrade-cmd.ts
|
|
4163
4277
|
var POSIX_GLOBAL_LIB_PREFIX = /^(?:[A-Za-z]:)?(?:\/usr(?:\/local)?|\/opt\/[^/]+)\/lib\/node_modules\/@yawlabs\/mcp\//;
|
|
@@ -4190,7 +4304,7 @@ ${UPGRADE_USAGE}` };
|
|
|
4190
4304
|
}
|
|
4191
4305
|
return { ok: true, options: opts };
|
|
4192
4306
|
}
|
|
4193
|
-
function detectInstallMethod(argvPath, realpath3 =
|
|
4307
|
+
function detectInstallMethod(argvPath, realpath3 = realpathSync2, resolveWhen = ["unknown"]) {
|
|
4194
4308
|
if (!argvPath) return "unknown";
|
|
4195
4309
|
const literal = classifyEntrypoint(argvPath);
|
|
4196
4310
|
if (!resolveWhen.includes(literal)) return literal;
|
|
@@ -4222,7 +4336,7 @@ function localInstallRoot(argvPath) {
|
|
|
4222
4336
|
const idx = argvPath.replace(/\\/g, "/").indexOf("/node_modules/");
|
|
4223
4337
|
return idx > 0 ? argvPath.slice(0, idx) : null;
|
|
4224
4338
|
}
|
|
4225
|
-
function runningPackageDir(argvPath, realpath3 =
|
|
4339
|
+
function runningPackageDir(argvPath, realpath3 = realpathSync2) {
|
|
4226
4340
|
if (!argvPath) return null;
|
|
4227
4341
|
const literal = packageDirOf(argvPath);
|
|
4228
4342
|
if (literal !== null) return literal;
|
|
@@ -4259,7 +4373,7 @@ function killProcessTree(child, platform = process.platform, spawnImpl = spawn2)
|
|
|
4259
4373
|
async function npmGlobalPrefix(spawnImpl) {
|
|
4260
4374
|
if (process.env.VITEST && !spawnImpl) return null;
|
|
4261
4375
|
const spawnFn = spawnImpl ?? spawn2;
|
|
4262
|
-
return new Promise((
|
|
4376
|
+
return new Promise((resolve7) => {
|
|
4263
4377
|
const child = spawnFn("npm", ["prefix", "-g"], {
|
|
4264
4378
|
shell: process.platform === "win32",
|
|
4265
4379
|
stdio: ["ignore", "pipe", "ignore"],
|
|
@@ -4270,25 +4384,25 @@ async function npmGlobalPrefix(spawnImpl) {
|
|
|
4270
4384
|
let out = "";
|
|
4271
4385
|
const timer = setTimeout(() => {
|
|
4272
4386
|
killProcessTree(child);
|
|
4273
|
-
|
|
4387
|
+
resolve7(null);
|
|
4274
4388
|
}, 3e3);
|
|
4275
4389
|
child.stdout?.on("data", (d) => {
|
|
4276
4390
|
out += String(d);
|
|
4277
4391
|
});
|
|
4278
4392
|
child.on("close", (code) => {
|
|
4279
4393
|
clearTimeout(timer);
|
|
4280
|
-
|
|
4394
|
+
resolve7(code === 0 && out.trim() ? out.trim() : null);
|
|
4281
4395
|
});
|
|
4282
4396
|
child.on("error", () => {
|
|
4283
4397
|
clearTimeout(timer);
|
|
4284
|
-
|
|
4398
|
+
resolve7(null);
|
|
4285
4399
|
});
|
|
4286
4400
|
});
|
|
4287
4401
|
}
|
|
4288
4402
|
function comparablePath(p) {
|
|
4289
4403
|
let real = p;
|
|
4290
4404
|
try {
|
|
4291
|
-
real =
|
|
4405
|
+
real = realpathSync2(p);
|
|
4292
4406
|
} catch {
|
|
4293
4407
|
}
|
|
4294
4408
|
const normalized = real.replace(/\\/g, "/");
|
|
@@ -4415,11 +4529,11 @@ async function oamFloorLines(probe) {
|
|
|
4415
4529
|
}
|
|
4416
4530
|
async function defaultRunningPrefix(argvPath) {
|
|
4417
4531
|
if (process.env.VITEST) return null;
|
|
4418
|
-
const { detectRunningInstallPrefix: detectRunningInstallPrefix2 } = await import("./auto-upgrade-
|
|
4532
|
+
const { detectRunningInstallPrefix: detectRunningInstallPrefix2 } = await import("./auto-upgrade-NFRIH42D.js");
|
|
4419
4533
|
return detectRunningInstallPrefix2(argvPath);
|
|
4420
4534
|
}
|
|
4421
4535
|
async function defaultSpawn(cmd, args, cwd) {
|
|
4422
|
-
return new Promise((
|
|
4536
|
+
return new Promise((resolve7) => {
|
|
4423
4537
|
const child = spawn2(cmd, args, {
|
|
4424
4538
|
stdio: "inherit",
|
|
4425
4539
|
shell: process.platform === "win32",
|
|
@@ -4430,8 +4544,8 @@ async function defaultSpawn(cmd, args, cwd) {
|
|
|
4430
4544
|
// them. See internal-secret-env.ts.
|
|
4431
4545
|
env: stripInternalSecretsFromEnv(process.env)
|
|
4432
4546
|
});
|
|
4433
|
-
child.on("close", (code) =>
|
|
4434
|
-
child.on("error", () =>
|
|
4547
|
+
child.on("close", (code) => resolve7(typeof code === "number" ? code : 1));
|
|
4548
|
+
child.on("error", () => resolve7(1));
|
|
4435
4549
|
});
|
|
4436
4550
|
}
|
|
4437
4551
|
async function detectSea() {
|
|
@@ -4476,7 +4590,7 @@ async function runUpgrade(opts = {}) {
|
|
|
4476
4590
|
if (method === "global-npm") {
|
|
4477
4591
|
const rawPrefix = await (opts.runningPrefix ?? defaultRunningPrefix)(argvPath);
|
|
4478
4592
|
if (rawPrefix !== null) {
|
|
4479
|
-
const { quoteArgForDisplay: quoteArgForDisplay2, quoteShellArgIfNeeded: quoteShellArgIfNeeded2 } = await import("./auto-upgrade-
|
|
4593
|
+
const { quoteArgForDisplay: quoteArgForDisplay2, quoteShellArgIfNeeded: quoteShellArgIfNeeded2 } = await import("./auto-upgrade-NFRIH42D.js");
|
|
4480
4594
|
const spawnForm = quoteShellArgIfNeeded2(rawPrefix, opts.platform);
|
|
4481
4595
|
const displayForm = quoteArgForDisplay2(rawPrefix, opts.platform);
|
|
4482
4596
|
if (spawnForm !== null && displayForm !== null) {
|
|
@@ -4593,7 +4707,7 @@ async function runUpgrade(opts = {}) {
|
|
|
4593
4707
|
return { exitCode: 3, lines };
|
|
4594
4708
|
}
|
|
4595
4709
|
function readCurrentVersion() {
|
|
4596
|
-
return true ? "1.0.
|
|
4710
|
+
return true ? "1.0.9" : "dev";
|
|
4597
4711
|
}
|
|
4598
4712
|
|
|
4599
4713
|
// src/auto-upgrade.ts
|
|
@@ -4612,11 +4726,11 @@ function detectRunningInstallPrefix(argvPath) {
|
|
|
4612
4726
|
if (!argvPath) return null;
|
|
4613
4727
|
let resolved;
|
|
4614
4728
|
try {
|
|
4615
|
-
resolved =
|
|
4729
|
+
resolved = realpathSync3(argvPath);
|
|
4616
4730
|
} catch {
|
|
4617
4731
|
return null;
|
|
4618
4732
|
}
|
|
4619
|
-
const dir =
|
|
4733
|
+
const dir = dirname3(resolved);
|
|
4620
4734
|
const idx = dir.lastIndexOf(`${sep2}node_modules${sep2}`);
|
|
4621
4735
|
if (idx === -1) return null;
|
|
4622
4736
|
const candidate = dir.slice(0, idx);
|
|
@@ -4875,10 +4989,10 @@ function defaultSpawn2(cmd, args, onDone = () => {
|
|
|
4875
4989
|
async function maybeAutoUpgrade(deps = {}) {
|
|
4876
4990
|
const optOut = process.env.YAW_MCP_AUTO_UPGRADE;
|
|
4877
4991
|
if (optOut === "0" || optOut?.toLowerCase() === "false") return;
|
|
4878
|
-
const current = deps.currentVersion ?? (true ? "1.0.
|
|
4992
|
+
const current = deps.currentVersion ?? (true ? "1.0.9" : "dev");
|
|
4879
4993
|
if (current === "dev") return;
|
|
4880
4994
|
const argvPath = deps.argvPath ?? process.argv[1];
|
|
4881
|
-
const method = (deps.isSeaImpl ? await deps.isSeaImpl() : await detectSea()) ? "binary" : detectInstallMethod(argvPath,
|
|
4995
|
+
const method = (deps.isSeaImpl ? await deps.isSeaImpl() : await detectSea()) ? "binary" : detectInstallMethod(argvPath, realpathSync3, ["unknown", "local-node-modules"]);
|
|
4882
4996
|
const cached = (deps.checkedRecentlyImpl ?? defaultCheckedRecently)();
|
|
4883
4997
|
let latest;
|
|
4884
4998
|
if (cached !== null) {
|
|
@@ -5013,8 +5127,12 @@ export {
|
|
|
5013
5127
|
containerNounFor,
|
|
5014
5128
|
effectiveConfigFormat,
|
|
5015
5129
|
selectSites,
|
|
5130
|
+
addressOf,
|
|
5016
5131
|
unloadableConfigProblem,
|
|
5017
5132
|
unloadableConfigFix,
|
|
5133
|
+
launchOf,
|
|
5134
|
+
carryableEnvOf,
|
|
5135
|
+
carriedFieldsOf,
|
|
5018
5136
|
importViewOf,
|
|
5019
5137
|
composeEntry,
|
|
5020
5138
|
reloadDoneClause,
|
|
@@ -5064,6 +5182,9 @@ export {
|
|
|
5064
5182
|
resolveOamSpawn,
|
|
5065
5183
|
isOamCommand,
|
|
5066
5184
|
isOamLaunch,
|
|
5185
|
+
POSIX_SHELL,
|
|
5186
|
+
POWERSHELL,
|
|
5187
|
+
powershellPayload,
|
|
5067
5188
|
parseUpgradeArgs,
|
|
5068
5189
|
detectInstallMethod,
|
|
5069
5190
|
refineInstallMethod,
|
package/dist/index.js
CHANGED
|
@@ -10,13 +10,18 @@ import {
|
|
|
10
10
|
INTERNAL_SECRET_ENV_KEYS,
|
|
11
11
|
LEGACY_ENTRY_NAMES,
|
|
12
12
|
MIN_OAM_VERSION,
|
|
13
|
+
POSIX_SHELL,
|
|
14
|
+
POWERSHELL,
|
|
13
15
|
acquireUpgradeLock,
|
|
16
|
+
addressOf,
|
|
14
17
|
applyClientConfigEdits,
|
|
15
18
|
atomicWriteFile,
|
|
16
19
|
blockedContainerFix,
|
|
17
20
|
buildLaunchEntry,
|
|
18
21
|
buildUpgradePlan,
|
|
19
22
|
cacheDir,
|
|
23
|
+
carriedFieldsOf,
|
|
24
|
+
carryableEnvOf,
|
|
20
25
|
classifyClientConfig,
|
|
21
26
|
claudeCodeContainerPathVariants,
|
|
22
27
|
claudeCodeContainerPaths,
|
|
@@ -43,6 +48,7 @@ import {
|
|
|
43
48
|
isRegistrySpec,
|
|
44
49
|
isUnderHome,
|
|
45
50
|
isWin32TransientFsError,
|
|
51
|
+
launchOf,
|
|
46
52
|
log,
|
|
47
53
|
maybeAutoUpgrade,
|
|
48
54
|
nodeLaunchKind,
|
|
@@ -58,6 +64,7 @@ import {
|
|
|
58
64
|
packageName,
|
|
59
65
|
parseJsonc,
|
|
60
66
|
parseUpgradeArgs,
|
|
67
|
+
powershellPayload,
|
|
61
68
|
prepareClaudeCodeSettingsPatch,
|
|
62
69
|
probeOam,
|
|
63
70
|
quoteArgForDisplay,
|
|
@@ -93,7 +100,7 @@ import {
|
|
|
93
100
|
unparseableConfigFix,
|
|
94
101
|
userConfigDir,
|
|
95
102
|
yawModeOverlay
|
|
96
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-7MK2GPCC.js";
|
|
97
104
|
|
|
98
105
|
// src/audit-cmd.ts
|
|
99
106
|
import { homedir as homedir6 } from "os";
|
|
@@ -3196,7 +3203,7 @@ async function connectToUpstreamOnce(config, onDisconnect, onListChanged, bridge
|
|
|
3196
3203
|
if (downstreamCaps?.sampling) capabilities.sampling = downstreamCaps.sampling;
|
|
3197
3204
|
if (downstreamCaps?.roots) capabilities.roots = {};
|
|
3198
3205
|
const client = new Client(
|
|
3199
|
-
{ name: "yaw-mcp", version: true ? "1.0.
|
|
3206
|
+
{ name: "yaw-mcp", version: true ? "1.0.9" : "dev" },
|
|
3200
3207
|
{ capabilities }
|
|
3201
3208
|
);
|
|
3202
3209
|
if (bridge && capabilities.elicitation) {
|
|
@@ -4026,7 +4033,7 @@ async function exists(path5) {
|
|
|
4026
4033
|
return false;
|
|
4027
4034
|
}
|
|
4028
4035
|
}
|
|
4029
|
-
async function migrateFile(legacy, target, scope) {
|
|
4036
|
+
async function migrateFile(legacy, target, scope, plan) {
|
|
4030
4037
|
let st;
|
|
4031
4038
|
try {
|
|
4032
4039
|
st = await lstat(legacy);
|
|
@@ -4066,6 +4073,10 @@ async function migrateFile(legacy, target, scope) {
|
|
|
4066
4073
|
});
|
|
4067
4074
|
return;
|
|
4068
4075
|
}
|
|
4076
|
+
if (plan !== null) {
|
|
4077
|
+
plan.push({ scope, legacy, target });
|
|
4078
|
+
return;
|
|
4079
|
+
}
|
|
4069
4080
|
try {
|
|
4070
4081
|
await mkdir3(dirname5(target), { recursive: true });
|
|
4071
4082
|
await rename2(legacy, target);
|
|
@@ -4092,10 +4103,18 @@ async function migrateFile(legacy, target, scope) {
|
|
|
4092
4103
|
}
|
|
4093
4104
|
}
|
|
4094
4105
|
async function migrateLegacyConfigPaths(opts) {
|
|
4106
|
+
await walkLegacyConfigPaths(opts, null);
|
|
4107
|
+
}
|
|
4108
|
+
async function planLegacyConfigMigration(opts) {
|
|
4109
|
+
const plan = [];
|
|
4110
|
+
await walkLegacyConfigPaths(opts, plan);
|
|
4111
|
+
return plan;
|
|
4112
|
+
}
|
|
4113
|
+
async function walkLegacyConfigPaths(opts, plan) {
|
|
4095
4114
|
const { cwd, home } = opts;
|
|
4096
4115
|
const legacyGlobal = join7(home, LEGACY_GLOBAL_FILENAME);
|
|
4097
4116
|
const newGlobal = join7(userConfigDir(home), NEW_CONFIG_FILENAME);
|
|
4098
|
-
await migrateFile(legacyGlobal, newGlobal, "global");
|
|
4117
|
+
await migrateFile(legacyGlobal, newGlobal, "global", plan);
|
|
4099
4118
|
const homeLocal = join7(home, LEGACY_LOCAL_FILENAME);
|
|
4100
4119
|
if (await exists(homeLocal)) {
|
|
4101
4120
|
log("warn", "yaw-mcp config: legacy machine-local file at $HOME has no new location -- leaving it in place", {
|
|
@@ -4109,10 +4128,10 @@ async function migrateLegacyConfigPaths(opts) {
|
|
|
4109
4128
|
const newDir = join7(legacyProjectRoot, CONFIG_DIRNAME);
|
|
4110
4129
|
const legacyLocal = join7(legacyProjectRoot, LEGACY_LOCAL_FILENAME);
|
|
4111
4130
|
const newLocal = join7(newDir, NEW_LOCAL_FILENAME);
|
|
4112
|
-
await migrateFile(legacyLocal, newLocal, "local");
|
|
4131
|
+
await migrateFile(legacyLocal, newLocal, "local", plan);
|
|
4113
4132
|
const legacyProject = join7(legacyProjectRoot, LEGACY_PROJECT_FILENAME);
|
|
4114
4133
|
const newProject = join7(newDir, NEW_CONFIG_FILENAME);
|
|
4115
|
-
await migrateFile(legacyProject, newProject, "project");
|
|
4134
|
+
await migrateFile(legacyProject, newProject, "project", plan);
|
|
4116
4135
|
}
|
|
4117
4136
|
}
|
|
4118
4137
|
async function findLegacyProjectRoot(cwd, home) {
|
|
@@ -4134,6 +4153,15 @@ async function findLegacyProjectRoot(cwd, home) {
|
|
|
4134
4153
|
var CONFIG_FILENAME = "config.json";
|
|
4135
4154
|
var LOCAL_CONFIG_FILENAME = "config.local.json";
|
|
4136
4155
|
var CURRENT_SCHEMA_VERSION = 1;
|
|
4156
|
+
var READONLY_DIAGNOSTICS_ENV = "YAW_MCP_READONLY_DIAGNOSTICS";
|
|
4157
|
+
function isReadOnlyDiagnostics(env = process.env) {
|
|
4158
|
+
const raw = env[READONLY_DIAGNOSTICS_ENV]?.trim();
|
|
4159
|
+
if (raw === void 0 || raw === "") return false;
|
|
4160
|
+
return raw === "1" || raw.toLowerCase() === "true";
|
|
4161
|
+
}
|
|
4162
|
+
function legacyMigrationSkippedWarning(p) {
|
|
4163
|
+
return `${p.legacy}: pre-0.12 config file not migrated -- ${READONLY_DIAGNOSTICS_ENV} is set, so this run moves no files and the settings in it are NOT part of this report. The next yaw-mcp start (or this command with ${READONLY_DIAGNOSTICS_ENV} unset) moves it to ${p.target}.`;
|
|
4164
|
+
}
|
|
4137
4165
|
var DEPRECATED_KEYS = ["token", "apiBase"];
|
|
4138
4166
|
var KNOWN_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
4139
4167
|
"$schema",
|
|
@@ -4295,7 +4323,17 @@ async function loadYawMcpConfig(opts = {}) {
|
|
|
4295
4323
|
const home = resolve3(opts.home ?? homedir7());
|
|
4296
4324
|
const warnings = [];
|
|
4297
4325
|
const loadedFiles = [];
|
|
4298
|
-
|
|
4326
|
+
if (opts.readOnly) {
|
|
4327
|
+
const pending2 = await planLegacyConfigMigration({ cwd, home }).catch((err) => {
|
|
4328
|
+
log("warn", "Legacy config migration check failed", {
|
|
4329
|
+
error: err instanceof Error ? err.message : String(err)
|
|
4330
|
+
});
|
|
4331
|
+
return [];
|
|
4332
|
+
});
|
|
4333
|
+
for (const p of pending2) warnings.push(legacyMigrationSkippedWarning(p));
|
|
4334
|
+
} else {
|
|
4335
|
+
await migrateLegacyConfigPathsOnce(cwd, home);
|
|
4336
|
+
}
|
|
4299
4337
|
const projectConfigDir = await findProjectConfigDir(cwd, home, opts.env).catch((err) => {
|
|
4300
4338
|
log("warn", "Failed searching for project .yaw-mcp/ dir", {
|
|
4301
4339
|
error: err instanceof Error ? err.message : String(err)
|
|
@@ -4427,7 +4465,7 @@ async function runBundlesCommand(opts = {}) {
|
|
|
4427
4465
|
}
|
|
4428
4466
|
const env = opts.env ?? process.env;
|
|
4429
4467
|
const loaded = await loadLocalBundles({ cwd: opts.cwd, home: opts.home, env });
|
|
4430
|
-
const config = await loadYawMcpConfig({ cwd: opts.cwd, home: opts.home, env });
|
|
4468
|
+
const config = await loadYawMcpConfig({ cwd: opts.cwd, home: opts.home, env, readOnly: isReadOnlyDiagnostics(env) });
|
|
4431
4469
|
for (const w of loaded.warnings) printErr(`warning: ${w}`);
|
|
4432
4470
|
for (const w of config.warnings) printErr(`warning: ${w}`);
|
|
4433
4471
|
const enabled = (loaded.config?.servers ?? []).filter((s) => s.isActive).map((s) => s.namespace);
|
|
@@ -6595,6 +6633,11 @@ var SUBCOMMAND_SPEC = [
|
|
|
6595
6633
|
flags: ["--json", "--help"]
|
|
6596
6634
|
},
|
|
6597
6635
|
{ name: "doctor", description: "Print diagnostic of yaw-mcp setup", flags: ["--json", "--help"] },
|
|
6636
|
+
{
|
|
6637
|
+
name: "heal",
|
|
6638
|
+
description: "Re-point client entries whose launch file no longer exists",
|
|
6639
|
+
flags: ["--json", "--dry-run", "--quiet", "--help"]
|
|
6640
|
+
},
|
|
6598
6641
|
// `servers` is not here because it no longer exists: it was deleted in
|
|
6599
6642
|
// 1.0.0, and typing it gets the retired-verb hint from RETIRED_SUBCOMMANDS
|
|
6600
6643
|
// in subcommands.ts. completion-cmd.test.ts pins it out of both this spec
|
|
@@ -11031,7 +11074,7 @@ function foldBundleWarnings(warnings, probe) {
|
|
|
11031
11074
|
const prefix = `${probe.path}:`;
|
|
11032
11075
|
return warnings.filter((w) => !w.startsWith(prefix));
|
|
11033
11076
|
}
|
|
11034
|
-
var VERSION = true ? "1.0.
|
|
11077
|
+
var VERSION = true ? "1.0.9" : "dev";
|
|
11035
11078
|
var DOCTOR_USAGE = `Usage: yaw-mcp doctor [--json]
|
|
11036
11079
|
|
|
11037
11080
|
Print a diagnostic of your yaw-mcp setup.
|
|
@@ -11058,8 +11101,9 @@ async function collectDoctorBase(opts) {
|
|
|
11058
11101
|
const appData = resolveAppDataDir({ home: opts.home, env: opts.env });
|
|
11059
11102
|
const os = opts.os ?? CURRENT_OS;
|
|
11060
11103
|
const env = opts.env ?? process.env;
|
|
11104
|
+
const readOnly = isReadOnlyDiagnostics(env);
|
|
11061
11105
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
11062
|
-
const config = await loadYawMcpConfig({ cwd, home, env });
|
|
11106
|
+
const config = await loadYawMcpConfig({ cwd, home, env, readOnly });
|
|
11063
11107
|
const trustProbe = await probeProjectTrust({ cwd, home, env }).catch(() => null);
|
|
11064
11108
|
const trustWarning = projectTrustWarning(trustProbe);
|
|
11065
11109
|
if (trustWarning) config.warnings = [...config.warnings, trustWarning];
|
|
@@ -11070,6 +11114,7 @@ async function collectDoctorBase(opts) {
|
|
|
11070
11114
|
appData,
|
|
11071
11115
|
os,
|
|
11072
11116
|
env,
|
|
11117
|
+
readOnly,
|
|
11073
11118
|
timestamp,
|
|
11074
11119
|
config,
|
|
11075
11120
|
trustProbe,
|
|
@@ -11111,7 +11156,8 @@ function clientLaunchWarnings(clients) {
|
|
|
11111
11156
|
for (const c of clients) {
|
|
11112
11157
|
if (!clientCannotLaunch(c)) continue;
|
|
11113
11158
|
const { client, status } = describeClient(c);
|
|
11114
|
-
const
|
|
11159
|
+
const fileLevel = c.malformed ? "malformed" : c.unreadable !== null ? "unreadable" : null;
|
|
11160
|
+
const key = fileLevel !== null ? `${c.path}\0${client}\0${fileLevel}` : `${c.path}\0${client}\0${c.containerPath.join(".")}`;
|
|
11115
11161
|
const seen = grouped.get(key);
|
|
11116
11162
|
if (seen) seen.scopes.push(c.scope);
|
|
11117
11163
|
else grouped.set(key, { path: c.path, client, scopes: [c.scope], status });
|
|
@@ -11127,10 +11173,11 @@ async function runDoctor(opts = {}) {
|
|
|
11127
11173
|
write(`${s}
|
|
11128
11174
|
`);
|
|
11129
11175
|
};
|
|
11130
|
-
const { cwd, home, appData, os, env, timestamp, config, trustProbe, claudeConfigDir, clientEnv: clientEnv2 } = await collectDoctorBase(opts);
|
|
11176
|
+
const { cwd, home, appData, os, env, readOnly, timestamp, config, trustProbe, claudeConfigDir, clientEnv: clientEnv2 } = await collectDoctorBase(opts);
|
|
11131
11177
|
print(`yaw-mcp doctor -- ${timestamp}`);
|
|
11132
11178
|
print(`yaw-mcp version: ${VERSION}`);
|
|
11133
11179
|
print(`platform: ${os}`);
|
|
11180
|
+
if (readOnly) print(`mode: read-only (${READONLY_DIAGNOSTICS_ENV} is set) -- no trial sweep, no config migration`);
|
|
11134
11181
|
print("");
|
|
11135
11182
|
print("CONFIG FILES");
|
|
11136
11183
|
if (config.loadedFiles.length === 0) {
|
|
@@ -11168,7 +11215,7 @@ async function runDoctor(opts = {}) {
|
|
|
11168
11215
|
print
|
|
11169
11216
|
});
|
|
11170
11217
|
renderReliabilitySection({ disabled: persistenceDisabled, persisted: persistedState, print });
|
|
11171
|
-
const trialWarnings = await renderTrialsSection({ home, print, now: opts.now });
|
|
11218
|
+
const trialWarnings = await renderTrialsSection({ home, print, now: opts.now, readOnly });
|
|
11172
11219
|
if (trialWarnings.length > 0) config.warnings = [...config.warnings, ...trialWarnings];
|
|
11173
11220
|
const clients = probeClients({
|
|
11174
11221
|
home,
|
|
@@ -11258,13 +11305,9 @@ async function runDoctor(opts = {}) {
|
|
|
11258
11305
|
async function runDoctorJson(opts) {
|
|
11259
11306
|
const lines = [];
|
|
11260
11307
|
const write = opts.out ?? createStreamWriter(process.stdout);
|
|
11261
|
-
const { cwd, home, appData, os, env, timestamp, config, trustProbe, claudeConfigDir, clientEnv: clientEnv2 } = await collectDoctorBase(opts);
|
|
11262
|
-
const
|
|
11263
|
-
const trialGc =
|
|
11264
|
-
home,
|
|
11265
|
-
now: opts.now,
|
|
11266
|
-
scan: trialScan
|
|
11267
|
-
}).catch(() => ({ cleared: 0, failed: 0, failures: [] }));
|
|
11308
|
+
const { cwd, home, appData, os, env, readOnly, timestamp, config, trustProbe, claudeConfigDir, clientEnv: clientEnv2 } = await collectDoctorBase(opts);
|
|
11309
|
+
const trialStatus = await collectTrialStatus({ home, now: opts.now, readOnly });
|
|
11310
|
+
const { scan: trialScan, gc: trialGc } = trialStatus;
|
|
11268
11311
|
const clients = probeClients({
|
|
11269
11312
|
home,
|
|
11270
11313
|
os,
|
|
@@ -11363,7 +11406,19 @@ async function runDoctorJson(opts) {
|
|
|
11363
11406
|
clientPath: marker.clientPath,
|
|
11364
11407
|
msUntilExpiry
|
|
11365
11408
|
})),
|
|
11366
|
-
malformed: trialScan.malformed
|
|
11409
|
+
malformed: trialScan.malformed,
|
|
11410
|
+
// Read-only runs only, so an ordinary run's `trials` block is unchanged
|
|
11411
|
+
// (see DoctorJsonSnapshot.trials.unswept).
|
|
11412
|
+
...readOnly ? {
|
|
11413
|
+
unswept: trialStatus.unswept.map(({ marker, path: path5, msUntilExpiry }) => ({
|
|
11414
|
+
slug: marker.slug,
|
|
11415
|
+
clientName: marker.clientName,
|
|
11416
|
+
clientPath: marker.clientPath,
|
|
11417
|
+
markerPath: path5,
|
|
11418
|
+
msSinceExpiry: Math.max(0, -msUntilExpiry)
|
|
11419
|
+
})),
|
|
11420
|
+
sweepHint: trialStatus.unswept.length > 0 ? TRIAL_SWEEP_HINT : null
|
|
11421
|
+
} : {}
|
|
11367
11422
|
};
|
|
11368
11423
|
const oamStatus = await collectOamRuntimeStatus({
|
|
11369
11424
|
env,
|
|
@@ -11374,8 +11429,8 @@ async function runDoctorJson(opts) {
|
|
|
11374
11429
|
});
|
|
11375
11430
|
config.warnings = [...config.warnings, ...foldBundleWarnings(oamStatus.bundleWarnings, trustProbe)];
|
|
11376
11431
|
const vault = await collectVaultStatus({ home, env, servers: oamStatus.servers });
|
|
11377
|
-
if (
|
|
11378
|
-
config.warnings = [...config.warnings, ...
|
|
11432
|
+
if (trialStatus.warnings.length > 0) {
|
|
11433
|
+
config.warnings = [...config.warnings, ...trialStatus.warnings];
|
|
11379
11434
|
}
|
|
11380
11435
|
config.warnings = [...config.warnings, ...clientLaunchWarnings(clients)];
|
|
11381
11436
|
const oamRuntime = {
|
|
@@ -11424,6 +11479,8 @@ async function runDoctorJson(opts) {
|
|
|
11424
11479
|
timestamp,
|
|
11425
11480
|
version: VERSION,
|
|
11426
11481
|
platform: os,
|
|
11482
|
+
// Present only on a read-only run -- see DoctorJsonSnapshot.readOnly.
|
|
11483
|
+
...readOnly ? { readOnly: true } : {},
|
|
11427
11484
|
// DEPRECATED keys, emitted with their original nested shape and null
|
|
11428
11485
|
// members so `doctor --json` stays parseable for consumers reading
|
|
11429
11486
|
// `.token.source` / `.apiBase.value`. See DoctorJsonSnapshot.
|
|
@@ -11466,6 +11523,7 @@ var DOCTOR_ENV_VARS = [
|
|
|
11466
11523
|
{ name: "YAW_MCP_DEFAULT_RUNTIME", defaultHint: "oam when installed" },
|
|
11467
11524
|
{ name: "YAW_MCP_TOOL_EXPOSURE", defaultHint: "gateway" },
|
|
11468
11525
|
{ name: "YAW_MCP_AUTO_UPGRADE", defaultHint: "default on" },
|
|
11526
|
+
{ name: "YAW_MCP_AUTO_HEAL", defaultHint: "default on" },
|
|
11469
11527
|
{ name: "YAW_MCP_SIDECAR_REFRESH", defaultHint: "default on" },
|
|
11470
11528
|
{ name: "YAW_MCP_CONFIG_RELOAD", defaultHint: "default on" },
|
|
11471
11529
|
{ name: "YAW_MCP_PREWARM", defaultHint: "default on" },
|
|
@@ -11824,16 +11882,35 @@ function renderReliabilitySection(opts) {
|
|
|
11824
11882
|
}
|
|
11825
11883
|
print("");
|
|
11826
11884
|
}
|
|
11827
|
-
|
|
11828
|
-
|
|
11885
|
+
var TRIAL_SWEEP_HINT = `Expired trials are not swept while ${READONLY_DIAGNOSTICS_ENV} is set. Run \`yaw-mcp doctor\` with it unset to sweep them all, or \`yaw-mcp try-cleanup <slug>\` to remove one.`;
|
|
11886
|
+
function trialUnsweptWarning(entry) {
|
|
11887
|
+
const { slug, clientPath } = entry.marker;
|
|
11888
|
+
return `trial "${slug}": expired but not swept -- ${READONLY_DIAGNOSTICS_ENV} is set, so this run edits no client config, and its entry may still be wired into ${clientPath}; run \`yaw-mcp doctor\` with ${READONLY_DIAGNOSTICS_ENV} unset to sweep it, or \`yaw-mcp try-cleanup ${slug}\``;
|
|
11889
|
+
}
|
|
11890
|
+
async function collectTrialStatus(opts) {
|
|
11891
|
+
const { home, now, readOnly } = opts;
|
|
11829
11892
|
const scan = await scanTrials({ home, now });
|
|
11893
|
+
if (readOnly) {
|
|
11894
|
+
return {
|
|
11895
|
+
scan,
|
|
11896
|
+
gc: { cleared: 0, failed: 0, failures: [] },
|
|
11897
|
+
unswept: scan.expired,
|
|
11898
|
+
warnings: scan.expired.map(trialUnsweptWarning)
|
|
11899
|
+
};
|
|
11900
|
+
}
|
|
11830
11901
|
const gc = await gcExpiredTrials({ home, now, scan }).catch(() => ({
|
|
11831
11902
|
cleared: 0,
|
|
11832
11903
|
failed: 0,
|
|
11833
11904
|
failures: []
|
|
11834
11905
|
}));
|
|
11835
|
-
|
|
11836
|
-
|
|
11906
|
+
return { scan, gc, unswept: [], warnings: gc.failures.map(trialGcFailureWarning) };
|
|
11907
|
+
}
|
|
11908
|
+
async function renderTrialsSection(opts) {
|
|
11909
|
+
const { home, print, now, readOnly } = opts;
|
|
11910
|
+
const { scan, gc, unswept, warnings } = await collectTrialStatus({ home, now, readOnly });
|
|
11911
|
+
if (scan.live.length === 0 && gc.cleared === 0 && gc.failed === 0 && unswept.length === 0 && scan.malformed.length === 0) {
|
|
11912
|
+
return warnings;
|
|
11913
|
+
}
|
|
11837
11914
|
print("TRIALS (yaw-mcp try)");
|
|
11838
11915
|
if (gc.cleared > 0) {
|
|
11839
11916
|
print(` swept ${gc.cleared} expired trial${gc.cleared === 1 ? "" : "s"} this run`);
|
|
@@ -11841,6 +11918,11 @@ async function renderTrialsSection(opts) {
|
|
|
11841
11918
|
if (gc.failed > 0) {
|
|
11842
11919
|
print(` ${gc.failed} expired trial${gc.failed === 1 ? "" : "s"} could not be swept -- see WARNINGS`);
|
|
11843
11920
|
}
|
|
11921
|
+
if (unswept.length > 0) {
|
|
11922
|
+
print(
|
|
11923
|
+
` ${unswept.length} expired trial${unswept.length === 1 ? "" : "s"} not swept (${READONLY_DIAGNOSTICS_ENV} is set) -- see WARNINGS`
|
|
11924
|
+
);
|
|
11925
|
+
}
|
|
11844
11926
|
for (const { marker, msUntilExpiry } of scan.live) {
|
|
11845
11927
|
print(` ${marker.slug} -> ${marker.clientName} (${marker.clientPath}) -- expires in ${formatTtl(msUntilExpiry)}`);
|
|
11846
11928
|
}
|
|
@@ -11957,6 +12039,7 @@ function* enumerateProbeSlots(opts) {
|
|
|
11957
12039
|
path: "(n/a)",
|
|
11958
12040
|
exists: false,
|
|
11959
12041
|
unavailable: true,
|
|
12042
|
+
containerPath: [],
|
|
11960
12043
|
...EMPTY_PROBE,
|
|
11961
12044
|
syntax: syntaxNameFor(effectiveConfigFormat(target.config, target.scopes[0])),
|
|
11962
12045
|
...why !== void 0 ? { unavailableReason: why } : {}
|
|
@@ -11993,7 +12076,8 @@ function* enumerateProbeSlots(opts) {
|
|
|
11993
12076
|
// The site's own format, resolved the one way the write path
|
|
11994
12077
|
// resolves it -- a row added to INSTALL_TARGETS is picked up here
|
|
11995
12078
|
// without touching this file.
|
|
11996
|
-
syntax: syntaxNameFor(site.format)
|
|
12079
|
+
syntax: syntaxNameFor(site.format),
|
|
12080
|
+
containerPath: addressOf(site).containerPath
|
|
11997
12081
|
},
|
|
11998
12082
|
read: exists2 ? { path: site.resolved.absolute, site, transform: target.entry } : null
|
|
11999
12083
|
};
|
|
@@ -12035,7 +12119,7 @@ function oamArgvTokens(command, args) {
|
|
|
12035
12119
|
if (i < 0 || !isOamCommand(args[i])) return null;
|
|
12036
12120
|
return { oam: args[i], rest: args.slice(i + 1) };
|
|
12037
12121
|
}
|
|
12038
|
-
if (
|
|
12122
|
+
if (POSIX_SHELL.test(base)) {
|
|
12039
12123
|
const dashC = args.indexOf("-c");
|
|
12040
12124
|
const payload = dashC >= 0 ? args[dashC + 1] : args[0];
|
|
12041
12125
|
if (payload === void 0) return null;
|
|
@@ -12044,11 +12128,23 @@ function oamArgvTokens(command, args) {
|
|
|
12044
12128
|
if (tokens[0] === void 0 || !isOamCommand(tokens[0])) return null;
|
|
12045
12129
|
return { oam: tokens[0], rest: tokens.slice(1) };
|
|
12046
12130
|
}
|
|
12131
|
+
if (POWERSHELL.test(base)) {
|
|
12132
|
+
const payload = powershellPayload(args);
|
|
12133
|
+
if (payload === null) return null;
|
|
12134
|
+
if (/["']/.test(payload)) return null;
|
|
12135
|
+
const tokens = payload.trim().split(/\s+/);
|
|
12136
|
+
if (tokens[0] === void 0 || !isOamCommand(tokens[0])) return null;
|
|
12137
|
+
return { oam: tokens[0], rest: tokens.slice(1) };
|
|
12138
|
+
}
|
|
12047
12139
|
return null;
|
|
12048
12140
|
}
|
|
12049
12141
|
function isForeignAbsoluteLaunch(command, platform = process.platform) {
|
|
12050
12142
|
return platform !== "win32" && /^[A-Za-z]:[\\/]/.test(command);
|
|
12051
12143
|
}
|
|
12144
|
+
function oamRunEntryPath(command, args) {
|
|
12145
|
+
const unwrapped = oamArgvTokens(command, args);
|
|
12146
|
+
return unwrapped === null ? null : oamRunEntryFromTokens(unwrapped.rest);
|
|
12147
|
+
}
|
|
12052
12148
|
function oamRunEntryFromTokens(tokens) {
|
|
12053
12149
|
const sub = tokens.findIndex((t) => !t.startsWith("-"));
|
|
12054
12150
|
if (sub < 0 || tokens[sub] !== "run") return null;
|
|
@@ -12968,6 +13064,209 @@ async function runFoundryExport(opts) {
|
|
|
12968
13064
|
return { exitCode: 0, lines };
|
|
12969
13065
|
}
|
|
12970
13066
|
|
|
13067
|
+
// src/heal-entries.ts
|
|
13068
|
+
import { statSync as statSync3 } from "fs";
|
|
13069
|
+
function norm(p, platform = process.platform) {
|
|
13070
|
+
const slashed = p.split("\\").join("/");
|
|
13071
|
+
return platform === "win32" ? slashed.toLowerCase() : slashed;
|
|
13072
|
+
}
|
|
13073
|
+
function isForeignEntry(command, entryPath, platform) {
|
|
13074
|
+
if (isForeignAbsoluteLaunch(command, platform)) return true;
|
|
13075
|
+
if (platform === "win32" && (entryPath.startsWith("/") || command.startsWith("/"))) return true;
|
|
13076
|
+
return false;
|
|
13077
|
+
}
|
|
13078
|
+
function isOwnBrokerEntry(entryPath) {
|
|
13079
|
+
return norm(entryPath).includes("/node_modules/@yawlabs/mcp/");
|
|
13080
|
+
}
|
|
13081
|
+
function isLaunchableFile(entryPath) {
|
|
13082
|
+
try {
|
|
13083
|
+
return statSync3(entryPath).isFile();
|
|
13084
|
+
} catch {
|
|
13085
|
+
return false;
|
|
13086
|
+
}
|
|
13087
|
+
}
|
|
13088
|
+
async function healStaleBrokerEntries(opts = {}) {
|
|
13089
|
+
const env = opts.env ?? process.env;
|
|
13090
|
+
if (isReadOnlyDiagnostics(env)) return { healed: [], unhealable: [] };
|
|
13091
|
+
const os = opts.os ?? CURRENT_OS;
|
|
13092
|
+
const platform = opts.platform ?? process.platform;
|
|
13093
|
+
const healed = [];
|
|
13094
|
+
const unhealable = [];
|
|
13095
|
+
let replacement = null;
|
|
13096
|
+
const replacementFor = async () => {
|
|
13097
|
+
if (replacement !== null) return replacement;
|
|
13098
|
+
let oamBinPath = null;
|
|
13099
|
+
try {
|
|
13100
|
+
oamBinPath = (await (opts.oamProbe ?? probeOam)()).binPath;
|
|
13101
|
+
} catch {
|
|
13102
|
+
oamBinPath = null;
|
|
13103
|
+
}
|
|
13104
|
+
const resolveEntry = opts.resolveOamEntry ?? resolveStableNpmEntry;
|
|
13105
|
+
replacement = { oamBinPath, oamEntry: oamBinPath === null ? null : resolveEntry("@yawlabs/mcp") };
|
|
13106
|
+
return replacement;
|
|
13107
|
+
};
|
|
13108
|
+
const seen = /* @__PURE__ */ new Set();
|
|
13109
|
+
for (const target of INSTALL_TARGETS) {
|
|
13110
|
+
for (const scope of target.scopes) {
|
|
13111
|
+
let site;
|
|
13112
|
+
try {
|
|
13113
|
+
site = resolveInstallSites({
|
|
13114
|
+
clientId: target.clientId,
|
|
13115
|
+
scope: scope.scope,
|
|
13116
|
+
os,
|
|
13117
|
+
home: opts.home,
|
|
13118
|
+
appData: opts.appData,
|
|
13119
|
+
projectDir: scope.requiresProjectDir ? opts.cwd ?? process.cwd() : void 0,
|
|
13120
|
+
claudeConfigDir: opts.claudeConfigDir
|
|
13121
|
+
})[0];
|
|
13122
|
+
} catch {
|
|
13123
|
+
continue;
|
|
13124
|
+
}
|
|
13125
|
+
if (site === void 0) continue;
|
|
13126
|
+
const resolvedSite = site;
|
|
13127
|
+
const key = `${norm(resolvedSite.resolved.absolute, platform)}::${addressOf(resolvedSite).containerPath.join(".")}`;
|
|
13128
|
+
if (seen.has(key)) continue;
|
|
13129
|
+
seen.add(key);
|
|
13130
|
+
try {
|
|
13131
|
+
const view = await readClientConfigFile(resolvedSite, { transform: target.entry });
|
|
13132
|
+
if (view.read.kind !== "ok") {
|
|
13133
|
+
if (view.read.kind !== "absent") {
|
|
13134
|
+
unhealable.push({
|
|
13135
|
+
clientId: target.clientId,
|
|
13136
|
+
scope: scope.scope,
|
|
13137
|
+
path: resolvedSite.resolved.absolute,
|
|
13138
|
+
reason: view.read.kind
|
|
13139
|
+
});
|
|
13140
|
+
}
|
|
13141
|
+
continue;
|
|
13142
|
+
}
|
|
13143
|
+
const stored = view.read.entries.find((e) => e.key === ENTRY_NAME);
|
|
13144
|
+
if (stored === void 0) continue;
|
|
13145
|
+
const launch = stored.launch ?? launchOf(stored.value);
|
|
13146
|
+
if (launch === null) continue;
|
|
13147
|
+
const entryPath = oamRunEntryPath(launch.command, launch.args);
|
|
13148
|
+
if (entryPath === null || !isOwnBrokerEntry(entryPath)) continue;
|
|
13149
|
+
if (isForeignEntry(launch.command, entryPath, platform)) continue;
|
|
13150
|
+
if (isLaunchableFile(entryPath)) continue;
|
|
13151
|
+
const { oamBinPath, oamEntry } = await replacementFor();
|
|
13152
|
+
const base = buildLaunchEntry({
|
|
13153
|
+
os,
|
|
13154
|
+
oamBinPath,
|
|
13155
|
+
oamEntry,
|
|
13156
|
+
windowsWrap: target.entry?.windowsLaunch?.broker !== "bare"
|
|
13157
|
+
});
|
|
13158
|
+
const next = composeEntry({
|
|
13159
|
+
base,
|
|
13160
|
+
transform: target.entry,
|
|
13161
|
+
os,
|
|
13162
|
+
purpose: "broker",
|
|
13163
|
+
env: carryableEnvOf(stored.value),
|
|
13164
|
+
carried: carriedFieldsOf(stored.value, target.entry)
|
|
13165
|
+
});
|
|
13166
|
+
const nextLaunch = launchOf(next);
|
|
13167
|
+
const nextEntry = nextLaunch === null ? null : oamRunEntryPath(nextLaunch.command, nextLaunch.args);
|
|
13168
|
+
if (nextEntry !== null && norm(nextEntry, platform) === norm(entryPath, platform)) continue;
|
|
13169
|
+
if (opts.dryRun !== true) {
|
|
13170
|
+
const text = applyClientConfigEdits(view, [{ op: "upsert", key: ENTRY_NAME, entry: next }], resolvedSite);
|
|
13171
|
+
await atomicWriteFile(resolvedSite.resolved.absolute, text);
|
|
13172
|
+
}
|
|
13173
|
+
healed.push({
|
|
13174
|
+
clientId: target.clientId,
|
|
13175
|
+
scope: scope.scope,
|
|
13176
|
+
path: resolvedSite.resolved.absolute,
|
|
13177
|
+
from: entryPath,
|
|
13178
|
+
to: nextEntry ?? "npx"
|
|
13179
|
+
});
|
|
13180
|
+
} catch (err) {
|
|
13181
|
+
log("warn", "Could not heal a stale yaw-mcp entry", {
|
|
13182
|
+
path: resolvedSite.resolved.absolute,
|
|
13183
|
+
error: err instanceof Error ? err.message : String(err)
|
|
13184
|
+
});
|
|
13185
|
+
}
|
|
13186
|
+
}
|
|
13187
|
+
}
|
|
13188
|
+
if (healed.length > 0) {
|
|
13189
|
+
log("info", "Re-pointed stale yaw-mcp entries whose launch file no longer existed", {
|
|
13190
|
+
count: healed.length,
|
|
13191
|
+
clients: healed.map((h) => `${h.clientId} (${h.scope})`)
|
|
13192
|
+
});
|
|
13193
|
+
}
|
|
13194
|
+
return { healed, unhealable };
|
|
13195
|
+
}
|
|
13196
|
+
async function maybeHealStaleBrokerEntries(opts = {}) {
|
|
13197
|
+
const env = opts.env ?? process.env;
|
|
13198
|
+
if (env.YAW_MCP_AUTO_HEAL === "0") return { healed: [], unhealable: [] };
|
|
13199
|
+
try {
|
|
13200
|
+
return await healStaleBrokerEntries(opts);
|
|
13201
|
+
} catch (err) {
|
|
13202
|
+
log("warn", "Stale-entry heal pass failed", {
|
|
13203
|
+
error: err instanceof Error ? err.message : String(err)
|
|
13204
|
+
});
|
|
13205
|
+
return { healed: [], unhealable: [] };
|
|
13206
|
+
}
|
|
13207
|
+
}
|
|
13208
|
+
|
|
13209
|
+
// src/heal-cmd.ts
|
|
13210
|
+
var USAGE2 = "Usage: yaw-mcp heal [--json] [--dry-run] [--quiet]\n\nRe-point yaw-mcp entries whose launch file no longer exists -- what an app\nupgrade leaves behind when it deletes the directory the entry named.\nOnly an entry yaw-mcp wrote AND that is currently broken is touched.\n\n --json Machine-readable result\n --dry-run Report what would change; write nothing\n --quiet No human transcript\n";
|
|
13211
|
+
function parseHealArgs(argv) {
|
|
13212
|
+
const options = {};
|
|
13213
|
+
for (const arg of argv) {
|
|
13214
|
+
if (arg === "--help" || arg === "-h") return { ok: false, error: USAGE2, help: true };
|
|
13215
|
+
else if (arg === "--json") options.json = true;
|
|
13216
|
+
else if (arg === "--dry-run") options.dryRun = true;
|
|
13217
|
+
else if (arg === "--quiet") options.quiet = true;
|
|
13218
|
+
else return { ok: false, error: `yaw-mcp heal: unknown option ${arg}
|
|
13219
|
+
|
|
13220
|
+
${USAGE2}` };
|
|
13221
|
+
}
|
|
13222
|
+
return { ok: true, options };
|
|
13223
|
+
}
|
|
13224
|
+
function describe(h) {
|
|
13225
|
+
return ` ${h.clientId} (${h.scope}): ${h.path}
|
|
13226
|
+
was -> ${h.from}
|
|
13227
|
+
now -> ${h.to}`;
|
|
13228
|
+
}
|
|
13229
|
+
async function runHeal(options = {}) {
|
|
13230
|
+
let result;
|
|
13231
|
+
try {
|
|
13232
|
+
result = await healStaleBrokerEntries({ dryRun: options.dryRun });
|
|
13233
|
+
} catch (err) {
|
|
13234
|
+
process.stderr.write(`yaw-mcp heal: ${err instanceof Error ? err.message : String(err)}
|
|
13235
|
+
`);
|
|
13236
|
+
return { exitCode: 1 };
|
|
13237
|
+
}
|
|
13238
|
+
const { healed, unhealable } = result;
|
|
13239
|
+
if (options.json === true) {
|
|
13240
|
+
process.stdout.write(
|
|
13241
|
+
`${JSON.stringify({ healed, unhealable, count: healed.length, dryRun: options.dryRun === true }, null, 2)}
|
|
13242
|
+
`
|
|
13243
|
+
);
|
|
13244
|
+
return { exitCode: 0 };
|
|
13245
|
+
}
|
|
13246
|
+
if (options.quiet !== true) {
|
|
13247
|
+
if (healed.length === 0) {
|
|
13248
|
+
process.stdout.write("No stale yaw-mcp entries found.\n");
|
|
13249
|
+
} else {
|
|
13250
|
+
const verb = options.dryRun === true ? "Would re-point" : "Re-pointed";
|
|
13251
|
+
process.stdout.write(
|
|
13252
|
+
`${verb} ${healed.length} stale ${healed.length === 1 ? "entry" : "entries"}:
|
|
13253
|
+
${healed.map(describe).join("\n")}
|
|
13254
|
+
` + (options.dryRun === true ? "" : "\nRestart the affected client(s) to pick this up.\n")
|
|
13255
|
+
);
|
|
13256
|
+
}
|
|
13257
|
+
if (unhealable.length > 0) {
|
|
13258
|
+
process.stdout.write(
|
|
13259
|
+
`
|
|
13260
|
+
${unhealable.length} config${unhealable.length === 1 ? "" : "s"} could not be checked:
|
|
13261
|
+
${unhealable.map((u) => ` ${u.clientId} (${u.scope}): ${u.path} -- ${u.reason}`).join("\n")}
|
|
13262
|
+
Run \`yaw-mcp doctor\` for what each one needs.
|
|
13263
|
+
`
|
|
13264
|
+
);
|
|
13265
|
+
}
|
|
13266
|
+
}
|
|
13267
|
+
return { exitCode: 0 };
|
|
13268
|
+
}
|
|
13269
|
+
|
|
12971
13270
|
// src/import-cmd.ts
|
|
12972
13271
|
import { homedir as homedir18 } from "os";
|
|
12973
13272
|
import { basename as basename3, resolve as resolvePath } from "path";
|
|
@@ -15836,7 +16135,7 @@ function pushToolCall(history, record, limit = HISTORY_LIMIT) {
|
|
|
15836
16135
|
}
|
|
15837
16136
|
|
|
15838
16137
|
// src/install-nudge.ts
|
|
15839
|
-
import { existsSync as existsSync9, mkdirSync as mkdirSync3, readFileSync as readFileSync6, statSync as
|
|
16138
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync3, readFileSync as readFileSync6, statSync as statSync4, writeFileSync as writeFileSync2 } from "fs";
|
|
15840
16139
|
import { dirname as dirname8, join as join15 } from "path";
|
|
15841
16140
|
var INSTALL_NUDGE_MIN_COUNT = 5;
|
|
15842
16141
|
var INSTALL_NUDGE_COOLDOWN_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
@@ -15857,7 +16156,7 @@ function readState(home) {
|
|
|
15857
16156
|
return { nudges: [] };
|
|
15858
16157
|
}
|
|
15859
16158
|
try {
|
|
15860
|
-
const st =
|
|
16159
|
+
const st = statSync4(path5);
|
|
15861
16160
|
if (stateMemo && stateMemo.path === path5 && stateMemo.mtimeMs === st.mtimeMs && stateMemo.size === st.size) {
|
|
15862
16161
|
return stateMemo.state;
|
|
15863
16162
|
}
|
|
@@ -15903,7 +16202,7 @@ function recordNudges(clis, home, now = Date.now) {
|
|
|
15903
16202
|
writeFileSync2(path5, `${JSON.stringify({ nudges: kept }, null, 2)}
|
|
15904
16203
|
`, "utf8");
|
|
15905
16204
|
try {
|
|
15906
|
-
const st =
|
|
16205
|
+
const st = statSync4(path5);
|
|
15907
16206
|
stateMemo = { path: path5, mtimeMs: st.mtimeMs, size: st.size, state: { nudges: kept } };
|
|
15908
16207
|
} catch {
|
|
15909
16208
|
stateMemo = null;
|
|
@@ -17860,7 +18159,7 @@ var ConnectServer = class _ConnectServer {
|
|
|
17860
18159
|
static SHUTDOWN_DRAIN_MS = 2e3;
|
|
17861
18160
|
constructor() {
|
|
17862
18161
|
this.server = new Server(
|
|
17863
|
-
{ name: "yaw-mcp", version: true ? "1.0.
|
|
18162
|
+
{ name: "yaw-mcp", version: true ? "1.0.9" : "dev" },
|
|
17864
18163
|
{
|
|
17865
18164
|
capabilities: {
|
|
17866
18165
|
tools: { listChanged: true },
|
|
@@ -18474,6 +18773,9 @@ var ConnectServer = class _ConnectServer {
|
|
|
18474
18773
|
maybeAutoUpgrade().catch((err) => log("warn", "Auto-upgrade check failed", { error: err?.message }));
|
|
18475
18774
|
maybeRefreshSidecars().catch((err) => log("warn", "Sidecar refresh check failed", { error: err?.message }));
|
|
18476
18775
|
maybeAutoPrewarmNpxCache().catch((err) => log("warn", "Auto-prewarm check failed", { error: err?.message }));
|
|
18776
|
+
maybeHealStaleBrokerEntries().catch(
|
|
18777
|
+
(err) => log("warn", "Stale-entry heal failed", { error: err?.message })
|
|
18778
|
+
);
|
|
18477
18779
|
log("info", "yaw-mcp started", {
|
|
18478
18780
|
servers: this.config?.servers.length ?? 0
|
|
18479
18781
|
});
|
|
@@ -21264,7 +21566,7 @@ function registerShutdownTriggers(shutdown, targets) {
|
|
|
21264
21566
|
// src/status-cmd.ts
|
|
21265
21567
|
import { existsSync as existsSync10 } from "fs";
|
|
21266
21568
|
import { homedir as homedir23 } from "os";
|
|
21267
|
-
var VERSION2 = true ? "1.0.
|
|
21569
|
+
var VERSION2 = true ? "1.0.9" : "dev";
|
|
21268
21570
|
var STATUS_SCHEMA_VERSION = 1;
|
|
21269
21571
|
var STATUS_USAGE = `Usage: yaw-mcp status [--json]
|
|
21270
21572
|
|
|
@@ -21446,6 +21748,7 @@ var KNOWN_SUBCOMMANDS = [
|
|
|
21446
21748
|
"list",
|
|
21447
21749
|
"status",
|
|
21448
21750
|
"doctor",
|
|
21751
|
+
"heal",
|
|
21449
21752
|
"reset-learning",
|
|
21450
21753
|
"sidecars",
|
|
21451
21754
|
"bundles",
|
|
@@ -21552,6 +21855,8 @@ if (subcommand === "compliance") {
|
|
|
21552
21855
|
);
|
|
21553
21856
|
} else if (subcommand === "doctor") {
|
|
21554
21857
|
run("doctor", parseDoctorArgs(process.argv.slice(3)), runDoctor);
|
|
21858
|
+
} else if (subcommand === "heal") {
|
|
21859
|
+
run("heal", parseHealArgs(process.argv.slice(3)), runHeal);
|
|
21555
21860
|
} else if (subcommand === "reset-learning") {
|
|
21556
21861
|
const parsed = parseResetLearningArgs(process.argv.slice(3));
|
|
21557
21862
|
if (parsed.kind === "help") {
|
|
@@ -21717,6 +22022,12 @@ if (subcommand === "compliance") {
|
|
|
21717
22022
|
local servers (ready vs. partially installed).
|
|
21718
22023
|
|
|
21719
22024
|
Maintenance:
|
|
22025
|
+
heal Re-point client entries whose launch file no
|
|
22026
|
+
longer exists -- what an app upgrade leaves
|
|
22027
|
+
behind when it deletes the directory the entry
|
|
22028
|
+
named. Only touches an entry yaw-mcp wrote that
|
|
22029
|
+
is currently broken. Runs automatically at
|
|
22030
|
+
startup; this is the manual form.
|
|
21720
22031
|
upgrade Show (or --run) the command that bumps
|
|
21721
22032
|
@yawlabs/mcp to the latest version.
|
|
21722
22033
|
sidecars install Install your servers into ~/.yaw-mcp/sidecars so
|
|
@@ -21782,6 +22093,12 @@ if (subcommand === "compliance") {
|
|
|
21782
22093
|
self-upgrade check at server startup (default:
|
|
21783
22094
|
stale global installs are upgraded in the
|
|
21784
22095
|
background -- npm, pnpm, and bun globals alike).
|
|
22096
|
+
YAW_MCP_AUTO_HEAL Set to \`0\` to disable the startup pass that
|
|
22097
|
+
re-points client entries whose launch file no
|
|
22098
|
+
longer exists -- what an app upgrade leaves
|
|
22099
|
+
behind when it deletes the directory the entry
|
|
22100
|
+
named (default: on; it only rewrites an entry
|
|
22101
|
+
yaw-mcp wrote AND that is currently broken).
|
|
21785
22102
|
YAW_MCP_CONFIG_RELOAD Set to \`0\` to stop re-reading bundles.json
|
|
21786
22103
|
while the session runs, restoring the pre-0.81
|
|
21787
22104
|
behaviour where an edit takes effect only after
|
|
@@ -21890,6 +22207,13 @@ if (subcommand === "compliance") {
|
|
|
21890
22207
|
are written -- never the raw intent -- but
|
|
21891
22208
|
ordinary words survive, so do not enable it on
|
|
21892
22209
|
intents that carry names or other PII.
|
|
22210
|
+
YAW_MCP_READONLY_DIAGNOSTICS Set to \`1\` to make \`doctor\` and \`bundles\`
|
|
22211
|
+
write nothing, for a caller that runs them in
|
|
22212
|
+
the background: expired \`yaw-mcp try\` trials
|
|
22213
|
+
are reported as warnings instead of swept out
|
|
22214
|
+
of client configs, and a pre-0.12 config file
|
|
22215
|
+
is reported instead of moved into .yaw-mcp/
|
|
22216
|
+
(default: off; \`status\` never writes).
|
|
21893
22217
|
YAW_MCP_CATALOG_URL Override the catalog \`add\`/\`try\` resolve slugs
|
|
21894
22218
|
against (default https://yaw.sh/data/mcp-catalog.json).
|
|
21895
22219
|
|
|
@@ -22016,7 +22340,7 @@ if (subcommand === "compliance") {
|
|
|
22016
22340
|
`);
|
|
22017
22341
|
process.exitCode = 0;
|
|
22018
22342
|
} else if (subcommand === "--version" || subcommand === "-V") {
|
|
22019
|
-
process.stdout.write(`yaw-mcp ${true ? "1.0.
|
|
22343
|
+
process.stdout.write(`yaw-mcp ${true ? "1.0.9" : "dev"}
|
|
22020
22344
|
`);
|
|
22021
22345
|
process.exitCode = 0;
|
|
22022
22346
|
} else if (subcommand !== void 0 && !subcommand.startsWith("-")) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yawlabs/mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"mcpName": "io.github.YawLabs/mcp",
|
|
5
5
|
"description": "MCP gateway and orchestrator: one local install fronts every MCP server for Claude Code, Cursor, and VS Code, loading tools on demand.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|