decode_interface_builder returns the complete object, hierarchy and connection graph inline. XLD.app's graph is 6.7 MB (about 1.98M o200k tokens) and Transmission.app's 6.3 MB; over MCP the doubled text and structured content exceed the default response budget, so an agent got a resource_constraint error instead of any answer. Add the established opt-in delivery: omitted or complete detail keeps the complete result and its Evidence ID, while summary retains the complete Evidence and returns every decoded document with node-kind, edge-relation and coverage-status tallies (10k tokens for XLD). inspect_analysis_view kind interface-builder pages documents, nodes, edges or coverage; nodes and edges accept an exact decoded document path, matched against each row's recorded evidence, and an undecoded path is refused. Decoder truncation stays visible on every page. Related cleanup, since the new code repeated it a ninth time: - parseAnalysisViewResult owns parsing a view parent's normalized result with the operation's schema and mapping issues into the view source. - retainedSummaryDelivery owns the preflight/summary hook pair and the shared registration options for artifact, native and managed tools. - openProductionTarget owns the production MCP session test setup. Duplication drops from 3.02% to 2.98% (threshold 3.0%). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
73 lines
2.4 KiB
TypeScript
73 lines
2.4 KiB
TypeScript
import { copyFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
|
|
import { describe, expect } from "vitest";
|
|
import { z } from "zod";
|
|
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
import { mcpTest } from "../../support/mcp/mcpFixture.js";
|
|
import { openProductionTarget } from "../../support/mcp/productionSession.js";
|
|
|
|
const demangledSchema = z.object({
|
|
normalized_result: z.object({
|
|
symbols: z.array(
|
|
z.object({ input: z.string(), output: z.string(), status: z.string() }),
|
|
),
|
|
}),
|
|
});
|
|
|
|
describe.skipIf(process.platform !== "darwin")(
|
|
"native Swift demangling through MCP",
|
|
() => {
|
|
mcpTest(
|
|
"passes option-like symbols to swift-demangle as symbols",
|
|
async ({ mcp, onTestFinished }) => {
|
|
const target = join(
|
|
await createTestTempDirectory("rea-demangle-mcp-"),
|
|
"tool",
|
|
);
|
|
await copyFile("/usr/bin/true", target);
|
|
const client = await openProductionTarget(mcp, onTestFinished, target);
|
|
|
|
const called = await client.callTool({
|
|
name: "demangle_swift",
|
|
arguments: {
|
|
symbols: ["-help", "--simplified", "$s4main3FooV", "carriage\r"],
|
|
},
|
|
});
|
|
expect(called.isError, JSON.stringify(called.content)).not.toBe(true);
|
|
expect(
|
|
demangledSchema.parse(called.structuredContent).normalized_result
|
|
.symbols,
|
|
).toEqual([
|
|
{ input: "-help", output: "-help", status: "unchanged" },
|
|
{
|
|
input: "--simplified",
|
|
output: "--simplified",
|
|
status: "unchanged",
|
|
},
|
|
{ input: "$s4main3FooV", output: "main.Foo", status: "demangled" },
|
|
{ input: "carriage\r", output: "carriage\r", status: "unchanged" },
|
|
]);
|
|
|
|
const spanning = await client.callTool({
|
|
name: "demangle_swift",
|
|
arguments: { symbols: ["$s4main\n3FooV"] },
|
|
});
|
|
expect(spanning.isError).toBe(true);
|
|
expect(JSON.stringify(spanning.content)).toContain(
|
|
"Each Swift symbol must be one line.",
|
|
);
|
|
const invalidNativeString = await client.callTool({
|
|
name: "demangle_swift",
|
|
arguments: { symbols: ["$s4main\0FooV"] },
|
|
});
|
|
expect(invalidNativeString.isError).toBe(true);
|
|
expect(JSON.stringify(invalidNativeString.content)).toContain(
|
|
"Swift symbols cannot contain NUL.",
|
|
);
|
|
},
|
|
);
|
|
},
|
|
);
|