kicad-sch-api 0.1.1__py3-none-any.whl → 0.1.3__py3-none-any.whl

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.

@@ -0,0 +1,322 @@
1
+ Metadata-Version: 2.4
2
+ Name: kicad-sch-api
3
+ Version: 0.1.3
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 ⚡**
@@ -1,4 +1,5 @@
1
1
  kicad_sch_api/__init__.py,sha256=mogTeOic6O-WWOfpoRuBzPicVNha-gbdMrhJX4ir5PY,2821
2
+ kicad_sch_api/cli.py,sha256=DvBDibtT4Ruyo_XWBwlsK5r2j0OWkjy-oslQqGk90Vs,12613
2
3
  kicad_sch_api/py.typed,sha256=e4ldqxwpY7pNDG1olbvj4HSKr8sZ9vxgA_2ek8xXn-Q,70
3
4
  kicad_sch_api/core/__init__.py,sha256=ur_KeYBlGKl-e1hLpLdxAhGV2A-PCCGkcqd0r6KSeBA,566
4
5
  kicad_sch_api/core/components.py,sha256=TiQrl7jdDTnuCWKdrlQC8-3b9PU58KoxTTnPX6VyZZk,24759
@@ -9,13 +10,17 @@ kicad_sch_api/core/parser.py,sha256=s1NwkuhouOplsBy-yZ_6RISmlunhWqRlD_8aNxIpYdU,
9
10
  kicad_sch_api/core/schematic.py,sha256=EHofbbfZfBfDcdHNNsO9peNNu3Iq07m2g_xQjL41p20,45972
10
11
  kicad_sch_api/core/types.py,sha256=I56eG0G8C4t9OaMiTcbxn6-xivwjpP5EXZUHnDoB6mY,12853
11
12
  kicad_sch_api/core/wires.py,sha256=kvANBg79KxOd5TKZNpHbjMyouZbGwRKLPNz4ePvvHgk,8207
13
+ kicad_sch_api/discovery/__init__.py,sha256=0ky_FT58x-6aez6R9nhH2BBV27yG1N8EutRbRu7USxo,328
14
+ kicad_sch_api/discovery/search_index.py,sha256=Yl3PXRk19mXCDtABM6Bs0ii0HMGiUAmIpD7xZjt7oEU,15943
12
15
  kicad_sch_api/library/__init__.py,sha256=NG9UTdcpn25Bl9tPsYs9ED7bvpaVPVdtLMbnxkQkOnU,250
13
16
  kicad_sch_api/library/cache.py,sha256=NPJT-apWH_JfVG1aXJ0gDnfGu8es_2tYiyZr-chcTxY,33511
17
+ kicad_sch_api/mcp/__init__.py,sha256=Jw4gKdn9H-2MVUYBTIAb6s5Tz2mYc9KoQPRsx-voD4s,159
18
+ kicad_sch_api/mcp/server.py,sha256=oeY4-EaxdzIeAW6jTNEpg5101QcFwZvNIP1WvIlCsb0,54343
14
19
  kicad_sch_api/utils/__init__.py,sha256=1V_yGgI7jro6MUc4Pviux_WIeJ1wmiYFID186SZwWLQ,277
15
20
  kicad_sch_api/utils/validation.py,sha256=XlWGRZJb3cOPYpU9sLQQgC_NASwbi6W-LCN7PzUmaPY,15626
16
- kicad_sch_api-0.1.1.dist-info/licenses/LICENSE,sha256=Em65Nvte1G9MHc0rHqtYuGkCPcshD588itTa358J6gs,1070
17
- kicad_sch_api-0.1.1.dist-info/METADATA,sha256=Z-e9Z73q-JnJ5cwvvyRPy40DO12RciKHUn5piRxHWCA,6676
18
- kicad_sch_api-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
- kicad_sch_api-0.1.1.dist-info/entry_points.txt,sha256=VWKsFi2Jv7G_tmio3cNVhhIBfv_OZFaKa-T_ED84lc8,57
20
- kicad_sch_api-0.1.1.dist-info/top_level.txt,sha256=n0ex4gOJ1b_fARowcGqRzyOGZcHRhc5LZa6_vVgGxcI,14
21
- kicad_sch_api-0.1.1.dist-info/RECORD,,
21
+ kicad_sch_api-0.1.3.dist-info/licenses/LICENSE,sha256=Em65Nvte1G9MHc0rHqtYuGkCPcshD588itTa358J6gs,1070
22
+ kicad_sch_api-0.1.3.dist-info/METADATA,sha256=RV0C_idQV160XSnrITBeHpVLp-sN_ez8ZwO92845rJk,10566
23
+ kicad_sch_api-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
+ kicad_sch_api-0.1.3.dist-info/entry_points.txt,sha256=Ibo-83_EdwmiuQwMcOHEzClKgl8MC9syASWtYzeD-os,103
25
+ kicad_sch_api-0.1.3.dist-info/top_level.txt,sha256=n0ex4gOJ1b_fARowcGqRzyOGZcHRhc5LZa6_vVgGxcI,14
26
+ kicad_sch_api-0.1.3.dist-info/RECORD,,
@@ -1,2 +1,3 @@
1
1
  [console_scripts]
2
2
  kicad-sch-api = kicad_sch_api.cli:main
3
+ kicad-sch-mcp = kicad_sch_api.mcp.server:main
@@ -1,207 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: kicad-sch-api
3
- Version: 0.1.1
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: sexpdata>=0.0.3
29
- Requires-Dist: typing-extensions>=4.0.0; python_version < "3.11"
30
- Provides-Extra: dev
31
- Requires-Dist: pytest>=7.0.0; extra == "dev"
32
- Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
33
- Requires-Dist: pytest-xdist>=3.0.0; extra == "dev"
34
- Requires-Dist: black>=22.0.0; extra == "dev"
35
- Requires-Dist: isort>=5.0.0; extra == "dev"
36
- Requires-Dist: flake8>=4.0.0; extra == "dev"
37
- Requires-Dist: mypy>=1.0.0; extra == "dev"
38
- Requires-Dist: pre-commit>=3.0.0; extra == "dev"
39
- Provides-Extra: docs
40
- Requires-Dist: sphinx>=5.0.0; extra == "docs"
41
- Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == "docs"
42
- Requires-Dist: myst-parser>=0.18.0; extra == "docs"
43
- Dynamic: license-file
44
-
45
- # kicad-sch-api
46
-
47
- **Professional KiCAD Schematic Manipulation Library with AI Agent Integration**
48
-
49
-
50
- ## 🚀 Key Features
51
-
52
- - **📋 Exact Format Preservation**: Output matches KiCAD's native formatting exactly
53
- - **⚡ High Performance**: Optimized for large schematics with symbol caching
54
- - **🔧 Enhanced API**: Intuitive object-oriented interface with bulk operations
55
- - **📚 Advanced Library Management**: Multi-source symbol lookup and caching
56
- - **✅ Professional Validation**: Comprehensive error collection and reporting
57
- - **🎯 KiCAD 9 Optimized**: Built specifically for latest KiCAD format
58
-
59
- ## 🆚 vs. Existing Solutions
60
-
61
- | Feature | kicad-sch-api | Other Solutions | KiCAD Official API |
62
- |---------|---------------|-----------------|-------------------|
63
- | **Schematic Support** | ✅ Full | ⚠️ Varies | ❌ PCB Only |
64
- | **Format Preservation** | ✅ Exact | ❌ Basic | N/A |
65
- | **Performance** | ✅ Optimized | ⚠️ Basic | N/A |
66
- | **Library Management** | ✅ Advanced | ⚠️ Limited | N/A |
67
- | **Runtime Dependencies** | ❌ None | ⚠️ Varies | ✅ KiCAD Required |
68
-
69
- ## 📦 Installation
70
-
71
- ```bash
72
- # Install from PyPI (coming soon)
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
- pip install -e .
79
-
80
- npm install
81
- npm run build
82
- ```
83
-
84
- ## 🎯 Quick Start
85
-
86
- ### Basic Schematic Manipulation
87
-
88
- ```python
89
- import kicad_sch_api as ksa
90
-
91
- # Create new schematic
92
- sch = ksa.create_schematic('My Circuit')
93
-
94
- # Add components
95
- resistor = sch.components.add('Device:R', reference='R1', value='10k', position=(100, 100))
96
- capacitor = sch.components.add('Device:C', reference='C1', value='0.1uF', position=(150, 100))
97
-
98
- # Update properties
99
- resistor.footprint = 'Resistor_SMD:R_0603_1608Metric'
100
- resistor.set_property('MPN', 'RC0603FR-0710KL')
101
-
102
- # Save with exact format preservation
103
- sch.save('my_circuit.kicad_sch')
104
- ```
105
-
106
- ### Advanced Operations
107
-
108
- ```python
109
- # Bulk operations for large schematics
110
- resistors = sch.components.filter(lib_id='Device:R')
111
- for r in resistors:
112
- r.set_property('Tolerance', '1%')
113
-
114
- # Search and analysis
115
- power_components = sch.components.in_area(0, 0, 50, 50)
116
- high_value_resistors = sch.components.filter(
117
- lib_id='Device:R',
118
- value_pattern='*k' # Components with 'k' in value
119
- )
120
-
121
- # Validation and error checking
122
- issues = sch.validate()
123
- if issues:
124
- print(f"Found {len(issues)} validation issues:")
125
- for issue in issues:
126
- print(f" {issue}")
127
-
128
- # Performance statistics
129
- stats = sch.get_performance_stats()
130
- print(f"Cache hit rate: {stats['symbol_cache']['hit_rate_percent']}%")
131
- ```
132
-
133
-
134
-
135
- ```json
136
- {
137
- "kicad-sch": {
138
- "command": "node",
139
- "env": {
140
- "PYTHON_PATH": "python3",
141
- "KICAD_SCH_API_PATH": "/path/to/kicad-sch-api/python"
142
- }
143
- }
144
- }
145
- ```
146
-
147
- Then use natural language with your AI agent:
148
-
149
- ```
150
- User: "Create a voltage divider circuit with two 10k resistors"
151
-
152
- Claude: I'll create a voltage divider circuit for you.
153
-
154
- 1. Create new schematic
155
- 2. Add R1 (10k resistor) at (100, 100)
156
- 3. Add R2 (10k resistor) at (100, 150)
157
- 4. Connect components with wires
158
- 5. Add voltage input and output labels
159
- 6. Save schematic with exact formatting
160
-
161
- Your voltage divider circuit is ready! The circuit provides 50% voltage division
162
- with two 10kΩ resistors in series configuration.
163
- ```
164
-
165
- ## 🏗️ Architecture
166
-
167
- The library consists of two main components:
168
-
169
- ### Python Library (Core)
170
- - **Enhanced Object Model**: Intuitive API with fast component collections
171
- - **Exact Format Preservation**: S-expression writer that matches KiCAD output
172
- - **Symbol Caching**: High-performance library symbol management
173
- - **Comprehensive Validation**: Error collection and professional reporting
174
-
175
- - **Python Bridge**: Reliable subprocess communication
176
- - **Comprehensive Tools**: 15+ tools for complete schematic manipulation
177
- - **Professional Error Handling**: Detailed error context for AI agents
178
-
179
- ## 🧪 Testing & Quality
180
-
181
- ```bash
182
- # Python tests
183
- cd python
184
- python -m pytest tests/ -v --cov=kicad_sch_api
185
-
186
- npm test
187
-
188
- # Format preservation tests
189
- python -m pytest tests/test_format_preservation.py -v
190
- ```
191
-
192
- ## 🤝 Contributing
193
-
194
- We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
195
-
196
- ## 📄 License
197
-
198
- MIT License - see [LICENSE](LICENSE) for details.
199
-
200
- ## 🔗 Related Projects
201
-
202
- - **[circuit-synth](https://github.com/circuit-synth/circuit-synth)**: Comprehensive circuit design automation
203
- - **[sexpdata](https://github.com/jd-boyd/sexpdata)**: S-expression parsing library
204
-
205
- ---
206
-
207
- **Built with ❤️ by the Circuit-Synth team**