← Commit history

2.11.10: export ships original page KiCad files, colon names sanitized

John Lauer ·042180a4ba ·1mo ago ·parent e31cb09
6 files changed +36−18
Cargo.lock+1−1
@@ -10,7 +10,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"  [[package]] name = "adom-lbr"-version = "2.11.9"+version = "2.11.10" dependencies = [  "altium-codec",  "anyhow",
Cargo.toml+1−1
@@ -1,6 +1,6 @@ [package] name = "adom-lbr"-version = "2.11.9"+version = "2.11.10" edition = "2021" description = "adom-lbr generator / EDA translator: the canonical adom-lbr JSON is the hub, with native converters to Altium (.SchLib/.PcbLib/.IntLib), EAGLE/Fusion (.lbr), and KiCad. Altium output is written natively — no Altium needed at conversion time." 
VERSION+1−1
@@ -1 +1 @@-2.11.9+2.11.10
package.json+1−1
@@ -1,6 +1,6 @@ {   "slug": "adom-lbr",-  "version": "2.11.9",+  "version": "2.11.10",   "type": "app",   "description": "adom-lbr \u2014 the EDA library translator. Bring a component in from any supported EDA tool and convert it to any other (KiCad \u21c4 Altium \u21c4 EAGLE/Fusion) through one canonical adom-lbr JSON \u2014 symbol + footprint + 3D + pin\u2194pad map. Altium is written natively (no Altium needed). Includes the adom-lbr Manager: browse wiki components and view symbol/footprint/3D + the per-EDA layer stackup.",   "dependencies": {},
page.json+9−12
@@ -1,8 +1,8 @@ {   "slug": "adom-lbr",-  "version": "2.11.9",+  "version": "2.11.10",   "type": "app",-  "description": "adom-lbr — the EDA library translator. Bring a component in from any supported EDA tool and convert it to any other (KiCad ⇄ Altium ⇄ EAGLE/Fusion) through one canonical adom-lbr JSON — symbol + footprint + 3D + pin↔pad map. Altium is written natively (no Altium needed). Includes the adom-lbr Manager: browse wiki components and view symbol/footprint/3D + the per-EDA layer stackup.",+  "description": "adom-lbr \u2014 the EDA library translator. Bring a component in from any supported EDA tool and convert it to any other (KiCad \u21c4 Altium \u21c4 EAGLE/Fusion) through one canonical adom-lbr JSON \u2014 symbol + footprint + 3D + pin\u2194pad map. Altium is written natively (no Altium needed). Includes the adom-lbr Manager: browse wiki components and view symbol/footprint/3D + the per-EDA layer stackup.",   "dependencies": {},   "tags": [     "eda",@@ -52,24 +52,21 @@   ],   "files": [     "bin/**",-    "assets/**",     "SKILL.md",-    "skills/**",     "README.md",     "install.sh",     "uninstall.sh",-    "screenshots/**",-    "dockbar.json"+    "screenshots/**"   ],-  "discovery_pitch": "Convert electronic-component symbols + footprints between any two EDA tools — KiCad, Altium (written natively, no Altium needed), and EAGLE/Fusion — through one canonical adom-lbr JSON, silk/courtyard/fab layers preserved. Plus a Manager to browse and inspect any wiki part.",+  "discovery_pitch": "Convert electronic-component symbols + footprints between any two EDA tools \u2014 KiCad, Altium (written natively, no Altium needed), and EAGLE/Fusion \u2014 through one canonical adom-lbr JSON, silk/courtyard/fab layers preserved. Plus a Manager to browse and inspect any wiki part.",   "sample_prompts": [     {       "prompt": "Convert this KiCad symbol and footprint to an Altium SchLib and PcbLib",-      "label": "KiCad → Altium"+      "label": "KiCad \u2192 Altium"     },     {       "prompt": "Import this Altium footprint into the adom-lbr JSON",-      "label": "Altium → JSON"+      "label": "Altium \u2192 JSON"     },     {       "prompt": "Bundle this part into a single Altium IntLib",@@ -77,15 +74,15 @@     },     {       "prompt": "Convert this Altium SchLib and PcbLib to a KiCad symbol and footprint",-      "label": "Altium → KiCad"+      "label": "Altium \u2192 KiCad"     },     {       "prompt": "Export this adom-lbr JSON to a KiCad .kicad_sym and .kicad_mod",-      "label": "JSON → KiCad"+      "label": "JSON \u2192 KiCad"     },     {       "prompt": "Open the adom-lbr Manager to browse wiki components and view the layer stackup",       "label": "Browse parts"     }   ]-}\ No newline at end of file+}
src/manage.rs+23−2
@@ -1151,6 +1151,16 @@ fn run_apply(items: Vec<(String, String, String)>, board: Option<String>, dest:     set_progress(json!({"stage":"Done","current":total,"total":total,"done":true,"result":result})); } +/// KiCad symbol names must not carry a lib-qualified "LIB:NAME" prefix: KiCad+/// treats the colon as a separator, editors cannot search the name, and KiCad+/// 10 mis-trees the sub-units (the whole AdomLapper library_cache_stale saga,+/// 2026-08-23). Wiki source files sometimes carry them; strip the prefix from+/// every `(symbol "...")` block name, sub-units included, and from `(extends)`.+fn sanitize_kicad_sym_names(txt: &str) -> String {+    let re = regex_lite::Regex::new(r#"\((symbol|extends) "[^":]+:([^"]+)""#).unwrap();+    re.replace_all(txt, "($1 \"$2\"").to_string()+}+ /// Everything the toolbar's web-control chains need to stage this part on the /// user's PC, in one payload: KiCad symbol + footprint text, a generated EAGLE /// .lbr (for Fusion's fusion_create_library shape A), the page's .step when it@@ -1175,8 +1185,18 @@ fn export_part(slug: &str) -> Value {             part.symbol.name = tail;         }     }-    let sym_txt = export_kicad_symbol(&part.symbol);-    let fp_txt = export_kicad_footprint(&part.footprint);+    // Prefer the page's ORIGINAL KiCad files (found by suffix, never by name+    // guessing): they are genuine KiCad format. The hub round-trip is the+    // fallback for pages that only publish the JSON or Altium sources - its+    // writer currently emits an old header KiCad 10 mis-trees (adom-lbr#11),+    // so a round-tripped export is second choice by design.+    let page_files = list_page_files(slug);+    let find = |suffix: &str| page_files.iter().find(|n| n.to_lowercase().ends_with(suffix)).cloned();+    let orig_sym = find(".kicad_sym").and_then(|n| wiki_text(slug, &n)).filter(|t| t.contains("(kicad_symbol_lib"));+    let orig_fp = find(".kicad_mod").and_then(|n| wiki_text(slug, &n)).filter(|t| t.contains("(footprint") || t.contains("(module"));+    let kicad_source = orig_sym.is_some();+    let sym_txt = sanitize_kicad_sym_names(&orig_sym.unwrap_or_else(|| export_kicad_symbol(&part.symbol)));+    let fp_txt = orig_fp.unwrap_or_else(|| export_kicad_footprint(&part.footprint));     // pin->pad map from the hub's connect[] (only the disagreements matter)     let mut pin_map: std::collections::HashMap<String, String> = Default::default();     for c in &part.connect {@@ -1209,6 +1229,7 @@ fn export_part(slug: &str) -> Value {         "mpn": mpn,         "slug": slug,         "source": src,+        "kicad_files": if kicad_source { "original (page), names sanitized" } else { "round-tripped (hub export)" },         "pin_map": pin_map,         "has_step": step_b64.is_some(),         "files": files,