Metadata-Version: 2.5
Name: prompt2gerber
Version: 0.1.5
Summary: CLI-first Python toolchain and AI-agent scaffolder turning prompts into KiCad PCB Gerbers
Project-URL: Homepage, https://github.com/nitrogene/prompt2gerber
Project-URL: Repository, https://github.com/nitrogene/prompt2gerber
Project-URL: Issues, https://github.com/nitrogene/prompt2gerber/issues
Project-URL: Changelog, https://github.com/nitrogene/prompt2gerber/blob/master/CHANGELOG.md
Author: nitrogene
License: # Project Licenses
        
        This project is licensed under a dual open-source framework tailored for open-source hardware (OSHW) and software/tooling.
        
        ---
        
        ## 1. Hardware License (Schematics, PCB Layouts, Manufacturing Files, 3D CAD)
        
        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)**.
        
        ### CERN Open Hardware Licence Version 2 – Permissive
        
        Copyright (c) 2026 prompt2gerber Contributors
        
        Preamble
        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.
        
        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.
        
        Full license text: https://ohwr.org/cern_ohl_p_v2.txt
        
        ---
        
        ## 2. Software & Tooling License (CLI, Engines, Adapters, Python Scripts)
        
        All software, templates, test scripts, and automation code within this repository are licensed under the **Apache License, Version 2.0**.
        
        ```
        Copyright (c) 2026 prompt2gerber Contributors
        
        Licensed under the Apache License, Version 2.0 (the "License");
        you may not use this file except in compliance with the License.
        You may obtain a copy of the License at
        
            http://www.apache.org/licenses/LICENSE-2.0
        
        Unless required by applicable law or agreed to in writing, software
        distributed under the License is distributed on an "AS IS" BASIS,
        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        See the License for the specific language governing permissions and
        limitations under the License.
        ```
License-File: LICENSE
Keywords: ai-agents,cli,eda,freerouting,gerber,kicad,pcb
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
Requires-Python: >=3.11
Requires-Dist: platformdirs>=4.0.0
Requires-Dist: pydantic>=2.6.0
Requires-Dist: skidl>=2.0.0
Requires-Dist: typer>=0.12.0
Description-Content-Type: text/markdown

# prompt2gerber

[![Python](https://img.shields.io/badge/Python-3.11+-3776AB?style=for-the-badge&logo=python&logoColor=white)](https://www.python.org/)
[![uv](https://img.shields.io/badge/Packaging-uv%20tool-DE5FE9?style=for-the-badge&logo=astral&logoColor=white)](https://docs.astral.sh/uv/)
[![EDA: KiCad Headless](https://img.shields.io/badge/EDA-KiCad%20Headless-314CB0?style=for-the-badge&logo=kicad&logoColor=white)](https://www.kicad.org/)
[![Router: Freerouting](https://img.shields.io/badge/Router-Freerouting%20CLI-0E7C7B?style=for-the-badge)](https://freerouting.org/)
[![Validation: Pydantic](https://img.shields.io/badge/Schema-Pydantic-E92063?style=for-the-badge&logo=pydantic&logoColor=white)](https://docs.pydantic.dev/)
[![AI Agents](https://img.shields.io/badge/Workflow-AI%20Agents-10A37F?style=for-the-badge)](./AGENTS.md)
[![Status: Planning](https://img.shields.io/badge/Status-Planning-F59E0B?style=for-the-badge)](./ROADMAP.md)
[![License](https://img.shields.io/badge/License-Apache%202.0%20%2F%20CERN--OHL--P%20v2-blue?style=for-the-badge)](./LICENSE)

`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).

## Installation & Usage (Planned)

```bash
# Install globally as an isolated CLI tool
uv tool install prompt2gerber

# Or in editable mode during development
uv tool install --editable .

# Verify local environment (kicad-cli, KiCad libraries, Freerouting/JRE)
prompt2gerber doctor

# Scaffold a new standalone PCB project tailored for an AI agent
prompt2gerber --init NewPCB --agent antigravity
```

## Platform Support & Prerequisites

* **Target Platforms:** **Windows, macOS, and Linux** — currently **only Windows is operational and verified**; macOS and Linux support (KiCad discovery, portable JRE/router paths, and CI validation) is planned.
* **KiCad (`kicad-cli` + standard libraries):** Not bundled inside the Python wheel; install locally (on Windows: `winget install KiCad.KiCad`).
* **Freerouting & JRE:** Managed automatically by `prompt2gerber` (cached portable runtime).
* Run `prompt2gerber doctor` to validate that all external tools are detected.

## Architecture Overview

`prompt2gerber` separates the reusable CLI toolchain from the generated PCB workspaces:

1. **Project Scaffolder (`--init <Project> --agent <Agent>`):**
   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).
2. **Two Decoupled CLI Pipelines:**

```text
User Prompt
   │
   ▼
[ LLM ] ──► netlist.json (BOM, semantics, power rails, functional blocks, explicit pin-to-pin nets)
               │
               ▼
   Pipeline 1: netlist.json ──► KiCad Schematic (.kicad_sch) + ERC
               │                 (skidl / ato validation + analog sizing helpers like buck-compensation)
               ▼
   Pipeline 2: Schematic + constraints.json / manifest.json
               ──► KiCad PCB (.kicad_pcb)
               ──► EMC Simulated Annealing Placer + Freerouting CLI + DSN Metrology + Stitching
               ──► Gerber / Excellon + DRC + SVG/PNG
```

### Key Design Principles

* **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.
* **Proven JSON Contracts (Evolved from `OBD2`):**
  * `netlist.json` builds on `bom.schema.json` + `semantics.schema.json` (designators, MPN/LCSC, `power_rails`, `functional_blocks`) and adds explicit `nets` connectivity.
  * 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`.
* **Reusable Algorithmic Engines + KiCad CLI Adapter:**
  * 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.
  * 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.
* **Component Library Strategy:**
  * Standard KiCad libraries for common/simple parts.
  * 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.
* **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.

## Repository Layout

```text
prompt2gerber/
├── pyproject.toml
├── AGENTS.md
├── README.md
├── ROADMAP.md
├── src/prompt2gerber/
│   ├── cli.py                   # Typer CLI entry point (--init, pipeline commands)
│   ├── schemas/                 # Pydantic models & JSON schemas (netlist, constraints, manifest)
│   ├── engines/                 # Pure algorithmic engines ported from OBD2 (placer, emc, dsn, stitcher, dfm)
│   ├── kicad/                   # Isolated KiCad CLI / file adapter (replaces EasyEDA bridge)
│   └── templates/               # Packaged PCB workspace & agent templates (--init --agent)
├── data/components/             # Human-reviewed JSON database of complex components
└── tests/                       # Unit and integration tests
```

## Prompt Examples

See [docs/prompt-examples.md](docs/prompt-examples.md) for concise, intent-first prompt examples that produce clean `netlist.json` and `constraints.json` contracts.

## Project Status

Planning / Early setup. See [ROADMAP.md](ROADMAP.md) for the step-by-step implementation plan.

## License

Dual-licensed under **Apache License 2.0** (software and tooling) and **CERN-OHL-P v2** (hardware designs). See [LICENSE](LICENSE) for full details.
