3 Commits

Author SHA1 Message Date
b42992f64d Detect KiCad symbol dir cross-platform in test gating
Some checks are pending
CI / Lint and Format (push) Waiting to run
CI / Test Python 3.11 on macos-latest (push) Waiting to run
CI / Test Python 3.12 on macos-latest (push) Waiting to run
CI / Test Python 3.13 on macos-latest (push) Waiting to run
CI / Test Python 3.10 on ubuntu-latest (push) Waiting to run
CI / Test Python 3.11 on ubuntu-latest (push) Waiting to run
CI / Test Python 3.12 on ubuntu-latest (push) Waiting to run
CI / Test Python 3.13 on ubuntu-latest (push) Waiting to run
CI / Security Scan (push) Waiting to run
CI / Build Package (push) Blocked by required conditions
requires_kicad keyed off a hardcoded /usr/share/kicad path, so symbol-dependent
tests silently skipped on macOS even with KiCad installed. Derive DEVICE_LIB
from get_kicad_symbol_dir() so those tests actually run on the macOS testbed.
2026-07-11 17:37:42 -06:00
1dca4d6912 Fix symbol library resolution on macOS and without a sym-lib-table
Two bugs left built-in symbols (Device, Connector, ...) unresolvable, which
cascaded into every batch place/label/wire producing zero results:

- get_kicad_symbol_dir() only checked KICAD9/KICAD8_SYMBOL_DIR and a single
  Linux path. It ignored the generic KICAD_SYMBOL_DIR, KiCad 10, and the
  macOS/Windows install locations, so it returned None on macOS even with the
  symbols present. Now checks KICAD_SYMBOL_DIR + KICAD{10,9,8,7}_SYMBOL_DIR and
  per-platform default paths.
- resolve_library_path() never searched the system symbol directory for
  <lib>.kicad_sym; the system dir was only used for variable substitution
  inside a sym-lib-table. With no table configured (tests, fresh installs),
  built-in libraries were unreachable. Added a system-dir fallback and covered
  the KiCad 10/7 global-table config dirs.

Update test_env_override to clear ambient symbol-dir vars so the override under
test is decisive regardless of the host environment.
2026-07-11 17:09:34 -06:00
57872e59c1 Replace kicad-sch-api with internal SchDocument engine
Eliminate the external kicad-sch-api dependency by migrating all MCP
tools to the internal SchDocument class built on sexp_tree.py. This
fixes three serialization bugs (dropped global labels, TypeError on
local labels, mis-quoted property private keywords) and removes ~1,900
lines of workaround code.

New modules:
- sexp_tree.py: S-expression parser and round-trip serializer
- sch_document.py: schematic read/write/mutate API
- lib_resolver.py: symbol library search and resolution
- sch_helpers.py: shared load/validate/expand helpers

Migrated all 9 tool files, resources, and tests. Removed 5 workaround
functions from sexp_parser.py. 531 tests pass, ruff + mypy clean.
2026-07-11 16:47:22 -06:00