# adom-lbr

EAGLE .lbr generator, linter, validator, and KiCad converter. Converts between KiCad `.kicad_sym` and EAGLE `.lbr` formats so both Fusion 360 and KiCad users can share component libraries.

![adom-lbr lint output](docs/screenshot-lint.png)

## Demo video

https://wiki-ufypy5dpx93o.adom.cloud/static/apps/adom-lbr/eda-tools-tour-v4.webm

82-second narrated tour: lint a broken .lbr (catches errors), generate a valid one, then deliver symbols and footprints to KiCad 10 and Fusion 360.

## Why this exists

Fusion 360 Electronics shows "No Components" when an `.lbr` file has an empty `<packages>` section or empty `<connects/>`. The old JS generator produced these broken files. adom-lbr generates a **complete** deviceset: symbol + placeholder SMD package + full pin-to-pad connect mappings.

KiCad users can import any `.lbr` back to `.kicad_sym` with `adom-lbr import`, validated via kicad-cli.

## Install

```
adompkg install adom-lbr
```

## Quick start

```bash
# Fusion user: KiCad symbol to EAGLE .lbr
adom-lbr generate --sym RP2040.kicad_sym -o RP2040.lbr

# KiCad user: EAGLE .lbr to KiCad symbol
adom-lbr import RP2040.lbr -o RP2040.kicad_sym
adom-lbr check RP2040.kicad_sym

# Lint any .lbr for Fusion compatibility
adom-lbr lint suspicious.lbr
```

## Screenshots

### RP2040 in Fusion 360 Electronics

The generated `.lbr` opens in Fusion with all 57 pins, complete deviceset, and the symbol rendering correctly. The device table shows the package and connect mappings that make Fusion recognize the component.

### Linting the old broken .lbr

The linter catches the exact bugs that cause Fusion to show "No Components":

```json
{
  "passed": false,
  "errors": [
    {"code": "empty-packages", "message": "Packages section is empty"},
    {"code": "empty-connects", "message": "Device has no pin-to-pad connect mappings"},
    {"code": "device-no-package", "message": "Device has no package attribute"}
  ]
}
```

### Round-trip into KiCad 10

The same `.lbr` imported back to `.kicad_sym`, validated by kicad-cli, and installed as a KiCad 10 symbol library. Renders with all pins, body rectangle, and description.

## Dependencies

| Dependency | Required? | Why |
|---|---|---|
| None (runtime) | -- | Standalone Rust binary with no runtime dependencies |
| kicad-cli | Optional | Used by `check` command to validate `.kicad_sym` output via headless SVG export |
| adom-desktop | Optional | Used by adom-symbol's "Send to" button to deliver `.lbr` files to Fusion 360 on the user's desktop |

**Upstream**: adom-symbol creates the `.kicad_sym` input. chip-fetcher downloads `.lbr` files from manufacturer sites.

**Downstream**: generated `.lbr` opens directly in Fusion 360 Electronics. Imported `.kicad_sym` installs into KiCad via `kicad_install_library`.

## Features

- Bidirectional conversion: `.kicad_sym` to `.lbr` and `.lbr` to `.kicad_sym`
- Generates complete EAGLE `.lbr` with symbol + placeholder SMD package + connect mappings
- Handles duplicate pin names (IOVDD x6, DVDD x2) with EAGLE `@N` suffix convention
- 7-check linter: empty-packages, empty-connects, device-no-package, duplicate-pin-name, connect-pad-missing, malformed-xml, no-symbol-layer
- JSON lint output for programmatic use
- `check` validates `.kicad_sym` via headless kicad-cli
- Shell completions (bash/zsh/fish)

## Talk to the AI

**Generate:**
- "Generate an lbr from RP2040.kicad_sym"
- "Convert this KiCad symbol to EAGLE format"
- "Make a Fusion 360 library from this symbol"

**Import:**
- "Import this .lbr to KiCad format"
- "Convert EAGLE library to .kicad_sym"

**Lint:**
- "Lint this .lbr file"
- "Check if this library will work in Fusion"
- "Why does Fusion show No Components?"

## Skills

| Skill | Purpose |
|---|---|
| adom-lbr | Generate, import, lint, validate, check EAGLE .lbr / KiCad .kicad_sym files |

## CLI reference

| Command | Description |
|---|---|
| `generate --sym <file> [-o out] [--fp <file>] [--name <name>]` | KiCad `.kicad_sym` to EAGLE `.lbr` |
| `import <file> [-o out]` | EAGLE `.lbr` to KiCad `.kicad_sym` |
| `lint <file>` | Lint `.lbr`, output JSON with error codes |
| `validate <file>` | Validate `.lbr`, human-readable output |
| `check <file>` | Validate `.kicad_sym` via kicad-cli SVG export |
| `health` | Print version |
| `install` | Install Claude Code skill + shell completions |
| `completions <shell>` | Generate bash/zsh/fish completions |
