prompt2gerber 0.1.1__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 (68) hide show
  1. prompt2gerber-0.1.1/.github/workflows/ci.yml +33 -0
  2. prompt2gerber-0.1.1/.github/workflows/release.yml +63 -0
  3. prompt2gerber-0.1.1/.gitignore +24 -0
  4. prompt2gerber-0.1.1/AGENTS.md +10 -0
  5. prompt2gerber-0.1.1/CHANGELOG.md +25 -0
  6. prompt2gerber-0.1.1/LICENSE +42 -0
  7. prompt2gerber-0.1.1/PKG-INFO +170 -0
  8. prompt2gerber-0.1.1/README.md +99 -0
  9. prompt2gerber-0.1.1/ROADMAP.md +81 -0
  10. prompt2gerber-0.1.1/TODO.md +37 -0
  11. prompt2gerber-0.1.1/data/components/esp32-s3-wroom-1.json +28 -0
  12. prompt2gerber-0.1.1/data/components/l9637d.json +31 -0
  13. prompt2gerber-0.1.1/data/components/ldl1117s33r.json +20 -0
  14. prompt2gerber-0.1.1/data/components/nup2105lt1g.json +16 -0
  15. prompt2gerber-0.1.1/data/components/tja1051t-3-1j.json +29 -0
  16. prompt2gerber-0.1.1/data/components/tps54331dr.json +24 -0
  17. prompt2gerber-0.1.1/pyproject.toml +62 -0
  18. prompt2gerber-0.1.1/src/prompt2gerber/__init__.py +3 -0
  19. prompt2gerber-0.1.1/src/prompt2gerber/cli.py +540 -0
  20. prompt2gerber-0.1.1/src/prompt2gerber/doctor.py +160 -0
  21. prompt2gerber-0.1.1/src/prompt2gerber/engines/__init__.py +1 -0
  22. prompt2gerber-0.1.1/src/prompt2gerber/engines/analog/__init__.py +13 -0
  23. prompt2gerber-0.1.1/src/prompt2gerber/engines/analog/buck_compensation.py +155 -0
  24. prompt2gerber-0.1.1/src/prompt2gerber/engines/freerouting/__init__.py +1 -0
  25. prompt2gerber-0.1.1/src/prompt2gerber/engines/freerouting/dsn_metrics.py +100 -0
  26. prompt2gerber-0.1.1/src/prompt2gerber/engines/freerouting/dsn_patcher.py +109 -0
  27. prompt2gerber-0.1.1/src/prompt2gerber/engines/freerouting/jre_manager.py +161 -0
  28. prompt2gerber-0.1.1/src/prompt2gerber/engines/freerouting/router.py +171 -0
  29. prompt2gerber-0.1.1/src/prompt2gerber/engines/group_rules.py +141 -0
  30. prompt2gerber-0.1.1/src/prompt2gerber/engines/placer/__init__.py +18 -0
  31. prompt2gerber-0.1.1/src/prompt2gerber/engines/placer/annealer.py +200 -0
  32. prompt2gerber-0.1.1/src/prompt2gerber/engines/placer/emc_physics.py +123 -0
  33. prompt2gerber-0.1.1/src/prompt2gerber/engines/placer/geometry.py +60 -0
  34. prompt2gerber-0.1.1/src/prompt2gerber/engines/stitcher.py +77 -0
  35. prompt2gerber-0.1.1/src/prompt2gerber/kicad/__init__.py +1 -0
  36. prompt2gerber-0.1.1/src/prompt2gerber/kicad/discovery.py +128 -0
  37. prompt2gerber-0.1.1/src/prompt2gerber/kicad/indexer.py +136 -0
  38. prompt2gerber-0.1.1/src/prompt2gerber/kicad/pcb_adapter.py +623 -0
  39. prompt2gerber-0.1.1/src/prompt2gerber/kicad/sch_compiler.py +169 -0
  40. prompt2gerber-0.1.1/src/prompt2gerber/kicad/smoke.py +198 -0
  41. prompt2gerber-0.1.1/src/prompt2gerber/llm/__init__.py +11 -0
  42. prompt2gerber-0.1.1/src/prompt2gerber/llm/client.py +100 -0
  43. prompt2gerber-0.1.1/src/prompt2gerber/llm/repair.py +151 -0
  44. prompt2gerber-0.1.1/src/prompt2gerber/orchestrator.py +173 -0
  45. prompt2gerber-0.1.1/src/prompt2gerber/pipeline1.py +45 -0
  46. prompt2gerber-0.1.1/src/prompt2gerber/pipeline2.py +136 -0
  47. prompt2gerber-0.1.1/src/prompt2gerber/scaffolder.py +226 -0
  48. prompt2gerber-0.1.1/src/prompt2gerber/schemas/__init__.py +49 -0
  49. prompt2gerber-0.1.1/src/prompt2gerber/schemas/component_db.py +205 -0
  50. prompt2gerber-0.1.1/src/prompt2gerber/schemas/constraints.py +66 -0
  51. prompt2gerber-0.1.1/src/prompt2gerber/schemas/manifest.py +48 -0
  52. prompt2gerber-0.1.1/src/prompt2gerber/schemas/netlist.py +137 -0
  53. prompt2gerber-0.1.1/src/prompt2gerber/templates/__init__.py +1 -0
  54. prompt2gerber-0.1.1/src/prompt2gerber/templates/agent_instructions.md.tmpl +30 -0
  55. prompt2gerber-0.1.1/src/prompt2gerber/templates/datasheet_extract_skill.md.tmpl +27 -0
  56. prompt2gerber-0.1.1/tests/test_component_extract.py +46 -0
  57. prompt2gerber-0.1.1/tests/test_doctor.py +151 -0
  58. prompt2gerber-0.1.1/tests/test_dsn_and_stitcher.py +114 -0
  59. prompt2gerber-0.1.1/tests/test_emc_physics.py +67 -0
  60. prompt2gerber-0.1.1/tests/test_indexer_and_db.py +146 -0
  61. prompt2gerber-0.1.1/tests/test_llm_repair.py +127 -0
  62. prompt2gerber-0.1.1/tests/test_pipeline1.py +82 -0
  63. prompt2gerber-0.1.1/tests/test_pipeline2.py +148 -0
  64. prompt2gerber-0.1.1/tests/test_router.py +58 -0
  65. prompt2gerber-0.1.1/tests/test_scaffolder.py +75 -0
  66. prompt2gerber-0.1.1/tests/test_schemas.py +119 -0
  67. prompt2gerber-0.1.1/tests/test_step6_integration.py +144 -0
  68. prompt2gerber-0.1.1/uv.lock +1479 -0
@@ -0,0 +1,33 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master, main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: windows-latest
11
+ steps:
12
+ - name: Check out repository
13
+ uses: actions/checkout@v4
14
+
15
+ - name: Install uv
16
+ uses: astral-sh/setup-uv@v5
17
+ with:
18
+ enable-cache: true
19
+
20
+ - name: Set up Python 3.13
21
+ run: uv python install 3.13
22
+
23
+ - name: Sync dependencies
24
+ run: uv sync --locked --dev || uv sync --dev
25
+
26
+ - name: Lint with ruff
27
+ run: uv run ruff check src tests
28
+
29
+ - name: Run unit tests
30
+ run: uv run pytest -v
31
+
32
+ - name: Build package
33
+ run: uv build
@@ -0,0 +1,63 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*.*.*"
7
+
8
+ permissions:
9
+ contents: write
10
+
11
+ jobs:
12
+ release:
13
+ runs-on: windows-latest
14
+ steps:
15
+ - name: Check out repository
16
+ uses: actions/checkout@v4
17
+
18
+ - name: Install uv
19
+ uses: astral-sh/setup-uv@v5
20
+ with:
21
+ enable-cache: true
22
+
23
+ - name: Set up Python 3.13
24
+ run: uv python install 3.13
25
+
26
+ - name: Sync dependencies
27
+ run: uv sync --locked --dev || uv sync --dev
28
+
29
+ - name: Lint and test before release
30
+ run: |
31
+ uv run ruff check src tests
32
+ uv run pytest -v
33
+
34
+ - name: Build wheel and sdist
35
+ run: uv build
36
+
37
+ - name: Upload build artifacts
38
+ uses: actions/upload-artifact@v4
39
+ with:
40
+ name: dist
41
+ path: dist/*
42
+
43
+ - name: Publish GitHub Release
44
+ uses: softprops/action-gh-release@v2
45
+ with:
46
+ files: dist/*
47
+ generate_release_notes: true
48
+
49
+ publish-pypi:
50
+ needs: release
51
+ runs-on: ubuntu-latest
52
+ environment: pypi
53
+ permissions:
54
+ id-token: write
55
+ steps:
56
+ - name: Download build artifacts
57
+ uses: actions/download-artifact@v4
58
+ with:
59
+ name: dist
60
+ path: dist
61
+
62
+ - name: Publish to PyPI (Trusted Publishing)
63
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,24 @@
1
+ # Python & uv
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ .venv/
6
+ venv/
7
+ dist/
8
+ build/
9
+ *.egg-info/
10
+ .pytest_cache/
11
+ .ruff_cache/
12
+ .mypy_cache/
13
+
14
+ # Local sandbox for testing `uv tool install` and `prompt2gerber --init` outputs
15
+ sandbox/
16
+
17
+ # SKiDL runtime artifacts
18
+ *.erc
19
+ *.log
20
+ *_sklib.py
21
+
22
+ # OS / Editors
23
+ .DS_Store
24
+ Thumbs.db
@@ -0,0 +1,10 @@
1
+ # Project Instructions
2
+
3
+ - **Language:** All documentation, code, comments, and identifiers (variables, functions, classes) must be written in English.
4
+ - **Distribution:** `prompt2gerber` is a Python CLI package installed via `uv tool` (e.g., `uv tool install --editable .`). It scaffolds standalone PCB workspaces via `prompt2gerber --init <Project> --agent <Agent>`.
5
+ - **Repository Structure:**
6
+ - `src/prompt2gerber/`: Python package source (`cli.py`, `schemas/`, `engines/` for pure ported algorithms, `kicad/` for isolated KiCad CLI adapters, and `templates/` for `--init`).
7
+ - `data/components/`: Human-reviewed JSON definitions for complex components extracted from datasheets.
8
+ - `tests/`: Unit and integration tests (keep generated test outputs out of the repository root).
9
+ - **Generated PCB Workspace Structure:** Any workspace initialized by `--init` must follow the standard KiCad layout (`libs/`, `docs/`, `routing/`, `fab/gerbers/`, `fab/reports/`, `netlist.json`, `constraints.json`, `manifest.json`, and agent-specific adapter files).
10
+ - **Progress Tracking:** Keep `TODO.md` (operational checklist) and `ROADMAP.md` (milestone status: `✅ Done`, `🚧 In Progress`, `⏳ Planned`) synchronized. Only mark tasks `[x]` or milestones `✅ Done` after real verification (tests and CLI execution).
@@ -0,0 +1,25 @@
1
+ # Changelog
2
+
3
+ All notable changes to `prompt2gerber` are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.1] - 2026-11-30
11
+
12
+ ### Added
13
+ - PyPI package metadata (`authors`, `keywords`, `classifiers`, `urls`) in `pyproject.toml`.
14
+ - Automated PyPI Trusted Publishing (`publish-pypi` job) in `.github/workflows/release.yml`.
15
+
16
+ ## [0.1.0] - 2026-11-30
17
+
18
+ ### Added
19
+ - **CLI & Packaging (`uv tool`):** `pyproject.toml` with `prompt2gerber` entry point, `doctor` environment audit (`Python`, `skidl`, `kicad-cli`, KiCad libraries, `Java 25+`, `FreeRouting`), `cache path/clean`, and `smoke` end-to-end check.
20
+ - **Pydantic Schemas & Component DB:** `netlist.json` (`Netlist` with `power_rails`, `functional_blocks`, `nets`, `board_hints`), `constraints.json` (`BoardConstraints`), `manifest.json` (`PcbManifest`), and `data/components/` seeded from `../OBD2` datasheets with `components sync/datasheet/list/validate/approve`.
21
+ - **Lazy KiCad Indexer:** `prompt2gerber search` with lazy-cached indexing of KiCad symbol (`.kicad_sym`) and footprint (`.pretty`) libraries.
22
+ - **Multi-Agent Scaffolder (`--init <Project> --agent <Agent>`):** Generates standalone KiCad PCB workspaces with embedded agent instructions and `datasheet-extract` skill for `antigravity`, `claude`, `copilot`, `mistral`, `codex`, `cursor`, and `windsurf`.
23
+ - **Pipeline 1 (`sch build` / `sch generate`):** Deterministic component-group validation (`group_rules.py`), SKiDL `.net`/`.kicad_sch` compilation with automatic `PWR_FLAG`, `kicad-cli sch erc`, ported TPS54331 Type II buck compensation (`analog buck`), and agnostic LLM + ERC repair loop.
24
+ - **Pipeline 2 (`pcb build`):** Isolated KiCad `pcbnew` / `kicad-cli` adapter, ported EMC physics (`emc_physics.py`), simulated annealing placement (`annealer.py`), Specctra DSN net-class patching (`dsn_patcher.py`), headless FreeRouting CLI runner, SES metrology (`dsn_metrics.py`), GND stitching vias (`stitcher.py`), DRC check, and Gerber/Excellon/SVG export.
25
+ - **Unified Orchestration & CI/CD:** `prompt2gerber build` and `prompt2gerber generate` generating `fab/reports/build_report.json` and `build_report.md`, plus GitHub Actions CI (`ci.yml`) and tag-triggered Release (`release.yml`).
@@ -0,0 +1,42 @@
1
+ # Project Licenses
2
+
3
+ This project is licensed under a dual open-source framework tailored for open-source hardware (OSHW) and software/tooling.
4
+
5
+ ---
6
+
7
+ ## 1. Hardware License (Schematics, PCB Layouts, Manufacturing Files, 3D CAD)
8
+
9
+ Any hardware design files, templates, and example outputs included in this repository (including schematics, PCB layout files, Gerber/drill production files, BOM, Pick-and-Place data, and 3D CAD models) are licensed under the **CERN Open Hardware Licence Version 2 – Permissive (CERN-OHL-P v2)**.
10
+
11
+ ### CERN Open Hardware Licence Version 2 – Permissive
12
+
13
+ Copyright (c) 2026 prompt2gerber Contributors
14
+
15
+ Preamble
16
+ CERN has developed this licence to promote collaboration on the hardware design of products, the sharing of technologies and to address specific issues of hardware licensing that are not addressed by conventional software licences. This licence governs the use, copying, modification and distribution of Hardware Designs, and the making and distribution of Products.
17
+
18
+ You may use, copy, modify, distribute, and manufacture products based on this hardware design under the terms and conditions of the CERN-OHL-P v2.
19
+
20
+ Full license text: https://ohwr.org/cern_ohl_p_v2.txt
21
+
22
+ ---
23
+
24
+ ## 2. Software & Tooling License (CLI, Engines, Adapters, Python Scripts)
25
+
26
+ All software, templates, test scripts, and automation code within this repository are licensed under the **Apache License, Version 2.0**.
27
+
28
+ ```
29
+ Copyright (c) 2026 prompt2gerber Contributors
30
+
31
+ Licensed under the Apache License, Version 2.0 (the "License");
32
+ you may not use this file except in compliance with the License.
33
+ You may obtain a copy of the License at
34
+
35
+ http://www.apache.org/licenses/LICENSE-2.0
36
+
37
+ Unless required by applicable law or agreed to in writing, software
38
+ distributed under the License is distributed on an "AS IS" BASIS,
39
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
40
+ See the License for the specific language governing permissions and
41
+ limitations under the License.
42
+ ```
@@ -0,0 +1,170 @@
1
+ Metadata-Version: 2.5
2
+ Name: prompt2gerber
3
+ Version: 0.1.1
4
+ Summary: CLI-first Python toolchain and AI-agent scaffolder turning prompts into KiCad PCB Gerbers
5
+ Project-URL: Homepage, https://github.com/nitrogene/prompt2gerber
6
+ Project-URL: Repository, https://github.com/nitrogene/prompt2gerber
7
+ Project-URL: Issues, https://github.com/nitrogene/prompt2gerber/issues
8
+ Project-URL: Changelog, https://github.com/nitrogene/prompt2gerber/blob/master/CHANGELOG.md
9
+ Author: Jean-Pierre GERVASONI
10
+ License: # Project Licenses
11
+
12
+ This project is licensed under a dual open-source framework tailored for open-source hardware (OSHW) and software/tooling.
13
+
14
+ ---
15
+
16
+ ## 1. Hardware License (Schematics, PCB Layouts, Manufacturing Files, 3D CAD)
17
+
18
+ Any hardware design files, templates, and example outputs included in this repository (including schematics, PCB layout files, Gerber/drill production files, BOM, Pick-and-Place data, and 3D CAD models) are licensed under the **CERN Open Hardware Licence Version 2 – Permissive (CERN-OHL-P v2)**.
19
+
20
+ ### CERN Open Hardware Licence Version 2 – Permissive
21
+
22
+ Copyright (c) 2026 prompt2gerber Contributors
23
+
24
+ Preamble
25
+ CERN has developed this licence to promote collaboration on the hardware design of products, the sharing of technologies and to address specific issues of hardware licensing that are not addressed by conventional software licences. This licence governs the use, copying, modification and distribution of Hardware Designs, and the making and distribution of Products.
26
+
27
+ You may use, copy, modify, distribute, and manufacture products based on this hardware design under the terms and conditions of the CERN-OHL-P v2.
28
+
29
+ Full license text: https://ohwr.org/cern_ohl_p_v2.txt
30
+
31
+ ---
32
+
33
+ ## 2. Software & Tooling License (CLI, Engines, Adapters, Python Scripts)
34
+
35
+ All software, templates, test scripts, and automation code within this repository are licensed under the **Apache License, Version 2.0**.
36
+
37
+ ```
38
+ Copyright (c) 2026 prompt2gerber Contributors
39
+
40
+ Licensed under the Apache License, Version 2.0 (the "License");
41
+ you may not use this file except in compliance with the License.
42
+ You may obtain a copy of the License at
43
+
44
+ http://www.apache.org/licenses/LICENSE-2.0
45
+
46
+ Unless required by applicable law or agreed to in writing, software
47
+ distributed under the License is distributed on an "AS IS" BASIS,
48
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
49
+ See the License for the specific language governing permissions and
50
+ limitations under the License.
51
+ ```
52
+ License-File: LICENSE
53
+ Keywords: ai-agents,cli,eda,freerouting,gerber,kicad,pcb
54
+ Classifier: Development Status :: 3 - Alpha
55
+ Classifier: Environment :: Console
56
+ Classifier: Intended Audience :: Developers
57
+ Classifier: Intended Audience :: Science/Research
58
+ Classifier: License :: OSI Approved :: Apache Software License
59
+ Classifier: Operating System :: Microsoft :: Windows
60
+ Classifier: Programming Language :: Python :: 3
61
+ Classifier: Programming Language :: Python :: 3.11
62
+ Classifier: Programming Language :: Python :: 3.12
63
+ Classifier: Programming Language :: Python :: 3.13
64
+ Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
65
+ Requires-Python: >=3.11
66
+ Requires-Dist: platformdirs>=4.0.0
67
+ Requires-Dist: pydantic>=2.6.0
68
+ Requires-Dist: skidl>=2.0.0
69
+ Requires-Dist: typer>=0.12.0
70
+ Description-Content-Type: text/markdown
71
+
72
+ # prompt2gerber
73
+
74
+ [![Python](https://img.shields.io/badge/Python-3.11+-3776AB?style=for-the-badge&logo=python&logoColor=white)](https://www.python.org/)
75
+ [![uv](https://img.shields.io/badge/Packaging-uv%20tool-DE5FE9?style=for-the-badge&logo=astral&logoColor=white)](https://docs.astral.sh/uv/)
76
+ [![EDA: KiCad Headless](https://img.shields.io/badge/EDA-KiCad%20Headless-314CB0?style=for-the-badge&logo=kicad&logoColor=white)](https://www.kicad.org/)
77
+ [![Router: Freerouting](https://img.shields.io/badge/Router-Freerouting%20CLI-0E7C7B?style=for-the-badge)](https://freerouting.org/)
78
+ [![Validation: Pydantic](https://img.shields.io/badge/Schema-Pydantic-E92063?style=for-the-badge&logo=pydantic&logoColor=white)](https://docs.pydantic.dev/)
79
+ [![AI Agents](https://img.shields.io/badge/Workflow-AI%20Agents-10A37F?style=for-the-badge)](./AGENTS.md)
80
+ [![Status: Planning](https://img.shields.io/badge/Status-Planning-F59E0B?style=for-the-badge)](./ROADMAP.md)
81
+ [![License](https://img.shields.io/badge/License-Apache%202.0%20%2F%20CERN--OHL--P%20v2-blue?style=for-the-badge)](./LICENSE)
82
+
83
+ `prompt2gerber` is a Python CLI tool and project scaffolder (distributed via `uv tool`) that turns natural-language hardware prompts into fabrication-ready PCB **Gerber** and **Excellon** drill files for multi-layer boards (including microcontrollers, full schematics, and autorouting).
84
+
85
+ ## Installation & Usage (Planned)
86
+
87
+ ```bash
88
+ # Install globally as an isolated CLI tool
89
+ uv tool install prompt2gerber
90
+
91
+ # Or in editable mode during development
92
+ uv tool install --editable .
93
+
94
+ # Verify local environment (kicad-cli, KiCad libraries, Freerouting/JRE)
95
+ prompt2gerber doctor
96
+
97
+ # Scaffold a new standalone PCB project tailored for an AI agent
98
+ prompt2gerber --init NewPCB --agent antigravity
99
+ ```
100
+
101
+ ## Platform Support & Prerequisites
102
+
103
+ * **Current Target Platform:** **Windows** (initial development target until cross-platform / Docker support is finalized for macOS and Linux).
104
+ * **KiCad (`kicad-cli` + standard libraries):** Not bundled inside the Python wheel; install locally via `winget install KiCad.KiCad`.
105
+ * **Freerouting & JRE:** Managed automatically by `prompt2gerber` (cached portable runtime).
106
+ * Run `prompt2gerber doctor` to validate that all external tools are detected.
107
+
108
+ ## Architecture Overview
109
+
110
+ `prompt2gerber` separates the reusable CLI toolchain from the generated PCB workspaces:
111
+
112
+ 1. **Project Scaffolder (`--init <Project> --agent <Agent>`):**
113
+ Creates a clean, standalone KiCad-compatible PCB workspace (`libs/`, `docs/`, `routing/`, `fab/`, `.gitignore`, JSON contracts) along with agent-specific adapter files (e.g., `AGENTS.md` for Antigravity, `CLAUDE.md` for Claude, `.cursor/rules/` for Cursor).
114
+ 2. **Two Decoupled CLI Pipelines:**
115
+
116
+ ```text
117
+ User Prompt
118
+ │
119
+ ▼
120
+ [ LLM ] ──► netlist.json (BOM, semantics, power rails, functional blocks, explicit pin-to-pin nets)
121
+ │
122
+ ▼
123
+ Pipeline 1: netlist.json ──► KiCad Schematic (.kicad_sch) + ERC
124
+ │ (skidl / ato validation + analog sizing helpers like buck-compensation)
125
+ ▼
126
+ Pipeline 2: Schematic + constraints.json / manifest.json
127
+ ──► KiCad PCB (.kicad_pcb)
128
+ ──► EMC Simulated Annealing Placer + Freerouting CLI + DSN Metrology + Stitching
129
+ ──► Gerber / Excellon + DRC + SVG/PNG
130
+ ```
131
+
132
+ ### Key Design Principles
133
+
134
+ * **Strict LLM Boundary:** The LLM only generates `netlist.json` (components, semantics, and explicit pin-to-pin nets). All schematic generation, placement, routing, and Gerber export are deterministic.
135
+ * **Proven JSON Contracts (Evolved from `OBD2`):**
136
+ * `netlist.json` builds on `bom.schema.json` + `semantics.schema.json` (designators, MPN/LCSC, `power_rails`, `functional_blocks`) and adds explicit `nets` connectivity.
137
+ * Pipeline 2 consumes `constraints.json` (`board`, `anchors`, `keepout_zones`, `net_classes`, `plane_nets`) and `manifest.json` (`packages`, `placement_constraints`, `rigid_groups`, `cem_target`), directly compatible with the placement/EMC/routing engines ported from `../OBD2`.
138
+ * **Reusable Algorithmic Engines + KiCad CLI Adapter:**
139
+ * Core engines ported from `../OBD2` (`pcb-placer` simulated annealing & `emc_physics`, `freerouting` JRE/DSN patcher/CLI runner, `pcb-synthesizer` closed-loop & `dsn_metrics`, `pcb-stitcher`, `pcb-dfm`, `buck-compensation`, `ratio-solver`) remain pure, EDA-agnostic Python modules.
140
+ * All KiCad interactions (`kicad-cli`, schematic/PCB generation, DSN/SES exchange, ERC/DRC, Gerber export) are isolated in a dedicated `kicad/` adapter module — replacing the legacy EasyEDA bridge.
141
+ * **Component Library Strategy:**
142
+ * Standard KiCad libraries for common/simple parts.
143
+ * Complex parts (e.g., MCUs, specialized ICs) stored in a local JSON database (`data/components/`) extracted from manufacturer datasheets with LLM assistance and **human-reviewed** before use.
144
+ * **100% CLI Workflow:** Driven via Python CLI (`typer`/`click`, Pydantic, agnostic LLM SDK) installed via `uv tool`, keeping target PCB workspaces free of Python virtual environments.
145
+
146
+ ## Repository Layout
147
+
148
+ ```text
149
+ prompt2gerber/
150
+ ├── pyproject.toml
151
+ ├── AGENTS.md
152
+ ├── README.md
153
+ ├── ROADMAP.md
154
+ ├── src/prompt2gerber/
155
+ │ ├── cli.py # Typer CLI entry point (--init, pipeline commands)
156
+ │ ├── schemas/ # Pydantic models & JSON schemas (netlist, constraints, manifest)
157
+ │ ├── engines/ # Pure algorithmic engines ported from OBD2 (placer, emc, dsn, stitcher, dfm)
158
+ │ ├── kicad/ # Isolated KiCad CLI / file adapter (replaces EasyEDA bridge)
159
+ │ └── templates/ # Packaged PCB workspace & agent templates (--init --agent)
160
+ ├── data/components/ # Human-reviewed JSON database of complex components
161
+ └── tests/ # Unit and integration tests
162
+ ```
163
+
164
+ ## Project Status
165
+
166
+ Planning / Early setup. See [ROADMAP.md](ROADMAP.md) for the step-by-step implementation plan.
167
+
168
+ ## License
169
+
170
+ Dual-licensed under **Apache License 2.0** (software and tooling) and **CERN-OHL-P v2** (hardware designs). See [LICENSE](LICENSE) for full details.
@@ -0,0 +1,99 @@
1
+ # prompt2gerber
2
+
3
+ [![Python](https://img.shields.io/badge/Python-3.11+-3776AB?style=for-the-badge&logo=python&logoColor=white)](https://www.python.org/)
4
+ [![uv](https://img.shields.io/badge/Packaging-uv%20tool-DE5FE9?style=for-the-badge&logo=astral&logoColor=white)](https://docs.astral.sh/uv/)
5
+ [![EDA: KiCad Headless](https://img.shields.io/badge/EDA-KiCad%20Headless-314CB0?style=for-the-badge&logo=kicad&logoColor=white)](https://www.kicad.org/)
6
+ [![Router: Freerouting](https://img.shields.io/badge/Router-Freerouting%20CLI-0E7C7B?style=for-the-badge)](https://freerouting.org/)
7
+ [![Validation: Pydantic](https://img.shields.io/badge/Schema-Pydantic-E92063?style=for-the-badge&logo=pydantic&logoColor=white)](https://docs.pydantic.dev/)
8
+ [![AI Agents](https://img.shields.io/badge/Workflow-AI%20Agents-10A37F?style=for-the-badge)](./AGENTS.md)
9
+ [![Status: Planning](https://img.shields.io/badge/Status-Planning-F59E0B?style=for-the-badge)](./ROADMAP.md)
10
+ [![License](https://img.shields.io/badge/License-Apache%202.0%20%2F%20CERN--OHL--P%20v2-blue?style=for-the-badge)](./LICENSE)
11
+
12
+ `prompt2gerber` is a Python CLI tool and project scaffolder (distributed via `uv tool`) that turns natural-language hardware prompts into fabrication-ready PCB **Gerber** and **Excellon** drill files for multi-layer boards (including microcontrollers, full schematics, and autorouting).
13
+
14
+ ## Installation & Usage (Planned)
15
+
16
+ ```bash
17
+ # Install globally as an isolated CLI tool
18
+ uv tool install prompt2gerber
19
+
20
+ # Or in editable mode during development
21
+ uv tool install --editable .
22
+
23
+ # Verify local environment (kicad-cli, KiCad libraries, Freerouting/JRE)
24
+ prompt2gerber doctor
25
+
26
+ # Scaffold a new standalone PCB project tailored for an AI agent
27
+ prompt2gerber --init NewPCB --agent antigravity
28
+ ```
29
+
30
+ ## Platform Support & Prerequisites
31
+
32
+ * **Current Target Platform:** **Windows** (initial development target until cross-platform / Docker support is finalized for macOS and Linux).
33
+ * **KiCad (`kicad-cli` + standard libraries):** Not bundled inside the Python wheel; install locally via `winget install KiCad.KiCad`.
34
+ * **Freerouting & JRE:** Managed automatically by `prompt2gerber` (cached portable runtime).
35
+ * Run `prompt2gerber doctor` to validate that all external tools are detected.
36
+
37
+ ## Architecture Overview
38
+
39
+ `prompt2gerber` separates the reusable CLI toolchain from the generated PCB workspaces:
40
+
41
+ 1. **Project Scaffolder (`--init <Project> --agent <Agent>`):**
42
+ Creates a clean, standalone KiCad-compatible PCB workspace (`libs/`, `docs/`, `routing/`, `fab/`, `.gitignore`, JSON contracts) along with agent-specific adapter files (e.g., `AGENTS.md` for Antigravity, `CLAUDE.md` for Claude, `.cursor/rules/` for Cursor).
43
+ 2. **Two Decoupled CLI Pipelines:**
44
+
45
+ ```text
46
+ User Prompt
47
+ │
48
+ ▼
49
+ [ LLM ] ──► netlist.json (BOM, semantics, power rails, functional blocks, explicit pin-to-pin nets)
50
+ │
51
+ ▼
52
+ Pipeline 1: netlist.json ──► KiCad Schematic (.kicad_sch) + ERC
53
+ │ (skidl / ato validation + analog sizing helpers like buck-compensation)
54
+ ▼
55
+ Pipeline 2: Schematic + constraints.json / manifest.json
56
+ ──► KiCad PCB (.kicad_pcb)
57
+ ──► EMC Simulated Annealing Placer + Freerouting CLI + DSN Metrology + Stitching
58
+ ──► Gerber / Excellon + DRC + SVG/PNG
59
+ ```
60
+
61
+ ### Key Design Principles
62
+
63
+ * **Strict LLM Boundary:** The LLM only generates `netlist.json` (components, semantics, and explicit pin-to-pin nets). All schematic generation, placement, routing, and Gerber export are deterministic.
64
+ * **Proven JSON Contracts (Evolved from `OBD2`):**
65
+ * `netlist.json` builds on `bom.schema.json` + `semantics.schema.json` (designators, MPN/LCSC, `power_rails`, `functional_blocks`) and adds explicit `nets` connectivity.
66
+ * Pipeline 2 consumes `constraints.json` (`board`, `anchors`, `keepout_zones`, `net_classes`, `plane_nets`) and `manifest.json` (`packages`, `placement_constraints`, `rigid_groups`, `cem_target`), directly compatible with the placement/EMC/routing engines ported from `../OBD2`.
67
+ * **Reusable Algorithmic Engines + KiCad CLI Adapter:**
68
+ * Core engines ported from `../OBD2` (`pcb-placer` simulated annealing & `emc_physics`, `freerouting` JRE/DSN patcher/CLI runner, `pcb-synthesizer` closed-loop & `dsn_metrics`, `pcb-stitcher`, `pcb-dfm`, `buck-compensation`, `ratio-solver`) remain pure, EDA-agnostic Python modules.
69
+ * All KiCad interactions (`kicad-cli`, schematic/PCB generation, DSN/SES exchange, ERC/DRC, Gerber export) are isolated in a dedicated `kicad/` adapter module — replacing the legacy EasyEDA bridge.
70
+ * **Component Library Strategy:**
71
+ * Standard KiCad libraries for common/simple parts.
72
+ * Complex parts (e.g., MCUs, specialized ICs) stored in a local JSON database (`data/components/`) extracted from manufacturer datasheets with LLM assistance and **human-reviewed** before use.
73
+ * **100% CLI Workflow:** Driven via Python CLI (`typer`/`click`, Pydantic, agnostic LLM SDK) installed via `uv tool`, keeping target PCB workspaces free of Python virtual environments.
74
+
75
+ ## Repository Layout
76
+
77
+ ```text
78
+ prompt2gerber/
79
+ ├── pyproject.toml
80
+ ├── AGENTS.md
81
+ ├── README.md
82
+ ├── ROADMAP.md
83
+ ├── src/prompt2gerber/
84
+ │ ├── cli.py # Typer CLI entry point (--init, pipeline commands)
85
+ │ ├── schemas/ # Pydantic models & JSON schemas (netlist, constraints, manifest)
86
+ │ ├── engines/ # Pure algorithmic engines ported from OBD2 (placer, emc, dsn, stitcher, dfm)
87
+ │ ├── kicad/ # Isolated KiCad CLI / file adapter (replaces EasyEDA bridge)
88
+ │ └── templates/ # Packaged PCB workspace & agent templates (--init --agent)
89
+ ├── data/components/ # Human-reviewed JSON database of complex components
90
+ └── tests/ # Unit and integration tests
91
+ ```
92
+
93
+ ## Project Status
94
+
95
+ Planning / Early setup. See [ROADMAP.md](ROADMAP.md) for the step-by-step implementation plan.
96
+
97
+ ## License
98
+
99
+ Dual-licensed under **Apache License 2.0** (software and tooling) and **CERN-OHL-P v2** (hardware designs). See [LICENSE](LICENSE) for full details.
@@ -0,0 +1,81 @@
1
+ # Roadmap — prompt2gerber
2
+
3
+ This roadmap breaks down the development of `prompt2gerber` (a `uv tool`-installable Python CLI package and PCB project scaffolder) into incremental, verifiable milestones, reusing and adapting the proven EDA-agnostic engines and JSON schemas from `../OBD2`.
4
+
5
+ ---
6
+
7
+ ## Step 1 — `uv tool` Packaging, Reproducible Environment & `skidl` / `ato` Evaluation ✅ Done (commit `7a8d410`)
8
+
9
+ **Goal:** Establish the installable Python CLI package and validate the KiCad + Freerouting CLI toolchain without EasyEDA.
10
+
11
+ * Initialize the Python package (`pyproject.toml` with `[project.scripts]`, `typer` CLI skeleton, test suite) and verify editable installation via `uv tool install --editable .`.
12
+ * Set up a baseline CI workflow (GitHub Actions: linting, unit tests via `uv run pytest`, and package build check).
13
+ * Set up a reproducible environment for `kicad-cli`, KiCad tools, and Freerouting CLI (porting `jre_manager.py` and `router.py` from `../OBD2/.agents/skills/freerouting/`).
14
+ * Run a comparative POC between **`skidl`** and **`atopile` (`ato`)** on a representative subcircuit (e.g., MCU + crystal + decoupling capacitors + voltage regulator) to evaluate subcircuit/group validation and KiCad export capabilities.
15
+
16
+ **Exit Criteria:** `prompt2gerber` runs globally via `uv tool` and executes an end-to-end smoke test that generates a minimal `.kicad_pcb` and exports Gerber + SVG/PNG previews via `kicad-cli`.
17
+
18
+ ---
19
+
20
+ ## Step 2 — JSON Schemas (`netlist.json`, `constraints.json`, `manifest.json`), Component DB & Initial `--init` ✅ Done
21
+
22
+ **Goal:** Lock down the Pydantic/JSON contracts (inspired by `../OBD2`), part resolution, and the `--init <Project> --agent <Agent>` scaffolder.
23
+
24
+ * Define strict Pydantic models (exporting JSON Schemas) aligned with `../OBD2/documents/`:
25
+ * `netlist.json`: combining `bom.schema.json` + `semantics.schema.json` (`power_rails`, `functional_blocks`, `components`) with explicit pin-to-pin `nets`.
26
+ * `constraints.json` & `manifest.json`: preserving `constraints.schema.json` (`board`, `anchors`, `keepout_zones`, `net_classes`, `plane_nets`) and `manifest.schema.json` (`packages`, `placement_constraints`, `rigid_groups`, `cem_target`).
27
+ * Build a searchable index of standard KiCad library parts.
28
+ * Implement the CLI workflow for complex components: *Manufacturer datasheet PDF → LLM-assisted JSON extraction → human review/approval* before adding to `data/components/`.
29
+ * Implement the initial **`prompt2gerber --init <Project> --agent <Agent>`** command using packaged templates (`importlib.resources`) to scaffold a standalone PCB workspace (`libs/`, `docs/`, `routing/`, `fab/`, `.gitignore`, base KiCad files) and an initial agent adapter (starting with `antigravity`).
30
+
31
+ **Exit Criteria:** A hand-authored `netlist.json` (e.g., 1 MCU + passives) inside a workspace created by `prompt2gerber --init NewPCB --agent antigravity` passes Pydantic validation and resolves all symbols and footprints cleanly.
32
+
33
+ ---
34
+
35
+ ## Step 3 — Pipeline 2: Schematic / Netlist → PCB → Gerber (Replacing EasyEDA) ✅ Done
36
+
37
+ **Goal:** Build the deterministic, CLI-only PCB layout, autorouting, and Gerber export pipeline by porting `../OBD2` engines onto the `kicad/` adapter.
38
+
39
+ * Implement the isolated `kicad/` adapter (footprint geometry extraction, `.kicad_pcb` generation/placement injection, DSN export, SES import, `kicad-cli pcb drc`, Gerber/Excellon + SVG/PNG export).
40
+ * Port pure engines and their existing unit tests from `../OBD2`:
41
+ * `pcb-placer` (`simulated_annealing.py`, `emc_physics.py`, `score.py`, `size_estimator.py`, `label_placer.py`, `render_svg.py`, `audit_placement.py`).
42
+ * `freerouting` (`dsn_patcher.py`, `dsn_updater.py`, `router.py`).
43
+ * `pcb-synthesizer` (`dsn_metrics.py` + closed-loop feedback) and `pcb-stitcher` (`fanout_stitcher.py`, `island_bridger.py`).
44
+ * Output **Gerber RS-274X + Excellon drill files** into `fab/gerbers/` and **SVG/PNG** layer renders + DRC report into `fab/reports/`.
45
+
46
+ **Exit Criteria:** Given a multi-layer test netlist + `constraints.json`/`manifest.json`, the CLI produces a fabrication-ready Gerber/Excellon archive with 0 DRC errors.
47
+
48
+ ---
49
+
50
+ ## Step 4 — Pipeline 1: `netlist.json` → Schematic & ERC ✅ Done
51
+
52
+ **Goal:** Deterministically convert `netlist.json` into a valid, ERC-checked KiCad schematic.
53
+
54
+ * Implement the `netlist.json` → `.kicad_sch` generator (incorporating the `skidl` / `ato` / KiCad strategy chosen in Step 1).
55
+ * Add component-group validation rules (e.g., decoupling capacitors, pull-ups, power rails) and integrate analog sizing helpers ported from `../OBD2` (`buck-compensation`, `ratio-solver`).
56
+ * Run **`kicad-cli sch erc`** and parse errors/warnings into structured JSON under `fab/reports/`.
57
+
58
+ **Exit Criteria:** A valid `netlist.json` produces a `.kicad_sch` that passes `kicad-cli sch erc` with no critical errors.
59
+
60
+ ---
61
+
62
+ ## Step 5 — LLM Integration & Automated Repair Loop ✅ Done
63
+
64
+ **Goal:** Connect natural-language prompts to Pipeline 1 with self-healing validation.
65
+
66
+ * Implement an agnostic LLM client that receives the available component catalog context and outputs `netlist.json`.
67
+ * Build the automated repair loop: if Pydantic validation, group rules, or `kicad-cli sch erc` fails, feed the exact structured errors back to the LLM to fix `netlist.json` (with a configurable retry limit).
68
+
69
+ **Exit Criteria:** A natural-language prompt converges to an ERC-clean `netlist.json` and `.kicad_sch` within $\le 3$ iterations.
70
+
71
+ ---
72
+
73
+ ## Step 6 — Full Orchestration, Multi-Agent Adapters & Quality Suite ✅ Done
74
+
75
+ **Goal:** Unify both pipelines behind a single CLI command and finalize agent adapters.
76
+
77
+ * Implement the unified command (e.g., `prompt2gerber generate "..."`) chaining: Prompt → `netlist.json` → Pipeline 1 (Schematic + ERC) → Pipeline 2 (Placement + Freerouting + DSN Metrology + Stitching + DRC + Gerber/Excellon + SVG/PNG previews).
78
+ * Finalize `--agent` adapter templates (`antigravity`, `claude`, `cursor`, etc.) with the stabilized CLI commands and workflow instructions.
79
+ * Generate a build summary report (BOM, ERC/DRC status, layer previews).
80
+ * Add an integration test suite covering reference prompts from simple sensor breakouts to multi-layer MCU boards.
81
+ * Finalize CI/CD pipelines (GitHub Actions): automated KiCad/Freerouting integration tests and tagged release publishing (`uv build` / PyPI or GitHub Release) for `uv tool install prompt2gerber`.
@@ -0,0 +1,37 @@
1
+ # Project Roadmap (TODO)
2
+
3
+ ## Step 1 — CLI Foundation & Toolchain ✅ Done
4
+ - [x] Initialize `pyproject.toml` (`typer`, `pydantic`, `skidl`, `platformdirs`, `pytest`, `ruff`) and verify `uv tool install --editable .`.
5
+ - [x] Implement `prompt2gerber doctor` (auditing Python, `skidl`, `kicad-cli`, KiCad libraries, Java 25+, FreeRouting) and `prompt2gerber cache path/clean`.
6
+ - [x] Port `jre_manager.py` and `router.py` from `../OBD2`.
7
+ - [x] Evaluate `skidl` vs `atopile` and lock in `skidl`.
8
+ - [x] Add baseline GitHub Actions CI (`.github/workflows/ci.yml`).
9
+ - [x] Validate end-to-end `prompt2gerber smoke` (`skidl` -> `.kicad_pcb` -> `kicad-cli` Gerbers + drill + SVG).
10
+
11
+ ## Step 2 — JSON Schemas, Component DB & `--init` Scaffolder ✅ Done
12
+ - [x] Define Pydantic models and JSON schemas (`netlist.json`, `constraints.json`, `manifest.json`) aligned with `../OBD2`.
13
+ - [x] Build searchable lazy-cached index of standard KiCad symbols and footprints (`prompt2gerber search`).
14
+ - [x] Seed `data/components/` from `../OBD2` datasheets (links + human-reviewed JSON) and bundle in wheel.
15
+ - [x] Implement `prompt2gerber --init <Project> --agent <Agent>` with packaged templates (`antigravity`, `claude`, `copilot`, `mistral`, `codex`, `cursor`, `windsurf`).
16
+ - [x] Implement deterministic component DB workflow (`components sync`, lazy `datasheet`, `validate`, `approve`) and scaffolded `datasheet-extract` agent skill (`--init`).
17
+
18
+ ## Step 3 — Pipeline 2: Schematic / Netlist → PCB → Gerber ✅ Done
19
+ - [x] Implement isolated `kicad/` adapter (geometry extraction, `.kicad_pcb` build/placement, DSN export, SES import, `kicad-cli pcb drc`, Gerber/Excellon + SVG export, stitching vias, clean silkscreen).
20
+ - [x] Port pure engines and unit tests from `../OBD2` (`emc_physics.py`, simulated annealing `annealer.py`, `dsn_patcher.py`, `dsn_metrics.py`, `stitcher.py`).
21
+ - [x] Validate end-to-end `prompt2gerber pcb build` with 0 DRC errors, SES metrology, and GND stitching vias.
22
+
23
+ ## Step 4 — Pipeline 1: `netlist.json` → Schematic & ERC ✅ Done
24
+ - [x] Implement `netlist.json` -> `.net` + `.kicad_sch` (SKiDL) compiler and `kicad-cli sch erc` (`prompt2gerber sch build`).
25
+ - [x] Add component-group validation rules (`group_rules.py`) and port analog sizing helper (`buck_compensation.py` / `prompt2gerber analog buck`).
26
+
27
+ ## Step 5 — LLM Integration & Automated Repair Loop ✅ Done
28
+ - [x] Implement agnostic LLM client (`OpenAICompatibleClient`) producing `netlist.json` from natural-language prompt + component catalog context.
29
+ - [x] Implement automated repair loop feeding Pydantic / group-rule / ERC errors back to LLM (`<= 3` retries) and syncing `board_hints` to `constraints.json`.
30
+
31
+ ## Step 6 — Full Orchestration, Multi-Agent Adapters & Quality Suite ✅ Done
32
+ - [x] Implement unified `prompt2gerber generate "..."` and `prompt2gerber build` commands (Prompt -> Pipeline 1 -> Pipeline 2 -> `build_report.json` / `build_report.md`).
33
+ - [x] Finalize multi-agent adapter templates (`agent_instructions.md.tmpl`), integration test suite (`test_step6_integration.py`), and GitHub Release workflow (`.github/workflows/release.yml`).
34
+
35
+ ## Manual Notes / Backlog
36
+ <!-- Add manual tasks and ideas below -->
37
+ - [ ] Optional GitHub PR contribution workflow for approved components (`prompt2gerber components contribute <file.json>` / `approve --pr` via `gh` CLI).
@@ -0,0 +1,28 @@
1
+ {
2
+ "mpn": "ESP32-S3-WROOM-1-N16R2",
3
+ "manufacturer": "Espressif Systems",
4
+ "role": "Dual-Core 240 MHz Wi-Fi / BLE 5.0 / Native USB / CAN (TWAI) SoC Module",
5
+ "package": "41-Pin SMD Module + Thermal EPAD (25.5 x 18.0 mm)",
6
+ "footprint": "RF_Module:ESP32-S3-WROOM-1",
7
+ "symbol": "RF_Module:ESP32-S3-WROOM-1",
8
+ "datasheet_url": "https://www.espressif.com/sites/default/files/documentation/esp32-s3-wroom-1_wroom-1u_datasheet_en.pdf",
9
+ "reviewed_by_human": true,
10
+ "ratings": {
11
+ "vdd_min_v": 3.0,
12
+ "vdd_typ_v": 3.3,
13
+ "vdd_max_v": 3.6,
14
+ "idd_peak_ma": 500,
15
+ "gpio_5v_tolerant": false
16
+ },
17
+ "schematic_guidelines": [
18
+ "Mandatory RC delay on EN (pin 3): 10 kOhm pull-up to 3.3V and 1 uF capacitor to GND (tau = 10 ms).",
19
+ "Local VDD decoupling: 10 uF bulk ceramic capacitor (>= 10V, X5R/X7R) + 100 nF high-frequency capacitor in parallel.",
20
+ "GPIO0 (pin 27) strapping: external 10 kOhm pull-up to 3.3V for normal SPI flash boot.",
21
+ "Native USB D+/D- (IO20/IO19): connect directly without external D+ pull-up."
22
+ ],
23
+ "pcb_guidelines": [
24
+ "15 mm all-layer keepout around the integrated meander PCB antenna; antenna must overhang or sit flush with board edge.",
25
+ "Thermal ground EPAD (pin 42): solder to GND plane with 9-16 thermal vias (0.3 mm drill).",
26
+ "Place EN RC reset circuit within 2 mm of pin 3."
27
+ ]
28
+ }