kicad-sch-api 0.1.2__tar.gz → 0.1.4__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.
Potentially problematic release.
This version of kicad-sch-api might be problematic. Click here for more details.
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/.claude/commands/dev/publish-pypi.md +43 -3
- kicad_sch_api-0.1.4/PKG-INFO +322 -0
- kicad_sch_api-0.1.4/README.md +273 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api/cli.py +62 -6
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api/mcp/server.py +1 -1
- kicad_sch_api-0.1.4/kicad_sch_api.egg-info/PKG-INFO +322 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/pyproject.toml +1 -1
- kicad_sch_api-0.1.2/PKG-INFO +0 -326
- kicad_sch_api-0.1.2/README.md +0 -277
- kicad_sch_api-0.1.2/kicad_sch_api.egg-info/PKG-INFO +0 -326
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/.claude/commands/dev/dead-code-analysis.md +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/.claude/commands/dev/review-implementation.md +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/.claude/commands/dev/run-tests.md +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/.claude/commands/dev/update-and-commit.md +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/.claude/commands/dev/update-memory-bank.md +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/.claude/commands/test/run-reference-tests.md +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/LICENSE +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/MANIFEST.in +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/examples/advanced_usage.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/examples/basic_usage.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/examples/mcp_basic_example.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/examples/mcp_integration.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api/__init__.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api/core/__init__.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api/core/components.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api/core/formatter.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api/core/ic_manager.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api/core/junctions.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api/core/parser.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api/core/schematic.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api/core/types.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api/core/wires.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api/discovery/__init__.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api/discovery/search_index.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api/library/__init__.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api/library/cache.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api/mcp/__init__.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api/py.typed +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api/utils/__init__.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api/utils/validation.py +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api.egg-info/SOURCES.txt +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api.egg-info/dependency_links.txt +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api.egg-info/entry_points.txt +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api.egg-info/requires.txt +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/kicad_sch_api.egg-info/top_level.txt +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/setup.cfg +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/README.md +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/blank_schematic/blank_schematic.kicad_pro +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/blank_schematic/blank_schematic.kicad_sch +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/multi_unit_7400/multi_unit_7400.kicad_pro +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/multi_unit_7400/multi_unit_7400.kicad_sch +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/power_symbols/power_symbols.kicad_pro +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/power_symbols/power_symbols.kicad_sch +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/resistor_divider/resistor_divider.kicad_pro +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/resistor_divider/resistor_divider.kicad_sch +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/sch_title/sch_title.kicad_pro +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/sch_title/sch_title.kicad_sch +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/single_extended_component/single_extended_component.kicad_pro +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/single_extended_component/single_extended_component.kicad_sch +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/single_hierarchical_sheet/single_hierarchical_sheet.kicad_pro +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/single_hierarchical_sheet/single_hierarchical_sheet.kicad_sch +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/single_hierarchical_sheet/subcircuit1.kicad_sch +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/single_label/single_label.kicad_pro +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/single_label/single_label.kicad_sch +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/single_label_hierarchical/single_label_hierarchical.kicad_pro +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/single_label_hierarchical/single_label_hierarchical.kicad_sch +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/single_resistor/single_resistor.kicad_pro +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/single_resistor/single_resistor.kicad_sch +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/single_text/single_text.kicad_pro +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/single_text/single_text.kicad_sch +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/single_text_box/single_text_box.kicad_pro +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/single_text_box/single_text_box.kicad_sch +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/single_wire/single_wire.kicad_pro +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/single_wire/single_wire.kicad_sch +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/two_resistors/two_resistors.kicad_pro +0 -0
- {kicad_sch_api-0.1.2 → kicad_sch_api-0.1.4}/tests/reference_tests/reference_kicad_projects/two_resistors/two_resistors.kicad_sch +0 -0
|
@@ -275,18 +275,58 @@ export PYPI_API_TOKEN=your_production_token
|
|
|
275
275
|
/publish-pypi --force
|
|
276
276
|
```
|
|
277
277
|
|
|
278
|
-
##
|
|
278
|
+
## Authentication Methods
|
|
279
279
|
|
|
280
|
-
###
|
|
280
|
+
### Method 1: Environment Variables (Recommended for CI)
|
|
281
|
+
|
|
282
|
+
#### For Test PyPI
|
|
281
283
|
```bash
|
|
282
284
|
export TEST_PYPI_API_TOKEN=pypi-your_test_token_here
|
|
283
285
|
```
|
|
284
286
|
|
|
285
|
-
|
|
287
|
+
#### For Production PyPI
|
|
286
288
|
```bash
|
|
287
289
|
export PYPI_API_TOKEN=pypi-your_production_token_here
|
|
288
290
|
```
|
|
289
291
|
|
|
292
|
+
### Method 2: .pypirc File (Recommended for Local Development)
|
|
293
|
+
|
|
294
|
+
Create `~/.pypirc` with your API tokens:
|
|
295
|
+
|
|
296
|
+
```ini
|
|
297
|
+
[distutils]
|
|
298
|
+
index-servers =
|
|
299
|
+
pypi
|
|
300
|
+
testpypi
|
|
301
|
+
|
|
302
|
+
[pypi]
|
|
303
|
+
repository = https://upload.pypi.org/legacy/
|
|
304
|
+
username = __token__
|
|
305
|
+
password = pypi-your_production_token_here
|
|
306
|
+
|
|
307
|
+
[testpypi]
|
|
308
|
+
repository = https://test.pypi.org/legacy/
|
|
309
|
+
username = __token__
|
|
310
|
+
password = pypi-your_test_token_here
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
**Using .pypirc:**
|
|
314
|
+
```bash
|
|
315
|
+
# Publish to Test PyPI using .pypirc
|
|
316
|
+
twine upload --repository testpypi dist/*
|
|
317
|
+
|
|
318
|
+
# Publish to Production PyPI using .pypirc
|
|
319
|
+
twine upload --repository pypi dist/*
|
|
320
|
+
|
|
321
|
+
# Or use the default (production PyPI)
|
|
322
|
+
twine upload dist/*
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
**Security Notes:**
|
|
326
|
+
- Set proper file permissions: `chmod 600 ~/.pypirc`
|
|
327
|
+
- Never commit `.pypirc` to version control
|
|
328
|
+
- Environment variables take precedence over `.pypirc`
|
|
329
|
+
|
|
290
330
|
## Post-Publication Checklist
|
|
291
331
|
|
|
292
332
|
After successful publication:
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kicad-sch-api
|
|
3
|
+
Version: 0.1.4
|
|
4
|
+
Summary: Professional KiCAD schematic manipulation library with exact format preservation and AI agent integration
|
|
5
|
+
Author-email: Circuit-Synth <shane@circuit-synth.com>
|
|
6
|
+
Maintainer-email: Circuit-Synth <shane@circuit-synth.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/circuit-synth/kicad-sch-api
|
|
9
|
+
Project-URL: Documentation, https://circuit-synth.github.io/kicad-sch-api/
|
|
10
|
+
Project-URL: Repository, https://github.com/circuit-synth/kicad-sch-api.git
|
|
11
|
+
Project-URL: Bug Reports, https://github.com/circuit-synth/kicad-sch-api/issues
|
|
12
|
+
Project-URL: Changelog, https://github.com/circuit-synth/kicad-sch-api/blob/main/CHANGELOG.md
|
|
13
|
+
Keywords: kicad,schematic,eda,electronics,circuit-design,ai,automation,pcb
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Operating System :: OS Independent
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: fastmcp>=2.0.0
|
|
29
|
+
Requires-Dist: mcp[cli]>=1.13.0
|
|
30
|
+
Requires-Dist: sexpdata>=0.0.3
|
|
31
|
+
Requires-Dist: typing-extensions>=4.0.0; python_version < "3.11"
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest-xdist>=3.0.0; extra == "dev"
|
|
36
|
+
Requires-Dist: black>=22.0.0; extra == "dev"
|
|
37
|
+
Requires-Dist: isort>=5.0.0; extra == "dev"
|
|
38
|
+
Requires-Dist: flake8>=4.0.0; extra == "dev"
|
|
39
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
40
|
+
Requires-Dist: pre-commit>=3.0.0; extra == "dev"
|
|
41
|
+
Provides-Extra: mcp
|
|
42
|
+
Requires-Dist: mcp[cli]>=1.0.0; extra == "mcp"
|
|
43
|
+
Requires-Dist: fastmcp>=2.0.0; extra == "mcp"
|
|
44
|
+
Provides-Extra: docs
|
|
45
|
+
Requires-Dist: sphinx>=5.0.0; extra == "docs"
|
|
46
|
+
Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == "docs"
|
|
47
|
+
Requires-Dist: myst-parser>=0.18.0; extra == "docs"
|
|
48
|
+
Dynamic: license-file
|
|
49
|
+
|
|
50
|
+
# KiCAD Schematic API
|
|
51
|
+
|
|
52
|
+
**Professional Python library for KiCAD schematic file manipulation with exact format preservation**
|
|
53
|
+
|
|
54
|
+
## Overview
|
|
55
|
+
|
|
56
|
+
Create and manipulate KiCAD schematic files programmatically with guaranteed exact format preservation. This library serves as the foundation for EDA automation tools and AI agents that need reliable, professional-grade schematic manipulation capabilities.
|
|
57
|
+
|
|
58
|
+
## 🎯 Core Features
|
|
59
|
+
|
|
60
|
+
- **📋 Exact Format Preservation**: Byte-perfect KiCAD output that matches native formatting
|
|
61
|
+
- **🏗️ Professional Component Management**: Object-oriented collections with search and validation
|
|
62
|
+
- **⚡ High Performance**: Optimized for large schematics with intelligent caching
|
|
63
|
+
- **🔍 Real KiCAD Library Integration**: Access to actual KiCAD symbol libraries and validation
|
|
64
|
+
- **🤖 AI Agent Ready**: MCP server for seamless integration with AI development tools
|
|
65
|
+
- **📚 Hierarchical Design**: Complete support for multi-sheet schematic projects
|
|
66
|
+
|
|
67
|
+
## 🚀 Quick Start
|
|
68
|
+
|
|
69
|
+
### Installation
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Install from PyPI
|
|
73
|
+
pip install kicad-sch-api
|
|
74
|
+
|
|
75
|
+
# Or install from source
|
|
76
|
+
git clone https://github.com/circuit-synth/kicad-sch-api.git
|
|
77
|
+
cd kicad-sch-api/python
|
|
78
|
+
uv pip install -e .
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Basic Usage
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
import kicad_sch_api as ksa
|
|
85
|
+
|
|
86
|
+
# Create a new schematic
|
|
87
|
+
sch = ksa.create_schematic("My Circuit")
|
|
88
|
+
|
|
89
|
+
# Add components with proper validation
|
|
90
|
+
resistor = sch.components.add(
|
|
91
|
+
lib_id="Device:R",
|
|
92
|
+
reference="R1",
|
|
93
|
+
value="10k",
|
|
94
|
+
position=(100.0, 100.0),
|
|
95
|
+
footprint="Resistor_SMD:R_0603_1608Metric",
|
|
96
|
+
datasheet="~",
|
|
97
|
+
description="Resistor"
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
capacitor = sch.components.add(
|
|
101
|
+
lib_id="Device:C",
|
|
102
|
+
reference="C1",
|
|
103
|
+
value="100nF",
|
|
104
|
+
position=(150.0, 100.0),
|
|
105
|
+
footprint="Capacitor_SMD:C_0603_1608Metric"
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
# Save with exact format preservation
|
|
109
|
+
sch.save("my_circuit.kicad_sch")
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Hierarchical Design
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
# Create main schematic with hierarchical sheet
|
|
116
|
+
main_sch = ksa.create_schematic("Main Board")
|
|
117
|
+
|
|
118
|
+
# Add hierarchical sheet
|
|
119
|
+
power_sheet = main_sch.add_hierarchical_sheet(
|
|
120
|
+
name="Power Supply",
|
|
121
|
+
filename="power.kicad_sch",
|
|
122
|
+
position=(100, 100),
|
|
123
|
+
size=(80, 60)
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
# Add sheet pins for connectivity
|
|
127
|
+
power_sheet.add_pin("VIN", pin_type="input", position=(0, 10))
|
|
128
|
+
power_sheet.add_pin("VOUT", pin_type="output", position=(80, 10))
|
|
129
|
+
|
|
130
|
+
# Create the sub-schematic
|
|
131
|
+
power_sch = ksa.create_schematic("Power Supply")
|
|
132
|
+
power_sch.add_hierarchical_label("VIN", label_type="input", position=(50, 25))
|
|
133
|
+
power_sch.add_hierarchical_label("VOUT", label_type="output", position=(150, 25))
|
|
134
|
+
|
|
135
|
+
# Save both schematics
|
|
136
|
+
main_sch.save("main.kicad_sch")
|
|
137
|
+
power_sch.save("power.kicad_sch")
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## 🔧 Advanced Features
|
|
141
|
+
|
|
142
|
+
### Component Search and Management
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
# Search for components
|
|
146
|
+
resistors = sch.components.find(lib_id_pattern='Device:R*')
|
|
147
|
+
power_components = sch.components.filter(reference_pattern=r'U[0-9]+')
|
|
148
|
+
|
|
149
|
+
# Bulk updates
|
|
150
|
+
sch.components.bulk_update(
|
|
151
|
+
criteria={'lib_id': 'Device:R'},
|
|
152
|
+
updates={'properties': {'Tolerance': '1%'}}
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
# Component validation
|
|
156
|
+
validation_result = sch.components.validate_component(
|
|
157
|
+
'Device:R',
|
|
158
|
+
'Resistor_SMD:R_0603_1608Metric'
|
|
159
|
+
)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### KiCAD Integration
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
# Run electrical rules check using KiCAD CLI
|
|
166
|
+
erc_result = sch.run_erc_check()
|
|
167
|
+
print(f"ERC Status: {erc_result.status}")
|
|
168
|
+
for violation in erc_result.violations:
|
|
169
|
+
print(f"- {violation.type}: {violation.message}")
|
|
170
|
+
|
|
171
|
+
# Generate netlist for connectivity analysis
|
|
172
|
+
netlist = sch.generate_netlist()
|
|
173
|
+
net_info = netlist.analyze_net("VCC")
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## 🤖 AI Agent Integration (MCP Server)
|
|
177
|
+
|
|
178
|
+
Use with Claude Code or other AI agents via Model Context Protocol:
|
|
179
|
+
|
|
180
|
+
### Setup MCP Server
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
# Install MCP server
|
|
184
|
+
pip install kicad-sch-api[mcp]
|
|
185
|
+
|
|
186
|
+
# Configure for Claude Code (automatic)
|
|
187
|
+
kicad-sch-api --setup-claude-code
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Usage with AI Agents
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
# Natural language commands to your AI agent:
|
|
194
|
+
"Create a voltage divider with two 10kΩ resistors"
|
|
195
|
+
"Add an ESP32 microcontroller with USB connector"
|
|
196
|
+
"Generate a hierarchical schematic with power supply subcircuit"
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
The AI agent will use the MCP server to:
|
|
200
|
+
1. Create professional schematics with proper component references
|
|
201
|
+
2. Use hierarchical labels instead of messy wires
|
|
202
|
+
3. Apply KiCAD design best practices automatically
|
|
203
|
+
4. Generate clean, industry-standard layouts
|
|
204
|
+
|
|
205
|
+
### Available MCP Tools
|
|
206
|
+
|
|
207
|
+
| Tool | Description |
|
|
208
|
+
|------|-------------|
|
|
209
|
+
| `create_schematic` | Create new schematic files |
|
|
210
|
+
| `add_component` | Add components with validation |
|
|
211
|
+
| `search_components` | Find components in KiCAD libraries |
|
|
212
|
+
| `add_hierarchical_sheet` | Create multi-sheet designs |
|
|
213
|
+
| `validate_component` | Check component/footprint compatibility |
|
|
214
|
+
| `list_components` | Get all components in schematic |
|
|
215
|
+
| `save_schematic` | Save with exact format preservation |
|
|
216
|
+
|
|
217
|
+
## 🏗️ Architecture
|
|
218
|
+
|
|
219
|
+
### Library Structure
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
kicad_sch_api/
|
|
223
|
+
├── core/ # Core schematic manipulation
|
|
224
|
+
├── library/ # KiCAD library integration
|
|
225
|
+
├── integration/ # KiCAD CLI and tool integration
|
|
226
|
+
├── mcp/ # MCP server for AI agents
|
|
227
|
+
└── utils/ # Validation and utilities
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Design Principles
|
|
231
|
+
|
|
232
|
+
- **Building Block First**: Designed to be the foundation for other tools
|
|
233
|
+
- **Exact Format Preservation**: Guaranteed byte-perfect KiCAD output
|
|
234
|
+
- **Professional Quality**: Comprehensive error handling and validation
|
|
235
|
+
- **AI-Native**: Built specifically for AI agent integration
|
|
236
|
+
- **Performance Optimized**: Fast operations on large schematics
|
|
237
|
+
|
|
238
|
+
## 🧪 Testing & Quality
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
# Run all tests
|
|
242
|
+
uv run pytest tests/ -v
|
|
243
|
+
|
|
244
|
+
# Format preservation tests (critical)
|
|
245
|
+
uv run pytest tests/reference_tests/ -v
|
|
246
|
+
|
|
247
|
+
# Code quality checks
|
|
248
|
+
uv run black kicad_sch_api/ tests/
|
|
249
|
+
uv run mypy kicad_sch_api/
|
|
250
|
+
uv run flake8 kicad_sch_api/ tests/
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## 🆚 Why This Library?
|
|
254
|
+
|
|
255
|
+
### vs. Direct KiCAD File Editing
|
|
256
|
+
- **Professional API**: High-level operations vs low-level S-expression manipulation
|
|
257
|
+
- **Guaranteed Format**: Byte-perfect output vs manual formatting
|
|
258
|
+
- **Validation**: Real KiCAD library integration and component validation
|
|
259
|
+
- **Performance**: Optimized collections vs manual iteration
|
|
260
|
+
|
|
261
|
+
### vs. Other Python KiCAD Libraries
|
|
262
|
+
- **Format Preservation**: Exact KiCAD compatibility vs approximate output
|
|
263
|
+
- **Modern Design**: Object-oriented collections vs legacy patterns
|
|
264
|
+
- **AI Integration**: Purpose-built MCP server vs no agent support
|
|
265
|
+
- **Professional Focus**: Production-ready vs exploration tools
|
|
266
|
+
|
|
267
|
+
## 🔗 Ecosystem
|
|
268
|
+
|
|
269
|
+
This library is designed as a building block for specialized tools:
|
|
270
|
+
|
|
271
|
+
```python
|
|
272
|
+
# Foundation library
|
|
273
|
+
import kicad_sch_api as ksa
|
|
274
|
+
|
|
275
|
+
# Specialized libraries (examples of what could be built)
|
|
276
|
+
# import kicad_sourcing_tools as sourcing # Component sourcing
|
|
277
|
+
# import kicad_placement_optimizer as placement # Layout optimization
|
|
278
|
+
# import kicad_dfm_checker as dfm # Manufacturing validation
|
|
279
|
+
|
|
280
|
+
# Foundation provides reliable schematic manipulation
|
|
281
|
+
sch = ksa.load_schematic('project.kicad_sch')
|
|
282
|
+
|
|
283
|
+
# Specialized tools extend functionality
|
|
284
|
+
# sourcing.update_component_sourcing(sch.components)
|
|
285
|
+
# placement.optimize_layout(sch)
|
|
286
|
+
# dfm.check_manufacturing_rules(sch)
|
|
287
|
+
|
|
288
|
+
# All save through foundation's format preservation
|
|
289
|
+
sch.save() # Guaranteed exact KiCAD format
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## 📖 Documentation
|
|
293
|
+
|
|
294
|
+
- **[API Reference](docs/api.md)**: Complete API documentation
|
|
295
|
+
- **[Examples](examples/)**: Code examples and tutorials
|
|
296
|
+
- **[MCP Integration](docs/mcp.md)**: AI agent integration guide
|
|
297
|
+
- **[Development](docs/development.md)**: Contributing and development setup
|
|
298
|
+
|
|
299
|
+
## 🤝 Contributing
|
|
300
|
+
|
|
301
|
+
We welcome contributions! Key areas:
|
|
302
|
+
|
|
303
|
+
- KiCAD library integration and component validation
|
|
304
|
+
- Performance optimizations for large schematics
|
|
305
|
+
- Additional MCP tools for AI agents
|
|
306
|
+
- Test coverage and format preservation validation
|
|
307
|
+
|
|
308
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
309
|
+
|
|
310
|
+
## 📄 License
|
|
311
|
+
|
|
312
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
313
|
+
|
|
314
|
+
## 🔗 Related Projects
|
|
315
|
+
|
|
316
|
+
- **[circuit-synth](https://github.com/circuit-synth/circuit-synth)**: High-level circuit design automation using this library
|
|
317
|
+
- **[Claude Code](https://claude.ai/code)**: AI development environment with MCP support
|
|
318
|
+
- **[KiCAD](https://kicad.org/)**: Open source electronics design automation suite
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
**Professional KiCAD schematic manipulation for the AI age ⚡**
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# KiCAD Schematic API
|
|
2
|
+
|
|
3
|
+
**Professional Python library for KiCAD schematic file manipulation with exact format preservation**
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Create and manipulate KiCAD schematic files programmatically with guaranteed exact format preservation. This library serves as the foundation for EDA automation tools and AI agents that need reliable, professional-grade schematic manipulation capabilities.
|
|
8
|
+
|
|
9
|
+
## 🎯 Core Features
|
|
10
|
+
|
|
11
|
+
- **📋 Exact Format Preservation**: Byte-perfect KiCAD output that matches native formatting
|
|
12
|
+
- **🏗️ Professional Component Management**: Object-oriented collections with search and validation
|
|
13
|
+
- **⚡ High Performance**: Optimized for large schematics with intelligent caching
|
|
14
|
+
- **🔍 Real KiCAD Library Integration**: Access to actual KiCAD symbol libraries and validation
|
|
15
|
+
- **🤖 AI Agent Ready**: MCP server for seamless integration with AI development tools
|
|
16
|
+
- **📚 Hierarchical Design**: Complete support for multi-sheet schematic projects
|
|
17
|
+
|
|
18
|
+
## 🚀 Quick Start
|
|
19
|
+
|
|
20
|
+
### Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Install from PyPI
|
|
24
|
+
pip install kicad-sch-api
|
|
25
|
+
|
|
26
|
+
# Or install from source
|
|
27
|
+
git clone https://github.com/circuit-synth/kicad-sch-api.git
|
|
28
|
+
cd kicad-sch-api/python
|
|
29
|
+
uv pip install -e .
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Basic Usage
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
import kicad_sch_api as ksa
|
|
36
|
+
|
|
37
|
+
# Create a new schematic
|
|
38
|
+
sch = ksa.create_schematic("My Circuit")
|
|
39
|
+
|
|
40
|
+
# Add components with proper validation
|
|
41
|
+
resistor = sch.components.add(
|
|
42
|
+
lib_id="Device:R",
|
|
43
|
+
reference="R1",
|
|
44
|
+
value="10k",
|
|
45
|
+
position=(100.0, 100.0),
|
|
46
|
+
footprint="Resistor_SMD:R_0603_1608Metric",
|
|
47
|
+
datasheet="~",
|
|
48
|
+
description="Resistor"
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
capacitor = sch.components.add(
|
|
52
|
+
lib_id="Device:C",
|
|
53
|
+
reference="C1",
|
|
54
|
+
value="100nF",
|
|
55
|
+
position=(150.0, 100.0),
|
|
56
|
+
footprint="Capacitor_SMD:C_0603_1608Metric"
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# Save with exact format preservation
|
|
60
|
+
sch.save("my_circuit.kicad_sch")
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Hierarchical Design
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
# Create main schematic with hierarchical sheet
|
|
67
|
+
main_sch = ksa.create_schematic("Main Board")
|
|
68
|
+
|
|
69
|
+
# Add hierarchical sheet
|
|
70
|
+
power_sheet = main_sch.add_hierarchical_sheet(
|
|
71
|
+
name="Power Supply",
|
|
72
|
+
filename="power.kicad_sch",
|
|
73
|
+
position=(100, 100),
|
|
74
|
+
size=(80, 60)
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
# Add sheet pins for connectivity
|
|
78
|
+
power_sheet.add_pin("VIN", pin_type="input", position=(0, 10))
|
|
79
|
+
power_sheet.add_pin("VOUT", pin_type="output", position=(80, 10))
|
|
80
|
+
|
|
81
|
+
# Create the sub-schematic
|
|
82
|
+
power_sch = ksa.create_schematic("Power Supply")
|
|
83
|
+
power_sch.add_hierarchical_label("VIN", label_type="input", position=(50, 25))
|
|
84
|
+
power_sch.add_hierarchical_label("VOUT", label_type="output", position=(150, 25))
|
|
85
|
+
|
|
86
|
+
# Save both schematics
|
|
87
|
+
main_sch.save("main.kicad_sch")
|
|
88
|
+
power_sch.save("power.kicad_sch")
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## 🔧 Advanced Features
|
|
92
|
+
|
|
93
|
+
### Component Search and Management
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
# Search for components
|
|
97
|
+
resistors = sch.components.find(lib_id_pattern='Device:R*')
|
|
98
|
+
power_components = sch.components.filter(reference_pattern=r'U[0-9]+')
|
|
99
|
+
|
|
100
|
+
# Bulk updates
|
|
101
|
+
sch.components.bulk_update(
|
|
102
|
+
criteria={'lib_id': 'Device:R'},
|
|
103
|
+
updates={'properties': {'Tolerance': '1%'}}
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
# Component validation
|
|
107
|
+
validation_result = sch.components.validate_component(
|
|
108
|
+
'Device:R',
|
|
109
|
+
'Resistor_SMD:R_0603_1608Metric'
|
|
110
|
+
)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### KiCAD Integration
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
# Run electrical rules check using KiCAD CLI
|
|
117
|
+
erc_result = sch.run_erc_check()
|
|
118
|
+
print(f"ERC Status: {erc_result.status}")
|
|
119
|
+
for violation in erc_result.violations:
|
|
120
|
+
print(f"- {violation.type}: {violation.message}")
|
|
121
|
+
|
|
122
|
+
# Generate netlist for connectivity analysis
|
|
123
|
+
netlist = sch.generate_netlist()
|
|
124
|
+
net_info = netlist.analyze_net("VCC")
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## 🤖 AI Agent Integration (MCP Server)
|
|
128
|
+
|
|
129
|
+
Use with Claude Code or other AI agents via Model Context Protocol:
|
|
130
|
+
|
|
131
|
+
### Setup MCP Server
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# Install MCP server
|
|
135
|
+
pip install kicad-sch-api[mcp]
|
|
136
|
+
|
|
137
|
+
# Configure for Claude Code (automatic)
|
|
138
|
+
kicad-sch-api --setup-claude-code
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Usage with AI Agents
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
# Natural language commands to your AI agent:
|
|
145
|
+
"Create a voltage divider with two 10kΩ resistors"
|
|
146
|
+
"Add an ESP32 microcontroller with USB connector"
|
|
147
|
+
"Generate a hierarchical schematic with power supply subcircuit"
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The AI agent will use the MCP server to:
|
|
151
|
+
1. Create professional schematics with proper component references
|
|
152
|
+
2. Use hierarchical labels instead of messy wires
|
|
153
|
+
3. Apply KiCAD design best practices automatically
|
|
154
|
+
4. Generate clean, industry-standard layouts
|
|
155
|
+
|
|
156
|
+
### Available MCP Tools
|
|
157
|
+
|
|
158
|
+
| Tool | Description |
|
|
159
|
+
|------|-------------|
|
|
160
|
+
| `create_schematic` | Create new schematic files |
|
|
161
|
+
| `add_component` | Add components with validation |
|
|
162
|
+
| `search_components` | Find components in KiCAD libraries |
|
|
163
|
+
| `add_hierarchical_sheet` | Create multi-sheet designs |
|
|
164
|
+
| `validate_component` | Check component/footprint compatibility |
|
|
165
|
+
| `list_components` | Get all components in schematic |
|
|
166
|
+
| `save_schematic` | Save with exact format preservation |
|
|
167
|
+
|
|
168
|
+
## 🏗️ Architecture
|
|
169
|
+
|
|
170
|
+
### Library Structure
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
kicad_sch_api/
|
|
174
|
+
├── core/ # Core schematic manipulation
|
|
175
|
+
├── library/ # KiCAD library integration
|
|
176
|
+
├── integration/ # KiCAD CLI and tool integration
|
|
177
|
+
├── mcp/ # MCP server for AI agents
|
|
178
|
+
└── utils/ # Validation and utilities
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Design Principles
|
|
182
|
+
|
|
183
|
+
- **Building Block First**: Designed to be the foundation for other tools
|
|
184
|
+
- **Exact Format Preservation**: Guaranteed byte-perfect KiCAD output
|
|
185
|
+
- **Professional Quality**: Comprehensive error handling and validation
|
|
186
|
+
- **AI-Native**: Built specifically for AI agent integration
|
|
187
|
+
- **Performance Optimized**: Fast operations on large schematics
|
|
188
|
+
|
|
189
|
+
## 🧪 Testing & Quality
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
# Run all tests
|
|
193
|
+
uv run pytest tests/ -v
|
|
194
|
+
|
|
195
|
+
# Format preservation tests (critical)
|
|
196
|
+
uv run pytest tests/reference_tests/ -v
|
|
197
|
+
|
|
198
|
+
# Code quality checks
|
|
199
|
+
uv run black kicad_sch_api/ tests/
|
|
200
|
+
uv run mypy kicad_sch_api/
|
|
201
|
+
uv run flake8 kicad_sch_api/ tests/
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## 🆚 Why This Library?
|
|
205
|
+
|
|
206
|
+
### vs. Direct KiCAD File Editing
|
|
207
|
+
- **Professional API**: High-level operations vs low-level S-expression manipulation
|
|
208
|
+
- **Guaranteed Format**: Byte-perfect output vs manual formatting
|
|
209
|
+
- **Validation**: Real KiCAD library integration and component validation
|
|
210
|
+
- **Performance**: Optimized collections vs manual iteration
|
|
211
|
+
|
|
212
|
+
### vs. Other Python KiCAD Libraries
|
|
213
|
+
- **Format Preservation**: Exact KiCAD compatibility vs approximate output
|
|
214
|
+
- **Modern Design**: Object-oriented collections vs legacy patterns
|
|
215
|
+
- **AI Integration**: Purpose-built MCP server vs no agent support
|
|
216
|
+
- **Professional Focus**: Production-ready vs exploration tools
|
|
217
|
+
|
|
218
|
+
## 🔗 Ecosystem
|
|
219
|
+
|
|
220
|
+
This library is designed as a building block for specialized tools:
|
|
221
|
+
|
|
222
|
+
```python
|
|
223
|
+
# Foundation library
|
|
224
|
+
import kicad_sch_api as ksa
|
|
225
|
+
|
|
226
|
+
# Specialized libraries (examples of what could be built)
|
|
227
|
+
# import kicad_sourcing_tools as sourcing # Component sourcing
|
|
228
|
+
# import kicad_placement_optimizer as placement # Layout optimization
|
|
229
|
+
# import kicad_dfm_checker as dfm # Manufacturing validation
|
|
230
|
+
|
|
231
|
+
# Foundation provides reliable schematic manipulation
|
|
232
|
+
sch = ksa.load_schematic('project.kicad_sch')
|
|
233
|
+
|
|
234
|
+
# Specialized tools extend functionality
|
|
235
|
+
# sourcing.update_component_sourcing(sch.components)
|
|
236
|
+
# placement.optimize_layout(sch)
|
|
237
|
+
# dfm.check_manufacturing_rules(sch)
|
|
238
|
+
|
|
239
|
+
# All save through foundation's format preservation
|
|
240
|
+
sch.save() # Guaranteed exact KiCAD format
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## 📖 Documentation
|
|
244
|
+
|
|
245
|
+
- **[API Reference](docs/api.md)**: Complete API documentation
|
|
246
|
+
- **[Examples](examples/)**: Code examples and tutorials
|
|
247
|
+
- **[MCP Integration](docs/mcp.md)**: AI agent integration guide
|
|
248
|
+
- **[Development](docs/development.md)**: Contributing and development setup
|
|
249
|
+
|
|
250
|
+
## 🤝 Contributing
|
|
251
|
+
|
|
252
|
+
We welcome contributions! Key areas:
|
|
253
|
+
|
|
254
|
+
- KiCAD library integration and component validation
|
|
255
|
+
- Performance optimizations for large schematics
|
|
256
|
+
- Additional MCP tools for AI agents
|
|
257
|
+
- Test coverage and format preservation validation
|
|
258
|
+
|
|
259
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
260
|
+
|
|
261
|
+
## 📄 License
|
|
262
|
+
|
|
263
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
264
|
+
|
|
265
|
+
## 🔗 Related Projects
|
|
266
|
+
|
|
267
|
+
- **[circuit-synth](https://github.com/circuit-synth/circuit-synth)**: High-level circuit design automation using this library
|
|
268
|
+
- **[Claude Code](https://claude.ai/code)**: AI development environment with MCP support
|
|
269
|
+
- **[KiCAD](https://kicad.org/)**: Open source electronics design automation suite
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
**Professional KiCAD schematic manipulation for the AI age ⚡**
|