@mthines/reaper-mcp 0.93.2 → 0.95.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -45
- package/bridge-ui/mcp_bridge.html +94 -54
- package/main.js +543 -131
- package/package.json +2 -1
- package/reaper/CLAUDE.md +1 -1
- package/reaper/mcp_prefs_lib.lua +109 -1
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",
|
|
@@ -10369,18 +10376,417 @@ Try it: reaper-mcp extension link ${basename4(r.dir)}`);
|
|
|
10369
10376
|
}
|
|
10370
10377
|
}
|
|
10371
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(env = process.env, platform7 = process.platform) {
|
|
10642
|
+
if (env.XDG_CONFIG_HOME) return join13(env.XDG_CONFIG_HOME, "reaper-mcp");
|
|
10643
|
+
if (platform7 === "win32" && env.APPDATA) return join13(env.APPDATA, "reaper-mcp");
|
|
10644
|
+
return join13(homedir9(), ".config", "reaper-mcp");
|
|
10645
|
+
}
|
|
10646
|
+
function parseJson(raw) {
|
|
10647
|
+
try {
|
|
10648
|
+
return JSON.parse(raw);
|
|
10649
|
+
} catch {
|
|
10650
|
+
return void 0;
|
|
10651
|
+
}
|
|
10652
|
+
}
|
|
10653
|
+
function readFlagOverrides(dir = defaultFlagsDir(), env = process.env, registry = FLAG_REGISTRY) {
|
|
10654
|
+
let fromFile;
|
|
10655
|
+
try {
|
|
10656
|
+
fromFile = parseJson(readFileSync6(join13(dir, FLAGS_FILE), "utf-8"));
|
|
10657
|
+
} catch {
|
|
10658
|
+
fromFile = void 0;
|
|
10659
|
+
}
|
|
10660
|
+
const fromEnv = env[FLAGS_ENV] ? parseJson(env[FLAGS_ENV]) : void 0;
|
|
10661
|
+
return { ...sanitizeFlagOverrides(fromFile, registry), ...sanitizeFlagOverrides(fromEnv, registry) };
|
|
10662
|
+
}
|
|
10663
|
+
function writeFlagOverrides(overrides, dir = defaultFlagsDir()) {
|
|
10664
|
+
mkdirSync7(dir, { recursive: true });
|
|
10665
|
+
writeFileSync6(join13(dir, FLAGS_FILE), JSON.stringify(overrides, null, 2) + "\n", "utf-8");
|
|
10666
|
+
}
|
|
10667
|
+
function createServerFlags(options = {}) {
|
|
10668
|
+
const registry = options.registry ?? FLAG_REGISTRY;
|
|
10669
|
+
const installId = options.installId ?? (() => readInstallId());
|
|
10670
|
+
const context = (withTargetingKey = true) => {
|
|
10671
|
+
const targetingKey = withTargetingKey ? installId() : void 0;
|
|
10672
|
+
return {
|
|
10673
|
+
...targetingKey && { targetingKey },
|
|
10674
|
+
flagOverrides: readFlagOverrides(options.dir, options.env, registry)
|
|
10675
|
+
};
|
|
10676
|
+
};
|
|
10677
|
+
const client = () => createFlagClient(registry, options.domain);
|
|
10678
|
+
return {
|
|
10679
|
+
context,
|
|
10680
|
+
async details(key) {
|
|
10681
|
+
const def = registry.find((f) => f.key === key);
|
|
10682
|
+
if (!def) throw new Error(`unknown flag "${key}"`);
|
|
10683
|
+
return evaluateDefinition(client(), def, context(def.experiment?.enabled === true));
|
|
10684
|
+
},
|
|
10685
|
+
rows() {
|
|
10686
|
+
const { flagOverrides } = context(false);
|
|
10687
|
+
return registry.map((def) => {
|
|
10688
|
+
const resolved = resolveFlag(def, { targetingKey: installId, overrides: flagOverrides });
|
|
10689
|
+
return {
|
|
10690
|
+
key: def.key,
|
|
10691
|
+
variant: resolved.variant,
|
|
10692
|
+
reason: resolved.reason,
|
|
10693
|
+
...flagOverrides[def.key] !== void 0 && { override: flagOverrides[def.key] },
|
|
10694
|
+
...def.experiment && {
|
|
10695
|
+
experiment: {
|
|
10696
|
+
enabled: def.experiment.enabled,
|
|
10697
|
+
split: def.experiment.variants.map((v) => `${v.key} ${v.weight}%`).join(" / ")
|
|
10698
|
+
}
|
|
10699
|
+
},
|
|
10700
|
+
description: def.description
|
|
10701
|
+
};
|
|
10702
|
+
});
|
|
10703
|
+
}
|
|
10704
|
+
};
|
|
10705
|
+
}
|
|
10706
|
+
function flagOverrideCheck(options = {}) {
|
|
10707
|
+
const forced = createServerFlags(options).rows().filter((r) => r.override !== void 0);
|
|
10708
|
+
if (forced.length === 0) return void 0;
|
|
10709
|
+
return {
|
|
10710
|
+
label: "Feature flags",
|
|
10711
|
+
status: "warn",
|
|
10712
|
+
detail: `${forced.length} forced on this install: ${forced.map((r) => `${r.key}=${r.override}`).join(", ")}`,
|
|
10713
|
+
fix: "reaper-mcp flags reset (forced flags can be unfinished and break things)"
|
|
10714
|
+
};
|
|
10715
|
+
}
|
|
10716
|
+
var defaultFlags = createServerFlags();
|
|
10717
|
+
var USAGE = [
|
|
10718
|
+
"Usage:",
|
|
10719
|
+
" reaper-mcp flags list Every flag, how it resolves for this install, and why",
|
|
10720
|
+
" reaper-mcp flags set <key> <variant> Force a variant on this install only",
|
|
10721
|
+
" reaper-mcp flags reset [key] Drop one override, or all of them"
|
|
10722
|
+
];
|
|
10723
|
+
function flagsCommand(args, options = {}) {
|
|
10724
|
+
const io = options.io ?? { log: console.log, error: console.error };
|
|
10725
|
+
const registry = options.registry ?? FLAG_REGISTRY;
|
|
10726
|
+
const dir = options.dir ?? defaultFlagsDir();
|
|
10727
|
+
const flags = createServerFlags({ ...options, registry, dir });
|
|
10728
|
+
const [sub = "list", key, variant] = args;
|
|
10729
|
+
if (sub === "list") {
|
|
10730
|
+
const rows = flags.rows();
|
|
10731
|
+
if (rows.length === 0) {
|
|
10732
|
+
io.log("No feature flags are declared.");
|
|
10733
|
+
return 0;
|
|
10734
|
+
}
|
|
10735
|
+
for (const row of rows) {
|
|
10736
|
+
const note = row.override ? " (override)" : row.experiment?.enabled ? ` (experiment: ${row.experiment.split})` : "";
|
|
10737
|
+
io.log(`${row.key} ${row.variant} reason=${row.reason}${note}`);
|
|
10738
|
+
io.log(` ${row.description}`);
|
|
10739
|
+
}
|
|
10740
|
+
return 0;
|
|
10741
|
+
}
|
|
10742
|
+
if (sub === "set") {
|
|
10743
|
+
if (!key || !variant) {
|
|
10744
|
+
io.error(USAGE.join("\n"));
|
|
10745
|
+
return 1;
|
|
10746
|
+
}
|
|
10747
|
+
const def = registry.find((f) => f.key === key);
|
|
10748
|
+
if (!def) {
|
|
10749
|
+
io.error(`Unknown flag "${key}". Known flags: ${registry.map((f) => f.key).join(", ") || "none"}.`);
|
|
10750
|
+
return 1;
|
|
10751
|
+
}
|
|
10752
|
+
if (!Object.hasOwn(def.variants, variant)) {
|
|
10753
|
+
io.error(`"${variant}" is not a variant of ${key}. Variants: ${Object.keys(def.variants).join(", ")}.`);
|
|
10754
|
+
return 1;
|
|
10755
|
+
}
|
|
10756
|
+
const stored = readFlagOverrides(dir, {}, registry);
|
|
10757
|
+
writeFlagOverrides({ ...stored, [key]: variant }, dir);
|
|
10758
|
+
io.log(`${key} forced to "${variant}" on this install. It applies from the next evaluation, no restart needed.`);
|
|
10759
|
+
io.log(`Forcing a flag is unsupported: it may be unfinished and break things. Undo it with: reaper-mcp flags reset ${key}`);
|
|
10760
|
+
return 0;
|
|
10761
|
+
}
|
|
10762
|
+
if (sub === "reset") {
|
|
10763
|
+
const stored = readFlagOverrides(dir, {}, registry);
|
|
10764
|
+
if (key) {
|
|
10765
|
+
const { [key]: dropped, ...rest } = stored;
|
|
10766
|
+
writeFlagOverrides(rest, dir);
|
|
10767
|
+
io.log(dropped === void 0 ? `${key} had no override.` : `${key} override removed.`);
|
|
10768
|
+
} else {
|
|
10769
|
+
writeFlagOverrides({}, dir);
|
|
10770
|
+
io.log("All flag overrides removed.");
|
|
10771
|
+
}
|
|
10772
|
+
return 0;
|
|
10773
|
+
}
|
|
10774
|
+
io.error(USAGE.join("\n"));
|
|
10775
|
+
return 1;
|
|
10776
|
+
}
|
|
10777
|
+
|
|
10372
10778
|
// apps/reaper-mcp-server/src/main.ts
|
|
10373
|
-
import { existsSync as existsSync13, mkdirSync as
|
|
10374
|
-
import { join as
|
|
10779
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync13, readFileSync as readFileSync14, realpathSync, rmSync as rmSync3, writeFileSync as writeFileSync12 } from "node:fs";
|
|
10780
|
+
import { join as join21, dirname as dirname12, resolve as resolve3 } from "node:path";
|
|
10375
10781
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
10376
|
-
import { homedir as
|
|
10782
|
+
import { homedir as homedir12, platform as platform6 } from "node:os";
|
|
10377
10783
|
import { exec as execCb, spawn as spawn3 } from "node:child_process";
|
|
10378
10784
|
import { promisify as promisifyUtil } from "node:util";
|
|
10379
10785
|
|
|
10380
10786
|
// apps/reaper-mcp-server/src/update.ts
|
|
10381
10787
|
import { spawn as spawn2 } from "node:child_process";
|
|
10382
|
-
import { dirname as dirname10, join as
|
|
10383
|
-
import { existsSync as existsSync9, readFileSync as
|
|
10788
|
+
import { dirname as dirname10, join as join16 } from "node:path";
|
|
10789
|
+
import { existsSync as existsSync9, readFileSync as readFileSync9 } from "node:fs";
|
|
10384
10790
|
|
|
10385
10791
|
// apps/reaper-mcp-server/src/version.ts
|
|
10386
10792
|
function compareVersions(a, b) {
|
|
@@ -10394,14 +10800,14 @@ function compareVersions(a, b) {
|
|
|
10394
10800
|
}
|
|
10395
10801
|
|
|
10396
10802
|
// apps/reaper-mcp-server/src/update-check.ts
|
|
10397
|
-
import { mkdirSync as
|
|
10398
|
-
import { dirname as dirname8, join as
|
|
10399
|
-
import { homedir as
|
|
10803
|
+
import { mkdirSync as mkdirSync8, readFileSync as readFileSync7, writeFileSync as writeFileSync7 } from "node:fs";
|
|
10804
|
+
import { dirname as dirname8, join as join14 } from "node:path";
|
|
10805
|
+
import { homedir as homedir10 } from "node:os";
|
|
10400
10806
|
var NPM_PACKAGE = "@mthines/reaper-mcp";
|
|
10401
10807
|
var PACKAGE_URL = "https://registry.npmjs.org/@mthines%2Freaper-mcp";
|
|
10402
10808
|
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
10403
10809
|
function defaultUpdateStatePath() {
|
|
10404
|
-
return
|
|
10810
|
+
return join14(homedir10(), ".reaper-mcp", "update-check.json");
|
|
10405
10811
|
}
|
|
10406
10812
|
function updateCheckDisabled(env = process.env) {
|
|
10407
10813
|
const setting = (env["REAPER_MCP_UPDATE_CHECK"] ?? "").trim().toLowerCase();
|
|
@@ -10426,7 +10832,7 @@ function updateNotice(current, latest) {
|
|
|
10426
10832
|
}
|
|
10427
10833
|
function readState(path) {
|
|
10428
10834
|
try {
|
|
10429
|
-
const s = JSON.parse(
|
|
10835
|
+
const s = JSON.parse(readFileSync7(path, "utf-8"));
|
|
10430
10836
|
return s && typeof s === "object" ? s : {};
|
|
10431
10837
|
} catch {
|
|
10432
10838
|
return {};
|
|
@@ -10434,8 +10840,8 @@ function readState(path) {
|
|
|
10434
10840
|
}
|
|
10435
10841
|
function writeState(path, state) {
|
|
10436
10842
|
try {
|
|
10437
|
-
|
|
10438
|
-
|
|
10843
|
+
mkdirSync8(dirname8(path), { recursive: true });
|
|
10844
|
+
writeFileSync7(path, JSON.stringify(state) + "\n", "utf-8");
|
|
10439
10845
|
} catch {
|
|
10440
10846
|
}
|
|
10441
10847
|
}
|
|
@@ -10459,9 +10865,9 @@ async function checkForUpdate(opts) {
|
|
|
10459
10865
|
|
|
10460
10866
|
// apps/reaper-mcp-server/src/harnesses.ts
|
|
10461
10867
|
import { execFileSync } from "node:child_process";
|
|
10462
|
-
import { existsSync as existsSync8, mkdirSync as
|
|
10463
|
-
import { delimiter, dirname as dirname9, isAbsolute as isAbsolute3, join as
|
|
10464
|
-
import { homedir as
|
|
10868
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync9, readFileSync as readFileSync8, writeFileSync as writeFileSync8 } from "node:fs";
|
|
10869
|
+
import { delimiter, dirname as dirname9, isAbsolute as isAbsolute3, join as join15 } from "node:path";
|
|
10870
|
+
import { homedir as homedir11, platform as platform4 } from "node:os";
|
|
10465
10871
|
var HARNESSES = [
|
|
10466
10872
|
{ id: "claude", name: "Claude Code", binary: "claude", installHint: "https://claude.com/claude-code", skillsHome: "claude" },
|
|
10467
10873
|
{ id: "codex", name: "Codex CLI", binary: "codex", installHint: "npm install -g @openai/codex (or: brew install codex)", skillsHome: "agents" },
|
|
@@ -10471,24 +10877,24 @@ var HARNESSES = [
|
|
|
10471
10877
|
var SERVER_NAME = "reaper";
|
|
10472
10878
|
function onPath(name, pathVar = process.env.PATH ?? "", win = platform4() === "win32") {
|
|
10473
10879
|
const exts = win ? ["", ".exe", ".cmd", ".bat"] : [""];
|
|
10474
|
-
return pathVar.split(delimiter).filter(Boolean).some((dir) => exts.some((ext) => existsSync8(
|
|
10880
|
+
return pathVar.split(delimiter).filter(Boolean).some((dir) => exts.some((ext) => existsSync8(join15(dir, name + ext))));
|
|
10475
10881
|
}
|
|
10476
10882
|
function realEnv() {
|
|
10477
|
-
return { home:
|
|
10883
|
+
return { home: homedir11(), codexHome: process.env.CODEX_HOME || void 0, hasBinary: (name) => onPath(name) };
|
|
10478
10884
|
}
|
|
10479
10885
|
var configPath = (id, env) => ({
|
|
10480
|
-
claude:
|
|
10481
|
-
codex:
|
|
10482
|
-
gemini:
|
|
10483
|
-
cursor:
|
|
10886
|
+
claude: join15(env.home, ".claude.json"),
|
|
10887
|
+
codex: join15(env.codexHome ?? join15(env.home, ".codex"), "config.toml"),
|
|
10888
|
+
gemini: join15(env.home, ".gemini", "settings.json"),
|
|
10889
|
+
cursor: join15(env.home, ".cursor", "mcp.json")
|
|
10484
10890
|
})[id];
|
|
10485
10891
|
function detectHarnesses(env = realEnv()) {
|
|
10486
|
-
return HARNESSES.filter((h) => h.binary ? env.hasBinary(h.binary) : existsSync8(
|
|
10892
|
+
return HARNESSES.filter((h) => h.binary ? env.hasBinary(h.binary) : existsSync8(join15(env.home, ".cursor")));
|
|
10487
10893
|
}
|
|
10488
10894
|
function registeredServer(id, env = realEnv()) {
|
|
10489
10895
|
let text8;
|
|
10490
10896
|
try {
|
|
10491
|
-
text8 =
|
|
10897
|
+
text8 = readFileSync8(configPath(id, env), "utf-8");
|
|
10492
10898
|
} catch {
|
|
10493
10899
|
return null;
|
|
10494
10900
|
}
|
|
@@ -10554,12 +10960,12 @@ var realRunner = (bin, args) => {
|
|
|
10554
10960
|
};
|
|
10555
10961
|
function writeJsonServer(path, node, mainJs) {
|
|
10556
10962
|
let config = {};
|
|
10557
|
-
if (existsSync8(path)) config = JSON.parse(
|
|
10963
|
+
if (existsSync8(path)) config = JSON.parse(readFileSync8(path, "utf-8"));
|
|
10558
10964
|
const servers = config.mcpServers && typeof config.mcpServers === "object" ? config.mcpServers : {};
|
|
10559
10965
|
servers[SERVER_NAME] = { command: node, args: [mainJs, "serve"] };
|
|
10560
10966
|
config.mcpServers = servers;
|
|
10561
|
-
|
|
10562
|
-
|
|
10967
|
+
mkdirSync9(dirname9(path), { recursive: true });
|
|
10968
|
+
writeFileSync8(path, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
10563
10969
|
}
|
|
10564
10970
|
function connectHarness(id, node, mainJs, env = realEnv(), run5 = realRunner) {
|
|
10565
10971
|
const existing = registeredServer(id, env);
|
|
@@ -10661,7 +11067,7 @@ async function fetchLatestRelease(fetchImpl = fetch, timeoutMs = 3e3) {
|
|
|
10661
11067
|
}
|
|
10662
11068
|
function realUpdateDeps(current, cli, force = false, bridge = false) {
|
|
10663
11069
|
const nodeDir = dirname10(process.execPath);
|
|
10664
|
-
const npmBeside =
|
|
11070
|
+
const npmBeside = join16(nodeDir, process.platform === "win32" ? "npm.cmd" : "npm");
|
|
10665
11071
|
return {
|
|
10666
11072
|
current,
|
|
10667
11073
|
latest: () => fetchLatestVersion(fetch, 1e4),
|
|
@@ -10679,7 +11085,7 @@ function realUpdateDeps(current, cli, force = false, bridge = false) {
|
|
|
10679
11085
|
released: () => fetchLatestRelease(fetch, 1e4),
|
|
10680
11086
|
installed: () => {
|
|
10681
11087
|
try {
|
|
10682
|
-
const version = JSON.parse(
|
|
11088
|
+
const version = JSON.parse(readFileSync9(join16(dirname10(cli), "package.json"), "utf-8")).version;
|
|
10683
11089
|
return typeof version === "string" ? version : void 0;
|
|
10684
11090
|
} catch {
|
|
10685
11091
|
return void 0;
|
|
@@ -10696,14 +11102,14 @@ function realUpdateDeps(current, cli, force = false, bridge = false) {
|
|
|
10696
11102
|
|
|
10697
11103
|
// apps/reaper-mcp-server/src/claude-assets.ts
|
|
10698
11104
|
import { createHash as createHash2 } from "node:crypto";
|
|
10699
|
-
import { existsSync as existsSync10, lstatSync, mkdirSync as
|
|
10700
|
-
import { dirname as dirname11, join as
|
|
11105
|
+
import { existsSync as existsSync10, lstatSync, mkdirSync as mkdirSync10, readFileSync as readFileSync10, readdirSync as readdirSync2, writeFileSync as writeFileSync9 } from "node:fs";
|
|
11106
|
+
import { dirname as dirname11, join as join17, relative } from "node:path";
|
|
10701
11107
|
var CLAUDE_MANIFEST = ".reaper-mcp-installed.json";
|
|
10702
11108
|
var sha = (buf) => createHash2("sha256").update(buf).digest("hex");
|
|
10703
11109
|
function listFiles(dir) {
|
|
10704
11110
|
const out2 = [];
|
|
10705
11111
|
for (const entry of readdirSync2(dir, { withFileTypes: true })) {
|
|
10706
|
-
const p =
|
|
11112
|
+
const p = join17(dir, entry.name);
|
|
10707
11113
|
if (entry.isDirectory()) out2.push(...listFiles(p));
|
|
10708
11114
|
else if (entry.isFile()) out2.push(p);
|
|
10709
11115
|
}
|
|
@@ -10718,7 +11124,7 @@ function isSymlink(path) {
|
|
|
10718
11124
|
}
|
|
10719
11125
|
function readManifest2(path) {
|
|
10720
11126
|
try {
|
|
10721
|
-
const m = JSON.parse(
|
|
11127
|
+
const m = JSON.parse(readFileSync10(path, "utf-8"));
|
|
10722
11128
|
if (m && m.version === 1 && m.files && typeof m.files === "object") return m;
|
|
10723
11129
|
} catch {
|
|
10724
11130
|
}
|
|
@@ -10727,28 +11133,28 @@ function readManifest2(path) {
|
|
|
10727
11133
|
function installClaudeAssets(packageClaudeDir, claudeDir, opts = {}) {
|
|
10728
11134
|
const wants = (part) => !opts.include || opts.include.includes(part);
|
|
10729
11135
|
const result = { installed: [], updated: [], unchanged: 0, skipped: [] };
|
|
10730
|
-
const manifestPath =
|
|
11136
|
+
const manifestPath = join17(claudeDir, CLAUDE_MANIFEST);
|
|
10731
11137
|
const manifest = readManifest2(manifestPath);
|
|
10732
11138
|
const plan = [];
|
|
10733
|
-
const skillsSrc =
|
|
11139
|
+
const skillsSrc = join17(packageClaudeDir, "skills");
|
|
10734
11140
|
if (wants("skills") && existsSync10(skillsSrc)) {
|
|
10735
11141
|
for (const f of listFiles(skillsSrc)) {
|
|
10736
11142
|
const rel = relative(skillsSrc, f);
|
|
10737
|
-
if (existsSync10(
|
|
10738
|
-
plan.push([f,
|
|
11143
|
+
if (existsSync10(join17(skillsSrc, rel.split(/[\\/]/)[0], ".repo-only"))) continue;
|
|
11144
|
+
plan.push([f, join17(claudeDir, "skills", rel), join17(claudeDir, "skills", rel.split(/[\\/]/)[0])]);
|
|
10739
11145
|
}
|
|
10740
11146
|
}
|
|
10741
|
-
const agentsSrc =
|
|
11147
|
+
const agentsSrc = join17(packageClaudeDir, "agents");
|
|
10742
11148
|
if (wants("agents") && existsSync10(agentsSrc)) {
|
|
10743
11149
|
for (const f of listFiles(agentsSrc)) {
|
|
10744
|
-
const dest =
|
|
11150
|
+
const dest = join17(claudeDir, "agents", relative(agentsSrc, f));
|
|
10745
11151
|
plan.push([f, dest, dest]);
|
|
10746
11152
|
}
|
|
10747
11153
|
}
|
|
10748
|
-
const knowledgeSrc =
|
|
11154
|
+
const knowledgeSrc = join17(packageClaudeDir, "knowledge");
|
|
10749
11155
|
if (wants("knowledge") && existsSync10(knowledgeSrc)) {
|
|
10750
11156
|
for (const f of listFiles(knowledgeSrc)) {
|
|
10751
|
-
plan.push([f,
|
|
11157
|
+
plan.push([f, join17(claudeDir, "knowledge", relative(knowledgeSrc, f)), join17(claudeDir, "knowledge")]);
|
|
10752
11158
|
}
|
|
10753
11159
|
}
|
|
10754
11160
|
const skippedSymlinks = /* @__PURE__ */ new Set();
|
|
@@ -10761,24 +11167,24 @@ function installClaudeAssets(packageClaudeDir, claudeDir, opts = {}) {
|
|
|
10761
11167
|
continue;
|
|
10762
11168
|
}
|
|
10763
11169
|
const key = relative(claudeDir, dest);
|
|
10764
|
-
const content =
|
|
11170
|
+
const content = readFileSync10(src);
|
|
10765
11171
|
const hash = sha(content);
|
|
10766
11172
|
if (!existsSync10(dest)) {
|
|
10767
11173
|
if (!opts.dryRun) {
|
|
10768
|
-
|
|
10769
|
-
|
|
11174
|
+
mkdirSync10(dirname11(dest), { recursive: true });
|
|
11175
|
+
writeFileSync9(dest, content);
|
|
10770
11176
|
manifest.files[key] = hash;
|
|
10771
11177
|
}
|
|
10772
11178
|
result.installed.push(key);
|
|
10773
11179
|
continue;
|
|
10774
11180
|
}
|
|
10775
|
-
const current = sha(
|
|
11181
|
+
const current = sha(readFileSync10(dest));
|
|
10776
11182
|
if (current === hash) {
|
|
10777
11183
|
if (!opts.dryRun) manifest.files[key] = hash;
|
|
10778
11184
|
result.unchanged++;
|
|
10779
11185
|
} else if (manifest.files[key] === current) {
|
|
10780
11186
|
if (!opts.dryRun) {
|
|
10781
|
-
|
|
11187
|
+
writeFileSync9(dest, content);
|
|
10782
11188
|
manifest.files[key] = hash;
|
|
10783
11189
|
}
|
|
10784
11190
|
result.updated.push(key);
|
|
@@ -10787,56 +11193,56 @@ function installClaudeAssets(packageClaudeDir, claudeDir, opts = {}) {
|
|
|
10787
11193
|
}
|
|
10788
11194
|
}
|
|
10789
11195
|
if (!opts.dryRun && (result.installed.length || result.updated.length || result.unchanged)) {
|
|
10790
|
-
|
|
10791
|
-
|
|
11196
|
+
mkdirSync10(claudeDir, { recursive: true });
|
|
11197
|
+
writeFileSync9(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
|
|
10792
11198
|
}
|
|
10793
11199
|
return result;
|
|
10794
11200
|
}
|
|
10795
11201
|
|
|
10796
11202
|
// apps/reaper-mcp-server/src/jsfx/examples.ts
|
|
10797
11203
|
import { createHash as createHash3 } from "node:crypto";
|
|
10798
|
-
import { existsSync as existsSync11, mkdirSync as
|
|
10799
|
-
import { join as
|
|
11204
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync11, readFileSync as readFileSync11, readdirSync as readdirSync3, writeFileSync as writeFileSync10 } from "node:fs";
|
|
11205
|
+
import { join as join18 } from "node:path";
|
|
10800
11206
|
var MANIFEST = ".installed.json";
|
|
10801
11207
|
var sha2 = (text8) => createHash3("sha256").update(text8).digest("hex");
|
|
10802
11208
|
function installExamplePlugins(examplesDir, outDir, toolkit, presetsDir2) {
|
|
10803
11209
|
const result = { installed: [], kept: [], presets: {}, presetErrors: [] };
|
|
10804
11210
|
if (!existsSync11(examplesDir)) return result;
|
|
10805
|
-
|
|
10806
|
-
const manifestPath =
|
|
11211
|
+
mkdirSync11(outDir, { recursive: true });
|
|
11212
|
+
const manifestPath = join18(outDir, MANIFEST);
|
|
10807
11213
|
let manifest = {};
|
|
10808
11214
|
try {
|
|
10809
|
-
manifest = JSON.parse(
|
|
11215
|
+
manifest = JSON.parse(readFileSync11(manifestPath, "utf8"));
|
|
10810
11216
|
} catch {
|
|
10811
11217
|
}
|
|
10812
11218
|
for (const file of readdirSync3(examplesDir).filter((f) => f.endsWith(".jsfx")).sort()) {
|
|
10813
|
-
const dest =
|
|
10814
|
-
const next = inlineToolkit(
|
|
10815
|
-
const current = existsSync11(dest) ?
|
|
11219
|
+
const dest = join18(outDir, file);
|
|
11220
|
+
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 });
|
|
11221
|
+
const current = existsSync11(dest) ? readFileSync11(dest, "utf8") : void 0;
|
|
10816
11222
|
if (current !== void 0 && current !== next && sha2(current) !== manifest[file]) {
|
|
10817
11223
|
result.kept.push(file);
|
|
10818
11224
|
continue;
|
|
10819
11225
|
}
|
|
10820
|
-
if (current !== next)
|
|
11226
|
+
if (current !== next) writeFileSync10(dest, next);
|
|
10821
11227
|
manifest[file] = sha2(next);
|
|
10822
11228
|
result.installed.push(file);
|
|
10823
11229
|
}
|
|
10824
11230
|
if (presetsDir2) {
|
|
10825
11231
|
const folder = outDir.split(/[/\\]/).slice(-2).join("/");
|
|
10826
11232
|
for (const file of readdirSync3(examplesDir).filter((f) => f.endsWith(".jsfx")).sort()) {
|
|
10827
|
-
const presetsPath =
|
|
11233
|
+
const presetsPath = join18(examplesDir, file.replace(/\.jsfx$/, ".presets.json"));
|
|
10828
11234
|
if (!existsSync11(presetsPath)) continue;
|
|
10829
|
-
const input = JSON.parse(
|
|
10830
|
-
const { values, errors } = resolvePresets(input, parseSliders(
|
|
11235
|
+
const input = JSON.parse(readFileSync11(presetsPath, "utf8"));
|
|
11236
|
+
const { values, errors } = resolvePresets(input, parseSliders(readFileSync11(join18(examplesDir, file), "utf8")).sliders);
|
|
10831
11237
|
if (errors.length) {
|
|
10832
11238
|
result.presetErrors.push(`${file}: ${errors.join(" ")}`);
|
|
10833
11239
|
continue;
|
|
10834
11240
|
}
|
|
10835
11241
|
const encoded = input.map((p, i) => encodePreset(p.name.trim(), values[i]));
|
|
10836
|
-
result.presets[file] = writePresetFile(presetsDir2, `${folder}/${file}`, encoded,
|
|
11242
|
+
result.presets[file] = writePresetFile(presetsDir2, `${folder}/${file}`, encoded, join18(outDir, ".presets", `${file}.json`)).written;
|
|
10837
11243
|
}
|
|
10838
11244
|
}
|
|
10839
|
-
|
|
11245
|
+
writeFileSync10(manifestPath, JSON.stringify(manifest, null, 2));
|
|
10840
11246
|
return result;
|
|
10841
11247
|
}
|
|
10842
11248
|
|
|
@@ -10867,24 +11273,24 @@ function renderDoctor(sections3, opts = {}) {
|
|
|
10867
11273
|
}
|
|
10868
11274
|
|
|
10869
11275
|
// apps/reaper-mcp-server/src/bridge-repair.ts
|
|
10870
|
-
import { existsSync as existsSync12, mkdirSync as
|
|
10871
|
-
import { join as
|
|
11276
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync12, readFileSync as readFileSync12, rmSync as rmSync2, writeFileSync as writeFileSync11 } from "node:fs";
|
|
11277
|
+
import { join as join19 } from "node:path";
|
|
10872
11278
|
var BRIDGE_VERSION_FILE = "mcp_bridge_version.txt";
|
|
10873
11279
|
function readBridgeVersion(scriptsDir) {
|
|
10874
11280
|
try {
|
|
10875
|
-
const v =
|
|
11281
|
+
const v = readFileSync12(join19(scriptsDir, BRIDGE_VERSION_FILE), "utf-8").trim();
|
|
10876
11282
|
return /^\d+\.\d+\.\d+/.test(v) ? v : void 0;
|
|
10877
11283
|
} catch {
|
|
10878
11284
|
return void 0;
|
|
10879
11285
|
}
|
|
10880
11286
|
}
|
|
10881
11287
|
function writeBridgeVersion(scriptsDir, version) {
|
|
10882
|
-
|
|
11288
|
+
writeFileSync11(join19(scriptsDir, BRIDGE_VERSION_FILE), `${version}
|
|
10883
11289
|
`, "utf-8");
|
|
10884
11290
|
}
|
|
10885
11291
|
function sameContent(a, b) {
|
|
10886
11292
|
try {
|
|
10887
|
-
return
|
|
11293
|
+
return readFileSync12(a).equals(readFileSync12(b));
|
|
10888
11294
|
} catch {
|
|
10889
11295
|
return false;
|
|
10890
11296
|
}
|
|
@@ -10892,32 +11298,32 @@ function sameContent(a, b) {
|
|
|
10892
11298
|
function installReaperFiles(paths) {
|
|
10893
11299
|
let luaChanged = false;
|
|
10894
11300
|
for (const asset of REAPER_ASSETS) {
|
|
10895
|
-
const src =
|
|
11301
|
+
const src = join19(paths.assetsDir, asset);
|
|
10896
11302
|
if (!existsSync12(src)) continue;
|
|
10897
11303
|
const lua = asset.endsWith(".lua");
|
|
10898
|
-
const destDir = lua ? paths.scriptsDir :
|
|
10899
|
-
|
|
10900
|
-
const dest =
|
|
11304
|
+
const destDir = lua ? paths.scriptsDir : join19(paths.effectsDir, "reaper-mcp");
|
|
11305
|
+
mkdirSync12(destDir, { recursive: true });
|
|
11306
|
+
const dest = join19(destDir, asset);
|
|
10901
11307
|
if (lua && !sameContent(src, dest)) luaChanged = true;
|
|
10902
11308
|
installFile(src, dest);
|
|
10903
11309
|
}
|
|
10904
|
-
for (const asset of RETIRED_ASSETS) rmSync2(
|
|
10905
|
-
if (existsSync12(
|
|
11310
|
+
for (const asset of RETIRED_ASSETS) rmSync2(join19(paths.scriptsDir, asset), { force: true });
|
|
11311
|
+
if (existsSync12(join19(paths.wwwSrcDir, BRIDGE_UI_FILE))) copyDirSync(paths.wwwSrcDir, paths.wwwDir);
|
|
10906
11312
|
return luaChanged;
|
|
10907
11313
|
}
|
|
10908
11314
|
function repairBridgeInstall(paths, version, opts) {
|
|
10909
11315
|
const none = { bridgeChanged: false, autostartAdded: false };
|
|
10910
11316
|
if (opts.inClone) return { skipped: "clone", ...none };
|
|
10911
|
-
const reapack = existsSync12(
|
|
10912
|
-
const ours = existsSync12(
|
|
11317
|
+
const reapack = existsSync12(join19(paths.scriptsDir, "reaper-mcp", "MCP Bridge", "mcp_bridge.lua"));
|
|
11318
|
+
const ours = existsSync12(join19(paths.scriptsDir, "mcp_bridge.lua"));
|
|
10913
11319
|
if (!reapack && !ours) return { skipped: "not_installed", ...none };
|
|
10914
11320
|
const from = readBridgeVersion(paths.scriptsDir);
|
|
10915
11321
|
if (from && compareVersions(from, version) >= 0) return { skipped: "current", from, ...none };
|
|
10916
11322
|
const bridgeChanged = reapack ? false : installReaperFiles(paths);
|
|
10917
|
-
const startupPath =
|
|
10918
|
-
const startup = existsSync12(startupPath) ?
|
|
11323
|
+
const startupPath = join19(paths.scriptsDir, "__startup.lua");
|
|
11324
|
+
const startup = existsSync12(startupPath) ? readFileSync12(startupPath, "utf-8") : "";
|
|
10919
11325
|
const { text: text8, changed } = ensureBridgeAutostart(startup);
|
|
10920
|
-
if (changed)
|
|
11326
|
+
if (changed) writeFileSync11(startupPath, text8, "utf-8");
|
|
10921
11327
|
writeBridgeVersion(paths.scriptsDir, version);
|
|
10922
11328
|
return { from, bridgeChanged, autostartAdded: !startup.includes(AUTOSTART_MARKER) };
|
|
10923
11329
|
}
|
|
@@ -10966,8 +11372,8 @@ ${SIDECAR_OFFER_TEXT}
|
|
|
10966
11372
|
|
|
10967
11373
|
// apps/reaper-mcp-server/src/setup-health.ts
|
|
10968
11374
|
import { execFile as execFile2 } from "node:child_process";
|
|
10969
|
-
import { readFileSync as
|
|
10970
|
-
import { join as
|
|
11375
|
+
import { readFileSync as readFileSync13 } from "node:fs";
|
|
11376
|
+
import { join as join20 } from "node:path";
|
|
10971
11377
|
import { platform as platform5 } from "node:os";
|
|
10972
11378
|
function heartbeatAgeBucket(ms) {
|
|
10973
11379
|
const min = 6e4;
|
|
@@ -10990,7 +11396,7 @@ function isReaperProcessRunning(timeoutMs = 2e3) {
|
|
|
10990
11396
|
}
|
|
10991
11397
|
function autostartInstalled(scriptsDir) {
|
|
10992
11398
|
try {
|
|
10993
|
-
return
|
|
11399
|
+
return readFileSync13(join20(scriptsDir, "__startup.lua"), "utf-8").includes(AUTOSTART_MARKER);
|
|
10994
11400
|
} catch {
|
|
10995
11401
|
return false;
|
|
10996
11402
|
}
|
|
@@ -11019,9 +11425,9 @@ async function setup() {
|
|
|
11019
11425
|
console.log(`Bridge directory: ${ui.dim(bridgeDir)}
|
|
11020
11426
|
`);
|
|
11021
11427
|
const scriptsDir = getReaperScriptsPath();
|
|
11022
|
-
|
|
11428
|
+
mkdirSync13(scriptsDir, { recursive: true });
|
|
11023
11429
|
const reaperDir = resolveAssetDir(__dirname2, "reaper");
|
|
11024
|
-
const filesPlan = setupFilesPlan(existsSync13(
|
|
11430
|
+
const filesPlan = setupFilesPlan(existsSync13(join21(scriptsDir, "reaper-mcp", "MCP Bridge", "mcp_bridge.lua")), findCloneRoot(__dirname2) !== null);
|
|
11025
11431
|
if (filesPlan === "leave") {
|
|
11026
11432
|
console.log(`${ui.mark("info")} The bridge is installed by ReaPack: leaving its scripts, JSFX and status page to ReaPack.`);
|
|
11027
11433
|
console.log(`${ui.dim("Setup only turns on starting with REAPER and the web interface.")}
|
|
@@ -11031,7 +11437,7 @@ async function setup() {
|
|
|
11031
11437
|
const port = await enableWebInterface();
|
|
11032
11438
|
console.log(`
|
|
11033
11439
|
${ui.mark("ok")} ${ui.bold("Setup complete!")}`);
|
|
11034
|
-
if (await chainAfterSetup(port,
|
|
11440
|
+
if (await chainAfterSetup(port, join21(scriptsDir, "reaper-mcp", "MCP Bridge", "mcp_bridge.lua"))) return;
|
|
11035
11441
|
console.log(`
|
|
11036
11442
|
Restart REAPER (or run the bridge once from the Action List) and add reaper-mcp to your harness: ${ui.cmd("reaper-mcp doctor")}`);
|
|
11037
11443
|
if (port) console.log(`The bridge opens its status window on start: ${ui.link(`http://localhost:${port}/${BRIDGE_UI_FILE}`)}`);
|
|
@@ -11048,14 +11454,14 @@ Restart REAPER (or run the bridge once from the Action List) and add reaper-mcp
|
|
|
11048
11454
|
const luaInstalled = [];
|
|
11049
11455
|
for (const asset of REAPER_ASSETS) {
|
|
11050
11456
|
if (!asset.endsWith(".lua")) continue;
|
|
11051
|
-
const src =
|
|
11052
|
-
const dest =
|
|
11457
|
+
const src = join21(reaperDir, asset);
|
|
11458
|
+
const dest = join21(scriptsDir, asset);
|
|
11053
11459
|
if (installFile(src, dest)) luaInstalled.push(asset);
|
|
11054
11460
|
else console.log(ui.item("fail", `Not found: ${src}`));
|
|
11055
11461
|
}
|
|
11056
11462
|
installedLine("scripts", luaInstalled);
|
|
11057
11463
|
for (const asset of RETIRED_ASSETS) {
|
|
11058
|
-
const dest =
|
|
11464
|
+
const dest = join21(scriptsDir, asset);
|
|
11059
11465
|
if (existsSync13(dest)) {
|
|
11060
11466
|
rmSync3(dest);
|
|
11061
11467
|
console.log(ui.item("info", `Removed: ${asset} (retired)`));
|
|
@@ -11064,26 +11470,26 @@ Restart REAPER (or run the bridge once from the Action List) and add reaper-mcp
|
|
|
11064
11470
|
const cloneRoot = findCloneRoot(__dirname2);
|
|
11065
11471
|
if (cloneRoot) {
|
|
11066
11472
|
const dev = isDevClone(await cloneState(cloneRoot));
|
|
11067
|
-
|
|
11473
|
+
writeFileSync12(join21(scriptsDir, "mcp_update.conf"), updateConfigText(cloneRoot, process.execPath, dev));
|
|
11068
11474
|
console.log(ui.item("ok", `Installed: mcp_update.conf (${dev ? "developer clone: Rebuild & reload" : "one-click updates"} from the status page)`));
|
|
11069
11475
|
} else {
|
|
11070
|
-
|
|
11476
|
+
writeFileSync12(join21(scriptsDir, "mcp_update.conf"), npmUpdateConfigText(process.execPath, join21(__dirname2, "main.js")));
|
|
11071
11477
|
}
|
|
11072
|
-
const effectsDir =
|
|
11073
|
-
|
|
11478
|
+
const effectsDir = join21(getReaperEffectsPath(), "reaper-mcp");
|
|
11479
|
+
mkdirSync13(effectsDir, { recursive: true });
|
|
11074
11480
|
console.log(ui.section("Installing JSFX analyzers..."));
|
|
11075
11481
|
const jsfxInstalled = [];
|
|
11076
11482
|
for (const asset of REAPER_ASSETS) {
|
|
11077
11483
|
if (asset.endsWith(".lua")) continue;
|
|
11078
|
-
const src =
|
|
11079
|
-
const dest =
|
|
11484
|
+
const src = join21(reaperDir, asset);
|
|
11485
|
+
const dest = join21(effectsDir, asset);
|
|
11080
11486
|
if (installFile(src, dest)) jsfxInstalled.push(`reaper-mcp/${asset}`);
|
|
11081
11487
|
else console.log(ui.item("fail", `Not found: ${src}`));
|
|
11082
11488
|
}
|
|
11083
11489
|
installedLine("JSFX files", jsfxInstalled);
|
|
11084
11490
|
console.log(ui.section("Installing example plugins..."));
|
|
11085
|
-
const examplesDir =
|
|
11086
|
-
const examples = installExamplePlugins(examplesDir,
|
|
11491
|
+
const examplesDir = join21(resolveAssetDir(__dirname2, "claude"), "skills", "make-plugin", "examples");
|
|
11492
|
+
const examples = installExamplePlugins(examplesDir, join21(generatedDir(), "examples"), loadToolkit(), presetsDir());
|
|
11087
11493
|
installedLine("example plugins", examples.installed.map((f) => `reaper-mcp-generated/examples/${f}`));
|
|
11088
11494
|
for (const f of examples.kept) console.log(ui.item("info", `Kept your edited copy: reaper-mcp-generated/examples/${f}`));
|
|
11089
11495
|
if (verbose) {
|
|
@@ -11093,11 +11499,11 @@ Restart REAPER (or run the bridge once from the Action List) and add reaper-mcp
|
|
|
11093
11499
|
if (!examples.installed.length && !examples.kept.length) console.log(ui.item("fail", `Not found: ${examplesDir}`));
|
|
11094
11500
|
const wwwSrc = resolveAssetDir(__dirname2, "bridge-ui");
|
|
11095
11501
|
console.log(ui.section("Installing bridge status UI..."));
|
|
11096
|
-
if (existsSync13(
|
|
11502
|
+
if (existsSync13(join21(wwwSrc, BRIDGE_UI_FILE))) {
|
|
11097
11503
|
const count = copyDirSync(wwwSrc, getReaperWwwPath());
|
|
11098
11504
|
console.log(ui.item("ok", verbose ? `Installed: reaper_www_root/${BRIDGE_UI_FILE} (+${count - 1} PWA files)` : "Status page installed"));
|
|
11099
11505
|
} else {
|
|
11100
|
-
console.log(ui.item("fail", `Not found: ${
|
|
11506
|
+
console.log(ui.item("fail", `Not found: ${join21(wwwSrc, BRIDGE_UI_FILE)} (build bridge-ui first)`));
|
|
11101
11507
|
}
|
|
11102
11508
|
installBridgeAutostart(scriptsDir);
|
|
11103
11509
|
writeBridgeVersion(scriptsDir, readServiceVersion());
|
|
@@ -11105,12 +11511,12 @@ Restart REAPER (or run the bridge once from the Action List) and add reaper-mcp
|
|
|
11105
11511
|
await registerSnapshotActions();
|
|
11106
11512
|
console.log(`
|
|
11107
11513
|
${ui.mark("ok")} ${ui.bold("Setup complete!")}`);
|
|
11108
|
-
if (await chainAfterSetup(webPort,
|
|
11514
|
+
if (await chainAfterSetup(webPort, join21(scriptsDir, "mcp_bridge.lua"))) return;
|
|
11109
11515
|
console.log("");
|
|
11110
11516
|
console.log(ui.heading("Next steps:"));
|
|
11111
11517
|
console.log(` ${ui.bold("1.")} Start REAPER: the bridge starts with it. If REAPER is already open, restart it,`);
|
|
11112
11518
|
console.log(" or run the bridge once by hand: Actions > Show action list > Load ReaScript,");
|
|
11113
|
-
console.log(` select ${ui.dim(
|
|
11519
|
+
console.log(` select ${ui.dim(join21(scriptsDir, "mcp_bridge.lua"))} and click Run.`);
|
|
11114
11520
|
console.log(` ${ui.bold("2.")} Connect your AI harness: ${ui.cmd("reaper-mcp init")}, then check it with ${ui.cmd("reaper-mcp doctor")}`);
|
|
11115
11521
|
if (webPort) {
|
|
11116
11522
|
console.log(`
|
|
@@ -11174,13 +11580,13 @@ async function isReaperRunning() {
|
|
|
11174
11580
|
}
|
|
11175
11581
|
async function enableWebInterface() {
|
|
11176
11582
|
console.log(ui.section("Enabling REAPER web interface..."));
|
|
11177
|
-
const iniPath =
|
|
11583
|
+
const iniPath = join21(getReaperResourcePath(), "reaper.ini");
|
|
11178
11584
|
if (!existsSync13(iniPath)) {
|
|
11179
11585
|
console.log(ui.item("warn", `Skipped: ${iniPath} not found (start REAPER once, quit it, then re-run setup)`));
|
|
11180
11586
|
return null;
|
|
11181
11587
|
}
|
|
11182
11588
|
const requested = Number(process.env["REAPER_WEB_PORT"]) || DEFAULT_WEB_PORT;
|
|
11183
|
-
const result = ensureWebInterface(
|
|
11589
|
+
const result = ensureWebInterface(readFileSync14(iniPath, "utf-8"), requested);
|
|
11184
11590
|
if (!result.changed) {
|
|
11185
11591
|
console.log(ui.item("ok", `Already enabled on port ${result.port}`));
|
|
11186
11592
|
return result.port;
|
|
@@ -11195,29 +11601,29 @@ async function enableWebInterface() {
|
|
|
11195
11601
|
console.log(" Quit REAPER to finish (Ctrl+C to skip)...");
|
|
11196
11602
|
while (await isReaperRunning()) await new Promise((r) => setTimeout(r, 1e3));
|
|
11197
11603
|
}
|
|
11198
|
-
|
|
11604
|
+
writeFileSync12(iniPath, ensureWebInterface(readFileSync14(iniPath, "utf-8"), requested).ini, "utf-8");
|
|
11199
11605
|
console.log(ui.item("ok", `Enabled on port ${result.port} (override with REAPER_WEB_PORT)`));
|
|
11200
11606
|
return result.port;
|
|
11201
11607
|
}
|
|
11202
11608
|
function installBridgeAutostart(scriptsDir) {
|
|
11203
11609
|
console.log(ui.section("Starting the bridge with REAPER..."));
|
|
11204
|
-
const path =
|
|
11205
|
-
const { text: text8, changed } = ensureBridgeAutostart(existsSync13(path) ?
|
|
11206
|
-
if (changed)
|
|
11610
|
+
const path = join21(scriptsDir, "__startup.lua");
|
|
11611
|
+
const { text: text8, changed } = ensureBridgeAutostart(existsSync13(path) ? readFileSync14(path, "utf-8") : "");
|
|
11612
|
+
if (changed) writeFileSync12(path, text8, "utf-8");
|
|
11207
11613
|
console.log(ui.item("ok", changed ? "Added to Scripts/__startup.lua (REAPER runs it at launch)" : "Already in Scripts/__startup.lua"));
|
|
11208
11614
|
console.log(ui.dim(" Turn it off in the bridge window: Settings > Start with REAPER."));
|
|
11209
11615
|
}
|
|
11210
11616
|
async function registerSnapshotActions() {
|
|
11211
11617
|
console.log(ui.section("Registering snapshot actions (quick save, next, previous)..."));
|
|
11212
|
-
const kbPath =
|
|
11213
|
-
const kb = existsSync13(kbPath) ?
|
|
11618
|
+
const kbPath = join21(getReaperResourcePath(), "reaper-kb.ini");
|
|
11619
|
+
const kb = existsSync13(kbPath) ? readFileSync14(kbPath, "utf-8") : "";
|
|
11214
11620
|
const { added } = ensureSnapshotActions(kb);
|
|
11215
11621
|
if (!added.length) {
|
|
11216
11622
|
console.log(ui.item("ok", "Already in the Action List"));
|
|
11217
11623
|
} else if (await isReaperRunning()) {
|
|
11218
11624
|
console.log(ui.item("info", "REAPER is running: the bridge adds them when it next starts (re-run mcp_bridge.lua)."));
|
|
11219
11625
|
} else {
|
|
11220
|
-
|
|
11626
|
+
writeFileSync12(kbPath, ensureSnapshotActions(kb).kb, "utf-8");
|
|
11221
11627
|
console.log(ui.item("ok", `Added: ${added.join(", ")}`));
|
|
11222
11628
|
}
|
|
11223
11629
|
console.log(`${ui.dim(" Bind keys in Actions > Show action list: search")} ${ui.cmd('"mcp_snapshot"')}${ui.dim(".")}`);
|
|
@@ -11250,11 +11656,11 @@ async function init(chained = false) {
|
|
|
11250
11656
|
for (const id of ids) {
|
|
11251
11657
|
const h = HARNESSES.find((x) => x.id === id);
|
|
11252
11658
|
if (id === "claude") {
|
|
11253
|
-
const settingsPath =
|
|
11254
|
-
|
|
11255
|
-
console.log(`${ui.mark("ok")} Claude settings (${MCP_TOOL_NAMES.length} REAPER tools allow-listed): ${ensureClaudeSettings(settingsPath)} \u2192 ${ui.dim(settingsPath.replace(
|
|
11659
|
+
const settingsPath = join21(homedir12(), ".claude", "settings.json");
|
|
11660
|
+
mkdirSync13(dirname12(settingsPath), { recursive: true });
|
|
11661
|
+
console.log(`${ui.mark("ok")} Claude settings (${MCP_TOOL_NAMES.length} REAPER tools allow-listed): ${ensureClaudeSettings(settingsPath)} \u2192 ${ui.dim(settingsPath.replace(homedir12(), "~"))}`);
|
|
11256
11662
|
if (inClone) {
|
|
11257
|
-
const mcpJsonPath =
|
|
11663
|
+
const mcpJsonPath = join21(process.cwd(), ".mcp.json");
|
|
11258
11664
|
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.`);
|
|
11259
11665
|
continue;
|
|
11260
11666
|
}
|
|
@@ -11291,7 +11697,7 @@ function installSkills(dryRun = false, ids) {
|
|
|
11291
11697
|
console.log("Running from a clone: scripts/sync-symlinks.sh links the skills and knowledge into ~/.claude and ~/.agents.");
|
|
11292
11698
|
return;
|
|
11293
11699
|
}
|
|
11294
|
-
const src =
|
|
11700
|
+
const src = join21(resolveAssetDir(__dirname2, "claude"));
|
|
11295
11701
|
if (!existsSync13(src)) {
|
|
11296
11702
|
console.log(`Skills not found: ${src} (this build has no claude/ folder)`);
|
|
11297
11703
|
process.exitCode = 1;
|
|
@@ -11310,9 +11716,9 @@ function installSkills(dryRun = false, ids) {
|
|
|
11310
11716
|
const homes = skillsHomes(targets.length ? targets : ["claude"]);
|
|
11311
11717
|
const verb = dryRun ? "Would install" : "Installed";
|
|
11312
11718
|
const jobs = [];
|
|
11313
|
-
if (homes.claude) jobs.push({ label: "~/.claude", dir:
|
|
11314
|
-
if (homes.agents) jobs.push({ label: "~/.agents", dir:
|
|
11315
|
-
if (homes.agents && !homes.claude) jobs.push({ label: "~/.claude", dir:
|
|
11719
|
+
if (homes.claude) jobs.push({ label: "~/.claude", dir: join21(homedir12(), ".claude"), what: "the mix skills, agents and knowledge" });
|
|
11720
|
+
if (homes.agents) jobs.push({ label: "~/.agents", dir: join21(homedir12(), ".agents"), include: ["skills", "agents"], what: "the mix skills and agents" });
|
|
11721
|
+
if (homes.agents && !homes.claude) jobs.push({ label: "~/.claude", dir: join21(homedir12(), ".claude"), include: ["knowledge"], what: "the knowledge base the skills read" });
|
|
11316
11722
|
for (const job of jobs) {
|
|
11317
11723
|
const r = installClaudeAssets(src, job.dir, { dryRun, include: job.include });
|
|
11318
11724
|
console.log(`${ui.mark("ok")} ${verb} ${job.what} in ${job.label}: ${r.installed.length} new, ${r.updated.length} updated, ${r.unchanged} already current.`);
|
|
@@ -11365,25 +11771,27 @@ async function doctor() {
|
|
|
11365
11771
|
core2.push(
|
|
11366
11772
|
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" }
|
|
11367
11773
|
);
|
|
11368
|
-
const readIfExists = (path) => existsSync13(path) ?
|
|
11774
|
+
const readIfExists = (path) => existsSync13(path) ? readFileSync14(path, "utf-8") : null;
|
|
11369
11775
|
core2.push(autostartCheck(
|
|
11370
|
-
readIfExists(
|
|
11371
|
-
readIfExists(
|
|
11776
|
+
readIfExists(join21(getReaperScriptsPath(), "__startup.lua")),
|
|
11777
|
+
readIfExists(join21(getReaperResourcePath(), "reaper-extstate.ini")),
|
|
11372
11778
|
await isReaperRunning()
|
|
11373
11779
|
));
|
|
11374
|
-
const
|
|
11375
|
-
|
|
11376
|
-
const
|
|
11377
|
-
const
|
|
11780
|
+
const forcedFlags = flagOverrideCheck();
|
|
11781
|
+
if (forcedFlags) core2.push(forcedFlags);
|
|
11782
|
+
const globalClaudeDir = join21(homedir12(), ".claude");
|
|
11783
|
+
const localSkills = existsSync13(join21(process.cwd(), ".claude", "skills", "mixer", "SKILL.md"));
|
|
11784
|
+
const globalSkills = existsSync13(join21(globalClaudeDir, "skills", "mixer", "SKILL.md"));
|
|
11785
|
+
const sharedSkills = existsSync13(join21(homedir12(), ".agents", "skills", "mixer", "SKILL.md"));
|
|
11378
11786
|
core2.push(
|
|
11379
11787
|
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" }
|
|
11380
11788
|
);
|
|
11381
|
-
const localKnowledge = existsSync13(
|
|
11382
|
-
const knowledgeLinked = localKnowledge || existsSync13(
|
|
11789
|
+
const localKnowledge = existsSync13(join21(process.cwd(), ".claude", "knowledge"));
|
|
11790
|
+
const knowledgeLinked = localKnowledge || existsSync13(join21(globalClaudeDir, "knowledge"));
|
|
11383
11791
|
core2.push(
|
|
11384
11792
|
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" }
|
|
11385
11793
|
);
|
|
11386
|
-
const mcpJsonExists = existsSync13(
|
|
11794
|
+
const mcpJsonExists = existsSync13(join21(process.cwd(), ".mcp.json"));
|
|
11387
11795
|
const harnessEnv = realEnv();
|
|
11388
11796
|
const installed = detectHarnesses(harnessEnv);
|
|
11389
11797
|
const connected = installed.filter((h) => registeredServer(h.id, harnessEnv));
|
|
@@ -11406,11 +11814,11 @@ async function doctor() {
|
|
|
11406
11814
|
status: "info",
|
|
11407
11815
|
detail: { default: "On, pseudonymous \xB7 turn off: reaper-mcp telemetry off", custom: "Your own OTEL_* destination", off: "Off" }[telemetry]
|
|
11408
11816
|
});
|
|
11409
|
-
const sidecarVenvPath =
|
|
11817
|
+
const sidecarVenvPath = join21(homedir12(), ".reaper-mcp", "sidecar-venv");
|
|
11410
11818
|
const venvBin = platform6() === "win32" ? "Scripts" : "bin";
|
|
11411
11819
|
const venvPythonName = platform6() === "win32" ? "python.exe" : "python";
|
|
11412
|
-
const venvPython =
|
|
11413
|
-
const hfCachePath =
|
|
11820
|
+
const venvPython = join21(sidecarVenvPath, venvBin, venvPythonName);
|
|
11821
|
+
const hfCachePath = join21(homedir12(), ".cache", "huggingface", "hub");
|
|
11414
11822
|
let pythonOk = false;
|
|
11415
11823
|
let pythonDetail = "Not found";
|
|
11416
11824
|
try {
|
|
@@ -11443,14 +11851,14 @@ async function doctor() {
|
|
|
11443
11851
|
addOns.demucs = found.separation;
|
|
11444
11852
|
addOns.lv_chordia = found.chords;
|
|
11445
11853
|
}
|
|
11446
|
-
const weightsPath =
|
|
11854
|
+
const weightsPath = join21(hfCachePath, "models--facebook--audiobox-aesthetics");
|
|
11447
11855
|
const weightsExist = existsSync13(weightsPath);
|
|
11448
11856
|
const sidecarReady = venvExists && depsOk;
|
|
11449
11857
|
const sidecarOptedIn = venvExists;
|
|
11450
11858
|
const sidecarBroken = sidecarOptedIn && !sidecarReady;
|
|
11451
11859
|
const missing = sidecarOptedIn ? "fail" : "info";
|
|
11452
11860
|
const repair = "reaper-mcp setup-sidecar";
|
|
11453
|
-
const home = (p) => p.replace(
|
|
11861
|
+
const home = (p) => p.replace(homedir12(), "~");
|
|
11454
11862
|
const sidecar = {
|
|
11455
11863
|
title: "Python sidecar",
|
|
11456
11864
|
note: "optional \xB7 lets Claude listen to the audio",
|
|
@@ -11609,7 +12017,7 @@ async function updateCommand(force, bridge) {
|
|
|
11609
12017
|
child.on("close", (code) => resolveCode(code ?? 1));
|
|
11610
12018
|
});
|
|
11611
12019
|
}
|
|
11612
|
-
return runUpdate(realUpdateDeps(readServiceVersion(),
|
|
12020
|
+
return runUpdate(realUpdateDeps(readServiceVersion(), join21(__dirname2, "main.js"), force, bridge));
|
|
11613
12021
|
}
|
|
11614
12022
|
var command = process.argv[2];
|
|
11615
12023
|
switch (command) {
|
|
@@ -11652,6 +12060,9 @@ switch (command) {
|
|
|
11652
12060
|
process.exit(1);
|
|
11653
12061
|
});
|
|
11654
12062
|
break;
|
|
12063
|
+
case "flags":
|
|
12064
|
+
process.exit(flagsCommand(process.argv.slice(3)));
|
|
12065
|
+
break;
|
|
11655
12066
|
case "extension":
|
|
11656
12067
|
case "extensions":
|
|
11657
12068
|
extensionCommand(process.argv.slice(3)).then(
|
|
@@ -11706,6 +12117,7 @@ Usage:
|
|
|
11706
12117
|
reaper-mcp update Update to the latest release (npm install: downloads it and installs it into REAPER; --force reinstalls)
|
|
11707
12118
|
reaper-mcp doctor Check that everything is configured correctly
|
|
11708
12119
|
reaper-mcp status Check if Lua bridge is running in REAPER
|
|
12120
|
+
reaper-mcp flags List feature flags and how they resolve here; set <key> <variant> forces one on this install only; reset [key]
|
|
11709
12121
|
reaper-mcp telemetry off Opt out of pseudonymous usage telemetry (also: on, status)
|
|
11710
12122
|
|
|
11711
12123
|
Quick Start (from npm):
|