fix: add pin-snapping and coordinate feedback to net label tools
add_schematic_net_label now accepts optional componentRef + pinNumber to
snap the label directly to the exact pin endpoint via PinLocator, removing
all approximation risk. The response always includes actual_position and,
when snapping was used, snapped_to_pin — so the caller gets confirmation
of exactly where the label landed.
connect_to_net return type changed from bool to Dict, returning
pin_location, label_location, and wire_stub on success so agents no
longer need a separate verification call to confirm placement.
connect_passthrough updated to check result.get("success") against the
new dict return. tool_schemas.py and schematic.ts updated to match
(position is now optional, componentRef/pinNumber/labelType/orientation
added, connect_to_net schema field names corrected).
17 new unit tests in tests/test_net_label_pin_snapping.py.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1399,7 +1399,15 @@ SCHEMATIC_TOOLS = [
|
||||
{
|
||||
"name": "add_schematic_net_label",
|
||||
"title": "Add Net Label",
|
||||
"description": "Adds a net label at exact coordinates on a schematic wire or pin endpoint. WARNING: x/y must match an existing wire endpoint or pin endpoint exactly — placing the label even 0.01mm away from a pin will result in an unconnected pin ERC error. To connect a component pin to a net by reference and pin number (recommended), use connect_to_net instead.",
|
||||
"description": (
|
||||
"Add a net label to a schematic. "
|
||||
"PREFERRED: supply componentRef + pinNumber to snap the label to the exact pin endpoint — "
|
||||
"this guarantees an electrical connection. "
|
||||
"Alternatively supply position [x, y], but the coordinates must match the pin endpoint exactly "
|
||||
"(even a 0.01 mm offset breaks the connection). "
|
||||
"The response includes actual_position (coordinates actually used) and snapped_to_pin "
|
||||
"(present when a pin reference was resolved)."
|
||||
),
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1411,21 +1419,45 @@ SCHEMATIC_TOOLS = [
|
||||
"type": "string",
|
||||
"description": "Name of the net (e.g., VCC, GND, SDA)",
|
||||
},
|
||||
"x": {"type": "number", "description": "X coordinate on schematic"},
|
||||
"y": {"type": "number", "description": "Y coordinate on schematic"},
|
||||
"rotation": {
|
||||
"position": {
|
||||
"type": "array",
|
||||
"items": {"type": "number"},
|
||||
"minItems": 2,
|
||||
"maxItems": 2,
|
||||
"description": "Position [x, y] for the label. Required when componentRef/pinNumber are not given.",
|
||||
},
|
||||
"componentRef": {
|
||||
"type": "string",
|
||||
"description": "Component reference to snap label to (e.g. U1, R1). Use with pinNumber.",
|
||||
},
|
||||
"pinNumber": {
|
||||
"type": "string",
|
||||
"description": "Pin number or name on componentRef (e.g. '1', 'GND'). Use with componentRef.",
|
||||
},
|
||||
"labelType": {
|
||||
"type": "string",
|
||||
"enum": ["label", "global_label", "hierarchical_label"],
|
||||
"description": "Label type (default: label)",
|
||||
"default": "label",
|
||||
},
|
||||
"orientation": {
|
||||
"type": "number",
|
||||
"description": "Rotation angle in degrees (0, 90, 180, 270)",
|
||||
"default": 0,
|
||||
},
|
||||
},
|
||||
"required": ["schematicPath", "netName", "x", "y"],
|
||||
"required": ["schematicPath", "netName"],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "connect_to_net",
|
||||
"title": "Connect Pin to Net",
|
||||
"description": "Intelligently connects a component pin to a named net, automatically routing wires as needed.",
|
||||
"description": (
|
||||
"Connect a component pin to a named net by adding a wire stub and net label at the exact "
|
||||
"pin endpoint. The response includes pin_location (exact pin coords), label_location "
|
||||
"(where the label was placed), and wire_stub (the wire segment added) so you can confirm "
|
||||
"the placement without a separate verification call."
|
||||
),
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1433,11 +1465,11 @@ SCHEMATIC_TOOLS = [
|
||||
"type": "string",
|
||||
"description": "Path to schematic file",
|
||||
},
|
||||
"reference": {
|
||||
"componentRef": {
|
||||
"type": "string",
|
||||
"description": "Component reference designator (e.g., R1, U3)",
|
||||
},
|
||||
"pinNumber": {
|
||||
"pinName": {
|
||||
"type": "string",
|
||||
"description": "Pin number or name on the component",
|
||||
},
|
||||
@@ -1446,7 +1478,7 @@ SCHEMATIC_TOOLS = [
|
||||
"description": "Name of the net to connect to",
|
||||
},
|
||||
},
|
||||
"required": ["schematicPath", "reference", "pinNumber", "netName"],
|
||||
"required": ["schematicPath", "componentRef", "pinName", "netName"],
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user