# adom-circuit (`aci`)

**AI-first EDA.** KiCad-native. Babylon-rendered. Mouser-sourced. Renderer-owned.

Build a PCB by prompting an AI, watch every step stream into a Hydrogen webview — BOM resolution → library construction → schematic → 3D board → autoroute → DRC → final GLB. Rust owns parse + geometry + compute; Babylon 8.x owns the 3D scene; they talk scene-IR JSON over WebSocket. `GLTF2Export` produces the final file from the live scene — **what the user watches being built is what ships**.

**Repo:** [adom-inc/adom-circuit](https://github.com/adom-inc/adom-circuit) (private)
**Binary name:** `aci`

## What the tool does

- **`aci build <prompt>`** — kicks off a BOM → datasheet → Mouser → library → schematic → 3D board pipeline. Spawns parallel sub-agents (one per component); LibView populates live; autoroute streams into a `routing-preview` scene node at 30 fps.
- **`aci dev`** — opens the Hydrogen webview with full chrome: Status Bar, Library Rail, Component HUD (refdes / footprint / nets / Mouser PN / price / stock), Timeline Strip, Global Footer with VS Code jump buttons.
- **`aci parity`** — cross-checks aci-drc / aci-erc / aci-svg against the `kicad-cli` oracle (via service-kicad or local install). Baseline gate before a release.
- **`aci doctor`** — health-checks every dep (service-kicad CLI → local kicad-cli → service-aci) before a build. Prints what's missing + what URL aci would hit.
- **`aci review <pcb>`** — quick DRC + ERC fidelity report without spinning up the viewer.
- **`aci test --visual --bless`** — pixel-diff visual regression harness with ralph-loop screenshots into the shotlog.
- **`aci share`** / **`aci clone`** — publish a complete project bundle to the Adom Wiki / pull someone else's project and open it locally.

## Native pipeline (no shell-outs in the hot path)

| Stage | Crate | What |
|---|---|---|
| KiCad s-expr parse + emit | `aci-sexpr` | Byte-identical round-trip on 99.6% of the corpus (461/463 files) |
| Typed schema + markdown bridge | `aci-kicad` | Shells to Noah's [kicad-to-markdown](https://wiki-ufypy5dpx93o.adom.cloud/skills/kicad-to-markdown) for LLM-facing view |
| Scene IR compute (outline / copper / vias / pads / paste) | `aci-render` | Feeds the Babylon scene via WebSocket patches |
| DRC | `aci-drc` | 8 rules r-tree-indexed; visualized as red overlays in the scene |
| ERC | `aci-erc` | Sheet + unit-aware; duplicates + unconnected + conflicts |
| Gerber emit | `aci-gerber` | RS-274X; parity-tested against kicad-cli on 20× draw-count |
| SVG emit | `aci-svg` | Schematic SVG; PCB top-view is an orthographic projection of the 3D scene |
| Autorouter | `aci-route` | A\* grid, rayon-parallelized; routes the reference PCB in 22 s |
| Supplier resolver | `aci-source` | Mouser → DigiKey → JLCPCB; datasheet-validated candidates only |
| Datasheet parser wrapper | `aci-datasheet` | Parallel pup-window fan-out; visualizer on port 8851 |
| Wiki publish | `aci-wiki` | `wiki.cache_hit` / `wiki.published` events on sym / fp / 3D deliver |

## Ecosystem dependencies (what aci reaches out to)

| Dependency | What | Install |
|---|---|---|
| [service-kicad](/apps/service-kicad) | kicad-cli operations + 4.7 GB of vetted KiCad library assets | Tier B auto-install on first trigger |
| [adom-mouser](/apps/adom-mouser) / [adom-digikey](/apps/adom-digikey) / [adom-jlcpcb](/apps/adom-jlcpcb) / [adom-parts-search](/apps/adom-parts-search) | Supplier pricing + stock + PN resolution | Tier A via gallia/install.mjs |
| adom-desktop (pup) | Multi-Chrome-session browser driving for ralph loops + the datasheet visualizer | Tier A |
| gallia/viewer | Absorbed Babylon 8.52 scene builders — symbol / footprint / gerber viewers, solder-jet-sizer, LibView | Tier A |

`aci doctor` surfaces any of these that aren't reachable from the current container, with a paste-into-Claude install prompt for each.

## First-class scene features (what makes the GLB different)

- **Named scene tree** — every node addressable by path: `board/components/U1/body`, `board/components/U1/pad/7`, `board/layers/F.Cu/trace[17]`, `board/paste/U1/pad_1/dot[3]`. Survives export as glTF `extras`.
- **Solder-jet paste deposition** — 13,627 paste dots at 250 µm planned + animated in the `squirt` AnimationGroup. Baked into the GLB.
- **Probing workcell simulation** — 100 mm GND-umbilical cover + greedy set-cover over test points. `probe.*` events stream during the simulation.
- **InstaPCB 26-step manufacturing sim** — pre-clad FR4 → lasered vias → electroplating → trace ablation → mask press → silk etch → depanel. Transient meshes (plating bath, vacuum press, silk ribbon, depanel groove) stripped from `board.glb`, kept in `full-scene.glb`.
- **Three export tiers** — `board.glb` (scene filtered to `exportClass=board`), `full-scene.glb` (everything including workcell + diagnostics + process), full project bundle (`scene-ir.json` + `build-log.ndjson` + source).

## Install (Tier B)

On a fresh Adom container, say "build me a board" or "run DRC via aci" — Claude's wiki-discover skill will surface this page and offer to run the install_hint. Manual:

```bash
curl -fsSL https://wiki-ufypy5dpx93o.adom.cloud/static/apps/adom-circuit/aci -o /tmp/aci \
  && chmod +x /tmp/aci \
  && sudo install -m 0755 /tmp/aci /usr/local/bin/aci \
  && aci install \
  && aci doctor
```

`aci doctor` prints the current dep status — any missing service suggests its own install_hint.

## Why Tier B (not Tier A)

Every external publisher to the Adom Wiki can only use Tier B — they can't edit `gallia/install.mjs`. If we publish our own flagship tool as Tier A, we never feel the friction external publishers are stuck with, and the Tier B path quietly rots. So we eat our own dog food. See [adom-app-model §7](https://github.com/adom-inc/gallia/blob/main/skills/adom-app-model/SKILL.md) for the full doctrine.

## Current status

- 97% of [PLAN.md](https://github.com/adom-inc/adom-circuit/blob/main/PLAN.md) shipped — every Part 27 Critical + High + Medium + Low resolved.
- 147+ commits, 87/87 tests green, 16 Rust crates, 2 TS packages.
- Phase 4 end-to-end proven (176 WebSocket events → Babylon scene → GLB round-trip).
- Phase 15 worked-example (`scripts/phase-15-worked-example.sh`) green on a blank project.
- Partial gates: Phase 8 SVG pixel-compare (structural tag parity done, resvg pixel-compare deferred), Phase 9 JLCPCB gerber submission (20× draw-count parity done, external fab submission is not automatable), Phase 10e WebGPU compute-shader autorouter (feature-gated scaffold).
