kcaa 0.2.4__tar.gz → 0.2.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. {kcaa-0.2.4 → kcaa-0.2.6}/PKG-INFO +2 -1
  2. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/server.py +3 -0
  3. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/pcb_query_tools.py +65 -18
  4. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/pcb_routing_tools.py +14 -7
  5. kcaa-0.2.6/kcaa/tools/render_board_tools.py +1878 -0
  6. {kcaa-0.2.4 → kcaa-0.2.6}/pyproject.toml +2 -1
  7. {kcaa-0.2.4 → kcaa-0.2.6}/.gitignore +0 -0
  8. {kcaa-0.2.4 → kcaa-0.2.6}/LICENSE +0 -0
  9. {kcaa-0.2.4 → kcaa-0.2.6}/README.md +0 -0
  10. {kcaa-0.2.4 → kcaa-0.2.6}/README_CN.md +0 -0
  11. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/__init__.py +0 -0
  12. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/context.py +0 -0
  13. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/prompts/__init__.py +0 -0
  14. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/prompts/bom_prompts.py +0 -0
  15. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/prompts/drc_prompt.py +0 -0
  16. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/prompts/pattern_prompts.py +0 -0
  17. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/prompts/templates.py +0 -0
  18. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/resources/__init__.py +0 -0
  19. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/resources/bom_resources.py +0 -0
  20. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/resources/drc_resources.py +0 -0
  21. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/resources/files.py +0 -0
  22. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/resources/netlist_resources.py +0 -0
  23. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/resources/pattern_resources.py +0 -0
  24. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/resources/projects.py +0 -0
  25. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/router/__init__.py +0 -0
  26. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/router/a_star.py +0 -0
  27. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/router/grid_a_star.py +0 -0
  28. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/router/path_postprocess.py +0 -0
  29. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/router/router.py +0 -0
  30. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/router/via_check.py +0 -0
  31. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/router/visibility_graph.py +0 -0
  32. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/router/world_model.py +0 -0
  33. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/__init__.py +0 -0
  34. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/analysis_tools.py +0 -0
  35. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/bom_tools.py +0 -0
  36. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/drc_tools.py +0 -0
  37. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/export_tools.py +0 -0
  38. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/kipy_tools.py +0 -0
  39. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/netlist_tools.py +0 -0
  40. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/pattern_tools.py +0 -0
  41. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/pcb_edit_tools.py +0 -0
  42. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/pcb_group_tools.py +0 -0
  43. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/pcb_library_tools.py +0 -0
  44. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/pcb_placement_helpers.py +0 -0
  45. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/pcb_placement_tools.py +0 -0
  46. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/pcb_zone_tools.py +0 -0
  47. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/placement_helpers.py +0 -0
  48. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/project_tools.py +0 -0
  49. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/schematic_group_tools.py +0 -0
  50. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/sheet_tools.py +0 -0
  51. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/skill_tools.py +0 -0
  52. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/symbol_edit_tools.py +0 -0
  53. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/symbol_tools.py +0 -0
  54. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/validation_tools.py +0 -0
  55. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/version_tools.py +0 -0
  56. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/tools/wire_edit_tools.py +0 -0
  57. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/__init__.py +0 -0
  58. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/boundary_validator.py +0 -0
  59. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/component_utils.py +0 -0
  60. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/config.py +0 -0
  61. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/file_utils.py +0 -0
  62. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/footprint_database.py +0 -0
  63. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/footprint_index_manager.py +0 -0
  64. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/fp_lib_table_utils.py +0 -0
  65. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/ipc_drc.py +0 -0
  66. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/kicad_api_detection.py +0 -0
  67. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/kicad_cli.py +0 -0
  68. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/kicad_utils.py +0 -0
  69. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/kipy_reload.py +0 -0
  70. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/net_settings.py +0 -0
  71. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/netlist_parser.py +0 -0
  72. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/path_validator.py +0 -0
  73. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/pattern_recognition.py +0 -0
  74. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/pcb_board_utils.py +0 -0
  75. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/pcb_design_rules.py +0 -0
  76. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/pcb_footprint_utils.py +0 -0
  77. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/pcb_library_utils.py +0 -0
  78. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/pcb_sexp_utils.py +0 -0
  79. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/schematic_sexp_utils.py +0 -0
  80. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/secure_subprocess.py +0 -0
  81. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/skip_compat.py +0 -0
  82. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/skip_helpers.py +0 -0
  83. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/symbol_database.py +0 -0
  84. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/symbol_extractor.py +0 -0
  85. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/symbol_geometry.py +0 -0
  86. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/symbol_index_manager.py +0 -0
  87. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/symbol_index_reader.py +0 -0
  88. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/temp_dir_manager.py +0 -0
  89. {kcaa-0.2.4 → kcaa-0.2.6}/kcaa/utils/version_manager.py +0 -0
  90. {kcaa-0.2.4 → kcaa-0.2.6}/kicad_plugin/README.md +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: kcaa
3
- Version: 0.2.4
3
+ Version: 0.2.6
4
4
  Summary: Model Context Protocol (MCP) server for KiCad electronic design automation (EDA) files
5
5
  Project-URL: Homepage, https://github.com/paul356/KiCad-AI-Assistant
6
6
  Project-URL: Bug Tracker, https://github.com/paul356/KiCad-AI-Assistant/issues
@@ -29,6 +29,7 @@ Requires-Dist: defusedxml>=0.7.0
29
29
  Requires-Dist: fastmcp>=2.0.0
30
30
  Requires-Dist: kicad-python>=0.7.1
31
31
  Requires-Dist: kicad-skip>=0.2.5
32
+ Requires-Dist: matplotlib>=3.8.0
32
33
  Requires-Dist: mcp[cli]>=1.0.0
33
34
  Requires-Dist: pandas>=2.0.0
34
35
  Requires-Dist: pyyaml>=6.0.0
@@ -42,6 +42,7 @@ from kcaa.tools.pcb_routing_tools import register_pcb_routing_tools
42
42
  from kcaa.tools.pcb_zone_tools import register_pcb_zone_tools
43
43
  from kcaa.tools.placement_helpers import register_placement_helpers
44
44
  from kcaa.tools.project_tools import register_project_tools
45
+ from kcaa.tools.render_board_tools import register_render_board_tools
45
46
  from kcaa.tools.schematic_group_tools import register_schematic_group_tools
46
47
  from kcaa.tools.sheet_tools import register_sheet_tools
47
48
  from kcaa.tools.skill_tools import register_skill_tools
@@ -132,6 +133,7 @@ def _register_plugin_profile(mcp: FastMCP) -> None:
132
133
  register_schematic_group_tools(mcp)
133
134
  register_pcb_zone_tools(mcp)
134
135
  register_pcb_routing_tools(mcp)
136
+ register_render_board_tools(mcp)
135
137
  register_kipy_tools(mcp)
136
138
  register_drc_tools(mcp)
137
139
  register_skill_tools(mcp)
@@ -175,6 +177,7 @@ def _register_full_profile(mcp: FastMCP) -> None:
175
177
  register_project_tools(mcp)
176
178
  register_analysis_tools(mcp)
177
179
  register_export_tools(mcp)
180
+ register_render_board_tools(mcp)
178
181
  register_drc_tools(mcp)
179
182
  register_bom_tools(mcp)
180
183
  register_netlist_tools(mcp)
@@ -1065,14 +1065,19 @@ def register_pcb_query_tools(mcp: FastMCP) -> None:
1065
1065
  net: str | None = None,
1066
1066
  layer: str | None = None,
1067
1067
  ) -> dict[str, Any]:
1068
- """List all track segments on the PCB, grouped by trace connectivity.
1069
-
1070
- Returns segments grouped into **traces** — two segments belong to
1071
- the same trace when they share an endpoint (within 0.01 mm).
1072
- Segments within each trace are ordered end-to-end as polylines.
1073
- A trace with a T-junction branches into multiple polylines.
1074
-
1075
- When ``net`` and/or ``layer`` are provided, only matching segments
1068
+ """List all track segments and arcs on the PCB, grouped by trace connectivity.
1069
+
1070
+ Returns segments and arcs grouped into **traces** — two items belong
1071
+ to the same trace when they share an endpoint (within 0.01 mm).
1072
+ Arc entries are parsed from KiCad ``(arc ...)`` nodes
1073
+ (``start``/``mid``/``end``) and their endpoints participate in
1074
+ connectivity exactly like straight segment endpoints, so a rounded
1075
+ PNS arc merges with adjacent straight segments into one trace.
1076
+ Items within each trace are ordered end-to-end as polylines
1077
+ (arcs are represented by their start→end chord). A trace with a
1078
+ T-junction branches into multiple polylines.
1079
+
1080
+ When ``net`` and/or ``layer`` are provided, only matching items
1076
1081
  are considered (and traces that cross layers or nets don't merge).
1077
1082
 
1078
1083
  Args:
@@ -1086,19 +1091,27 @@ def register_pcb_query_tools(mcp: FastMCP) -> None:
1086
1091
  traces: list of trace groups. Each trace has ``polylines``
1087
1092
  (list of point-lists) and shared metadata
1088
1093
  ``width``, ``layer``, ``net``.
1089
- segment_count: total number of segments.
1094
+ segment_count: total number of items (segments + arcs).
1090
1095
  trace_count: number of connected trace groups.
1096
+
1097
+ Each trace's ``segments`` entries carry ``kind`` (``"segment"`` or
1098
+ ``"arc"``); arc entries also carry ``mid`` so the arc geometry can
1099
+ be rebuilt by upper layers.
1091
1100
  """
1092
1101
  data = load_pcb(pcb_path)
1093
1102
  tol = 0.01 # mm — same as delete tools
1094
1103
 
1095
- # ── Collect all raw segment entries ──────────────────────────
1104
+ # ── Collect all raw segment/arc entries ──────────────────────
1096
1105
  raw_segs: list[dict[str, Any]] = []
1097
1106
  for item in data:
1098
- if not (isinstance(item, list) and len(item) > 0 and _sym(item[0]) == "segment"):
1107
+ if not (
1108
+ isinstance(item, list) and len(item) > 0 and _sym(item[0]) in ("segment", "arc")
1109
+ ):
1099
1110
  continue
1111
+ kind = _sym(item[0])
1100
1112
  start_node = _find_sub_pq(item, "start")
1101
1113
  end_node = _find_sub_pq(item, "end")
1114
+ mid_node = _find_sub_pq(item, "mid") if kind == "arc" else None
1102
1115
  width_node = _find_sub_pq(item, "width")
1103
1116
  layer_node = _find_sub_pq(item, "layer")
1104
1117
  net_node = _find_sub_pq(item, "net")
@@ -1126,6 +1139,20 @@ def register_pcb_query_tools(mcp: FastMCP) -> None:
1126
1139
  if layer is not None and item_layer != layer:
1127
1140
  continue
1128
1141
 
1142
+ mid: tuple[float, float] | None = None
1143
+ if mid_node is not None and len(mid_node) >= 3:
1144
+ mx = (
1145
+ float(mid_node[1])
1146
+ if not isinstance(mid_node[1], str)
1147
+ else float(str(mid_node[1]))
1148
+ )
1149
+ my = (
1150
+ float(mid_node[2])
1151
+ if not isinstance(mid_node[2], str)
1152
+ else float(str(mid_node[2]))
1153
+ )
1154
+ mid = (mx, my)
1155
+
1129
1156
  raw_segs.append(
1130
1157
  {
1131
1158
  "x1": sx,
@@ -1135,6 +1162,8 @@ def register_pcb_query_tools(mcp: FastMCP) -> None:
1135
1162
  "width": sw,
1136
1163
  "layer": item_layer,
1137
1164
  "net": item_net,
1165
+ "kind": kind,
1166
+ "mid": mid,
1138
1167
  }
1139
1168
  )
1140
1169
 
@@ -1142,8 +1171,8 @@ def register_pcb_query_tools(mcp: FastMCP) -> None:
1142
1171
  return {"traces": [], "segment_count": 0, "trace_count": 0}
1143
1172
 
1144
1173
  # ── Collect pad centre positions (world coords) ──────────────
1145
- # Segments that meet at a pad centre are NOT connected (the
1146
- # connection goes through the pad, not directly segment-to-segment).
1174
+ # Items that meet at a pad centre are NOT connected (the
1175
+ # connection goes through the pad, not directly item-to-item).
1147
1176
  # Also build a reverse lookup: (rounded_x, rounded_y) → pad info.
1148
1177
  pad_centres: set[tuple[float, float]] = set()
1149
1178
  pad_at: dict[tuple[float, float], list[dict[str, Any]]] = {}
@@ -1183,10 +1212,11 @@ def register_pcb_query_tools(mcp: FastMCP) -> None:
1183
1212
  )
1184
1213
 
1185
1214
  # ── Build adjacency ──────────────────────────────────────────
1186
- # Each segment has two endpoints (a, b). Two segments share an
1187
- # endpoint if any endpoint pair is within tol — *unless* that
1215
+ # Each item (segment/arc) has two endpoints (a, b); for arcs the
1216
+ # endpoints are the start/end points of the arc. Two items share
1217
+ # an endpoint if any endpoint pair is within tol — *unless* that
1188
1218
  # point is a pad centre (connection goes through the pad, not
1189
- # directly segment-to-segment).
1219
+ # directly item-to-item).
1190
1220
  n = len(raw_segs)
1191
1221
  adj: list[list[int]] = [[] for _ in range(n)]
1192
1222
 
@@ -1329,13 +1359,22 @@ def register_pcb_query_tools(mcp: FastMCP) -> None:
1329
1359
  for i in range(len(poly) - 1):
1330
1360
  a, b = poly[i], poly[i + 1]
1331
1361
  for s in raw_segs:
1362
+ seg_entry: dict[str, Any]
1332
1363
  if (
1333
1364
  abs(s["x1"] - a[0]) < tol
1334
1365
  and abs(s["y1"] - a[1]) < tol
1335
1366
  and abs(s["x2"] - b[0]) < tol
1336
1367
  and abs(s["y2"] - b[1]) < tol
1337
1368
  ):
1338
- segs_in_poly.append({"start": a, "end": b, "width": s["width"]})
1369
+ seg_entry = {
1370
+ "start": a,
1371
+ "end": b,
1372
+ "width": s["width"],
1373
+ "kind": s["kind"],
1374
+ }
1375
+ if s["mid"] is not None:
1376
+ seg_entry["mid"] = s["mid"]
1377
+ segs_in_poly.append(seg_entry)
1339
1378
  break
1340
1379
  elif (
1341
1380
  abs(s["x1"] - b[0]) < tol
@@ -1343,7 +1382,15 @@ def register_pcb_query_tools(mcp: FastMCP) -> None:
1343
1382
  and abs(s["x2"] - a[0]) < tol
1344
1383
  and abs(s["y2"] - a[1]) < tol
1345
1384
  ):
1346
- segs_in_poly.append({"start": a, "end": b, "width": s["width"]})
1385
+ seg_entry = {
1386
+ "start": a,
1387
+ "end": b,
1388
+ "width": s["width"],
1389
+ "kind": s["kind"],
1390
+ }
1391
+ if s["mid"] is not None:
1392
+ seg_entry["mid"] = s["mid"]
1393
+ segs_in_poly.append(seg_entry)
1347
1394
  break
1348
1395
  polylines_out.append(segs_in_poly)
1349
1396
 
@@ -291,9 +291,11 @@ def register_pcb_routing_tools(mcp: FastMCP) -> None:
291
291
  """Delete specific track segments by their endpoint coordinates.
292
292
 
293
293
  Each element of ``segments`` is a dict with ``x1``, ``y1``, ``x2``,
294
- ``y2`` and optional ``layer``. A matching ``(segment ...)`` entry is
295
- removed when both endpoints match within 0.01 mm and (if specified)
296
- the layer matches.
294
+ ``y2`` and optional ``layer``. A matching ``(segment ...)`` or
295
+ ``(arc ...)`` entry is removed when both endpoints match within
296
+ 0.01 mm (either direction) and (if specified) the layer matches.
297
+ Arc tracks match on their start/end endpoints — pass the arc's
298
+ two ends as reported by the router (the mid point is ignored).
297
299
 
298
300
  A ``.bak`` backup is created before any modification. An empty
299
301
  match list (``[]``) is a no-op — no backup, no write. Returns the
@@ -302,8 +304,9 @@ def register_pcb_routing_tools(mcp: FastMCP) -> None:
302
304
 
303
305
  Args:
304
306
  pcb_path: Absolute path to the .kicad_pcb file.
305
- segments: List of segment descriptors, each with
306
- ``x1``, ``y1``, ``x2``, ``y2`` and optional ``layer``.
307
+ segments: List of track descriptors, each with
308
+ ``x1``, ``y1``, ``x2``, ``y2`` and optional ``layer``
309
+ (matches straight segments and arc tracks alike).
307
310
  ctx: MCP context (unused).
308
311
 
309
312
  Returns:
@@ -324,12 +327,16 @@ def register_pcb_routing_tools(mcp: FastMCP) -> None:
324
327
  data = load_pcb(pcb_path)
325
328
  tol = 0.01 # mm
326
329
 
327
- # Collect existing (segment ...) items with their endpoint info.
330
+ # Collect existing (segment ...) and (arc ...) items with their
331
+ # endpoint info. Arc track nodes share the (start) / (end) fields,
332
+ # so endpoint matching is identical; the mid point is not used for
333
+ # lookup (a caller deleting a rounded corner passes the arc's two
334
+ # endpoints, exactly what the router reported as the segment).
328
335
  existing: list[tuple[list, float, float, float, float, str | None]] = []
329
336
  for item in data:
330
337
  if not (isinstance(item, list) and len(item) > 0):
331
338
  continue
332
- if not _is_sym(item[0], "segment"):
339
+ if not (_is_sym(item[0], "segment") or _is_sym(item[0], "arc")):
333
340
  continue
334
341
  start_node = _find_sub(item, "start")
335
342
  end_node = _find_sub(item, "end")