style: revert Prettier formatting in TS files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Eugene Mikhantyev
2026-03-29 12:28:30 +01:00
parent 7d53272cb1
commit 8b0ed30ee3
2 changed files with 370 additions and 484 deletions

View File

@@ -4,7 +4,7 @@
* Centralizes all tool definitions and provides lookup/search functionality * Centralizes all tool definitions and provides lookup/search functionality
*/ */
import { z } from "zod"; import { z } from 'zod';
export interface ToolDefinition { export interface ToolDefinition {
name: string; name: string;
@@ -26,8 +26,7 @@ export interface ToolCategory {
export const toolCategories: ToolCategory[] = [ export const toolCategories: ToolCategory[] = [
{ {
name: "board", name: "board",
description: description: "Board configuration: layers, mounting holes, zones, visualization",
"Board configuration: layers, mounting holes, zones, visualization",
tools: [ tools: [
"add_layer", "add_layer",
"set_active_layer", "set_active_layer",
@@ -37,13 +36,12 @@ export const toolCategories: ToolCategory[] = [
"add_zone", "add_zone",
"get_board_extents", "get_board_extents",
"get_board_2d_view", "get_board_2d_view",
"launch_kicad_ui", "launch_kicad_ui"
], ]
}, },
{ {
name: "component", name: "component",
description: description: "Advanced component operations: edit, delete, search, group, annotate",
"Advanced component operations: edit, delete, search, group, annotate",
tools: [ tools: [
"rotate_component", "rotate_component",
"delete_component", "delete_component",
@@ -52,13 +50,12 @@ export const toolCategories: ToolCategory[] = [
"get_component_properties", "get_component_properties",
"add_component_annotation", "add_component_annotation",
"group_components", "group_components",
"replace_component", "replace_component"
], ]
}, },
{ {
name: "export", name: "export",
description: description: "File export for fabrication and documentation: Gerber, PDF, BOM, 3D models",
"File export for fabrication and documentation: Gerber, PDF, BOM, 3D models",
tools: [ tools: [
"export_gerber", "export_gerber",
"export_pdf", "export_pdf",
@@ -67,13 +64,12 @@ export const toolCategories: ToolCategory[] = [
"export_bom", "export_bom",
"export_netlist", "export_netlist",
"export_position_file", "export_position_file",
"export_vrml", "export_vrml"
], ]
}, },
{ {
name: "drc", name: "drc",
description: description: "Design rule checking and electrical validation: DRC, net classes, clearances",
"Design rule checking and electrical validation: DRC, net classes, clearances",
tools: [ tools: [
"set_design_rules", "set_design_rules",
"get_design_rules", "get_design_rules",
@@ -82,13 +78,12 @@ export const toolCategories: ToolCategory[] = [
"assign_net_to_class", "assign_net_to_class",
"set_layer_constraints", "set_layer_constraints",
"check_clearance", "check_clearance",
"get_drc_violations", "get_drc_violations"
], ]
}, },
{ {
name: "schematic", name: "schematic",
description: description: "Schematic operations: create, inspect, add/edit/delete components, wire connections, netlists, annotation",
"Schematic operations: create, inspect, add/edit/delete components, wire connections, netlists, annotation",
tools: [ tools: [
"create_schematic", "create_schematic",
"add_schematic_component", "add_schematic_component",
@@ -112,31 +107,37 @@ export const toolCategories: ToolCategory[] = [
"sync_schematic_to_board", "sync_schematic_to_board",
"get_schematic_view", "get_schematic_view",
"export_schematic_svg", "export_schematic_svg",
"export_schematic_pdf", "export_schematic_pdf"
], ]
}, },
{ {
name: "library", name: "library",
description: description: "Footprint library access: search, browse, get footprint information",
"Footprint library access: search, browse, get footprint information",
tools: [ tools: [
"list_libraries", "list_libraries",
"search_footprints", "search_footprints",
"list_library_footprints", "list_library_footprints",
"get_footprint_info", "get_footprint_info"
], ]
}, },
{ {
name: "routing", name: "routing",
description: "Advanced routing operations: vias, copper pours", description: "Advanced routing operations: vias, copper pours",
tools: ["add_via", "add_copper_pour"], tools: [
"add_via",
"add_copper_pour"
]
}, },
{ {
name: "autoroute", name: "autoroute",
description: description: "Freerouting autorouter: automatic PCB routing via Specctra DSN/SES",
"Freerouting autorouter: automatic PCB routing via Specctra DSN/SES", tools: [
tools: ["autoroute", "export_dsn", "import_ses", "check_freerouting"], "autoroute",
}, "export_dsn",
"import_ses",
"check_freerouting"
]
}
]; ];
/** /**
@@ -174,7 +175,7 @@ export const directToolNames = [
"sync_schematic_to_board", "sync_schematic_to_board",
// UI management // UI management
"check_kicad_ui", "check_kicad_ui"
]; ];
// Build lookup maps at module load time // Build lookup maps at module load time
@@ -259,7 +260,7 @@ export function searchTools(query: string): SearchResult[] {
matches.push({ matches.push({
category: "direct", category: "direct",
tool: toolName, tool: toolName,
description: `${toolName} (direct tool — call directly, no execute_tool needed)`, description: `${toolName} (direct tool — call directly, no execute_tool needed)`
}); });
} }
} }
@@ -275,7 +276,7 @@ export function searchTools(query: string): SearchResult[] {
matches.push({ matches.push({
category: category.name, category: category.name,
tool: toolName, tool: toolName,
description: `${toolName} (${category.name})`, description: `${toolName} (${category.name})`
}); });
} }
} }
@@ -296,10 +297,10 @@ export function getRegistryStats() {
total_routed_tools: routedToolCount, total_routed_tools: routedToolCount,
total_direct_tools: directToolCount, total_direct_tools: directToolCount,
total_tools: routedToolCount + directToolCount, total_tools: routedToolCount + directToolCount,
categories: toolCategories.map((c) => ({ categories: toolCategories.map(c => ({
name: c.name, name: c.name,
tool_count: c.tools.length, tool_count: c.tools.length
})), }))
}; };
} }

View File

@@ -161,37 +161,15 @@ preserves the component's position and UUID.
Note: operates on .kicad_sch files only. To modify a PCB footprint use edit_component.`, Note: operates on .kicad_sch files only. To modify a PCB footprint use edit_component.`,
{ {
schematicPath: z.string().describe("Path to the .kicad_sch file"), schematicPath: z.string().describe("Path to the .kicad_sch file"),
reference: z reference: z.string().describe("Current reference designator of the component (e.g. R1, U3)"),
.string() footprint: z.string().optional().describe("New KiCAD footprint string (e.g. Resistor_SMD:R_0603_1608Metric)"),
.describe( value: z.string().optional().describe("New value string (e.g. 10k, 100nF)"),
"Current reference designator of the component (e.g. R1, U3)", newReference: z.string().optional().describe("Rename the reference designator (e.g. R1 → R10)"),
), fieldPositions: z.record(z.object({
footprint: z x: z.number(),
.string() y: z.number(),
.optional() angle: z.number().optional().default(0),
.describe( })).optional().describe("Reposition field labels: map of field name to {x, y, angle} (e.g. {\"Reference\": {\"x\": 12.5, \"y\": 17.0}})"),
"New KiCAD footprint string (e.g. Resistor_SMD:R_0603_1608Metric)",
),
value: z
.string()
.optional()
.describe("New value string (e.g. 10k, 100nF)"),
newReference: z
.string()
.optional()
.describe("Rename the reference designator (e.g. R1 → R10)"),
fieldPositions: z
.record(
z.object({
x: z.number(),
y: z.number(),
angle: z.number().optional().default(0),
}),
)
.optional()
.describe(
'Reposition field labels: map of field name to {x, y, angle} (e.g. {"Reference": {"x": 12.5, "y": 17.0}})',
),
}, },
async (args: { async (args: {
schematicPath: string; schematicPath: string;
@@ -232,9 +210,7 @@ Note: operates on .kicad_sch files only. To modify a PCB footprint use edit_comp
"Get full component info from a schematic: position, field values, and each field's label position (at x/y/angle). Use this to inspect or prepare repositioning of Reference/Value labels.", "Get full component info from a schematic: position, field values, and each field's label position (at x/y/angle). Use this to inspect or prepare repositioning of Reference/Value labels.",
{ {
schematicPath: z.string().describe("Path to the .kicad_sch file"), schematicPath: z.string().describe("Path to the .kicad_sch file"),
reference: z reference: z.string().describe("Component reference designator (e.g. R1, U1)"),
.string()
.describe("Component reference designator (e.g. R1, U1)"),
}, },
async (args: { schematicPath: string; reference: string }) => { async (args: { schematicPath: string; reference: string }) => {
const result = await callKicadScript("get_schematic_component", args); const result = await callKicadScript("get_schematic_component", args);
@@ -244,24 +220,20 @@ Note: operates on .kicad_sch files only. To modify a PCB footprint use edit_comp
: "unknown"; : "unknown";
const fieldLines = Object.entries(result.fields ?? {}).map( const fieldLines = Object.entries(result.fields ?? {}).map(
([name, f]: [string, any]) => ([name, f]: [string, any]) =>
` ${name}: "${f.value}" @ (${f.x}, ${f.y}, angle=${f.angle}°)`, ` ${name}: "${f.value}" @ (${f.x}, ${f.y}, angle=${f.angle}°)`
); );
return { return {
content: [ content: [{
{ type: "text",
type: "text", text: `Component ${result.reference} at ${pos}\nFields:\n${fieldLines.join("\n")}`,
text: `Component ${result.reference} at ${pos}\nFields:\n${fieldLines.join("\n")}`, }],
},
],
}; };
} }
return { return {
content: [ content: [{
{ type: "text",
type: "text", text: `Failed to get component: ${result.message || "Unknown error"}`,
text: `Failed to get component: ${result.message || "Unknown error"}`, }],
},
],
}; };
}, },
); );
@@ -608,14 +580,8 @@ Note: operates on .kicad_sch files only. To modify a PCB footprint use edit_comp
schematicPath: z.string().describe("Path to the .kicad_sch file"), schematicPath: z.string().describe("Path to the .kicad_sch file"),
filter: z filter: z
.object({ .object({
libId: z libId: z.string().optional().describe("Filter by library ID (e.g., 'Device:R')"),
.string() referencePrefix: z.string().optional().describe("Filter by reference prefix (e.g., 'R', 'C', 'U')"),
.optional()
.describe("Filter by library ID (e.g., 'Device:R')"),
referencePrefix: z
.string()
.optional()
.describe("Filter by reference prefix (e.g., 'R', 'C', 'U')"),
}) })
.optional() .optional()
.describe("Optional filters"), .describe("Optional filters"),
@@ -629,9 +595,7 @@ Note: operates on .kicad_sch files only. To modify a PCB footprint use edit_comp
const comps = result.components || []; const comps = result.components || [];
if (comps.length === 0) { if (comps.length === 0) {
return { return {
content: [ content: [{ type: "text", text: "No components found in schematic." }],
{ type: "text", text: "No components found in schematic." },
],
}; };
} }
const lines = comps.map( const lines = comps.map(
@@ -692,10 +656,7 @@ Note: operates on .kicad_sch files only. To modify a PCB footprint use edit_comp
} }
return { return {
content: [ content: [
{ { type: "text", text: `Failed to list nets: ${result.message || "Unknown error"}` },
type: "text",
text: `Failed to list nets: ${result.message || "Unknown error"}`,
},
], ],
isError: true, isError: true,
}; };
@@ -733,10 +694,7 @@ Note: operates on .kicad_sch files only. To modify a PCB footprint use edit_comp
} }
return { return {
content: [ content: [
{ { type: "text", text: `Failed to list wires: ${result.message || "Unknown error"}` },
type: "text",
text: `Failed to list wires: ${result.message || "Unknown error"}`,
},
], ],
isError: true, isError: true,
}; };
@@ -774,10 +732,7 @@ Note: operates on .kicad_sch files only. To modify a PCB footprint use edit_comp
} }
return { return {
content: [ content: [
{ { type: "text", text: `Failed to list labels: ${result.message || "Unknown error"}` },
type: "text",
text: `Failed to list labels: ${result.message || "Unknown error"}`,
},
], ],
isError: true, isError: true,
}; };
@@ -834,7 +789,10 @@ Note: operates on .kicad_sch files only. To modify a PCB footprint use edit_comp
schematicPath: z.string().describe("Path to the .kicad_sch file"), schematicPath: z.string().describe("Path to the .kicad_sch file"),
reference: z.string().describe("Reference designator (e.g., R1, U1)"), reference: z.string().describe("Reference designator (e.g., R1, U1)"),
angle: z.number().describe("Rotation angle in degrees (0, 90, 180, 270)"), angle: z.number().describe("Rotation angle in degrees (0, 90, 180, 270)"),
mirror: z.enum(["x", "y"]).optional().describe("Optional mirror axis"), mirror: z
.enum(["x", "y"])
.optional()
.describe("Optional mirror axis"),
}, },
async (args: { async (args: {
schematicPath: string; schematicPath: string;
@@ -1078,14 +1036,8 @@ Note: operates on .kicad_sch files only. To modify a PCB footprint use edit_comp
.enum(["png", "svg"]) .enum(["png", "svg"])
.optional() .optional()
.describe("Output format (default: png)"), .describe("Output format (default: png)"),
width: z width: z.number().optional().describe("Image width in pixels (default: 1200)"),
.number() height: z.number().optional().describe("Image height in pixels (default: 900)"),
.optional()
.describe("Image width in pixels (default: 1200)"),
height: z
.number()
.optional()
.describe("Image height in pixels (default: 900)"),
}, },
async (args: { async (args: {
schematicPath: string; schematicPath: string;
@@ -1255,35 +1207,19 @@ Note: operates on .kicad_sch files only. To modify a PCB footprint use edit_comp
"get_schematic_view_region", "get_schematic_view_region",
"Export a cropped region of the schematic as an image (PNG or SVG). Specify bounding box coordinates in schematic mm. Useful for zooming into a specific area to inspect wiring or layout.", "Export a cropped region of the schematic as an image (PNG or SVG). Specify bounding box coordinates in schematic mm. Useful for zooming into a specific area to inspect wiring or layout.",
{ {
schematicPath: z schematicPath: z.string().describe("Path to the .kicad_sch schematic file"),
.string()
.describe("Path to the .kicad_sch schematic file"),
x1: z.number().describe("Left X coordinate of the region in mm"), x1: z.number().describe("Left X coordinate of the region in mm"),
y1: z.number().describe("Top Y coordinate of the region in mm"), y1: z.number().describe("Top Y coordinate of the region in mm"),
x2: z.number().describe("Right X coordinate of the region in mm"), x2: z.number().describe("Right X coordinate of the region in mm"),
y2: z.number().describe("Bottom Y coordinate of the region in mm"), y2: z.number().describe("Bottom Y coordinate of the region in mm"),
format: z format: z.enum(["png", "svg"]).optional().describe("Output image format (default: png)"),
.enum(["png", "svg"]) width: z.number().optional().describe("Output image width in pixels (default: 800)"),
.optional() height: z.number().optional().describe("Output image height in pixels (default: 600)"),
.describe("Output image format (default: png)"),
width: z
.number()
.optional()
.describe("Output image width in pixels (default: 800)"),
height: z
.number()
.optional()
.describe("Output image height in pixels (default: 600)"),
}, },
async (args: { async (args: {
schematicPath: string; schematicPath: string;
x1: number; x1: number; y1: number; x2: number; y2: number;
y1: number; format?: string; width?: number; height?: number;
x2: number;
y2: number;
format?: string;
width?: number;
height?: number;
}) => { }) => {
const result = await callKicadScript("get_schematic_view_region", args); const result = await callKicadScript("get_schematic_view_region", args);
if (result.success && result.imageData) { if (result.success && result.imageData) {
@@ -1291,40 +1227,27 @@ Note: operates on .kicad_sch files only. To modify a PCB footprint use edit_comp
return { content: [{ type: "text", text: result.imageData }] }; return { content: [{ type: "text", text: result.imageData }] };
} }
return { return {
content: [ content: [{
{ type: "image",
type: "image", data: result.imageData,
data: result.imageData, mimeType: "image/png",
mimeType: "image/png", }],
},
],
}; };
} }
return { return {
content: [ content: [{ type: "text", text: `Failed: ${result.message || "Unknown error"}` }],
{
type: "text",
text: `Failed: ${result.message || "Unknown error"}`,
},
],
}; };
}, },
); );
// Find overlapping elements // Find overlapping elements
server.tool( server.tool(
"find_overlapping_elements", "find_overlapping_elements",
"Detect spatially overlapping symbols, wires, and labels in the schematic. Finds duplicate power symbols at the same position, collinear overlapping wires, and labels stacked on top of each other.", "Detect spatially overlapping symbols, wires, and labels in the schematic. Finds duplicate power symbols at the same position, collinear overlapping wires, and labels stacked on top of each other.",
{ {
schematicPath: z schematicPath: z.string().describe("Path to the .kicad_sch schematic file"),
.string() tolerance: z.number().optional().describe("Distance threshold in mm for label proximity and wire collinearity checks. Symbol overlap uses bounding-box intersection. (default: 0.5)"),
.describe("Path to the .kicad_sch schematic file"),
tolerance: z
.number()
.optional()
.describe(
"Distance threshold in mm for label proximity and wire collinearity checks. Symbol overlap uses bounding-box intersection. (default: 0.5)",
),
}, },
async (args: { schematicPath: string; tolerance?: number }) => { async (args: { schematicPath: string; tolerance?: number }) => {
const result = await callKicadScript("find_overlapping_elements", args); const result = await callKicadScript("find_overlapping_elements", args);
@@ -1336,36 +1259,25 @@ Note: operates on .kicad_sch files only. To modify a PCB footprint use edit_comp
if (syms.length) { if (syms.length) {
lines.push(`\nOverlapping symbols (${syms.length}):`); lines.push(`\nOverlapping symbols (${syms.length}):`);
syms.slice(0, 20).forEach((o: any) => { syms.slice(0, 20).forEach((o: any) => {
lines.push( lines.push(` ${o.element1.reference}${o.element2.reference} (${o.distance}mm) [${o.type}]`);
` ${o.element1.reference}${o.element2.reference} (${o.distance}mm) [${o.type}]`,
);
}); });
} }
if (lbls.length) { if (lbls.length) {
lines.push(`\nOverlapping labels (${lbls.length}):`); lines.push(`\nOverlapping labels (${lbls.length}):`);
lbls.slice(0, 20).forEach((o: any) => { lbls.slice(0, 20).forEach((o: any) => {
lines.push( lines.push(` "${o.element1.name}" ↔ "${o.element2.name}" (${o.distance}mm)`);
` "${o.element1.name}" ↔ "${o.element2.name}" (${o.distance}mm)`,
);
}); });
} }
if (wires.length) { if (wires.length) {
lines.push(`\nOverlapping wires (${wires.length}):`); lines.push(`\nOverlapping wires (${wires.length}):`);
wires.slice(0, 20).forEach((o: any) => { wires.slice(0, 20).forEach((o: any) => {
lines.push( lines.push(` wire @ (${o.wire1.start.x},${o.wire1.start.y})→(${o.wire1.end.x},${o.wire1.end.y}) overlaps with another`);
` wire @ (${o.wire1.start.x},${o.wire1.start.y})→(${o.wire1.end.x},${o.wire1.end.y}) overlaps with another`,
);
}); });
} }
return { content: [{ type: "text", text: lines.join("\n") }] }; return { content: [{ type: "text", text: lines.join("\n") }] };
} }
return { return {
content: [ content: [{ type: "text", text: `Failed: ${result.message || "Unknown error"}` }],
{
type: "text",
text: `Failed: ${result.message || "Unknown error"}`,
},
],
}; };
}, },
); );
@@ -1375,9 +1287,7 @@ Note: operates on .kicad_sch files only. To modify a PCB footprint use edit_comp
"get_elements_in_region", "get_elements_in_region",
"List all symbols, wires, and labels within a rectangular region of the schematic. Useful for understanding what is in a specific area before modifying it.", "List all symbols, wires, and labels within a rectangular region of the schematic. Useful for understanding what is in a specific area before modifying it.",
{ {
schematicPath: z schematicPath: z.string().describe("Path to the .kicad_sch schematic file"),
.string()
.describe("Path to the .kicad_sch schematic file"),
x1: z.number().describe("Left X coordinate of the region in mm"), x1: z.number().describe("Left X coordinate of the region in mm"),
y1: z.number().describe("Top Y coordinate of the region in mm"), y1: z.number().describe("Top Y coordinate of the region in mm"),
x2: z.number().describe("Right X coordinate of the region in mm"), x2: z.number().describe("Right X coordinate of the region in mm"),
@@ -1385,56 +1295,39 @@ Note: operates on .kicad_sch files only. To modify a PCB footprint use edit_comp
}, },
async (args: { async (args: {
schematicPath: string; schematicPath: string;
x1: number; x1: number; y1: number; x2: number; y2: number;
y1: number;
x2: number;
y2: number;
}) => { }) => {
const result = await callKicadScript("get_elements_in_region", args); const result = await callKicadScript("get_elements_in_region", args);
if (result.success) { if (result.success) {
const c = result.counts; const c = result.counts;
const lines = [ const lines = [`Region (${args.x1},${args.y1})→(${args.x2},${args.y2}): ${c.symbols} symbols, ${c.wires} wires, ${c.labels} labels`];
`Region (${args.x1},${args.y1})→(${args.x2},${args.y2}): ${c.symbols} symbols, ${c.wires} wires, ${c.labels} labels`,
];
const syms: any[] = result.symbols || []; const syms: any[] = result.symbols || [];
if (syms.length) { if (syms.length) {
lines.push("\nSymbols:"); lines.push("\nSymbols:");
syms.forEach((s: any) => { syms.forEach((s: any) => {
const pinCount = s.pins ? Object.keys(s.pins).length : 0; const pinCount = s.pins ? Object.keys(s.pins).length : 0;
lines.push( lines.push(` ${s.reference} (${s.libId}) @ (${s.position.x}, ${s.position.y}) [${pinCount} pins]`);
` ${s.reference} (${s.libId}) @ (${s.position.x}, ${s.position.y}) [${pinCount} pins]`,
);
}); });
} }
const wires: any[] = result.wires || []; const wires: any[] = result.wires || [];
if (wires.length) { if (wires.length) {
lines.push(`\nWires (${wires.length}):`); lines.push(`\nWires (${wires.length}):`);
wires.slice(0, 30).forEach((w: any) => { wires.slice(0, 30).forEach((w: any) => {
lines.push( lines.push(` (${w.start.x},${w.start.y}) → (${w.end.x},${w.end.y})`);
` (${w.start.x},${w.start.y}) → (${w.end.x},${w.end.y})`,
);
}); });
if (wires.length > 30) if (wires.length > 30) lines.push(` ... and ${wires.length - 30} more`);
lines.push(` ... and ${wires.length - 30} more`);
} }
const labels: any[] = result.labels || []; const labels: any[] = result.labels || [];
if (labels.length) { if (labels.length) {
lines.push(`\nLabels (${labels.length}):`); lines.push(`\nLabels (${labels.length}):`);
labels.forEach((l: any) => { labels.forEach((l: any) => {
lines.push( lines.push(` "${l.name}" [${l.type}] @ (${l.position.x}, ${l.position.y})`);
` "${l.name}" [${l.type}] @ (${l.position.x}, ${l.position.y})`,
);
}); });
} }
return { content: [{ type: "text", text: lines.join("\n") }] }; return { content: [{ type: "text", text: lines.join("\n") }] };
} }
return { return {
content: [ content: [{ type: "text", text: `Failed: ${result.message || "Unknown error"}` }],
{
type: "text",
text: `Failed: ${result.message || "Unknown error"}`,
},
],
}; };
}, },
); );
@@ -1444,9 +1337,7 @@ Note: operates on .kicad_sch files only. To modify a PCB footprint use edit_comp
"find_wires_crossing_symbols", "find_wires_crossing_symbols",
"Find all wires that cross over component symbol bodies. Wires passing over symbols are unacceptable in schematics — they indicate routing mistakes where a wire was drawn across a component instead of around it.", "Find all wires that cross over component symbol bodies. Wires passing over symbols are unacceptable in schematics — they indicate routing mistakes where a wire was drawn across a component instead of around it.",
{ {
schematicPath: z schematicPath: z.string().describe("Path to the .kicad_sch schematic file"),
.string()
.describe("Path to the .kicad_sch schematic file"),
}, },
async (args: { schematicPath: string }) => { async (args: { schematicPath: string }) => {
const result = await callKicadScript("find_wires_crossing_symbols", args); const result = await callKicadScript("find_wires_crossing_symbols", args);
@@ -1455,20 +1346,14 @@ Note: operates on .kicad_sch files only. To modify a PCB footprint use edit_comp
const lines = [`Found ${collisions.length} wire(s) crossing symbols:`]; const lines = [`Found ${collisions.length} wire(s) crossing symbols:`];
collisions.slice(0, 30).forEach((c: any, i: number) => { collisions.slice(0, 30).forEach((c: any, i: number) => {
lines.push( lines.push(
` ${i + 1}. Wire (${c.wire.start.x},${c.wire.start.y})→(${c.wire.end.x},${c.wire.end.y}) crosses ${c.component.reference} (${c.component.libId})`, ` ${i + 1}. Wire (${c.wire.start.x},${c.wire.start.y})→(${c.wire.end.x},${c.wire.end.y}) crosses ${c.component.reference} (${c.component.libId})`
); );
}); });
if (collisions.length > 30) if (collisions.length > 30) lines.push(` ... and ${collisions.length - 30} more`);
lines.push(` ... and ${collisions.length - 30} more`);
return { content: [{ type: "text", text: lines.join("\n") }] }; return { content: [{ type: "text", text: lines.join("\n") }] };
} }
return { return {
content: [ content: [{ type: "text", text: `Failed: ${result.message || "Unknown error"}` }],
{
type: "text",
text: `Failed: ${result.message || "Unknown error"}`,
},
],
}; };
}, },
); );