railyard/packages/mcp/test/copy.test.mjs
caelum0x f32e27244f feat(mcp): Railyard MCP server and agent skill (RYP-D5, Y-5)
railyard-mcp (stdio, MCP TypeScript SDK) with seven tools, all marked
read-only for the agent:
- deploy.run returns the exact npx railyard deploy command (login first
  when signed out); the deploy itself runs on the user's machine.
- deploy.list and usage.current read the console API with the org
  token saved by railyard login; a token only ever sees its own org.
- insights.summary and insights.funnel say no_data_yet until an
  Insights query store is configured (RYP-D2), then pass its numbers.
- flags.list reports arriving and lists nothing.
- gateway.traces reads /relay/traces (RY-RL3) with the gateway key in the
  environment; Relay limits it to that key's own calls.
Arguments are schema-checked; errors are explicit, never an empty
success; no token appears in any output.

packages/skills: a Claude Code plugin (manifest starting railyard-mcp)
with a railyard skill (deploy, Cloudflare login in the browser, rollback,
no invented numbers) and a README.

Tests: annotation linter over tools/list, org A/B isolation against the
real console token and deploy code, signed-out and expired paths,
insights and gateway paths, a stdio round trip, and the copy lint over
both READMEs, the skill and every tool string.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 16:35:39 +03:00

29 lines
1.5 KiB
JavaScript

// The plugin README, the MCP README, the skill and every tool description and
// message pass the vendored copy denylist (docs surface).
import { test } from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import { errors, formatFindings, lintUnits, markdownUnits } from "../../../policy/copy-lint.mjs";
import { TOOLS } from "../src/tools.mjs";
const HERE = dirname(fileURLToPath(import.meta.url));
const R = (p) => readFileSync(join(HERE, "..", p), "utf8");
test("plugin README, MCP README and SKILL.md pass the copy lint", () => {
const units = ["README.md", "../skills/README.md", "../skills/skills/railyard/SKILL.md"].flatMap((f) => markdownUnits(R(f), { where: f }));
const found = errors(lintUnits(units));
assert.deepEqual(found, [], formatFindings(found));
const plugin = JSON.parse(R("../skills/.claude-plugin/plugin.json"));
assert.deepEqual(errors(lintUnits([{ text: plugin.description, surface: "docs" }])), []);
});
test("tool titles, descriptions and messages pass the copy lint", () => {
const src = R("src/tools.mjs");
const strings = [...src.matchAll(/"([^"\n]{12,})"/g)].map((m) => m[1]).filter((s) => !/^[\^[]/.test(s));
const units = [...TOOLS.flatMap((t) => [t.title, t.description]), ...strings].map((text) => ({ text, surface: "docs" }));
const found = errors(lintUnits(units));
assert.deepEqual(found, [], formatFindings(found));
});