@mthines/reaper-mcp 0.96.0 → 0.97.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/README.md +47 -47
- package/bridge-ui/mcp_bridge.html +29 -29
- package/main.js +134 -12
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -298,6 +298,14 @@ var ALLOWED_SPAN_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
|
298
298
|
"reaper.bridge.heartbeat_age",
|
|
299
299
|
"reaper.bridge.autostart",
|
|
300
300
|
"reaper.sidecar.installed",
|
|
301
|
+
// How this copy was installed and whether it keeps up with releases, on the startup span (install-info.ts):
|
|
302
|
+
// npx, npm_global, clone or other; what an npx config asked for (exact, range, latest, unversioned, tag, none);
|
|
303
|
+
// whether npm's latest release is newer (as last asked, update-check.json); and on the first start after
|
|
304
|
+
// `reaper-mcp update`, whether the bridge page or the command installed it. Closed values, never a path or a spec.
|
|
305
|
+
"reaper.install.method",
|
|
306
|
+
"reaper.install.pin",
|
|
307
|
+
"reaper.update.available",
|
|
308
|
+
"reaper.update.via",
|
|
301
309
|
// A failed tool call's missing setup step, a fixed set (toolErrorCause in server.ts):
|
|
302
310
|
// sidecar_not_installed, bridge_not_running, bridge_outdated
|
|
303
311
|
"reaper.tool.error.cause",
|
|
@@ -10772,7 +10780,7 @@ function flagsCommand(args, options = {}) {
|
|
|
10772
10780
|
}
|
|
10773
10781
|
|
|
10774
10782
|
// apps/reaper-mcp-server/src/main.ts
|
|
10775
|
-
import { existsSync as existsSync13, mkdirSync as mkdirSync13, readFileSync as
|
|
10783
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync13, readFileSync as readFileSync15, realpathSync as realpathSync2, rmSync as rmSync4, writeFileSync as writeFileSync12 } from "node:fs";
|
|
10776
10784
|
import { join as join21, dirname as dirname12, resolve as resolve3 } from "node:path";
|
|
10777
10785
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
10778
10786
|
import { homedir as homedir12, platform as platform6 } from "node:os";
|
|
@@ -10796,7 +10804,7 @@ function compareVersions(a, b) {
|
|
|
10796
10804
|
}
|
|
10797
10805
|
|
|
10798
10806
|
// apps/reaper-mcp-server/src/update-check.ts
|
|
10799
|
-
import { mkdirSync as mkdirSync8, readFileSync as readFileSync7, writeFileSync as writeFileSync7 } from "node:fs";
|
|
10807
|
+
import { mkdirSync as mkdirSync8, readFileSync as readFileSync7, rmSync as rmSync2, writeFileSync as writeFileSync7 } from "node:fs";
|
|
10800
10808
|
import { dirname as dirname8, join as join14 } from "node:path";
|
|
10801
10809
|
import { homedir as homedir10 } from "node:os";
|
|
10802
10810
|
var NPM_PACKAGE = "@mthines/reaper-mcp";
|
|
@@ -10858,6 +10866,35 @@ async function checkForUpdate(opts) {
|
|
|
10858
10866
|
markNotified: () => writeState(statePath, { ...readState(statePath), notifiedAt: Date.now() })
|
|
10859
10867
|
};
|
|
10860
10868
|
}
|
|
10869
|
+
function cachedUpdateAvailable(current, statePath = defaultUpdateStatePath()) {
|
|
10870
|
+
const latest = readState(statePath).latest;
|
|
10871
|
+
if (typeof latest !== "string" || !/^\d+\.\d+\.\d+/.test(latest)) return void 0;
|
|
10872
|
+
return compareVersions(latest, current) > 0;
|
|
10873
|
+
}
|
|
10874
|
+
function defaultUpdateMarkerPath() {
|
|
10875
|
+
return join14(homedir10(), ".reaper-mcp", "last-update.json");
|
|
10876
|
+
}
|
|
10877
|
+
function writeUpdateMarker(path, marker) {
|
|
10878
|
+
try {
|
|
10879
|
+
mkdirSync8(dirname8(path), { recursive: true });
|
|
10880
|
+
writeFileSync7(path, JSON.stringify(marker) + "\n", "utf-8");
|
|
10881
|
+
} catch {
|
|
10882
|
+
}
|
|
10883
|
+
}
|
|
10884
|
+
function takeUpdateMarker(path, current) {
|
|
10885
|
+
let marker;
|
|
10886
|
+
try {
|
|
10887
|
+
marker = JSON.parse(readFileSync7(path, "utf-8"));
|
|
10888
|
+
} catch {
|
|
10889
|
+
return void 0;
|
|
10890
|
+
}
|
|
10891
|
+
if (marker?.to !== current) return void 0;
|
|
10892
|
+
try {
|
|
10893
|
+
rmSync2(path, { force: true });
|
|
10894
|
+
} catch {
|
|
10895
|
+
}
|
|
10896
|
+
return marker.via === "bridge_page" || marker.via === "cli" ? marker.via : void 0;
|
|
10897
|
+
}
|
|
10861
10898
|
|
|
10862
10899
|
// apps/reaper-mcp-server/src/harnesses.ts
|
|
10863
10900
|
import { execFileSync } from "node:child_process";
|
|
@@ -11035,6 +11072,7 @@ async function runUpdate(deps) {
|
|
|
11035
11072
|
log(` Run this in a terminal to see what npm says: npm install -g ${NPM_PACKAGE}@${latest}`);
|
|
11036
11073
|
return 1;
|
|
11037
11074
|
}
|
|
11075
|
+
deps.recordUpdate?.(latest);
|
|
11038
11076
|
log("==> Installing into REAPER");
|
|
11039
11077
|
if (await deps.run(deps.node, [deps.cli, "setup", "--yes"]) !== 0) {
|
|
11040
11078
|
log("\u2717 The new version downloaded, but installing it into REAPER failed. Run this in a terminal to see why:");
|
|
@@ -11092,7 +11130,8 @@ function realUpdateDeps(current, cli, force = false, bridge = false) {
|
|
|
11092
11130
|
cli,
|
|
11093
11131
|
log: (line) => console.log(line),
|
|
11094
11132
|
force,
|
|
11095
|
-
bridge
|
|
11133
|
+
bridge,
|
|
11134
|
+
recordUpdate: (version) => writeUpdateMarker(defaultUpdateMarkerPath(), { via: bridge ? "bridge_page" : "cli", to: version })
|
|
11096
11135
|
};
|
|
11097
11136
|
}
|
|
11098
11137
|
|
|
@@ -11269,7 +11308,7 @@ function renderDoctor(sections3, opts = {}) {
|
|
|
11269
11308
|
}
|
|
11270
11309
|
|
|
11271
11310
|
// apps/reaper-mcp-server/src/bridge-repair.ts
|
|
11272
|
-
import { existsSync as existsSync12, mkdirSync as mkdirSync12, readFileSync as readFileSync12, rmSync as
|
|
11311
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync12, readFileSync as readFileSync12, rmSync as rmSync3, writeFileSync as writeFileSync11 } from "node:fs";
|
|
11273
11312
|
import { join as join19 } from "node:path";
|
|
11274
11313
|
var BRIDGE_VERSION_FILE = "mcp_bridge_version.txt";
|
|
11275
11314
|
function readBridgeVersion(scriptsDir) {
|
|
@@ -11303,7 +11342,7 @@ function installReaperFiles(paths) {
|
|
|
11303
11342
|
if (lua && !sameContent(src, dest)) luaChanged = true;
|
|
11304
11343
|
installFile(src, dest);
|
|
11305
11344
|
}
|
|
11306
|
-
for (const asset of RETIRED_ASSETS)
|
|
11345
|
+
for (const asset of RETIRED_ASSETS) rmSync3(join19(paths.scriptsDir, asset), { force: true });
|
|
11307
11346
|
if (existsSync12(join19(paths.wwwSrcDir, BRIDGE_UI_FILE))) copyDirSync(paths.wwwSrcDir, paths.wwwDir);
|
|
11308
11347
|
return luaChanged;
|
|
11309
11348
|
}
|
|
@@ -11406,6 +11445,88 @@ function setupHealthAttributes(h) {
|
|
|
11406
11445
|
return attrs;
|
|
11407
11446
|
}
|
|
11408
11447
|
|
|
11448
|
+
// apps/reaper-mcp-server/src/install-info.ts
|
|
11449
|
+
import { readFileSync as readFileSync14, realpathSync } from "node:fs";
|
|
11450
|
+
import { posix, win32 } from "node:path";
|
|
11451
|
+
function pathApi(platform7) {
|
|
11452
|
+
return platform7 === "win32" ? win32 : posix;
|
|
11453
|
+
}
|
|
11454
|
+
function npxRoot(dir, platform7) {
|
|
11455
|
+
const p = pathApi(platform7);
|
|
11456
|
+
const parts = dir.split(p.sep);
|
|
11457
|
+
const i = parts.lastIndexOf("_npx");
|
|
11458
|
+
return i >= 0 && i + 1 < parts.length ? parts.slice(0, i + 2).join(p.sep) : void 0;
|
|
11459
|
+
}
|
|
11460
|
+
function isGlobalNpm(ctx) {
|
|
11461
|
+
const p = pathApi(ctx.platform);
|
|
11462
|
+
const pkgTail = p.join("node_modules", ...NPM_PACKAGE.split("/"));
|
|
11463
|
+
if (ctx.platform !== "win32") return ctx.dir.endsWith(p.sep + p.join("lib", pkgTail));
|
|
11464
|
+
const dir = ctx.dir.toLowerCase();
|
|
11465
|
+
const prefixes = [p.dirname(ctx.execPath), ctx.env["APPDATA"] ? p.join(ctx.env["APPDATA"], "npm") : void 0];
|
|
11466
|
+
return prefixes.some((prefix) => prefix !== void 0 && dir === p.join(prefix, pkgTail).toLowerCase());
|
|
11467
|
+
}
|
|
11468
|
+
function installMethod(ctx) {
|
|
11469
|
+
if (ctx.isClone) return "clone";
|
|
11470
|
+
if (npxRoot(ctx.dir, ctx.platform)) return "npx";
|
|
11471
|
+
if (isGlobalNpm(ctx)) return "npm_global";
|
|
11472
|
+
return ctx.env["npm_command"] === "exec" ? "npx" : "other";
|
|
11473
|
+
}
|
|
11474
|
+
function classifySpec(spec) {
|
|
11475
|
+
if (!spec.startsWith(NPM_PACKAGE)) return void 0;
|
|
11476
|
+
const rest = spec.slice(NPM_PACKAGE.length);
|
|
11477
|
+
if (rest === "") return "unversioned";
|
|
11478
|
+
if (!rest.startsWith("@")) return void 0;
|
|
11479
|
+
const version = rest.slice(1).trim();
|
|
11480
|
+
if (version === "") return "unversioned";
|
|
11481
|
+
if (version === "latest") return "latest";
|
|
11482
|
+
if (/^v?\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$/.test(version)) return "exact";
|
|
11483
|
+
if (/^[\^~<>=*xX\d]/.test(version) || version.includes("||") || / - /.test(version)) return "range";
|
|
11484
|
+
return "tag";
|
|
11485
|
+
}
|
|
11486
|
+
function installPin(ctx, method, readFile6 = (path) => readFileSync14(path, "utf-8")) {
|
|
11487
|
+
if (method !== "npx") return "none";
|
|
11488
|
+
const specs = [];
|
|
11489
|
+
const root = npxRoot(ctx.dir, ctx.platform);
|
|
11490
|
+
if (root) {
|
|
11491
|
+
try {
|
|
11492
|
+
const pkg = JSON.parse(readFile6(pathApi(ctx.platform).join(root, "package.json")));
|
|
11493
|
+
const packages = pkg._npx?.packages;
|
|
11494
|
+
if (Array.isArray(packages)) specs.push(...packages.filter((s) => typeof s === "string"));
|
|
11495
|
+
} catch {
|
|
11496
|
+
}
|
|
11497
|
+
}
|
|
11498
|
+
if (ctx.env["npm_config_package"]) specs.push(...ctx.env["npm_config_package"].split(/[\n,]/));
|
|
11499
|
+
for (const spec of specs) {
|
|
11500
|
+
const pin = classifySpec(spec.trim());
|
|
11501
|
+
if (pin) return pin;
|
|
11502
|
+
}
|
|
11503
|
+
return void 0;
|
|
11504
|
+
}
|
|
11505
|
+
function installAttributes(info) {
|
|
11506
|
+
const attrs = { "reaper.install.method": info.method };
|
|
11507
|
+
if (info.pin !== void 0) attrs["reaper.install.pin"] = info.pin;
|
|
11508
|
+
if (info.updateAvailable !== void 0) attrs["reaper.update.available"] = info.updateAvailable;
|
|
11509
|
+
if (info.via !== void 0) attrs["reaper.update.via"] = info.via;
|
|
11510
|
+
return attrs;
|
|
11511
|
+
}
|
|
11512
|
+
function readInstallInfo(codeDir, current, env = process.env, paths = { statePath: defaultUpdateStatePath(), markerPath: defaultUpdateMarkerPath() }) {
|
|
11513
|
+
let dir = codeDir;
|
|
11514
|
+
try {
|
|
11515
|
+
dir = realpathSync(codeDir);
|
|
11516
|
+
} catch {
|
|
11517
|
+
}
|
|
11518
|
+
const ctx = { dir, isClone: findCloneRoot(dir) !== null, env, execPath: process.execPath, platform: process.platform };
|
|
11519
|
+
const method = installMethod(ctx);
|
|
11520
|
+
const pin = installPin(ctx, method);
|
|
11521
|
+
const checks = !ctx.isClone && !updateCheckDisabled(env);
|
|
11522
|
+
return {
|
|
11523
|
+
method,
|
|
11524
|
+
pin,
|
|
11525
|
+
updateAvailable: checks ? cachedUpdateAvailable(current, paths.statePath) : void 0,
|
|
11526
|
+
via: takeUpdateMarker(paths.markerPath, current)
|
|
11527
|
+
};
|
|
11528
|
+
}
|
|
11529
|
+
|
|
11409
11530
|
// apps/reaper-mcp-server/src/main.ts
|
|
11410
11531
|
var execAsync = promisifyUtil(execCb);
|
|
11411
11532
|
var ui = createUi();
|
|
@@ -11459,7 +11580,7 @@ Restart REAPER (or run the bridge once from the Action List) and add reaper-mcp
|
|
|
11459
11580
|
for (const asset of RETIRED_ASSETS) {
|
|
11460
11581
|
const dest = join21(scriptsDir, asset);
|
|
11461
11582
|
if (existsSync13(dest)) {
|
|
11462
|
-
|
|
11583
|
+
rmSync4(dest);
|
|
11463
11584
|
console.log(ui.item("info", `Removed: ${asset} (retired)`));
|
|
11464
11585
|
}
|
|
11465
11586
|
}
|
|
@@ -11582,7 +11703,7 @@ async function enableWebInterface() {
|
|
|
11582
11703
|
return null;
|
|
11583
11704
|
}
|
|
11584
11705
|
const requested = Number(process.env["REAPER_WEB_PORT"]) || DEFAULT_WEB_PORT;
|
|
11585
|
-
const result = ensureWebInterface(
|
|
11706
|
+
const result = ensureWebInterface(readFileSync15(iniPath, "utf-8"), requested);
|
|
11586
11707
|
if (!result.changed) {
|
|
11587
11708
|
console.log(ui.item("ok", `Already enabled on port ${result.port}`));
|
|
11588
11709
|
return result.port;
|
|
@@ -11597,14 +11718,14 @@ async function enableWebInterface() {
|
|
|
11597
11718
|
console.log(" Quit REAPER to finish (Ctrl+C to skip)...");
|
|
11598
11719
|
while (await isReaperRunning()) await new Promise((r) => setTimeout(r, 1e3));
|
|
11599
11720
|
}
|
|
11600
|
-
writeFileSync12(iniPath, ensureWebInterface(
|
|
11721
|
+
writeFileSync12(iniPath, ensureWebInterface(readFileSync15(iniPath, "utf-8"), requested).ini, "utf-8");
|
|
11601
11722
|
console.log(ui.item("ok", `Enabled on port ${result.port} (override with REAPER_WEB_PORT)`));
|
|
11602
11723
|
return result.port;
|
|
11603
11724
|
}
|
|
11604
11725
|
function installBridgeAutostart(scriptsDir) {
|
|
11605
11726
|
console.log(ui.section("Starting the bridge with REAPER..."));
|
|
11606
11727
|
const path = join21(scriptsDir, "__startup.lua");
|
|
11607
|
-
const { text: text8, changed } = ensureBridgeAutostart(existsSync13(path) ?
|
|
11728
|
+
const { text: text8, changed } = ensureBridgeAutostart(existsSync13(path) ? readFileSync15(path, "utf-8") : "");
|
|
11608
11729
|
if (changed) writeFileSync12(path, text8, "utf-8");
|
|
11609
11730
|
console.log(ui.item("ok", changed ? "Added to Scripts/__startup.lua (REAPER runs it at launch)" : "Already in Scripts/__startup.lua"));
|
|
11610
11731
|
console.log(ui.dim(" Turn it off in the bridge window: Settings > Start with REAPER."));
|
|
@@ -11612,7 +11733,7 @@ function installBridgeAutostart(scriptsDir) {
|
|
|
11612
11733
|
async function registerSnapshotActions() {
|
|
11613
11734
|
console.log(ui.section("Registering snapshot actions (quick save, next, previous)..."));
|
|
11614
11735
|
const kbPath = join21(getReaperResourcePath(), "reaper-kb.ini");
|
|
11615
|
-
const kb = existsSync13(kbPath) ?
|
|
11736
|
+
const kb = existsSync13(kbPath) ? readFileSync15(kbPath, "utf-8") : "";
|
|
11616
11737
|
const { added } = ensureSnapshotActions(kb);
|
|
11617
11738
|
if (!added.length) {
|
|
11618
11739
|
console.log(ui.item("ok", "Already in the Action List"));
|
|
@@ -11647,7 +11768,7 @@ async function init(chained = false) {
|
|
|
11647
11768
|
console.log(`None of the supported harnesses is installed yet. Install one (see above), then run: ${ui.cmd("reaper-mcp init")}`);
|
|
11648
11769
|
return;
|
|
11649
11770
|
}
|
|
11650
|
-
const mainJs =
|
|
11771
|
+
const mainJs = realpathSync2(process.argv[1]);
|
|
11651
11772
|
const inClone = findCloneRoot(__dirname2) !== null;
|
|
11652
11773
|
for (const id of ids) {
|
|
11653
11774
|
const h = HARNESSES.find((x) => x.id === id);
|
|
@@ -11767,7 +11888,7 @@ async function doctor() {
|
|
|
11767
11888
|
core2.push(
|
|
11768
11889
|
bridgeRunning ? { label: "Lua bridge", status: "ok", detail: "Connected" } : { label: "Lua bridge", status: "fail", detail: "Not detected", fix: "reaper-mcp setup, then run mcp_bridge.lua in REAPER" }
|
|
11769
11890
|
);
|
|
11770
|
-
const readIfExists = (path) => existsSync13(path) ?
|
|
11891
|
+
const readIfExists = (path) => existsSync13(path) ? readFileSync15(path, "utf-8") : null;
|
|
11771
11892
|
core2.push(autostartCheck(
|
|
11772
11893
|
readIfExists(join21(getReaperScriptsPath(), "__startup.lua")),
|
|
11773
11894
|
readIfExists(join21(getReaperResourcePath(), "reaper-extstate.ini")),
|
|
@@ -11933,6 +12054,7 @@ async function serve() {
|
|
|
11933
12054
|
log(`Cleaned up ${cleaned} stale bridge files`);
|
|
11934
12055
|
}
|
|
11935
12056
|
const repair = repairReaperSide(log);
|
|
12057
|
+
startupSpan.setAttributes(installAttributes(readInstallInfo(__dirname2, readServiceVersion())));
|
|
11936
12058
|
const bridge = await tracer.startActiveSpan("check bridge connection", { kind: SpanKind5.INTERNAL }, async (bridgeSpan) => {
|
|
11937
12059
|
const status = await getBridgeState();
|
|
11938
12060
|
const running = status.state === "connected";
|
package/package.json
CHANGED