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
rust/src/catalog.rsdeleted−150@@ -1,150 +0,0 @@-//! One table for every verb: name, mechanism, risk, timeout and the describe entry.-//! ab's Verbs tab renders `kicad_describe` verbatim, so the text here is what the AI reads.--use serde_json::{json, Value};--#[allow(dead_code)] // File, Ipc and Window arrive in phases 1b to 3-#[derive(Clone, Copy, Debug, PartialEq, Eq)]-pub enum Mechanism {- /// Pure bridge logic, no KiCad involved.- Local,- /// kicad-cli subprocess.- Cli,- /// Reads or edits KiCad files on disk.- File,- /// KiCad IPC API (phase 2).- Ipc,- /// Window control (phase 3).- Window,-}--impl Mechanism {- pub fn as_str(self) -> &'static str {- match self {- Mechanism::Local => "local",- Mechanism::Cli => "cli",- Mechanism::File => "file",- Mechanism::Ipc => "ipc",- Mechanism::Window => "window",- }- }-}--pub struct Verb {- pub name: &'static str,- pub summary: &'static str,- pub mechanism: Mechanism,- /// ab risk class: read | write | exec | process | config | input- pub risk: &'static str,- pub timeout_sec: u32,- pub input: &'static str,- pub example: &'static str,- pub hint: &'static str,- pub related: &'static [&'static str],- pub pitfalls: &'static [&'static str],-}--pub static VERBS: &[Verb] = &[- Verb {- name: "kicad_describe",- summary: "List every verb with input, example, hint, related verbs and pitfalls.",- mechanism: Mechanism::Local, risk: "read", timeout_sec: 5,- input: "{}", example: "kicad_describe {}",- hint: "Read this once per session; every response also carries _hint and _next.",- related: &["kicad_readiness", "kicad_status"], pitfalls: &[],- },- Verb {- name: "kicad_status",- summary: "Bridge health, KiCad version, install location and uptime.",- mechanism: Mechanism::Local, risk: "read", timeout_sec: 10,- input: "{}", example: "kicad_status {}",- hint: "Cheap; call it before any window verb to learn what KiCad is on this box.",- related: &["kicad_readiness", "kicad_diagnostics"], pitfalls: &[],- },- Verb {- name: "kicad_readiness",- summary: "Is KiCad installed and usable here; if not, the three alternatives (service-kicad, kicad-cli in your container, another box).",- mechanism: Mechanism::Local, risk: "read", timeout_sec: 15,- input: "{}", example: "kicad_readiness {}",- hint: "When installed is false read `alternatives`: the headless verbs still run against service-kicad or a named target.",- related: &["kicad_status", "kicad_list_versions", "kicad_upgrade"],- pitfalls: &["The bridge never installs KiCad from readiness; kicad_upgrade does that on request."],- },- Verb {- name: "kicad_list_versions",- summary: "Every KiCad install found (registry and standard folders) with bin dir, kicad-cli path and version.",- mechanism: Mechanism::Local, risk: "read", timeout_sec: 15,- input: "{}", example: "kicad_list_versions {}",- hint: "The first entry is the one the bridge drives.",- related: &["kicad_readiness"], pitfalls: &[],- },- Verb {- name: "kicad_diagnostics",- summary: "Environment the bridge runs in: user, paths, env vars that matter, KiCad config dir.",- mechanism: Mechanism::Local, risk: "read", timeout_sec: 10,- input: "{}", example: "kicad_diagnostics {}",- hint: "Attach this to any bug report.",- related: &["kicad_status"], pitfalls: &[],- },- Verb {- name: "kicad_run_drc",- summary: "Run kicad-cli pcb drc on a board and return the parsed JSON report (violations, unconnected, counts by severity).",- mechanism: Mechanism::Cli, risk: "read", timeout_sec: 300,- input: "{\"boardPath\": \"C:/.../x.kicad_pcb\", \"refillZones\"?: bool, \"backend\"?: \"local\"}",- example: "kicad_run_drc {\"boardPath\":\"C:/Users/john/proj/board.kicad_pcb\"}",- hint: "Headless: works with no KiCad window open. refillZones true matches what the editor does before its own DRC.",- related: &["kicad_run_erc", "kicad_lint_board"],- pitfalls: &["A board saved by a newer KiCad than kicad-cli refuses to load; the error names both versions."],- },- Verb {- name: "kicad_run_erc",- summary: "Run kicad-cli sch erc on a schematic and return the parsed JSON report.",- mechanism: Mechanism::Cli, risk: "read", timeout_sec: 300,- input: "{\"schematicPath\": \"C:/.../x.kicad_sch\", \"backend\"?: \"local\"}",- example: "kicad_run_erc {\"schematicPath\":\"C:/Users/john/proj/board.kicad_sch\"}",- hint: "Headless. Pass the root sheet; hierarchical sheets are followed by kicad-cli.",- related: &["kicad_run_drc", "kicad_lint_schematic"], pitfalls: &[],- },- Verb {- name: "kicad_uninstall",- summary: "Remove only this bridge's own artifacts (scratch dir, backups it made). Never KiCad, never user data.",- mechanism: Mechanism::Local, risk: "write", timeout_sec: 120,- input: "{\"cascade\"?: bool}", example: "kicad_uninstall {}",- hint: "ab calls this during bridge_uninstall; it is idempotent and non-interactive.",- related: &[], pitfalls: &[],- },-];--pub fn find(name: &str) -> Option<&'static Verb> {- VERBS.iter().find(|v| v.name == name)-}--pub fn describe(version: &str) -> Value {- let verbs: Vec<Value> = VERBS- .iter()- .map(|v| {- json!({- "name": v.name,- "summary": v.summary,- "mechanism": v.mechanism.as_str(),- "risk": v.risk,- "timeoutSeconds": v.timeout_sec,- "longRunning": v.timeout_sec > 60,- "input": v.input,- "example": v.example,- "hint": v.hint,- "related": v.related,- "pitfalls": v.pitfalls,- })- })- .collect();- json!({- "success": true,- "bridge": "kicad",- "version": version,- "runtime": "native",- "verbCount": verbs.len(),- "verbs": verbs,- "_hint": "Phase 1 of the Rust port: headless verbs only. Window, show, routing and demo verbs are still served by the Python bridge until each phase passes the verb runner.",- })-}