# chip-fetcher

Download manufacturer-grade chip CAD bundles (STEP + KiCad symbol + KiCad footprint + Altium IntLib + Fusion .lbr + datasheet) into a structured library by driving Chrome via pup on the user's desktop.

## What's new in 1.2.23

- **`chip-fetcher done`** — 9-level completeness ladder per chip (PDF → STEP → KiCad → Altium → Fusion → Thumbnails → Validated → Stock → Provenance)
- **Two-layer provenance** — every fetched file records `discovery_source` (where found) + `content_origin` (who made it)
- **ds2sf + concur integration** — autonomous validation loop: extract symbol/footprint from datasheet, cross-validate against KiCad/Altium/EAGLE sources, auto-refetch on divergence
- **Interactive dashboard** with card zoom (animated), auto-zoom, validation badges, orientation picker, action buttons, per-element tooltips, live-updating status
- **`chip-fetcher scrape`** — CLI wrapper for pup browser automation with hardcoded profile enforcement
- **`chip-fetcher creds`** — credential vault (list/save/delete) persisted in adom-desktop
- **`chip-fetcher pup-pdf-fetch`** — fetch PDFs through authenticated pup sessions when direct curl fails
- **`chip-fetcher pdf-check`** — sweep all PDFs for HTML masquerade, auto-repair with `--repair`
- **Programmatic rule enforcement** — `sources`, `gate`, `mfr-probe`, `next-source`, `done`, `hint` subcommands with HINT lines
- **DigiKey models playbook** — documented `/en/models/<id>` page with Manufacturer Provided STEP + UL + SnapMagic accordions

## Sourcing ladder (enforced by `chip-fetcher sources`)

1. Manufacturer's own site (ti.com, nordicsemi.com, nxp.com, st.com, etc.)
2. SnapEDA / SnapMagic (snapeda.com)
3. Mouser (`adom-mouser search`)
4. DigiKey (`adom-digikey search`)
5. Arrow (arrow.com)
6. CSE / UL — only when mfr links there
7. LCSC — last resort, avoid

## Install

```
curl -fsSL https://wiki-ufypy5dpx93o.adom.cloud/static/apps/chip-fetcher/chip-fetcher -o /usr/local/bin/chip-fetcher && chmod +x /usr/local/bin/chip-fetcher && chip-fetcher install
```

## Key commands

| Command | What it does |
|---|---|
| `chip-fetcher fetch <MPN>` | Start fetching a chip's full CAD bundle |
| `chip-fetcher done [--mpn X]` | Show 9-level completeness per chip |
| `chip-fetcher sources` | Print the sourcing ladder |
| `chip-fetcher gate [--strict]` | Exit non-zero if any chip missing essentials |
| `chip-fetcher mfr-probe <MPN>` | Check manufacturer's site for CAD/datasheet |
| `chip-fetcher next-source <MPN>` | Print next untried source in the ladder |
| `chip-fetcher validate <MPN>` | Run ds2sf + concur validation loop |
| `chip-fetcher import <file> --mpn X` | Import a file with two-layer provenance |
| `chip-fetcher scrape open/nav/eval/shot` | Drive pup browser for scraping |
| `chip-fetcher pup-pdf-fetch <MPN> <URL>` | Fetch PDF through authenticated pup session |
| `chip-fetcher pdf-check [--repair]` | Sweep for HTML-masquerading-as-PDF |
| `chip-fetcher creds list/save/delete` | Manage vendor credentials |
| `chip-fetcher heartbeat <MPN> <stage>` | Update dashboard + auto-scroll + HINTs |
| `chip-fetcher serve` | Launch the interactive dashboard |
| `chip-fetcher selfcheck` | Verify all dependencies are installed |

## Requirements

- `adom-desktop` v1.6.3+ (for pup browser automation + Page.setDownloadBehavior)
- `adom-mouser` (for stock/pricing queries)
- `adom-digikey` (for DigiKey search)
- `ds2sf` v0.5.2+ (for datasheet extraction)
- `concur` v0.8.0+ (for cross-source validation)
- `chip-thumbnailer` v0.5.1+ (for thumbnail generation)
