← Commit history

v0.9.84: lib-table self-heal (merge missing stock libraries at boot) — root cause of Device:R failing: early bootstrap left user tables with NO stock libs

John Lauer ·7c47a6a337 ·2mo ago ·parent 2a883c5
6 files changed +46−13
BRIDGE_VERSION+1−1
@@ -1 +1 @@-0.9.83+0.9.84
adom-bridge-kicad-manifest.json+5−5
@@ -1,15 +1,15 @@ {   "manifest_version": 1,   "name": "kicad",-  "version": "0.9.83",-  "url": "https://wiki.adom.inc/download/adom/kicad-bridge/0.9.83/adom-bridge-kicad-v0.9.83.zip",-  "sha256": "edc6f4f0abb235511074b6c50f00b19ff500e305d855160aaea4fbee0350fbf9",-  "size": 377395,+  "version": "0.9.84",+  "url": "https://wiki.adom.inc/download/adom/kicad-bridge/0.9.84/adom-bridge-kicad-v0.9.84.zip",+  "sha256": "b613d71ee8cfecc822972efcf226892ddfa004cc278ae6e2c06d0474f67faafa",+  "size": 378015,   "verbPrefixes": [     "kicad_"   ],   "healthEndpoint": "/status",-  "released_at": "2026-08-14T15:33:11Z",+  "released_at": "2026-08-14T15:37:15Z",   "hero": "https://wiki.adom.inc/blob/app/kicad-bridge/kicad-hero.png",   "languages": [     "Python",
adom-bridge-kicad-v0.9.84.zipadded
⋯ 1 unchanged line ⋯
bridge.json+1−1
@@ -2,7 +2,7 @@   "manifest_version": 1,   "name": "kicad",   "displayName": "KiCad EDA",-  "version": "0.9.83",+  "version": "0.9.84",   "description": "Reverse bridge for KiCad \u2014 board/schematic introspection, lint via kicad-cli, plugin install, multi-instance probe, in-process DRC.",   "homepage": "https://wiki.adom.inc/adom/adom-bridge",   "author": "Adom Inc.",
kicad_detect.py+28−6
@@ -220,15 +220,37 @@ def ensure_win_user_config(version: str, base_dir):     template = Path(base_dir) / "share" / "kicad" / "template" if base_dir else None     for fname, root in (("sym-lib-table", "sym_lib_table"), ("fp-lib-table", "fp_lib_table")):         dest = config / fname-        if dest.exists():+        src = (template / fname) if template else None+        if not dest.exists():+            try:+                if src and src.exists():+                    dest.write_bytes(src.read_bytes())  # keep KiCad's standard global libs+                else:+                    dest.write_text(f"({root}\n  (version 7)\n)\n", encoding="utf-8")+            except OSError:+                pass             continue+        # v0.9.84 SELF-HEAL: an EXISTING user table can be missing every stock+        # library —earlier bootstraps fell back to an empty table when base_dir wasn't+        # resolved yet, leaving users with a KiCad whose symbol chooser has no+        # Device/Connector/etc. (found via the Device:R repro in issue #20).+        # Merge any template rows the user table lacks; never touch user rows.         try:-            src = (template / fname) if template else None             if src and src.exists():-                dest.write_bytes(src.read_bytes())  # keep KiCad's standard global libs-            else:-                dest.write_text(f"({root}\n  (version 7)\n)\n", encoding="utf-8")-        except OSError:+                from lib_table import LibTable+                user_t = LibTable.parse_file(str(dest))+                tmpl_t = LibTable.parse_file(str(src))+                have = {e.name for e in user_t.entries}+                added = 0+                for e in tmpl_t.entries:+                    if e.name not in have:+                        user_t.entries.append(e)+                        added += 1+                if added:+                    user_t.write_file(str(dest))+                    print(f"[KiCad Bridge] lib-table self-heal: merged {added} stock "+                          f"librar{'y' if added==1 else 'ies'} into {dest}", flush=True)+        except Exception:             pass     # Seed a minimal kicad_common.json so KiCad doesn't treat this as a FIRST RUN     # ("KiCad is starting for the first time, or some of its configuration files are
server.py+11
@@ -947,6 +947,17 @@ def main():     kicad_info = all_kicad_versions[0] if all_kicad_versions else detect_kicad()     print(f"[KiCad Bridge] detection done ({len(all_kicad_versions)} version(s))", flush=True) +    # v0.9.84: lib-table self-heal at every boot — merges any stock-template+    # libraries missing from the user's sym/fp-lib-table (earlier bootstraps+    # could leave users with NO stock libs; see ensure_win_user_config).+    for _ki in (all_kicad_versions or ([kicad_info] if kicad_info else [])):+        if _ki and _ki.get("installed") and _ki.get("version"):+            try:+                import kicad_detect as _kd+                _kd.ensure_win_user_config(_ki["version"], _ki.get("base_dir"))+            except Exception:+                pass+     print(f"[KiCad Bridge] KiCad detection result:")     print(f"  Versions found: {len(all_kicad_versions)}")     for v in all_kicad_versions: