Files
Clément SAILLANT c2addfd81d feat(hw): add schops tool for schematic operations and kicad-cli integration
- Introduced `kicad_cli.sh` for local and Docker-based kicad-cli execution.
- Created `schops.py` for schematic operations including ERC, BOM, netlist exports, and bulk edits.
- Added README.md for schops with installation and usage instructions.
- Included requirements.txt for necessary Python packages.
- Implemented rules engine for applying field defaults and renaming nets.
- Added tests for rules engine functionality.
- Introduced scope guard script to enforce file modification policies based on PR labels.
- Created watch script to monitor KiCad files and trigger hardware gate on changes.
2026-02-18 23:47:56 +01:00
..

schops (Schematic Ops)

CLI local pour :

  • ERC/BOM/netlist via kicad-cli
  • bulk edits via kicad-sch-api (si installé)
  • Design Blocks KiCad 9 (structure + metadata)

Philosophie : bulk edits safe (backup + report) + exports déterministes (kicad-cli).

Install (local)

python -m venv .venv && source .venv/bin/activate
python -m pip install -U pip
python -m pip install -r tools/hw/schops/requirements.txt

Usage

python tools/hw/schops/schops.py --help

Exports (kicad-cli)

python tools/hw/schops/schops.py erc --schematic hardware/kicad/<proj>/<proj>.kicad_sch
python tools/hw/schops/schops.py netlist --schematic hardware/kicad/<proj>/<proj>.kicad_sch
python tools/hw/schops/schops.py bom --schematic hardware/kicad/<proj>/<proj>.kicad_sch \
  --fields "Reference,Value,Footprint,${DNP}" \
  --group-by "Value,Footprint" \
  --exclude-dnp

Les sorties vont dans artifacts/hw/<timestamp>/.

Bulk edits (kicad-sch-api)

Champs / propriétés

Applique hardware/rules/fields.yaml (defaults + règles) et écrit un rapport JSON.

python tools/hw/schops/schops.py apply-fields \
  --schematic hardware/kicad/<proj>/<proj>.kicad_sch \
  --rules hardware/rules/fields.yaml

# review-only
python tools/hw/schops/schops.py apply-fields --dry-run --schematic ... --rules ...

Footprints

python tools/hw/schops/schops.py apply-footprints \
  --schematic hardware/kicad/<proj>/<proj>.kicad_sch \
  --map hardware/rules/footprints.csv

Renommage de nets (labels)

python tools/hw/schops/schops.py rename-nets \
  --schematic hardware/kicad/<proj>/<proj>.kicad_sch \
  --rules hardware/rules/nets_rename.yaml

Snapshot (pour diff)

python tools/hw/schops/schops.py snapshot --schematic ... --name before.json
# ... modifications ...
python tools/hw/schops/schops.py snapshot --schematic ... --name after.json

Design Blocks (KiCad 9)

Les design blocks sont des dossiers *.kicad_block stockés dans une librairie *.kicad_blocks.

python tools/hw/schops/schops.py block-make \
  --name buck_5v \
  --from-sheet hardware/kicad/buck/buck.kicad_sch \
  --lib hardware/blocks/power.kicad_blocks \
  --description "Buck 5V@2A" \
  --keywords "power,buck,5v"

python tools/hw/schops/schops.py block-ls --lib hardware/blocks/power.kicad_blocks