fix(native): pass Swift symbols to swift-demangle as operands
`swift-demangle` parsed a symbol beginning with `-` as an option, so `-help` replaced the results with usage text and the call failed as unreadable output. A symbol containing a line feed split into extra output records, and the CRLF-tolerant parser stripped a carriage return that belonged to the final symbol. Pass the symbols after `--`, split records on the LF the demangler emits, and reject multi-line symbols in the shared CLI/MCP input schema. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
676959ecb5
commit
6c88094da4
@@ -48,6 +48,16 @@ const native = <Name extends string, Schema extends z.ZodObject>(
|
||||
} satisfies ToolContract<Name, Schema, typeof outputSchema>;
|
||||
};
|
||||
|
||||
/** Ordered single-line symbols; `swift-demangle` ends each result with LF. */
|
||||
export const swiftSymbolsSchema = z
|
||||
.array(
|
||||
z
|
||||
.string()
|
||||
.min(1)
|
||||
.regex(/^[^\n]*$/u, "Each Swift symbol must be one line."),
|
||||
)
|
||||
.min(1);
|
||||
|
||||
/** Provider-neutral semantic operations backed initially by macOS utilities. */
|
||||
export const NATIVE_TOOL_CONTRACTS = [
|
||||
native(
|
||||
@@ -84,9 +94,9 @@ export const NATIVE_TOOL_CONTRACTS = [
|
||||
),
|
||||
native(
|
||||
"demangle_swift",
|
||||
"Demangle an ordered list of Swift symbols without requiring Hopper. Each input returns demangled, unchanged, or invalid status.",
|
||||
"Demangle an ordered list of single-line Swift symbols without requiring Hopper. Each input returns demangled, unchanged, or invalid status.",
|
||||
z.object({
|
||||
symbols: z.array(z.string().min(1)).min(1),
|
||||
symbols: swiftSymbolsSchema,
|
||||
}),
|
||||
),
|
||||
] as const satisfies readonly ToolContract[];
|
||||
|
||||
Reference in New Issue
Block a user