@mthines/reaper-mcp 0.83.0-beta.117.1 → 0.83.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 +45 -45
- package/bridge-ui/mcp_bridge.html +26 -26
- package/main.js +971 -270
- package/package.json +1 -1
- package/sidecar/server.py +19 -4
- package/sidecar/tests/test_chords.py +29 -0
- package/sidecar/tests/test_server.py +13 -0
- package/sidecar/tests/test_voice_render.py +1 -1
- package/sidecar/voice_render.py +4 -2
package/main.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// apps/reaper-mcp-server/src/main.ts
|
|
4
|
+
import { createInterface as createInterface5 } from "node:readline";
|
|
4
5
|
import { SpanKind as SpanKind5, SpanStatusCode as SpanStatusCode4 } from "@opentelemetry/api";
|
|
5
6
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
7
|
|
|
@@ -32,6 +33,108 @@ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
|
32
33
|
import { homedir } from "node:os";
|
|
33
34
|
import { join } from "node:path";
|
|
34
35
|
import { createInterface } from "node:readline";
|
|
36
|
+
import { PassThrough } from "node:stream";
|
|
37
|
+
|
|
38
|
+
// apps/reaper-mcp-server/src/stream-ended.ts
|
|
39
|
+
function streamEnded(stream) {
|
|
40
|
+
const s = stream;
|
|
41
|
+
return s.readableEnded === true || s.destroyed === true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// apps/reaper-mcp-server/src/terminal-ui.ts
|
|
45
|
+
function colorLevel(stream = process.stdout, env = process.env) {
|
|
46
|
+
if (env["NO_COLOR"] !== void 0 && env["NO_COLOR"] !== "") return 0;
|
|
47
|
+
const force = env["FORCE_COLOR"];
|
|
48
|
+
if (force === "0" || force === "false") return 0;
|
|
49
|
+
const forced = force !== void 0 && force !== "";
|
|
50
|
+
if (!forced && !stream.isTTY) return 0;
|
|
51
|
+
if (!forced && env["TERM"] === "dumb") return 0;
|
|
52
|
+
if (force === "1" || force === "2" || force === "3") return Number(force);
|
|
53
|
+
const colorterm = (env["COLORTERM"] ?? "").toLowerCase();
|
|
54
|
+
if (colorterm === "truecolor" || colorterm === "24bit") return 3;
|
|
55
|
+
if (/256color/.test(env["TERM"] ?? "") || env["TERM_PROGRAM"] === "Apple_Terminal") return 2;
|
|
56
|
+
return 1;
|
|
57
|
+
}
|
|
58
|
+
function useColor(stream = process.stdout, env = process.env) {
|
|
59
|
+
return colorLevel(stream, env) > 0;
|
|
60
|
+
}
|
|
61
|
+
var BRAND = [
|
|
62
|
+
[134, 239, 172],
|
|
63
|
+
[34, 211, 238],
|
|
64
|
+
[129, 140, 248]
|
|
65
|
+
];
|
|
66
|
+
var STATUS_CODE = { ok: "32", fail: "31", warn: "33", info: "2" };
|
|
67
|
+
var STATUS_MARK = { ok: "\u2713", fail: "\u2717", warn: "!", info: "\xB7" };
|
|
68
|
+
function lerp(stops, t) {
|
|
69
|
+
const x = Math.min(Math.max(t, 0), 1) * (stops.length - 1);
|
|
70
|
+
const i = Math.min(Math.floor(x), stops.length - 2);
|
|
71
|
+
const f = x - i;
|
|
72
|
+
return [0, 1, 2].map((k) => Math.round(stops[i][k] + (stops[i + 1][k] - stops[i][k]) * f));
|
|
73
|
+
}
|
|
74
|
+
function rgbTo256([r, g, b]) {
|
|
75
|
+
const cube = (v) => Math.round(v / 255 * 5);
|
|
76
|
+
return 16 + 36 * cube(r) + 6 * cube(g) + cube(b);
|
|
77
|
+
}
|
|
78
|
+
var GLYPHS = {
|
|
79
|
+
R: ["\u2588\u2588\u2588\u2588\u2588\u2588\u2557 ", "\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557", "\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D", "\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557", "\u2588\u2588\u2551 \u2588\u2588\u2551", "\u255A\u2550\u255D \u255A\u2550\u255D"],
|
|
80
|
+
E: ["\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557", "\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D", "\u2588\u2588\u2588\u2588\u2588\u2557 ", "\u2588\u2588\u2554\u2550\u2550\u255D ", "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557", "\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D"],
|
|
81
|
+
A: [" \u2588\u2588\u2588\u2588\u2588\u2557 ", "\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557", "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551", "\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551", "\u2588\u2588\u2551 \u2588\u2588\u2551", "\u255A\u2550\u255D \u255A\u2550\u255D"],
|
|
82
|
+
P: ["\u2588\u2588\u2588\u2588\u2588\u2588\u2557 ", "\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557", "\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D", "\u2588\u2588\u2554\u2550\u2550\u2550\u255D ", "\u2588\u2588\u2551 ", "\u255A\u2550\u255D "],
|
|
83
|
+
M: ["\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557", "\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551", "\u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551", "\u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551", "\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551", "\u255A\u2550\u255D \u255A\u2550\u255D"],
|
|
84
|
+
C: [" \u2588\u2588\u2588\u2588\u2588\u2588\u2557", "\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D", "\u2588\u2588\u2551 ", "\u2588\u2588\u2551 ", "\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557", " \u255A\u2550\u2550\u2550\u2550\u2550\u255D"],
|
|
85
|
+
" ": [" ", " ", " ", " ", " ", " "]
|
|
86
|
+
};
|
|
87
|
+
function wordmark(text8) {
|
|
88
|
+
return [0, 1, 2, 3, 4, 5].map((row) => [...text8].map((ch) => GLYPHS[ch][row]).join(""));
|
|
89
|
+
}
|
|
90
|
+
var LOGO_WIDTH = wordmark("REAPER MCP")[0].length;
|
|
91
|
+
var WAVE = "\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588\u2587\u2586\u2585\u2584\u2583\u2582\u2581\u2582\u2583\u2585\u2587\u2588\u2587\u2585\u2583\u2582\u2581\u2582\u2584\u2586\u2588\u2586\u2584\u2582\u2581";
|
|
92
|
+
function createUi(opts = {}) {
|
|
93
|
+
const level = opts.level ?? colorLevel();
|
|
94
|
+
const tty = opts.tty ?? Boolean(process.stdout.isTTY);
|
|
95
|
+
const columns = opts.columns ?? process.stdout.columns ?? 80;
|
|
96
|
+
const sgr = (codes, s) => level > 0 && s ? `\x1B[${codes}m${s}\x1B[0m` : s;
|
|
97
|
+
const rgb = (c) => level >= 3 ? `38;2;${c[0]};${c[1]};${c[2]}` : level === 2 ? `38;5;${rgbTo256(c)}` : "92";
|
|
98
|
+
const spread = (s, from = 0, to = 1) => {
|
|
99
|
+
if (level === 0) return s;
|
|
100
|
+
if (level === 1) return sgr("92", s);
|
|
101
|
+
const chars = [...s];
|
|
102
|
+
return chars.map((ch, i) => ch === " " ? ch : `\x1B[${rgb(lerp(BRAND, from + (to - from) * i / Math.max(chars.length - 1, 1)))}m${ch}`).join("") + "\x1B[0m";
|
|
103
|
+
};
|
|
104
|
+
const fancy = tty && columns >= LOGO_WIDTH + 2;
|
|
105
|
+
const ui2 = {
|
|
106
|
+
level,
|
|
107
|
+
columns,
|
|
108
|
+
tty,
|
|
109
|
+
fancy,
|
|
110
|
+
bold: (s) => sgr("1", s),
|
|
111
|
+
dim: (s) => sgr("2", s),
|
|
112
|
+
underline: (s) => sgr("4", s),
|
|
113
|
+
brand: (s) => sgr(level >= 2 ? rgb(BRAND[0]) : "92", s),
|
|
114
|
+
cmd: (s) => sgr("36", s),
|
|
115
|
+
link: (s) => sgr("4;36", s),
|
|
116
|
+
ok: (s) => sgr(STATUS_CODE.ok, s),
|
|
117
|
+
warn: (s) => sgr(STATUS_CODE.warn, s),
|
|
118
|
+
fail: (s) => sgr(STATUS_CODE.fail, s),
|
|
119
|
+
status: (status, text8) => sgr(STATUS_CODE[status], text8),
|
|
120
|
+
mark: (status) => sgr(STATUS_CODE[status], STATUS_MARK[status]),
|
|
121
|
+
gradient: (s) => spread(s),
|
|
122
|
+
heading: (text8, note) => `${sgr("1", text8)}${note ? sgr("2", ` ${note}`) : ""}`,
|
|
123
|
+
section: (title) => `
|
|
124
|
+
${sgr("1", title)}`,
|
|
125
|
+
item: (status, text8) => ` ${sgr(STATUS_CODE[status], STATUS_MARK[status])} ${text8}`,
|
|
126
|
+
banner: (subtitle, version) => {
|
|
127
|
+
const plain = `REAPER MCP \u2014 ${subtitle}`;
|
|
128
|
+
if (!fancy) return plain + "\n";
|
|
129
|
+
const logo = wordmark("REAPER MCP").map((line) => ` ${spread(line)}`);
|
|
130
|
+
const wave = ` ${spread(WAVE)} ${sgr("1", subtitle)}${version ? sgr("2", ` v${version}`) : ""}`;
|
|
131
|
+
return ["", ...logo, "", wave, ""].join("\n");
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
return ui2;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// apps/reaper-mcp-server/src/telemetry-consent.ts
|
|
35
138
|
var DEFAULT_DESTINATION = {
|
|
36
139
|
endpoint: "https://ingress.europe-west4.gcp.dash0-dev.com",
|
|
37
140
|
dataset: "reaper-mcp",
|
|
@@ -40,16 +143,19 @@ var DEFAULT_DESTINATION = {
|
|
|
40
143
|
};
|
|
41
144
|
var CONSENT_SERVICE_NAME = "reaper-mcp-consent";
|
|
42
145
|
var TELEMETRY_DOC_URL = "https://github.com/mthines/reaper-mcp/blob/main/TELEMETRY.md";
|
|
43
|
-
|
|
146
|
+
function renderTelemetryNotice(ui2 = createUi({ level: 0, tty: false })) {
|
|
147
|
+
return `${ui2.bold("Pseudonymous usage telemetry is ON by default.")}
|
|
44
148
|
reaper-mcp is built by one developer. To see which tools people use, which fail,
|
|
45
149
|
and how fast they are, it sends pseudonymous usage data: tool names, error types,
|
|
46
150
|
timings, and app/OS versions, tagged with a random install id.
|
|
47
151
|
It never sends your projects, track names, parameters, file paths or error text.
|
|
48
152
|
Your answer below is counted once, anonymously (on or off, no install id).
|
|
49
153
|
|
|
50
|
-
Opt out any time: reaper-mcp telemetry off
|
|
51
|
-
(or set REAPER_MCP_TELEMETRY=0 or DO_NOT_TRACK=1)
|
|
52
|
-
Details: ${TELEMETRY_DOC_URL}`;
|
|
154
|
+
Opt out any time: ${ui2.cmd("reaper-mcp telemetry off")}
|
|
155
|
+
${ui2.dim("(or set REAPER_MCP_TELEMETRY=0 or DO_NOT_TRACK=1)")}
|
|
156
|
+
Details: ${ui2.link(TELEMETRY_DOC_URL)}`;
|
|
157
|
+
}
|
|
158
|
+
var TELEMETRY_NOTICE = renderTelemetryNotice();
|
|
53
159
|
var FALSY = /* @__PURE__ */ new Set(["0", "false", "off", "no"]);
|
|
54
160
|
var isSet = (v) => v !== void 0 && v.trim() !== "";
|
|
55
161
|
var isFalsy = (v) => FALSY.has(v.trim().toLowerCase());
|
|
@@ -101,24 +207,65 @@ function resolveTelemetry(env = process.env, config = readTelemetryConfig(), des
|
|
|
101
207
|
reason: forcedOn ? `REAPER_MCP_TELEMETRY=${flag}` : "on by default \u2014 opt out with `reaper-mcp telemetry off`"
|
|
102
208
|
};
|
|
103
209
|
}
|
|
210
|
+
function lineReader(input) {
|
|
211
|
+
const ended = streamEnded(input);
|
|
212
|
+
const rl = createInterface({ input: ended ? new PassThrough() : input, terminal: false });
|
|
213
|
+
const queue = [];
|
|
214
|
+
let waiting;
|
|
215
|
+
let closed3 = ended;
|
|
216
|
+
rl.on("line", (line) => {
|
|
217
|
+
if (waiting) {
|
|
218
|
+
const resolve4 = waiting;
|
|
219
|
+
waiting = void 0;
|
|
220
|
+
resolve4(line);
|
|
221
|
+
} else queue.push(line);
|
|
222
|
+
});
|
|
223
|
+
rl.on("close", () => {
|
|
224
|
+
closed3 = true;
|
|
225
|
+
waiting?.("");
|
|
226
|
+
});
|
|
227
|
+
return {
|
|
228
|
+
next: () => queue.length ? Promise.resolve(queue.shift()) : closed3 ? Promise.resolve("") : new Promise((resolve4) => waiting = resolve4),
|
|
229
|
+
close: () => rl.close()
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
async function confirmOptOut(lines, output, ui2) {
|
|
233
|
+
output.write(`
|
|
234
|
+
${ui2.bold("Totally your call, no hard feelings \u{1F64F}")}
|
|
235
|
+
reaper-mcp is just me: one developer, building it in my spare time. These counts help me a ton,
|
|
236
|
+
they show me what to fix next. I can't see your music, projects, track names or files. Ever.
|
|
237
|
+
|
|
238
|
+
${ui2.bold("Turn telemetry off anyway?")} ${ui2.dim("[y/N]")} `);
|
|
239
|
+
const answer = (await lines.next()).trim().toLowerCase();
|
|
240
|
+
return answer === "y" || answer === "yes";
|
|
241
|
+
}
|
|
242
|
+
async function confirmOptOutPrompt(io) {
|
|
243
|
+
if (!io.interactive) return true;
|
|
244
|
+
const lines = lineReader(io.input);
|
|
245
|
+
const off = await confirmOptOut(lines, io.output, io.ui ?? createUi({ level: 0, tty: false }));
|
|
246
|
+
lines.close();
|
|
247
|
+
if (!off) io.output.write(`${(io.ui ?? createUi({ level: 0, tty: false })).mark("ok")} Thanks, telemetry stays on \u{1F49A}
|
|
248
|
+
`);
|
|
249
|
+
return off;
|
|
250
|
+
}
|
|
104
251
|
async function firstRunTelemetryNotice(io, dir = defaultConfigDir(), env = process.env, destination = DEFAULT_DESTINATION) {
|
|
105
252
|
const config = readTelemetryConfig(dir);
|
|
106
253
|
if (config.telemetryNoticeShown || resolveTelemetry(env, config, destination).mode !== "default") return void 0;
|
|
254
|
+
const ui2 = io.ui ?? createUi({ level: 0, tty: false });
|
|
107
255
|
io.output.write(`
|
|
108
|
-
${
|
|
256
|
+
${renderTelemetryNotice(ui2)}
|
|
109
257
|
|
|
110
258
|
`);
|
|
111
259
|
let keep = true;
|
|
112
260
|
if (io.interactive) {
|
|
113
|
-
const
|
|
114
|
-
io.output.write("Keep usage telemetry on? [Y/n]
|
|
115
|
-
const answer = await
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
io.output.write(keep ? "Thanks \u2014 telemetry stays on.\n" : "Telemetry is off. Turn it back on with `reaper-mcp telemetry on`.\n");
|
|
261
|
+
const lines = lineReader(io.input);
|
|
262
|
+
io.output.write(`${ui2.bold("Keep usage telemetry on?")} ${ui2.dim("[Y/n]")} `);
|
|
263
|
+
const answer = (await lines.next()).trim().toLowerCase();
|
|
264
|
+
keep = !(answer === "n" || answer === "no") || !await confirmOptOut(lines, io.output, ui2);
|
|
265
|
+
lines.close();
|
|
266
|
+
io.output.write(keep ? `${ui2.mark("ok")} Thanks \u2014 telemetry stays on.
|
|
267
|
+
` : `${ui2.mark("ok")} Telemetry is off. Turn it back on with \`${ui2.cmd("reaper-mcp telemetry on")}\`.
|
|
268
|
+
`);
|
|
122
269
|
}
|
|
123
270
|
writeTelemetryConfig({ telemetry: keep, telemetryNoticeShown: true }, dir);
|
|
124
271
|
return { state: keep ? "on" : "off", source: io.interactive ? "first_run_prompt" : "first_run_notice" };
|
|
@@ -140,6 +287,20 @@ var ALLOWED_SPAN_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
|
140
287
|
// (a fixed set: connected, stale, never_started, not_installed, no_reaper — never a path)
|
|
141
288
|
"reaper.bridge.connected",
|
|
142
289
|
"reaper.bridge.state",
|
|
290
|
+
// Whether this start brought REAPER's files up to its release (bridge-repair.ts): the bridge files
|
|
291
|
+
// changed, and the start-with-REAPER block was added (booleans, set only when true)
|
|
292
|
+
"reaper.bridge.files_updated",
|
|
293
|
+
"reaper.bridge.autostart_added",
|
|
294
|
+
// How far setup got, on the startup span (setup-health.ts): whether REAPER is running when the bridge
|
|
295
|
+
// did not answer, the heartbeat's age as a range (<1m … >7d), whether the bridge starts with REAPER,
|
|
296
|
+
// whether the audio sidecar is installed. Booleans and a fixed set of ranges, never a path or a time.
|
|
297
|
+
"reaper.app.running",
|
|
298
|
+
"reaper.bridge.heartbeat_age",
|
|
299
|
+
"reaper.bridge.autostart",
|
|
300
|
+
"reaper.sidecar.installed",
|
|
301
|
+
// A failed tool call's missing setup step, a fixed set (toolErrorCause in server.ts):
|
|
302
|
+
// sidecar_not_installed, bridge_not_running, bridge_outdated
|
|
303
|
+
"reaper.tool.error.cause",
|
|
143
304
|
// detect_key / detect_chords: where they read from and how sure they were, never the key or chords
|
|
144
305
|
"reaper.key.source",
|
|
145
306
|
"reaper.key.confidence",
|
|
@@ -660,6 +821,20 @@ function withPageLink(result, links) {
|
|
|
660
821
|
return { ...reply5, content: [...reply5.content, { type: "text", text: `Bridge page (before/after view): ${last}` }] };
|
|
661
822
|
}
|
|
662
823
|
|
|
824
|
+
// apps/reaper-mcp-server/src/call-outcome.ts
|
|
825
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
826
|
+
var store2 = new AsyncLocalStorage2();
|
|
827
|
+
function trackCallOutcome(fn) {
|
|
828
|
+
const outcome = { logged: false, regression: false };
|
|
829
|
+
return store2.run(outcome, async () => ({ result: await fn(), outcome }));
|
|
830
|
+
}
|
|
831
|
+
function noteLoggedFailure(regression) {
|
|
832
|
+
const outcome = store2.getStore();
|
|
833
|
+
if (!outcome) return;
|
|
834
|
+
outcome.logged = true;
|
|
835
|
+
if (regression) outcome.regression = true;
|
|
836
|
+
}
|
|
837
|
+
|
|
663
838
|
// apps/reaper-mcp-server/src/bridge.ts
|
|
664
839
|
var POLL_INTERVAL_MS = 10;
|
|
665
840
|
var BRIDGE_RPC_SYSTEM = "reaper_bridge";
|
|
@@ -825,6 +1000,7 @@ async function sendCommand(type, params = {}, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
|
825
1000
|
{ "rpc.method": type, "error.type": "bridge_not_running", "reaper.bridge.state": down.state },
|
|
826
1001
|
{ eventName: "reaper.bridge.command.not_sent" }
|
|
827
1002
|
);
|
|
1003
|
+
noteLoggedFailure(false);
|
|
828
1004
|
}
|
|
829
1005
|
finish("bridge_not_running");
|
|
830
1006
|
return { id: randomUUID2(), success: false, error: message, timestamp: Date.now() };
|
|
@@ -908,6 +1084,7 @@ async function sendCommand(type, params = {}, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
|
908
1084
|
},
|
|
909
1085
|
{ eventName: "reaper.bridge.command.failed" }
|
|
910
1086
|
);
|
|
1087
|
+
noteLoggedFailure(systemError);
|
|
911
1088
|
}
|
|
912
1089
|
const tMetrics = now();
|
|
913
1090
|
finish(errorType);
|
|
@@ -941,6 +1118,7 @@ async function sendCommand(type, params = {}, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
|
941
1118
|
{ "rpc.method": type, "reaper.bridge.command.id": id, "error.type": "timeout", "reaper.bridge.timeout_ms": timeoutMs },
|
|
942
1119
|
{ eventName: "reaper.bridge.command.timeout" }
|
|
943
1120
|
);
|
|
1121
|
+
noteLoggedFailure(true);
|
|
944
1122
|
finish("timeout");
|
|
945
1123
|
return {
|
|
946
1124
|
id,
|
|
@@ -956,6 +1134,7 @@ async function sendCommand(type, params = {}, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
|
956
1134
|
"error.type": errorType,
|
|
957
1135
|
...exceptionAttributes(err)
|
|
958
1136
|
});
|
|
1137
|
+
noteLoggedFailure(true);
|
|
959
1138
|
finish(errorType);
|
|
960
1139
|
throw err;
|
|
961
1140
|
} finally {
|
|
@@ -1091,6 +1270,22 @@ function stopPollers() {
|
|
|
1091
1270
|
}
|
|
1092
1271
|
}
|
|
1093
1272
|
|
|
1273
|
+
// apps/reaper-mcp-server/src/notices.ts
|
|
1274
|
+
var NOTICE_HEADING = "Note from reaper-mcp for the user (pass this on; it is not part of the result):";
|
|
1275
|
+
var pending = [];
|
|
1276
|
+
function addNotice(notice) {
|
|
1277
|
+
pending.push(notice);
|
|
1278
|
+
}
|
|
1279
|
+
function withNotices(result) {
|
|
1280
|
+
if (pending.length === 0) return result;
|
|
1281
|
+
const res = result;
|
|
1282
|
+
if (!res || !Array.isArray(res.content)) return result;
|
|
1283
|
+
const notices = pending.splice(0);
|
|
1284
|
+
const text8 = [NOTICE_HEADING, ...notices.map((n) => `- ${n.text}`)].join("\n");
|
|
1285
|
+
for (const n of notices) n.onDelivered?.();
|
|
1286
|
+
return { ...res, content: [...res.content, { type: "text", text: text8 }] };
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1094
1289
|
// apps/reaper-mcp-server/src/tools/project.ts
|
|
1095
1290
|
import { z as z3 } from "zod/v4";
|
|
1096
1291
|
|
|
@@ -4485,24 +4680,6 @@ function createMcpJson(targetPath, serverScript) {
|
|
|
4485
4680
|
writeFileSync3(targetPath, config + "\n", "utf-8");
|
|
4486
4681
|
return true;
|
|
4487
4682
|
}
|
|
4488
|
-
function hasUserMcpServer(claudeJsonPath) {
|
|
4489
|
-
try {
|
|
4490
|
-
const config = JSON.parse(readFileSync3(claudeJsonPath, "utf-8"));
|
|
4491
|
-
return Boolean(config?.mcpServers?.reaper);
|
|
4492
|
-
} catch {
|
|
4493
|
-
return false;
|
|
4494
|
-
}
|
|
4495
|
-
}
|
|
4496
|
-
function userMcpServerIsStale(claudeJsonPath) {
|
|
4497
|
-
try {
|
|
4498
|
-
const server = JSON.parse(readFileSync3(claudeJsonPath, "utf-8"))?.mcpServers?.reaper;
|
|
4499
|
-
if (!server) return false;
|
|
4500
|
-
const paths = [server.command, ...Array.isArray(server.args) ? server.args : []].filter((p) => typeof p === "string" && isAbsolute(p));
|
|
4501
|
-
return paths.some((p) => !existsSync(p));
|
|
4502
|
-
} catch {
|
|
4503
|
-
return false;
|
|
4504
|
-
}
|
|
4505
|
-
}
|
|
4506
4683
|
var REAPER_ASSETS = [
|
|
4507
4684
|
"mcp_bridge.lua",
|
|
4508
4685
|
"mcp_analyzer.jsfx",
|
|
@@ -5317,6 +5494,27 @@ var VENV_PYTHON = join6(SIDECAR_VENV_PATH2, VENV_BIN2, VENV_PYTHON_NAME2);
|
|
|
5317
5494
|
var _rawTimeout = Number(process.env["REAPER_MCP_SIDECAR_TIMEOUT_MS"]);
|
|
5318
5495
|
var ANALYZE_TIMEOUT_MS = Number.isFinite(_rawTimeout) && _rawTimeout > 0 ? _rawTimeout : 6e4;
|
|
5319
5496
|
var QUEUE_WAIT_MS = 5 * 6e4;
|
|
5497
|
+
var SidecarRpcError = class extends Error {
|
|
5498
|
+
// No `name` override: a tool that lets this escape reports `error.type` from the name, which stays `Error`.
|
|
5499
|
+
constructor(message, code) {
|
|
5500
|
+
super(message);
|
|
5501
|
+
this.code = code;
|
|
5502
|
+
}
|
|
5503
|
+
};
|
|
5504
|
+
var INVALID_PARAMS = -32602;
|
|
5505
|
+
var REJECTED_INPUT = /^(Audio file not found|Audio file unreadable|Audio too short|Sample rates differ)\b/;
|
|
5506
|
+
var NOT_INSTALLED = /^Audio understanding sidecar not installed|\b(audiobox-aesthetics not installed|Stem separation is not installed|FluidSynth native library is not installed)\b/;
|
|
5507
|
+
function classifySidecarError(err) {
|
|
5508
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
5509
|
+
if (message.startsWith("Sidecar timeout")) return "timeout";
|
|
5510
|
+
if (message.startsWith("Sidecar busy")) return "busy";
|
|
5511
|
+
if (NOT_INSTALLED.test(message)) return "not_installed";
|
|
5512
|
+
if (err instanceof SidecarRpcError && err.code === INVALID_PARAMS || REJECTED_INPUT.test(message)) return "sidecar_rejected";
|
|
5513
|
+
return "sidecar_error";
|
|
5514
|
+
}
|
|
5515
|
+
function isSidecarRegression(type) {
|
|
5516
|
+
return type === "timeout" || type === "sidecar_error";
|
|
5517
|
+
}
|
|
5320
5518
|
var SidecarClientImpl = class {
|
|
5321
5519
|
process = null;
|
|
5322
5520
|
pending = /* @__PURE__ */ new Map();
|
|
@@ -5404,14 +5602,16 @@ var SidecarClientImpl = class {
|
|
|
5404
5602
|
return result;
|
|
5405
5603
|
} catch (err) {
|
|
5406
5604
|
const message = err instanceof Error ? err.message : String(err);
|
|
5407
|
-
const errorType =
|
|
5605
|
+
const errorType = classifySidecarError(err);
|
|
5606
|
+
const regression = isSidecarRegression(errorType);
|
|
5408
5607
|
metricAttrs["error.type"] = errorType;
|
|
5409
5608
|
span.setAttribute("error.type", errorType);
|
|
5410
|
-
span.setStatus({ code: SpanStatusCode2.ERROR, message: redactHome(message) });
|
|
5411
|
-
emitLog(
|
|
5609
|
+
if (regression) span.setStatus({ code: SpanStatusCode2.ERROR, message: redactHome(message) });
|
|
5610
|
+
emitLog(regression ? "error" : "warn", `Sidecar ${method} failed: ${message}`, {
|
|
5412
5611
|
"rpc.method": method,
|
|
5413
5612
|
"error.type": errorType
|
|
5414
|
-
});
|
|
5613
|
+
}, { eventName: "reaper.sidecar.request.failed" });
|
|
5614
|
+
noteLoggedFailure(regression);
|
|
5415
5615
|
throw err;
|
|
5416
5616
|
} finally {
|
|
5417
5617
|
span.end();
|
|
@@ -5569,18 +5769,18 @@ var SidecarClientImpl = class {
|
|
|
5569
5769
|
}
|
|
5570
5770
|
return;
|
|
5571
5771
|
}
|
|
5572
|
-
const
|
|
5573
|
-
if (!
|
|
5772
|
+
const pending2 = this.pending.get(response.id);
|
|
5773
|
+
if (!pending2) {
|
|
5574
5774
|
emitLog("warn", `Sidecar response for unknown id ${response.id}`);
|
|
5575
5775
|
return;
|
|
5576
5776
|
}
|
|
5577
5777
|
this.pending.delete(response.id);
|
|
5578
5778
|
if (response.error) {
|
|
5579
|
-
|
|
5779
|
+
pending2.reject(new SidecarRpcError(response.error.message, response.error.code));
|
|
5580
5780
|
} else if (response.result) {
|
|
5581
|
-
|
|
5781
|
+
pending2.resolve(response.result);
|
|
5582
5782
|
} else {
|
|
5583
|
-
|
|
5783
|
+
pending2.reject(new Error("Sidecar response missing both result and error fields"));
|
|
5584
5784
|
}
|
|
5585
5785
|
}
|
|
5586
5786
|
handleProcessDeath() {
|
|
@@ -9446,6 +9646,11 @@ function registerPluginBuildTools(server) {
|
|
|
9446
9646
|
// apps/reaper-mcp-server/src/server.ts
|
|
9447
9647
|
var MAX_STATUS_MESSAGE = 256;
|
|
9448
9648
|
var TOOL_ERROR_MESSAGE = "reaper.tool.error.message";
|
|
9649
|
+
function toolErrorCause(text8) {
|
|
9650
|
+
if (/sidecar not installed|needs the Python sidecar/i.test(text8)) return "sidecar_not_installed";
|
|
9651
|
+
const type = classifyBridgeError(text8.replace(/^Error:\s*/, ""));
|
|
9652
|
+
return type === "bridge_not_running" || type === "bridge_outdated" ? type : void 0;
|
|
9653
|
+
}
|
|
9449
9654
|
function instrumentToolHandlers(server) {
|
|
9450
9655
|
const originalTool = server.tool.bind(server);
|
|
9451
9656
|
server.tool = (...args) => {
|
|
@@ -9473,17 +9678,26 @@ function instrumentToolHandlers(server) {
|
|
|
9473
9678
|
},
|
|
9474
9679
|
async (span) => {
|
|
9475
9680
|
try {
|
|
9476
|
-
const collected = await collectPageLinks(() => originalCb(...cbArgs));
|
|
9477
|
-
const result = withPageLink(collected.result, collected.links);
|
|
9681
|
+
const { result: collected, outcome } = await trackCallOutcome(() => collectPageLinks(() => originalCb(...cbArgs)));
|
|
9682
|
+
const result = withNotices(withPageLink(collected.result, collected.links));
|
|
9478
9683
|
const res = result;
|
|
9479
9684
|
if (res?.isError) {
|
|
9480
9685
|
const errorText = res.content?.[0]?.text ?? "Tool error";
|
|
9481
9686
|
const message = redactHome(errorText).slice(0, MAX_STATUS_MESSAGE);
|
|
9687
|
+
const regression = outcome.regression || isSystemError(classifyBridgeError(errorText.replace(/^Error:\s*/, "")));
|
|
9482
9688
|
metricAttrs["error.type"] = "tool_error";
|
|
9483
9689
|
span.setAttribute("error.type", "tool_error");
|
|
9484
9690
|
span.setAttribute(TOOL_ERROR_MESSAGE, message);
|
|
9485
|
-
|
|
9486
|
-
|
|
9691
|
+
const cause = toolErrorCause(errorText);
|
|
9692
|
+
if (cause) span.setAttribute("reaper.tool.error.cause", cause);
|
|
9693
|
+
if (regression) span.setStatus({ code: SpanStatusCode3.ERROR, message });
|
|
9694
|
+
if (!outcome.logged) {
|
|
9695
|
+
emitLog(
|
|
9696
|
+
regression ? "error" : "warn",
|
|
9697
|
+
`Tool ${toolName} failed: ${message}`,
|
|
9698
|
+
{ "gen_ai.tool.name": toolName, "error.type": "tool_error" },
|
|
9699
|
+
{ eventName: "reaper.tool.failed" }
|
|
9700
|
+
);
|
|
9487
9701
|
}
|
|
9488
9702
|
}
|
|
9489
9703
|
return result;
|
|
@@ -10131,11 +10345,11 @@ Try it: reaper-mcp extension link ${basename4(r.dir)}`);
|
|
|
10131
10345
|
}
|
|
10132
10346
|
|
|
10133
10347
|
// apps/reaper-mcp-server/src/main.ts
|
|
10134
|
-
import { existsSync as
|
|
10135
|
-
import { join as
|
|
10348
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync12, readFileSync as readFileSync12, realpathSync, rmSync as rmSync3, writeFileSync as writeFileSync11 } from "node:fs";
|
|
10349
|
+
import { join as join19, dirname as dirname11, resolve as resolve3 } from "node:path";
|
|
10136
10350
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
10137
|
-
import { homedir as
|
|
10138
|
-
import { exec as execCb
|
|
10351
|
+
import { homedir as homedir11, platform as platform6 } from "node:os";
|
|
10352
|
+
import { exec as execCb } from "node:child_process";
|
|
10139
10353
|
import { promisify as promisifyUtil } from "node:util";
|
|
10140
10354
|
|
|
10141
10355
|
// apps/reaper-mcp-server/src/claude-assets.ts
|
|
@@ -10169,12 +10383,13 @@ function readManifest2(path) {
|
|
|
10169
10383
|
return { version: 1, files: {} };
|
|
10170
10384
|
}
|
|
10171
10385
|
function installClaudeAssets(packageClaudeDir, claudeDir, opts = {}) {
|
|
10386
|
+
const wants = (part) => !opts.include || opts.include.includes(part);
|
|
10172
10387
|
const result = { installed: [], updated: [], unchanged: 0, skipped: [] };
|
|
10173
10388
|
const manifestPath = join13(claudeDir, CLAUDE_MANIFEST);
|
|
10174
10389
|
const manifest = readManifest2(manifestPath);
|
|
10175
10390
|
const plan = [];
|
|
10176
10391
|
const skillsSrc = join13(packageClaudeDir, "skills");
|
|
10177
|
-
if (existsSync8(skillsSrc)) {
|
|
10392
|
+
if (wants("skills") && existsSync8(skillsSrc)) {
|
|
10178
10393
|
for (const f of listFiles(skillsSrc)) {
|
|
10179
10394
|
const rel = relative(skillsSrc, f);
|
|
10180
10395
|
if (existsSync8(join13(skillsSrc, rel.split(/[\\/]/)[0], ".repo-only"))) continue;
|
|
@@ -10182,14 +10397,14 @@ function installClaudeAssets(packageClaudeDir, claudeDir, opts = {}) {
|
|
|
10182
10397
|
}
|
|
10183
10398
|
}
|
|
10184
10399
|
const agentsSrc = join13(packageClaudeDir, "agents");
|
|
10185
|
-
if (existsSync8(agentsSrc)) {
|
|
10400
|
+
if (wants("agents") && existsSync8(agentsSrc)) {
|
|
10186
10401
|
for (const f of listFiles(agentsSrc)) {
|
|
10187
10402
|
const dest = join13(claudeDir, "agents", relative(agentsSrc, f));
|
|
10188
10403
|
plan.push([f, dest, dest]);
|
|
10189
10404
|
}
|
|
10190
10405
|
}
|
|
10191
10406
|
const knowledgeSrc = join13(packageClaudeDir, "knowledge");
|
|
10192
|
-
if (existsSync8(knowledgeSrc)) {
|
|
10407
|
+
if (wants("knowledge") && existsSync8(knowledgeSrc)) {
|
|
10193
10408
|
for (const f of listFiles(knowledgeSrc)) {
|
|
10194
10409
|
plan.push([f, join13(claudeDir, "knowledge", relative(knowledgeSrc, f)), join13(claudeDir, "knowledge")]);
|
|
10195
10410
|
}
|
|
@@ -10236,72 +10451,206 @@ function installClaudeAssets(packageClaudeDir, claudeDir, opts = {}) {
|
|
|
10236
10451
|
return result;
|
|
10237
10452
|
}
|
|
10238
10453
|
|
|
10454
|
+
// apps/reaper-mcp-server/src/harnesses.ts
|
|
10455
|
+
import { execFileSync } from "node:child_process";
|
|
10456
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync8, readFileSync as readFileSync7, writeFileSync as writeFileSync7 } from "node:fs";
|
|
10457
|
+
import { delimiter, dirname as dirname9, isAbsolute as isAbsolute3, join as join14 } from "node:path";
|
|
10458
|
+
import { homedir as homedir9, platform as platform4 } from "node:os";
|
|
10459
|
+
var HARNESSES = [
|
|
10460
|
+
{ id: "claude", name: "Claude Code", binary: "claude", installHint: "https://claude.com/claude-code", skillsHome: "claude" },
|
|
10461
|
+
{ id: "codex", name: "Codex CLI", binary: "codex", installHint: "npm install -g @openai/codex (or: brew install codex)", skillsHome: "agents" },
|
|
10462
|
+
{ id: "gemini", name: "Gemini CLI", binary: "gemini", installHint: "npm install -g @google/gemini-cli", skillsHome: "agents" },
|
|
10463
|
+
{ id: "cursor", name: "Cursor", binary: null, installHint: "https://cursor.com", skillsHome: "agents" }
|
|
10464
|
+
];
|
|
10465
|
+
var SERVER_NAME = "reaper";
|
|
10466
|
+
function onPath(name, pathVar = process.env.PATH ?? "", win = platform4() === "win32") {
|
|
10467
|
+
const exts = win ? ["", ".exe", ".cmd", ".bat"] : [""];
|
|
10468
|
+
return pathVar.split(delimiter).filter(Boolean).some((dir) => exts.some((ext) => existsSync9(join14(dir, name + ext))));
|
|
10469
|
+
}
|
|
10470
|
+
function realEnv() {
|
|
10471
|
+
return { home: homedir9(), codexHome: process.env.CODEX_HOME || void 0, hasBinary: (name) => onPath(name) };
|
|
10472
|
+
}
|
|
10473
|
+
var configPath = (id, env) => ({
|
|
10474
|
+
claude: join14(env.home, ".claude.json"),
|
|
10475
|
+
codex: join14(env.codexHome ?? join14(env.home, ".codex"), "config.toml"),
|
|
10476
|
+
gemini: join14(env.home, ".gemini", "settings.json"),
|
|
10477
|
+
cursor: join14(env.home, ".cursor", "mcp.json")
|
|
10478
|
+
})[id];
|
|
10479
|
+
function detectHarnesses(env = realEnv()) {
|
|
10480
|
+
return HARNESSES.filter((h) => h.binary ? env.hasBinary(h.binary) : existsSync9(join14(env.home, ".cursor")));
|
|
10481
|
+
}
|
|
10482
|
+
function registeredServer(id, env = realEnv()) {
|
|
10483
|
+
let text8;
|
|
10484
|
+
try {
|
|
10485
|
+
text8 = readFileSync7(configPath(id, env), "utf-8");
|
|
10486
|
+
} catch {
|
|
10487
|
+
return null;
|
|
10488
|
+
}
|
|
10489
|
+
if (id === "codex") return codexServer(text8);
|
|
10490
|
+
try {
|
|
10491
|
+
const server = JSON.parse(text8)?.mcpServers?.[SERVER_NAME];
|
|
10492
|
+
if (!server || typeof server.command !== "string") return null;
|
|
10493
|
+
return { command: server.command, args: Array.isArray(server.args) ? server.args.filter((a) => typeof a === "string") : [] };
|
|
10494
|
+
} catch {
|
|
10495
|
+
return null;
|
|
10496
|
+
}
|
|
10497
|
+
}
|
|
10498
|
+
function codexServer(toml) {
|
|
10499
|
+
const header = new RegExp(`^\\[mcp_servers\\.(?:${SERVER_NAME}|"${SERVER_NAME}")\\]\\s*$`, "m").exec(toml);
|
|
10500
|
+
if (!header) return null;
|
|
10501
|
+
const rest = toml.slice(header.index + header[0].length);
|
|
10502
|
+
const next = /^\[/m.exec(rest);
|
|
10503
|
+
const section = next ? rest.slice(0, next.index) : rest;
|
|
10504
|
+
const command2 = /^command\s*=\s*("(?:[^"\\]|\\.)*"|'[^']*')/m.exec(section)?.[1];
|
|
10505
|
+
if (!command2) return null;
|
|
10506
|
+
const args = /^args\s*=\s*\[([^\]]*)\]/m.exec(section)?.[1] ?? "";
|
|
10507
|
+
const strings = (s) => [...s.matchAll(/"((?:[^"\\]|\\.)*)"|'([^']*)'/g)].map((m) => m[1] !== void 0 ? JSON.parse(`"${m[1]}"`) : m[2]);
|
|
10508
|
+
return { command: strings(command2)[0], args: strings(args) };
|
|
10509
|
+
}
|
|
10510
|
+
function isStale(server) {
|
|
10511
|
+
return [server.command, ...server.args].filter(isAbsolute3).some((p) => !existsSync9(p));
|
|
10512
|
+
}
|
|
10513
|
+
function addCommand(id, node, mainJs) {
|
|
10514
|
+
switch (id) {
|
|
10515
|
+
case "claude":
|
|
10516
|
+
return { bin: "claude", args: ["mcp", "add", "--scope", "user", SERVER_NAME, "--", node, mainJs, "serve"] };
|
|
10517
|
+
case "codex":
|
|
10518
|
+
return { bin: "codex", args: ["mcp", "add", SERVER_NAME, "--", node, mainJs, "serve"] };
|
|
10519
|
+
case "gemini":
|
|
10520
|
+
return { bin: "gemini", args: ["mcp", "add", "--scope", "user", SERVER_NAME, node, mainJs, "serve"] };
|
|
10521
|
+
case "cursor":
|
|
10522
|
+
return null;
|
|
10523
|
+
}
|
|
10524
|
+
}
|
|
10525
|
+
function removeCommand(id) {
|
|
10526
|
+
switch (id) {
|
|
10527
|
+
case "claude":
|
|
10528
|
+
return { bin: "claude", args: ["mcp", "remove", "--scope", "user", SERVER_NAME] };
|
|
10529
|
+
case "codex":
|
|
10530
|
+
return { bin: "codex", args: ["mcp", "remove", SERVER_NAME] };
|
|
10531
|
+
case "gemini":
|
|
10532
|
+
return { bin: "gemini", args: ["mcp", "remove", "--scope", "user", SERVER_NAME] };
|
|
10533
|
+
case "cursor":
|
|
10534
|
+
return null;
|
|
10535
|
+
}
|
|
10536
|
+
}
|
|
10537
|
+
function manualCommand(id, node, mainJs, env = realEnv()) {
|
|
10538
|
+
const add2 = addCommand(id, node, mainJs);
|
|
10539
|
+
if (add2) return [add2.bin, ...add2.args].join(" ");
|
|
10540
|
+
return `add "${SERVER_NAME}": { "command": "${node}", "args": ["${mainJs}", "serve"] } under "mcpServers" in ${configPath(id, env)}`;
|
|
10541
|
+
}
|
|
10542
|
+
function quoteForCmd(arg) {
|
|
10543
|
+
return /[\s"]/.test(arg) ? `"${arg.replace(/"/g, '\\"')}"` : arg;
|
|
10544
|
+
}
|
|
10545
|
+
var realRunner = (bin, args) => {
|
|
10546
|
+
if (platform4() === "win32") execFileSync(quoteForCmd(bin), args.map(quoteForCmd), { stdio: "pipe", shell: true });
|
|
10547
|
+
else execFileSync(bin, args, { stdio: "pipe" });
|
|
10548
|
+
};
|
|
10549
|
+
function writeJsonServer(path, node, mainJs) {
|
|
10550
|
+
let config = {};
|
|
10551
|
+
if (existsSync9(path)) config = JSON.parse(readFileSync7(path, "utf-8"));
|
|
10552
|
+
const servers = config.mcpServers && typeof config.mcpServers === "object" ? config.mcpServers : {};
|
|
10553
|
+
servers[SERVER_NAME] = { command: node, args: [mainJs, "serve"] };
|
|
10554
|
+
config.mcpServers = servers;
|
|
10555
|
+
mkdirSync8(dirname9(path), { recursive: true });
|
|
10556
|
+
writeFileSync7(path, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
10557
|
+
}
|
|
10558
|
+
function connectHarness(id, node, mainJs, env = realEnv(), run5 = realRunner) {
|
|
10559
|
+
const existing = registeredServer(id, env);
|
|
10560
|
+
if (existing && !isStale(existing)) return { id, status: "already" };
|
|
10561
|
+
const manual = manualCommand(id, node, mainJs, env);
|
|
10562
|
+
try {
|
|
10563
|
+
const add2 = addCommand(id, node, mainJs);
|
|
10564
|
+
if (!add2) {
|
|
10565
|
+
writeJsonServer(configPath(id, env), node, mainJs);
|
|
10566
|
+
} else {
|
|
10567
|
+
const remove = removeCommand(id);
|
|
10568
|
+
if (existing && remove) run5(remove.bin, remove.args);
|
|
10569
|
+
run5(add2.bin, add2.args);
|
|
10570
|
+
}
|
|
10571
|
+
} catch (err) {
|
|
10572
|
+
const missing = err.code === "ENOENT";
|
|
10573
|
+
const first = String(err.message).split("\n")[0];
|
|
10574
|
+
return { id, status: "failed", detail: missing ? "its command was not found" : first, manual };
|
|
10575
|
+
}
|
|
10576
|
+
return { id, status: existing ? "replaced" : "connected" };
|
|
10577
|
+
}
|
|
10578
|
+
function parseHarnessFlag(argv) {
|
|
10579
|
+
if (argv.includes("--all")) return HARNESSES.map((h) => h.id);
|
|
10580
|
+
const i = argv.findIndex((a) => a === "--harness" || a.startsWith("--harness="));
|
|
10581
|
+
if (i < 0) return null;
|
|
10582
|
+
const value = argv[i].includes("=") ? argv[i].split("=")[1] : argv[i + 1];
|
|
10583
|
+
const ids = (value ?? "").split(",").map((s) => s.trim().toLowerCase()).filter(Boolean);
|
|
10584
|
+
const known = HARNESSES.map((h) => h.id);
|
|
10585
|
+
const bad = ids.filter((s) => !known.includes(s));
|
|
10586
|
+
if (!ids.length || bad.length) {
|
|
10587
|
+
throw new Error(`Unknown harness${bad.length > 1 ? "es" : ""}: ${bad.join(", ") || "(none given)"}. Use one or more of: ${known.join(", ")}, or --all.`);
|
|
10588
|
+
}
|
|
10589
|
+
return [...new Set(ids)];
|
|
10590
|
+
}
|
|
10591
|
+
function skillsHomes(ids) {
|
|
10592
|
+
const chosen = HARNESSES.filter((h) => ids.includes(h.id));
|
|
10593
|
+
return { claude: chosen.some((h) => h.skillsHome === "claude"), agents: chosen.some((h) => h.skillsHome === "agents") };
|
|
10594
|
+
}
|
|
10595
|
+
|
|
10239
10596
|
// apps/reaper-mcp-server/src/jsfx/examples.ts
|
|
10240
10597
|
import { createHash as createHash3 } from "node:crypto";
|
|
10241
|
-
import { existsSync as
|
|
10242
|
-
import { join as
|
|
10598
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync9, readFileSync as readFileSync8, readdirSync as readdirSync3, writeFileSync as writeFileSync8 } from "node:fs";
|
|
10599
|
+
import { join as join15 } from "node:path";
|
|
10243
10600
|
var MANIFEST = ".installed.json";
|
|
10244
10601
|
var sha2 = (text8) => createHash3("sha256").update(text8).digest("hex");
|
|
10245
10602
|
function installExamplePlugins(examplesDir, outDir, toolkit, presetsDir2) {
|
|
10246
10603
|
const result = { installed: [], kept: [], presets: {}, presetErrors: [] };
|
|
10247
|
-
if (!
|
|
10248
|
-
|
|
10249
|
-
const manifestPath =
|
|
10604
|
+
if (!existsSync10(examplesDir)) return result;
|
|
10605
|
+
mkdirSync9(outDir, { recursive: true });
|
|
10606
|
+
const manifestPath = join15(outDir, MANIFEST);
|
|
10250
10607
|
let manifest = {};
|
|
10251
10608
|
try {
|
|
10252
|
-
manifest = JSON.parse(
|
|
10609
|
+
manifest = JSON.parse(readFileSync8(manifestPath, "utf8"));
|
|
10253
10610
|
} catch {
|
|
10254
10611
|
}
|
|
10255
10612
|
for (const file of readdirSync3(examplesDir).filter((f) => f.endsWith(".jsfx")).sort()) {
|
|
10256
|
-
const dest =
|
|
10257
|
-
const next = inlineToolkit(
|
|
10258
|
-
const current =
|
|
10613
|
+
const dest = join15(outDir, file);
|
|
10614
|
+
const next = inlineToolkit(readFileSync8(join15(examplesDir, file), "utf8"), { toolkit, version: 1, request: "a plugin that ships with reaper-mcp", slug: file.replace(/\.jsfx$/, ""), example: true });
|
|
10615
|
+
const current = existsSync10(dest) ? readFileSync8(dest, "utf8") : void 0;
|
|
10259
10616
|
if (current !== void 0 && current !== next && sha2(current) !== manifest[file]) {
|
|
10260
10617
|
result.kept.push(file);
|
|
10261
10618
|
continue;
|
|
10262
10619
|
}
|
|
10263
|
-
if (current !== next)
|
|
10620
|
+
if (current !== next) writeFileSync8(dest, next);
|
|
10264
10621
|
manifest[file] = sha2(next);
|
|
10265
10622
|
result.installed.push(file);
|
|
10266
10623
|
}
|
|
10267
10624
|
if (presetsDir2) {
|
|
10268
10625
|
const folder = outDir.split(/[/\\]/).slice(-2).join("/");
|
|
10269
10626
|
for (const file of readdirSync3(examplesDir).filter((f) => f.endsWith(".jsfx")).sort()) {
|
|
10270
|
-
const presetsPath =
|
|
10271
|
-
if (!
|
|
10272
|
-
const input = JSON.parse(
|
|
10273
|
-
const { values, errors } = resolvePresets(input, parseSliders(
|
|
10627
|
+
const presetsPath = join15(examplesDir, file.replace(/\.jsfx$/, ".presets.json"));
|
|
10628
|
+
if (!existsSync10(presetsPath)) continue;
|
|
10629
|
+
const input = JSON.parse(readFileSync8(presetsPath, "utf8"));
|
|
10630
|
+
const { values, errors } = resolvePresets(input, parseSliders(readFileSync8(join15(examplesDir, file), "utf8")).sliders);
|
|
10274
10631
|
if (errors.length) {
|
|
10275
10632
|
result.presetErrors.push(`${file}: ${errors.join(" ")}`);
|
|
10276
10633
|
continue;
|
|
10277
10634
|
}
|
|
10278
10635
|
const encoded = input.map((p, i) => encodePreset(p.name.trim(), values[i]));
|
|
10279
|
-
result.presets[file] = writePresetFile(presetsDir2, `${folder}/${file}`, encoded,
|
|
10636
|
+
result.presets[file] = writePresetFile(presetsDir2, `${folder}/${file}`, encoded, join15(outDir, ".presets", `${file}.json`)).written;
|
|
10280
10637
|
}
|
|
10281
10638
|
}
|
|
10282
|
-
|
|
10639
|
+
writeFileSync8(manifestPath, JSON.stringify(manifest, null, 2));
|
|
10283
10640
|
return result;
|
|
10284
10641
|
}
|
|
10285
10642
|
|
|
10286
10643
|
// apps/reaper-mcp-server/src/doctor-report.ts
|
|
10287
|
-
var ICON = { ok: "\u2713", fail: "\u2717", warn: "!", info: "\xB7" };
|
|
10288
|
-
var CODE = { ok: "32", fail: "31", warn: "33", info: "2" };
|
|
10289
|
-
function useColor(stream = process.stdout, env = process.env) {
|
|
10290
|
-
if (env["NO_COLOR"] !== void 0 && env["NO_COLOR"] !== "") return false;
|
|
10291
|
-
if (env["FORCE_COLOR"] && env["FORCE_COLOR"] !== "0") return true;
|
|
10292
|
-
return Boolean(stream.isTTY);
|
|
10293
|
-
}
|
|
10294
10644
|
function renderDoctor(sections3, opts = {}) {
|
|
10295
|
-
const
|
|
10296
|
-
const bold
|
|
10297
|
-
const dim = (s) => paint("2", s);
|
|
10645
|
+
const ui2 = createUi({ level: opts.color ? 1 : 0, tty: false });
|
|
10646
|
+
const { bold, dim } = ui2;
|
|
10298
10647
|
const width = Math.max(...sections3.flatMap((s) => s.checks.map((c) => c.label.length)));
|
|
10299
|
-
const out2 = ["", ` ${bold("REAPER MCP")} ${dim("doctor")}${opts.version ? dim(` v${opts.version}`) : ""}`];
|
|
10648
|
+
const out2 = opts.header === false ? [] : ["", ` ${bold("REAPER MCP")} ${dim("doctor")}${opts.version ? dim(` v${opts.version}`) : ""}`];
|
|
10300
10649
|
for (const section of sections3) {
|
|
10301
|
-
const state = section.state ? ` ${
|
|
10650
|
+
const state = section.state ? ` ${ui2.status(section.state.status, section.state.text)}` : "";
|
|
10302
10651
|
out2.push("", ` ${bold(section.title)}${section.note ? dim(` ${section.note}`) : ""}${state}`);
|
|
10303
10652
|
for (const c of section.checks) {
|
|
10304
|
-
out2.push(` ${
|
|
10653
|
+
out2.push(` ${ui2.mark(c.status)} ${c.label.padEnd(width)} ${c.status === "info" ? dim(c.detail) : c.detail}`);
|
|
10305
10654
|
if (c.fix && c.status !== "ok") out2.push(` ${" ".repeat(width)}${dim("\u2192")} ${c.fix}`);
|
|
10306
10655
|
}
|
|
10307
10656
|
}
|
|
@@ -10309,108 +10658,377 @@ function renderDoctor(sections3, opts = {}) {
|
|
|
10309
10658
|
out2.push("");
|
|
10310
10659
|
if (problems.length) {
|
|
10311
10660
|
const fixes = [...new Set(problems.map((c) => c.fix).filter((f) => Boolean(f)))];
|
|
10312
|
-
out2.push(` ${
|
|
10661
|
+
out2.push(` ${ui2.fail(`${problems.length} problem${problems.length === 1 ? "" : "s"}`)}${fixes.length ? dim(` \xB7 fix with: ${fixes.join(", then ")}`) : ""}`);
|
|
10313
10662
|
} else {
|
|
10314
|
-
out2.push(` ${
|
|
10663
|
+
out2.push(` ${ui2.ok("All good.")}`);
|
|
10315
10664
|
}
|
|
10316
10665
|
out2.push("");
|
|
10317
10666
|
return out2.join("\n");
|
|
10318
10667
|
}
|
|
10319
10668
|
|
|
10669
|
+
// apps/reaper-mcp-server/src/bridge-repair.ts
|
|
10670
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync10, readFileSync as readFileSync9, rmSync as rmSync2, writeFileSync as writeFileSync9 } from "node:fs";
|
|
10671
|
+
import { join as join16 } from "node:path";
|
|
10672
|
+
|
|
10673
|
+
// apps/reaper-mcp-server/src/version.ts
|
|
10674
|
+
function compareVersions(a, b) {
|
|
10675
|
+
const parts = (v) => v.replace(/^v/, "").split("-")[0].split(".").map((n) => parseInt(n, 10) || 0);
|
|
10676
|
+
const [pa, pb] = [parts(a), parts(b)];
|
|
10677
|
+
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
10678
|
+
const d = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
10679
|
+
if (d) return Math.sign(d);
|
|
10680
|
+
}
|
|
10681
|
+
return 0;
|
|
10682
|
+
}
|
|
10683
|
+
|
|
10684
|
+
// apps/reaper-mcp-server/src/bridge-repair.ts
|
|
10685
|
+
var BRIDGE_VERSION_FILE = "mcp_bridge_version.txt";
|
|
10686
|
+
function readBridgeVersion(scriptsDir) {
|
|
10687
|
+
try {
|
|
10688
|
+
const v = readFileSync9(join16(scriptsDir, BRIDGE_VERSION_FILE), "utf-8").trim();
|
|
10689
|
+
return /^\d+\.\d+\.\d+/.test(v) ? v : void 0;
|
|
10690
|
+
} catch {
|
|
10691
|
+
return void 0;
|
|
10692
|
+
}
|
|
10693
|
+
}
|
|
10694
|
+
function writeBridgeVersion(scriptsDir, version) {
|
|
10695
|
+
writeFileSync9(join16(scriptsDir, BRIDGE_VERSION_FILE), `${version}
|
|
10696
|
+
`, "utf-8");
|
|
10697
|
+
}
|
|
10698
|
+
function sameContent(a, b) {
|
|
10699
|
+
try {
|
|
10700
|
+
return readFileSync9(a).equals(readFileSync9(b));
|
|
10701
|
+
} catch {
|
|
10702
|
+
return false;
|
|
10703
|
+
}
|
|
10704
|
+
}
|
|
10705
|
+
function installReaperFiles(paths) {
|
|
10706
|
+
let luaChanged = false;
|
|
10707
|
+
for (const asset of REAPER_ASSETS) {
|
|
10708
|
+
const src = join16(paths.assetsDir, asset);
|
|
10709
|
+
if (!existsSync11(src)) continue;
|
|
10710
|
+
const lua = asset.endsWith(".lua");
|
|
10711
|
+
const destDir = lua ? paths.scriptsDir : join16(paths.effectsDir, "reaper-mcp");
|
|
10712
|
+
mkdirSync10(destDir, { recursive: true });
|
|
10713
|
+
const dest = join16(destDir, asset);
|
|
10714
|
+
if (lua && !sameContent(src, dest)) luaChanged = true;
|
|
10715
|
+
installFile(src, dest);
|
|
10716
|
+
}
|
|
10717
|
+
for (const asset of RETIRED_ASSETS) rmSync2(join16(paths.scriptsDir, asset), { force: true });
|
|
10718
|
+
if (existsSync11(join16(paths.wwwSrcDir, BRIDGE_UI_FILE))) copyDirSync(paths.wwwSrcDir, paths.wwwDir);
|
|
10719
|
+
return luaChanged;
|
|
10720
|
+
}
|
|
10721
|
+
function repairBridgeInstall(paths, version, opts) {
|
|
10722
|
+
const none = { bridgeChanged: false, autostartAdded: false };
|
|
10723
|
+
if (opts.inClone) return { skipped: "clone", ...none };
|
|
10724
|
+
const reapack = existsSync11(join16(paths.scriptsDir, "reaper-mcp", "MCP Bridge", "mcp_bridge.lua"));
|
|
10725
|
+
const ours = existsSync11(join16(paths.scriptsDir, "mcp_bridge.lua"));
|
|
10726
|
+
if (!reapack && !ours) return { skipped: "not_installed", ...none };
|
|
10727
|
+
const from = readBridgeVersion(paths.scriptsDir);
|
|
10728
|
+
if (from && compareVersions(from, version) >= 0) return { skipped: "current", from, ...none };
|
|
10729
|
+
const bridgeChanged = reapack ? false : installReaperFiles(paths);
|
|
10730
|
+
const startupPath = join16(paths.scriptsDir, "__startup.lua");
|
|
10731
|
+
const startup = existsSync11(startupPath) ? readFileSync9(startupPath, "utf-8") : "";
|
|
10732
|
+
const { text: text8, changed } = ensureBridgeAutostart(startup);
|
|
10733
|
+
if (changed) writeFileSync9(startupPath, text8, "utf-8");
|
|
10734
|
+
writeBridgeVersion(paths.scriptsDir, version);
|
|
10735
|
+
return { from, bridgeChanged, autostartAdded: !startup.includes(AUTOSTART_MARKER) };
|
|
10736
|
+
}
|
|
10737
|
+
function repairNotices(repair, version, bridgeRunning) {
|
|
10738
|
+
const notices = [];
|
|
10739
|
+
if (repair.bridgeChanged) {
|
|
10740
|
+
notices.push(bridgeRunning ? `reaper-mcp updated the REAPER bridge to ${version}, but REAPER is still running the old one: restart REAPER, or click Restart bridge in the bridge window, so it loads the new bridge.` : `reaper-mcp updated the REAPER bridge to ${version}; REAPER loads it the next time the bridge starts.`);
|
|
10741
|
+
}
|
|
10742
|
+
if (repair.autostartAdded) {
|
|
10743
|
+
notices.push("The REAPER bridge now starts with REAPER (reaper-mcp added it to REAPER's Scripts/__startup.lua; turn it off in the bridge window under Settings \u2192 Start with REAPER). " + (bridgeRunning ? "It takes effect the next time REAPER starts." : "Start or restart REAPER and the bridge starts with it."));
|
|
10744
|
+
}
|
|
10745
|
+
return notices;
|
|
10746
|
+
}
|
|
10747
|
+
|
|
10748
|
+
// apps/reaper-mcp-server/src/update-check.ts
|
|
10749
|
+
import { mkdirSync as mkdirSync11, readFileSync as readFileSync10, writeFileSync as writeFileSync10 } from "node:fs";
|
|
10750
|
+
import { dirname as dirname10, join as join17 } from "node:path";
|
|
10751
|
+
import { homedir as homedir10 } from "node:os";
|
|
10752
|
+
var NPM_PACKAGE = "@mthines/reaper-mcp";
|
|
10753
|
+
var LATEST_URL = "https://registry.npmjs.org/@mthines%2Freaper-mcp/latest";
|
|
10754
|
+
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
10755
|
+
function defaultUpdateStatePath() {
|
|
10756
|
+
return join17(homedir10(), ".reaper-mcp", "update-check.json");
|
|
10757
|
+
}
|
|
10758
|
+
function updateCheckDisabled(env = process.env) {
|
|
10759
|
+
const setting = (env["REAPER_MCP_UPDATE_CHECK"] ?? "").trim().toLowerCase();
|
|
10760
|
+
return ["0", "false", "off", "no"].includes(setting) || Boolean(env["NO_UPDATE_NOTIFIER"]) || Boolean(env["CI"]);
|
|
10761
|
+
}
|
|
10762
|
+
async function fetchLatestVersion(fetchImpl = fetch, timeoutMs = 3e3) {
|
|
10763
|
+
try {
|
|
10764
|
+
const res = await fetchImpl(LATEST_URL, { signal: AbortSignal.timeout(timeoutMs), headers: { accept: "application/json" } });
|
|
10765
|
+
if (!res.ok) return void 0;
|
|
10766
|
+
const body = await res.json();
|
|
10767
|
+
return typeof body.version === "string" && /^\d+\.\d+\.\d+/.test(body.version) ? body.version : void 0;
|
|
10768
|
+
} catch {
|
|
10769
|
+
return void 0;
|
|
10770
|
+
}
|
|
10771
|
+
}
|
|
10772
|
+
function updateNotice(current, latest) {
|
|
10773
|
+
return `reaper-mcp ${latest} is out (this is ${current}). To update, run in a terminal: npm install -g ${NPM_PACKAGE}@latest, then restart Claude Code (or run /mcp). The next start updates the REAPER side too.`;
|
|
10774
|
+
}
|
|
10775
|
+
function readState(path) {
|
|
10776
|
+
try {
|
|
10777
|
+
const s = JSON.parse(readFileSync10(path, "utf-8"));
|
|
10778
|
+
return s && typeof s === "object" ? s : {};
|
|
10779
|
+
} catch {
|
|
10780
|
+
return {};
|
|
10781
|
+
}
|
|
10782
|
+
}
|
|
10783
|
+
function writeState(path, state) {
|
|
10784
|
+
try {
|
|
10785
|
+
mkdirSync11(dirname10(path), { recursive: true });
|
|
10786
|
+
writeFileSync10(path, JSON.stringify(state) + "\n", "utf-8");
|
|
10787
|
+
} catch {
|
|
10788
|
+
}
|
|
10789
|
+
}
|
|
10790
|
+
async function checkForUpdate(opts) {
|
|
10791
|
+
const statePath = opts.statePath ?? defaultUpdateStatePath();
|
|
10792
|
+
const now = opts.now ?? Date.now();
|
|
10793
|
+
const state = readState(statePath);
|
|
10794
|
+
if (state.notifiedAt !== void 0 && now - state.notifiedAt < DAY_MS) return void 0;
|
|
10795
|
+
let latest = state.latest;
|
|
10796
|
+
if (state.checkedAt === void 0 || now - state.checkedAt >= DAY_MS) {
|
|
10797
|
+
latest = await (opts.fetchLatest ?? fetchLatestVersion)() ?? latest;
|
|
10798
|
+
writeState(statePath, { ...state, checkedAt: now, ...latest ? { latest } : {} });
|
|
10799
|
+
}
|
|
10800
|
+
if (!latest || compareVersions(latest, opts.current) <= 0) return void 0;
|
|
10801
|
+
return {
|
|
10802
|
+
latest,
|
|
10803
|
+
text: updateNotice(opts.current, latest),
|
|
10804
|
+
markNotified: () => writeState(statePath, { ...readState(statePath), notifiedAt: Date.now() })
|
|
10805
|
+
};
|
|
10806
|
+
}
|
|
10807
|
+
|
|
10808
|
+
// apps/reaper-mcp-server/src/sidecar-offer.ts
|
|
10809
|
+
import { createInterface as createInterface4 } from "node:readline";
|
|
10810
|
+
var SIDECAR_OFFER_TEXT = "Audio analysis needs the Python sidecar, which this setup does not install: analyze_audio_file, analyze_track_offline, detect_key and detect_chords on audio, detect_transients, separate_stems and the mix checks fail without it. It needs Python 3.10+ and downloads PyTorch (CPU) and audio libraries (~0.5-1 GB; up to ~2.5 GB on Linux), then lets you pick the optional models.";
|
|
10811
|
+
async function offerSidecarSetup(io, installed, install) {
|
|
10812
|
+
if (installed) return "present";
|
|
10813
|
+
io.output.write(`
|
|
10814
|
+
${SIDECAR_OFFER_TEXT}
|
|
10815
|
+
`);
|
|
10816
|
+
if (!io.interactive) {
|
|
10817
|
+
io.output.write(`Add it any time: ${SETUP_SIDECAR_COMMAND}
|
|
10818
|
+
`);
|
|
10819
|
+
return "told";
|
|
10820
|
+
}
|
|
10821
|
+
io.output.write("Set it up now? [y/N] ");
|
|
10822
|
+
let answer = "";
|
|
10823
|
+
if (!streamEnded(io.input)) {
|
|
10824
|
+
const rl = createInterface4({ input: io.input, output: io.output, terminal: false });
|
|
10825
|
+
answer = await new Promise((resolve4) => {
|
|
10826
|
+
rl.once("line", resolve4);
|
|
10827
|
+
rl.once("close", () => resolve4(""));
|
|
10828
|
+
}).then((a) => a.trim().toLowerCase());
|
|
10829
|
+
rl.close();
|
|
10830
|
+
}
|
|
10831
|
+
if (answer !== "y" && answer !== "yes") {
|
|
10832
|
+
io.output.write(`Skipped. Add it any time: ${SETUP_SIDECAR_COMMAND}
|
|
10833
|
+
`);
|
|
10834
|
+
return "declined";
|
|
10835
|
+
}
|
|
10836
|
+
await install();
|
|
10837
|
+
return "installed";
|
|
10838
|
+
}
|
|
10839
|
+
|
|
10840
|
+
// apps/reaper-mcp-server/src/setup-health.ts
|
|
10841
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
10842
|
+
import { readFileSync as readFileSync11 } from "node:fs";
|
|
10843
|
+
import { join as join18 } from "node:path";
|
|
10844
|
+
import { platform as platform5 } from "node:os";
|
|
10845
|
+
function heartbeatAgeBucket(ms) {
|
|
10846
|
+
const min = 6e4;
|
|
10847
|
+
if (ms < min) return "<1m";
|
|
10848
|
+
if (ms < 60 * min) return "1m-1h";
|
|
10849
|
+
if (ms < 24 * 60 * min) return "1h-1d";
|
|
10850
|
+
if (ms < 7 * 24 * 60 * min) return "1d-7d";
|
|
10851
|
+
return ">7d";
|
|
10852
|
+
}
|
|
10853
|
+
function isReaperProcessRunning(timeoutMs = 2e3) {
|
|
10854
|
+
const win = platform5() === "win32";
|
|
10855
|
+
const [cmd, args] = win ? ["tasklist", ["/FI", "IMAGENAME eq reaper.exe", "/NH"]] : ["pgrep", ["-xi", "reaper"]];
|
|
10856
|
+
return new Promise((resolve4) => {
|
|
10857
|
+
execFile2(cmd, args, { timeout: timeoutMs, windowsHide: true }, (err, stdout) => {
|
|
10858
|
+
if (win) return resolve4(err ? void 0 : /reaper\.exe/i.test(String(stdout)));
|
|
10859
|
+
if (!err) return resolve4(true);
|
|
10860
|
+
resolve4(Number(err.code) === 1 ? false : void 0);
|
|
10861
|
+
});
|
|
10862
|
+
});
|
|
10863
|
+
}
|
|
10864
|
+
function autostartInstalled(scriptsDir) {
|
|
10865
|
+
try {
|
|
10866
|
+
return readFileSync11(join18(scriptsDir, "__startup.lua"), "utf-8").includes(AUTOSTART_MARKER);
|
|
10867
|
+
} catch {
|
|
10868
|
+
return false;
|
|
10869
|
+
}
|
|
10870
|
+
}
|
|
10871
|
+
function setupHealthAttributes(h) {
|
|
10872
|
+
const attrs = { "reaper.sidecar.installed": h.sidecarInstalled };
|
|
10873
|
+
const { state, heartbeatAgeMs: heartbeatAgeMs2 } = h.status;
|
|
10874
|
+
if (state === "connected" || state === "stale" || state === "never_started") attrs["reaper.bridge.autostart"] = h.autostart;
|
|
10875
|
+
if (state !== "connected" && h.reaperRunning !== void 0) attrs["reaper.app.running"] = h.reaperRunning;
|
|
10876
|
+
if (state === "stale" && heartbeatAgeMs2 !== void 0) attrs["reaper.bridge.heartbeat_age"] = heartbeatAgeBucket(heartbeatAgeMs2);
|
|
10877
|
+
return attrs;
|
|
10878
|
+
}
|
|
10879
|
+
|
|
10320
10880
|
// apps/reaper-mcp-server/src/main.ts
|
|
10321
10881
|
var execAsync = promisifyUtil(execCb);
|
|
10322
|
-
var
|
|
10882
|
+
var ui = createUi();
|
|
10883
|
+
var __dirname2 = dirname11(fileURLToPath6(import.meta.url));
|
|
10323
10884
|
async function setup() {
|
|
10324
|
-
|
|
10885
|
+
const verbose = process.argv.includes("--verbose");
|
|
10886
|
+
const installedLine = (what, files) => {
|
|
10887
|
+
if (verbose) for (const f of files) console.log(ui.item("ok", `Installed: ${f}`));
|
|
10888
|
+
else if (files.length) console.log(ui.item("ok", `${files.length} ${what} installed`));
|
|
10889
|
+
};
|
|
10890
|
+
console.log(ui.banner("Setup", readServiceVersion()));
|
|
10325
10891
|
const bridgeDir = await ensureBridgeDir();
|
|
10326
|
-
console.log(`Bridge directory: ${bridgeDir}
|
|
10892
|
+
console.log(`Bridge directory: ${ui.dim(bridgeDir)}
|
|
10327
10893
|
`);
|
|
10328
10894
|
const scriptsDir = getReaperScriptsPath();
|
|
10329
|
-
|
|
10895
|
+
mkdirSync12(scriptsDir, { recursive: true });
|
|
10330
10896
|
const reaperDir = resolveAssetDir(__dirname2, "reaper");
|
|
10331
|
-
const filesPlan = setupFilesPlan(
|
|
10897
|
+
const filesPlan = setupFilesPlan(existsSync12(join19(scriptsDir, "reaper-mcp", "MCP Bridge", "mcp_bridge.lua")), findCloneRoot(__dirname2) !== null);
|
|
10332
10898
|
if (filesPlan === "leave") {
|
|
10333
|
-
console.log("The bridge is installed by ReaPack: leaving its scripts, JSFX and status page to ReaPack
|
|
10334
|
-
console.log("Setup only turns on starting with REAPER and the web interface
|
|
10899
|
+
console.log(`${ui.mark("info")} The bridge is installed by ReaPack: leaving its scripts, JSFX and status page to ReaPack.`);
|
|
10900
|
+
console.log(`${ui.dim("Setup only turns on starting with REAPER and the web interface.")}
|
|
10901
|
+
`);
|
|
10335
10902
|
installBridgeAutostart(scriptsDir);
|
|
10903
|
+
writeBridgeVersion(scriptsDir, readServiceVersion());
|
|
10336
10904
|
const port = await enableWebInterface();
|
|
10337
|
-
console.log(
|
|
10338
|
-
|
|
10339
|
-
if (port
|
|
10905
|
+
console.log(`
|
|
10906
|
+
${ui.mark("ok")} ${ui.bold("Setup complete!")}`);
|
|
10907
|
+
if (await chainAfterSetup(port, join19(scriptsDir, "reaper-mcp", "MCP Bridge", "mcp_bridge.lua"))) return;
|
|
10908
|
+
console.log(`
|
|
10909
|
+
Restart REAPER (or run the bridge once from the Action List) and add reaper-mcp to your harness: ${ui.cmd("reaper-mcp doctor")}`);
|
|
10910
|
+
if (port) console.log(`The bridge opens its status window on start: ${ui.link(`http://localhost:${port}/${BRIDGE_UI_FILE}`)}`);
|
|
10911
|
+
await offerSidecar();
|
|
10340
10912
|
return;
|
|
10341
10913
|
}
|
|
10342
10914
|
if (filesPlan === "install-with-warning") {
|
|
10343
|
-
console.log("WARNING: ReaPack has installed the bridge too, and REAPER prefers its copy (Scripts/reaper-mcp/MCP Bridge/ and
|
|
10915
|
+
console.log(`${ui.warn("WARNING:")} ReaPack has installed the bridge too, and REAPER prefers its copy (Scripts/reaper-mcp/MCP Bridge/ and`);
|
|
10344
10916
|
console.log("Effects/reaper-mcp/Meters/) over the files this checkout installs. Your local changes will not run until you");
|
|
10345
10917
|
console.log("uninstall the reaper-mcp packages in ReaPack (Manage repositories > reaper-mcp > Uninstall packages),");
|
|
10346
10918
|
console.log("then run setup again: this run also overwrote the status page ReaPack installed, which uninstalling removes.\n");
|
|
10347
10919
|
}
|
|
10348
|
-
console.log("Installing Lua scripts...");
|
|
10920
|
+
console.log(`${ui.bold("Installing Lua scripts...")}`);
|
|
10921
|
+
const luaInstalled = [];
|
|
10349
10922
|
for (const asset of REAPER_ASSETS) {
|
|
10350
10923
|
if (!asset.endsWith(".lua")) continue;
|
|
10351
|
-
const src =
|
|
10352
|
-
const dest =
|
|
10353
|
-
if (installFile(src, dest))
|
|
10354
|
-
|
|
10355
|
-
} else {
|
|
10356
|
-
console.log(` Not found: ${src}`);
|
|
10357
|
-
}
|
|
10924
|
+
const src = join19(reaperDir, asset);
|
|
10925
|
+
const dest = join19(scriptsDir, asset);
|
|
10926
|
+
if (installFile(src, dest)) luaInstalled.push(asset);
|
|
10927
|
+
else console.log(ui.item("fail", `Not found: ${src}`));
|
|
10358
10928
|
}
|
|
10929
|
+
installedLine("scripts", luaInstalled);
|
|
10359
10930
|
for (const asset of RETIRED_ASSETS) {
|
|
10360
|
-
const dest =
|
|
10361
|
-
if (
|
|
10362
|
-
|
|
10363
|
-
console.log(`
|
|
10931
|
+
const dest = join19(scriptsDir, asset);
|
|
10932
|
+
if (existsSync12(dest)) {
|
|
10933
|
+
rmSync3(dest);
|
|
10934
|
+
console.log(ui.item("info", `Removed: ${asset} (retired)`));
|
|
10364
10935
|
}
|
|
10365
10936
|
}
|
|
10366
10937
|
const cloneRoot = findCloneRoot(__dirname2);
|
|
10367
10938
|
if (cloneRoot) {
|
|
10368
10939
|
const dev = isDevClone(await cloneState(cloneRoot));
|
|
10369
|
-
|
|
10370
|
-
console.log(`
|
|
10940
|
+
writeFileSync11(join19(scriptsDir, "mcp_update.conf"), updateConfigText(cloneRoot, process.execPath, dev));
|
|
10941
|
+
console.log(ui.item("ok", `Installed: mcp_update.conf (${dev ? "developer clone: Rebuild & reload" : "one-click updates"} from the status page)`));
|
|
10371
10942
|
}
|
|
10372
|
-
const effectsDir =
|
|
10373
|
-
|
|
10374
|
-
console.log("
|
|
10943
|
+
const effectsDir = join19(getReaperEffectsPath(), "reaper-mcp");
|
|
10944
|
+
mkdirSync12(effectsDir, { recursive: true });
|
|
10945
|
+
console.log(ui.section("Installing JSFX analyzers..."));
|
|
10946
|
+
const jsfxInstalled = [];
|
|
10375
10947
|
for (const asset of REAPER_ASSETS) {
|
|
10376
10948
|
if (asset.endsWith(".lua")) continue;
|
|
10377
|
-
const src =
|
|
10378
|
-
const dest =
|
|
10379
|
-
if (installFile(src, dest)) {
|
|
10380
|
-
|
|
10381
|
-
|
|
10382
|
-
|
|
10383
|
-
|
|
10384
|
-
|
|
10385
|
-
|
|
10386
|
-
|
|
10387
|
-
const
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
for (const e of examples.presetErrors) console.log(`
|
|
10392
|
-
if (!examples.installed.length && !examples.kept.length) console.log(`
|
|
10949
|
+
const src = join19(reaperDir, asset);
|
|
10950
|
+
const dest = join19(effectsDir, asset);
|
|
10951
|
+
if (installFile(src, dest)) jsfxInstalled.push(`reaper-mcp/${asset}`);
|
|
10952
|
+
else console.log(ui.item("fail", `Not found: ${src}`));
|
|
10953
|
+
}
|
|
10954
|
+
installedLine("JSFX files", jsfxInstalled);
|
|
10955
|
+
console.log(ui.section("Installing example plugins..."));
|
|
10956
|
+
const examplesDir = join19(resolveAssetDir(__dirname2, "claude"), "skills", "make-plugin", "examples");
|
|
10957
|
+
const examples = installExamplePlugins(examplesDir, join19(generatedDir(), "examples"), loadToolkit(), presetsDir());
|
|
10958
|
+
installedLine("example plugins", examples.installed.map((f) => `reaper-mcp-generated/examples/${f}`));
|
|
10959
|
+
for (const f of examples.kept) console.log(ui.item("info", `Kept your edited copy: reaper-mcp-generated/examples/${f}`));
|
|
10960
|
+
if (verbose) {
|
|
10961
|
+
for (const [f, names] of Object.entries(examples.presets)) if (names.length) console.log(ui.item("info", `Presets for ${f}: ${names.join(", ")}`));
|
|
10962
|
+
}
|
|
10963
|
+
for (const e of examples.presetErrors) console.log(ui.item("warn", `Skipped presets (invalid): ${e}`));
|
|
10964
|
+
if (!examples.installed.length && !examples.kept.length) console.log(ui.item("fail", `Not found: ${examplesDir}`));
|
|
10393
10965
|
const wwwSrc = resolveAssetDir(__dirname2, "bridge-ui");
|
|
10394
|
-
console.log("
|
|
10395
|
-
if (
|
|
10966
|
+
console.log(ui.section("Installing bridge status UI..."));
|
|
10967
|
+
if (existsSync12(join19(wwwSrc, BRIDGE_UI_FILE))) {
|
|
10396
10968
|
const count = copyDirSync(wwwSrc, getReaperWwwPath());
|
|
10397
|
-
console.log(`
|
|
10969
|
+
console.log(ui.item("ok", verbose ? `Installed: reaper_www_root/${BRIDGE_UI_FILE} (+${count - 1} PWA files)` : "Status page installed"));
|
|
10398
10970
|
} else {
|
|
10399
|
-
console.log(`
|
|
10971
|
+
console.log(ui.item("fail", `Not found: ${join19(wwwSrc, BRIDGE_UI_FILE)} (build bridge-ui first)`));
|
|
10400
10972
|
}
|
|
10401
10973
|
installBridgeAutostart(scriptsDir);
|
|
10974
|
+
writeBridgeVersion(scriptsDir, readServiceVersion());
|
|
10402
10975
|
const webPort = await enableWebInterface();
|
|
10403
10976
|
await registerSnapshotActions();
|
|
10404
|
-
console.log(
|
|
10405
|
-
|
|
10406
|
-
|
|
10977
|
+
console.log(`
|
|
10978
|
+
${ui.mark("ok")} ${ui.bold("Setup complete!")}`);
|
|
10979
|
+
if (await chainAfterSetup(webPort, join19(scriptsDir, "mcp_bridge.lua"))) return;
|
|
10980
|
+
console.log("");
|
|
10981
|
+
console.log(ui.heading("Next steps:"));
|
|
10982
|
+
console.log(` ${ui.bold("1.")} Start REAPER: the bridge starts with it. If REAPER is already open, restart it,`);
|
|
10407
10983
|
console.log(" or run the bridge once by hand: Actions > Show action list > Load ReaScript,");
|
|
10408
|
-
console.log(` select ${
|
|
10409
|
-
console.log("
|
|
10984
|
+
console.log(` select ${ui.dim(join19(scriptsDir, "mcp_bridge.lua"))} and click Run.`);
|
|
10985
|
+
console.log(` ${ui.bold("2.")} Connect your AI harness: ${ui.cmd("reaper-mcp init")}, then check it with ${ui.cmd("reaper-mcp doctor")}`);
|
|
10410
10986
|
if (webPort) {
|
|
10411
10987
|
console.log(`
|
|
10412
|
-
The bridge opens its status window on start: http://localhost:${webPort}/${BRIDGE_UI_FILE}`);
|
|
10988
|
+
The bridge opens its status window on start: ${ui.link(`http://localhost:${webPort}/${BRIDGE_UI_FILE}`)}`);
|
|
10413
10989
|
}
|
|
10990
|
+
await offerSidecar();
|
|
10991
|
+
}
|
|
10992
|
+
async function offerSidecar() {
|
|
10993
|
+
const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY) && !process.env["CI"];
|
|
10994
|
+
await offerSidecarSetup({ input: process.stdin, output: process.stdout, interactive }, getSidecarClient().isAvailable(), () => setupSidecar([]));
|
|
10995
|
+
}
|
|
10996
|
+
async function askYesNo(question, defaultYes = true) {
|
|
10997
|
+
process.stdout.write(`
|
|
10998
|
+
${ui.bold(question)} ${ui.dim(defaultYes ? "[Y/n]" : "[y/N]")} `);
|
|
10999
|
+
let answer = "";
|
|
11000
|
+
if (!streamEnded(process.stdin)) {
|
|
11001
|
+
const rl = createInterface5({ input: process.stdin, output: process.stdout, terminal: false });
|
|
11002
|
+
answer = await new Promise((resolve4) => {
|
|
11003
|
+
rl.once("line", resolve4);
|
|
11004
|
+
rl.once("close", () => resolve4(""));
|
|
11005
|
+
}).then((a) => a.trim().toLowerCase());
|
|
11006
|
+
rl.close();
|
|
11007
|
+
}
|
|
11008
|
+
return answer === "" ? defaultYes : answer === "y" || answer === "yes";
|
|
11009
|
+
}
|
|
11010
|
+
async function chainAfterSetup(port, bridgeScript) {
|
|
11011
|
+
const yes = process.argv.includes("--yes") || process.argv.includes("-y");
|
|
11012
|
+
const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
11013
|
+
if (!yes && !interactive) return false;
|
|
11014
|
+
if (yes || await askYesNo("Connect your AI harness now?")) {
|
|
11015
|
+
await init(true);
|
|
11016
|
+
if (yes || await askYesNo("Check that everything is in place?")) {
|
|
11017
|
+
console.log("");
|
|
11018
|
+
await doctor();
|
|
11019
|
+
console.log(ui.dim("The bridge shows as not detected until REAPER has started it: that is the one step left."));
|
|
11020
|
+
}
|
|
11021
|
+
} else {
|
|
11022
|
+
console.log(`
|
|
11023
|
+
Whenever you are ready: ${ui.cmd("reaper-mcp init")}, then ${ui.cmd("reaper-mcp doctor")}`);
|
|
11024
|
+
}
|
|
11025
|
+
await offerSidecar();
|
|
11026
|
+
console.log(`
|
|
11027
|
+
${ui.heading("One step left:")} start REAPER (restart it if it is open): the bridge starts with it.`);
|
|
11028
|
+
console.log(` ${ui.dim("Rather not restart? Actions > Show action list > Load ReaScript, select")} ${ui.dim(bridgeScript)} ${ui.dim("and click Run.")}`);
|
|
11029
|
+
if (port) console.log(`
|
|
11030
|
+
The bridge opens its status window on start: ${ui.link(`http://localhost:${port}/${BRIDGE_UI_FILE}`)}`);
|
|
11031
|
+
return true;
|
|
10414
11032
|
}
|
|
10415
11033
|
async function cloneState(repo) {
|
|
10416
11034
|
const git = async (args) => (await execAsync(`git -C "${repo}" ${args}`)).stdout.trim();
|
|
@@ -10423,137 +11041,161 @@ async function cloneState(repo) {
|
|
|
10423
11041
|
}
|
|
10424
11042
|
}
|
|
10425
11043
|
async function isReaperRunning() {
|
|
10426
|
-
|
|
10427
|
-
try {
|
|
10428
|
-
const { stdout } = await execAsync(cmd);
|
|
10429
|
-
return platform4() === "win32" ? /reaper\.exe/i.test(stdout) : true;
|
|
10430
|
-
} catch {
|
|
10431
|
-
return false;
|
|
10432
|
-
}
|
|
11044
|
+
return await isReaperProcessRunning(1e4) ?? false;
|
|
10433
11045
|
}
|
|
10434
11046
|
async function enableWebInterface() {
|
|
10435
|
-
console.log("
|
|
10436
|
-
const iniPath =
|
|
10437
|
-
if (!
|
|
10438
|
-
console.log(`
|
|
11047
|
+
console.log(ui.section("Enabling REAPER web interface..."));
|
|
11048
|
+
const iniPath = join19(getReaperResourcePath(), "reaper.ini");
|
|
11049
|
+
if (!existsSync12(iniPath)) {
|
|
11050
|
+
console.log(ui.item("warn", `Skipped: ${iniPath} not found (start REAPER once, quit it, then re-run setup)`));
|
|
10439
11051
|
return null;
|
|
10440
11052
|
}
|
|
10441
11053
|
const requested = Number(process.env["REAPER_WEB_PORT"]) || DEFAULT_WEB_PORT;
|
|
10442
|
-
const result = ensureWebInterface(
|
|
11054
|
+
const result = ensureWebInterface(readFileSync12(iniPath, "utf-8"), requested);
|
|
10443
11055
|
if (!result.changed) {
|
|
10444
|
-
console.log(`
|
|
11056
|
+
console.log(ui.item("ok", `Already enabled on port ${result.port}`));
|
|
10445
11057
|
return result.port;
|
|
10446
11058
|
}
|
|
10447
11059
|
if (await isReaperRunning()) {
|
|
10448
11060
|
if (!process.stdout.isTTY) {
|
|
10449
|
-
console.log("
|
|
10450
|
-
console.log(
|
|
11061
|
+
console.log(ui.item("warn", "Skipped: REAPER is running and would overwrite reaper.ini on exit."));
|
|
11062
|
+
console.log(` Quit REAPER and run ${ui.cmd("reaper-mcp setup")} again.`);
|
|
10451
11063
|
return null;
|
|
10452
11064
|
}
|
|
10453
|
-
console.log("
|
|
10454
|
-
console.log("
|
|
11065
|
+
console.log(ui.item("warn", "REAPER is running and would overwrite reaper.ini on exit."));
|
|
11066
|
+
console.log(" Quit REAPER to finish (Ctrl+C to skip)...");
|
|
10455
11067
|
while (await isReaperRunning()) await new Promise((r) => setTimeout(r, 1e3));
|
|
10456
11068
|
}
|
|
10457
|
-
|
|
10458
|
-
console.log(`
|
|
11069
|
+
writeFileSync11(iniPath, ensureWebInterface(readFileSync12(iniPath, "utf-8"), requested).ini, "utf-8");
|
|
11070
|
+
console.log(ui.item("ok", `Enabled on port ${result.port} (override with REAPER_WEB_PORT)`));
|
|
10459
11071
|
return result.port;
|
|
10460
11072
|
}
|
|
10461
11073
|
function installBridgeAutostart(scriptsDir) {
|
|
10462
|
-
console.log("
|
|
10463
|
-
const path =
|
|
10464
|
-
const { text: text8, changed } = ensureBridgeAutostart(
|
|
10465
|
-
if (changed)
|
|
10466
|
-
console.log(changed ? "
|
|
10467
|
-
console.log("
|
|
11074
|
+
console.log(ui.section("Starting the bridge with REAPER..."));
|
|
11075
|
+
const path = join19(scriptsDir, "__startup.lua");
|
|
11076
|
+
const { text: text8, changed } = ensureBridgeAutostart(existsSync12(path) ? readFileSync12(path, "utf-8") : "");
|
|
11077
|
+
if (changed) writeFileSync11(path, text8, "utf-8");
|
|
11078
|
+
console.log(ui.item("ok", changed ? "Added to Scripts/__startup.lua (REAPER runs it at launch)" : "Already in Scripts/__startup.lua"));
|
|
11079
|
+
console.log(ui.dim(" Turn it off in the bridge window: Settings > Start with REAPER."));
|
|
10468
11080
|
}
|
|
10469
11081
|
async function registerSnapshotActions() {
|
|
10470
|
-
console.log("
|
|
10471
|
-
const kbPath =
|
|
10472
|
-
const kb =
|
|
11082
|
+
console.log(ui.section("Registering snapshot actions (quick save, next, previous)..."));
|
|
11083
|
+
const kbPath = join19(getReaperResourcePath(), "reaper-kb.ini");
|
|
11084
|
+
const kb = existsSync12(kbPath) ? readFileSync12(kbPath, "utf-8") : "";
|
|
10473
11085
|
const { added } = ensureSnapshotActions(kb);
|
|
10474
11086
|
if (!added.length) {
|
|
10475
|
-
console.log("
|
|
11087
|
+
console.log(ui.item("ok", "Already in the Action List"));
|
|
10476
11088
|
} else if (await isReaperRunning()) {
|
|
10477
|
-
console.log("
|
|
11089
|
+
console.log(ui.item("info", "REAPER is running: the bridge adds them when it next starts (re-run mcp_bridge.lua)."));
|
|
10478
11090
|
} else {
|
|
10479
|
-
|
|
10480
|
-
console.log(`
|
|
11091
|
+
writeFileSync11(kbPath, ensureSnapshotActions(kb).kb, "utf-8");
|
|
11092
|
+
console.log(ui.item("ok", `Added: ${added.join(", ")}`));
|
|
10481
11093
|
}
|
|
10482
|
-
console.log(
|
|
11094
|
+
console.log(`${ui.dim(" Bind keys in Actions > Show action list: search")} ${ui.cmd('"mcp_snapshot"')}${ui.dim(".")}`);
|
|
10483
11095
|
}
|
|
10484
|
-
|
|
10485
|
-
|
|
10486
|
-
|
|
10487
|
-
|
|
10488
|
-
|
|
10489
|
-
|
|
10490
|
-
|
|
10491
|
-
|
|
10492
|
-
|
|
10493
|
-
|
|
11096
|
+
function installHint(ui2, hint) {
|
|
11097
|
+
return /^https?:\/\/\S+$/.test(hint) ? ui2.link(hint) : hint;
|
|
11098
|
+
}
|
|
11099
|
+
async function init(chained = false) {
|
|
11100
|
+
let chosen;
|
|
11101
|
+
try {
|
|
11102
|
+
chosen = parseHarnessFlag(process.argv);
|
|
11103
|
+
} catch (err) {
|
|
11104
|
+
console.error(err.message);
|
|
11105
|
+
process.exit(1);
|
|
11106
|
+
}
|
|
11107
|
+
console.log(ui.banner("Connect your AI harness", readServiceVersion()));
|
|
11108
|
+
const env = realEnv();
|
|
11109
|
+
const found = detectHarnesses(env).map((h) => h.id);
|
|
11110
|
+
const ids = chosen ?? found;
|
|
11111
|
+
for (const h of HARNESSES) {
|
|
11112
|
+
console.log(found.includes(h.id) ? ` ${ui.mark("ok")} ${ui.dim("found")} ${ui.bold(h.name)}` : ` ${ui.mark("info")} ${ui.dim("not found")} ${h.name}: ${ui.dim(installHint(ui, h.installHint))}`);
|
|
11113
|
+
}
|
|
11114
|
+
console.log("");
|
|
11115
|
+
if (ids.length === 0) {
|
|
11116
|
+
console.log(`None of the supported harnesses is installed yet. Install one (see above), then run: ${ui.cmd("reaper-mcp init")}`);
|
|
11117
|
+
return;
|
|
11118
|
+
}
|
|
11119
|
+
const mainJs = realpathSync(process.argv[1]);
|
|
11120
|
+
const inClone = findCloneRoot(__dirname2) !== null;
|
|
11121
|
+
for (const id of ids) {
|
|
11122
|
+
const h = HARNESSES.find((x) => x.id === id);
|
|
11123
|
+
if (id === "claude") {
|
|
11124
|
+
const settingsPath = join19(homedir11(), ".claude", "settings.json");
|
|
11125
|
+
mkdirSync12(dirname11(settingsPath), { recursive: true });
|
|
11126
|
+
console.log(`${ui.mark("ok")} Claude settings (${MCP_TOOL_NAMES.length} REAPER tools allow-listed): ${ensureClaudeSettings(settingsPath)} \u2192 ${ui.dim(settingsPath.replace(homedir11(), "~"))}`);
|
|
11127
|
+
if (inClone) {
|
|
11128
|
+
const mcpJsonPath = join19(process.cwd(), ".mcp.json");
|
|
11129
|
+
console.log(createMcpJson(mcpJsonPath, resolve3(process.argv[1])) ? `${ui.mark("ok")} Created: ${ui.dim(mcpJsonPath)}` : `${ui.mark("ok")} .mcp.json already exists \u2014 leaving it untouched.`);
|
|
11130
|
+
continue;
|
|
11131
|
+
}
|
|
11132
|
+
}
|
|
11133
|
+
const r = connectHarness(id, process.execPath, mainJs, env);
|
|
11134
|
+
if (r.status === "failed") {
|
|
11135
|
+
console.log(`${ui.mark("fail")} Could not connect ${ui.bold(h.name)}: ${r.detail}${found.includes(id) ? "" : ` ${ui.dim(`(not installed: ${installHint(ui, h.installHint)})`)}`}`);
|
|
11136
|
+
console.log(` ${ui.dim("To connect it yourself:")} ${ui.cmd(r.manual ?? "")}`);
|
|
10494
11137
|
} else {
|
|
10495
|
-
|
|
11138
|
+
const what = { connected: "Connected", replaced: "Reconnected (the old entry pointed at files that no longer exist)", already: "Already connected" }[r.status];
|
|
11139
|
+
console.log(`${ui.mark("ok")} ${what}: ${ui.bold(h.name)}${id === "claude" && inClone ? "" : ui.dim(" (works from any folder)")}`);
|
|
10496
11140
|
}
|
|
10497
|
-
} else {
|
|
10498
|
-
registerUserMcpServer();
|
|
10499
11141
|
}
|
|
10500
11142
|
await askTelemetryOnce();
|
|
10501
|
-
if (
|
|
11143
|
+
if (inClone) {
|
|
10502
11144
|
console.log("\nIf you haven't yet, symlink the skills + knowledge and install the bridge:");
|
|
10503
|
-
console.log("
|
|
11145
|
+
console.log(` ${ui.cmd("scripts/sync-symlinks.sh")} ${ui.dim("# mix skills + knowledge \u2192 ~/.claude, skills + agents \u2192 ~/.agents")}`);
|
|
10504
11146
|
} else {
|
|
10505
11147
|
console.log("");
|
|
10506
|
-
installSkills();
|
|
10507
|
-
console.log("\nIf you haven't yet, install the bridge:");
|
|
10508
|
-
}
|
|
10509
|
-
console.log(" reaper-mcp setup # Lua bridge + JSFX \u2192 REAPER");
|
|
10510
|
-
console.log("then start (or restart) REAPER: the bridge starts with it.");
|
|
10511
|
-
if (!findCloneRoot(__dirname2)) console.log("\nWant it to remember plugins and your corrections? Connect LoreKit (free): https://lorekit.io. /learn-plugin will walk you through it.");
|
|
10512
|
-
console.log('\nTry: /mixer "Please gain stage my tracks" \xB7 /critique "Roast my mix"');
|
|
10513
|
-
}
|
|
10514
|
-
function registerUserMcpServer() {
|
|
10515
|
-
const claudeJson = join15(homedir9(), ".claude.json");
|
|
10516
|
-
const registered = hasUserMcpServer(claudeJson);
|
|
10517
|
-
if (registered && !userMcpServerIsStale(claudeJson)) {
|
|
10518
|
-
console.log('Claude Code already knows REAPER (user-scope server "reaper" is registered).');
|
|
10519
|
-
return;
|
|
11148
|
+
installSkills(false, ids);
|
|
11149
|
+
if (!chained) console.log("\nIf you haven't yet, install the bridge:");
|
|
10520
11150
|
}
|
|
10521
|
-
|
|
10522
|
-
|
|
10523
|
-
|
|
10524
|
-
execFileSync("claude", ["mcp", "remove", "--scope", "user", "reaper"], { stdio: "pipe" });
|
|
10525
|
-
console.log("The registered REAPER server pointed at files that no longer exist; replacing it.");
|
|
10526
|
-
}
|
|
10527
|
-
execFileSync("claude", ["mcp", "add", "--scope", "user", "reaper", "--", process.execPath, mainJs, "serve"], { stdio: "pipe" });
|
|
10528
|
-
console.log("Connected Claude Code to REAPER (works from any folder).");
|
|
10529
|
-
} catch (err) {
|
|
10530
|
-
const missing = err.code === "ENOENT";
|
|
10531
|
-
console.log(missing ? "Claude Code is not installed yet. Get it from https://claude.com/claude-code, then run: reaper-mcp init" : `Could not connect Claude Code to REAPER: ${String(err.message).split("\n")[0]}`);
|
|
10532
|
-
console.log(`To connect it yourself: claude mcp add --scope user reaper -- ${process.execPath} ${mainJs} serve`);
|
|
11151
|
+
if (!chained) {
|
|
11152
|
+
console.log(` ${ui.cmd("reaper-mcp setup")} ${ui.dim("# Lua bridge + JSFX \u2192 REAPER")}`);
|
|
11153
|
+
console.log("then start (or restart) REAPER: the bridge starts with it.");
|
|
10533
11154
|
}
|
|
11155
|
+
if (!inClone) console.log(`
|
|
11156
|
+
Want it to remember plugins and your corrections? Connect LoreKit (free): ${ui.link("https://lorekit.io")}. ${ui.cmd("/learn-plugin")} will walk you through it.`);
|
|
11157
|
+
console.log(`
|
|
11158
|
+
Try: ${ui.cmd('/mixer "Please gain stage my tracks"')} \xB7 ${ui.cmd('/critique "Roast my mix"')}`);
|
|
10534
11159
|
}
|
|
10535
|
-
function installSkills(dryRun = false) {
|
|
11160
|
+
function installSkills(dryRun = false, ids) {
|
|
10536
11161
|
if (findCloneRoot(__dirname2)) {
|
|
10537
|
-
console.log("Running from a clone: scripts/sync-symlinks.sh links the skills and knowledge into ~/.claude.");
|
|
11162
|
+
console.log("Running from a clone: scripts/sync-symlinks.sh links the skills and knowledge into ~/.claude and ~/.agents.");
|
|
10538
11163
|
return;
|
|
10539
11164
|
}
|
|
10540
|
-
const src =
|
|
10541
|
-
if (!
|
|
11165
|
+
const src = join19(resolveAssetDir(__dirname2, "claude"));
|
|
11166
|
+
if (!existsSync12(src)) {
|
|
10542
11167
|
console.log(`Skills not found: ${src} (this build has no claude/ folder)`);
|
|
10543
11168
|
process.exitCode = 1;
|
|
10544
11169
|
return;
|
|
10545
11170
|
}
|
|
10546
|
-
|
|
11171
|
+
let targets = ids;
|
|
11172
|
+
if (!targets) {
|
|
11173
|
+
try {
|
|
11174
|
+
targets = parseHarnessFlag(process.argv) ?? detectHarnesses().map((h) => h.id);
|
|
11175
|
+
} catch (err) {
|
|
11176
|
+
console.error(err.message);
|
|
11177
|
+
process.exitCode = 1;
|
|
11178
|
+
return;
|
|
11179
|
+
}
|
|
11180
|
+
}
|
|
11181
|
+
const homes = skillsHomes(targets.length ? targets : ["claude"]);
|
|
10547
11182
|
const verb = dryRun ? "Would install" : "Installed";
|
|
10548
|
-
|
|
10549
|
-
|
|
10550
|
-
|
|
10551
|
-
|
|
11183
|
+
const jobs = [];
|
|
11184
|
+
if (homes.claude) jobs.push({ label: "~/.claude", dir: join19(homedir11(), ".claude"), what: "the mix skills, agents and knowledge" });
|
|
11185
|
+
if (homes.agents) jobs.push({ label: "~/.agents", dir: join19(homedir11(), ".agents"), include: ["skills", "agents"], what: "the mix skills and agents" });
|
|
11186
|
+
if (homes.agents && !homes.claude) jobs.push({ label: "~/.claude", dir: join19(homedir11(), ".claude"), include: ["knowledge"], what: "the knowledge base the skills read" });
|
|
11187
|
+
for (const job of jobs) {
|
|
11188
|
+
const r = installClaudeAssets(src, job.dir, { dryRun, include: job.include });
|
|
11189
|
+
console.log(`${ui.mark("ok")} ${verb} ${job.what} in ${job.label}: ${r.installed.length} new, ${r.updated.length} updated, ${r.unchanged} already current.`);
|
|
11190
|
+
for (const s of r.skipped) {
|
|
11191
|
+
const why = { edited: "you changed it, left as is", "not-ours": "already exists and is yours, left as is", symlink: "linked elsewhere, left as is", "broken-symlink": "a link to a folder that no longer exists (a deleted clone?); remove it and run this again" }[s.reason];
|
|
11192
|
+
console.log(ui.dim(` Skipped ${s.path}: ${why}`));
|
|
11193
|
+
}
|
|
10552
11194
|
}
|
|
10553
|
-
if (!dryRun) console.log("Try /mixer, /critique or /learn-plugin in
|
|
11195
|
+
if (!dryRun) console.log("Try /mixer, /critique or /learn-plugin in your harness. (/learn-plugin saves what it learns to LoreKit, see the README.)");
|
|
10554
11196
|
}
|
|
10555
11197
|
function consoleConsentIO() {
|
|
10556
|
-
return { input: process.stdin, output: process.stdout, interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY) };
|
|
11198
|
+
return { input: process.stdin, output: process.stdout, interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY), ui };
|
|
10557
11199
|
}
|
|
10558
11200
|
var OPT_OUT_COUNTED = 'One anonymous "opted out" count was sent (no install id). Nothing is sent after this.';
|
|
10559
11201
|
async function askTelemetryOnce() {
|
|
@@ -10564,26 +11206,29 @@ async function askTelemetryOnce() {
|
|
|
10564
11206
|
}
|
|
10565
11207
|
function describeTelemetry() {
|
|
10566
11208
|
const { mode, reason } = resolveTelemetry();
|
|
10567
|
-
const label = { default: "On \u2014 pseudonymous usage data to the developer", custom: "Custom \u2014 your own OTEL_* destination", off: "Off" }[mode];
|
|
10568
|
-
return `${label} (${reason})`;
|
|
11209
|
+
const label = { default: ui.ok("On \u2014 pseudonymous usage data to the developer"), custom: ui.cmd("Custom \u2014 your own OTEL_* destination"), off: ui.dim("Off") }[mode];
|
|
11210
|
+
return `${label} ${ui.dim(`(${reason})`)}`;
|
|
10569
11211
|
}
|
|
10570
11212
|
async function telemetryCommand(sub = "status") {
|
|
11213
|
+
if (sub !== "on" && sub !== "off" && sub !== "setup" && sub !== "status") {
|
|
11214
|
+
console.log(`Usage: ${ui.cmd("reaper-mcp telemetry")} [status|on|off]`);
|
|
11215
|
+
process.exitCode = 1;
|
|
11216
|
+
return;
|
|
11217
|
+
}
|
|
11218
|
+
if (ui.fancy && sub !== "setup") console.log(ui.banner("Telemetry", readServiceVersion()));
|
|
11219
|
+
if (sub === "off" && resolveTelemetry().mode === "default" && !await confirmOptOutPrompt(consoleConsentIO())) return;
|
|
10571
11220
|
if (sub === "on" || sub === "off") {
|
|
10572
11221
|
const change = saveTelemetryChoice(sub === "on");
|
|
10573
11222
|
const counted = change ? await reportConsentChange(change) : false;
|
|
10574
|
-
if (sub === "on") console.log("Pseudonymous usage telemetry turned on \u2014 thank you
|
|
10575
|
-
else console.log(
|
|
10576
|
-
console.log("Restart Claude Code (or run /mcp) for the running server to pick it up.");
|
|
11223
|
+
if (sub === "on") console.log(`${ui.mark("ok")} Pseudonymous usage telemetry turned ${ui.ok("on")} \u2014 thank you!`);
|
|
11224
|
+
else console.log(`${ui.mark("ok")} Telemetry turned ${ui.bold("off")}. ${counted ? OPT_OUT_COUNTED : "Nothing will be sent."}`);
|
|
11225
|
+
console.log(`${ui.dim("Restart Claude Code (or run")} ${ui.cmd("/mcp")}${ui.dim(") for the running server to pick it up.")}`);
|
|
10577
11226
|
} else if (sub === "setup") {
|
|
10578
|
-
if (!await askTelemetryOnce()) console.log(
|
|
10579
|
-
return;
|
|
10580
|
-
} else if (sub !== "status") {
|
|
10581
|
-
console.log("Usage: reaper-mcp telemetry [status|on|off]");
|
|
10582
|
-
process.exitCode = 1;
|
|
11227
|
+
if (!await askTelemetryOnce()) console.log(`${ui.bold("Telemetry:")} ${describeTelemetry()}`);
|
|
10583
11228
|
return;
|
|
10584
11229
|
}
|
|
10585
|
-
console.log(
|
|
10586
|
-
console.log(`What is and isn't collected: ${TELEMETRY_DOC_URL}`);
|
|
11230
|
+
console.log(`${ui.bold("Telemetry:")} ${describeTelemetry()}`);
|
|
11231
|
+
console.log(`What is and isn't collected: ${ui.link(TELEMETRY_DOC_URL)}`);
|
|
10587
11232
|
}
|
|
10588
11233
|
async function doctor() {
|
|
10589
11234
|
const core2 = [];
|
|
@@ -10591,29 +11236,40 @@ async function doctor() {
|
|
|
10591
11236
|
core2.push(
|
|
10592
11237
|
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" }
|
|
10593
11238
|
);
|
|
10594
|
-
const readIfExists = (path) =>
|
|
11239
|
+
const readIfExists = (path) => existsSync12(path) ? readFileSync12(path, "utf-8") : null;
|
|
10595
11240
|
core2.push(autostartCheck(
|
|
10596
|
-
readIfExists(
|
|
10597
|
-
readIfExists(
|
|
11241
|
+
readIfExists(join19(getReaperScriptsPath(), "__startup.lua")),
|
|
11242
|
+
readIfExists(join19(getReaperResourcePath(), "reaper-extstate.ini")),
|
|
10598
11243
|
await isReaperRunning()
|
|
10599
11244
|
));
|
|
10600
|
-
const globalClaudeDir =
|
|
10601
|
-
const localSkills =
|
|
10602
|
-
const globalSkills =
|
|
11245
|
+
const globalClaudeDir = join19(homedir11(), ".claude");
|
|
11246
|
+
const localSkills = existsSync12(join19(process.cwd(), ".claude", "skills", "mixer", "SKILL.md"));
|
|
11247
|
+
const globalSkills = existsSync12(join19(globalClaudeDir, "skills", "mixer", "SKILL.md"));
|
|
11248
|
+
const sharedSkills = existsSync12(join19(homedir11(), ".agents", "skills", "mixer", "SKILL.md"));
|
|
10603
11249
|
core2.push(
|
|
10604
|
-
localSkills || globalSkills ? { label: "Mix skills", status: "ok", detail: localSkills ? ".claude/skills" : "~/.claude/skills" } : { label: "Mix skills", status: "fail", detail: "Not linked", fix: findCloneRoot(__dirname2) ? "scripts/sync-symlinks.sh (from your clone)" : "reaper-mcp install-skills" }
|
|
11250
|
+
localSkills || globalSkills || sharedSkills ? { label: "Mix skills", status: "ok", detail: localSkills ? ".claude/skills" : globalSkills ? "~/.claude/skills" : "~/.agents/skills" } : { label: "Mix skills", status: "fail", detail: "Not linked", fix: findCloneRoot(__dirname2) ? "scripts/sync-symlinks.sh (from your clone)" : "reaper-mcp install-skills" }
|
|
10605
11251
|
);
|
|
10606
|
-
const localKnowledge =
|
|
10607
|
-
const knowledgeLinked = localKnowledge ||
|
|
11252
|
+
const localKnowledge = existsSync12(join19(process.cwd(), ".claude", "knowledge"));
|
|
11253
|
+
const knowledgeLinked = localKnowledge || existsSync12(join19(globalClaudeDir, "knowledge"));
|
|
10608
11254
|
core2.push(
|
|
10609
11255
|
knowledgeLinked ? { label: "Knowledge base", status: "ok", detail: localKnowledge ? ".claude/knowledge" : "~/.claude/knowledge" } : { label: "Knowledge base", status: "fail", detail: "Not linked", fix: findCloneRoot(__dirname2) ? "scripts/sync-symlinks.sh (from your clone)" : "reaper-mcp install-skills" }
|
|
10610
11256
|
);
|
|
10611
|
-
const
|
|
10612
|
-
const
|
|
10613
|
-
const
|
|
10614
|
-
|
|
10615
|
-
|
|
10616
|
-
);
|
|
11257
|
+
const mcpJsonExists = existsSync12(join19(process.cwd(), ".mcp.json"));
|
|
11258
|
+
const harnessEnv = realEnv();
|
|
11259
|
+
const installed = detectHarnesses(harnessEnv);
|
|
11260
|
+
const connected = installed.filter((h) => registeredServer(h.id, harnessEnv));
|
|
11261
|
+
const staleOnes = connected.filter((h) => isStale(registeredServer(h.id, harnessEnv)));
|
|
11262
|
+
const fixMcp = findCloneRoot(__dirname2) ? "scripts/install.sh (from your clone)" : "reaper-mcp init";
|
|
11263
|
+
const mcpRegistered = staleOnes.length === 0 && (connected.length > 0 || mcpJsonExists);
|
|
11264
|
+
if (staleOnes.length) {
|
|
11265
|
+
core2.push({ label: "MCP config", status: "fail", detail: `${staleOnes.map((h) => h.name).join(", ")}: points at files that no longer exist`, fix: fixMcp });
|
|
11266
|
+
} else if (connected.length || mcpJsonExists) {
|
|
11267
|
+
const where = [...connected.map((h) => h.name), ...mcpJsonExists ? [".mcp.json in this folder"] : []].join(", ");
|
|
11268
|
+
const missing2 = installed.filter((h) => !connected.includes(h));
|
|
11269
|
+
core2.push({ label: "MCP config", status: "ok", detail: `Connected: ${where}${missing2.length ? ` \xB7 not yet: ${missing2.map((h) => h.name).join(", ")} (reaper-mcp init)` : ""}` });
|
|
11270
|
+
} else {
|
|
11271
|
+
core2.push({ label: "MCP config", status: "fail", detail: installed.length ? `Not registered in ${installed.map((h) => h.name).join(", ")}` : "No supported harness found (Claude Code, Codex CLI, Gemini CLI, Cursor)", fix: fixMcp });
|
|
11272
|
+
}
|
|
10617
11273
|
core2.push({ label: "SWS", status: "info", detail: "Checked live: the bridge page shows it, or ask Claude to run list_available_fx" });
|
|
10618
11274
|
const telemetry = resolveTelemetry().mode;
|
|
10619
11275
|
core2.push({
|
|
@@ -10621,11 +11277,11 @@ async function doctor() {
|
|
|
10621
11277
|
status: "info",
|
|
10622
11278
|
detail: { default: "On, pseudonymous \xB7 turn off: reaper-mcp telemetry off", custom: "Your own OTEL_* destination", off: "Off" }[telemetry]
|
|
10623
11279
|
});
|
|
10624
|
-
const sidecarVenvPath =
|
|
10625
|
-
const venvBin =
|
|
10626
|
-
const venvPythonName =
|
|
10627
|
-
const venvPython =
|
|
10628
|
-
const hfCachePath =
|
|
11280
|
+
const sidecarVenvPath = join19(homedir11(), ".reaper-mcp", "sidecar-venv");
|
|
11281
|
+
const venvBin = platform6() === "win32" ? "Scripts" : "bin";
|
|
11282
|
+
const venvPythonName = platform6() === "win32" ? "python.exe" : "python";
|
|
11283
|
+
const venvPython = join19(sidecarVenvPath, venvBin, venvPythonName);
|
|
11284
|
+
const hfCachePath = join19(homedir11(), ".cache", "huggingface", "hub");
|
|
10629
11285
|
let pythonOk = false;
|
|
10630
11286
|
let pythonDetail = "Not found";
|
|
10631
11287
|
try {
|
|
@@ -10642,9 +11298,9 @@ async function doctor() {
|
|
|
10642
11298
|
} catch {
|
|
10643
11299
|
pythonDetail = "Not found";
|
|
10644
11300
|
}
|
|
10645
|
-
const venvExists =
|
|
11301
|
+
const venvExists = existsSync12(sidecarVenvPath);
|
|
10646
11302
|
let depsOk = false;
|
|
10647
|
-
if (venvExists &&
|
|
11303
|
+
if (venvExists && existsSync12(venvPython)) {
|
|
10648
11304
|
try {
|
|
10649
11305
|
await execAsync(`"${venvPython}" -c "import audiobox_aesthetics.infer"`);
|
|
10650
11306
|
depsOk = true;
|
|
@@ -10658,14 +11314,14 @@ async function doctor() {
|
|
|
10658
11314
|
addOns.demucs = found.separation;
|
|
10659
11315
|
addOns.lv_chordia = found.chords;
|
|
10660
11316
|
}
|
|
10661
|
-
const weightsPath =
|
|
10662
|
-
const weightsExist =
|
|
11317
|
+
const weightsPath = join19(hfCachePath, "models--facebook--audiobox-aesthetics");
|
|
11318
|
+
const weightsExist = existsSync12(weightsPath);
|
|
10663
11319
|
const sidecarReady = venvExists && depsOk;
|
|
10664
11320
|
const sidecarOptedIn = venvExists;
|
|
10665
11321
|
const sidecarBroken = sidecarOptedIn && !sidecarReady;
|
|
10666
11322
|
const missing = sidecarOptedIn ? "fail" : "info";
|
|
10667
11323
|
const repair = "reaper-mcp setup-sidecar";
|
|
10668
|
-
const home = (p) => p.replace(
|
|
11324
|
+
const home = (p) => p.replace(homedir11(), "~");
|
|
10669
11325
|
const sidecar = {
|
|
10670
11326
|
title: "Python sidecar",
|
|
10671
11327
|
note: "optional \xB7 lets Claude listen to the audio",
|
|
@@ -10700,8 +11356,31 @@ async function doctor() {
|
|
|
10700
11356
|
const sections3 = [{ title: "Core", checks: core2 }, sidecar];
|
|
10701
11357
|
if (extensionChecks.length > 0) sections3.push({ title: "Extensions", checks: extensionChecks });
|
|
10702
11358
|
const extensionsBroken = extensionChecks.some((c) => c.status === "fail");
|
|
10703
|
-
console.log(
|
|
10704
|
-
|
|
11359
|
+
if (ui.fancy) console.log(ui.banner("Doctor", readServiceVersion()));
|
|
11360
|
+
console.log(renderDoctor(sections3, { version: readServiceVersion(), color: useColor(), header: !ui.fancy }));
|
|
11361
|
+
return bridgeRunning && knowledgeLinked && mcpRegistered && !sidecarBroken && !extensionsBroken ? 0 : 1;
|
|
11362
|
+
}
|
|
11363
|
+
function notifyNewerRelease(log) {
|
|
11364
|
+
if (findCloneRoot(__dirname2) || updateCheckDisabled()) return;
|
|
11365
|
+
checkForUpdate({ current: readServiceVersion() }).then((update) => {
|
|
11366
|
+
if (!update) return;
|
|
11367
|
+
log(`reaper-mcp ${update.latest} is available (this is ${readServiceVersion()})`);
|
|
11368
|
+
addNotice({ text: update.text, onDelivered: update.markNotified });
|
|
11369
|
+
}).catch(() => void 0);
|
|
11370
|
+
}
|
|
11371
|
+
function repairReaperSide(log) {
|
|
11372
|
+
try {
|
|
11373
|
+
return repairBridgeInstall({
|
|
11374
|
+
scriptsDir: getReaperScriptsPath(),
|
|
11375
|
+
effectsDir: getReaperEffectsPath(),
|
|
11376
|
+
wwwDir: getReaperWwwPath(),
|
|
11377
|
+
assetsDir: resolveAssetDir(__dirname2, "reaper"),
|
|
11378
|
+
wwwSrcDir: resolveAssetDir(__dirname2, "bridge-ui")
|
|
11379
|
+
}, readServiceVersion(), { inClone: findCloneRoot(__dirname2) !== null });
|
|
11380
|
+
} catch (err) {
|
|
11381
|
+
log(`Could not update REAPER's reaper-mcp files: ${err instanceof Error ? err.message : String(err)}`);
|
|
11382
|
+
return void 0;
|
|
11383
|
+
}
|
|
10705
11384
|
}
|
|
10706
11385
|
async function serve() {
|
|
10707
11386
|
const log = (...args) => console.error("[reaper-mcp]", ...args);
|
|
@@ -10720,6 +11399,7 @@ async function serve() {
|
|
|
10720
11399
|
startupSpan.setAttribute("reaper.bridge.stale_files_cleaned", cleaned);
|
|
10721
11400
|
log(`Cleaned up ${cleaned} stale bridge files`);
|
|
10722
11401
|
}
|
|
11402
|
+
const repair = repairReaperSide(log);
|
|
10723
11403
|
const bridge = await tracer.startActiveSpan("check bridge connection", { kind: SpanKind5.INTERNAL }, async (bridgeSpan) => {
|
|
10724
11404
|
const status = await getBridgeState();
|
|
10725
11405
|
const running = status.state === "connected";
|
|
@@ -10741,6 +11421,14 @@ async function serve() {
|
|
|
10741
11421
|
});
|
|
10742
11422
|
startupSpan.setAttribute("reaper.bridge.connected", bridge.state === "connected");
|
|
10743
11423
|
startupSpan.setAttribute("reaper.bridge.state", bridge.state);
|
|
11424
|
+
const reaperRunning = bridge.state === "connected" ? Promise.resolve(void 0) : isReaperProcessRunning();
|
|
11425
|
+
if (repair && !repair.skipped) {
|
|
11426
|
+
const version = readServiceVersion();
|
|
11427
|
+
if (repair.bridgeChanged) startupSpan.setAttribute("reaper.bridge.files_updated", true);
|
|
11428
|
+
if (repair.autostartAdded) startupSpan.setAttribute("reaper.bridge.autostart_added", true);
|
|
11429
|
+
log(`Updated REAPER's reaper-mcp files from ${repair.from ?? "an earlier release"} to ${version}`);
|
|
11430
|
+
for (const text8 of repairNotices(repair, version, bridge.state === "connected")) addNotice({ text: text8 });
|
|
11431
|
+
}
|
|
10744
11432
|
const profile = resolveProfile();
|
|
10745
11433
|
const server = createServer(profile);
|
|
10746
11434
|
const selected = profile.categories;
|
|
@@ -10762,6 +11450,13 @@ async function serve() {
|
|
|
10762
11450
|
recordClientConnected();
|
|
10763
11451
|
};
|
|
10764
11452
|
startSessionPing();
|
|
11453
|
+
notifyNewerRelease(log);
|
|
11454
|
+
startupSpan.setAttributes(setupHealthAttributes({
|
|
11455
|
+
status: bridge,
|
|
11456
|
+
reaperRunning: await reaperRunning,
|
|
11457
|
+
autostart: autostartInstalled(getReaperScriptsPath()),
|
|
11458
|
+
sidecarInstalled: getSidecarClient().isAvailable()
|
|
11459
|
+
}));
|
|
10765
11460
|
startupSpan.setStatus({ code: SpanStatusCode4.OK });
|
|
10766
11461
|
log("MCP server connected via stdio");
|
|
10767
11462
|
} catch (error7) {
|
|
@@ -10794,10 +11489,13 @@ switch (command) {
|
|
|
10794
11489
|
});
|
|
10795
11490
|
break;
|
|
10796
11491
|
case "doctor":
|
|
10797
|
-
doctor().
|
|
10798
|
-
|
|
10799
|
-
|
|
10800
|
-
|
|
11492
|
+
doctor().then(
|
|
11493
|
+
(code) => process.exit(code),
|
|
11494
|
+
(err) => {
|
|
11495
|
+
console.error("Doctor failed:", err);
|
|
11496
|
+
process.exit(1);
|
|
11497
|
+
}
|
|
11498
|
+
);
|
|
10801
11499
|
break;
|
|
10802
11500
|
case "telemetry":
|
|
10803
11501
|
telemetryCommand(process.argv[3]).catch((err) => {
|
|
@@ -10825,7 +11523,7 @@ switch (command) {
|
|
|
10825
11523
|
(async () => {
|
|
10826
11524
|
const status = await getBridgeState();
|
|
10827
11525
|
const running = status.state === "connected";
|
|
10828
|
-
console.log(`Bridge status: ${running ? "CONNECTED" : `NOT DETECTED (${status.state})`}`);
|
|
11526
|
+
console.log(`Bridge status: ${running ? ui.ok("CONNECTED") : ui.fail(`NOT DETECTED (${status.state})`)}`);
|
|
10829
11527
|
if (!running) console.log(bridgeDownMessage(status));
|
|
10830
11528
|
process.exit(running ? 0 : 1);
|
|
10831
11529
|
})();
|
|
@@ -10846,20 +11544,23 @@ Install from npm (below), or clone the repo and run ./scripts/install.sh.
|
|
|
10846
11544
|
Usage:
|
|
10847
11545
|
reaper-mcp Start MCP server (stdio mode)
|
|
10848
11546
|
reaper-mcp serve Start MCP server (stdio mode)
|
|
10849
|
-
reaper-mcp setup Install Lua bridge + JSFX analyzers into REAPER
|
|
11547
|
+
reaper-mcp setup Install Lua bridge + JSFX analyzers into REAPER, then offer init and doctor
|
|
11548
|
+
(--yes: do all three without asking; --verbose lists every file)
|
|
10850
11549
|
reaper-mcp setup-sidecar Install the Python sidecar (opt-in audio analysis); in a terminal it asks which parts.
|
|
10851
11550
|
Agents/CI: --yes (core + aesthetics weights), --all, --with-separation (Demucs),
|
|
10852
11551
|
--with-chords (chord model), --without-aesthetics, --list [--json] (what is installed)
|
|
10853
11552
|
reaper-mcp extension Manage opt-in extensions: list | add <name|folder|git-url> | link <folder> | remove <name> | new <name>
|
|
10854
|
-
reaper-mcp init
|
|
10855
|
-
|
|
11553
|
+
reaper-mcp init Connect the harnesses you have installed (Claude Code, Codex CLI, Gemini CLI, Cursor) and suggest the ones you don't;
|
|
11554
|
+
--harness claude,codex or --all to pick by hand. From npm it also installs the skills
|
|
11555
|
+
reaper-mcp install-skills Copy the mix skills, agents and knowledge into ~/.claude, and skills + agents into ~/.agents for the
|
|
11556
|
+
other harnesses (npm install; --harness to pick, --dry-run to preview)
|
|
10856
11557
|
reaper-mcp doctor Check that everything is configured correctly
|
|
10857
11558
|
reaper-mcp status Check if Lua bridge is running in REAPER
|
|
10858
11559
|
reaper-mcp telemetry off Opt out of pseudonymous usage telemetry (also: on, status)
|
|
10859
11560
|
|
|
10860
11561
|
Quick Start (from npm):
|
|
10861
11562
|
npm install -g @mthines/reaper-mcp
|
|
10862
|
-
reaper-mcp setup && reaper-mcp init # bridge into REAPER, tools + skills into
|
|
11563
|
+
reaper-mcp setup && reaper-mcp init # bridge into REAPER, tools + skills into your harness(es)
|
|
10863
11564
|
# then start (or restart) REAPER: the bridge starts with it
|
|
10864
11565
|
|
|
10865
11566
|
Quick Start (from your clone):
|