Library Megamaid Extraction Design

Purpose

Library megamaid extraction turns a KiCad project into inspectable local libraries, extracted 3D models, and JSON metadata for downstream library import.

This design exists because project-local KiCad assets and HTTP library placement metadata are useful during design, but canonical library promotion needs a cleaner split: bare reusable symbols and footprints, metadata preserved in JSON, model payloads that do not depend on external KiCad install paths, and stable linkage between placed instances, symbols, footprints, and part-record candidate metadata.

Boundary

kicad_monkey is responsible for low-level KiCad file operations: scanning project assets, classifying symbol and footprint sources, classifying model references, extracting symbols and footprints, stripping metadata by policy, repairing standalone footprint embedded model payloads, writing folder-based symbol libraries and .pretty libraries, and emitting scan and extraction diagnostics.

kicad_cruncher is responsible for workflow commands that assemble those operations into cleaned megamaid ingestion bundles and metadata-preserving project-lib bundles. Downstream library tooling is responsible for part-record creation and update behavior.

Public API Candidates

The first kicad_monkey implementation should promote small, testable helpers before exposing a large workflow object:

These APIs should return structured diagnostics rather than only writing files.

Extraction Modes

Internal Mode

Project-Local Mode

Model Handling

The model scanner must classify:

When an extracted standalone footprint references kicad-embed://name.step, the matching embedded payload must be present inside the .kicad_mod. If the payload only exists at board level, extraction must rehydrate the footprint from the board embedded-file map.

Extracted STEP/STP files should be deduped by content hash.

Project health scans use the active project board/schematic pair plus local symbol and footprint libraries listed in the project library tables. They intentionally ignore unrelated recursive KiCad files under the project directory that are not part of those local library tables. Standalone footprint-library health checks use a model-only S-expression projection path instead of hydrating full footprint objects.

JSON Output

The workflow JSON should preserve enough data for downstream library import:

kicad_cruncher should not create part records directly.

Fixture

The primary real-world fixture is:

tests/corpus/.unpacked/kicad/projects/4-ch-backplane

The preferred project file is:

input/4-ch-backplane.kicad_pro

The fixture should cover:

Test Requirements

Parser-Level Tests

KiCad CLI Validation Tests

Rack Ownership

Future Work