@mthines/reaper-mcp 0.93.1 → 0.94.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
@@ -307,6 +307,13 @@ var ALLOWED_SPAN_ATTRIBUTES = /* @__PURE__ */ new Set([
307
307
  "reaper.chords.source",
308
308
  "reaper.chords.count",
309
309
  "reaper.chords.engine",
310
+ // Which variant of a feature flag a call ran under (libs/feature-flags otel-hook.ts), so an experiment's
311
+ // arms can be compared: the flag key, the provider's name, the variant key and the reason it resolved
312
+ // that way (static, split, override, error). Never the targeting key (the install id).
313
+ "feature_flag.key",
314
+ "feature_flag.provider.name",
315
+ "feature_flag.result.variant",
316
+ "feature_flag.result.reason",
310
317
  // opt-in/opt-out counts: on or off, and where the choice was made
311
318
  "reaper.telemetry.consent.state",
312
319
  "reaper.telemetry.consent.source",
@@ -2212,17 +2219,18 @@ import { z as z10 } from "zod/v4";
2212
2219
  function registerSnapshotTools(server) {
2213
2220
  server.tool(
2214
2221
  "snapshot_save",
2215
- "Save the current mixer state as a named snapshot. Stored in .reaper-mcp/snapshots/ alongside the project file (falls back to global bridge dir for unsaved projects). By default captures ALL tracks' volumes, pans, mutes, solos, FX bypass/offline states, full FX parameter values, preset names, track names/colors, and send levels. Pass trackIndices to scope the snapshot to specific tracks (e.g. just the master bus for an A/B that never touches other tracks). Pass fullChunk (or rely on its default-on when scoped) to capture exact track state chunks, which faithfully reproduce each plugin's internal state on restore \u2014 including plugins whose tone is driven by internal snapshots (e.g. Helix Native) that parameter-value capture cannot reproduce. Response includes storageLocation, scoped, fullChunk, and tracksCaptured.",
2222
+ "Save the current mixer state as a named snapshot. Stored in .reaper-mcp/snapshots/ alongside the project file (falls back to global bridge dir for unsaved projects). By default captures ALL tracks' volumes, pans, mutes, solos, FX bypass/offline states, full FX parameter values, preset names, track names/colors, and send levels. Pass trackIndices to scope the snapshot to specific tracks (e.g. just the master bus for an A/B that never touches other tracks). Pass fullChunk (or rely on its default-on when scoped) to capture exact track state chunks, which faithfully reproduce each plugin's internal state on restore \u2014 including plugins whose tone is driven by internal snapshots (e.g. Helix Native) that parameter-value capture cannot reproduce. Pass stretchMarkers to also keep the stretch markers of every audio item on the captured tracks (an alignment or a stretch edit): they are stored on their own, so they come back even where REAPER refuses to apply a track chunk (seen on tracks whose items carry Melodyne take FX). A fullChunk snapshot also holds each track's items (the whole chunk comes back on restore); without fullChunk a snapshot holds no items, only the stretch markers when asked for. Response includes storageLocation, scoped, fullChunk, tracksCaptured, and stretchMarkerItems.",
2216
2223
  {
2217
2224
  name: z10.string().min(1).describe('Unique snapshot name (e.g. "before-compression", "v1-mix")'),
2218
2225
  description: z10.string().optional().describe("Optional human-readable description"),
2219
2226
  includeFxParams: z10.boolean().optional().default(true).describe("Include FX parameter values in snapshot (default true). Only applies to non-chunk capture."),
2220
2227
  maxParamsPerFx: z10.coerce.number().int().min(1).max(2e3).optional().default(500).describe("Max parameters to capture per FX plugin (default 500). Only applies to non-chunk capture."),
2221
2228
  trackIndices: z10.array(z10.coerce.number().int().min(0)).optional().describe("Restrict the snapshot to these 0-based track indices. Omit to capture all tracks. Restoring a scoped snapshot only affects the listed tracks."),
2222
- fullChunk: z10.boolean().optional().describe("Capture exact track state chunks (complete FX internal state, e.g. Helix Native snapshots) instead of parameter values. Defaults to true when trackIndices is set, false otherwise (whole-project chunk snapshots are large).")
2229
+ fullChunk: z10.boolean().optional().describe("Capture exact track state chunks (complete FX internal state, e.g. Helix Native snapshots) instead of parameter values. Defaults to true when trackIndices is set, false otherwise (whole-project chunk snapshots are large)."),
2230
+ stretchMarkers: z10.boolean().optional().describe("Also keep the stretch markers of every audio item on the captured tracks (default false). Restoring puts them back on the same items (found by GUID, else by track, position and length). Up to 5000 audio items: scope with trackIndices for a big project.")
2223
2231
  },
2224
- async ({ name, description, includeFxParams, maxParamsPerFx, trackIndices, fullChunk }) => {
2225
- const res = await sendCommand("snapshot_save", { name, description, includeFxParams, maxParamsPerFx, trackIndices, fullChunk });
2232
+ async ({ name, description, includeFxParams, maxParamsPerFx, trackIndices, fullChunk, stretchMarkers }) => {
2233
+ const res = await sendCommand("snapshot_save", { name, description, includeFxParams, maxParamsPerFx, trackIndices, fullChunk, stretchMarkers });
2226
2234
  if (!res.success) {
2227
2235
  return { content: [{ type: "text", text: `Error: ${res.error}` }], isError: true };
2228
2236
  }
@@ -2231,14 +2239,15 @@ function registerSnapshotTools(server) {
2231
2239
  );
2232
2240
  server.tool(
2233
2241
  "snapshot_restore",
2234
- "Restore a previously saved mixer snapshot by name. Reads from .reaper-mcp/snapshots/ alongside the project file (falls back to global bridge dir for unsaved projects). For chunk-based snapshots (saved with fullChunk), restores each captured track exactly via its state chunk \u2014 reproducing complete FX internal state (incl. plugin internal snapshots like Helix Native) and affecting only the tracks the snapshot captured. For parameter-based snapshots, restores volumes, pans, mutes, solos, FX bypass states, and FX parameters (parameters only when the plugin name matches, to avoid applying wrong values).",
2242
+ "Restore a previously saved mixer snapshot by name. Reads from .reaper-mcp/snapshots/ alongside the project file (falls back to global bridge dir for unsaved projects). For chunk-based snapshots (saved with fullChunk), restores each captured track exactly via its state chunk \u2014 reproducing complete FX internal state (incl. plugin internal snapshots like Helix Native) and affecting only the tracks the snapshot captured. For parameter-based snapshots, restores volumes, pans, mutes, solos, FX bypass states, and FX parameters (parameters only when the plugin name matches, to avoid applying wrong values). Stretch markers saved with the snapshot are put back on their items afterwards, also when a track chunk could not be applied (the reply field stretchMarkers counts restored, unchanged and missing items).",
2235
2243
  {
2236
2244
  name: z10.string().min(1).describe("Name of the snapshot to restore"),
2237
2245
  restoreTrackMeta: z10.boolean().optional().default(false).describe("Also restore track names and colors (default false)"),
2238
- restoreSendLevels: z10.boolean().optional().default(true).describe("Restore send volume/pan/mute for existing sends (default true)")
2246
+ restoreSendLevels: z10.boolean().optional().default(true).describe("Restore send volume/pan/mute for existing sends (default true)"),
2247
+ restoreStretchMarkers: z10.boolean().optional().default(true).describe("Put back the stretch markers saved with the snapshot (default true; only snapshots saved with stretchMarkers hold any)")
2239
2248
  },
2240
- async ({ name, restoreTrackMeta, restoreSendLevels }) => {
2241
- const res = await sendCommand("snapshot_restore", { name, restoreTrackMeta, restoreSendLevels });
2249
+ async ({ name, restoreTrackMeta, restoreSendLevels, restoreStretchMarkers }) => {
2250
+ const res = await sendCommand("snapshot_restore", { name, restoreTrackMeta, restoreSendLevels, restoreStretchMarkers });
2242
2251
  if (!res.success) {
2243
2252
  return { content: [{ type: "text", text: `Error: ${res.error}` }], isError: true };
2244
2253
  }
@@ -3083,6 +3092,21 @@ function registerSelectionTools(server) {
3083
3092
  return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
3084
3093
  }
3085
3094
  );
3095
+ server.tool(
3096
+ "get_selected_items",
3097
+ 'Get the media items selected right now, as {trackIndex, itemIndex} (the indexes list_media_items and the item tools use) with the track name, position and length in seconds, and mute. Use it when the user says "the selected items", instead of guessing which tracks they mean. Paged: returns {total, hasMore, items}; pass offset to read on.',
3098
+ {
3099
+ offset: z15.coerce.number().int().min(0).optional().default(0).describe("Selected items to skip"),
3100
+ limit: z15.coerce.number().int().min(1).max(1e3).optional().default(200).describe("Most items to return")
3101
+ },
3102
+ async ({ offset, limit }) => {
3103
+ const res = await sendCommand("get_selected_items", { offset, limit });
3104
+ if (!res.success) {
3105
+ return { content: [{ type: "text", text: `Error: ${res.error}` }], isError: true };
3106
+ }
3107
+ return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
3108
+ }
3109
+ );
3086
3110
  server.tool(
3087
3111
  "set_selected_items",
3088
3112
  "Select media items by track and item index (as list_media_items reports them) \u2014 usually before run_action. Every item is resolved first: a missing one changes nothing. Returns the selection afterwards.",
@@ -4319,7 +4343,7 @@ var TOOL_CATEGORIES = {
4319
4343
  selection: {
4320
4344
  name: "selection",
4321
4345
  description: "Selection and navigation: get/set selected tracks and items, get/set time selection range",
4322
- tools: ["get_selected_tracks", "set_selected_tracks", "set_selected_items", "get_time_selection", "set_time_selection"]
4346
+ tools: ["get_selected_tracks", "set_selected_tracks", "get_selected_items", "set_selected_items", "get_time_selection", "set_time_selection"]
4323
4347
  },
4324
4348
  recording: {
4325
4349
  name: "recording",
@@ -4533,8 +4557,8 @@ var PROFILES = {
4533
4557
  minimal: ["project", "tracks", "fx", "transport", "discovery", "selection"],
4534
4558
  /** Mixing and mastering: measure, set levels and FX, route, automate, snapshot, render. */
4535
4559
  mixing: ["project", "tracks", "fx", "fx_files", "transport", "discovery", "selection", "routing", "plan", "analysis", "snapshots", "envelopes", "actions", "knowledge", "recording"],
4536
- /** Writing and editing music and arrangements (no takes or actions). Adding categories or an extension, e.g. `mixing,composition`, can push a profile past 128. */
4537
- music: ["project", "tracks", "fx", "transport", "discovery", "selection", "midi", "media", "arrange", "markers", "tempo", "envelopes", "plan"],
4560
+ /** Writing and editing music and arrangements (no takes, actions or envelopes). Adding categories or an extension, e.g. `mixing,composition`, can push a profile past 128. */
4561
+ music: ["project", "tracks", "fx", "transport", "discovery", "selection", "midi", "media", "arrange", "markers", "tempo", "plan"],
4538
4562
  /** Inspect and measure; the tracks and project categories still hold a few writers, so this is not read-only. */
4539
4563
  analysis: ["project", "tracks", "transport", "discovery", "selection", "routing", "markers", "tempo", "analysis", "knowledge"]
4540
4564
  };
@@ -4908,6 +4932,7 @@ var MCP_TOOL_NAMES = [
4908
4932
  "process_items",
4909
4933
  // selection & navigation
4910
4934
  "get_selected_tracks",
4935
+ "get_selected_items",
4911
4936
  "get_time_selection",
4912
4937
  "set_time_selection",
4913
4938
  // markers & regions
@@ -10351,18 +10376,415 @@ Try it: reaper-mcp extension link ${basename4(r.dir)}`);
10351
10376
  }
10352
10377
  }
10353
10378
 
10379
+ // apps/reaper-mcp-server/src/flags.ts
10380
+ import { mkdirSync as mkdirSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync6 } from "node:fs";
10381
+ import { homedir as homedir9 } from "node:os";
10382
+ import { join as join13 } from "node:path";
10383
+
10384
+ // libs/feature-flags/src/bucketing.ts
10385
+ function fnv1aHash(input) {
10386
+ let hash = 2166136261;
10387
+ for (let i = 0; i < input.length; i++) {
10388
+ hash ^= input.charCodeAt(i);
10389
+ hash = Math.imul(hash, 16777619);
10390
+ }
10391
+ return hash >>> 0;
10392
+ }
10393
+ function bucketOf(flagKey, targetingKey) {
10394
+ return fnv1aHash(`${flagKey}:${targetingKey}`) % 100;
10395
+ }
10396
+ function assignExperimentVariant(flagKey, experiment, targetingKey) {
10397
+ const bucket = bucketOf(flagKey, targetingKey);
10398
+ let cumulative = 0;
10399
+ for (const variant of experiment.variants) {
10400
+ cumulative += variant.weight;
10401
+ if (bucket < cumulative) return variant.key;
10402
+ }
10403
+ return experiment.variants[experiment.variants.length - 1].key;
10404
+ }
10405
+
10406
+ // libs/feature-flags/src/schema.ts
10407
+ import { z as z39 } from "zod/v4";
10408
+ var FLAG_KEY_PATTERN = /^[a-z][a-z0-9-]*$/;
10409
+ var FlagTypeSchema = z39.enum(["boolean", "string", "number", "object"]);
10410
+ var ExperimentVariantSchema = z39.object({
10411
+ key: z39.string().min(1),
10412
+ description: z39.string().optional(),
10413
+ weight: z39.number().min(0).max(100)
10414
+ });
10415
+ var ExperimentSchema = z39.object({
10416
+ enabled: z39.boolean().default(false),
10417
+ variants: z39.array(ExperimentVariantSchema).min(2)
10418
+ }).superRefine((experiment, ctx) => {
10419
+ const total = experiment.variants.reduce((sum, v) => sum + v.weight, 0);
10420
+ if (Math.abs(total - 100) > 1e-3) {
10421
+ ctx.addIssue({
10422
+ code: "custom",
10423
+ message: `experiment.variants weights must sum to 100, got ${total}`
10424
+ });
10425
+ }
10426
+ const keys = experiment.variants.map((v) => v.key);
10427
+ if (new Set(keys).size !== keys.length) {
10428
+ ctx.addIssue({ code: "custom", message: "experiment.variants keys must be unique" });
10429
+ }
10430
+ });
10431
+ var jsonValue = z39.lazy(
10432
+ () => z39.union([z39.boolean(), z39.string(), z39.number(), z39.null(), z39.array(jsonValue), z39.record(z39.string(), jsonValue)])
10433
+ );
10434
+ var FlagDefinitionSchema = z39.object({
10435
+ key: z39.string().regex(FLAG_KEY_PATTERN, 'flag key must be kebab-case (e.g. "example-new-panel")'),
10436
+ description: z39.string().min(1),
10437
+ type: FlagTypeSchema,
10438
+ /** Variant key -> the value returned for that variant. Must include `defaultVariant`. */
10439
+ variants: z39.record(z39.string(), jsonValue),
10440
+ defaultVariant: z39.string().min(1),
10441
+ /** Optional A/B(/n) experiment. Every `experiment.variants[].key` must exist in `variants`. */
10442
+ experiment: ExperimentSchema.optional(),
10443
+ /** Who owns the flag, surfaced in the manifest for cleanup audits. */
10444
+ owner: z39.string().min(1),
10445
+ tags: z39.array(z39.string()).default([])
10446
+ }).superRefine((def, ctx) => {
10447
+ if (!Object.hasOwn(def.variants, def.defaultVariant)) {
10448
+ ctx.addIssue({
10449
+ code: "custom",
10450
+ path: ["defaultVariant"],
10451
+ message: `defaultVariant "${def.defaultVariant}" is not a key of variants`
10452
+ });
10453
+ }
10454
+ for (const variant of def.experiment?.variants ?? []) {
10455
+ if (!Object.hasOwn(def.variants, variant.key)) {
10456
+ ctx.addIssue({
10457
+ code: "custom",
10458
+ path: ["experiment", "variants"],
10459
+ message: `experiment variant "${variant.key}" is not a key of variants`
10460
+ });
10461
+ }
10462
+ }
10463
+ if (Object.values(def.variants).some((v) => typeof v !== def.type)) {
10464
+ ctx.addIssue({
10465
+ code: "custom",
10466
+ path: ["variants"],
10467
+ message: `all variant values must be of declared type "${def.type}"`
10468
+ });
10469
+ }
10470
+ });
10471
+ var FlagRegistrySchema = z39.array(FlagDefinitionSchema).superRefine((defs, ctx) => {
10472
+ const keys = defs.map((d) => d.key);
10473
+ const dupes = keys.filter((k, i) => keys.indexOf(k) !== i);
10474
+ if (dupes.length > 0) {
10475
+ ctx.addIssue({ code: "custom", message: `duplicate flag keys: ${[...new Set(dupes)].join(", ")}` });
10476
+ }
10477
+ });
10478
+ function parseRegistry(input) {
10479
+ const result = FlagRegistrySchema.safeParse(input);
10480
+ if (!result.success) {
10481
+ throw new Error(
10482
+ `Invalid @reaper-mcp/feature-flags registry:
10483
+ ${result.error.issues.map((i) => ` - ${i.path.join(".")}: ${i.message}`).join("\n")}`
10484
+ );
10485
+ }
10486
+ return result.data;
10487
+ }
10488
+
10489
+ // libs/feature-flags/src/registry.ts
10490
+ var REGISTRY_INPUT = [];
10491
+ var FLAG_REGISTRY = parseRegistry(REGISTRY_INPUT);
10492
+
10493
+ // libs/feature-flags/src/resolve.ts
10494
+ function resolveFlag(def, context = {}) {
10495
+ const forced = context.overrides?.[def.key];
10496
+ if (forced !== void 0 && Object.hasOwn(def.variants, forced)) {
10497
+ return { variant: forced, value: def.variants[forced], reason: "override" };
10498
+ }
10499
+ if (def.experiment?.enabled) {
10500
+ const key = typeof context.targetingKey === "function" ? context.targetingKey() : context.targetingKey;
10501
+ if (key) {
10502
+ const variant = assignExperimentVariant(def.key, def.experiment, key);
10503
+ return { variant, value: def.variants[variant], reason: "split" };
10504
+ }
10505
+ }
10506
+ return { variant: def.defaultVariant, value: def.variants[def.defaultVariant], reason: "static" };
10507
+ }
10508
+
10509
+ // libs/feature-flags/src/overrides.ts
10510
+ var FLAG_OVERRIDES_CONTEXT_KEY = "flagOverrides";
10511
+ function sanitizeFlagOverrides(parsed, registry = FLAG_REGISTRY) {
10512
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return {};
10513
+ const valid = {};
10514
+ for (const [key, value] of Object.entries(parsed)) {
10515
+ if (typeof value !== "string") continue;
10516
+ const def = registry.find((f) => f.key === key);
10517
+ if (!def || !Object.hasOwn(def.variants, value)) continue;
10518
+ valid[key] = value;
10519
+ }
10520
+ return valid;
10521
+ }
10522
+
10523
+ // libs/feature-flags/src/otel-attributes.ts
10524
+ var ATTR_FEATURE_FLAG_KEY = "feature_flag.key";
10525
+ var ATTR_FEATURE_FLAG_PROVIDER_NAME = "feature_flag.provider.name";
10526
+ var ATTR_FEATURE_FLAG_RESULT_VARIANT = "feature_flag.result.variant";
10527
+ var ATTR_FEATURE_FLAG_RESULT_REASON = "feature_flag.result.reason";
10528
+ var EVENT_FEATURE_FLAG_EVALUATION = "feature_flag.evaluation";
10529
+ function flagReasonValue(reason) {
10530
+ return reason ? reason.toLowerCase() : "unknown";
10531
+ }
10532
+
10533
+ // libs/feature-flags/src/client.ts
10534
+ import {
10535
+ OpenFeature
10536
+ } from "@openfeature/server-sdk";
10537
+
10538
+ // libs/feature-flags/src/otel-hook.ts
10539
+ import { trace as trace11 } from "@opentelemetry/api";
10540
+ function stampSpan(span, attrs) {
10541
+ for (const [key, value] of Object.entries(attrs)) span.setAttribute(key, value);
10542
+ span.addEvent(EVENT_FEATURE_FLAG_EVALUATION, attrs);
10543
+ }
10544
+ function baseAttributes(hookContext) {
10545
+ return {
10546
+ [ATTR_FEATURE_FLAG_KEY]: hookContext.flagKey,
10547
+ [ATTR_FEATURE_FLAG_PROVIDER_NAME]: hookContext.providerMetadata.name
10548
+ };
10549
+ }
10550
+ var featureFlagOtelHook = {
10551
+ after(hookContext, details) {
10552
+ const span = trace11.getActiveSpan();
10553
+ if (!span) return;
10554
+ const attrs = baseAttributes(hookContext);
10555
+ if (details.variant) attrs[ATTR_FEATURE_FLAG_RESULT_VARIANT] = details.variant;
10556
+ attrs[ATTR_FEATURE_FLAG_RESULT_REASON] = flagReasonValue(details.reason);
10557
+ stampSpan(span, attrs);
10558
+ },
10559
+ error(hookContext, error7) {
10560
+ const span = trace11.getActiveSpan();
10561
+ if (!span) return;
10562
+ stampSpan(span, baseAttributes(hookContext));
10563
+ if (error7 instanceof Error) span.recordException(error7);
10564
+ }
10565
+ };
10566
+
10567
+ // libs/feature-flags/src/provider.ts
10568
+ import { ErrorCode, StandardResolutionReasons } from "@openfeature/server-sdk";
10569
+ var PROVIDER_NAME = "reaper-mcp-flags";
10570
+ var REASONS = {
10571
+ override: "OVERRIDE",
10572
+ split: StandardResolutionReasons.SPLIT,
10573
+ static: StandardResolutionReasons.STATIC
10574
+ };
10575
+ var FlagProvider = class {
10576
+ constructor(registry = FLAG_REGISTRY) {
10577
+ this.registry = registry;
10578
+ }
10579
+ metadata = { name: PROVIDER_NAME };
10580
+ async resolveBooleanEvaluation(key, fallback, context) {
10581
+ return this.resolveFor(key, fallback, context, "boolean");
10582
+ }
10583
+ async resolveStringEvaluation(key, fallback, context) {
10584
+ return this.resolveFor(key, fallback, context, "string");
10585
+ }
10586
+ async resolveNumberEvaluation(key, fallback, context) {
10587
+ return this.resolveFor(key, fallback, context, "number");
10588
+ }
10589
+ async resolveObjectEvaluation(key, fallback, context) {
10590
+ return this.resolveFor(key, fallback, context, "object");
10591
+ }
10592
+ resolveFor(key, fallback, context, type) {
10593
+ const def = this.registry.find((f) => f.key === key);
10594
+ if (!def) {
10595
+ return { value: fallback, reason: StandardResolutionReasons.ERROR, errorCode: ErrorCode.FLAG_NOT_FOUND };
10596
+ }
10597
+ if (def.type !== type) {
10598
+ return {
10599
+ value: fallback,
10600
+ reason: StandardResolutionReasons.ERROR,
10601
+ errorCode: ErrorCode.TYPE_MISMATCH,
10602
+ errorMessage: `flag "${def.key}" is type "${def.type}", not "${type}"`
10603
+ };
10604
+ }
10605
+ const overrides = sanitizeFlagOverrides(context[FLAG_OVERRIDES_CONTEXT_KEY], this.registry);
10606
+ const resolved = resolveFlag(def, { targetingKey: context.targetingKey, overrides });
10607
+ return { value: resolved.value, variant: resolved.variant, reason: REASONS[resolved.reason] };
10608
+ }
10609
+ };
10610
+
10611
+ // libs/feature-flags/src/client.ts
10612
+ var DEFAULT_DOMAIN = "reaper-mcp-feature-flags";
10613
+ var clients = /* @__PURE__ */ new Map();
10614
+ function createFlagClient(registry = FLAG_REGISTRY, domain = DEFAULT_DOMAIN) {
10615
+ let client = clients.get(domain);
10616
+ if (!client) {
10617
+ OpenFeature.setProvider(domain, new FlagProvider(registry));
10618
+ client = OpenFeature.getClient(domain);
10619
+ client.addHooks(featureFlagOtelHook);
10620
+ clients.set(domain, client);
10621
+ }
10622
+ return client;
10623
+ }
10624
+ async function evaluateDefinition(client, def, context = {}) {
10625
+ const fallback = def.variants[def.defaultVariant];
10626
+ switch (def.type) {
10627
+ case "boolean":
10628
+ return client.getBooleanDetails(def.key, fallback, context);
10629
+ case "string":
10630
+ return client.getStringDetails(def.key, fallback, context);
10631
+ case "number":
10632
+ return client.getNumberDetails(def.key, fallback, context);
10633
+ case "object":
10634
+ return client.getObjectDetails(def.key, fallback, context);
10635
+ }
10636
+ }
10637
+
10638
+ // apps/reaper-mcp-server/src/flags.ts
10639
+ var FLAGS_FILE = "flags.json";
10640
+ var FLAGS_ENV = "REAPER_MCP_FLAGS";
10641
+ function defaultFlagsDir() {
10642
+ return join13(homedir9(), ".config", "reaper-mcp");
10643
+ }
10644
+ function parseJson(raw) {
10645
+ try {
10646
+ return JSON.parse(raw);
10647
+ } catch {
10648
+ return void 0;
10649
+ }
10650
+ }
10651
+ function readFlagOverrides(dir = defaultFlagsDir(), env = process.env, registry = FLAG_REGISTRY) {
10652
+ let fromFile;
10653
+ try {
10654
+ fromFile = parseJson(readFileSync6(join13(dir, FLAGS_FILE), "utf-8"));
10655
+ } catch {
10656
+ fromFile = void 0;
10657
+ }
10658
+ const fromEnv = env[FLAGS_ENV] ? parseJson(env[FLAGS_ENV]) : void 0;
10659
+ return { ...sanitizeFlagOverrides(fromFile, registry), ...sanitizeFlagOverrides(fromEnv, registry) };
10660
+ }
10661
+ function writeFlagOverrides(overrides, dir = defaultFlagsDir()) {
10662
+ mkdirSync7(dir, { recursive: true });
10663
+ writeFileSync6(join13(dir, FLAGS_FILE), JSON.stringify(overrides, null, 2) + "\n", "utf-8");
10664
+ }
10665
+ function createServerFlags(options = {}) {
10666
+ const registry = options.registry ?? FLAG_REGISTRY;
10667
+ const installId = options.installId ?? (() => readInstallId());
10668
+ const context = (withTargetingKey = true) => {
10669
+ const targetingKey = withTargetingKey ? installId() : void 0;
10670
+ return {
10671
+ ...targetingKey && { targetingKey },
10672
+ flagOverrides: readFlagOverrides(options.dir, options.env, registry)
10673
+ };
10674
+ };
10675
+ const client = () => createFlagClient(registry, options.domain);
10676
+ return {
10677
+ context,
10678
+ async details(key) {
10679
+ const def = registry.find((f) => f.key === key);
10680
+ if (!def) throw new Error(`unknown flag "${key}"`);
10681
+ return evaluateDefinition(client(), def, context(def.experiment?.enabled === true));
10682
+ },
10683
+ rows() {
10684
+ const { flagOverrides } = context(false);
10685
+ return registry.map((def) => {
10686
+ const resolved = resolveFlag(def, { targetingKey: installId, overrides: flagOverrides });
10687
+ return {
10688
+ key: def.key,
10689
+ variant: resolved.variant,
10690
+ reason: resolved.reason,
10691
+ ...flagOverrides[def.key] !== void 0 && { override: flagOverrides[def.key] },
10692
+ ...def.experiment && {
10693
+ experiment: {
10694
+ enabled: def.experiment.enabled,
10695
+ split: def.experiment.variants.map((v) => `${v.key} ${v.weight}%`).join(" / ")
10696
+ }
10697
+ },
10698
+ description: def.description
10699
+ };
10700
+ });
10701
+ }
10702
+ };
10703
+ }
10704
+ function flagOverrideCheck(options = {}) {
10705
+ const forced = createServerFlags(options).rows().filter((r) => r.override !== void 0);
10706
+ if (forced.length === 0) return void 0;
10707
+ return {
10708
+ label: "Feature flags",
10709
+ status: "warn",
10710
+ detail: `${forced.length} forced on this install: ${forced.map((r) => `${r.key}=${r.override}`).join(", ")}`,
10711
+ fix: "reaper-mcp flags reset (forced flags can be unfinished and break things)"
10712
+ };
10713
+ }
10714
+ var defaultFlags = createServerFlags();
10715
+ var USAGE = [
10716
+ "Usage:",
10717
+ " reaper-mcp flags list Every flag, how it resolves for this install, and why",
10718
+ " reaper-mcp flags set <key> <variant> Force a variant on this install only",
10719
+ " reaper-mcp flags reset [key] Drop one override, or all of them"
10720
+ ];
10721
+ function flagsCommand(args, options = {}) {
10722
+ const io = options.io ?? { log: console.log, error: console.error };
10723
+ const registry = options.registry ?? FLAG_REGISTRY;
10724
+ const dir = options.dir ?? defaultFlagsDir();
10725
+ const flags = createServerFlags({ ...options, registry, dir });
10726
+ const [sub = "list", key, variant] = args;
10727
+ if (sub === "list") {
10728
+ const rows = flags.rows();
10729
+ if (rows.length === 0) {
10730
+ io.log("No feature flags are declared.");
10731
+ return 0;
10732
+ }
10733
+ for (const row of rows) {
10734
+ const note = row.override ? " (override)" : row.experiment?.enabled ? ` (experiment: ${row.experiment.split})` : "";
10735
+ io.log(`${row.key} ${row.variant} reason=${row.reason}${note}`);
10736
+ io.log(` ${row.description}`);
10737
+ }
10738
+ return 0;
10739
+ }
10740
+ if (sub === "set") {
10741
+ if (!key || !variant) {
10742
+ io.error(USAGE.join("\n"));
10743
+ return 1;
10744
+ }
10745
+ const def = registry.find((f) => f.key === key);
10746
+ if (!def) {
10747
+ io.error(`Unknown flag "${key}". Known flags: ${registry.map((f) => f.key).join(", ") || "none"}.`);
10748
+ return 1;
10749
+ }
10750
+ if (!Object.hasOwn(def.variants, variant)) {
10751
+ io.error(`"${variant}" is not a variant of ${key}. Variants: ${Object.keys(def.variants).join(", ")}.`);
10752
+ return 1;
10753
+ }
10754
+ const stored = readFlagOverrides(dir, {}, registry);
10755
+ writeFlagOverrides({ ...stored, [key]: variant }, dir);
10756
+ io.log(`${key} forced to "${variant}" on this install. It applies from the next evaluation, no restart needed.`);
10757
+ io.log(`Forcing a flag is unsupported: it may be unfinished and break things. Undo it with: reaper-mcp flags reset ${key}`);
10758
+ return 0;
10759
+ }
10760
+ if (sub === "reset") {
10761
+ const stored = readFlagOverrides(dir, {}, registry);
10762
+ if (key) {
10763
+ const { [key]: dropped, ...rest } = stored;
10764
+ writeFlagOverrides(rest, dir);
10765
+ io.log(dropped === void 0 ? `${key} had no override.` : `${key} override removed.`);
10766
+ } else {
10767
+ writeFlagOverrides({}, dir);
10768
+ io.log("All flag overrides removed.");
10769
+ }
10770
+ return 0;
10771
+ }
10772
+ io.error(USAGE.join("\n"));
10773
+ return 1;
10774
+ }
10775
+
10354
10776
  // apps/reaper-mcp-server/src/main.ts
10355
- import { existsSync as existsSync13, mkdirSync as mkdirSync12, readFileSync as readFileSync13, realpathSync, rmSync as rmSync3, writeFileSync as writeFileSync11 } from "node:fs";
10356
- import { join as join20, dirname as dirname12, resolve as resolve3 } from "node:path";
10777
+ import { existsSync as existsSync13, mkdirSync as mkdirSync13, readFileSync as readFileSync14, realpathSync, rmSync as rmSync3, writeFileSync as writeFileSync12 } from "node:fs";
10778
+ import { join as join21, dirname as dirname12, resolve as resolve3 } from "node:path";
10357
10779
  import { fileURLToPath as fileURLToPath6 } from "node:url";
10358
- import { homedir as homedir11, platform as platform6 } from "node:os";
10780
+ import { homedir as homedir12, platform as platform6 } from "node:os";
10359
10781
  import { exec as execCb, spawn as spawn3 } from "node:child_process";
10360
10782
  import { promisify as promisifyUtil } from "node:util";
10361
10783
 
10362
10784
  // apps/reaper-mcp-server/src/update.ts
10363
10785
  import { spawn as spawn2 } from "node:child_process";
10364
- import { dirname as dirname10, join as join15 } from "node:path";
10365
- import { existsSync as existsSync9, readFileSync as readFileSync8 } from "node:fs";
10786
+ import { dirname as dirname10, join as join16 } from "node:path";
10787
+ import { existsSync as existsSync9, readFileSync as readFileSync9 } from "node:fs";
10366
10788
 
10367
10789
  // apps/reaper-mcp-server/src/version.ts
10368
10790
  function compareVersions(a, b) {
@@ -10376,14 +10798,14 @@ function compareVersions(a, b) {
10376
10798
  }
10377
10799
 
10378
10800
  // 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";
10801
+ import { mkdirSync as mkdirSync8, readFileSync as readFileSync7, writeFileSync as writeFileSync7 } from "node:fs";
10802
+ import { dirname as dirname8, join as join14 } from "node:path";
10803
+ import { homedir as homedir10 } from "node:os";
10382
10804
  var NPM_PACKAGE = "@mthines/reaper-mcp";
10383
10805
  var PACKAGE_URL = "https://registry.npmjs.org/@mthines%2Freaper-mcp";
10384
10806
  var DAY_MS = 24 * 60 * 60 * 1e3;
10385
10807
  function defaultUpdateStatePath() {
10386
- return join13(homedir9(), ".reaper-mcp", "update-check.json");
10808
+ return join14(homedir10(), ".reaper-mcp", "update-check.json");
10387
10809
  }
10388
10810
  function updateCheckDisabled(env = process.env) {
10389
10811
  const setting = (env["REAPER_MCP_UPDATE_CHECK"] ?? "").trim().toLowerCase();
@@ -10408,7 +10830,7 @@ function updateNotice(current, latest) {
10408
10830
  }
10409
10831
  function readState(path) {
10410
10832
  try {
10411
- const s = JSON.parse(readFileSync6(path, "utf-8"));
10833
+ const s = JSON.parse(readFileSync7(path, "utf-8"));
10412
10834
  return s && typeof s === "object" ? s : {};
10413
10835
  } catch {
10414
10836
  return {};
@@ -10416,8 +10838,8 @@ function readState(path) {
10416
10838
  }
10417
10839
  function writeState(path, state) {
10418
10840
  try {
10419
- mkdirSync7(dirname8(path), { recursive: true });
10420
- writeFileSync6(path, JSON.stringify(state) + "\n", "utf-8");
10841
+ mkdirSync8(dirname8(path), { recursive: true });
10842
+ writeFileSync7(path, JSON.stringify(state) + "\n", "utf-8");
10421
10843
  } catch {
10422
10844
  }
10423
10845
  }
@@ -10441,9 +10863,9 @@ async function checkForUpdate(opts) {
10441
10863
 
10442
10864
  // apps/reaper-mcp-server/src/harnesses.ts
10443
10865
  import { execFileSync } from "node:child_process";
10444
- import { existsSync as existsSync8, mkdirSync as mkdirSync8, readFileSync as readFileSync7, writeFileSync as writeFileSync7 } from "node:fs";
10445
- import { delimiter, dirname as dirname9, isAbsolute as isAbsolute3, join as join14 } from "node:path";
10446
- import { homedir as homedir10, platform as platform4 } from "node:os";
10866
+ import { existsSync as existsSync8, mkdirSync as mkdirSync9, readFileSync as readFileSync8, writeFileSync as writeFileSync8 } from "node:fs";
10867
+ import { delimiter, dirname as dirname9, isAbsolute as isAbsolute3, join as join15 } from "node:path";
10868
+ import { homedir as homedir11, platform as platform4 } from "node:os";
10447
10869
  var HARNESSES = [
10448
10870
  { id: "claude", name: "Claude Code", binary: "claude", installHint: "https://claude.com/claude-code", skillsHome: "claude" },
10449
10871
  { id: "codex", name: "Codex CLI", binary: "codex", installHint: "npm install -g @openai/codex (or: brew install codex)", skillsHome: "agents" },
@@ -10453,24 +10875,24 @@ var HARNESSES = [
10453
10875
  var SERVER_NAME = "reaper";
10454
10876
  function onPath(name, pathVar = process.env.PATH ?? "", win = platform4() === "win32") {
10455
10877
  const exts = win ? ["", ".exe", ".cmd", ".bat"] : [""];
10456
- return pathVar.split(delimiter).filter(Boolean).some((dir) => exts.some((ext) => existsSync8(join14(dir, name + ext))));
10878
+ return pathVar.split(delimiter).filter(Boolean).some((dir) => exts.some((ext) => existsSync8(join15(dir, name + ext))));
10457
10879
  }
10458
10880
  function realEnv() {
10459
- return { home: homedir10(), codexHome: process.env.CODEX_HOME || void 0, hasBinary: (name) => onPath(name) };
10881
+ return { home: homedir11(), codexHome: process.env.CODEX_HOME || void 0, hasBinary: (name) => onPath(name) };
10460
10882
  }
10461
10883
  var configPath = (id, env) => ({
10462
- claude: join14(env.home, ".claude.json"),
10463
- codex: join14(env.codexHome ?? join14(env.home, ".codex"), "config.toml"),
10464
- gemini: join14(env.home, ".gemini", "settings.json"),
10465
- cursor: join14(env.home, ".cursor", "mcp.json")
10884
+ claude: join15(env.home, ".claude.json"),
10885
+ codex: join15(env.codexHome ?? join15(env.home, ".codex"), "config.toml"),
10886
+ gemini: join15(env.home, ".gemini", "settings.json"),
10887
+ cursor: join15(env.home, ".cursor", "mcp.json")
10466
10888
  })[id];
10467
10889
  function detectHarnesses(env = realEnv()) {
10468
- return HARNESSES.filter((h) => h.binary ? env.hasBinary(h.binary) : existsSync8(join14(env.home, ".cursor")));
10890
+ return HARNESSES.filter((h) => h.binary ? env.hasBinary(h.binary) : existsSync8(join15(env.home, ".cursor")));
10469
10891
  }
10470
10892
  function registeredServer(id, env = realEnv()) {
10471
10893
  let text8;
10472
10894
  try {
10473
- text8 = readFileSync7(configPath(id, env), "utf-8");
10895
+ text8 = readFileSync8(configPath(id, env), "utf-8");
10474
10896
  } catch {
10475
10897
  return null;
10476
10898
  }
@@ -10536,12 +10958,12 @@ var realRunner = (bin, args) => {
10536
10958
  };
10537
10959
  function writeJsonServer(path, node, mainJs) {
10538
10960
  let config = {};
10539
- if (existsSync8(path)) config = JSON.parse(readFileSync7(path, "utf-8"));
10961
+ if (existsSync8(path)) config = JSON.parse(readFileSync8(path, "utf-8"));
10540
10962
  const servers = config.mcpServers && typeof config.mcpServers === "object" ? config.mcpServers : {};
10541
10963
  servers[SERVER_NAME] = { command: node, args: [mainJs, "serve"] };
10542
10964
  config.mcpServers = servers;
10543
- mkdirSync8(dirname9(path), { recursive: true });
10544
- writeFileSync7(path, JSON.stringify(config, null, 2) + "\n", "utf-8");
10965
+ mkdirSync9(dirname9(path), { recursive: true });
10966
+ writeFileSync8(path, JSON.stringify(config, null, 2) + "\n", "utf-8");
10545
10967
  }
10546
10968
  function connectHarness(id, node, mainJs, env = realEnv(), run5 = realRunner) {
10547
10969
  const existing = registeredServer(id, env);
@@ -10643,7 +11065,7 @@ async function fetchLatestRelease(fetchImpl = fetch, timeoutMs = 3e3) {
10643
11065
  }
10644
11066
  function realUpdateDeps(current, cli, force = false, bridge = false) {
10645
11067
  const nodeDir = dirname10(process.execPath);
10646
- const npmBeside = join15(nodeDir, process.platform === "win32" ? "npm.cmd" : "npm");
11068
+ const npmBeside = join16(nodeDir, process.platform === "win32" ? "npm.cmd" : "npm");
10647
11069
  return {
10648
11070
  current,
10649
11071
  latest: () => fetchLatestVersion(fetch, 1e4),
@@ -10661,7 +11083,7 @@ function realUpdateDeps(current, cli, force = false, bridge = false) {
10661
11083
  released: () => fetchLatestRelease(fetch, 1e4),
10662
11084
  installed: () => {
10663
11085
  try {
10664
- const version = JSON.parse(readFileSync8(join15(dirname10(cli), "package.json"), "utf-8")).version;
11086
+ const version = JSON.parse(readFileSync9(join16(dirname10(cli), "package.json"), "utf-8")).version;
10665
11087
  return typeof version === "string" ? version : void 0;
10666
11088
  } catch {
10667
11089
  return void 0;
@@ -10678,14 +11100,14 @@ function realUpdateDeps(current, cli, force = false, bridge = false) {
10678
11100
 
10679
11101
  // apps/reaper-mcp-server/src/claude-assets.ts
10680
11102
  import { createHash as createHash2 } from "node:crypto";
10681
- import { existsSync as existsSync10, lstatSync, mkdirSync as mkdirSync9, readFileSync as readFileSync9, readdirSync as readdirSync2, writeFileSync as writeFileSync8 } from "node:fs";
10682
- import { dirname as dirname11, join as join16, relative } from "node:path";
11103
+ import { existsSync as existsSync10, lstatSync, mkdirSync as mkdirSync10, readFileSync as readFileSync10, readdirSync as readdirSync2, writeFileSync as writeFileSync9 } from "node:fs";
11104
+ import { dirname as dirname11, join as join17, relative } from "node:path";
10683
11105
  var CLAUDE_MANIFEST = ".reaper-mcp-installed.json";
10684
11106
  var sha = (buf) => createHash2("sha256").update(buf).digest("hex");
10685
11107
  function listFiles(dir) {
10686
11108
  const out2 = [];
10687
11109
  for (const entry of readdirSync2(dir, { withFileTypes: true })) {
10688
- const p = join16(dir, entry.name);
11110
+ const p = join17(dir, entry.name);
10689
11111
  if (entry.isDirectory()) out2.push(...listFiles(p));
10690
11112
  else if (entry.isFile()) out2.push(p);
10691
11113
  }
@@ -10700,7 +11122,7 @@ function isSymlink(path) {
10700
11122
  }
10701
11123
  function readManifest2(path) {
10702
11124
  try {
10703
- const m = JSON.parse(readFileSync9(path, "utf-8"));
11125
+ const m = JSON.parse(readFileSync10(path, "utf-8"));
10704
11126
  if (m && m.version === 1 && m.files && typeof m.files === "object") return m;
10705
11127
  } catch {
10706
11128
  }
@@ -10709,28 +11131,28 @@ function readManifest2(path) {
10709
11131
  function installClaudeAssets(packageClaudeDir, claudeDir, opts = {}) {
10710
11132
  const wants = (part) => !opts.include || opts.include.includes(part);
10711
11133
  const result = { installed: [], updated: [], unchanged: 0, skipped: [] };
10712
- const manifestPath = join16(claudeDir, CLAUDE_MANIFEST);
11134
+ const manifestPath = join17(claudeDir, CLAUDE_MANIFEST);
10713
11135
  const manifest = readManifest2(manifestPath);
10714
11136
  const plan = [];
10715
- const skillsSrc = join16(packageClaudeDir, "skills");
11137
+ const skillsSrc = join17(packageClaudeDir, "skills");
10716
11138
  if (wants("skills") && existsSync10(skillsSrc)) {
10717
11139
  for (const f of listFiles(skillsSrc)) {
10718
11140
  const rel = relative(skillsSrc, f);
10719
- if (existsSync10(join16(skillsSrc, rel.split(/[\\/]/)[0], ".repo-only"))) continue;
10720
- plan.push([f, join16(claudeDir, "skills", rel), join16(claudeDir, "skills", rel.split(/[\\/]/)[0])]);
11141
+ if (existsSync10(join17(skillsSrc, rel.split(/[\\/]/)[0], ".repo-only"))) continue;
11142
+ plan.push([f, join17(claudeDir, "skills", rel), join17(claudeDir, "skills", rel.split(/[\\/]/)[0])]);
10721
11143
  }
10722
11144
  }
10723
- const agentsSrc = join16(packageClaudeDir, "agents");
11145
+ const agentsSrc = join17(packageClaudeDir, "agents");
10724
11146
  if (wants("agents") && existsSync10(agentsSrc)) {
10725
11147
  for (const f of listFiles(agentsSrc)) {
10726
- const dest = join16(claudeDir, "agents", relative(agentsSrc, f));
11148
+ const dest = join17(claudeDir, "agents", relative(agentsSrc, f));
10727
11149
  plan.push([f, dest, dest]);
10728
11150
  }
10729
11151
  }
10730
- const knowledgeSrc = join16(packageClaudeDir, "knowledge");
11152
+ const knowledgeSrc = join17(packageClaudeDir, "knowledge");
10731
11153
  if (wants("knowledge") && existsSync10(knowledgeSrc)) {
10732
11154
  for (const f of listFiles(knowledgeSrc)) {
10733
- plan.push([f, join16(claudeDir, "knowledge", relative(knowledgeSrc, f)), join16(claudeDir, "knowledge")]);
11155
+ plan.push([f, join17(claudeDir, "knowledge", relative(knowledgeSrc, f)), join17(claudeDir, "knowledge")]);
10734
11156
  }
10735
11157
  }
10736
11158
  const skippedSymlinks = /* @__PURE__ */ new Set();
@@ -10743,24 +11165,24 @@ function installClaudeAssets(packageClaudeDir, claudeDir, opts = {}) {
10743
11165
  continue;
10744
11166
  }
10745
11167
  const key = relative(claudeDir, dest);
10746
- const content = readFileSync9(src);
11168
+ const content = readFileSync10(src);
10747
11169
  const hash = sha(content);
10748
11170
  if (!existsSync10(dest)) {
10749
11171
  if (!opts.dryRun) {
10750
- mkdirSync9(dirname11(dest), { recursive: true });
10751
- writeFileSync8(dest, content);
11172
+ mkdirSync10(dirname11(dest), { recursive: true });
11173
+ writeFileSync9(dest, content);
10752
11174
  manifest.files[key] = hash;
10753
11175
  }
10754
11176
  result.installed.push(key);
10755
11177
  continue;
10756
11178
  }
10757
- const current = sha(readFileSync9(dest));
11179
+ const current = sha(readFileSync10(dest));
10758
11180
  if (current === hash) {
10759
11181
  if (!opts.dryRun) manifest.files[key] = hash;
10760
11182
  result.unchanged++;
10761
11183
  } else if (manifest.files[key] === current) {
10762
11184
  if (!opts.dryRun) {
10763
- writeFileSync8(dest, content);
11185
+ writeFileSync9(dest, content);
10764
11186
  manifest.files[key] = hash;
10765
11187
  }
10766
11188
  result.updated.push(key);
@@ -10769,56 +11191,56 @@ function installClaudeAssets(packageClaudeDir, claudeDir, opts = {}) {
10769
11191
  }
10770
11192
  }
10771
11193
  if (!opts.dryRun && (result.installed.length || result.updated.length || result.unchanged)) {
10772
- mkdirSync9(claudeDir, { recursive: true });
10773
- writeFileSync8(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
11194
+ mkdirSync10(claudeDir, { recursive: true });
11195
+ writeFileSync9(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
10774
11196
  }
10775
11197
  return result;
10776
11198
  }
10777
11199
 
10778
11200
  // apps/reaper-mcp-server/src/jsfx/examples.ts
10779
11201
  import { createHash as createHash3 } from "node:crypto";
10780
- import { existsSync as existsSync11, mkdirSync as mkdirSync10, readFileSync as readFileSync10, readdirSync as readdirSync3, writeFileSync as writeFileSync9 } from "node:fs";
10781
- import { join as join17 } from "node:path";
11202
+ import { existsSync as existsSync11, mkdirSync as mkdirSync11, readFileSync as readFileSync11, readdirSync as readdirSync3, writeFileSync as writeFileSync10 } from "node:fs";
11203
+ import { join as join18 } from "node:path";
10782
11204
  var MANIFEST = ".installed.json";
10783
11205
  var sha2 = (text8) => createHash3("sha256").update(text8).digest("hex");
10784
11206
  function installExamplePlugins(examplesDir, outDir, toolkit, presetsDir2) {
10785
11207
  const result = { installed: [], kept: [], presets: {}, presetErrors: [] };
10786
11208
  if (!existsSync11(examplesDir)) return result;
10787
- mkdirSync10(outDir, { recursive: true });
10788
- const manifestPath = join17(outDir, MANIFEST);
11209
+ mkdirSync11(outDir, { recursive: true });
11210
+ const manifestPath = join18(outDir, MANIFEST);
10789
11211
  let manifest = {};
10790
11212
  try {
10791
- manifest = JSON.parse(readFileSync10(manifestPath, "utf8"));
11213
+ manifest = JSON.parse(readFileSync11(manifestPath, "utf8"));
10792
11214
  } catch {
10793
11215
  }
10794
11216
  for (const file of readdirSync3(examplesDir).filter((f) => f.endsWith(".jsfx")).sort()) {
10795
- const dest = join17(outDir, file);
10796
- const next = inlineToolkit(readFileSync10(join17(examplesDir, file), "utf8"), { toolkit, version: 1, request: "a plugin that ships with reaper-mcp", slug: file.replace(/\.jsfx$/, ""), example: true });
10797
- const current = existsSync11(dest) ? readFileSync10(dest, "utf8") : void 0;
11217
+ const dest = join18(outDir, file);
11218
+ const next = inlineToolkit(readFileSync11(join18(examplesDir, file), "utf8"), { toolkit, version: 1, request: "a plugin that ships with reaper-mcp", slug: file.replace(/\.jsfx$/, ""), example: true });
11219
+ const current = existsSync11(dest) ? readFileSync11(dest, "utf8") : void 0;
10798
11220
  if (current !== void 0 && current !== next && sha2(current) !== manifest[file]) {
10799
11221
  result.kept.push(file);
10800
11222
  continue;
10801
11223
  }
10802
- if (current !== next) writeFileSync9(dest, next);
11224
+ if (current !== next) writeFileSync10(dest, next);
10803
11225
  manifest[file] = sha2(next);
10804
11226
  result.installed.push(file);
10805
11227
  }
10806
11228
  if (presetsDir2) {
10807
11229
  const folder = outDir.split(/[/\\]/).slice(-2).join("/");
10808
11230
  for (const file of readdirSync3(examplesDir).filter((f) => f.endsWith(".jsfx")).sort()) {
10809
- const presetsPath = join17(examplesDir, file.replace(/\.jsfx$/, ".presets.json"));
11231
+ const presetsPath = join18(examplesDir, file.replace(/\.jsfx$/, ".presets.json"));
10810
11232
  if (!existsSync11(presetsPath)) continue;
10811
- const input = JSON.parse(readFileSync10(presetsPath, "utf8"));
10812
- const { values, errors } = resolvePresets(input, parseSliders(readFileSync10(join17(examplesDir, file), "utf8")).sliders);
11233
+ const input = JSON.parse(readFileSync11(presetsPath, "utf8"));
11234
+ const { values, errors } = resolvePresets(input, parseSliders(readFileSync11(join18(examplesDir, file), "utf8")).sliders);
10813
11235
  if (errors.length) {
10814
11236
  result.presetErrors.push(`${file}: ${errors.join(" ")}`);
10815
11237
  continue;
10816
11238
  }
10817
11239
  const encoded = input.map((p, i) => encodePreset(p.name.trim(), values[i]));
10818
- result.presets[file] = writePresetFile(presetsDir2, `${folder}/${file}`, encoded, join17(outDir, ".presets", `${file}.json`)).written;
11240
+ result.presets[file] = writePresetFile(presetsDir2, `${folder}/${file}`, encoded, join18(outDir, ".presets", `${file}.json`)).written;
10819
11241
  }
10820
11242
  }
10821
- writeFileSync9(manifestPath, JSON.stringify(manifest, null, 2));
11243
+ writeFileSync10(manifestPath, JSON.stringify(manifest, null, 2));
10822
11244
  return result;
10823
11245
  }
10824
11246
 
@@ -10849,24 +11271,24 @@ function renderDoctor(sections3, opts = {}) {
10849
11271
  }
10850
11272
 
10851
11273
  // apps/reaper-mcp-server/src/bridge-repair.ts
10852
- import { existsSync as existsSync12, mkdirSync as mkdirSync11, readFileSync as readFileSync11, rmSync as rmSync2, writeFileSync as writeFileSync10 } from "node:fs";
10853
- import { join as join18 } from "node:path";
11274
+ import { existsSync as existsSync12, mkdirSync as mkdirSync12, readFileSync as readFileSync12, rmSync as rmSync2, writeFileSync as writeFileSync11 } from "node:fs";
11275
+ import { join as join19 } from "node:path";
10854
11276
  var BRIDGE_VERSION_FILE = "mcp_bridge_version.txt";
10855
11277
  function readBridgeVersion(scriptsDir) {
10856
11278
  try {
10857
- const v = readFileSync11(join18(scriptsDir, BRIDGE_VERSION_FILE), "utf-8").trim();
11279
+ const v = readFileSync12(join19(scriptsDir, BRIDGE_VERSION_FILE), "utf-8").trim();
10858
11280
  return /^\d+\.\d+\.\d+/.test(v) ? v : void 0;
10859
11281
  } catch {
10860
11282
  return void 0;
10861
11283
  }
10862
11284
  }
10863
11285
  function writeBridgeVersion(scriptsDir, version) {
10864
- writeFileSync10(join18(scriptsDir, BRIDGE_VERSION_FILE), `${version}
11286
+ writeFileSync11(join19(scriptsDir, BRIDGE_VERSION_FILE), `${version}
10865
11287
  `, "utf-8");
10866
11288
  }
10867
11289
  function sameContent(a, b) {
10868
11290
  try {
10869
- return readFileSync11(a).equals(readFileSync11(b));
11291
+ return readFileSync12(a).equals(readFileSync12(b));
10870
11292
  } catch {
10871
11293
  return false;
10872
11294
  }
@@ -10874,32 +11296,32 @@ function sameContent(a, b) {
10874
11296
  function installReaperFiles(paths) {
10875
11297
  let luaChanged = false;
10876
11298
  for (const asset of REAPER_ASSETS) {
10877
- const src = join18(paths.assetsDir, asset);
11299
+ const src = join19(paths.assetsDir, asset);
10878
11300
  if (!existsSync12(src)) continue;
10879
11301
  const lua = asset.endsWith(".lua");
10880
- const destDir = lua ? paths.scriptsDir : join18(paths.effectsDir, "reaper-mcp");
10881
- mkdirSync11(destDir, { recursive: true });
10882
- const dest = join18(destDir, asset);
11302
+ const destDir = lua ? paths.scriptsDir : join19(paths.effectsDir, "reaper-mcp");
11303
+ mkdirSync12(destDir, { recursive: true });
11304
+ const dest = join19(destDir, asset);
10883
11305
  if (lua && !sameContent(src, dest)) luaChanged = true;
10884
11306
  installFile(src, dest);
10885
11307
  }
10886
- for (const asset of RETIRED_ASSETS) rmSync2(join18(paths.scriptsDir, asset), { force: true });
10887
- if (existsSync12(join18(paths.wwwSrcDir, BRIDGE_UI_FILE))) copyDirSync(paths.wwwSrcDir, paths.wwwDir);
11308
+ for (const asset of RETIRED_ASSETS) rmSync2(join19(paths.scriptsDir, asset), { force: true });
11309
+ if (existsSync12(join19(paths.wwwSrcDir, BRIDGE_UI_FILE))) copyDirSync(paths.wwwSrcDir, paths.wwwDir);
10888
11310
  return luaChanged;
10889
11311
  }
10890
11312
  function repairBridgeInstall(paths, version, opts) {
10891
11313
  const none = { bridgeChanged: false, autostartAdded: false };
10892
11314
  if (opts.inClone) return { skipped: "clone", ...none };
10893
- const reapack = existsSync12(join18(paths.scriptsDir, "reaper-mcp", "MCP Bridge", "mcp_bridge.lua"));
10894
- const ours = existsSync12(join18(paths.scriptsDir, "mcp_bridge.lua"));
11315
+ const reapack = existsSync12(join19(paths.scriptsDir, "reaper-mcp", "MCP Bridge", "mcp_bridge.lua"));
11316
+ const ours = existsSync12(join19(paths.scriptsDir, "mcp_bridge.lua"));
10895
11317
  if (!reapack && !ours) return { skipped: "not_installed", ...none };
10896
11318
  const from = readBridgeVersion(paths.scriptsDir);
10897
11319
  if (from && compareVersions(from, version) >= 0) return { skipped: "current", from, ...none };
10898
11320
  const bridgeChanged = reapack ? false : installReaperFiles(paths);
10899
- const startupPath = join18(paths.scriptsDir, "__startup.lua");
10900
- const startup = existsSync12(startupPath) ? readFileSync11(startupPath, "utf-8") : "";
11321
+ const startupPath = join19(paths.scriptsDir, "__startup.lua");
11322
+ const startup = existsSync12(startupPath) ? readFileSync12(startupPath, "utf-8") : "";
10901
11323
  const { text: text8, changed } = ensureBridgeAutostart(startup);
10902
- if (changed) writeFileSync10(startupPath, text8, "utf-8");
11324
+ if (changed) writeFileSync11(startupPath, text8, "utf-8");
10903
11325
  writeBridgeVersion(paths.scriptsDir, version);
10904
11326
  return { from, bridgeChanged, autostartAdded: !startup.includes(AUTOSTART_MARKER) };
10905
11327
  }
@@ -10948,8 +11370,8 @@ ${SIDECAR_OFFER_TEXT}
10948
11370
 
10949
11371
  // apps/reaper-mcp-server/src/setup-health.ts
10950
11372
  import { execFile as execFile2 } from "node:child_process";
10951
- import { readFileSync as readFileSync12 } from "node:fs";
10952
- import { join as join19 } from "node:path";
11373
+ import { readFileSync as readFileSync13 } from "node:fs";
11374
+ import { join as join20 } from "node:path";
10953
11375
  import { platform as platform5 } from "node:os";
10954
11376
  function heartbeatAgeBucket(ms) {
10955
11377
  const min = 6e4;
@@ -10972,7 +11394,7 @@ function isReaperProcessRunning(timeoutMs = 2e3) {
10972
11394
  }
10973
11395
  function autostartInstalled(scriptsDir) {
10974
11396
  try {
10975
- return readFileSync12(join19(scriptsDir, "__startup.lua"), "utf-8").includes(AUTOSTART_MARKER);
11397
+ return readFileSync13(join20(scriptsDir, "__startup.lua"), "utf-8").includes(AUTOSTART_MARKER);
10976
11398
  } catch {
10977
11399
  return false;
10978
11400
  }
@@ -11001,9 +11423,9 @@ async function setup() {
11001
11423
  console.log(`Bridge directory: ${ui.dim(bridgeDir)}
11002
11424
  `);
11003
11425
  const scriptsDir = getReaperScriptsPath();
11004
- mkdirSync12(scriptsDir, { recursive: true });
11426
+ mkdirSync13(scriptsDir, { recursive: true });
11005
11427
  const reaperDir = resolveAssetDir(__dirname2, "reaper");
11006
- const filesPlan = setupFilesPlan(existsSync13(join20(scriptsDir, "reaper-mcp", "MCP Bridge", "mcp_bridge.lua")), findCloneRoot(__dirname2) !== null);
11428
+ const filesPlan = setupFilesPlan(existsSync13(join21(scriptsDir, "reaper-mcp", "MCP Bridge", "mcp_bridge.lua")), findCloneRoot(__dirname2) !== null);
11007
11429
  if (filesPlan === "leave") {
11008
11430
  console.log(`${ui.mark("info")} The bridge is installed by ReaPack: leaving its scripts, JSFX and status page to ReaPack.`);
11009
11431
  console.log(`${ui.dim("Setup only turns on starting with REAPER and the web interface.")}
@@ -11013,7 +11435,7 @@ async function setup() {
11013
11435
  const port = await enableWebInterface();
11014
11436
  console.log(`
11015
11437
  ${ui.mark("ok")} ${ui.bold("Setup complete!")}`);
11016
- if (await chainAfterSetup(port, join20(scriptsDir, "reaper-mcp", "MCP Bridge", "mcp_bridge.lua"))) return;
11438
+ if (await chainAfterSetup(port, join21(scriptsDir, "reaper-mcp", "MCP Bridge", "mcp_bridge.lua"))) return;
11017
11439
  console.log(`
11018
11440
  Restart REAPER (or run the bridge once from the Action List) and add reaper-mcp to your harness: ${ui.cmd("reaper-mcp doctor")}`);
11019
11441
  if (port) console.log(`The bridge opens its status window on start: ${ui.link(`http://localhost:${port}/${BRIDGE_UI_FILE}`)}`);
@@ -11030,14 +11452,14 @@ Restart REAPER (or run the bridge once from the Action List) and add reaper-mcp
11030
11452
  const luaInstalled = [];
11031
11453
  for (const asset of REAPER_ASSETS) {
11032
11454
  if (!asset.endsWith(".lua")) continue;
11033
- const src = join20(reaperDir, asset);
11034
- const dest = join20(scriptsDir, asset);
11455
+ const src = join21(reaperDir, asset);
11456
+ const dest = join21(scriptsDir, asset);
11035
11457
  if (installFile(src, dest)) luaInstalled.push(asset);
11036
11458
  else console.log(ui.item("fail", `Not found: ${src}`));
11037
11459
  }
11038
11460
  installedLine("scripts", luaInstalled);
11039
11461
  for (const asset of RETIRED_ASSETS) {
11040
- const dest = join20(scriptsDir, asset);
11462
+ const dest = join21(scriptsDir, asset);
11041
11463
  if (existsSync13(dest)) {
11042
11464
  rmSync3(dest);
11043
11465
  console.log(ui.item("info", `Removed: ${asset} (retired)`));
@@ -11046,26 +11468,26 @@ Restart REAPER (or run the bridge once from the Action List) and add reaper-mcp
11046
11468
  const cloneRoot = findCloneRoot(__dirname2);
11047
11469
  if (cloneRoot) {
11048
11470
  const dev = isDevClone(await cloneState(cloneRoot));
11049
- writeFileSync11(join20(scriptsDir, "mcp_update.conf"), updateConfigText(cloneRoot, process.execPath, dev));
11471
+ writeFileSync12(join21(scriptsDir, "mcp_update.conf"), updateConfigText(cloneRoot, process.execPath, dev));
11050
11472
  console.log(ui.item("ok", `Installed: mcp_update.conf (${dev ? "developer clone: Rebuild & reload" : "one-click updates"} from the status page)`));
11051
11473
  } else {
11052
- writeFileSync11(join20(scriptsDir, "mcp_update.conf"), npmUpdateConfigText(process.execPath, join20(__dirname2, "main.js")));
11474
+ writeFileSync12(join21(scriptsDir, "mcp_update.conf"), npmUpdateConfigText(process.execPath, join21(__dirname2, "main.js")));
11053
11475
  }
11054
- const effectsDir = join20(getReaperEffectsPath(), "reaper-mcp");
11055
- mkdirSync12(effectsDir, { recursive: true });
11476
+ const effectsDir = join21(getReaperEffectsPath(), "reaper-mcp");
11477
+ mkdirSync13(effectsDir, { recursive: true });
11056
11478
  console.log(ui.section("Installing JSFX analyzers..."));
11057
11479
  const jsfxInstalled = [];
11058
11480
  for (const asset of REAPER_ASSETS) {
11059
11481
  if (asset.endsWith(".lua")) continue;
11060
- const src = join20(reaperDir, asset);
11061
- const dest = join20(effectsDir, asset);
11482
+ const src = join21(reaperDir, asset);
11483
+ const dest = join21(effectsDir, asset);
11062
11484
  if (installFile(src, dest)) jsfxInstalled.push(`reaper-mcp/${asset}`);
11063
11485
  else console.log(ui.item("fail", `Not found: ${src}`));
11064
11486
  }
11065
11487
  installedLine("JSFX files", jsfxInstalled);
11066
11488
  console.log(ui.section("Installing example plugins..."));
11067
- const examplesDir = join20(resolveAssetDir(__dirname2, "claude"), "skills", "make-plugin", "examples");
11068
- const examples = installExamplePlugins(examplesDir, join20(generatedDir(), "examples"), loadToolkit(), presetsDir());
11489
+ const examplesDir = join21(resolveAssetDir(__dirname2, "claude"), "skills", "make-plugin", "examples");
11490
+ const examples = installExamplePlugins(examplesDir, join21(generatedDir(), "examples"), loadToolkit(), presetsDir());
11069
11491
  installedLine("example plugins", examples.installed.map((f) => `reaper-mcp-generated/examples/${f}`));
11070
11492
  for (const f of examples.kept) console.log(ui.item("info", `Kept your edited copy: reaper-mcp-generated/examples/${f}`));
11071
11493
  if (verbose) {
@@ -11075,11 +11497,11 @@ Restart REAPER (or run the bridge once from the Action List) and add reaper-mcp
11075
11497
  if (!examples.installed.length && !examples.kept.length) console.log(ui.item("fail", `Not found: ${examplesDir}`));
11076
11498
  const wwwSrc = resolveAssetDir(__dirname2, "bridge-ui");
11077
11499
  console.log(ui.section("Installing bridge status UI..."));
11078
- if (existsSync13(join20(wwwSrc, BRIDGE_UI_FILE))) {
11500
+ if (existsSync13(join21(wwwSrc, BRIDGE_UI_FILE))) {
11079
11501
  const count = copyDirSync(wwwSrc, getReaperWwwPath());
11080
11502
  console.log(ui.item("ok", verbose ? `Installed: reaper_www_root/${BRIDGE_UI_FILE} (+${count - 1} PWA files)` : "Status page installed"));
11081
11503
  } else {
11082
- console.log(ui.item("fail", `Not found: ${join20(wwwSrc, BRIDGE_UI_FILE)} (build bridge-ui first)`));
11504
+ console.log(ui.item("fail", `Not found: ${join21(wwwSrc, BRIDGE_UI_FILE)} (build bridge-ui first)`));
11083
11505
  }
11084
11506
  installBridgeAutostart(scriptsDir);
11085
11507
  writeBridgeVersion(scriptsDir, readServiceVersion());
@@ -11087,12 +11509,12 @@ Restart REAPER (or run the bridge once from the Action List) and add reaper-mcp
11087
11509
  await registerSnapshotActions();
11088
11510
  console.log(`
11089
11511
  ${ui.mark("ok")} ${ui.bold("Setup complete!")}`);
11090
- if (await chainAfterSetup(webPort, join20(scriptsDir, "mcp_bridge.lua"))) return;
11512
+ if (await chainAfterSetup(webPort, join21(scriptsDir, "mcp_bridge.lua"))) return;
11091
11513
  console.log("");
11092
11514
  console.log(ui.heading("Next steps:"));
11093
11515
  console.log(` ${ui.bold("1.")} Start REAPER: the bridge starts with it. If REAPER is already open, restart it,`);
11094
11516
  console.log(" or run the bridge once by hand: Actions > Show action list > Load ReaScript,");
11095
- console.log(` select ${ui.dim(join20(scriptsDir, "mcp_bridge.lua"))} and click Run.`);
11517
+ console.log(` select ${ui.dim(join21(scriptsDir, "mcp_bridge.lua"))} and click Run.`);
11096
11518
  console.log(` ${ui.bold("2.")} Connect your AI harness: ${ui.cmd("reaper-mcp init")}, then check it with ${ui.cmd("reaper-mcp doctor")}`);
11097
11519
  if (webPort) {
11098
11520
  console.log(`
@@ -11156,13 +11578,13 @@ async function isReaperRunning() {
11156
11578
  }
11157
11579
  async function enableWebInterface() {
11158
11580
  console.log(ui.section("Enabling REAPER web interface..."));
11159
- const iniPath = join20(getReaperResourcePath(), "reaper.ini");
11581
+ const iniPath = join21(getReaperResourcePath(), "reaper.ini");
11160
11582
  if (!existsSync13(iniPath)) {
11161
11583
  console.log(ui.item("warn", `Skipped: ${iniPath} not found (start REAPER once, quit it, then re-run setup)`));
11162
11584
  return null;
11163
11585
  }
11164
11586
  const requested = Number(process.env["REAPER_WEB_PORT"]) || DEFAULT_WEB_PORT;
11165
- const result = ensureWebInterface(readFileSync13(iniPath, "utf-8"), requested);
11587
+ const result = ensureWebInterface(readFileSync14(iniPath, "utf-8"), requested);
11166
11588
  if (!result.changed) {
11167
11589
  console.log(ui.item("ok", `Already enabled on port ${result.port}`));
11168
11590
  return result.port;
@@ -11177,29 +11599,29 @@ async function enableWebInterface() {
11177
11599
  console.log(" Quit REAPER to finish (Ctrl+C to skip)...");
11178
11600
  while (await isReaperRunning()) await new Promise((r) => setTimeout(r, 1e3));
11179
11601
  }
11180
- writeFileSync11(iniPath, ensureWebInterface(readFileSync13(iniPath, "utf-8"), requested).ini, "utf-8");
11602
+ writeFileSync12(iniPath, ensureWebInterface(readFileSync14(iniPath, "utf-8"), requested).ini, "utf-8");
11181
11603
  console.log(ui.item("ok", `Enabled on port ${result.port} (override with REAPER_WEB_PORT)`));
11182
11604
  return result.port;
11183
11605
  }
11184
11606
  function installBridgeAutostart(scriptsDir) {
11185
11607
  console.log(ui.section("Starting the bridge with REAPER..."));
11186
- const path = join20(scriptsDir, "__startup.lua");
11187
- const { text: text8, changed } = ensureBridgeAutostart(existsSync13(path) ? readFileSync13(path, "utf-8") : "");
11188
- if (changed) writeFileSync11(path, text8, "utf-8");
11608
+ const path = join21(scriptsDir, "__startup.lua");
11609
+ const { text: text8, changed } = ensureBridgeAutostart(existsSync13(path) ? readFileSync14(path, "utf-8") : "");
11610
+ if (changed) writeFileSync12(path, text8, "utf-8");
11189
11611
  console.log(ui.item("ok", changed ? "Added to Scripts/__startup.lua (REAPER runs it at launch)" : "Already in Scripts/__startup.lua"));
11190
11612
  console.log(ui.dim(" Turn it off in the bridge window: Settings > Start with REAPER."));
11191
11613
  }
11192
11614
  async function registerSnapshotActions() {
11193
11615
  console.log(ui.section("Registering snapshot actions (quick save, next, previous)..."));
11194
- const kbPath = join20(getReaperResourcePath(), "reaper-kb.ini");
11195
- const kb = existsSync13(kbPath) ? readFileSync13(kbPath, "utf-8") : "";
11616
+ const kbPath = join21(getReaperResourcePath(), "reaper-kb.ini");
11617
+ const kb = existsSync13(kbPath) ? readFileSync14(kbPath, "utf-8") : "";
11196
11618
  const { added } = ensureSnapshotActions(kb);
11197
11619
  if (!added.length) {
11198
11620
  console.log(ui.item("ok", "Already in the Action List"));
11199
11621
  } else if (await isReaperRunning()) {
11200
11622
  console.log(ui.item("info", "REAPER is running: the bridge adds them when it next starts (re-run mcp_bridge.lua)."));
11201
11623
  } else {
11202
- writeFileSync11(kbPath, ensureSnapshotActions(kb).kb, "utf-8");
11624
+ writeFileSync12(kbPath, ensureSnapshotActions(kb).kb, "utf-8");
11203
11625
  console.log(ui.item("ok", `Added: ${added.join(", ")}`));
11204
11626
  }
11205
11627
  console.log(`${ui.dim(" Bind keys in Actions > Show action list: search")} ${ui.cmd('"mcp_snapshot"')}${ui.dim(".")}`);
@@ -11232,11 +11654,11 @@ async function init(chained = false) {
11232
11654
  for (const id of ids) {
11233
11655
  const h = HARNESSES.find((x) => x.id === id);
11234
11656
  if (id === "claude") {
11235
- const settingsPath = join20(homedir11(), ".claude", "settings.json");
11236
- mkdirSync12(dirname12(settingsPath), { recursive: true });
11237
- console.log(`${ui.mark("ok")} Claude settings (${MCP_TOOL_NAMES.length} REAPER tools allow-listed): ${ensureClaudeSettings(settingsPath)} \u2192 ${ui.dim(settingsPath.replace(homedir11(), "~"))}`);
11657
+ const settingsPath = join21(homedir12(), ".claude", "settings.json");
11658
+ mkdirSync13(dirname12(settingsPath), { recursive: true });
11659
+ console.log(`${ui.mark("ok")} Claude settings (${MCP_TOOL_NAMES.length} REAPER tools allow-listed): ${ensureClaudeSettings(settingsPath)} \u2192 ${ui.dim(settingsPath.replace(homedir12(), "~"))}`);
11238
11660
  if (inClone) {
11239
- const mcpJsonPath = join20(process.cwd(), ".mcp.json");
11661
+ const mcpJsonPath = join21(process.cwd(), ".mcp.json");
11240
11662
  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.`);
11241
11663
  continue;
11242
11664
  }
@@ -11273,7 +11695,7 @@ function installSkills(dryRun = false, ids) {
11273
11695
  console.log("Running from a clone: scripts/sync-symlinks.sh links the skills and knowledge into ~/.claude and ~/.agents.");
11274
11696
  return;
11275
11697
  }
11276
- const src = join20(resolveAssetDir(__dirname2, "claude"));
11698
+ const src = join21(resolveAssetDir(__dirname2, "claude"));
11277
11699
  if (!existsSync13(src)) {
11278
11700
  console.log(`Skills not found: ${src} (this build has no claude/ folder)`);
11279
11701
  process.exitCode = 1;
@@ -11292,9 +11714,9 @@ function installSkills(dryRun = false, ids) {
11292
11714
  const homes = skillsHomes(targets.length ? targets : ["claude"]);
11293
11715
  const verb = dryRun ? "Would install" : "Installed";
11294
11716
  const jobs = [];
11295
- if (homes.claude) jobs.push({ label: "~/.claude", dir: join20(homedir11(), ".claude"), what: "the mix skills, agents and knowledge" });
11296
- if (homes.agents) jobs.push({ label: "~/.agents", dir: join20(homedir11(), ".agents"), include: ["skills", "agents"], what: "the mix skills and agents" });
11297
- if (homes.agents && !homes.claude) jobs.push({ label: "~/.claude", dir: join20(homedir11(), ".claude"), include: ["knowledge"], what: "the knowledge base the skills read" });
11717
+ if (homes.claude) jobs.push({ label: "~/.claude", dir: join21(homedir12(), ".claude"), what: "the mix skills, agents and knowledge" });
11718
+ if (homes.agents) jobs.push({ label: "~/.agents", dir: join21(homedir12(), ".agents"), include: ["skills", "agents"], what: "the mix skills and agents" });
11719
+ if (homes.agents && !homes.claude) jobs.push({ label: "~/.claude", dir: join21(homedir12(), ".claude"), include: ["knowledge"], what: "the knowledge base the skills read" });
11298
11720
  for (const job of jobs) {
11299
11721
  const r = installClaudeAssets(src, job.dir, { dryRun, include: job.include });
11300
11722
  console.log(`${ui.mark("ok")} ${verb} ${job.what} in ${job.label}: ${r.installed.length} new, ${r.updated.length} updated, ${r.unchanged} already current.`);
@@ -11347,25 +11769,27 @@ async function doctor() {
11347
11769
  core2.push(
11348
11770
  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" }
11349
11771
  );
11350
- const readIfExists = (path) => existsSync13(path) ? readFileSync13(path, "utf-8") : null;
11772
+ const readIfExists = (path) => existsSync13(path) ? readFileSync14(path, "utf-8") : null;
11351
11773
  core2.push(autostartCheck(
11352
- readIfExists(join20(getReaperScriptsPath(), "__startup.lua")),
11353
- readIfExists(join20(getReaperResourcePath(), "reaper-extstate.ini")),
11774
+ readIfExists(join21(getReaperScriptsPath(), "__startup.lua")),
11775
+ readIfExists(join21(getReaperResourcePath(), "reaper-extstate.ini")),
11354
11776
  await isReaperRunning()
11355
11777
  ));
11356
- const globalClaudeDir = join20(homedir11(), ".claude");
11357
- const localSkills = existsSync13(join20(process.cwd(), ".claude", "skills", "mixer", "SKILL.md"));
11358
- const globalSkills = existsSync13(join20(globalClaudeDir, "skills", "mixer", "SKILL.md"));
11359
- const sharedSkills = existsSync13(join20(homedir11(), ".agents", "skills", "mixer", "SKILL.md"));
11778
+ const forcedFlags = flagOverrideCheck();
11779
+ if (forcedFlags) core2.push(forcedFlags);
11780
+ const globalClaudeDir = join21(homedir12(), ".claude");
11781
+ const localSkills = existsSync13(join21(process.cwd(), ".claude", "skills", "mixer", "SKILL.md"));
11782
+ const globalSkills = existsSync13(join21(globalClaudeDir, "skills", "mixer", "SKILL.md"));
11783
+ const sharedSkills = existsSync13(join21(homedir12(), ".agents", "skills", "mixer", "SKILL.md"));
11360
11784
  core2.push(
11361
11785
  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" }
11362
11786
  );
11363
- const localKnowledge = existsSync13(join20(process.cwd(), ".claude", "knowledge"));
11364
- const knowledgeLinked = localKnowledge || existsSync13(join20(globalClaudeDir, "knowledge"));
11787
+ const localKnowledge = existsSync13(join21(process.cwd(), ".claude", "knowledge"));
11788
+ const knowledgeLinked = localKnowledge || existsSync13(join21(globalClaudeDir, "knowledge"));
11365
11789
  core2.push(
11366
11790
  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" }
11367
11791
  );
11368
- const mcpJsonExists = existsSync13(join20(process.cwd(), ".mcp.json"));
11792
+ const mcpJsonExists = existsSync13(join21(process.cwd(), ".mcp.json"));
11369
11793
  const harnessEnv = realEnv();
11370
11794
  const installed = detectHarnesses(harnessEnv);
11371
11795
  const connected = installed.filter((h) => registeredServer(h.id, harnessEnv));
@@ -11388,11 +11812,11 @@ async function doctor() {
11388
11812
  status: "info",
11389
11813
  detail: { default: "On, pseudonymous \xB7 turn off: reaper-mcp telemetry off", custom: "Your own OTEL_* destination", off: "Off" }[telemetry]
11390
11814
  });
11391
- const sidecarVenvPath = join20(homedir11(), ".reaper-mcp", "sidecar-venv");
11815
+ const sidecarVenvPath = join21(homedir12(), ".reaper-mcp", "sidecar-venv");
11392
11816
  const venvBin = platform6() === "win32" ? "Scripts" : "bin";
11393
11817
  const venvPythonName = platform6() === "win32" ? "python.exe" : "python";
11394
- const venvPython = join20(sidecarVenvPath, venvBin, venvPythonName);
11395
- const hfCachePath = join20(homedir11(), ".cache", "huggingface", "hub");
11818
+ const venvPython = join21(sidecarVenvPath, venvBin, venvPythonName);
11819
+ const hfCachePath = join21(homedir12(), ".cache", "huggingface", "hub");
11396
11820
  let pythonOk = false;
11397
11821
  let pythonDetail = "Not found";
11398
11822
  try {
@@ -11425,14 +11849,14 @@ async function doctor() {
11425
11849
  addOns.demucs = found.separation;
11426
11850
  addOns.lv_chordia = found.chords;
11427
11851
  }
11428
- const weightsPath = join20(hfCachePath, "models--facebook--audiobox-aesthetics");
11852
+ const weightsPath = join21(hfCachePath, "models--facebook--audiobox-aesthetics");
11429
11853
  const weightsExist = existsSync13(weightsPath);
11430
11854
  const sidecarReady = venvExists && depsOk;
11431
11855
  const sidecarOptedIn = venvExists;
11432
11856
  const sidecarBroken = sidecarOptedIn && !sidecarReady;
11433
11857
  const missing = sidecarOptedIn ? "fail" : "info";
11434
11858
  const repair = "reaper-mcp setup-sidecar";
11435
- const home = (p) => p.replace(homedir11(), "~");
11859
+ const home = (p) => p.replace(homedir12(), "~");
11436
11860
  const sidecar = {
11437
11861
  title: "Python sidecar",
11438
11862
  note: "optional \xB7 lets Claude listen to the audio",
@@ -11591,7 +12015,7 @@ async function updateCommand(force, bridge) {
11591
12015
  child.on("close", (code) => resolveCode(code ?? 1));
11592
12016
  });
11593
12017
  }
11594
- return runUpdate(realUpdateDeps(readServiceVersion(), join20(__dirname2, "main.js"), force, bridge));
12018
+ return runUpdate(realUpdateDeps(readServiceVersion(), join21(__dirname2, "main.js"), force, bridge));
11595
12019
  }
11596
12020
  var command = process.argv[2];
11597
12021
  switch (command) {
@@ -11634,6 +12058,9 @@ switch (command) {
11634
12058
  process.exit(1);
11635
12059
  });
11636
12060
  break;
12061
+ case "flags":
12062
+ process.exit(flagsCommand(process.argv.slice(3)));
12063
+ break;
11637
12064
  case "extension":
11638
12065
  case "extensions":
11639
12066
  extensionCommand(process.argv.slice(3)).then(
@@ -11688,6 +12115,7 @@ Usage:
11688
12115
  reaper-mcp update Update to the latest release (npm install: downloads it and installs it into REAPER; --force reinstalls)
11689
12116
  reaper-mcp doctor Check that everything is configured correctly
11690
12117
  reaper-mcp status Check if Lua bridge is running in REAPER
12118
+ reaper-mcp flags List feature flags and how they resolve here; set <key> <variant> forces one on this install only; reset [key]
11691
12119
  reaper-mcp telemetry off Opt out of pseudonymous usage telemetry (also: on, status)
11692
12120
 
11693
12121
  Quick Start (from npm):