@yawlabs/mcp 0.76.1 → 0.78.0
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 +973 -753
- package/README.md +16 -5
- package/dist/{auto-upgrade-CIO76Z6V.js → auto-upgrade-TDMGTOK3.js} +4 -2
- package/dist/{chunk-CNEMSMQD.js → chunk-33LK4DLQ.js} +59 -29
- package/dist/chunk-3RRZQPA5.js +39 -0
- package/dist/{chunk-U3KC5QAD.js → chunk-AB63LGSO.js} +136 -49
- package/dist/index.js +10291 -8820
- package/dist/{oam-spawn-VPVBHI7B.js → oam-spawn-UUOFWXFP.js} +2 -2
- package/package.json +4 -4
- package/schemas/yaw-mcp.config.v1.json +57 -0
- package/dist/chunk-C3AQHLOR.js +0 -15
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
log
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3RRZQPA5.js";
|
|
5
5
|
|
|
6
6
|
// src/auto-upgrade.ts
|
|
7
7
|
import { spawn as spawn2 } from "child_process";
|
|
8
|
-
import { realpathSync as realpathSync2 } from "fs";
|
|
9
|
-
import {
|
|
8
|
+
import { closeSync, openSync, realpathSync as realpathSync2, statSync, unlinkSync, writeSync } from "fs";
|
|
9
|
+
import { tmpdir } from "os";
|
|
10
|
+
import { dirname, join, sep } from "path";
|
|
10
11
|
|
|
11
12
|
// src/upgrade-cmd.ts
|
|
12
13
|
import { spawn } from "child_process";
|
|
13
14
|
import { realpathSync } from "fs";
|
|
14
|
-
var
|
|
15
|
+
var BINARY_RETIRED_HINT = "the standalone-binary track was retired in 0.70.3. Install from npm instead -- `npm install -g @yawlabs/mcp@latest` -- then delete this executable.";
|
|
15
16
|
var POSIX_GLOBAL_LIB_PREFIX = /^(?:[A-Za-z]:)?(?:\/usr(?:\/local)?|\/opt\/[^/]+)\/lib\/node_modules\/@yawlabs\/mcp\//;
|
|
16
17
|
var MANAGED_NODE_LIB_PREFIX = /\/(?:\.local|\.nvm|\.fnm|fnm|\.asdf|\.volta|\.nodenv|\.nvs|n)\/(?:[^/]+\/)*lib\/node_modules\/@yawlabs\/mcp\//;
|
|
17
18
|
var UPGRADE_USAGE = `Usage: yaw-mcp upgrade [--run] [--json]
|
|
@@ -23,8 +24,8 @@ var UPGRADE_USAGE = `Usage: yaw-mcp upgrade [--run] [--json]
|
|
|
23
24
|
--json Emit a machine-readable snapshot ({ current, latest, stale,
|
|
24
25
|
method, command }) instead of prose.
|
|
25
26
|
NOTE: --json is a report-only snapshot; it never spawns an upgrade
|
|
26
|
-
even when combined with --run
|
|
27
|
-
actually perform the upgrade.`;
|
|
27
|
+
even when combined with --run, and exits 1 whenever "stale" is
|
|
28
|
+
true. Use --run without --json to actually perform the upgrade.`;
|
|
28
29
|
function parseUpgradeArgs(argv) {
|
|
29
30
|
const opts = {};
|
|
30
31
|
for (const a of argv) {
|
|
@@ -50,7 +51,7 @@ function detectInstallMethod(argvPath) {
|
|
|
50
51
|
if (/\/pnpm\/global\/\d+\/node_modules\/@yawlabs\/mcp\//.test(normalized)) return "pnpm-global";
|
|
51
52
|
if (/\/\.bun\/install\/global\/node_modules\/@yawlabs\/mcp\//.test(normalized)) return "bun-global";
|
|
52
53
|
if (/\/node_modules\/@yawlabs\/mcp\//.test(normalized)) return "local-node-modules";
|
|
53
|
-
if (/\/(yaw-mcp|mcph)\/(dist|src)\//.test(normalized)) return "dev-checkout";
|
|
54
|
+
if (/\/(yaw-mcp|mcph|mcp)\/(dist|src)\//.test(normalized)) return "dev-checkout";
|
|
54
55
|
return "unknown";
|
|
55
56
|
}
|
|
56
57
|
function localInstallRoot(argvPath) {
|
|
@@ -58,6 +59,16 @@ function localInstallRoot(argvPath) {
|
|
|
58
59
|
const idx = argvPath.replace(/\\/g, "/").indexOf("/node_modules/");
|
|
59
60
|
return idx > 0 ? argvPath.slice(0, idx) : null;
|
|
60
61
|
}
|
|
62
|
+
function killProcessTree(child, platform = process.platform, spawnImpl = spawn) {
|
|
63
|
+
if (platform === "win32" && child.pid !== void 0) {
|
|
64
|
+
try {
|
|
65
|
+
spawnImpl("taskkill", ["/pid", String(child.pid), "/T", "/F"], { stdio: "ignore" }).on("error", () => {
|
|
66
|
+
});
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
child.kill();
|
|
71
|
+
}
|
|
61
72
|
async function npmGlobalPrefix() {
|
|
62
73
|
if (process.env.VITEST) return null;
|
|
63
74
|
return new Promise((resolve) => {
|
|
@@ -67,7 +78,7 @@ async function npmGlobalPrefix() {
|
|
|
67
78
|
});
|
|
68
79
|
let out = "";
|
|
69
80
|
const timer = setTimeout(() => {
|
|
70
|
-
child
|
|
81
|
+
killProcessTree(child);
|
|
71
82
|
resolve(null);
|
|
72
83
|
}, 3e3);
|
|
73
84
|
child.stdout?.on("data", (d) => {
|
|
@@ -208,7 +219,7 @@ async function fetchLatestVersion(opts = {}) {
|
|
|
208
219
|
async function oamFloorLines(probe) {
|
|
209
220
|
if (!probe && process.env.VITEST) return [];
|
|
210
221
|
try {
|
|
211
|
-
const { MIN_OAM_VERSION, probeOam } = await import("./oam-spawn-
|
|
222
|
+
const { MIN_OAM_VERSION, probeOam } = await import("./oam-spawn-UUOFWXFP.js");
|
|
212
223
|
const oam = probe ? await probe() : await probeOam();
|
|
213
224
|
if (!oam.belowMin) return [];
|
|
214
225
|
return [
|
|
@@ -224,7 +235,7 @@ async function oamFloorLines(probe) {
|
|
|
224
235
|
}
|
|
225
236
|
async function defaultRunningPrefix(argvPath) {
|
|
226
237
|
if (process.env.VITEST) return null;
|
|
227
|
-
const { detectRunningInstallPrefix: detectRunningInstallPrefix2 } = await import("./auto-upgrade-
|
|
238
|
+
const { detectRunningInstallPrefix: detectRunningInstallPrefix2 } = await import("./auto-upgrade-TDMGTOK3.js");
|
|
228
239
|
return detectRunningInstallPrefix2(argvPath);
|
|
229
240
|
}
|
|
230
241
|
async function defaultSpawn(cmd, args, cwd) {
|
|
@@ -276,7 +287,7 @@ async function runUpgrade(opts = {}) {
|
|
|
276
287
|
if (method === "global-npm") {
|
|
277
288
|
const rawPrefix = await (opts.runningPrefix ?? defaultRunningPrefix)(argvPath);
|
|
278
289
|
if (rawPrefix !== null) {
|
|
279
|
-
const { quoteArgForDisplay: quoteArgForDisplay2, quoteShellArgIfNeeded: quoteShellArgIfNeeded2 } = await import("./auto-upgrade-
|
|
290
|
+
const { quoteArgForDisplay: quoteArgForDisplay2, quoteShellArgIfNeeded: quoteShellArgIfNeeded2 } = await import("./auto-upgrade-TDMGTOK3.js");
|
|
280
291
|
const spawnForm = quoteShellArgIfNeeded2(rawPrefix);
|
|
281
292
|
const displayForm = quoteArgForDisplay2(rawPrefix);
|
|
282
293
|
if (spawnForm !== null && displayForm !== null) {
|
|
@@ -287,7 +298,7 @@ async function runUpgrade(opts = {}) {
|
|
|
287
298
|
}
|
|
288
299
|
if (opts.json) {
|
|
289
300
|
print(JSON.stringify({ ...plan, command: suggestedCommand }, null, 2));
|
|
290
|
-
return { exitCode: plan.stale
|
|
301
|
+
return { exitCode: plan.stale ? 1 : 0, lines };
|
|
291
302
|
}
|
|
292
303
|
if (latest === null) {
|
|
293
304
|
print("yaw-mcp upgrade: couldn't reach the npm registry (offline? firewall?).");
|
|
@@ -298,8 +309,7 @@ async function runUpgrade(opts = {}) {
|
|
|
298
309
|
} else if (method === "bundled-app") {
|
|
299
310
|
print("This copy of yaw-mcp ships inside Yaw Terminal and updates with the app \u2014 nothing to run.");
|
|
300
311
|
} else if (method === "binary") {
|
|
301
|
-
print(
|
|
302
|
-
print(`this executable: ${BINARY_DOWNLOAD_URL}`);
|
|
312
|
+
print(`yaw-mcp is a standalone binary; ${BINARY_RETIRED_HINT}`);
|
|
303
313
|
} else {
|
|
304
314
|
print("Your install uses `npx -y` \u2014 just restart the MCP client when you're back online.");
|
|
305
315
|
}
|
|
@@ -326,17 +336,23 @@ async function runUpgrade(opts = {}) {
|
|
|
326
336
|
}
|
|
327
337
|
if (method === "binary") {
|
|
328
338
|
print("yaw-mcp is running as a standalone binary \u2014 manual upgrade required.");
|
|
329
|
-
print(
|
|
330
|
-
print("this: download the latest build and replace this executable:");
|
|
331
|
-
print("");
|
|
332
|
-
print(` ${BINARY_DOWNLOAD_URL}`);
|
|
339
|
+
print(`There's no package manager to upgrade it, and \`--run\` can't automate this: ${BINARY_RETIRED_HINT}`);
|
|
333
340
|
return { exitCode: opts.run ? 2 : 1, lines };
|
|
334
341
|
}
|
|
335
342
|
const installRoot = method === "local-node-modules" ? localInstallRoot(argvPath) : null;
|
|
336
343
|
const runSpec = method === "global-npm" ? {
|
|
337
344
|
cmd: "npm",
|
|
338
345
|
args: globalPrefixArg ? ["install", "-g", "--prefix", globalPrefixArg, "@yawlabs/mcp@latest"] : ["install", "-g", "@yawlabs/mcp@latest"]
|
|
339
|
-
} : method === "pnpm-global" ? { cmd: "pnpm", args: ["add", "-g", "@yawlabs/mcp@latest"] } : method === "bun-global" ? { cmd: "bun", args: ["add", "-g", "@yawlabs/mcp@latest"] } :
|
|
346
|
+
} : method === "pnpm-global" ? { cmd: "pnpm", args: ["add", "-g", "@yawlabs/mcp@latest"] } : method === "bun-global" ? { cmd: "bun", args: ["add", "-g", "@yawlabs/mcp@latest"] } : (
|
|
347
|
+
// The `installRoot !== null` arm is defensive-dead, kept only so a
|
|
348
|
+
// future localInstallRoot change cannot produce `cwd: undefined`
|
|
349
|
+
// and silently install into the process cwd: localInstallRoot
|
|
350
|
+
// returns null exactly when `/node_modules/` sits at index 0, i.e.
|
|
351
|
+
// a node_modules directory at the filesystem root, which no real
|
|
352
|
+
// classification produces (detectInstallMethod only labels a path
|
|
353
|
+
// local-node-modules when there is a tree above it).
|
|
354
|
+
method === "local-node-modules" && installRoot !== null ? { cmd: "npm", args: ["install", "@yawlabs/mcp@latest"], cwd: installRoot } : null
|
|
355
|
+
);
|
|
340
356
|
const commandLine = method === "global-npm" ? suggestedCommand : runSpec ? [runSpec.cmd, ...runSpec.args].join(" ") : plan.command;
|
|
341
357
|
if (!opts.run) {
|
|
342
358
|
if (runSpec) {
|
|
@@ -379,7 +395,7 @@ async function runUpgrade(opts = {}) {
|
|
|
379
395
|
return { exitCode: 3, lines };
|
|
380
396
|
}
|
|
381
397
|
function readCurrentVersion() {
|
|
382
|
-
return true ? "0.
|
|
398
|
+
return true ? "0.78.0" : "dev";
|
|
383
399
|
}
|
|
384
400
|
|
|
385
401
|
// src/auto-upgrade.ts
|
|
@@ -402,29 +418,17 @@ function detectRunningInstallPrefix(argvPath) {
|
|
|
402
418
|
} catch {
|
|
403
419
|
return null;
|
|
404
420
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
const candidate = dir.slice(0, idx);
|
|
412
|
-
if (candidate.endsWith(`${sep}lib`)) return candidate.slice(0, -`${sep}lib`.length);
|
|
413
|
-
return candidate;
|
|
414
|
-
}
|
|
415
|
-
prev = dir;
|
|
416
|
-
dir = dirname(dir);
|
|
417
|
-
}
|
|
418
|
-
return null;
|
|
419
|
-
}
|
|
420
|
-
function comparablePrefix(p) {
|
|
421
|
-
const trimmed = p.trim();
|
|
422
|
-
return process.platform === "win32" ? trimmed.toLowerCase() : trimmed;
|
|
421
|
+
const dir = dirname(resolved);
|
|
422
|
+
const idx = dir.lastIndexOf(`${sep}node_modules${sep}`);
|
|
423
|
+
if (idx === -1) return null;
|
|
424
|
+
const candidate = dir.slice(0, idx);
|
|
425
|
+
if (candidate.endsWith(`${sep}lib`)) return candidate.slice(0, -`${sep}lib`.length);
|
|
426
|
+
return candidate;
|
|
423
427
|
}
|
|
424
428
|
async function compareWithNpmPrefix(detected, probe = npmGlobalPrefix) {
|
|
425
429
|
const npmPrefix = await probe();
|
|
426
430
|
if (!npmPrefix?.trim()) return;
|
|
427
|
-
if (
|
|
431
|
+
if (comparablePath(npmPrefix.trim()) === comparablePath(detected)) return;
|
|
428
432
|
process.stderr.write(
|
|
429
433
|
`yaw-mcp self-upgrade: detected running prefix differs from \`npm prefix -g\`:
|
|
430
434
|
running: ${detected}
|
|
@@ -433,8 +437,66 @@ async function compareWithNpmPrefix(detected, probe = npmGlobalPrefix) {
|
|
|
433
437
|
`
|
|
434
438
|
);
|
|
435
439
|
}
|
|
436
|
-
|
|
440
|
+
var UPGRADE_LOCK_NAME = ".yaw-mcp-upgrade.lock";
|
|
441
|
+
var UPGRADE_LOCK_STALE_MS = 10 * 60 * 1e3;
|
|
442
|
+
var UPGRADE_LOCK_FUTURE_SKEW_MS = 5 * 1e3;
|
|
443
|
+
function acquireUpgradeLock(dir, now = Date.now()) {
|
|
444
|
+
const lockPath = join(dir, UPGRADE_LOCK_NAME);
|
|
445
|
+
const take = () => {
|
|
446
|
+
try {
|
|
447
|
+
const fd = openSync(lockPath, "wx");
|
|
448
|
+
try {
|
|
449
|
+
writeSync(fd, `${process.pid}
|
|
450
|
+
`);
|
|
451
|
+
} finally {
|
|
452
|
+
closeSync(fd);
|
|
453
|
+
}
|
|
454
|
+
let released = false;
|
|
455
|
+
return () => {
|
|
456
|
+
if (released) return;
|
|
457
|
+
released = true;
|
|
458
|
+
try {
|
|
459
|
+
unlinkSync(lockPath);
|
|
460
|
+
} catch {
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
} catch (err) {
|
|
464
|
+
if (err.code === "EEXIST") return void 0;
|
|
465
|
+
return () => {
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
const first = take();
|
|
470
|
+
if (first !== void 0) return first;
|
|
471
|
+
let ageMs;
|
|
472
|
+
try {
|
|
473
|
+
ageMs = now - statSync(lockPath).mtimeMs;
|
|
474
|
+
} catch {
|
|
475
|
+
ageMs = UPGRADE_LOCK_STALE_MS;
|
|
476
|
+
}
|
|
477
|
+
if (ageMs > -UPGRADE_LOCK_FUTURE_SKEW_MS && ageMs < UPGRADE_LOCK_STALE_MS) return null;
|
|
478
|
+
try {
|
|
479
|
+
unlinkSync(lockPath);
|
|
480
|
+
} catch {
|
|
481
|
+
return null;
|
|
482
|
+
}
|
|
483
|
+
const second = take();
|
|
484
|
+
return second === void 0 ? null : second;
|
|
485
|
+
}
|
|
486
|
+
function defaultAcquireLock(dir) {
|
|
487
|
+
if (process.env.VITEST) return () => {
|
|
488
|
+
};
|
|
489
|
+
return acquireUpgradeLock(dir);
|
|
490
|
+
}
|
|
491
|
+
function defaultSpawn2(cmd, args, onDone = () => {
|
|
492
|
+
}) {
|
|
437
493
|
let errorFired = false;
|
|
494
|
+
let released = false;
|
|
495
|
+
const finish = () => {
|
|
496
|
+
if (released) return;
|
|
497
|
+
released = true;
|
|
498
|
+
onDone();
|
|
499
|
+
};
|
|
438
500
|
const correctiveCmd = cmd === "npm" ? "npm install -g @yawlabs/mcp@latest" : cmd === "pnpm" ? "pnpm add -g @yawlabs/mcp@latest" : "bun add -g @yawlabs/mcp@latest";
|
|
439
501
|
const child = spawn2(cmd, args, {
|
|
440
502
|
stdio: "ignore",
|
|
@@ -449,6 +511,7 @@ function defaultSpawn2(cmd, args) {
|
|
|
449
511
|
shell: process.platform === "win32"
|
|
450
512
|
});
|
|
451
513
|
child.on("close", (code) => {
|
|
514
|
+
finish();
|
|
452
515
|
if (errorFired) return;
|
|
453
516
|
if (code === 0) {
|
|
454
517
|
log("info", "yaw-mcp self-upgrade complete; the next client restart will run the new version");
|
|
@@ -463,13 +526,14 @@ function defaultSpawn2(cmd, args) {
|
|
|
463
526
|
});
|
|
464
527
|
child.on("error", (err) => {
|
|
465
528
|
errorFired = true;
|
|
529
|
+
finish();
|
|
466
530
|
log("warn", `yaw-mcp self-upgrade: ${cmd} spawn failed`, { error: err?.message });
|
|
467
531
|
});
|
|
468
532
|
}
|
|
469
533
|
async function maybeAutoUpgrade(deps = {}) {
|
|
470
534
|
const optOut = process.env.YAW_MCP_AUTO_UPGRADE;
|
|
471
535
|
if (optOut === "0" || optOut?.toLowerCase() === "false") return;
|
|
472
|
-
const current = deps.currentVersion ?? (true ? "0.
|
|
536
|
+
const current = deps.currentVersion ?? (true ? "0.78.0" : "dev");
|
|
473
537
|
if (current === "dev") return;
|
|
474
538
|
const method = (deps.isSeaImpl ? await deps.isSeaImpl() : await detectSea()) ? "binary" : detectInstallMethod(deps.argvPath ?? process.argv[1]);
|
|
475
539
|
const latest = await (deps.fetchLatestImpl ?? fetchLatestVersion)();
|
|
@@ -483,6 +547,17 @@ async function maybeAutoUpgrade(deps = {}) {
|
|
|
483
547
|
args: quotedPrefix ? ["install", "-g", "--prefix", quotedPrefix, "@yawlabs/mcp@latest"] : ["install", "-g", "@yawlabs/mcp@latest"]
|
|
484
548
|
} : method === "pnpm-global" ? { cmd: "pnpm", args: ["add", "-g", "@yawlabs/mcp@latest"] } : method === "bun-global" ? { cmd: "bun", args: ["add", "-g", "@yawlabs/mcp@latest"] } : null;
|
|
485
549
|
if (globalSpec) {
|
|
550
|
+
const lockDir = rawPrefix ?? tmpdir();
|
|
551
|
+
const releaseLock = (deps.acquireLockImpl ?? defaultAcquireLock)(lockDir);
|
|
552
|
+
if (releaseLock === null) {
|
|
553
|
+
log("info", "yaw-mcp self-upgrade: another process is already upgrading this install; skipping this one", {
|
|
554
|
+
current,
|
|
555
|
+
latest,
|
|
556
|
+
tool: globalSpec.cmd,
|
|
557
|
+
lockDir
|
|
558
|
+
});
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
486
561
|
log("info", "yaw-mcp is out of date; upgrading the global install in the background", {
|
|
487
562
|
current,
|
|
488
563
|
latest,
|
|
@@ -496,7 +571,14 @@ async function maybeAutoUpgrade(deps = {}) {
|
|
|
496
571
|
if (method === "global-npm" && rawPrefix !== null && quotedPrefix !== null) {
|
|
497
572
|
void compareWithNpmPrefix(rawPrefix, deps.npmPrefixImpl);
|
|
498
573
|
}
|
|
499
|
-
|
|
574
|
+
try {
|
|
575
|
+
(deps.spawnImpl ?? defaultSpawn2)(globalSpec.cmd, globalSpec.args, releaseLock);
|
|
576
|
+
} catch (err) {
|
|
577
|
+
releaseLock();
|
|
578
|
+
log("warn", `yaw-mcp self-upgrade: could not start ${globalSpec.cmd}`, {
|
|
579
|
+
error: err instanceof Error ? err.message : String(err)
|
|
580
|
+
});
|
|
581
|
+
}
|
|
500
582
|
return;
|
|
501
583
|
}
|
|
502
584
|
if (method === "bundled-app") {
|
|
@@ -504,7 +586,11 @@ async function maybeAutoUpgrade(deps = {}) {
|
|
|
504
586
|
return;
|
|
505
587
|
}
|
|
506
588
|
if (method === "binary") {
|
|
507
|
-
log(
|
|
589
|
+
log(
|
|
590
|
+
"info",
|
|
591
|
+
"yaw-mcp (standalone binary) is behind npm; the binary track was retired -- npm install -g @yawlabs/mcp@latest, then delete the old executable",
|
|
592
|
+
{ current, latest }
|
|
593
|
+
);
|
|
508
594
|
return;
|
|
509
595
|
}
|
|
510
596
|
if (method === "npx") {
|
|
@@ -537,16 +623,17 @@ async function maybeAutoUpgrade(deps = {}) {
|
|
|
537
623
|
}
|
|
538
624
|
|
|
539
625
|
export {
|
|
540
|
-
|
|
541
|
-
quoteArgForDisplay,
|
|
542
|
-
detectRunningInstallPrefix,
|
|
543
|
-
maybeAutoUpgrade,
|
|
544
|
-
BINARY_DOWNLOAD_URL,
|
|
626
|
+
BINARY_RETIRED_HINT,
|
|
545
627
|
parseUpgradeArgs,
|
|
546
628
|
detectInstallMethod,
|
|
547
629
|
refineInstallMethod,
|
|
548
630
|
buildUpgradePlan,
|
|
549
631
|
fetchLatestVersion,
|
|
550
632
|
detectSea,
|
|
551
|
-
runUpgrade
|
|
633
|
+
runUpgrade,
|
|
634
|
+
quoteShellArgIfNeeded,
|
|
635
|
+
quoteArgForDisplay,
|
|
636
|
+
detectRunningInstallPrefix,
|
|
637
|
+
acquireUpgradeLock,
|
|
638
|
+
maybeAutoUpgrade
|
|
552
639
|
};
|