Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@
# Do not apply core.autocrlf or text normalization to the exact-source archive.
**/evidence/** -text
**/evidence/files/** -diff

# The packaged supplier baseline must match the canonical bytes on every OS.
templates/jlcpcb-2layer-1oz/jlcpcb-2layer-1oz.kicad_pro -text
templates/jlcpcb-2layer-1oz/jlcpcb-2layer-1oz.kicad_dru -text

# The media manifest identifies exact captured output bytes, including JSON.
docs/media/** -text

# The self-contained example carries byte-bound CAD/library/source receipts.
examples/gpio-indicator/** -text
49 changes: 49 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Software and package checks

on:
push:
pull_request:

permissions:
contents: read

jobs:
software:
name: Python software checks (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: '3.11'
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
enable-cache: true
- name: Install locked workspace and test dependencies
run: uv sync --locked
# This explicit suite covers software behavior with mocked native/supplier
# boundaries. It does not run ERC/DRC or qualify the checked-in boards.
- name: Software preservation, evidence, review gates and CLI
run: >-
uv run --locked pytest -q -m "not slow and not network"
tests/test_package_smoke.py tests/test_toolchain.py tests/test_doctor.py
tests/test_cli_encoding.py tests/test_demo.py tests/test_demo_change.py tests/test_project.py
tests/test_state.py tests/test_status_cli.py tests/test_update_guard.py
tests/test_transaction.py tests/test_cleanup.py tests/test_release.py
tests/test_stock.py tests/test_sch_io_multiline.py
tests/evidence/test_archive.py tests/evidence/test_index.py
tests/evidence/test_git_archive.py tests/evidence/test_checks.py
tests/review/test_signoff.py tests/review/test_registry.py
tests/schematic/test_intent.py tests/layout/test_layout_intent.py
tests/layout/test_official_footprint_provenance.py
- name: Build both wheels and verify clean external installation
run: uv run --locked python tools/check_package.py
- name: Landing-page links and captured media identities
run: uv run --locked python tools/check_readme.py
209 changes: 149 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,160 @@
# PCB Copilot

One KiCad workspace and one CLI: **read the saved design → prepare a scoped
candidate → check it → review it → apply → release when approved**.
The current native CAD is authoritative. Generators and old snapshots do not
replace owner edits. Start with the [working workflow](docs/WORKFLOW.md).
**AI-assisted PCB engineering. Native KiCad. Evidence you can inspect.**

## Open a board
![PCB Copilot beside a native 3D render of the Rover power distribution board](docs/media/hero.png)

| Project | Role | Open in KiCad |
| --- | --- | --- |
| [Rover PDB](projects/rover-pdb/README.md) | Completed owner work; sole retained Rover board | [Project](projects/rover-pdb/rover-pdb.kicad_pro) |
| [TMS A2](projects/tms/README.md) | Installed schematic and component verification; PCB and qualification pending | [Project](projects/tms/tms.kicad_pro) |
Prepare scoped changes to real KiCad projects, check the candidate, inspect the
results, and apply it explicitly. Keep source evidence and engineering decisions
with the design, through to a gated manufacturing package.

**[Get started](docs/QUICKSTART.md)** · **[Watch the walkthrough](docs/media/workflow.mp4)** ·
**[Read the workflow](docs/WORKFLOW.md)** · **[See the roadmap](docs/ROADMAP.md)**

TMS was recreated from [recorded decisions and exact research](design-bases/tms/README.md).
Its [component guide](projects/tms/docs/design/COMPONENT_VERIFICATION.md) explains
all 120 parts and remaining qualifications. Retired TMS CAD is a frozen regression
input under `tests/fixtures/boards/tms-v3`, never an active project.
## See what it actually does

CAD checks are scoped checks, not fabrication approval. Each project's
requirements, design basis, deviations and review profile state what remains.
The owner retired the sensor projects and Rover comparison on 2026-10-07.
Recovery archives and the cleanup boundary are recorded in
[Architecture](docs/ARCHITECTURE.md#cleanup-and-retention).
[![Animated walkthrough: native CAD, evidence verification, a rejected apply without a preview, and a blocked review](docs/media/workflow.gif)](docs/media/workflow.mp4)

## Daily commands
*16-second animated walkthrough of recorded CLI results and native CAD renders.
This is a guided tour, not a screen recording or a successful-edit demonstration.
The full Rover run reported 12/14 checks passing; datasheet coverage and unsigned
human decisions blocked release. [Recorded results](docs/media/demo-results.json)
and [source/output hashes](docs/media/manifest.json) make the scope inspectable.*

Install Python 3.11+, uv and KiCad 10, then run `uv sync` once.
Replace `PROJECT` with a project folder such as `projects/rover-pdb`.
## Why this pipeline

| Intent | Command |
| What you need | What PCB Copilot does |
| --- | --- |
| See saved state | `uv run pcb-copilot status PROJECT` |
| Verify archived sources | `uv run pcb-copilot research PROJECT --verify` |
| Inspect exact supplier identity | `uv run pcb-copilot parts PROJECT --lookup C6890985` |
| Preview an edited native schematic hierarchy | `uv run pcb-copilot update-schematic PROJECT --candidate C:/work/rover-pdb.kicad_sch` |
| Preview an edited native PCB | `uv run pcb-copilot update-layout PROJECT --candidate C:/work/rover-pdb.kicad_pcb` |
| Run current review | `uv run pcb-copilot review PROJECT` |
| Create an unsigned human review worksheet | `uv run pcb-copilot prepare-signoff PROJECT` |
| Check and export an approved package | `uv run pcb-copilot release PROJECT` |
| Preview removal of reproducible preview files | `uv run pcb-copilot clean PROJECT` |

Save and close KiCad before external application. Inspect the preview, then
repeat the identical update command with `--apply`. Any intervening saved edit
requires a fresh preview. Intent-driven generation and optional autorouting are
advanced creation paths described in the workflow; use native candidates for
ordinary maintenance of an owner-edited board.

## Where to look, from the surface down

| Level | Location | What belongs there |
| Keep an existing engineer-edited design | Start from saved native CAD. Scoped candidates preserve the rest of the design; old generation recipes do not override owner edits. |
| Know where a part or decision came from | Archive exact source bytes and provenance; verify selected part identities and local footprint receipts. |
| Inspect a change before installing it | Preview candidates with connectivity, geometry and native-tool checks. Apply must match the current successful preview. |
| Keep approval tied to the current revision | Bind human decisions to CAD, requirements, rules and evidence. Changed inputs invalidate old decisions. |
| Publish a complete fabrication package | Rerun review and export Gerbers, drills, BOM, positions and provenance together; preserve the previous package if publication fails. |

```text
Saved KiCad + source evidence
↓
Scoped candidate
↓
Checks + rendered inspection
↓
Explicit apply
↓
Current human decisions → gated release
```

## Try it on a real board

Use **Python 3.11+**, [uv](https://docs.astral.sh/uv/getting-started/installation/)
and **KiCad 10**. Native review also needs a Python runtime that can import
KiCad's `pcbnew`; [setup and troubleshooting](docs/QUICKSTART.md) explain discovery.

```sh
git clone https://github.com/devkyber/PCB.git
cd PCB
uv sync
uv run pcb-copilot doctor
uv run pcb-copilot status projects/rover-pdb
uv run python tools/demo.py
```

The quick demo copies declared Rover inputs to a new temporary directory, runs
status and archive verification, and exercises the actual missing-preview guard.
It prints the path to a Markdown report, machine-readable transcript and exact
command logs. The source board stays untouched. **It does not run native ERC/DRC.**

Add `--full` to run the registered native review checks on that disposable copy:

```sh
uv run python tools/demo.py --full
```

A blocked review returns exit code **1**, with its findings preserved. This is
expected when evidence or current human decisions are incomplete. Demo completion
and a clean individual check do not grant fabrication approval.

## Start with a small, complete example

[![A native KiCad turntable of the four-channel GPIO indicator example](docs/media/gpio-turntable.gif)](docs/media/gpio-turntable.mp4)

The [GPIO indicator](examples/gpio-indicator/README.md) is a new **45 × 35 mm,
two-layer educational board** with four independent 3.3 V LED channels. It has
one readable sheet, routed copper, project-local libraries, archived manufacturer
sources and a [native 3D model](examples/gpio-indicator/output/gpio-indicator.glb).
It is an **unbuilt DRAFT**; physical fit and bench behavior remain unqualified.

The scoped-change demo runs a real **successful preview → stale-apply rejection →
fresh preview → reviewed apply** in an external copy. Only a title-block revision
changes; native electrical inventories and PCB bytes are compared.

```sh
uv run python tools/demo_change.py
```

It stops at the fresh preview and prints the rendered PDF and exact hash. Inspect
every page, then use the printed resume command to apply that exact candidate to
the disposable copy. This author inspection is separate from owner fabrication
sign-off. [Recorded proof](docs/media/change-proof.md) shows a completed run.

## Inspect the native design

![Fresh native KiCad exports: a Rover schematic sheet and the PCB top copper and silkscreen](docs/media/native-cad.png)

The design remains an editable schematic hierarchy and PCB. The images above are
native exports, and the hero uses a **3D render**. Physical fit, thermal performance
and bench qualification remain separate engineering work.

| Example | What to inspect | Current scope |
| --- | --- | --- |
| L0: operate | This README; project README | Entry points and current deliverables |
| L1: understand | [Workflow](docs/WORKFLOW.md), [Architecture](docs/ARCHITECTURE.md) | Commands, internal stages, file ownership and cleanup |
| L2: design | `projects/BOARD/` | Native CAD, declared inputs, local libraries and exact source evidence |
| New project inputs | `templates/project/`; `templates/jlcpcb-2layer-1oz/` | Requirement/profile/intent skeleton and the dated native geometry baseline |
| L3: inspect implementation | `src/pcb_copilot`, `packages/kicad-claude-mcp` | CLI stages and the small CAD adapter dependency |
| L4: verify behavior | `tests`, adapter tests | Connectivity, geometry, source, update, cleanup and export regressions; frozen board inputs live only in `tests/fixtures/boards` |
| Generated work | `.pcb-copilot/`; `fabrication/` | Reproducible previews/state; gated manufacturing packages |

Read [Design rules](docs/DESIGN_RULES.md) for engineering/drawing conventions and
[Limitations](docs/LIMITATIONS.md) for what machine checks cannot establish.
The [Rover audit](projects/rover-pdb/docs/review/PIPELINE_AUDIT.md) is the
concrete worked example. Its archived construction code is not a second pipeline.
The [shared lessons and enforcement map](docs/ARCHITECTURE.md#rover-lessons-used-by-the-shared-pipeline)
apply to every board. Release always requires the shared schematic-readability
and layout-handover decisions as well as the project's own review items.

Run `uv run pytest -q` for the full suite. `-m "not slow and not network"` skips
marked integrations; some current-project tests still invoke KiCad. `.git` is
history and `.venv` is the installed environment, not clutter to delete routinely.
| [GPIO indicator](examples/gpio-indicator/README.md) | [Native project](examples/gpio-indicator/gpio-indicator.kicad_pro), [schematic](examples/gpio-indicator/output/schematic.pdf), [review](examples/gpio-indicator/docs/review/A1_REVIEW.md) | Small routed educational example. Native checks pass; assembly qualification and human release decisions remain open. |
| [Rover PDB](projects/rover-pdb/README.md) | [Native project](projects/rover-pdb/rover-pdb.kicad_pro), [schematic](projects/rover-pdb/rover-pdb.kicad_sch), [PCB](projects/rover-pdb/rover-pdb.kicad_pcb), [pipeline audit](projects/rover-pdb/docs/review/PIPELINE_AUDIT.md) | Owner-edited, routed two-layer power board. Development is closed; engineering qualification and fabrication approval remain separate. |
| [TMS](projects/tms/README.md) | [Native project](projects/tms/tms.kicad_pro), [source evidence](projects/tms/evidence/index.yaml), [design basis](projects/tms/DESIGN_BASIS.md) | Recreated schematic; PCB and qualification pending. Its project README is the revision/status authority. |

## What works today

| Capability | Status and boundary |
| --- | --- |
| Native schematic and PCB candidates | Implemented: checked preview/apply, parity and stale-input protection. Visual inspection remains required. |
| Evidence and exact supplier-part lookup/import | Implemented: archived bytes, provenance, C-number/MPN identity. Coverage does not prove interpretation or suitability. |
| Current review and transactional release | Implemented: fourteen registered checks plus current named human decisions. Each check reports its own scope. |
| Toolchain diagnostics and disposable demo | Implemented: `doctor`, recorded command results and input-preservation hashes. |
| Intent-based schematic/placement generation | Available as a proposal/redraw path. It does not merge later manual CAD edits or establish engineering correctness. |
| Optional autorouting | Requires Freerouting and compatible Java. A route remains a candidate for review. |
| Agent integration | Agents can operate the CLI. A packaged interactive copilot/MCP service is future work. |
| Autonomous engineering and measured time savings | Unproven. See [limitations](docs/LIMITATIONS.md) and the [evaluation roadmap](docs/ROADMAP.md). |

The geometric house-rule checker covers portions of **4 of 42** historical rule
sections. ERC, DRC, archive verification and parity are useful scoped checks;
they cannot decide every circuit choice, return path, RF, thermal, mechanical or
failure-mode question.

## Bring your KiCad project

Start with [the new-board workflow](docs/WORKFLOW.md#start-a-new-board) and
`templates/project/`. Declare the saved CAD, requirements, evidence and review
profile. Use [the native JLCPCB geometry template](templates/jlcpcb-2layer-1oz/meta/info.html)
when its dated process assumptions fit your board.

For an existing design, save and close KiCad before external application, prepare
a separate native candidate, and preview before using the identical command with
`--apply`. The [complete workflow](docs/WORKFLOW.md) covers hierarchy, layout,
supplier assembly checks, sign-off and interrupted-operation recovery.

## Go deeper

| Read | For |
| --- | --- |
| [Quickstart](docs/QUICKSTART.md) | Setup, first useful result and troubleshooting |
| [Workflow](docs/WORKFLOW.md) | Supported commands and the preview/apply/release lifecycle |
| [Architecture](docs/ARCHITECTURE.md) | Implementation boundaries, ownership and retention |
| [Design rules](docs/DESIGN_RULES.md) | Schematic readability, physical layout and review conventions |
| [Limitations](docs/LIMITATIONS.md) | What checks establish and what needs engineering judgment |
| [Roadmap](docs/ROADMAP.md) | Next capabilities and the evidence needed to claim them |
| [Media sources](docs/media/README.md) | Reproduce the images and video; inspect captured results |

The shared CLI lives in `src/pcb_copilot`. The retained KiCad adapter lives in
`packages/kicad-claude-mcp`; its historical name does not imply a running MCP
server. Frozen boards under `tests/fixtures/boards` are regression inputs, never
active projects to develop or restore.

If the workflow is useful to you, a star helps other engineers discover it.
Loading
Loading