@mthines/reaper-mcp 0.83.2 → 0.85.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/main.js CHANGED
@@ -5082,6 +5082,13 @@ node=${node}
5082
5082
  dev=${dev ? 1 : 0}
5083
5083
  `;
5084
5084
  }
5085
+ function npmUpdateConfigText(node, cli) {
5086
+ return `mode=npm
5087
+ node=${node}
5088
+ cli=${cli}
5089
+ dev=0
5090
+ `;
5091
+ }
5085
5092
  function isDevClone({ dirty, branch, ahead }) {
5086
5093
  return dirty || branch !== "main" || ahead === null || ahead > 0;
5087
5094
  }
@@ -10345,117 +10352,98 @@ Try it: reaper-mcp extension link ${basename4(r.dir)}`);
10345
10352
  }
10346
10353
 
10347
10354
  // apps/reaper-mcp-server/src/main.ts
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";
10355
+ import { existsSync as existsSync13, mkdirSync as mkdirSync12, readFileSync as readFileSync12, realpathSync, rmSync as rmSync3, writeFileSync as writeFileSync11 } from "node:fs";
10356
+ import { join as join20, dirname as dirname12, resolve as resolve3 } from "node:path";
10350
10357
  import { fileURLToPath as fileURLToPath6 } from "node:url";
10351
10358
  import { homedir as homedir11, platform as platform6 } from "node:os";
10352
- import { exec as execCb } from "node:child_process";
10359
+ import { exec as execCb, spawn as spawn3 } from "node:child_process";
10353
10360
  import { promisify as promisifyUtil } from "node:util";
10354
10361
 
10355
- // apps/reaper-mcp-server/src/claude-assets.ts
10356
- import { createHash as createHash2 } from "node:crypto";
10357
- import { existsSync as existsSync8, lstatSync, mkdirSync as mkdirSync7, readFileSync as readFileSync6, readdirSync as readdirSync2, writeFileSync as writeFileSync6 } from "node:fs";
10358
- import { dirname as dirname8, join as join13, relative } from "node:path";
10359
- var CLAUDE_MANIFEST = ".reaper-mcp-installed.json";
10360
- var sha = (buf) => createHash2("sha256").update(buf).digest("hex");
10361
- function listFiles(dir) {
10362
- const out2 = [];
10363
- for (const entry of readdirSync2(dir, { withFileTypes: true })) {
10364
- const p = join13(dir, entry.name);
10365
- if (entry.isDirectory()) out2.push(...listFiles(p));
10366
- else if (entry.isFile()) out2.push(p);
10362
+ // apps/reaper-mcp-server/src/update.ts
10363
+ import { spawn as spawn2 } from "node:child_process";
10364
+ import { dirname as dirname10, join as join15 } from "node:path";
10365
+ import { existsSync as existsSync9 } from "node:fs";
10366
+
10367
+ // apps/reaper-mcp-server/src/version.ts
10368
+ function compareVersions(a, b) {
10369
+ const parts = (v) => v.replace(/^v/, "").split("-")[0].split(".").map((n) => parseInt(n, 10) || 0);
10370
+ const [pa, pb] = [parts(a), parts(b)];
10371
+ for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
10372
+ const d = (pa[i] ?? 0) - (pb[i] ?? 0);
10373
+ if (d) return Math.sign(d);
10367
10374
  }
10368
- return out2;
10375
+ return 0;
10369
10376
  }
10370
- function isSymlink(path) {
10377
+
10378
+ // apps/reaper-mcp-server/src/update-check.ts
10379
+ import { mkdirSync as mkdirSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync6 } from "node:fs";
10380
+ import { dirname as dirname8, join as join13 } from "node:path";
10381
+ import { homedir as homedir9 } from "node:os";
10382
+ var NPM_PACKAGE = "@mthines/reaper-mcp";
10383
+ var PACKAGE_URL = "https://registry.npmjs.org/@mthines%2Freaper-mcp";
10384
+ var DAY_MS = 24 * 60 * 60 * 1e3;
10385
+ function defaultUpdateStatePath() {
10386
+ return join13(homedir9(), ".reaper-mcp", "update-check.json");
10387
+ }
10388
+ function updateCheckDisabled(env = process.env) {
10389
+ const setting = (env["REAPER_MCP_UPDATE_CHECK"] ?? "").trim().toLowerCase();
10390
+ return ["0", "false", "off", "no"].includes(setting) || Boolean(env["NO_UPDATE_NOTIFIER"]) || Boolean(env["CI"]);
10391
+ }
10392
+ async function fetchLatestVersion(fetchImpl = fetch, timeoutMs = 3e3) {
10371
10393
  try {
10372
- return lstatSync(path).isSymbolicLink();
10394
+ const res = await fetchImpl(PACKAGE_URL, {
10395
+ signal: AbortSignal.timeout(timeoutMs),
10396
+ headers: { accept: "application/vnd.npm.install-v1+json" }
10397
+ });
10398
+ if (!res.ok) return void 0;
10399
+ const body = await res.json();
10400
+ const latest = body["dist-tags"]?.latest;
10401
+ return typeof latest === "string" && /^\d+\.\d+\.\d+/.test(latest) && body.versions && latest in body.versions ? latest : void 0;
10373
10402
  } catch {
10374
- return false;
10403
+ return void 0;
10375
10404
  }
10376
10405
  }
10377
- function readManifest2(path) {
10406
+ function updateNotice(current, latest) {
10407
+ 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.`;
10408
+ }
10409
+ function readState(path) {
10378
10410
  try {
10379
- const m = JSON.parse(readFileSync6(path, "utf-8"));
10380
- if (m && m.version === 1 && m.files && typeof m.files === "object") return m;
10411
+ const s = JSON.parse(readFileSync6(path, "utf-8"));
10412
+ return s && typeof s === "object" ? s : {};
10381
10413
  } catch {
10414
+ return {};
10382
10415
  }
10383
- return { version: 1, files: {} };
10384
10416
  }
10385
- function installClaudeAssets(packageClaudeDir, claudeDir, opts = {}) {
10386
- const wants = (part) => !opts.include || opts.include.includes(part);
10387
- const result = { installed: [], updated: [], unchanged: 0, skipped: [] };
10388
- const manifestPath = join13(claudeDir, CLAUDE_MANIFEST);
10389
- const manifest = readManifest2(manifestPath);
10390
- const plan = [];
10391
- const skillsSrc = join13(packageClaudeDir, "skills");
10392
- if (wants("skills") && existsSync8(skillsSrc)) {
10393
- for (const f of listFiles(skillsSrc)) {
10394
- const rel = relative(skillsSrc, f);
10395
- if (existsSync8(join13(skillsSrc, rel.split(/[\\/]/)[0], ".repo-only"))) continue;
10396
- plan.push([f, join13(claudeDir, "skills", rel), join13(claudeDir, "skills", rel.split(/[\\/]/)[0])]);
10397
- }
10398
- }
10399
- const agentsSrc = join13(packageClaudeDir, "agents");
10400
- if (wants("agents") && existsSync8(agentsSrc)) {
10401
- for (const f of listFiles(agentsSrc)) {
10402
- const dest = join13(claudeDir, "agents", relative(agentsSrc, f));
10403
- plan.push([f, dest, dest]);
10404
- }
10405
- }
10406
- const knowledgeSrc = join13(packageClaudeDir, "knowledge");
10407
- if (wants("knowledge") && existsSync8(knowledgeSrc)) {
10408
- for (const f of listFiles(knowledgeSrc)) {
10409
- plan.push([f, join13(claudeDir, "knowledge", relative(knowledgeSrc, f)), join13(claudeDir, "knowledge")]);
10410
- }
10411
- }
10412
- const skippedSymlinks = /* @__PURE__ */ new Set();
10413
- for (const [src, dest, linkRoot] of plan) {
10414
- if (isSymlink(linkRoot)) {
10415
- if (!skippedSymlinks.has(linkRoot)) {
10416
- skippedSymlinks.add(linkRoot);
10417
- result.skipped.push({ path: linkRoot, reason: existsSync8(linkRoot) ? "symlink" : "broken-symlink" });
10418
- }
10419
- continue;
10420
- }
10421
- const key = relative(claudeDir, dest);
10422
- const content = readFileSync6(src);
10423
- const hash = sha(content);
10424
- if (!existsSync8(dest)) {
10425
- if (!opts.dryRun) {
10426
- mkdirSync7(dirname8(dest), { recursive: true });
10427
- writeFileSync6(dest, content);
10428
- manifest.files[key] = hash;
10429
- }
10430
- result.installed.push(key);
10431
- continue;
10432
- }
10433
- const current = sha(readFileSync6(dest));
10434
- if (current === hash) {
10435
- if (!opts.dryRun) manifest.files[key] = hash;
10436
- result.unchanged++;
10437
- } else if (manifest.files[key] === current) {
10438
- if (!opts.dryRun) {
10439
- writeFileSync6(dest, content);
10440
- manifest.files[key] = hash;
10441
- }
10442
- result.updated.push(key);
10443
- } else {
10444
- result.skipped.push({ path: key, reason: key in manifest.files ? "edited" : "not-ours" });
10445
- }
10417
+ function writeState(path, state) {
10418
+ try {
10419
+ mkdirSync7(dirname8(path), { recursive: true });
10420
+ writeFileSync6(path, JSON.stringify(state) + "\n", "utf-8");
10421
+ } catch {
10446
10422
  }
10447
- if (!opts.dryRun && (result.installed.length || result.updated.length || result.unchanged)) {
10448
- mkdirSync7(claudeDir, { recursive: true });
10449
- writeFileSync6(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
10423
+ }
10424
+ async function checkForUpdate(opts) {
10425
+ const statePath = opts.statePath ?? defaultUpdateStatePath();
10426
+ const now = opts.now ?? Date.now();
10427
+ const state = readState(statePath);
10428
+ if (state.notifiedAt !== void 0 && now - state.notifiedAt < DAY_MS) return void 0;
10429
+ let latest = state.latest;
10430
+ if (state.checkedAt === void 0 || now - state.checkedAt >= DAY_MS) {
10431
+ latest = await (opts.fetchLatest ?? fetchLatestVersion)() ?? latest;
10432
+ writeState(statePath, { ...state, checkedAt: now, ...latest ? { latest } : {} });
10450
10433
  }
10451
- return result;
10434
+ if (!latest || compareVersions(latest, opts.current) <= 0) return void 0;
10435
+ return {
10436
+ latest,
10437
+ text: updateNotice(opts.current, latest),
10438
+ markNotified: () => writeState(statePath, { ...readState(statePath), notifiedAt: Date.now() })
10439
+ };
10452
10440
  }
10453
10441
 
10454
10442
  // apps/reaper-mcp-server/src/harnesses.ts
10455
10443
  import { execFileSync } from "node:child_process";
10456
- import { existsSync as existsSync9, mkdirSync as mkdirSync8, readFileSync as readFileSync7, writeFileSync as writeFileSync7 } from "node:fs";
10444
+ import { existsSync as existsSync8, mkdirSync as mkdirSync8, readFileSync as readFileSync7, writeFileSync as writeFileSync7 } from "node:fs";
10457
10445
  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";
10446
+ import { homedir as homedir10, platform as platform4 } from "node:os";
10459
10447
  var HARNESSES = [
10460
10448
  { id: "claude", name: "Claude Code", binary: "claude", installHint: "https://claude.com/claude-code", skillsHome: "claude" },
10461
10449
  { id: "codex", name: "Codex CLI", binary: "codex", installHint: "npm install -g @openai/codex (or: brew install codex)", skillsHome: "agents" },
@@ -10465,10 +10453,10 @@ var HARNESSES = [
10465
10453
  var SERVER_NAME = "reaper";
10466
10454
  function onPath(name, pathVar = process.env.PATH ?? "", win = platform4() === "win32") {
10467
10455
  const exts = win ? ["", ".exe", ".cmd", ".bat"] : [""];
10468
- return pathVar.split(delimiter).filter(Boolean).some((dir) => exts.some((ext) => existsSync9(join14(dir, name + ext))));
10456
+ return pathVar.split(delimiter).filter(Boolean).some((dir) => exts.some((ext) => existsSync8(join14(dir, name + ext))));
10469
10457
  }
10470
10458
  function realEnv() {
10471
- return { home: homedir9(), codexHome: process.env.CODEX_HOME || void 0, hasBinary: (name) => onPath(name) };
10459
+ return { home: homedir10(), codexHome: process.env.CODEX_HOME || void 0, hasBinary: (name) => onPath(name) };
10472
10460
  }
10473
10461
  var configPath = (id, env) => ({
10474
10462
  claude: join14(env.home, ".claude.json"),
@@ -10477,7 +10465,7 @@ var configPath = (id, env) => ({
10477
10465
  cursor: join14(env.home, ".cursor", "mcp.json")
10478
10466
  })[id];
10479
10467
  function detectHarnesses(env = realEnv()) {
10480
- return HARNESSES.filter((h) => h.binary ? env.hasBinary(h.binary) : existsSync9(join14(env.home, ".cursor")));
10468
+ return HARNESSES.filter((h) => h.binary ? env.hasBinary(h.binary) : existsSync8(join14(env.home, ".cursor")));
10481
10469
  }
10482
10470
  function registeredServer(id, env = realEnv()) {
10483
10471
  let text8;
@@ -10508,7 +10496,7 @@ function codexServer(toml) {
10508
10496
  return { command: strings(command2)[0], args: strings(args) };
10509
10497
  }
10510
10498
  function isStale(server) {
10511
- return [server.command, ...server.args].filter(isAbsolute3).some((p) => !existsSync9(p));
10499
+ return [server.command, ...server.args].filter(isAbsolute3).some((p) => !existsSync8(p));
10512
10500
  }
10513
10501
  function addCommand(id, node, mainJs) {
10514
10502
  switch (id) {
@@ -10548,7 +10536,7 @@ var realRunner = (bin, args) => {
10548
10536
  };
10549
10537
  function writeJsonServer(path, node, mainJs) {
10550
10538
  let config = {};
10551
- if (existsSync9(path)) config = JSON.parse(readFileSync7(path, "utf-8"));
10539
+ if (existsSync8(path)) config = JSON.parse(readFileSync7(path, "utf-8"));
10552
10540
  const servers = config.mcpServers && typeof config.mcpServers === "object" ? config.mcpServers : {};
10553
10541
  servers[SERVER_NAME] = { command: node, args: [mainJs, "serve"] };
10554
10542
  config.mcpServers = servers;
@@ -10593,50 +10581,204 @@ function skillsHomes(ids) {
10593
10581
  return { claude: chosen.some((h) => h.skillsHome === "claude"), agents: chosen.some((h) => h.skillsHome === "agents") };
10594
10582
  }
10595
10583
 
10584
+ // apps/reaper-mcp-server/src/update.ts
10585
+ async function runUpdate(deps) {
10586
+ const { current, log } = deps;
10587
+ log("==> Checking for a new version");
10588
+ const latest = await deps.latest();
10589
+ if (!latest) {
10590
+ log("\u2717 Could not find a version npm can install. Either npm is unreachable (check your internet connection), or the newest release is not published there yet. Try again later.");
10591
+ return 1;
10592
+ }
10593
+ if (!deps.force && compareVersions(latest, current) <= 0) {
10594
+ log(`\u2713 Already on the latest version (v${current})`);
10595
+ return deps.bridge ? 3 : 0;
10596
+ }
10597
+ log(` v${current} \u2192 v${latest}`);
10598
+ log("==> Downloading the new version");
10599
+ if (await deps.run(deps.npm, ["install", "-g", `${NPM_PACKAGE}@${latest}`]) !== 0) {
10600
+ log("\u2717 The download did not finish. If npm asked for permission, run this once in a terminal:");
10601
+ log(` npm install -g ${NPM_PACKAGE}@latest`);
10602
+ return 1;
10603
+ }
10604
+ log("==> Installing into REAPER");
10605
+ if (await deps.run(deps.node, [deps.cli, "setup", "--yes"]) !== 0) {
10606
+ log("\u2717 The new version downloaded, but installing it into REAPER failed. Run this in a terminal to see why:");
10607
+ log(" reaper-mcp setup");
10608
+ return 2;
10609
+ }
10610
+ log(`\u2713 Updated to v${latest}`);
10611
+ return 0;
10612
+ }
10613
+ function realUpdateDeps(current, cli, force = false, bridge = false) {
10614
+ const nodeDir = dirname10(process.execPath);
10615
+ const npmBeside = join15(nodeDir, process.platform === "win32" ? "npm.cmd" : "npm");
10616
+ return {
10617
+ current,
10618
+ latest: () => fetchLatestVersion(fetch, 1e4),
10619
+ run: (command2, args) => new Promise((resolve4) => {
10620
+ const win = process.platform === "win32";
10621
+ const child = spawn2(win ? quoteForCmd(command2) : command2, win ? args.map(quoteForCmd) : args, {
10622
+ shell: win,
10623
+ stdio: ["ignore", "inherit", "inherit"],
10624
+ // The node that runs this first on PATH: npm's own shebang and the child reaper-mcp find it
10625
+ env: { ...process.env, PATH: `${nodeDir}${process.platform === "win32" ? ";" : ":"}${process.env["PATH"] ?? ""}` }
10626
+ });
10627
+ child.on("error", () => resolve4(1));
10628
+ child.on("close", (code) => resolve4(code ?? 1));
10629
+ }),
10630
+ npm: existsSync9(npmBeside) ? npmBeside : "npm",
10631
+ node: process.execPath,
10632
+ cli,
10633
+ log: (line) => console.log(line),
10634
+ force,
10635
+ bridge
10636
+ };
10637
+ }
10638
+
10639
+ // apps/reaper-mcp-server/src/claude-assets.ts
10640
+ import { createHash as createHash2 } from "node:crypto";
10641
+ import { existsSync as existsSync10, lstatSync, mkdirSync as mkdirSync9, readFileSync as readFileSync8, readdirSync as readdirSync2, writeFileSync as writeFileSync8 } from "node:fs";
10642
+ import { dirname as dirname11, join as join16, relative } from "node:path";
10643
+ var CLAUDE_MANIFEST = ".reaper-mcp-installed.json";
10644
+ var sha = (buf) => createHash2("sha256").update(buf).digest("hex");
10645
+ function listFiles(dir) {
10646
+ const out2 = [];
10647
+ for (const entry of readdirSync2(dir, { withFileTypes: true })) {
10648
+ const p = join16(dir, entry.name);
10649
+ if (entry.isDirectory()) out2.push(...listFiles(p));
10650
+ else if (entry.isFile()) out2.push(p);
10651
+ }
10652
+ return out2;
10653
+ }
10654
+ function isSymlink(path) {
10655
+ try {
10656
+ return lstatSync(path).isSymbolicLink();
10657
+ } catch {
10658
+ return false;
10659
+ }
10660
+ }
10661
+ function readManifest2(path) {
10662
+ try {
10663
+ const m = JSON.parse(readFileSync8(path, "utf-8"));
10664
+ if (m && m.version === 1 && m.files && typeof m.files === "object") return m;
10665
+ } catch {
10666
+ }
10667
+ return { version: 1, files: {} };
10668
+ }
10669
+ function installClaudeAssets(packageClaudeDir, claudeDir, opts = {}) {
10670
+ const wants = (part) => !opts.include || opts.include.includes(part);
10671
+ const result = { installed: [], updated: [], unchanged: 0, skipped: [] };
10672
+ const manifestPath = join16(claudeDir, CLAUDE_MANIFEST);
10673
+ const manifest = readManifest2(manifestPath);
10674
+ const plan = [];
10675
+ const skillsSrc = join16(packageClaudeDir, "skills");
10676
+ if (wants("skills") && existsSync10(skillsSrc)) {
10677
+ for (const f of listFiles(skillsSrc)) {
10678
+ const rel = relative(skillsSrc, f);
10679
+ if (existsSync10(join16(skillsSrc, rel.split(/[\\/]/)[0], ".repo-only"))) continue;
10680
+ plan.push([f, join16(claudeDir, "skills", rel), join16(claudeDir, "skills", rel.split(/[\\/]/)[0])]);
10681
+ }
10682
+ }
10683
+ const agentsSrc = join16(packageClaudeDir, "agents");
10684
+ if (wants("agents") && existsSync10(agentsSrc)) {
10685
+ for (const f of listFiles(agentsSrc)) {
10686
+ const dest = join16(claudeDir, "agents", relative(agentsSrc, f));
10687
+ plan.push([f, dest, dest]);
10688
+ }
10689
+ }
10690
+ const knowledgeSrc = join16(packageClaudeDir, "knowledge");
10691
+ if (wants("knowledge") && existsSync10(knowledgeSrc)) {
10692
+ for (const f of listFiles(knowledgeSrc)) {
10693
+ plan.push([f, join16(claudeDir, "knowledge", relative(knowledgeSrc, f)), join16(claudeDir, "knowledge")]);
10694
+ }
10695
+ }
10696
+ const skippedSymlinks = /* @__PURE__ */ new Set();
10697
+ for (const [src, dest, linkRoot] of plan) {
10698
+ if (isSymlink(linkRoot)) {
10699
+ if (!skippedSymlinks.has(linkRoot)) {
10700
+ skippedSymlinks.add(linkRoot);
10701
+ result.skipped.push({ path: linkRoot, reason: existsSync10(linkRoot) ? "symlink" : "broken-symlink" });
10702
+ }
10703
+ continue;
10704
+ }
10705
+ const key = relative(claudeDir, dest);
10706
+ const content = readFileSync8(src);
10707
+ const hash = sha(content);
10708
+ if (!existsSync10(dest)) {
10709
+ if (!opts.dryRun) {
10710
+ mkdirSync9(dirname11(dest), { recursive: true });
10711
+ writeFileSync8(dest, content);
10712
+ manifest.files[key] = hash;
10713
+ }
10714
+ result.installed.push(key);
10715
+ continue;
10716
+ }
10717
+ const current = sha(readFileSync8(dest));
10718
+ if (current === hash) {
10719
+ if (!opts.dryRun) manifest.files[key] = hash;
10720
+ result.unchanged++;
10721
+ } else if (manifest.files[key] === current) {
10722
+ if (!opts.dryRun) {
10723
+ writeFileSync8(dest, content);
10724
+ manifest.files[key] = hash;
10725
+ }
10726
+ result.updated.push(key);
10727
+ } else {
10728
+ result.skipped.push({ path: key, reason: key in manifest.files ? "edited" : "not-ours" });
10729
+ }
10730
+ }
10731
+ if (!opts.dryRun && (result.installed.length || result.updated.length || result.unchanged)) {
10732
+ mkdirSync9(claudeDir, { recursive: true });
10733
+ writeFileSync8(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
10734
+ }
10735
+ return result;
10736
+ }
10737
+
10596
10738
  // apps/reaper-mcp-server/src/jsfx/examples.ts
10597
10739
  import { createHash as createHash3 } from "node:crypto";
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";
10740
+ import { existsSync as existsSync11, mkdirSync as mkdirSync10, readFileSync as readFileSync9, readdirSync as readdirSync3, writeFileSync as writeFileSync9 } from "node:fs";
10741
+ import { join as join17 } from "node:path";
10600
10742
  var MANIFEST = ".installed.json";
10601
10743
  var sha2 = (text8) => createHash3("sha256").update(text8).digest("hex");
10602
10744
  function installExamplePlugins(examplesDir, outDir, toolkit, presetsDir2) {
10603
10745
  const result = { installed: [], kept: [], presets: {}, presetErrors: [] };
10604
- if (!existsSync10(examplesDir)) return result;
10605
- mkdirSync9(outDir, { recursive: true });
10606
- const manifestPath = join15(outDir, MANIFEST);
10746
+ if (!existsSync11(examplesDir)) return result;
10747
+ mkdirSync10(outDir, { recursive: true });
10748
+ const manifestPath = join17(outDir, MANIFEST);
10607
10749
  let manifest = {};
10608
10750
  try {
10609
- manifest = JSON.parse(readFileSync8(manifestPath, "utf8"));
10751
+ manifest = JSON.parse(readFileSync9(manifestPath, "utf8"));
10610
10752
  } catch {
10611
10753
  }
10612
10754
  for (const file of readdirSync3(examplesDir).filter((f) => f.endsWith(".jsfx")).sort()) {
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;
10755
+ const dest = join17(outDir, file);
10756
+ const next = inlineToolkit(readFileSync9(join17(examplesDir, file), "utf8"), { toolkit, version: 1, request: "a plugin that ships with reaper-mcp", slug: file.replace(/\.jsfx$/, ""), example: true });
10757
+ const current = existsSync11(dest) ? readFileSync9(dest, "utf8") : void 0;
10616
10758
  if (current !== void 0 && current !== next && sha2(current) !== manifest[file]) {
10617
10759
  result.kept.push(file);
10618
10760
  continue;
10619
10761
  }
10620
- if (current !== next) writeFileSync8(dest, next);
10762
+ if (current !== next) writeFileSync9(dest, next);
10621
10763
  manifest[file] = sha2(next);
10622
10764
  result.installed.push(file);
10623
10765
  }
10624
10766
  if (presetsDir2) {
10625
10767
  const folder = outDir.split(/[/\\]/).slice(-2).join("/");
10626
10768
  for (const file of readdirSync3(examplesDir).filter((f) => f.endsWith(".jsfx")).sort()) {
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);
10769
+ const presetsPath = join17(examplesDir, file.replace(/\.jsfx$/, ".presets.json"));
10770
+ if (!existsSync11(presetsPath)) continue;
10771
+ const input = JSON.parse(readFileSync9(presetsPath, "utf8"));
10772
+ const { values, errors } = resolvePresets(input, parseSliders(readFileSync9(join17(examplesDir, file), "utf8")).sliders);
10631
10773
  if (errors.length) {
10632
10774
  result.presetErrors.push(`${file}: ${errors.join(" ")}`);
10633
10775
  continue;
10634
10776
  }
10635
10777
  const encoded = input.map((p, i) => encodePreset(p.name.trim(), values[i]));
10636
- result.presets[file] = writePresetFile(presetsDir2, `${folder}/${file}`, encoded, join15(outDir, ".presets", `${file}.json`)).written;
10778
+ result.presets[file] = writePresetFile(presetsDir2, `${folder}/${file}`, encoded, join17(outDir, ".presets", `${file}.json`)).written;
10637
10779
  }
10638
10780
  }
10639
- writeFileSync8(manifestPath, JSON.stringify(manifest, null, 2));
10781
+ writeFileSync9(manifestPath, JSON.stringify(manifest, null, 2));
10640
10782
  return result;
10641
10783
  }
10642
10784
 
@@ -10667,37 +10809,24 @@ function renderDoctor(sections3, opts = {}) {
10667
10809
  }
10668
10810
 
10669
10811
  // 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
10812
+ import { existsSync as existsSync12, mkdirSync as mkdirSync11, readFileSync as readFileSync10, rmSync as rmSync2, writeFileSync as writeFileSync10 } from "node:fs";
10813
+ import { join as join18 } from "node:path";
10685
10814
  var BRIDGE_VERSION_FILE = "mcp_bridge_version.txt";
10686
10815
  function readBridgeVersion(scriptsDir) {
10687
10816
  try {
10688
- const v = readFileSync9(join16(scriptsDir, BRIDGE_VERSION_FILE), "utf-8").trim();
10817
+ const v = readFileSync10(join18(scriptsDir, BRIDGE_VERSION_FILE), "utf-8").trim();
10689
10818
  return /^\d+\.\d+\.\d+/.test(v) ? v : void 0;
10690
10819
  } catch {
10691
10820
  return void 0;
10692
10821
  }
10693
10822
  }
10694
10823
  function writeBridgeVersion(scriptsDir, version) {
10695
- writeFileSync9(join16(scriptsDir, BRIDGE_VERSION_FILE), `${version}
10824
+ writeFileSync10(join18(scriptsDir, BRIDGE_VERSION_FILE), `${version}
10696
10825
  `, "utf-8");
10697
10826
  }
10698
10827
  function sameContent(a, b) {
10699
10828
  try {
10700
- return readFileSync9(a).equals(readFileSync9(b));
10829
+ return readFileSync10(a).equals(readFileSync10(b));
10701
10830
  } catch {
10702
10831
  return false;
10703
10832
  }
@@ -10705,32 +10834,32 @@ function sameContent(a, b) {
10705
10834
  function installReaperFiles(paths) {
10706
10835
  let luaChanged = false;
10707
10836
  for (const asset of REAPER_ASSETS) {
10708
- const src = join16(paths.assetsDir, asset);
10709
- if (!existsSync11(src)) continue;
10837
+ const src = join18(paths.assetsDir, asset);
10838
+ if (!existsSync12(src)) continue;
10710
10839
  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);
10840
+ const destDir = lua ? paths.scriptsDir : join18(paths.effectsDir, "reaper-mcp");
10841
+ mkdirSync11(destDir, { recursive: true });
10842
+ const dest = join18(destDir, asset);
10714
10843
  if (lua && !sameContent(src, dest)) luaChanged = true;
10715
10844
  installFile(src, dest);
10716
10845
  }
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);
10846
+ for (const asset of RETIRED_ASSETS) rmSync2(join18(paths.scriptsDir, asset), { force: true });
10847
+ if (existsSync12(join18(paths.wwwSrcDir, BRIDGE_UI_FILE))) copyDirSync(paths.wwwSrcDir, paths.wwwDir);
10719
10848
  return luaChanged;
10720
10849
  }
10721
10850
  function repairBridgeInstall(paths, version, opts) {
10722
10851
  const none = { bridgeChanged: false, autostartAdded: false };
10723
10852
  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"));
10853
+ const reapack = existsSync12(join18(paths.scriptsDir, "reaper-mcp", "MCP Bridge", "mcp_bridge.lua"));
10854
+ const ours = existsSync12(join18(paths.scriptsDir, "mcp_bridge.lua"));
10726
10855
  if (!reapack && !ours) return { skipped: "not_installed", ...none };
10727
10856
  const from = readBridgeVersion(paths.scriptsDir);
10728
10857
  if (from && compareVersions(from, version) >= 0) return { skipped: "current", from, ...none };
10729
10858
  const bridgeChanged = reapack ? false : installReaperFiles(paths);
10730
- const startupPath = join16(paths.scriptsDir, "__startup.lua");
10731
- const startup = existsSync11(startupPath) ? readFileSync9(startupPath, "utf-8") : "";
10859
+ const startupPath = join18(paths.scriptsDir, "__startup.lua");
10860
+ const startup = existsSync12(startupPath) ? readFileSync10(startupPath, "utf-8") : "";
10732
10861
  const { text: text8, changed } = ensureBridgeAutostart(startup);
10733
- if (changed) writeFileSync9(startupPath, text8, "utf-8");
10862
+ if (changed) writeFileSync10(startupPath, text8, "utf-8");
10734
10863
  writeBridgeVersion(paths.scriptsDir, version);
10735
10864
  return { from, bridgeChanged, autostartAdded: !startup.includes(AUTOSTART_MARKER) };
10736
10865
  }
@@ -10745,66 +10874,6 @@ function repairNotices(repair, version, bridgeRunning) {
10745
10874
  return notices;
10746
10875
  }
10747
10876
 
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
10877
  // apps/reaper-mcp-server/src/sidecar-offer.ts
10809
10878
  import { createInterface as createInterface4 } from "node:readline";
10810
10879
  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.";
@@ -10840,7 +10909,7 @@ ${SIDECAR_OFFER_TEXT}
10840
10909
  // apps/reaper-mcp-server/src/setup-health.ts
10841
10910
  import { execFile as execFile2 } from "node:child_process";
10842
10911
  import { readFileSync as readFileSync11 } from "node:fs";
10843
- import { join as join18 } from "node:path";
10912
+ import { join as join19 } from "node:path";
10844
10913
  import { platform as platform5 } from "node:os";
10845
10914
  function heartbeatAgeBucket(ms) {
10846
10915
  const min = 6e4;
@@ -10863,7 +10932,7 @@ function isReaperProcessRunning(timeoutMs = 2e3) {
10863
10932
  }
10864
10933
  function autostartInstalled(scriptsDir) {
10865
10934
  try {
10866
- return readFileSync11(join18(scriptsDir, "__startup.lua"), "utf-8").includes(AUTOSTART_MARKER);
10935
+ return readFileSync11(join19(scriptsDir, "__startup.lua"), "utf-8").includes(AUTOSTART_MARKER);
10867
10936
  } catch {
10868
10937
  return false;
10869
10938
  }
@@ -10880,7 +10949,7 @@ function setupHealthAttributes(h) {
10880
10949
  // apps/reaper-mcp-server/src/main.ts
10881
10950
  var execAsync = promisifyUtil(execCb);
10882
10951
  var ui = createUi();
10883
- var __dirname2 = dirname11(fileURLToPath6(import.meta.url));
10952
+ var __dirname2 = dirname12(fileURLToPath6(import.meta.url));
10884
10953
  async function setup() {
10885
10954
  const verbose = process.argv.includes("--verbose");
10886
10955
  const installedLine = (what, files) => {
@@ -10894,7 +10963,7 @@ async function setup() {
10894
10963
  const scriptsDir = getReaperScriptsPath();
10895
10964
  mkdirSync12(scriptsDir, { recursive: true });
10896
10965
  const reaperDir = resolveAssetDir(__dirname2, "reaper");
10897
- const filesPlan = setupFilesPlan(existsSync12(join19(scriptsDir, "reaper-mcp", "MCP Bridge", "mcp_bridge.lua")), findCloneRoot(__dirname2) !== null);
10966
+ const filesPlan = setupFilesPlan(existsSync13(join20(scriptsDir, "reaper-mcp", "MCP Bridge", "mcp_bridge.lua")), findCloneRoot(__dirname2) !== null);
10898
10967
  if (filesPlan === "leave") {
10899
10968
  console.log(`${ui.mark("info")} The bridge is installed by ReaPack: leaving its scripts, JSFX and status page to ReaPack.`);
10900
10969
  console.log(`${ui.dim("Setup only turns on starting with REAPER and the web interface.")}
@@ -10904,7 +10973,7 @@ async function setup() {
10904
10973
  const port = await enableWebInterface();
10905
10974
  console.log(`
10906
10975
  ${ui.mark("ok")} ${ui.bold("Setup complete!")}`);
10907
- if (await chainAfterSetup(port, join19(scriptsDir, "reaper-mcp", "MCP Bridge", "mcp_bridge.lua"))) return;
10976
+ if (await chainAfterSetup(port, join20(scriptsDir, "reaper-mcp", "MCP Bridge", "mcp_bridge.lua"))) return;
10908
10977
  console.log(`
10909
10978
  Restart REAPER (or run the bridge once from the Action List) and add reaper-mcp to your harness: ${ui.cmd("reaper-mcp doctor")}`);
10910
10979
  if (port) console.log(`The bridge opens its status window on start: ${ui.link(`http://localhost:${port}/${BRIDGE_UI_FILE}`)}`);
@@ -10921,15 +10990,15 @@ Restart REAPER (or run the bridge once from the Action List) and add reaper-mcp
10921
10990
  const luaInstalled = [];
10922
10991
  for (const asset of REAPER_ASSETS) {
10923
10992
  if (!asset.endsWith(".lua")) continue;
10924
- const src = join19(reaperDir, asset);
10925
- const dest = join19(scriptsDir, asset);
10993
+ const src = join20(reaperDir, asset);
10994
+ const dest = join20(scriptsDir, asset);
10926
10995
  if (installFile(src, dest)) luaInstalled.push(asset);
10927
10996
  else console.log(ui.item("fail", `Not found: ${src}`));
10928
10997
  }
10929
10998
  installedLine("scripts", luaInstalled);
10930
10999
  for (const asset of RETIRED_ASSETS) {
10931
- const dest = join19(scriptsDir, asset);
10932
- if (existsSync12(dest)) {
11000
+ const dest = join20(scriptsDir, asset);
11001
+ if (existsSync13(dest)) {
10933
11002
  rmSync3(dest);
10934
11003
  console.log(ui.item("info", `Removed: ${asset} (retired)`));
10935
11004
  }
@@ -10937,24 +11006,26 @@ Restart REAPER (or run the bridge once from the Action List) and add reaper-mcp
10937
11006
  const cloneRoot = findCloneRoot(__dirname2);
10938
11007
  if (cloneRoot) {
10939
11008
  const dev = isDevClone(await cloneState(cloneRoot));
10940
- writeFileSync11(join19(scriptsDir, "mcp_update.conf"), updateConfigText(cloneRoot, process.execPath, dev));
11009
+ writeFileSync11(join20(scriptsDir, "mcp_update.conf"), updateConfigText(cloneRoot, process.execPath, dev));
10941
11010
  console.log(ui.item("ok", `Installed: mcp_update.conf (${dev ? "developer clone: Rebuild & reload" : "one-click updates"} from the status page)`));
11011
+ } else {
11012
+ writeFileSync11(join20(scriptsDir, "mcp_update.conf"), npmUpdateConfigText(process.execPath, join20(__dirname2, "main.js")));
10942
11013
  }
10943
- const effectsDir = join19(getReaperEffectsPath(), "reaper-mcp");
11014
+ const effectsDir = join20(getReaperEffectsPath(), "reaper-mcp");
10944
11015
  mkdirSync12(effectsDir, { recursive: true });
10945
11016
  console.log(ui.section("Installing JSFX analyzers..."));
10946
11017
  const jsfxInstalled = [];
10947
11018
  for (const asset of REAPER_ASSETS) {
10948
11019
  if (asset.endsWith(".lua")) continue;
10949
- const src = join19(reaperDir, asset);
10950
- const dest = join19(effectsDir, asset);
11020
+ const src = join20(reaperDir, asset);
11021
+ const dest = join20(effectsDir, asset);
10951
11022
  if (installFile(src, dest)) jsfxInstalled.push(`reaper-mcp/${asset}`);
10952
11023
  else console.log(ui.item("fail", `Not found: ${src}`));
10953
11024
  }
10954
11025
  installedLine("JSFX files", jsfxInstalled);
10955
11026
  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());
11027
+ const examplesDir = join20(resolveAssetDir(__dirname2, "claude"), "skills", "make-plugin", "examples");
11028
+ const examples = installExamplePlugins(examplesDir, join20(generatedDir(), "examples"), loadToolkit(), presetsDir());
10958
11029
  installedLine("example plugins", examples.installed.map((f) => `reaper-mcp-generated/examples/${f}`));
10959
11030
  for (const f of examples.kept) console.log(ui.item("info", `Kept your edited copy: reaper-mcp-generated/examples/${f}`));
10960
11031
  if (verbose) {
@@ -10964,11 +11035,11 @@ Restart REAPER (or run the bridge once from the Action List) and add reaper-mcp
10964
11035
  if (!examples.installed.length && !examples.kept.length) console.log(ui.item("fail", `Not found: ${examplesDir}`));
10965
11036
  const wwwSrc = resolveAssetDir(__dirname2, "bridge-ui");
10966
11037
  console.log(ui.section("Installing bridge status UI..."));
10967
- if (existsSync12(join19(wwwSrc, BRIDGE_UI_FILE))) {
11038
+ if (existsSync13(join20(wwwSrc, BRIDGE_UI_FILE))) {
10968
11039
  const count = copyDirSync(wwwSrc, getReaperWwwPath());
10969
11040
  console.log(ui.item("ok", verbose ? `Installed: reaper_www_root/${BRIDGE_UI_FILE} (+${count - 1} PWA files)` : "Status page installed"));
10970
11041
  } else {
10971
- console.log(ui.item("fail", `Not found: ${join19(wwwSrc, BRIDGE_UI_FILE)} (build bridge-ui first)`));
11042
+ console.log(ui.item("fail", `Not found: ${join20(wwwSrc, BRIDGE_UI_FILE)} (build bridge-ui first)`));
10972
11043
  }
10973
11044
  installBridgeAutostart(scriptsDir);
10974
11045
  writeBridgeVersion(scriptsDir, readServiceVersion());
@@ -10976,12 +11047,12 @@ Restart REAPER (or run the bridge once from the Action List) and add reaper-mcp
10976
11047
  await registerSnapshotActions();
10977
11048
  console.log(`
10978
11049
  ${ui.mark("ok")} ${ui.bold("Setup complete!")}`);
10979
- if (await chainAfterSetup(webPort, join19(scriptsDir, "mcp_bridge.lua"))) return;
11050
+ if (await chainAfterSetup(webPort, join20(scriptsDir, "mcp_bridge.lua"))) return;
10980
11051
  console.log("");
10981
11052
  console.log(ui.heading("Next steps:"));
10982
11053
  console.log(` ${ui.bold("1.")} Start REAPER: the bridge starts with it. If REAPER is already open, restart it,`);
10983
11054
  console.log(" or run the bridge once by hand: Actions > Show action list > Load ReaScript,");
10984
- console.log(` select ${ui.dim(join19(scriptsDir, "mcp_bridge.lua"))} and click Run.`);
11055
+ console.log(` select ${ui.dim(join20(scriptsDir, "mcp_bridge.lua"))} and click Run.`);
10985
11056
  console.log(` ${ui.bold("2.")} Connect your AI harness: ${ui.cmd("reaper-mcp init")}, then check it with ${ui.cmd("reaper-mcp doctor")}`);
10986
11057
  if (webPort) {
10987
11058
  console.log(`
@@ -11045,8 +11116,8 @@ async function isReaperRunning() {
11045
11116
  }
11046
11117
  async function enableWebInterface() {
11047
11118
  console.log(ui.section("Enabling REAPER web interface..."));
11048
- const iniPath = join19(getReaperResourcePath(), "reaper.ini");
11049
- if (!existsSync12(iniPath)) {
11119
+ const iniPath = join20(getReaperResourcePath(), "reaper.ini");
11120
+ if (!existsSync13(iniPath)) {
11050
11121
  console.log(ui.item("warn", `Skipped: ${iniPath} not found (start REAPER once, quit it, then re-run setup)`));
11051
11122
  return null;
11052
11123
  }
@@ -11072,16 +11143,16 @@ async function enableWebInterface() {
11072
11143
  }
11073
11144
  function installBridgeAutostart(scriptsDir) {
11074
11145
  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") : "");
11146
+ const path = join20(scriptsDir, "__startup.lua");
11147
+ const { text: text8, changed } = ensureBridgeAutostart(existsSync13(path) ? readFileSync12(path, "utf-8") : "");
11077
11148
  if (changed) writeFileSync11(path, text8, "utf-8");
11078
11149
  console.log(ui.item("ok", changed ? "Added to Scripts/__startup.lua (REAPER runs it at launch)" : "Already in Scripts/__startup.lua"));
11079
11150
  console.log(ui.dim(" Turn it off in the bridge window: Settings > Start with REAPER."));
11080
11151
  }
11081
11152
  async function registerSnapshotActions() {
11082
11153
  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") : "";
11154
+ const kbPath = join20(getReaperResourcePath(), "reaper-kb.ini");
11155
+ const kb = existsSync13(kbPath) ? readFileSync12(kbPath, "utf-8") : "";
11085
11156
  const { added } = ensureSnapshotActions(kb);
11086
11157
  if (!added.length) {
11087
11158
  console.log(ui.item("ok", "Already in the Action List"));
@@ -11121,11 +11192,11 @@ async function init(chained = false) {
11121
11192
  for (const id of ids) {
11122
11193
  const h = HARNESSES.find((x) => x.id === id);
11123
11194
  if (id === "claude") {
11124
- const settingsPath = join19(homedir11(), ".claude", "settings.json");
11125
- mkdirSync12(dirname11(settingsPath), { recursive: true });
11195
+ const settingsPath = join20(homedir11(), ".claude", "settings.json");
11196
+ mkdirSync12(dirname12(settingsPath), { recursive: true });
11126
11197
  console.log(`${ui.mark("ok")} Claude settings (${MCP_TOOL_NAMES.length} REAPER tools allow-listed): ${ensureClaudeSettings(settingsPath)} \u2192 ${ui.dim(settingsPath.replace(homedir11(), "~"))}`);
11127
11198
  if (inClone) {
11128
- const mcpJsonPath = join19(process.cwd(), ".mcp.json");
11199
+ const mcpJsonPath = join20(process.cwd(), ".mcp.json");
11129
11200
  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
11201
  continue;
11131
11202
  }
@@ -11162,8 +11233,8 @@ function installSkills(dryRun = false, ids) {
11162
11233
  console.log("Running from a clone: scripts/sync-symlinks.sh links the skills and knowledge into ~/.claude and ~/.agents.");
11163
11234
  return;
11164
11235
  }
11165
- const src = join19(resolveAssetDir(__dirname2, "claude"));
11166
- if (!existsSync12(src)) {
11236
+ const src = join20(resolveAssetDir(__dirname2, "claude"));
11237
+ if (!existsSync13(src)) {
11167
11238
  console.log(`Skills not found: ${src} (this build has no claude/ folder)`);
11168
11239
  process.exitCode = 1;
11169
11240
  return;
@@ -11181,9 +11252,9 @@ function installSkills(dryRun = false, ids) {
11181
11252
  const homes = skillsHomes(targets.length ? targets : ["claude"]);
11182
11253
  const verb = dryRun ? "Would install" : "Installed";
11183
11254
  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" });
11255
+ if (homes.claude) jobs.push({ label: "~/.claude", dir: join20(homedir11(), ".claude"), what: "the mix skills, agents and knowledge" });
11256
+ if (homes.agents) jobs.push({ label: "~/.agents", dir: join20(homedir11(), ".agents"), include: ["skills", "agents"], what: "the mix skills and agents" });
11257
+ if (homes.agents && !homes.claude) jobs.push({ label: "~/.claude", dir: join20(homedir11(), ".claude"), include: ["knowledge"], what: "the knowledge base the skills read" });
11187
11258
  for (const job of jobs) {
11188
11259
  const r = installClaudeAssets(src, job.dir, { dryRun, include: job.include });
11189
11260
  console.log(`${ui.mark("ok")} ${verb} ${job.what} in ${job.label}: ${r.installed.length} new, ${r.updated.length} updated, ${r.unchanged} already current.`);
@@ -11236,25 +11307,25 @@ async function doctor() {
11236
11307
  core2.push(
11237
11308
  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" }
11238
11309
  );
11239
- const readIfExists = (path) => existsSync12(path) ? readFileSync12(path, "utf-8") : null;
11310
+ const readIfExists = (path) => existsSync13(path) ? readFileSync12(path, "utf-8") : null;
11240
11311
  core2.push(autostartCheck(
11241
- readIfExists(join19(getReaperScriptsPath(), "__startup.lua")),
11242
- readIfExists(join19(getReaperResourcePath(), "reaper-extstate.ini")),
11312
+ readIfExists(join20(getReaperScriptsPath(), "__startup.lua")),
11313
+ readIfExists(join20(getReaperResourcePath(), "reaper-extstate.ini")),
11243
11314
  await isReaperRunning()
11244
11315
  ));
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"));
11316
+ const globalClaudeDir = join20(homedir11(), ".claude");
11317
+ const localSkills = existsSync13(join20(process.cwd(), ".claude", "skills", "mixer", "SKILL.md"));
11318
+ const globalSkills = existsSync13(join20(globalClaudeDir, "skills", "mixer", "SKILL.md"));
11319
+ const sharedSkills = existsSync13(join20(homedir11(), ".agents", "skills", "mixer", "SKILL.md"));
11249
11320
  core2.push(
11250
11321
  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" }
11251
11322
  );
11252
- const localKnowledge = existsSync12(join19(process.cwd(), ".claude", "knowledge"));
11253
- const knowledgeLinked = localKnowledge || existsSync12(join19(globalClaudeDir, "knowledge"));
11323
+ const localKnowledge = existsSync13(join20(process.cwd(), ".claude", "knowledge"));
11324
+ const knowledgeLinked = localKnowledge || existsSync13(join20(globalClaudeDir, "knowledge"));
11254
11325
  core2.push(
11255
11326
  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" }
11256
11327
  );
11257
- const mcpJsonExists = existsSync12(join19(process.cwd(), ".mcp.json"));
11328
+ const mcpJsonExists = existsSync13(join20(process.cwd(), ".mcp.json"));
11258
11329
  const harnessEnv = realEnv();
11259
11330
  const installed = detectHarnesses(harnessEnv);
11260
11331
  const connected = installed.filter((h) => registeredServer(h.id, harnessEnv));
@@ -11277,11 +11348,11 @@ async function doctor() {
11277
11348
  status: "info",
11278
11349
  detail: { default: "On, pseudonymous \xB7 turn off: reaper-mcp telemetry off", custom: "Your own OTEL_* destination", off: "Off" }[telemetry]
11279
11350
  });
11280
- const sidecarVenvPath = join19(homedir11(), ".reaper-mcp", "sidecar-venv");
11351
+ const sidecarVenvPath = join20(homedir11(), ".reaper-mcp", "sidecar-venv");
11281
11352
  const venvBin = platform6() === "win32" ? "Scripts" : "bin";
11282
11353
  const venvPythonName = platform6() === "win32" ? "python.exe" : "python";
11283
- const venvPython = join19(sidecarVenvPath, venvBin, venvPythonName);
11284
- const hfCachePath = join19(homedir11(), ".cache", "huggingface", "hub");
11354
+ const venvPython = join20(sidecarVenvPath, venvBin, venvPythonName);
11355
+ const hfCachePath = join20(homedir11(), ".cache", "huggingface", "hub");
11285
11356
  let pythonOk = false;
11286
11357
  let pythonDetail = "Not found";
11287
11358
  try {
@@ -11298,9 +11369,9 @@ async function doctor() {
11298
11369
  } catch {
11299
11370
  pythonDetail = "Not found";
11300
11371
  }
11301
- const venvExists = existsSync12(sidecarVenvPath);
11372
+ const venvExists = existsSync13(sidecarVenvPath);
11302
11373
  let depsOk = false;
11303
- if (venvExists && existsSync12(venvPython)) {
11374
+ if (venvExists && existsSync13(venvPython)) {
11304
11375
  try {
11305
11376
  await execAsync(`"${venvPython}" -c "import audiobox_aesthetics.infer"`);
11306
11377
  depsOk = true;
@@ -11314,8 +11385,8 @@ async function doctor() {
11314
11385
  addOns.demucs = found.separation;
11315
11386
  addOns.lv_chordia = found.chords;
11316
11387
  }
11317
- const weightsPath = join19(hfCachePath, "models--facebook--audiobox-aesthetics");
11318
- const weightsExist = existsSync12(weightsPath);
11388
+ const weightsPath = join20(hfCachePath, "models--facebook--audiobox-aesthetics");
11389
+ const weightsExist = existsSync13(weightsPath);
11319
11390
  const sidecarReady = venvExists && depsOk;
11320
11391
  const sidecarOptedIn = venvExists;
11321
11392
  const sidecarBroken = sidecarOptedIn && !sidecarReady;
@@ -11471,6 +11542,17 @@ async function serve() {
11471
11542
  }
11472
11543
  });
11473
11544
  }
11545
+ async function updateCommand(force, bridge) {
11546
+ const cloneRoot = findCloneRoot(__dirname2);
11547
+ if (cloneRoot) {
11548
+ return new Promise((resolveCode) => {
11549
+ const child = spawn3("bash", ["./scripts/update.sh"], { cwd: cloneRoot, stdio: "inherit" });
11550
+ child.on("error", () => resolveCode(1));
11551
+ child.on("close", (code) => resolveCode(code ?? 1));
11552
+ });
11553
+ }
11554
+ return runUpdate(realUpdateDeps(readServiceVersion(), join20(__dirname2, "main.js"), force, bridge));
11555
+ }
11474
11556
  var command = process.argv[2];
11475
11557
  switch (command) {
11476
11558
  case "init":
@@ -11488,6 +11570,15 @@ switch (command) {
11488
11570
  process.exit(1);
11489
11571
  });
11490
11572
  break;
11573
+ case "update":
11574
+ updateCommand(process.argv.includes("--force"), process.argv.includes("--bridge")).then(
11575
+ (code) => process.exit(code),
11576
+ (err) => {
11577
+ console.error("Update failed:", err);
11578
+ process.exit(1);
11579
+ }
11580
+ );
11581
+ break;
11491
11582
  case "doctor":
11492
11583
  doctor().then(
11493
11584
  (code) => process.exit(code),
@@ -11554,6 +11645,7 @@ Usage:
11554
11645
  --harness claude,codex or --all to pick by hand. From npm it also installs the skills
11555
11646
  reaper-mcp install-skills Copy the mix skills, agents and knowledge into ~/.claude, and skills + agents into ~/.agents for the
11556
11647
  other harnesses (npm install; --harness to pick, --dry-run to preview)
11648
+ reaper-mcp update Update to the latest release (npm install: downloads it and installs it into REAPER; --force reinstalls)
11557
11649
  reaper-mcp doctor Check that everything is configured correctly
11558
11650
  reaper-mcp status Check if Lua bridge is running in REAPER
11559
11651
  reaper-mcp telemetry off Opt out of pseudonymous usage telemetry (also: on, status)