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.
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.
The first kicad_monkey implementation should promote small,
testable helpers before exposing a large workflow object:
scan_project_assets(project_path)scan_3d_models(project_path)extract_symbols(project_path, mode)strip_symbol_metadata(symbol, policy)extract_footprints(project_path, mode, embed_models=True)strip_footprint_metadata(footprint, policy)rehydrate_embedded_model_payloads(board, footprint)extract_3d_models(project_path)extract_3d_models_from_footprint_records(records, output_dir)write_symbol_folder_library(...)write_pretty_library(...)These APIs should return structured diagnostics rather than only writing files.
The model scanner must classify:
kicad-embed://... references;${KICAD*_3DMODEL_DIR} references;
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.
The workflow JSON should preserve enough data for downstream library import:
cad-reference candidates;cad-reference when obvious;kicad_cruncher should not create part records directly.
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:
Libs/speedy.pretty;kicad-embed://... model references;${KICAD10_3DMODEL_DIR} and
${KICAD9_3DMODEL_DIR} references;
on_board behavior already covered by the netlist corpus.kicad-embed://... footprint model
has a matching embedded payload.
kicad-cli is available.sym-lib-table and fp-lib-table management;