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