app
KiCad - the KiCad Bridge
Public Made by Adomby adom
Reference implementation of the KiCad bridge: multi-instance Python server, forward path via kicad-cli, reverse path via in-process plugin. Most complex of the three bundled bridges.
← Commit history
BRIDGE_VERSION+1−1@@ -1 +1 @@-0.9.3+0.9.4
bridge.json+1−1@@ -2,7 +2,7 @@ "manifest_version": 1, "name": "kicad", "displayName": "KiCad EDA",- "version": "0.9.3",+ "version": "0.9.4", "description": "Reverse bridge for KiCad \u2014 board/schematic introspection, lint via kicad-cli, plugin install, multi-instance probe, in-process DRC.", "homepage": "https://github.com/adom-inc/adom-desktop", "author": "Adom Inc.",
server.py+17−1@@ -401,12 +401,25 @@ class KiCadBridgeHandler(BaseHTTPRequestHandler): def main(): global kicad_info, all_kicad_versions + # Line-buffer stdout/stderr. When a supervisor (Adom Desktop) redirects our+ # output to a log FILE, Python block-buffers it by default — so a startup+ # hang shows a 0-byte log and is undebuggable. Line buffering makes every+ # startup step land in ~/.adom/bridge-logs/<name>.log in real time, which is+ # exactly what AD asked bridge authors to do (fatal errors → stdout/stderr).+ try:+ sys.stdout.reconfigure(line_buffering=True)+ sys.stderr.reconfigure(line_buffering=True)+ except Exception:+ pass+ port = DEFAULT_PORT if "--port" in sys.argv: idx = sys.argv.index("--port") if idx + 1 < len(sys.argv): port = int(sys.argv[idx + 1]) + print(f"[KiCad Bridge] starting v{BRIDGE_VERSION} on port {port} (pid {os.getpid()})", flush=True)+ # ── SINGLE-INSTANCE GUARD ──────────────────────────────────────────────── # Bind the port FIRST, before the (slow ~9s) KiCad detection. A supervisor # that lazy-spawns the bridge on every verb call can otherwise fire several@@ -427,8 +440,10 @@ def main(): f"Another bridge instance owns it — exiting cleanly (single-instance guard).") return + print("[KiCad Bridge] bound port; detecting KiCad installs...", flush=True) all_kicad_versions = detect_all_kicad_versions() 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) print(f"[KiCad Bridge] KiCad detection result:") print(f" Versions found: {len(all_kicad_versions)}")@@ -447,6 +462,7 @@ def main(): # Ensure the global Adom symbol library exists and is registered if kicad_info.get("installed"):+ print("[KiCad Bridge] ensuring Adom library...", flush=True) lib_result = ensure_adom_library(kicad_info) if lib_result.get("created"): print(f"[KiCad Bridge] Created Adom symbol library (Adom.kicad_sym)")@@ -456,7 +472,7 @@ def main(): print(f"[KiCad Bridge] Adom library: {len(symbols)} symbol(s) — {', '.join(symbols) if symbols else '(empty)'}") # server already bound above (single-instance guard); now serve.- print(f"[KiCad Bridge] Listening on http://127.0.0.1:{port}")+ print(f"[KiCad Bridge] Listening on http://127.0.0.1:{port} — serving now", flush=True) print(f"[KiCad Bridge] Health check: http://127.0.0.1:{port}/status (and /health)") print(f"[KiCad Bridge] Press Ctrl+C to stop.")