From da881f425d7f0814241a030e60a2675e70358755 Mon Sep 17 00:00:00 2001 From: i2cjak Date: Tue, 24 Nov 2026 13:24:20 -0500 Subject: [PATCH] agents,kicad: enforce KiStack skill loading and lint wall-of-labels schematics --- native/host/src/agents/context.rs | 15 +- native/host/src/agents/kistack.rs | 19 ++- native/host/src/agents/mcp.rs | 101 +++++++++++- native/host/src/agents/mod.rs | 5 +- native/host/src/agents/prompt.rs | 14 +- native/host/src/agents/prompt_text.rs | 2 +- native/host/src/agents/skills.rs | 46 +++--- native/host/src/agents/tests.rs | 30 ++++ native/host/src/kicad/kedit.rs | 203 ++++++++++++++++++++++++- test/agents/fixtures/argv-default.json | 2 +- test/agents/fixtures/mcp-tools.json | 2 +- 11 files changed, 404 insertions(+), 35 deletions(-) diff --git a/native/host/src/agents/context.rs b/native/host/src/agents/context.rs index 3a249bca54..9ab741901d 100644 --- a/native/host/src/agents/context.rs +++ b/native/host/src/agents/context.rs @@ -251,7 +251,12 @@ impl Prompt { let (instructions, project) = instructions_for(cwd, provider, claude); let discovered = skills::index(env, cwd); let active = skills::for_model(&discovered, provider, model); - let index = skills::prompt_index(&active, provider, isolated); + let index = if base.contains("") { + let filtered: Vec<_> = active.iter().filter(|f| !f.kistack).cloned().collect(); + skills::prompt_index(&filtered, provider, isolated) + } else { + skills::prompt_index(&active, provider, isolated) + }; let skills = discovered.iter().map(|s| { let status = if !active.contains(s) { "Skipped" } else if skills::native(s, provider, isolated) { "Native" } @@ -304,6 +309,14 @@ mod launch_tests { let claude = prompt("claude", "sonnet"); assert!(claude.skills.iter().any(|row| row["name"] == "deploy" && row["status"] == "Native")); assert!(!claude.index.contains("command marker")); + + // Pinned KiStack skills are omitted from when is already in base, while remaining active in skills. + let ks_dir = dir.join("kistack_pin"); + put(&ks_dir, "skills/schematic/SKILL.md", "---\nname: kicad-schematic\ndescription: Draw schematics.\n---\nBODY"); + let env_ks = crate::agents::skills::env_from(home.to_str().unwrap(), &bundle, Some(&ks_dir)); + let codex_with_ks = Prompt::build("MANDATORY: ...".into(), &env_ks, cwd.to_str().unwrap(), "codex", "gpt-6", false, ClaudeFiles::default()); + assert!(!codex_with_ks.index.contains("kicad-schematic"), "no duplicate KiStack entry in "); + assert!(codex_with_ks.skills.iter().any(|row| row["name"] == "kicad-schematic" && row["status"] == "Cross-provider")); } #[test] diff --git a/native/host/src/agents/kistack.rs b/native/host/src/agents/kistack.rs index f2a2ee35cb..987f68e92b 100644 --- a/native/host/src/agents/kistack.rs +++ b/native/host/src/agents/kistack.rs @@ -103,9 +103,24 @@ mod tests { std::fs::write(&stale, "---\nname: kicad-schematic\ndescription: an older copy\n---\nold\n").unwrap(); let ss = crate::agents::skills::scan_all(&env, &home.to_string_lossy()); let f = crate::agents::skills::lookup(&ss, "kicad-schematic").expect("listed"); - assert_eq!((f.group.as_str(), f.kind), ("Agents · yours", crate::agents::skills::Kind::Agents), "the user copy wins the name"); + assert_eq!((f.group.as_str(), f.kind, f.kistack), ("Backplane", crate::agents::skills::Kind::Hub, true), "pinned KiStack beats user copy"); + let fk = crate::agents::skills::lookup(&ss, "kistack:kicad-schematic").expect("plugin name lookup"); + assert_eq!(fk.path, f.path); assert_eq!(ss.iter().filter(|f| f.name == "kicad-schematic" && f.kind == crate::agents::skills::Kind::Hub).count(), 1, "one entry, not one per root"); - assert!(crate::agents::skills::prepare("$kicad-schematic draw it", &ss, "codex", false).replace('\\', "/").contains(".agents/skills/schematic/SKILL.md"), "Codex is told the user file"); + for (prov, model) in [("claude", "fable"), ("codex", "gpt-6")] { + let active = crate::agents::skills::for_model(&ss, prov, model); + let picked = active.iter().find(|s| s.name == "kicad-schematic").expect("kicad-schematic in for_model"); + assert!(picked.kistack && picked.path.replace('\\', "/").contains("hub/kistack/skills/schematic/SKILL.md"), "{prov} picked {}", picked.path); + } + assert!(crate::agents::skills::prepare("$kicad-schematic draw it", &ss, "codex", false).replace('\\', "/").contains("hub/kistack/skills/schematic/SKILL.md"), "Codex is told the pinned KiStack file"); + // a project-scoped override still wins over pinned KiStack when cwd is inside that project + let proj = h.join("proj"); let ovr = proj.join(".backplane/skills/schematic/SKILL.md"); + std::fs::create_dir_all(ovr.parent().unwrap()).unwrap(); + std::fs::write(&ovr, "---\nname: kicad-schematic\ndescription: project override\n---\nproj\n").unwrap(); + let pss = crate::agents::skills::scan_all(&env, &proj.to_string_lossy()); + let pf = crate::agents::skills::lookup(&pss, "kicad-schematic").expect("project override"); + assert_eq!(pf.scope, "Project"); + assert!(pf.path.replace('\\', "/").contains(".backplane/skills/schematic/SKILL.md")); let _ = std::fs::remove_dir_all(&h); } } diff --git a/native/host/src/agents/mcp.rs b/native/host/src/agents/mcp.rs index 88ca7a5f71..0f1471ca39 100644 --- a/native/host/src/agents/mcp.rs +++ b/native/host/src/agents/mcp.rs @@ -24,6 +24,32 @@ pub trait ToolSet: Send + Sync { pub fn altium_next(spec: &Value) -> Option<&'static str> { spec.get("schdoc").filter(|v| v.is_object()).map(|_| "Look at the sheet now (viewer_show) and check it against KiStack's kicad-schematic rules: signal left to right, power ports up and ground down, wires between nearby pins, parts spread over the sheet, no text over a part or another text. Fix what fails before the next step.") } + +/// Deterministic wall-of-labels lint for an `altium_write` `schdoc` spec. +pub fn altium_schdoc_lint(spec: &Value) -> Option { + let schdoc = spec.get("schdoc")?.as_object()?; + let parts = schdoc.get("place").and_then(Value::as_array).map_or(0, Vec::len); + let label_connects = schdoc.get("connect").and_then(Value::as_array).map_or(0, |a| { + a.iter().filter(|c| { + let is_power = c.get("power").is_some_and(|p| !p.is_null() && *p != json!(false)); + let is_nc = c.get("net").and_then(Value::as_str).is_some_and(|n| n.eq_ignore_ascii_case("NC")); + !is_power && !is_nc + }).count() + }); + let labels = schdoc.get("labels").and_then(Value::as_array).map_or(0, Vec::len); + let wires = schdoc.get("wires").and_then(Value::as_array).map_or(0, Vec::len); + let net_stubs = label_connects + labels; + if parts >= 3 && net_stubs >= 6 && (wires == 0 || (wires < parts && net_stubs > wires * 2)) { + return Some(json!({ + "warnings": [ + format!("Wall-of-labels schematic pattern: placed {parts} parts with {net_stubs} connect/label entries ({label_connects} connect, {labels} labels) and only {wires} explicit wire(s). Follow KiStack's kicad-schematic skill: wire passives directly to IC pins with `wires`, group decoupling capacitors onto shared rails, box and label subcircuits, and reserve net labels for inter-block signals.") + ], + "stats": {"parts": parts, "connects": label_connects, "labels": labels, "wires": wires}, + "next": "Load and follow KiStack's kicad-schematic skill, replace floating pin labels on passives with direct wires, box subcircuits, and visually inspect the rendered sheet." + })); + } + None +} pub const TOOLS_JSON: &str = include_str!("../../../../test/agents/fixtures/mcp-tools.json"); pub const IMPLEMENTED: &[&str] = &["orchestrator_capabilities", "review_comment", "review_comments", "work_run", "work_watch", "work_list", "work_cancel", "work_unwatch", "lock_acquire", "lock_release", "lock_cancel", "lock_list", "account_list", "thread_launch", "machine_list", "delegate_task", "task_status", "task_cancel", "thread_list", "thread_read", "thread_send", "thread_reply", "thread_update", "thread_wait", "thread_interrupt", "thread_settle", "viewer_show", "permission_prompt", "kicad_ipc", "kicad_edit", "kicad_ipc_status", "kicad_select", "kicad_bring_back", "altium_status", "altium_script", "altium_write", "terminal_open", "terminal_read", "terminal_send", "terminal_close", "preview_open", "preview_navigate", "preview_snapshot", "preview_click", "preview_type", "preview_press", "preview_scroll", "preview_evaluate", "preview_wait_for", "preview_resize", "preview_status", "secret_request", "secret_list", "secret_run", "settings_inspect", "settings_propose"]; const MAX_BODY: usize = 4 << 20; @@ -305,7 +331,7 @@ impl Mcp { let spec = a.clone(); let ran = tokio::task::spawn_blocking(move || crate::files::altium::write::spec::run(&spec, std::path::Path::new(&base))).await; match ran { - Ok(Ok((v, _written))) => { let added = crate::files::altium::write::spec::project_added(&v); let mut out = crate::files::altium::live::after_write(&ss, v, &open, &added).await; if let (Some(n), Some(o)) = (altium_next(&a), out.as_object_mut()) { o.insert("next".into(), json!(n)); } (true, out) } + Ok(Ok((v, _written))) => { let added = crate::files::altium::write::spec::project_added(&v); let mut out = crate::files::altium::live::after_write(&ss, v, &open, &added).await; if let (Some(n), Some(o)) = (altium_next(&a), out.as_object_mut()) { o.insert("next".into(), json!(n)); } if let (Some(lint), Some(o)) = (altium_schdoc_lint(&a), out.as_object_mut()) { o.insert("schematic_lint".into(), lint); } (true, out) } Ok(Err(e)) => { let _ = crate::files::altium::live::after_write(&ss, json!({}), &open, &[]).await; fail(&e) } Err(e) => { let _ = crate::files::altium::live::after_write(&ss, json!({}), &open, &[]).await; fail(&e.to_string()) } } @@ -400,6 +426,79 @@ mod tests { #[test] fn the_tool_list_is_the_js_hubs_for_every_tool_we_serve() { let all: Value = serde_json::from_str(TOOLS_JSON).unwrap(); let names: Vec<&str> = all["result"]["tools"].as_array().unwrap().iter().map(|t| sv(t, "name")).collect(); for n in IMPLEMENTED { assert!(names.contains(n), "{n} is not a tool the JS hub lists") } + let ke = all["result"]["tools"].as_array().unwrap().iter().find(|t| sv(t, "name") == "kicad_edit").unwrap(); + let desc = sv(ke, "description"); + assert!(desc.contains("load and follow the matching KiStack skill") && desc.contains("kistack:kicad-schematic"), "{desc}"); + assert!(!desc.contains("do not read or render the sheet to find room or to check the result"), "{desc}"); + } + #[test] fn altium_schdoc_lint_flags_wall_of_labels_and_stays_quiet_when_wired() { + let wall = json!({ + "schdoc": { + "path": "Main.SchDoc", + "place": [ + {"symbol": "MCU", "designator": "U1", "at": [1000, 1000]}, + {"symbol": "RES", "designator": "R1", "at": [2000, 1000]}, + {"symbol": "CAP", "designator": "C1", "at": [3000, 1000]} + ], + "connect": [ + {"pin": "U1.1", "net": "VCC"}, + {"pin": "U1.2", "net": "GND"}, + {"pin": "U1.3", "net": "SDA"}, + {"pin": "U1.4", "net": "SCL"}, + {"pin": "R1.1", "net": "SDA"}, + {"pin": "C1.1", "net": "VCC"} + ], + "wires": [] + } + }); + let lint = altium_schdoc_lint(&wall).expect("wall-of-labels schdoc should trigger lint"); + assert!(lint["warnings"][0].as_str().unwrap().contains("Wall-of-labels schematic pattern"), "{lint}"); + assert_eq!(lint["stats"]["parts"], 3); + assert_eq!(lint["stats"]["wires"], 0); + + let wired = json!({ + "schdoc": { + "path": "Main.SchDoc", + "place": [ + {"symbol": "MCU", "designator": "U1", "at": [1000, 1000]}, + {"symbol": "RES", "designator": "R1", "at": [1500, 1000]}, + {"symbol": "CAP", "designator": "C1", "at": [1500, 800]} + ], + "connect": [ + {"pin": "U1.1", "net": "VCC", "power": true}, + {"pin": "U1.2", "net": "GND", "power": true} + ], + "wires": [ + [[1200, 1000], [1400, 1000]], + [[1200, 900], [1400, 900]], + [[1500, 900], [1500, 850]] + ] + } + }); + assert!(altium_schdoc_lint(&wired).is_none()); + + let power_only = json!({ + "schdoc": { + "path": "Power.SchDoc", + "place": [ + {"symbol": "LDO", "designator": "U1", "at": [1000, 1000]}, + {"symbol": "CAP", "designator": "C1", "at": [1500, 1000]}, + {"symbol": "CAP", "designator": "C2", "at": [2000, 1000]} + ], + "connect": [ + {"pin": "U1.1", "net": "VIN", "power": true}, + {"pin": "U1.2", "net": "GND", "power": true}, + {"pin": "U1.3", "net": "+3V3", "power": "bar"}, + {"pin": "U1.4", "net": "NC"}, + {"pin": "C1.1", "net": "+3V3", "power": true}, + {"pin": "C1.2", "net": "GND", "power": true}, + {"pin": "C2.1", "net": "VIN", "power": true}, + {"pin": "C2.2", "net": "GND", "power": true} + ], + "wires": [] + } + }); + assert!(altium_schdoc_lint(&power_only).is_none(), "power/NC connects should not trigger wall-of-labels"); } } diff --git a/native/host/src/agents/mod.rs b/native/host/src/agents/mod.rs index 6b5cf3cd81..26c29a4b66 100644 --- a/native/host/src/agents/mod.rs +++ b/native/host/src/agents/mod.rs @@ -213,9 +213,10 @@ impl Agents { let locks: Vec<(String, String)> = [&f.pcb, &f.sch].into_iter().filter(|d| !d.is_empty()).map(|d| (d.clone(), crate::files::kicad::canonical::doc_lock(d))).collect(); let design = if f.pcb.is_empty() && f.sch.is_empty() { String::new() } else { prompt::design_words(&main, code.as_ref().filter(|c| !c.0.is_empty()).map(|c| (c.0.as_str(), c.1.as_str())), &locks) }; let keys = prompt::api_keys(&keys_path.to_string_lossy(), &prompt::key_names(&std::fs::read_to_string(&keys_path).unwrap_or_default())) + &prompt::secrets(&crate::settings::vault::names()); + let kistack = host.kistack.as_deref().map(kistack::describe); prompt::build(&prompt::PromptEnv { fc: crate::files::kicad::stepglb::told_freecad(&host.home, &host.fc), render: host.render.clone(), kicad: host.kicad.clone(), kicad_ipc: ipc, models: host.models_text(), may_delegate: true, orders_on: orders, routing_plan: plan, - // The context index supplies the skill catalog once, with provider scoping and overrides. - root: main, pro: f.pro, pcb: f.pcb, sch: f.sch, all: cad.kicad.join("\n"), altium_projects: cad.altium, design, keys, machines, buy, lang, skills: vec![], kistack: None }) + // Keep `` in the base prompt so every provider (including Claude with `--plugin-dir` and brand-new projects with no KiCad files yet) sees the mandatory KiStack workflow directive and pinned `SKILL.md` paths untruncated by ``. + root: main, pro: f.pro, pcb: f.pcb, sch: f.sch, all: cad.kicad.join("\n"), altium_projects: cad.altium, design, keys, machines, buy, lang, skills: vec![], kistack }) }).await.unwrap_or_default() } /// PendingChanged: the number of open asks on a thread, written after an ask opens or closes (`extra` asks counted on top). diff --git a/native/host/src/agents/prompt.rs b/native/host/src/agents/prompt.rs index 17268c5e87..d5dffa6dde 100644 --- a/native/host/src/agents/prompt.rs +++ b/native/host/src/agents/prompt.rs @@ -50,7 +50,7 @@ pub fn why(text: &str) -> String { text.lines().next().unwrap_or("").trim().char pub fn kicad(k: &Kicad, ipc: bool) -> String { let status = match (k.status.as_str(), ipc) { - ("ok", true) => format!("Backplane KiCad {}. Start with `kicad_edit`. If it lacks an operation, read the bundled `kicad-ipc` skill and use `kicad_ipc_status` for live commands.", k.version), + ("ok", true) => format!("Backplane KiCad {}. Load and follow the matching KiStack skill (`kistack:` or its SKILL.md in ``) before creating or editing any schematic, symbol, footprint, or board, then start edits with `kicad_edit`. If `kicad_edit` lacks an operation, read the bundled `kicad-ipc` skill and use `kicad_ipc_status` for live commands.", k.version), ("ok", false) => "KiCad IPC is turned off. Enable it in Settings for document work.".into(), ("stock", _) => "Install Backplane KiCad from Settings to use editing IPC.".into(), ("old", _) => format!("Update Backplane KiCad from Settings for editing IPC (minimum {}).", min_version()), @@ -124,7 +124,7 @@ pub fn kistack_skills(c: &crate::agents::kistack::Copy) -> String { let l = T::PROMPT_SKILL_LINE; let which = if c.pinned { format!("pinned with this Backplane (KiStack commit {})", &c.rev[..12.min(c.rev.len())]) } else { format!("from BACKPLANE_KISTACK (KiStack {})", if c.rev.is_empty() { "of no recorded commit" } else { &c.rev }) }; let list = c.skills.iter().map(|(n, d, p)| format!("{}{n}{}{d}{}{p}{}", l[0], l[1], l[2], l[3])).collect::>().join("\n"); - format!("Use KiStack as the default skill set for KiCad work and apply its CAD design rules in Altium. Read the relevant SKILL.md before design work. This copy is {which} at `{}`.\n{list}", c.dir) + format!("MANDATORY: Use KiStack as the default skill set for KiCad work and apply its CAD design rules in Altium. Before creating or editing any KiCad schematic, symbol, footprint, or PCB layout (including in a new project with no KiCad files yet), load and follow the matching KiStack skill — in Claude via the Skill loader (`kistack:`, e.g. `kistack:kicad-schematic`, `kistack:kicad-symbol`, `kistack:kicad-footprint`, `kistack:kicad-layout`, `kistack:kicad-pcb`, `kistack:kicad-bom`, `kistack:kicad-export`), or by reading its pinned SKILL.md below. Do not bypass KiStack skills with ad-hoc scripts or wall-of-labels bulk pin dumps, and use this pinned copy rather than any older personal copy (such as under `~/.agents/skills`). This copy is {which} at `{}`.\n{list}", c.dir) } /// Where a hardware thread's work goes. `code`: its code worktree and branch when it works in the /// main checkout ("" for a thread still in an older worktree); `locks`: (document, its lock). @@ -259,7 +259,9 @@ pub(crate) mod tests { } #[test] fn kicad_words_follow_the_status() { let k = |s: &str| Kicad { status: s.into(), cli: "/k".into(), version: "1".into(), commit: "abc".into(), why: "no\nmore".into() }; - assert!(kicad(&k("ok"), true).contains("`kicad_ipc_status`")); assert!(kicad(&k("ok"), false).contains("turned off")); assert!(kicad(&k("broken"), true).contains("doesn't run (no)")); + assert!(kicad(&k("ok"), true).contains("`kicad_ipc_status`")); + assert!(kicad(&k("ok"), true).contains("Load and follow the matching KiStack skill") && kicad(&k("ok"), true).contains("then start edits with `kicad_edit`")); + assert!(kicad(&k("ok"), false).contains("turned off")); assert!(kicad(&k("broken"), true).contains("doesn't run (no)")); { let mut e = PromptEnv { pcb: "/p/b.kicad_pcb".into(), ..Default::default() }; e.kicad.status = "ok".into(); e.kicad.version = "10.99.0-bp.11".into(); assert!(build(&e).contains("")); assert!(build(&e).contains("Plan before routing is off") && !build(&e).contains("plan_approve"), "off unless the person turns it on: route as asked"); e.routing_plan = true; assert!(build(&e).contains("plan_approve") && !build(&e).contains("is off")); e.routing_plan = false; e.kicad.version = "10.99.0-bp.10".into(); assert!(!build(&e).contains(""), "the plan API came with bp.11"); e.kicad.status = "stock".into(); assert!(!build(&e).contains(""), "stock KiCad has no plan API"); } @@ -284,12 +286,14 @@ pub(crate) mod tests { } #[test] fn kistack_is_named_with_its_files_only_when_the_agent_has_it() { let e = gold_env(); let s = build(&e); - assert!(!s.contains("")); + assert!(!s.contains("")); let mut e = e; e.kistack = Some(crate::agents::kistack::Copy { dir: "/skills/kistack".into(), rev: crate::agents::kistack::REV.into(), pinned: true, skills: vec![("kicad-schematic".into(), "Draw schematics.".into(), "/skills/kistack/schematic/SKILL.md".into())] }); let s = build(&e); - assert!(s.contains("Use KiStack as the default skill set") && s.contains("/skills/kistack/schematic/SKILL.md")); + assert!(s.contains("MANDATORY: Use KiStack as the default skill set") && s.contains("kistack:kicad-schematic") && s.contains("/skills/kistack/schematic/SKILL.md")); + assert!(s.contains("including in a new project with no KiCad files yet"), "{s}"); + assert!(s.contains("load and follow the matching KiStack skill"), "PROMPT_BOARD should mandate KiStack before kicad_edit"); } #[test] fn buy_workflow_is_loaded_on_demand() { let mut e = gold_env(); diff --git a/native/host/src/agents/prompt_text.rs b/native/host/src/agents/prompt_text.rs index 0d7bd8d4e8..b2b30b3f7a 100644 --- a/native/host/src/agents/prompt_text.rs +++ b/native/host/src/agents/prompt_text.rs @@ -9,7 +9,7 @@ pub const PROMPT_SKILL_LINE: &[&str] = &["- ", ": ", " Read \"", "\""]; pub const PROMPT_LINES: &[&str] = &[]; pub const PROMPT_SKILLS: &[&str] = &["\n"]; pub const PROMPT_BUNDLED: &[&str] = &["Backplane's own skills, for every agent whatever its provider: before work one of them covers, read its SKILL.md completely and follow it.\n", ""]; -pub const PROMPT_BOARD: &[&str] = &["\n- Use the named KiCad design in the main checkout, including referenced sheets. Use the canonical files by default. Backplane routes design tools there and commits saves to main. Use your thread worktree for code, firmware and docs. Create a labeled alternate board only for an experiment the person requests.\n- Always use IPC to inspect and edit KiCad documents. Start with `kicad_edit {path, ops}`: it batches operations into one commit, takes a free document lock, saves and returns the ERC/DRC delta. Use references and millimetres. Use `rule` and `netclass` for rules and net classes. Use raw `kicad_ipc` only for operations it lacks. Never write .kicad_pcb, .kicad_sch, .kicad_pro or .kicad_dru directly or through scripts while KiCad is open.\n- Edits land live and can be undone in KiCad’s Agents panel. Keep the person’s editor open. The result's `person` field shows selections and edits from the last two minutes. Ask before touching those items or their area and continue elsewhere meanwhile. `ISC_DEFERRED` and `IDS_DEFERRED` edits merge after the person finishes their edit. Check `GetNotices` for the result.\n- Backplane releases document locks when your turn ends. Call `lock_acquire` only when a tool directs you. Keep changes scoped and re-read shared items before changing them.\n- Save every meaningful milestone, including unfinished work. `kicad_edit` saves automatically. For raw IPC, send `SaveDocument`. Read back the saved path, open it with `viewer_show` and verify viewer and history match. Preserve companion .backplane.json metadata and report mismatches.\n"]; +pub const PROMPT_BOARD: &[&str] = &["\n- Use the named KiCad design in the main checkout, including referenced sheets. Use the canonical files by default. Backplane routes design tools there and commits saves to main. Use your thread worktree for code, firmware and docs. Create a labeled alternate board only for an experiment the person requests.\n- Before creating or editing any KiCad schematic, symbol, footprint, or board, load and follow the matching KiStack skill (from ``, or `kistack:` in Claude). Always use IPC to inspect and edit KiCad documents — start edits with `kicad_edit {path, ops}`: it batches operations into one commit, takes a free document lock, saves and returns the ERC/DRC delta. Use references and millimetres. Use `rule` and `netclass` for rules and net classes. Use raw `kicad_ipc` only for operations it lacks. Never write .kicad_pcb, .kicad_sch, .kicad_pro or .kicad_dru directly or through scripts while KiCad is open.\n- Edits land live and can be undone in KiCad’s Agents panel. Keep the person’s editor open. The result's `person` field shows selections and edits from the last two minutes. Ask before touching those items or their area and continue elsewhere meanwhile. `ISC_DEFERRED` and `IDS_DEFERRED` edits merge after the person finishes their edit. Check `GetNotices` for the result.\n- Backplane releases document locks when your turn ends. Call `lock_acquire` only when a tool directs you. Keep changes scoped and re-read shared items before changing them.\n- Save every meaningful milestone, including unfinished work. `kicad_edit` saves automatically. For raw IPC, send `SaveDocument`. Read back the saved path, open it with `viewer_show` and verify viewer and history match. Preserve companion .backplane.json metadata and report mismatches.\n"]; pub const PROMPT_RUNTIME: &[&str] = &["In case you're asked: you are running in Backplane through the ", " harness. Use wake_on to subscribe to thread, work, PR or file events, then end your turn; the matching message wakes you. No need to mention this otherwise. You can embed images and videos in your response using Markdown with absolute file paths.\n\n", "To show the user an image (a board render, plot, screenshot or photo), save it as PNG or JPEG and write its absolute path on its own, e.g. /home/h/x.png (no spaces in the path); it's drawn under your message. Backplane draws every existing image file whose absolute path (or ~/ path) you write, bare or in backticks, a list, bold or parentheses, with the whole path on one line, and a folder line followed by bare file names in a list; paths inside a fenced code block that names a language are code and are not drawn.\n\n", "Backplane hosts a web browser for you: the backplane MCP server's preview_* tools (preview_open, preview_navigate, preview_snapshot, preview_click, preview_type, preview_press, preview_scroll, preview_evaluate, preview_wait_for). The user watches it live in the app's Browser tab. Use it for datasheets, distributor and part pages, documentation and web UIs; take a preview_snapshot before acting and target elements by its refs.\n\n"]; /// Simulation (kicad/ksim.rs), for a schematic on a runtime with `sim-run`. pub const PROMPT_SIM: &str = "For schematic simulation, read the bundled `kicad-sim` skill and use `kicad_sim`."; diff --git a/native/host/src/agents/skills.rs b/native/host/src/agents/skills.rs index 3a344c3443..0bff57af53 100644 --- a/native/host/src/agents/skills.rs +++ b/native/host/src/agents/skills.rs @@ -95,7 +95,7 @@ mod parsing_tests { pub enum Kind { ClaudeUser, ClaudeProject, ClaudePlugin, Codex, Agents, Gemini, Cursor, Universal, Pi, Omp, Grok, Hub, HubLocal } #[derive(Clone, Debug, PartialEq)] -pub struct Found { pub name: String, pub bare: String, pub description: String, pub path: String, pub group: String, pub kind: Kind, pub provider: String, pub model_pattern: String, pub model: bool, pub user: bool, pub scope: &'static str } +pub struct Found { pub name: String, pub bare: String, pub description: String, pub path: String, pub group: String, pub kind: Kind, pub provider: String, pub model_pattern: String, pub model: bool, pub user: bool, pub scope: &'static str, pub kistack: bool } /// Where to look: the person's home, the hub's home, KiStack, and Codex's own home when set. #[derive(Clone, Debug, Default)] @@ -119,18 +119,22 @@ pub fn directories(cwd: &Path) -> Vec { dirs } -struct Root { dir: PathBuf, kind: Kind, group: String, plugin: String, scope: &'static str } +struct Root { dir: PathBuf, kind: Kind, group: String, plugin: String, scope: &'static str, kistack: bool } fn read_json(p: &Path) -> Value { std::fs::read_to_string(p).ok().and_then(|t| serde_json::from_str(&t).ok()).unwrap_or(Value::Null) } /// Every folder skills may sit in, for a thread working in `cwd`. fn roots(env: &Env, cwd: &str) -> Vec { let home = PathBuf::from(&env.home); let mut v: Vec = vec![]; - let mut add = |dir: PathBuf, kind: Kind, group: &str, plugin: &str, scope| if !v.iter().any(|r| r.dir == dir) { v.push(Root { dir, kind, group: group.into(), plugin: plugin.into(), scope }) }; + let mut add = |dir: PathBuf, kind: Kind, group: &str, plugin: &str, scope, kistack| if !v.iter().any(|r| r.dir == dir) { v.push(Root { dir, kind, group: group.into(), plugin: plugin.into(), scope, kistack }) }; for dir in directories(Path::new(cwd)).into_iter().rev().filter(|d| *d != home) { - for (rel, kind, group) in locations(true) { add(dir.join(rel), kind, group, "", "Project"); } + for (rel, kind, group) in locations(true) { add(dir.join(rel), kind, group, "", "Project", false); } } - for (rel, kind, group) in locations(false) { add(home.join(rel), kind, group, "", "User"); } + // Backplane's pinned KiStack copy takes precedence over user-level copies (such as stale ~/.agents/skills/kicad-*), + // while project-local overrides above still win. + if let Some(k) = &env.kistack { add(k.join("skills"), Kind::Hub, "Backplane", "", "Bundled", true); } + add(env.hub_home.join("kistack/skills"), Kind::Hub, "Backplane", "", "Bundled", true); + for (rel, kind, group) in locations(false) { add(home.join(rel), kind, group, "", "User", false); } let enabled = read_json(&home.join(".claude/settings.json")); let installed = read_json(&home.join(".claude/plugins/installed_plugins.json")); for (key, list) in installed["plugins"].as_object().into_iter().flatten() { @@ -140,17 +144,15 @@ fn roots(env: &Env, cwd: &str) -> Vec { let mut any = false; for i in list.as_array().into_iter().flatten() { let p = PathBuf::from(i["installPath"].as_str().unwrap_or("")); if !p.is_dir() { continue } - any = true; add(p.join("skills"), Kind::ClaudePlugin, &group, plugin, "User"); + any = true; add(p.join("skills"), Kind::ClaudePlugin, &group, plugin, "User", false); } if !any { // the install is gone: a directory marketplace is read where it is - if let Some(m) = enabled["extraKnownMarketplaces"][market]["source"]["path"].as_str() { add(PathBuf::from(m).join("skills"), Kind::ClaudePlugin, &group, plugin, "User"); add(PathBuf::from(m), Kind::ClaudePlugin, &group, plugin, "User"); } + if let Some(m) = enabled["extraKnownMarketplaces"][market]["source"]["path"].as_str() { add(PathBuf::from(m).join("skills"), Kind::ClaudePlugin, &group, plugin, "User", false); add(PathBuf::from(m), Kind::ClaudePlugin, &group, plugin, "User", false); } } } let codex = env.codex_home.as_ref().map(PathBuf::from).unwrap_or_else(|| home.join(".codex")); - add(codex.join("skills"), Kind::Codex, "Codex · yours", "", "User"); - if let Some(k) = &env.kistack { add(k.join("skills"), Kind::Hub, "Backplane", "", "Bundled"); } - add(env.hub_home.join("kistack/skills"), Kind::Hub, "Backplane", "", "Bundled"); - add(env.hub_home.join("skills"), Kind::HubLocal, "Backplane", "", "Bundled"); add(env.hub_home.join("bundled/skills"), Kind::Hub, "Backplane", "", "Bundled"); // bundled.rs dir() + add(codex.join("skills"), Kind::Codex, "Codex · yours", "", "User", false); + add(env.hub_home.join("skills"), Kind::HubLocal, "Backplane", "", "Bundled", false); add(env.hub_home.join("bundled/skills"), Kind::Hub, "Backplane", "", "Bundled", false); // bundled.rs dir() v } @@ -214,9 +216,13 @@ fn applicable(f: &Found, provider: &str, model: &str) -> bool { pub fn for_model(ss: &[Found], provider: &str, model: &str) -> Vec { let mut candidates: Vec<_> = ss.iter().filter(|f| applicable(f, provider, model)).collect(); - // Stable sort keeps the closest directory ahead of its ancestors within the same scope. - candidates.sort_by_key(|f| (match f.scope { "Project" => 0, "User" => 1, _ => 2 }, - f.provider.is_empty() && matches!(f.kind, Kind::Universal | Kind::Agents | Kind::Hub | Kind::HubLocal), f.model_pattern.is_empty())); + // Stable sort keeps the closest directory ahead of its ancestors within the same scope; + // Project > pinned KiStack > User > other Bundled so stale user copies never shadow KiStack. + candidates.sort_by_key(|f| ( + if f.scope == "Project" { 0 } else if f.kistack { 1 } else if f.scope == "User" { 2 } else { 3 }, + f.provider.is_empty() && matches!(f.kind, Kind::Universal | Kind::Agents | Kind::Hub | Kind::HubLocal), + f.model_pattern.is_empty(), + )); let mut seen = std::collections::HashSet::new(); candidates.into_iter().filter(|f| seen.insert(&f.name)).cloned().collect() } @@ -245,7 +251,7 @@ pub fn scan_all(env: &Env, cwd: &str) -> Vec { let s = parse_skill(&t, d.strip_suffix(".md").unwrap_or(&d), &p.to_string_lossy()); let name = if r.plugin.is_empty() { s.name.clone() } else { format!("{}:{}", r.plugin, s.name) }; if out.iter().any(|f| f.path == s.path) { continue } - out.push(Found { name, bare: s.name, description: s.description, path: s.path, group: r.group.clone(), kind: r.kind, provider: s.provider, model_pattern: s.model_pattern, model: s.model, user: s.user, scope: r.scope }); + out.push(Found { name, bare: s.name, description: s.description, path: s.path, group: r.group.clone(), kind: r.kind, provider: s.provider, model_pattern: s.model_pattern, model: s.model, user: s.user, scope: r.scope, kistack: r.kistack }); } } out @@ -285,13 +291,15 @@ pub fn native(f: &Found, provider: &str, isolated: bool) -> bool { ("antigravity", Kind::Gemini) => f.scope == "User", ("pi", Kind::Pi) | ("omp", Kind::Omp | Kind::ClaudeUser | Kind::ClaudeProject | Kind::ClaudePlugin | Kind::Codex) | ("grok", Kind::Grok) | ("opencode", Kind::ClaudeUser | Kind::ClaudeProject) => true, - ("pi", Kind::Hub) => f.path.replace('\\', "/").contains("/kistack/skills/"), + ("pi", Kind::Hub) => f.kistack || f.path.replace('\\', "/").contains("/kistack/skills/"), _ => false, } } -/// A skill word (`$name`, or the bare name of a plugin's skill when only one has it) to its skill. +/// A skill word (`$name`, `kistack:`, or the bare name of a plugin's skill when only one has it) to its skill. pub fn lookup<'a>(ss: &'a [Found], name: &str) -> Option<&'a Found> { - ss.iter().find(|f| f.name == name).or_else(|| { let m: Vec<&Found> = ss.iter().filter(|f| f.bare == name).collect(); if m.len() == 1 { Some(m[0]) } else { None } }) + ss.iter().find(|f| f.name == name) + .or_else(|| name.strip_prefix("kistack:").and_then(|bare| ss.iter().find(|f| f.kistack && f.bare == bare))) + .or_else(|| { let m: Vec<&Found> = ss.iter().filter(|f| f.bare == name).collect(); if m.len() == 1 { Some(m[0]) } else { None } }) } fn as_u(f: &Found) -> USkill { USkill { name: f.name.clone(), description: f.description.clone(), path: f.path.clone(), model: f.model, user: f.user, ..Default::default() } } fn canon(text: &str, ss: &[Found]) -> String { // a bare plugin skill word becomes its full name @@ -427,7 +435,7 @@ mod tests { put(&home, ".claude/skills/new/SKILL.md", &sk("new", "changed text")); assert_eq!(index(&env, "")[0].description, "changed text"); std::fs::remove_dir_all(&t).ok(); } - fn f(n: &str, kind: Kind, group: &str) -> Found { Found { name: n.into(), bare: n.rsplit(':').next().unwrap().into(), description: format!("{n} does things"), path: format!("/s/{n}/SKILL.md"), group: group.into(), kind, provider: String::new(), model_pattern: String::new(), model: true, user: true, scope: "User" } } + fn f(n: &str, kind: Kind, group: &str) -> Found { Found { name: n.into(), bare: n.rsplit(':').next().unwrap().into(), description: format!("{n} does things"), path: format!("/s/{n}/SKILL.md"), group: group.into(), kind, provider: String::new(), model_pattern: String::new(), model: true, user: true, scope: "User", kistack: false } } #[test] fn claude_gets_slash_for_what_it_loads_and_a_file_note_for_the_rest() { let ss = vec![f("unslop", Kind::ClaudeUser, "Claude · yours"), f("cdx", Kind::Codex, "Codex · yours"), f("pk:review", Kind::ClaudePlugin, "p")]; let o = prepare("run $unslop and $cdx then $review and $nope", &ss, "claude", false); diff --git a/native/host/src/agents/tests.rs b/native/host/src/agents/tests.rs index 881c9eaea2..02b1f76866 100644 --- a/native/host/src/agents/tests.rs +++ b/native/host/src/agents/tests.rs @@ -2751,3 +2751,33 @@ impl mailroom::Mailroom for ChatRoom { assert!(posted.iter().any(|e| is(e, "MessagePosted") && e["msg"] == "hm-replay")); ag.shutdown(); } + +#[tokio::test(flavor = "multi_thread")] async fn prompt_for_includes_kistack_and_claude_plugin_exposes_all_pinned_skills() { + let home = dir("kistack-prompt-home"); + let work = dir("kistack-prompt-work"); + std::fs::write(home.join("events.jsonl"), base_log(&work, 1, "")).unwrap(); + let hub = Hub::start(Cfg { home: home.to_path_buf(), version: "0.1.0-dev".into(), commit: "c".into(), listen: "x".into(), os: "linux".into(), arch: "x64".into() }, Arc::new(Canned { reply: json!({}) })).await.unwrap(); + let kistack_dir = kistack::install(&home).expect("install pinned kistack"); + let host = host::HostInfo { home: home.to_path_buf(), kistack: Some(kistack_dir.clone()), ..Default::default() }; + let ag = Agents::start_host(hub.clone(), Cli::standin(&dir("kistack-prompt-bin")), host).await.unwrap(); + + // Even in an empty brand-new project with no .kicad_* files yet, prompt_for includes . + let prompt = ag.prompt_for(T1, &work.to_string_lossy()).await; + assert!(prompt.contains("") && prompt.contains("MANDATORY: Use KiStack as the default skill set"), "{prompt}"); + for expected in ["kicad-schematic", "kicad-layout", "kicad-symbol", "kicad-footprint", "kicad-bom", "kicad-pcb", "kicad-export"] { + assert!(prompt.contains(expected), "prompt missing KiStack skill {expected}"); + } + + // Claude plugin manifest and --plugin-dir wiring expose the pinned KiStack directory cleanly. + let plugin_json: Value = serde_json::from_str(&std::fs::read_to_string(kistack_dir.join(".claude-plugin/plugin.json")).unwrap()).unwrap(); + assert_eq!(plugin_json["name"], "kistack"); + let desc = kistack::describe(&kistack_dir); + for expected in ["kicad-schematic", "kicad-layout", "kicad-symbol", "kicad-footprint", "kicad-bom", "kicad-pcb", "kicad-export"] { + assert!(desc.skills.iter().any(|s| s.0 == expected), "kistack::describe missing {expected}"); + } + let plugins = vec![kistack_dir.to_string_lossy().into_owned()]; + let args = rules::claude_args(&rules::ArgsIn { model: "", session: "", runtime: "full-access", interaction: "default", prompt: &prompt, dirs: &[], effort: "", think: false, plugins: &plugins, mcp_url: "http://127.0.0.1:9/mcp/t1", mcp_json: "", disallowed: &[], speed: "" }); + let i = args.iter().position(|a| a == "--plugin-dir").expect("--plugin-dir flag"); + assert_eq!(args[i + 1], kistack_dir.to_string_lossy()); + ag.shutdown(); +} diff --git a/native/host/src/kicad/kedit.rs b/native/host/src/kicad/kedit.rs index cdcb28788d..e257cbb23d 100644 --- a/native/host/src/kicad/kedit.rs +++ b/native/host/src/kicad/kedit.rs @@ -90,6 +90,121 @@ pub fn file_prop(texts: &[String], reference: &str, name: &str, value: &str) -> false }) } +/// Summary counts of drawn schematic elements across saved `.kicad_sch` texts, used for deterministic quality linting. +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct SchQualityStats { + pub components: usize, + pub power_symbols: usize, + pub labels: usize, + pub connecting_wires: usize, + pub stub_wires: usize, + pub boxes: usize, +} + +fn sx_prop<'a>(x: &'a super::sexpr::Sx<'a>, name: &str) -> &'a str { + x.all("property").find(|p| p.arg(0) == name).map(|p| p.arg(1)).unwrap_or("") +} + +fn sx_xy(x: &super::sexpr::Sx<'_>) -> (f64, f64) { + (x.f(0) as f64, x.f(1) as f64) +} + +fn close_pt(a: (f64, f64), b: (f64, f64), tol: f64) -> bool { + (a.0 - b.0).hypot(a.1 - b.1) <= tol +} + +/// Counts components, labels, stub vs. connecting wires, and subcircuit boxes from saved `.kicad_sch` sheet texts. +pub fn sch_quality_from_texts(texts: &[String]) -> SchQualityStats { + use super::sexpr::{forms, parse}; + let mut stats = SchQualityStats::default(); + for t in texts { + let Some(top_forms) = forms(t.as_bytes()) else { continue }; + let mut stub_anchors: Vec<(f64, f64)> = vec![]; + let mut sheet_wires: Vec<((f64, f64), (f64, f64))> = vec![]; + for raw in top_forms { + let x = parse(raw); + match x.name() { + "symbol" => { + let rf = sx_prop(&x, "Reference"); + if rf.starts_with('#') { + stats.power_symbols += 1; + stub_anchors.push(sx_xy(x.get("at"))); + } else if !rf.is_empty() { + stats.components += 1; + } + } + "label" | "global_label" | "hierarchical_label" => { + stats.labels += 1; + stub_anchors.push(sx_xy(x.get("at"))); + } + "rectangle" | "sheet" => stats.boxes += 1, + "polyline" => { + let pts: Vec<(f64, f64)> = x.get("pts").all("xy").map(|p| sx_xy(p)).collect(); + if pts.len() >= 5 || (pts.len() >= 4 && close_pt(pts[0], pts[pts.len() - 1], 0.05)) { + stats.boxes += 1; + } + } + "wire" => { + let pts: Vec<(f64, f64)> = x.get("pts").all("xy").map(|p| sx_xy(p)).collect(); + for seg in pts.windows(2) { + sheet_wires.push((seg[0], seg[1])); + } + } + _ => {} + } + } + for (a, b) in sheet_wires { + let len = (b.0 - a.0).hypot(b.1 - a.1); + let near_stub = stub_anchors.iter().any(|s| close_pt(a, *s, 0.05) || close_pt(b, *s, 0.05)); + if len <= 3.0 && near_stub { + stats.stub_wires += 1; + } else { + stats.connecting_wires += 1; + } + } + } + stats +} + +/// Emits actionable warnings when a schematic edit looks like a wall-of-labels dump or lacks subcircuit boxes. +pub fn sch_quality_lint(stats: &SchQualityStats, symbols_added: usize, bulk_pin_stubs: usize, explicit_wires_added: usize) -> Option { + let mut warnings = vec![]; + if stats.components >= 3 + && stats.labels >= 6 + && (stats.connecting_wires == 0 + || (stats.connecting_wires < stats.components && stats.labels > stats.connecting_wires * 2)) + { + warnings.push(format!( + "Wall-of-labels schematic detected: {} components and {} net labels, but only {} connecting wire(s) ({} short label/power stub wire(s)). Follow KiStack's kicad-schematic skill: wire passives directly to IC pins with `wire`, group decoupling capacitors onto shared rails, and use net labels only for inter-block buses or distant signals.", + stats.components, stats.labels, stats.connecting_wires, stats.stub_wires + )); + } else if stats.components == 0 && symbols_added >= 3 && bulk_pin_stubs >= 6 && explicit_wires_added == 0 { + warnings.push(format!( + "Bulk pin-label dump detected: added {symbols_added} symbols with {bulk_pin_stubs} pin stubs via `pins: {{...}}` and 0 explicit `wire` entries. Follow KiStack's kicad-schematic skill: wire passives directly to IC pins with `wire`, group decoupling capacitors, and reserve `pins` / labels for power rails or inter-block connections." + )); + } + if stats.components >= 4 && stats.boxes == 0 { + warnings.push(format!( + "No subcircuit boxes detected across {} components. Follow KiStack's kicad-schematic skill: group each subcircuit inside a colored KiCad rectangle with a brief, bold title.", + stats.components + )); + } + if warnings.is_empty() { + return None; + } + Some(json!({ + "warnings": warnings, + "stats": { + "components": stats.components, + "connecting_wires": stats.connecting_wires, + "stub_wires": stats.stub_wires, + "labels": stats.labels, + "boxes": stats.boxes, + }, + "next": "Follow KiStack's kicad-schematic skill before moving on: wire passives directly to IC pins, group decoupling caps, box and label subcircuits, color related nets, run ERC, and visually inspect rendered PNGs (viewer_show / kicad-cli sch export svg -> PNG)." + })) +} + /// A check report's findings as one line each: DRC violations, unconnected items and parity, or ERC violations of every sheet. pub fn findings(report: &Value) -> Vec { let line = |kind: &str, v: &Value| { let items: Vec = v["items"].as_array().into_iter().flatten().map(|i| i["description"].as_str().unwrap_or("").chars().take(70).collect()).collect(); @@ -508,7 +623,9 @@ struct Run<'a> { c: &'a dyn Call, doc: Value, board: bool, commit: Option /// What the saved sheet files must show (reference, property, text), and how many updates KiCad deferred (the person is editing those items). expect: Vec<(String, String, String)>, deferred: usize, /// Copper moved or was added (a route, a placement, a track): every zone is refilled before the save, so no pour is left over the new copper. - refill_all: bool } + refill_all: bool, + /// Schematic `add` quality tracking for wall-of-labels lint. + sch_added: bool, symbols_added: usize, pin_stubs_added: usize, explicit_wires_added: usize } /// Rows a change answers with: what the items are now, so nothing is read again to check it. /// What `from_library` does next after KiCad answered "not found": wait for the library, ask once more at once, or give up (its words, or /// empty for KiCad's own "not found"). @@ -890,6 +1007,10 @@ impl Run<'_> { "add" => { let mut list = match &op["add"] { Value::Array(a) => a.clone(), o => vec![o.clone()] }; let mut note = Map::new(); if !self.board { + self.sch_added = true; + self.explicit_wires_added += list.iter().filter(|it| it["wire"].is_array()).count(); + self.symbols_added += list.iter().filter(|it| it["symbol"].is_object() && !it["symbol"]["ref"].as_str().unwrap_or("").starts_with('#')).count(); + self.pin_stubs_added += list.iter().filter_map(|it| it["symbol"]["pins"].as_object()).map(|m| m.len()).sum::(); // a symbol is placed by KiCad first and a pin is read from the document: both need the changes so far to have landed if list.iter().any(|it| it["symbol"].is_object() || it.to_string().contains('.')) { self.settle(i).await? } let (asked, pwr0) = (list.clone(), self.pwr); list = self.expand(op, asked.clone()).await?; @@ -1133,7 +1254,7 @@ pub async fn run(c: &dyn Call, path: &str, a: &Value) -> Result { if let Some((i, _)) = ops.iter().enumerate().find(|(_, o)| verb(o).is_empty()) { return Err(format!("op {}: an op is one of find, move, set, add, delete, route, place, netclass, rule, refill, ipc", i + 1)) } let patient = Patient { c, step: BUSY_STEP, wait: BUSY_WAIT }; let c: &dyn Call = &patient; let doc = Run::open(c, path).await?; - let mut r = Run { c, expect: vec![], deferred: 0, refill_all: false, planned: Default::default(), added: vec![], lib_kicked: false, pwr: None, touched: vec![], touch_all: false, vacated: vec![], field_fixes: c.caps().iter().any(|x| x == FIELD_FIXES), only: vec![], lib_step: std::time::Duration::from_millis(if cfg!(test) { 1 } else { 500 }), board: path.ends_with(".kicad_pcb"), doc, commit: None, sheets: None, refill: vec![], wrote: false, cache: Default::default(), + let mut r = Run { c, expect: vec![], deferred: 0, refill_all: false, sch_added: false, symbols_added: 0, pin_stubs_added: 0, explicit_wires_added: 0, planned: Default::default(), added: vec![], lib_kicked: false, pwr: None, touched: vec![], touch_all: false, vacated: vec![], field_fixes: c.caps().iter().any(|x| x == FIELD_FIXES), only: vec![], lib_step: std::time::Duration::from_millis(if cfg!(test) { 1 } else { 500 }), board: path.ends_with(".kicad_pcb"), doc, commit: None, sheets: None, refill: vec![], wrote: false, cache: Default::default(), message: a["message"].as_str().unwrap_or("kicad_edit").to_string(), split: 0, templates: Default::default() }; // KiCad's own check before the edit, so the answer can say what the edit added to it (check: false leaves it out) let checking = writes(&a["ops"]) && a["save"].as_bool().unwrap_or(true) && a["check"].as_bool().unwrap_or(true); @@ -1184,6 +1305,13 @@ pub async fn run(c: &dyn Call, path: &str, a: &Value) -> Result { if out["saved"].is_string() && !r.board && !r.added.is_empty() { if let Ok(all) = r.c.nets().await { let m: Map = r.added.iter().filter(|a| all[a.as_str()].is_object()).map(|a| (a.clone(), all[a.as_str()].clone())).collect(); if !m.is_empty() { out["nets"] = Value::Object(m) } } } if out["saved"].is_string() && !before.is_null() { if let Ok(now) = r.c.check().await { if !now.is_null() { out["check"] = check_delta(&before, &now, if r.touch_all || !r.board { &[] } else { &r.touched }) } } } } + if r.wrote && !r.board && r.sch_added { + let texts = if out["saved"].is_string() { r.c.sheet_texts() } else { None }; + let stats = texts.as_deref().map(sch_quality_from_texts).unwrap_or_default(); + if let Some(lint) = sch_quality_lint(&stats, r.symbols_added, r.pin_stubs_added, r.explicit_wires_added) { + out["schematic_lint"] = lint; + } + } Ok(out) } @@ -1656,4 +1784,75 @@ mod tests { assert_eq!(names(&f), ["GetOpenDocuments", "OpenDocument", "GetNets", "BeginCommit", "CreateItems", "EndCommit"]); assert_eq!(sent(&f, "GetNets")["board"]["board_filename"], "b.kicad_pcb"); } + + #[test] fn schematic_quality_lint_flags_wall_of_labels_and_stays_quiet_when_wired_and_boxed() { + // Wall-of-labels sheet: 4 components, 8 labels, only 2.54 mm stub wires ending at labels/power symbols, 0 connecting wires, 0 boxes. + let wall_sheet = r##"(kicad_sch + (symbol (lib_id "MCU:U") (at 50 50 0) (property "Reference" "U1")) + (symbol (lib_id "Device:R") (at 80 50 0) (property "Reference" "R1")) + (symbol (lib_id "Device:C") (at 90 50 0) (property "Reference" "C1")) + (symbol (lib_id "Device:C") (at 100 50 0) (property "Reference" "C2")) + (symbol (lib_id "power:GND") (at 90 56 0) (property "Reference" "#PWR001")) + (wire (pts (xy 80 48) (xy 80 45.46))) + (label "SDA" (at 80 45.46 0)) + (wire (pts (xy 80 52) (xy 80 54.54))) + (label "SCL" (at 80 54.54 0)) + (wire (pts (xy 90 48) (xy 90 45.46))) + (label "+3V3" (at 90 45.46 0)) + (wire (pts (xy 90 53.46) (xy 90 56))) + (label "CS" (at 50 40 0)) + (label "SCK" (at 50 42 0)) + (label "MOSI" (at 50 44 0)) + (label "MISO" (at 50 46 0)) + )"##.to_string(); + let f = Fake { texts: Some(vec![wall_sheet]), ..fake(None) }; + let out = go_on(&f, "/p/b.kicad_sch", json!({"ops": [{"add": [{"symbol": {"lib": "Device:R", "ref": "R2", "at": [110, 50]}}]}]})).unwrap(); + let lint = out.get("schematic_lint").expect("wall-of-labels should emit schematic_lint"); + let warnings: Vec<&str> = lint["warnings"].as_array().unwrap().iter().filter_map(Value::as_str).collect(); + assert!(warnings.iter().any(|w| w.contains("Wall-of-labels schematic detected")), "{warnings:?}"); + assert!(warnings.iter().any(|w| w.contains("No subcircuit boxes detected")), "{warnings:?}"); + assert_eq!(lint["stats"]["components"], 4); + assert_eq!(lint["stats"]["connecting_wires"], 0); + assert_eq!(lint["stats"]["stub_wires"], 4); + assert_eq!(lint["stats"]["labels"], 7); + assert_eq!(lint["stats"]["boxes"], 0); + assert!(lint["next"].as_str().unwrap().contains("kicad-schematic")); + + // Properly wired and boxed schematic: real connecting wires between pins + KiCad rectangle subcircuit box. + let good_sheet = r##"(kicad_sch + (rectangle (start 40 35) (end 115 70)) + (symbol (lib_id "MCU:U") (at 50 50 0) (property "Reference" "U1")) + (symbol (lib_id "Device:R") (at 70 50 0) (property "Reference" "R1")) + (symbol (lib_id "Device:C") (at 85 50 0) (property "Reference" "C1")) + (symbol (lib_id "Device:C") (at 95 50 0) (property "Reference" "C2")) + (symbol (lib_id "power:GND") (at 85 60 0) (property "Reference" "#PWR001")) + (wire (pts (xy 55 50) (xy 70 50))) + (wire (pts (xy 55 52.54) (xy 85 52.54) (xy 85 50))) + (wire (pts (xy 85 55) (xy 95 55))) + (wire (pts (xy 85 55) (xy 85 60))) + (wire (pts (xy 55 47.46) (xy 70 47.46))) + (label "SPI_MOSI" (at 110 47.46 0)) + )"##.to_string(); + let f_good = Fake { texts: Some(vec![good_sheet]), ..fake(None) }; + let out_good = go_on(&f_good, "/p/b.kicad_sch", json!({"ops": [{"add": [{"symbol": {"lib": "Device:R", "ref": "R2", "at": [110, 50]}}]}]})).unwrap(); + assert!(out_good.get("schematic_lint").is_none(), "properly wired & boxed schematic must not warn: {out_good}"); + + // Fallback when sheet_texts() is unavailable (including save: false): bulk pins:{...} dump (>= 3 symbols, >= 6 pin stubs, 0 explicit wires) warns, while 1 IC with 6 pins stays quiet. + let stats_none = SchQualityStats::default(); + let fallback = sch_quality_lint(&stats_none, 3, 6, 0).expect("bulk pin stub fallback should warn"); + assert!(fallback["warnings"][0].as_str().unwrap().contains("Bulk pin-label dump detected"), "{fallback}"); + assert!(sch_quality_lint(&stats_none, 1, 6, 0).is_none(), "single IC with 6 pins should not warn"); + assert!(sch_quality_lint(&stats_none, 3, 6, 1).is_none(), "explicit wire suppresses fallback bulk-stub warning"); + + let f_unsaved = fake(None); + let out_unsaved = go_on(&f_unsaved, "/p/b.kicad_sch", json!({ + "save": false, + "ops": [{"add": [ + {"symbol": {"lib": "Device:R", "ref": "R1", "at": [10, 20], "pins": {"1": "A", "2": "B"}}}, + {"symbol": {"lib": "Device:R", "ref": "R2", "at": [20, 20], "pins": {"1": "C", "2": "D"}}}, + {"symbol": {"lib": "Device:R", "ref": "R3", "at": [30, 20], "pins": {"1": "E", "2": "F"}}} + ]}] + })).unwrap(); + assert!(out_unsaved["schematic_lint"]["warnings"][0].as_str().unwrap().contains("Bulk pin-label dump detected"), "{out_unsaved}"); + } } diff --git a/test/agents/fixtures/argv-default.json b/test/agents/fixtures/argv-default.json index 2004cc9ed2..c657216489 100644 --- a/test/agents/fixtures/argv-default.json +++ b/test/agents/fixtures/argv-default.json @@ -11,7 +11,7 @@ "--disallowedTools", "Agent,Task", "--append-system-prompt", - "In case you're asked: you are running in Backplane through the Backplane harness. Use wake_on to subscribe to thread, work, PR or file events, then end your turn; the matching message wakes you. No need to mention this otherwise. You can embed images and videos in your response using Markdown with absolute file paths.\n\nTo show the user an image (a board render, plot, screenshot or photo), save it as PNG or JPEG and write its absolute path on its own, e.g. /home/h/x.png (no spaces in the path); it's drawn under your message. Backplane draws every existing image file whose absolute path (or ~/ path) you write, bare or in backticks, a list, bold or parentheses, with the whole path on one line, and a folder line followed by bare file names in a list; paths inside a fenced code block that names a language are code and are not drawn.\n\nBackplane hosts a web browser for you: the backplane MCP server's preview_* tools (preview_open, preview_navigate, preview_snapshot, preview_click, preview_type, preview_press, preview_scroll, preview_evaluate, preview_wait_for). The user watches it live in the app's Browser tab. Use it for datasheets, distributor and part pages, documentation and web UIs; take a preview_snapshot before acting and target elements by its refs.\n\n\n- Use the named KiCad design in the main checkout, including referenced sheets. Use the canonical files by default. Backplane routes design tools there and commits saves to main. Use your thread worktree for code, firmware and docs. Create a labeled alternate board only for an experiment the person requests.\n- Always use IPC to inspect and edit KiCad documents. Start with `kicad_edit {path, ops}`: it batches operations into one commit, takes a free document lock, saves and returns the ERC/DRC delta. Use references and millimetres. Use `rule` and `netclass` for rules and net classes. Use raw `kicad_ipc` only for operations it lacks. Never write .kicad_pcb, .kicad_sch, .kicad_pro or .kicad_dru directly or through scripts while KiCad is open.\n- Edits land live and can be undone in KiCad’s Agents panel. Keep the person’s editor open. The result's `person` field shows selections and edits from the last two minutes. Ask before touching those items or their area and continue elsewhere meanwhile. `ISC_DEFERRED` and `IDS_DEFERRED` edits merge after the person finishes their edit. Check `GetNotices` for the result.\n- Backplane releases document locks when your turn ends. Call `lock_acquire` only when a tool directs you. Keep changes scoped and re-read shared items before changing them.\n- Save every meaningful milestone, including unfinished work. `kicad_edit` saves automatically. For raw IPC, send `SaveDocument`. Read back the saved path, open it with `viewer_show` and verify viewer and history match. Preserve companion .backplane.json metadata and report mismatches.\n\n\n\nFor mechanical work, use FreeCAD in `mech/` and follow the bundled `freecad` skill.\nShow the saved STEP with `viewer_show` (kind `mech`). Optional renderer: `/home/h/Documents/i2cjak/backplane-gpui/build/gpui/backplane-serve-current` with `--render`.\nFreeCAD GUI: `/home/h/.local/bin/freecad`. Console: `/home/h/.local/bin/freecadcmd`.\n\n\nInstall Backplane KiCad from Settings to use editing IPC. Use the selected CLI `/home/h/.local/bin/kicad-cli` for exports and standalone ERC/DRC (`sch erc`, `pcb drc`). `kicad-cli` on your PATH and `$BACKPLANE_KICAD_CLI` select the same runtime.\n\nProject root: `/home/h/Documents/i2cjak/backplane-gpui/build/gpui/results/agents/argv2/work/fixroot`. No KiCad project was found in this project (its root, or folders up to four deep). When you create one, give the .kicad_pro, .kicad_pcb and .kicad_sch the same name so Backplane picks them up, or name it in `.backplane.json`.\nA KiCad project may sit in a folder below the root. To choose which one is canonical (the one Backplane's viewers, the Open in KiCad button and this list follow), write `.backplane.json` in the project root: `{\"project\": \"\"}`; its board and schematic are the files beside it with the same name, or name them with the keys `pcb` and `schematic` (paths from the root). Keep any other keys in that file. Backplane reads it at each turn and whenever a viewer opens. To show the user a board, schematic, 3D model or STEP file, call the backplane MCP tool `viewer_show` with its path.\n\n\n- Use `thread_launch` for a continuing subthread, or `delegate_task` for a bounded task with model selection. Use Backplane for delegation and never spawn provider-native subagents. Set `subthread: false` only for an explicitly requested top-level thread.\n- Give a child the context, paths, acceptance criteria and any permission to write canonical design files. Name applicable skills. Keep one writer per design file. `orchestrator_capabilities` lists providers. Models available: claude (fable, opus, sonnet, haiku); codex (gpt-6.1-sol, gpt-6-astra, gpt-6.1-terra, gpt-6-sol, gpt-6-luna, gpt-5.6-sol, gpt-5.6-terra, gpt-5.6-luna).\n- Use `machine_list` to find paired machines. `thread_list` and `thread_launch` accept `machine`. A remote thread ID has form `~` and works with `thread_send`, `thread_read`, `thread_wait`, `thread_interrupt` and `thread_update`. A `>machine:slug` mention names a remote thread.\n\n\n\n- Start long or detached jobs with `work_run`, or register existing work with `work_watch`.\n- For exclusive jobs, pass a named lock to `work_run`. When you need to hold a lock yourself, use `lock_acquire`, await the grant by ending your turn if queued, and call `lock_release` when done.\n- End your turn after starting work or delegating. Backplane wakes you with the result or reports work lost on restart. Avoid polling and sleep-waiting.\n\n\n`.backplane/intent.md` says what the person is building, in their words: `# Goal` (one or two lines), `# Parts` (a line each: the part, its folder, what it is, whether it is to be ordered) and `# Notes` (only what matters: constraints and choices they made). Keep it short and plain; the person reads and edits it on the project card. At the start of each request that says something new about the goal, the parts or a constraint, update it inline; leave it alone otherwise. Delegate substantial work through Backplane subthreads, never provider-native subagents. Never put progress, plans or todo lists in it.\nLay out a new project as `boards//` (one KiCad project per board), `mech/` (mechanical parts: `.py`, `.FCStd`, `.step`), `extra/` (designed here but never ordered: jigs, test fixtures, references) and `mfg/` (generated manufacturing files; never edit by hand). In a project laid out otherwise, offer once to reorganize it; never move files without the person's OK.\nKeep a measured `.fab.json` beside each part to order and refresh its features after design changes.\nRead the bundled `fab-spec` skill for the schema, measurements and material options. Prefer basic and preferred parts from the fab's own stock when choosing components (the pcbparts tools: jlc_search, jlc_stock_check); every BOM line needs its manufacturer part number (an `MPN` field on the symbol). In what you write, call the manufacturer \"the fab\" and its catalog \"the fab's stock\", never by name (no JLC, LCSC or EasyEDA). Ordering happens only through Backplane: once a part's fab file is ready, the person presses Buy it in the thread's header. It opens a buy thread that checks the design, gets the exact quote from Backplane's order server and takes payment. When the person asks to order, buy or price the project, tell them that. Never order yourself unless the person specifically asks for it in their message: on your own, never open, upload to or fill in a manufacturer's website (the Browser tab included) and never start a thread to order with (thread_launch). When they do ask (say, to work the fab's site in their own browser), do it. Never ask for their payment details: they enter those themselves.\nFor manufacturing or order-readiness reviews, read and follow the bundled `manufacturing-review` skill.\n\nBackplane keeps secrets (API keys, auth keys, tokens, passwords) in a vault you never see into. None is set yet. Use one only through the secret_run tool: `env {VAR: name}` puts it in that command's environment, `files {VAR: name}` writes it to a private temporary file whose path is in VAR (e.g. `tailscale up --auth-key=file:$TS`, `gh auth login --with-token < $GH`); its output comes back with any secret masked. Never ask the person to paste a key, token or password in chat, and never put one in a message, a file or a command line: call secret_request {name, purpose} and end your turn; a message tells you when it is set.", + "In case you're asked: you are running in Backplane through the Backplane harness. Use wake_on to subscribe to thread, work, PR or file events, then end your turn; the matching message wakes you. No need to mention this otherwise. You can embed images and videos in your response using Markdown with absolute file paths.\n\nTo show the user an image (a board render, plot, screenshot or photo), save it as PNG or JPEG and write its absolute path on its own, e.g. /home/h/x.png (no spaces in the path); it's drawn under your message. Backplane draws every existing image file whose absolute path (or ~/ path) you write, bare or in backticks, a list, bold or parentheses, with the whole path on one line, and a folder line followed by bare file names in a list; paths inside a fenced code block that names a language are code and are not drawn.\n\nBackplane hosts a web browser for you: the backplane MCP server's preview_* tools (preview_open, preview_navigate, preview_snapshot, preview_click, preview_type, preview_press, preview_scroll, preview_evaluate, preview_wait_for). The user watches it live in the app's Browser tab. Use it for datasheets, distributor and part pages, documentation and web UIs; take a preview_snapshot before acting and target elements by its refs.\n\n\n- Use the named KiCad design in the main checkout, including referenced sheets. Use the canonical files by default. Backplane routes design tools there and commits saves to main. Use your thread worktree for code, firmware and docs. Create a labeled alternate board only for an experiment the person requests.\n- Before creating or editing any KiCad schematic, symbol, footprint, or board, load and follow the matching KiStack skill (from ``, or `kistack:` in Claude). Always use IPC to inspect and edit KiCad documents — start edits with `kicad_edit {path, ops}`: it batches operations into one commit, takes a free document lock, saves and returns the ERC/DRC delta. Use references and millimetres. Use `rule` and `netclass` for rules and net classes. Use raw `kicad_ipc` only for operations it lacks. Never write .kicad_pcb, .kicad_sch, .kicad_pro or .kicad_dru directly or through scripts while KiCad is open.\n- Edits land live and can be undone in KiCad’s Agents panel. Keep the person’s editor open. The result's `person` field shows selections and edits from the last two minutes. Ask before touching those items or their area and continue elsewhere meanwhile. `ISC_DEFERRED` and `IDS_DEFERRED` edits merge after the person finishes their edit. Check `GetNotices` for the result.\n- Backplane releases document locks when your turn ends. Call `lock_acquire` only when a tool directs you. Keep changes scoped and re-read shared items before changing them.\n- Save every meaningful milestone, including unfinished work. `kicad_edit` saves automatically. For raw IPC, send `SaveDocument`. Read back the saved path, open it with `viewer_show` and verify viewer and history match. Preserve companion .backplane.json metadata and report mismatches.\n\n\n\nFor mechanical work, use FreeCAD in `mech/` and follow the bundled `freecad` skill.\nShow the saved STEP with `viewer_show` (kind `mech`). Optional renderer: `/home/h/Documents/i2cjak/backplane-gpui/build/gpui/backplane-serve-current` with `--render`.\nFreeCAD GUI: `/home/h/.local/bin/freecad`. Console: `/home/h/.local/bin/freecadcmd`.\n\n\nInstall Backplane KiCad from Settings to use editing IPC. Use the selected CLI `/home/h/.local/bin/kicad-cli` for exports and standalone ERC/DRC (`sch erc`, `pcb drc`). `kicad-cli` on your PATH and `$BACKPLANE_KICAD_CLI` select the same runtime.\n\nProject root: `/home/h/Documents/i2cjak/backplane-gpui/build/gpui/results/agents/argv2/work/fixroot`. No KiCad project was found in this project (its root, or folders up to four deep). When you create one, give the .kicad_pro, .kicad_pcb and .kicad_sch the same name so Backplane picks them up, or name it in `.backplane.json`.\nA KiCad project may sit in a folder below the root. To choose which one is canonical (the one Backplane's viewers, the Open in KiCad button and this list follow), write `.backplane.json` in the project root: `{\"project\": \"\"}`; its board and schematic are the files beside it with the same name, or name them with the keys `pcb` and `schematic` (paths from the root). Keep any other keys in that file. Backplane reads it at each turn and whenever a viewer opens. To show the user a board, schematic, 3D model or STEP file, call the backplane MCP tool `viewer_show` with its path.\n\n\n- Use `thread_launch` for a continuing subthread, or `delegate_task` for a bounded task with model selection. Use Backplane for delegation and never spawn provider-native subagents. Set `subthread: false` only for an explicitly requested top-level thread.\n- Give a child the context, paths, acceptance criteria and any permission to write canonical design files. Name applicable skills. Keep one writer per design file. `orchestrator_capabilities` lists providers. Models available: claude (fable, opus, sonnet, haiku); codex (gpt-6.1-sol, gpt-6-astra, gpt-6.1-terra, gpt-6-sol, gpt-6-luna, gpt-5.6-sol, gpt-5.6-terra, gpt-5.6-luna).\n- Use `machine_list` to find paired machines. `thread_list` and `thread_launch` accept `machine`. A remote thread ID has form `~` and works with `thread_send`, `thread_read`, `thread_wait`, `thread_interrupt` and `thread_update`. A `>machine:slug` mention names a remote thread.\n\n\n\n- Start long or detached jobs with `work_run`, or register existing work with `work_watch`.\n- For exclusive jobs, pass a named lock to `work_run`. When you need to hold a lock yourself, use `lock_acquire`, await the grant by ending your turn if queued, and call `lock_release` when done.\n- End your turn after starting work or delegating. Backplane wakes you with the result or reports work lost on restart. Avoid polling and sleep-waiting.\n\n\n`.backplane/intent.md` says what the person is building, in their words: `# Goal` (one or two lines), `# Parts` (a line each: the part, its folder, what it is, whether it is to be ordered) and `# Notes` (only what matters: constraints and choices they made). Keep it short and plain; the person reads and edits it on the project card. At the start of each request that says something new about the goal, the parts or a constraint, update it inline; leave it alone otherwise. Delegate substantial work through Backplane subthreads, never provider-native subagents. Never put progress, plans or todo lists in it.\nLay out a new project as `boards//` (one KiCad project per board), `mech/` (mechanical parts: `.py`, `.FCStd`, `.step`), `extra/` (designed here but never ordered: jigs, test fixtures, references) and `mfg/` (generated manufacturing files; never edit by hand). In a project laid out otherwise, offer once to reorganize it; never move files without the person's OK.\nKeep a measured `.fab.json` beside each part to order and refresh its features after design changes.\nRead the bundled `fab-spec` skill for the schema, measurements and material options. Prefer basic and preferred parts from the fab's own stock when choosing components (the pcbparts tools: jlc_search, jlc_stock_check); every BOM line needs its manufacturer part number (an `MPN` field on the symbol). In what you write, call the manufacturer \"the fab\" and its catalog \"the fab's stock\", never by name (no JLC, LCSC or EasyEDA). Ordering happens only through Backplane: once a part's fab file is ready, the person presses Buy it in the thread's header. It opens a buy thread that checks the design, gets the exact quote from Backplane's order server and takes payment. When the person asks to order, buy or price the project, tell them that. Never order yourself unless the person specifically asks for it in their message: on your own, never open, upload to or fill in a manufacturer's website (the Browser tab included) and never start a thread to order with (thread_launch). When they do ask (say, to work the fab's site in their own browser), do it. Never ask for their payment details: they enter those themselves.\nFor manufacturing or order-readiness reviews, read and follow the bundled `manufacturing-review` skill.\n\nBackplane keeps secrets (API keys, auth keys, tokens, passwords) in a vault you never see into. None is set yet. Use one only through the secret_run tool: `env {VAR: name}` puts it in that command's environment, `files {VAR: name}` writes it to a private temporary file whose path is in VAR (e.g. `tailscale up --auth-key=file:$TS`, `gh auth login --with-token < $GH`); its output comes back with any secret masked. Never ask the person to paste a key, token or password in chat, and never put one in a message, a file or a command line: call secret_request {name, purpose} and end your turn; a message tells you when it is set.", "--add-dir", "/home/h/Documents/i2cjak/backplane-gpui/build/gpui/results/agents/argv2/work/home/attachments", "--settings", diff --git a/test/agents/fixtures/mcp-tools.json b/test/agents/fixtures/mcp-tools.json index 57b2f74416..cd0f762093 100644 --- a/test/agents/fixtures/mcp-tools.json +++ b/test/agents/fixtures/mcp-tools.json @@ -1 +1 @@ -{"jsonrpc":"2.0","id":1,"result":{"tools":[{"name":"account_list","description":"List the accounts of this hub with what each has left: the Claude and Codex accounts, then each other provider's own login (Antigravity, Grok, Muse, Oh My Pi, Pi, OpenCode). Each: label, email, plan, state, remainingPercent (null when unknown), usage windows, whether it is held after running out and until when, which one the thread is on, and whether the person pinned that thread. A provider that reports no usage has usageReported false, a note saying so, and what the hub saw (seenToday, lastLimit). Use it to choose an `account` for thread_launch, delegate_task or thread_update.","inputSchema":{"type":"object","properties":{"provider":{"type":"string","description":"claude, codex, antigravity, grok, muse, omp, pi or opencode (default: all)."},"threadId":{"type":"string","description":"The thread to report on (default: this one)."}},"required":[]}},{"name":"settings_inspect","description":"Inspect supported hub-wide provider fallback settings and installed model capabilities. Never returns credentials.","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"settings_propose","description":"Propose a hub-wide fallback change for the person's one-time approval. This never applies the change itself. Do not supply credentials or secrets.","inputSchema":{"type":"object","properties":{"on":{"type":"string","description":"on or off."},"chain":{"type":"string","description":"Comma-separated installed provider/model hierarchy; empty only when off."}},"required":["on","chain"]}},{"name":"orchestrator_capabilities","description":"List the providers and models this Backplane can run, the delegation depth limit, and this thread's own provider, model and depth.","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"delegate_task","description":"Create a bounded subthread by delegating one task to a child agent of THIS thread, on any provider/model (see orchestrator_capabilities). The child sees only `prompt` of this conversation (no history) and works in this thread's directory; like every thread it has Backplane's instructions and the installed skills (KiStack's KiCad skills, the person's) and uses the one its task matches, so name a skill rather than pasting it. Its result arrives in this thread as a message when it finishes, so end your turn instead of polling; use task_status only when you need it mid-turn. Delegation is limited in depth; children of children are allowed up to the limit.","inputSchema":{"type":"object","properties":{"prompt":{"type":"string","description":"The complete task for the child, with every detail it needs."},"provider":{"type":"string","description":"claude, codex, grok, muse, antigravity, opencode, pi or omp (default: this thread's)."},"model":{"type":"string","description":"Model for the child (default: this thread's)."},"title":{"type":"string","description":"Short title for the child thread."},"project":{"type":"string","description":"Bots only, and required for them: the project's name or id (project_list); the child is a thread of its own there that the person can follow."},"account":{"type":"string","description":"The account to run on: its id, email or label (account_list shows them), or default for the CLI's own login. Claude and Codex only; it decides the provider when none is given."}},"required":["prompt"]}},{"name":"task_status","description":"Read a delegated task: state (queued, running, done, failed, cancelled), the child's thread, and its result summary once finished.","inputSchema":{"type":"object","properties":{"taskId":{"type":"string","description":"The task id delegate_task returned."}},"required":["taskId"]}},{"name":"task_cancel","description":"Cancel a running delegated task (stops its child agent). Finished tasks keep their result.","inputSchema":{"type":"object","properties":{"taskId":{"type":"string","description":"The task id."}},"required":["taskId"]}},{"name":"thread_list","description":"List the threads of this thread's project (id, title, provider, model, turn state, and phase: monitoring while work it owns runs after its turn), newest activity first. With `machine` (machine_list shows them), the threads of that other machine of the person's, whose ids work in the thread tools here; `project` narrows it to one project there.","inputSchema":{"type":"object","properties":{"machine":{"type":"string","description":"Another machine's name (or link id): list its threads."},"project":{"type":"string","description":"With machine: a project there, by name or id."}},"required":[]}},{"name":"machine_list","description":"List the person's machines linked to this one (this one first), whether each is here or away, and each one's projects with ids and a `key` (the project across machines: its normalized git remote, else /) you can give thread_launch. A thread elsewhere has an id like ~; thread_send, thread_read, thread_wait, thread_interrupt and thread_update take it, so you can work with a thread on any of their machines.","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"thread_read","description":"Read a thread's status (including turn state) and available timeline in this project (or on another machine, by its ~): messages and tool activity, oldest first (the last `limit` entries). Empty entries alone do not mean stopped or completed; inspect status.turn and status.phase: monitoring means the turn is over but work the thread owns (a background subagent, shell or monitor, or a delegated task) still runs (status.waiting counts it, status.work names it); only complete means nothing is left.","inputSchema":{"type":"object","properties":{"threadId":{"type":"string","description":"The thread to read."},"limit":{"type":"number","description":"How many entries (default 40)."}},"required":["threadId"]}},{"name":"thread_send","description":"Send a message to another thread in this project, or on another machine by its ~. It is delivered at once: an idle thread starts a turn with it, a running turn takes it (Claude at once; Codex, Grok and Muse with their next Backplane tool result, or as a new turn if theirs ends first).","inputSchema":{"type":"object","properties":{"threadId":{"type":"string","description":"The thread."},"text":{"type":"string","description":"The message."}},"required":["threadId","text"]}},{"name":"thread_launch","description":"Create a continuing subthread of this calling thread, with a first message on any provider/model. It nests under its launcher, counts in its subthreads badge, reports back and follows normal auto-settle rules; it can still be opened and messaged on its own. Use subthread false ONLY when the user explicitly requests a top-level conversation. Local subthreads must stay in their launcher’s project; bots and launches on another machine have no local parent. Bots must name the project. Scratch is retired and cannot be a launch target; use a project from machine_list. Answers its threadId. Its reports come to you by themselves, as a message that wakes you: each time its turn ends (completed, failed or interrupted, with its last reply), and at once when it asks the person something; so end your turn instead of polling, and answer it with thread_send. report false launches it without reports; thread_update turns them off or on later. With `machine`, it starts on that other machine of the person's, in its project named by `project` (machine_list). With no `machine`, `project` may be a project's key, git remote or name on any of the person's machines: the hub picks the machine (this one if it has the project, else the one most recently active; one that is away starts it when it is back).","inputSchema":{"type":"object","properties":{"subthread":{"type":"boolean","description":"Nest under this calling thread (default true). False only for an explicitly requested top-level thread; required for cross-project launches."},"prompt":{"type":"string","description":"The first message, complete."},"title":{"type":"string","description":"A short title (default: from the prompt)."},"report":{"type":"boolean","description":"Whether its turn ends and asks are reported to you (default true)."},"provider":{"type":"string","description":"claude, codex, grok, muse, antigravity, opencode, pi or omp (default: the user's default)."},"model":{"type":"string","description":"Model (default: the provider's default)."},"project":{"type":"string","description":"The project's name, id or key (default: this thread's; bots must give one); on another machine its ~ from machine_list. A key, remote or name of a project on another machine starts it there."},"machine":{"type":"string","description":"Start it on another machine of the person's, in its project of that name (machine_list)."},"account":{"type":"string","description":"The account to run on: its id, email or label (account_list shows them), or default for the CLI's own login. Claude and Codex only; it decides the provider when none is given."}},"required":["prompt"]}},{"name":"thread_update","description":"Configure a thread's provider/model between turns without sending a message or starting an agent; answers the saved status. Running turns are rejected. Stopped queued work stays held until a new request or explicit resume. Fresh choices are silent; established history is kept for the next real prompt. With no provider/model: rename with title, regenerate the title with no title, or change a launched thread's reports with report. Give pinned true or false alone to pin a thread to the top of its project in the sidebar or unpin it (a pinned thread never settles by itself). Give parent alone to explicitly move a thread under a conversation in the same project, or empty to move to top level; this persists ThreadParentSet and wins over its launch relationship. Configuration cannot be combined with title/report/parent.","inputSchema":{"type":"object","properties":{"parent":{"type":"string","description":"Explicit parent move (same project); empty moves to top level. Use only when asked to move a thread; give without title/report/provider/model."},"threadId":{"type":"string","description":"The thread (default: this one), or its ~ on another machine."},"provider":{"type":"string","description":"claude, codex, grok, muse, antigravity, opencode, pi or omp. A different provider uses its default model unless model is given; accounts are unchanged."},"model":{"type":"string","description":"Set the selected provider's model; empty selects its default. May be used alone."},"title":{"type":"string","description":"The new title; empty to regenerate it."},"pinned":{"type":"boolean","description":"Pin (true) or unpin (false) the thread in the sidebar. Give alone."},"report":{"type":"boolean","description":"For a thread you launched: whether its reports come to you."},"account":{"type":"string","description":"Move the thread to this account between turns: its id, email or label, or default. The conversation is handed over with its next message. A thread the person pinned to an account moves only when their own latest message names the one you give. Give it without title, report or parent; with provider, it is an account of that provider."}},"required":[]}},{"name":"thread_wait","description":"Wait until a thread in this project has finished its turn, or until timeoutMs passes. Answers its state, whether it is done, and its last reply. For anything longer than a few minutes use wake_on instead and end your turn.","inputSchema":{"type":"object","properties":{"threadId":{"type":"string","description":"The thread."},"timeoutMs":{"type":"number","description":"How long to wait at most (default 30000, at most 600000)."}},"required":["threadId"]}},{"name":"thread_interrupt","description":"Stop the running turn of a thread in this project.","inputSchema":{"type":"object","properties":{"threadId":{"type":"string","description":"The thread."}},"required":["threadId"]}},{"name":"thread_settle","description":"Settle a thread in this project (default: this one): move it out of the active list as done, the same as the Settle button. Use it when the person asks you to settle, once your work is finished.","inputSchema":{"type":"object","properties":{"threadId":{"type":"string","description":"The thread; this thread when left out."}},"required":[]}},{"name":"deploy_restart","description":"Restart the Backplane hub into a new build safely. Answers at once: the restart waits until no thread is inside a tool call (a build, an edit) and the build lock (/tmp/bp-bend.lock) is free, then goes; every turn it cuts resumes by itself. With stage, a directory holding the built package (backplane, backplane-serve, web/ ...) is swapped into the install first. You are woken after the restart with the new version: end your turn, do not wait.","inputSchema":{"type":"object","properties":{"stage":{"type":"string","description":"Absolute path of a staged package to install first (default: the files are already in place)."},"note":{"type":"string","description":"Why, shown to the person."}},"required":[]}},{"name":"deploy_status","description":"Whether a deploy_restart waits, who asked, and what it still waits for (tool calls in flight, the build lock); under main, deploy_main's state (the commit building, staged, live).","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"deploy_main","description":"Deploy origin/main to this machine's hub: the hub fetches it in its source checkout (setting deploy.repo), builds it in a job of its own and restarts into it safely (as deploy_restart). Answers at once: queued, skipped (origin/main is already in the commit being built, staged or live: the answer names it) or not configured. One build runs at a time; requests during it make one more build of the newest origin/main. When the build ends you are told (commit, version, result): end your turn, do not wait or poll.","inputSchema":{"type":"object","properties":{"note":{"type":"string","description":"Why, shown with the request."}},"required":[]}},{"name":"deploy_cancel","description":"Cancel a waiting deploy_restart.","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"viewer_show","description":"Show a file in the user's Backplane viewer panel: a .kicad_pcb on the Board tab (kind 3d: the board in 3D), a .kicad_sch on the Schematic tab, and any .step/.stp or .glb on the Mech tab, the 3D design tab (the model turned in 3D, the project's parts in mech/ beside it, their renders a tap away), wherever the file is. Use it after changing a design so the user sees the result; the viewer also follows the file live.","inputSchema":{"type":"object","properties":{"path":{"type":"string","description":"Absolute path of the file."},"kind":{"type":"string","description":"board, schematic, 3d (a board in 3D) or mech (a STEP or GLB); default from the extension."}},"required":["path"]}},{"name":"kicad_export10","description":"Export an outside-project KiCad 10 copy. First returns a compatibility report; force accepts the reported changes. Never opens a GUI.","inputSchema":{"type":"object","properties":{"path":{"type":"string","description":"Absolute .kicad_pro path."},"force":{"type":"boolean","description":"Accept changes, including dropping blocked approximations (default false)."}},"required":["path"]}},{"name":"terminal_open","description":"Open a terminal in this chat that runs a command (through the user's shell, in this thread's folder) and that the user sees and types into right in the conversation. Use it to hand the user a small tool: a TUI, a picker, an interactive script, a live monitor, a REPL. It answers the terminal's id at once; when the command ends the terminal stays open at the user's shell. Read its screen with terminal_read; what it shows when the user next writes to you comes with their message. It stops (and greys out, a click restarts it) when the user sends another message, unless they pin it.","inputSchema":{"type":"object","properties":{"command":{"type":"string","description":"The command line, e.g. python3 tools/pick.py or htop."},"title":{"type":"string","description":"A short title shown above it."},"cols":{"type":"number","description":"Columns (default 80, 20 to 200)."},"rows":{"type":"number","description":"Rows (default 24, 3 to 60)."}},"required":["command"]}},{"name":"terminal_read","description":"Read a terminal of this chat: its state (running: the command runs; done N: it ended with status N and the shell is open; stopped or exited N: the terminal is closed) and the text on its screen. waitMs waits until the command ends, up to that long, for a script you want the result of.","inputSchema":{"type":"object","properties":{"id":{"type":"string","description":"The id terminal_open answered."},"waitMs":{"type":"number","description":"Wait for the command to end, at most this long (default 0, at most 120000)."}},"required":["id"]}},{"name":"terminal_send","description":"Type into a terminal of this chat, as the user would: text is sent as is (\\r is Enter, \\u0003 is ctrl+c, \\u001b[A is Up).","inputSchema":{"type":"object","properties":{"id":{"type":"string","description":"The terminal's id."},"text":{"type":"string","description":"The bytes to send, as text."}},"required":["id","text"]}},{"name":"terminal_close","description":"Stop a terminal of this chat (its program is hung up; the user can start it again).","inputSchema":{"type":"object","properties":{"id":{"type":"string","description":"The terminal's id."}},"required":["id"]}},{"name":"secret_request","description":"Ask the person for a secret (an API key, auth key, token or password) without it ever passing through the chat or reaching you: they get a masked box in this chat that names you and your purpose, and the value goes straight into Backplane's vault. Answers {secret, set}; when it is not set yet, end your turn: a message tells you once they saved it. Never ask for a secret in a message.","inputSchema":{"type":"object","properties":{"name":{"type":"string","description":"A short name for it, e.g. tailscale-bub or github-token (lower case, digits, - _ .)."},"purpose":{"type":"string","description":"What you need it for, in one line the person reads."}},"required":["name","purpose"]}},{"name":"secret_list","description":"List the secrets in Backplane's vault as handles: [{secret, set, purpose, usedAt}]. You never get a value.","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"secret_run","description":"Run a shell command (in this thread's folder) that uses secrets from the vault without you seeing them: env {VAR: name} puts a secret in the command's environment as $VAR, files {VAR: name} writes it to a private temporary file (removed after) whose path is $VAR, e.g. `tailscale up --auth-key=file:$TS` with files {TS: tailscale-bub}, or `gh auth login --with-token < $GH`. Prefer files over putting $VAR on a command line. Answers {code, stdout, stderr} with every secret masked.","inputSchema":{"type":"object","properties":{"command":{"type":"string","description":"The shell command."},"env":{"type":"object","description":"Environment variable name to secret name.","additionalProperties":{"type":"string"}},"files":{"type":"object","description":"Environment variable (gets the file's path) to secret name.","additionalProperties":{"type":"string"}},"cwd":{"type":"string","description":"Folder to run in (default this thread's)."},"timeout":{"type":"number","description":"Seconds before it is stopped (default 120, at most 600)."}},"required":["command"]}},{"name":"wake_on","description":"Subscribe to a local thread, work id, PR or absolute file path. A matching event posts a message in your thread and wakes you; end your turn instead of polling. Thread targets elsewhere are not supported yet.","inputSchema":{"type":"object","properties":{"kind":{"type":"string","description":"thread, work, pr or file."},"target":{"type":"string","description":"Thread/work id, owner/repo#N (or #N in a project), or absolute path."},"events":{"type":"array","items":{"type":"string"}},"once":{"type":"boolean","description":"Drop after delivery (default true)."},"note":{"type":"string","description":"Include this reminder in the wake message."}},"required":["kind","target"]}},{"name":"wake_list","description":"List your wake subscriptions.","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"wake_cancel","description":"Cancel one of your wake subscriptions.","inputSchema":{"type":"object","properties":{"id":{"type":"string","description":"The subscription id."}},"required":["id"]}},{"name":"work_run","description":"Start long or detached work (a build, a test run, a job on another machine) so Backplane owns it: when it ends you are woken with its exit code and the end of its output; if a restart of Backplane cuts it off you are told it was lost and can start it again. Use this instead of `&`, nohup or disown, then end your turn; never poll or sleep-wait.","inputSchema":{"type":"object","properties":{"command":{"type":"string","description":"The shell command, run in this thread's folder."},"lock":{"type":"string","description":"Optional named FIFO lock, held until work ends."},"note":{"type":"string","description":"What it is, in a few words."},"timeoutSec":{"type":"number","description":"Report a timeout after this many seconds; default 1200 (work.timeout.seconds setting), explicit 0 disables. Work keeps running; never killed."}},"required":["command"]}},{"name":"work_watch","description":"Have Backplane watch work that is already running and wake you when it ends: kind pid (a process) or file (a file that will contain the token this call returns). Then end your turn.","inputSchema":{"type":"object","properties":{"kind":{"type":"string","description":"pid or file."},"target":{"type":"string","description":"The pid, or the file's path."},"note":{"type":"string","description":"What it is."},"timeoutSec":{"type":"number","description":"Report a timeout after this many seconds; default 1200 (work.timeout.seconds setting), explicit 0 disables. Never kills the watched work."}},"required":["kind","target"]}},{"name":"lock_acquire","description":"Acquire a named FIFO lock without blocking; if queued, end your turn and wait for the grant message.","inputSchema":{"type":"object","properties":{"name":{"type":"string","description":"Lock name"},"note":{"type":"string","description":"Purpose"}},"required":["name"]}},{"name":"lock_release","description":"Release your named lock, granting the next waiter.","inputSchema":{"type":"object","properties":{"name":{"type":"string","description":"Lock name"}},"required":["name"]}},{"name":"lock_cancel","description":"Leave a named lock queue.","inputSchema":{"type":"object","properties":{"name":{"type":"string","description":"Lock name"}},"required":["name"]}},{"name":"lock_list","description":"List named lock holders, timestamps, notes and FIFO waiters.","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"work_list","description":"List the work Backplane watches for this thread (work_run and work_watch), with each one's state.","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"work_cancel","description":"Stop work started with work_run (or a watched unit or pid). It shows as cancelling until its end is confirmed.","inputSchema":{"type":"object","properties":{"id":{"type":"string","description":"The work's id."}},"required":["id"]}},{"name":"work_unwatch","description":"Stop watching work without stopping it: it may still run, and you will not be told when it ends.","inputSchema":{"type":"object","properties":{"id":{"type":"string","description":"The work's id."}},"required":["id"]}},{"name":"review_comments","description":"The design review comments on this thread's design (a person's or an agent's, pinned to a place on a board layer or a schematic sheet): the open ones with their replies, and how many are resolved.","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"review_comment","description":"Comment on the design, pinned to a place (op add: file, x, y in mm in the file's own coordinates, layer for a board, text), or answer (op add with parent), resolve, reopen, edit or drop a comment by its id. The person sees it pinned in the viewer.","inputSchema":{"type":"object","properties":{"op":{"type":"string","description":"add, resolve, reopen, edit or drop."},"id":{"type":"string","description":"The comment (resolve, reopen, edit, drop)."},"parent":{"type":"string","description":"The comment answered (an add that is a reply)."},"file":{"type":"string","description":"The board or schematic, from this thread's folder."},"x":{"type":"number","description":"X in mm."},"y":{"type":"number","description":"Y in mm."},"layer":{"type":"string","description":"A board's layer (F.Cu, B.Silkscreen...)."},"text":{"type":"string","description":"What the comment says."}},"required":["op"]}},{"name":"preview_open","description":"Open the Backplane browser (the user sees it live in the app's Browser tab), optionally at a URL. Use it to check web UIs, datasheets, distributor pages and docs.","inputSchema":{"type":"object","properties":{"url":{"type":"string","description":"URL to load; a bare host gets https://, localhost gets http://."},"width":{"type":"number","description":"Viewport width (default 1280)."},"height":{"type":"number","description":"Viewport height (default 800)."}},"required":[]}},{"name":"preview_navigate","description":"Go to a URL in the Backplane browser.","inputSchema":{"type":"object","properties":{"url":{"type":"string","description":"The URL."},"readiness":{"type":"string","description":"load (default), domContentLoaded or none."}},"required":["url"]}},{"name":"preview_snapshot","description":"Read the page: URL, title, visible text, interactive elements and an outline whose [ref=eN] marks are targets for click and type. Snapshot before acting.","inputSchema":{"type":"object","properties":{"screenshot":{"type":"boolean","description":"Also return a PNG screenshot."}},"required":[]}},{"name":"preview_click","description":"Click an element (ref, locator or selector) or a point (x, y in viewport pixels).","inputSchema":{"type":"object","properties":{"ref":{"type":"string","description":"A ref from preview_snapshot's outline, e.g. e5 (preferred)."},"locator":{"type":"string","description":"A Playwright selector, role or text based, e.g. role=button[name='Send'] or text=Continue."},"selector":{"type":"string","description":"A CSS selector."},"timeoutMs":{"type":"number","description":"Timeout in ms (default 15000, at most 60000)."},"x":{"type":"number","description":"X in viewport pixels."},"y":{"type":"number","description":"Y in viewport pixels."}},"required":[]}},{"name":"preview_type","description":"Type text into an element (or the focused one).","inputSchema":{"type":"object","properties":{"ref":{"type":"string","description":"A ref from preview_snapshot's outline, e.g. e5 (preferred)."},"locator":{"type":"string","description":"A Playwright selector, role or text based, e.g. role=button[name='Send'] or text=Continue."},"selector":{"type":"string","description":"A CSS selector."},"timeoutMs":{"type":"number","description":"Timeout in ms (default 15000, at most 60000)."},"text":{"type":"string","description":"The text, inserted literally."},"clear":{"type":"boolean","description":"Clear the field first."}},"required":["text"]}},{"name":"preview_press","description":"Press a key (Enter, Escape, Tab, ArrowDown, Backspace, a...).","inputSchema":{"type":"object","properties":{"key":{"type":"string","description":"Playwright key name."}},"required":["key"]}},{"name":"preview_scroll","description":"Scroll the page (dx, dy in pixels; positive is right/down), or an element with a target.","inputSchema":{"type":"object","properties":{"ref":{"type":"string","description":"A ref from preview_snapshot's outline, e.g. e5 (preferred)."},"locator":{"type":"string","description":"A Playwright selector, role or text based, e.g. role=button[name='Send'] or text=Continue."},"selector":{"type":"string","description":"A CSS selector."},"timeoutMs":{"type":"number","description":"Timeout in ms (default 15000, at most 60000)."},"dx":{"type":"number","description":"Horizontal pixels."},"dy":{"type":"number","description":"Vertical pixels."}},"required":[]}},{"name":"preview_evaluate","description":"Evaluate a JavaScript expression in the page and return its JSON value.","inputSchema":{"type":"object","properties":{"expression":{"type":"string","description":"The expression."}},"required":["expression"]}},{"name":"preview_wait_for","description":"Wait until an element is visible, some text appears, or the URL contains a string.","inputSchema":{"type":"object","properties":{"ref":{"type":"string","description":"A ref from preview_snapshot's outline, e.g. e5 (preferred)."},"locator":{"type":"string","description":"A Playwright selector, role or text based, e.g. role=button[name='Send'] or text=Continue."},"selector":{"type":"string","description":"A CSS selector."},"timeoutMs":{"type":"number","description":"Timeout in ms (default 15000, at most 60000)."},"text":{"type":"string","description":"Text to wait for."},"url":{"type":"string","description":"URL substring to wait for."}},"required":[]}},{"name":"preview_resize","description":"Resize the browser viewport.","inputSchema":{"type":"object","properties":{"width":{"type":"number","description":"Width."},"height":{"type":"number","description":"Height."}},"required":["width","height"]}},{"name":"preview_status","description":"The browser's state: open, URL, title, viewport.","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"kicad_edit","description":"Edit or read a KiCad board or schematic in ONE call: Backplane takes the document's lock, opens it, runs `ops` in order inside one commit, refills the pours, saves, and answers with what KiCad's own DRC with schematic parity (board) or ERC (schematic) now says that it did not say before. Name parts by reference; lengths are mm, angles degrees, layers as KiCad shows them (F.Cu); answers are short rows, never whole items, and say which KiCad served them (served_by: headless, embedded, or both; null when nothing reached KiCad). Prefer it to kicad_ipc and to reading or writing the files. Ops:\n- {route: \"/LED*\" or [nets, or parts \"R3\" / pads \"R3.2\" for the nets on them], width?, layers?: [\"B.Cu\"], vias?: false, ripup?: true}: routes what is unconnected on those nets with tracks at the net class's width (or `width`) that keep its clearance to all other copper, on the layers and with the via kinds the board itself uses (laser micro vias on a board that has them, no drilled via under an IC), straight runs at 0, 45 and 90 degrees with room over the clearance where there is room; ripup takes the nets' old tracks up first. Answers per net: length, vias, layers, or `failed` with why. Do not work out track coordinates yourself.\n- {place: {\"C5\": \"U1.26\", \"C6\": \"U1.31\"}, within: 2}: moves each part next to that pin (its pad on the pin's net within `within` mm; pad: \"1\" to say which), turned to fit, no courtyard over another, pads clear of other nets' copper. Do not search for free places yourself.\n- {set: refs, footprint: \"Lib:Name\"}: on a board, exchanges the footprint (pad 1 stays where it is, rotation, side, fields and each pad's net kept) and answers the pads' new places; on a schematic, sets the symbols' Footprint. Follow it in the same call with {route: refs}: that joins what the new pads left unconnected, and another net's track that now lies on one of those pads is taken up and routed again.\n- {add: [...], sheet?, fit?: [x0, y0, x1, y1]}: board {track: {from, to, width, layer, net}}, {via: {at, size, drill, net, layers?}}; schematic {symbol: {lib: \"Device:C\", ref, value, at, rot, footprint, fields, allow_empty?, pins: {\"1\": \"VCC\", \"2\": \"GND\"}}} (a symbol KiCad gives with no pins and nothing drawn, as an HTTP library part whose source symbol had not loaded, is refused unless allow_empty: true; pins joins each pin, by number or name, to that net with a short wire and the net's power symbol, or a label when the power library has none; the answer gives every pin's place and, from the saved netlist, its net), {wire: [\"U7.2\", [x, y], \"C11.1\"]} (a point may be a pin REF.PIN; between pins it runs square), {label: {text, at, type: local|global|hier}}, {junction: at}, {no_connect: at}; or KiCad's own item with @type. Lay a group of new parts out relative to each other; where it would lie over something of the sheet it is moved as one, on the 1.27 mm grid, to the nearest free room (inside fit: the area it must stay in, when given), and the answer says so: do not read or render the sheet to find room or to check the result.\n- {find: {kind, ...match}}: the rows of a kind (board: footprint, pad, track, arc, via, zone, text, shape, net; schematic: symbol, wire, label, junction, no_connect, sheet). Match any row key (ref, value, net, layer, at, sheet, id ...): text takes * and ?, a list is any-of, near: [x, y, radius]. A pad's row has its copper's size, rot and layer. An answer over about 24 thousand characters stops there and says how many rows are left. fields: true adds a part's fields; raw: true gives KiCad's own items.\n- {move: refs, by: [dx, dy]} or to: [x, y], and/or rot (a symbol's texts move with it).\n- {set: refs or {kind, ...match}, ...row keys}: {set: [\"R1\", \"R2\"], value: \"10k\", fields: {MPN: \"...\"}}; {set: {kind: \"zone\", net: \"GND\"}, clearance: 0.2, min_width: 0.2, name: \"...\", priority: 1}; {set: {kind: \"track\", net: \"+5V\"}, width: 0.3}. raw: {...} merges into KiCad's own item (a placed symbol's library symbol is not changed by set: delete it and add the other).\n- {delete: ids or {kind, ...match}}.\n- {netclass: {name, clearance, track_width, diff_pair_width, diff_pair_gap, via_diameter, via_drill, patterns: [\"/USB*\"]}}: added or changed, the patterns assigned to it (a route after it in the same call uses it).\n- {rule: {name, condition, constraints: [{type: \"clearance\", min: 0.2}], layer, severity}} or {rule: {remove: name}}: custom design rules, by name.\n- {ipc: {type, message}}: any kicad_ipc command in the sequence (\"$doc\" and \"$project\" stand for the document and its project).\nA failing op drops the whole commit and saves nothing. The answer is {results: [one per op], saved: path, check: {new: [findings this edit added, on what it worked on], elsewhere?, left, gone}, nets?, shown}: the save is done and committed, the pours are refilled and the person's viewer shows it, so do not re-read the file, run kicad-cli drc/erc or export a netlist to check it, and do not call viewer_show for it; `check.new` empty means the edit added no violation and no unconnected item; `elsewhere` counts findings on items the edit did not work on that a refill or the save moved, which are not this edit's to chase. saved: false with not_saved says why nothing was written; deferred counts items the person is editing right now (applied when they finish). While the person is working in KiCad a change is answered with what they are doing instead: ask them if it touches that, else repeat the call with person_seen: true.","inputSchema":{"type":"object","properties":{"path":{"type":"string","description":"Absolute path of the board (.kicad_pcb) or schematic (.kicad_sch)."},"ops":{"type":"array","items":{"type":"object"},"description":"The edits, in order."},"message":{"type":"string","description":"What the commit is, in a few words (KiCad's undo history shows it)."},"save":{"type":"boolean","description":"Save after the edits (default true)."},"show":{"type":"boolean","description":"Show the saved document in the person's viewer (default true)."},"person_seen":{"type":"boolean","description":"You have seen what the person is doing in KiCad (the refusal showed it) and this edit does not touch it."},"check":{"type":"boolean","description":"Answer with what KiCad's DRC/ERC says that it did not before (default true)."}},"required":["path","ops"]}},{"name":"kicad_ipc","description":"Send one command to the project's headless KiCad over its IPC API (Backplane starts one KiCad per project). path is the project's .kicad_pro, .kicad_pcb or .kicad_sch (absolute); type is the fully-qualified protobuf command, e.g. kiapi.board.commands.GetItems, kiapi.common.commands.BeginCommit, kiapi.backplane.SketchRoute; message is the command's fields as JSON. The answer is the response as JSON. Headless KiCad has no selection or view state: always pass explicit item IDs (the KIIDs GetItems returns), wrap edits in BeginCommit/EndCommit, then SaveDocument (the viewers follow the saved files). Unsaved work is undone with EndCommit CMA_DROP. Backplane KiCad bp.4 supports partial footprint updates and CreateItems from a symbol library id, with symbol libraries loaded on demand. On runtimes without footprint-partial-update or symbol-from-libid, the hub refuses unsafe requests and explains the workaround: send the full FootprintInstance from GetItems, or LoadAllLibraries, wait for GetLibraryStatuses, then PlaceSymbolFromLibrary. Selection, view and RunAction commands are refused at once. When IPC is unavailable the error says why and names the fallback (edit the file directly or use kicad-cli, then re-read the file). In the person's open KiCad, an edit is saved by Backplane when it lands (an EndCommit that commits, or an item write outside a commit; the answer's `saved`), so a crash never loses it; the save also writes the person's own unsaved edits in that document (`save_note`). Pass save: false on each commit of a batch to save once at its end.","inputSchema":{"type":"object","properties":{"save":{"type":"boolean","description":"false: do not save this change yet (a batch of commits); save before ending the turn."},"path":{"type":"string","description":"Absolute path of the project's .kicad_pro, .kicad_pcb or .kicad_sch."},"type":{"type":"string","description":"The protobuf command, fully qualified (kiapi.board.commands.GetItems)."},"message":{"type":"object","description":"The command's fields as JSON (default {})."}},"required":["path","type"]}},{"name":"kicad_ipc_status","description":"The project's headless KiCad: its server's state (starting, ready, failed or stopped), its version, its start command line (argv), and the capabilities and commands it has (kiapi.backplane.GetCapabilities). Starts the server if it is not running. Headless KiCad has no selection or view state: always pass explicit item IDs (KIIDs from GetItems) in kicad_ipc, wrap edits in BeginCommit/EndCommit, then SaveDocument.","inputSchema":{"type":"object","properties":{"path":{"type":"string","description":"Absolute path of the project's .kicad_pro, .kicad_pcb or .kicad_sch."}},"required":["path"]}},{"name":"kicad_select","description":"Select parts, nets or pins in the person's KiCad editor open in Backplane (and light them in Backplane's Board and Schematic viewers), as a click on a reference in the chat does: use it to point the person at what you mean (\"U3 is the regulator\"). path is the project's .kicad_pro, .kicad_pcb or .kicad_sch (absolute). The answer says whether KiCad is open (kicad) and what it found (found, not_found). With KiCad closed the viewers still light the first part or net.","inputSchema":{"type":"object","properties":{"path":{"type":"string","description":"Absolute path of the project's .kicad_pro, .kicad_pcb or .kicad_sch."},"references":{"type":"array","items":{"type":"string"},"description":"Reference designators, e.g. [\"U3\", \"R12\"]."},"nets":{"type":"array","items":{"type":"string"},"description":"Net names, e.g. [\"GND\", \"/SDA\"]."},"pins":{"type":"array","items":{"type":"string"},"description":"Pins as ., e.g. [\"U3.4\"]."},"zoom":{"type":"boolean","description":"Zoom to what was found (default true)."},"show":{"type":"string","enum":["PCB","SCH"],"description":"Switch the pane to this editor first."}},"required":["path"]}},{"name":"kicad_bring_back","description":"Bring an older thread worktree's design changes (KiCad files, libraries, 3D models, mech/, mfg/, fab files) back to the project's main checkout, where KiCad work now lives. Without mode it only lists what differs; with mode \"apply\" (only once the person agreed) main's copies are backed up to .backplane/backup/ first, the worktree's files are copied in and committed to main, the worktree keeps only code, and the thread works in the main checkout for design files from then on.","inputSchema":{"type":"object","properties":{"thread":{"type":"string","description":"The thread whose worktree to bring back (default: this thread)."},"mode":{"type":"string","enum":["list","apply"],"description":"list (default) or apply."}},"required":[]}},{"name":"altium_status","description":"The person's running Altium Designer (Windows only): its build, the projects and documents open in it, and the focused document. Altium has no headless mode: it must be running on this machine with the project open.","inputSchema":{"type":"object","properties":{}}},{"name":"altium_script","description":"Run a DelphiScript inside the person's running Altium Designer (Windows only) and return what it printed. Write a script as Altium's scripting docs do: an optional `var` (and `const`) section, optional procedures and functions, then statements (no enclosing program or Run procedure; a single outer begin..end is fine). Call Emit(S) to print a line. The whole Altium API is available: GetWorkspace (projects, documents, compile, ERC), SchServer (schematic objects, PreProcess/PostProcess around edits), PCBServer (board objects, iterators, PreProcess/PostProcess), Client.SendMessage / ResetParameters+AddStringParameter+RunProcess (any menu command, e.g. 'PCB:RunDRC', 'WorkspaceManager:Compile', 'WorkspaceManager:SaveObject'). Errors come back as `error` (with Altium's message), not as dialogs. Every loop is cut short at the deadline so Altium never freezes. Edits are left unsaved in Altium (undoable there) unless the script saves; save the document (e.g. Client.SendMessage('WorkspaceManager:SaveObject', 'ObjectKind=Document|FileName=' + Path, 255, Client.CurrentView)) when the person should see it in Backplane's viewers, which read the files.","inputSchema":{"type":"object","properties":{"script":{"type":"string","description":"DelphiScript: [var section] [procedures/functions] statements. Emit(S) prints a line."},"timeout":{"type":"integer","description":"Seconds to wait (default 60, at most 600). Loops are cut short 3 s before it."}},"required":["script"]}},{"name":"altium_write","description":"Make or edit Altium Designer files directly, with no Altium running (any platform): footprints in a .PcbLib, symbols in a .SchLib, schematic sheets (.SchDoc), and the project's document list (.PrjPcb). One JSON spec; its parts run in the order pcblib, schlib, schdoc, project, so one call can make a footprint, the symbol that uses it and a sheet that places it. Paths are relative to the project folder; schematic coordinates are mils (Y up, 100 mil grid), footprint ones mm. pcblib: {path, footprints:[...], remove:[names]}; a footprint is {package: chip (size \"0603\", kind resistor|capacitor|inductor) | soic|sop|tssop|msop (pins, pitch, span, body [w,l], foot, lead, height) | sot23 (pins 3|5|6) | qfn|dfn (pins or nx/ny, pitch, body [x,y], term, lead, ep [w,h]) | header (rows, pins or cols, pitch, drill, pad) | custom (pads:[{number,x,y,w,h,shape rect|round|roundrect|oct,rotation,hole,slot,layer}], body [w,l]), name (default: the IPC-7351 name), description, height, lines:[{layer,from,to,width}]}: IPC-7351B lands, silk clear of copper, assembly outline, courtyard, 3D body. schlib: {path, symbols:[...], remove:[names]}; a symbol is {name, description, designator \"U?\", comment, footprint (name or list; from the pcblib of the same call unless footprint_library), parameters {Name: value}, pins:[{number, name, side left|right|top|bottom, type input|output|io|passive|power|open_collector|open_emitter|hiz, part, inverted, clock, hidden} or {gap:true, side}] (a box sized to them, one per part), or pins with at [x,y] (the wire end) and points left|right|up|down plus shapes:[{kind rect|line|polygon|arc|ellipse|text,...}], or template resistor|capacitor|inductor|diode|led}. A symbol or footprint of the same name is replaced; others are kept as they are. schdoc: {path, size A4|A3|...|Letter (new sheet), remove {parts:[designators], nets:[label/port names], at:[[x,y]]}, place:[{symbol, library (.SchLib path), designator, at [x,y], rotation 0|90|180|270, mirror, part, comment, parameters {}}], set:[{part, name, value, visible}], connect:[{pin \"U1.3\" or \"U1.VIN\", net, power: style|true (ground for GND nets by default), stub}] (a short wire from the pin with a net label or power port; net NC puts a no-ERC mark), wires:[[[x,y],...]], labels:[{net, at, rotation}], power:[{net, at, style bar|arrow|circle|wave|ground|signal_ground|earth, rotation}], junctions:[[x,y]], no_erc:[[x,y]]}. project: a .PrjPcb path; the written files are added to it (made when missing). The result lists what each file now holds, read back through Backplane's readers (pins with their wire ends, pads, parts, nets). If Altium has a written document open, it is reloaded when it has no unsaved edits. Before the first sheet, symbol or footprint, read KiStack's kicad-schematic, kicad-symbol or kicad-footprint SKILL.md completely (paths in ) and lay it out by its rules: this tool writes what the spec says and lays nothing out for you.","inputSchema":{"type":"object","properties":{"pcblib":{"type":"object","description":"{path, footprints:[...], remove:[names]}"},"schlib":{"type":"object","description":"{path, symbols:[...], remove:[names]}"},"schdoc":{"type":"object","description":"{path, size, remove, place, set, connect, wires, labels, power, junctions, no_erc}"},"project":{"type":"string","description":"A .PrjPcb to add the written files to (made when missing)."}},"required":[]}},{"name":"permission_prompt","description":"Internal to Backplane: asks the user before a tool runs. Do not call it yourself.","inputSchema":{"type":"object","properties":{"tool_name":{"type":"string","description":"The tool."},"input":{"type":"object","description":"Its input."},"tool_use_id":{"type":"string","description":"The call."}},"required":["tool_name","input"]}},{"name":"told_check","description":"Before telling the person something (a digest item, a reminder, news), check whether they were already told: by its topic key, or by text (matching words). Answers {told: bool, matches: [{key, text, channel, bot, at, ago}]}. Covers the last 7 days by default (up to 30) on this machine, including every alert already sent (asks, finished work, failures, merges, notify_person notes, which are recorded by themselves). Alerting is notify_person's policy (needs_you, done, or a routine's reminder or digest); this only tells you what was already said.","inputSchema":{"type":"object","properties":{"key":{"type":"string","description":"The topic key, e.g. lunch-dana-1028 (as given to told_mark)."},"text":{"type":"string","description":"The text you are about to say; matched by its words."},"days":{"type":"number","description":"How many days back (default 7, at most 30)."}},"required":[]}},{"name":"told_mark","description":"Record that you told the person something without an alert (in a digest, a room post, a chat answer, your Space, an email), so you and other bots skip it next time. Alerts, notify_person's included, are recorded by themselves. key: a short stable topic key (e.g. lunch-dana-1028); without one, it is made from the text. channel: digest, room, chat, email or other. Answers {key}.","inputSchema":{"type":"object","properties":{"key":{"type":"string","description":"A short stable topic key; made from the text when omitted."},"text":{"type":"string","description":"What you told them, in a sentence."},"channel":{"type":"string","description":"digest, room, chat, email or other (default chat)."}},"required":["text"]}},{"name":"task_board_list","description":"List the shared task board: open items by default (all includes done and dropped). Answers {text, items}: text is one line per item, [status] title (id; @owner; %project; due D; group), and items has the full records.","inputSchema":{"type":"object","properties":{"status":{"type":"string","description":"todo, doing, blocked, done or dropped; several separated by commas."},"owner":{"type":"string","description":"A bot's name or id, me for yourself, or person."},"project":{"type":"string","description":"A project's name or id."},"group":{"type":"string","description":"A section name."},"all":{"type":"boolean","description":"Include done and dropped items."}},"required":[]}},{"name":"task_board_add","description":"Add an item to the shared task board. Answers {id}.","inputSchema":{"type":"object","properties":{"title":{"type":"string","description":"What is to be done (at most 300 characters)."},"status":{"type":"string","description":"todo (default), doing, blocked, done or dropped."},"owner":{"type":"string","description":"A bot's name or id, me for yourself, or person (default)."},"project":{"type":"string","description":"A project's name or id."},"due":{"type":"string","description":"YYYY-MM-DD."},"group":{"type":"string","description":"A section name."},"links":{"type":"string","description":"URLs, thread ids or paths: a JSON array, or a string split on spaces and commas (at most 20)."},"notes":{"type":"string","description":"Notes (at most 4000 characters)."}},"required":["title"]}},{"name":"task_board_update","description":"Change an item on the task board: only the fields you give change. Answers {id}.","inputSchema":{"type":"object","properties":{"id":{"type":"string","description":"The item's id."},"title":{"type":"string","description":"New title."},"status":{"type":"string","description":"todo, doing, blocked, done or dropped."},"owner":{"type":"string","description":"A bot's name or id, me for yourself, or person."},"project":{"type":"string","description":"A project's name or id."},"due":{"type":"string","description":"YYYY-MM-DD, or empty to clear."},"group":{"type":"string","description":"A section name."},"links":{"type":"string","description":"Replaces the links: a JSON array, or a string split on spaces and commas."},"notes":{"type":"string","description":"Replaces the notes."},"notes_append":{"type":"string","description":"A line added to the notes."}},"required":["id"]}},{"name":"task_board_remove","description":"Delete an item from the task board for good. Prefer task_board_update with status dropped, which keeps a record.","inputSchema":{"type":"object","properties":{"id":{"type":"string","description":"The item's id."}},"required":["id"]}},{"name":"task_board_import","description":"Import a markdown todo list (checkbox items `- [ ]`, `- [x]`, `- [~]`; headings become groups). Lines without a checkbox are not imported and are returned as `skipped`. Importing the same list again adds nothing. Answers {added, duplicates, skipped}.","inputSchema":{"type":"object","properties":{"markdown":{"type":"string","description":"The list."},"project":{"type":"string","description":"Put every item in this project (a name or id)."},"owner":{"type":"string","description":"A bot's name or id, me for yourself, or person (default)."}},"required":["markdown"]}},{"name":"order_review","description":"The project's manufacturing review. gate (a buy thread, before exporting): Backplane checks the review and, unless it is current and passed, shows the person why and asks them; answers what it did. check: whether the design (its boards, schematics, models and fab files) was reviewed since it last changed; answers state (none, stale or current), verdict, summary and issues. record: after a manufacturing review, keep its verdict (ok or issues), a one-line summary and the issues, one short line each, with the design as it is now.","inputSchema":{"type":"object","properties":{"action":{"type":"string","description":"gate, check or record"},"verdict":{"type":"string","description":"record: ok or issues"},"summary":{"type":"string","description":"record: one line"},"issues":{"type":"array","items":{"type":"string"},"description":"record: what must change, one short line each (\"Shade: walls 0.6 mm, need 0.8\"), at most 8; none when ok."}},"required":["action"]}},{"name":"thread_reply","description":"Say something to the person in this thread now, while your turn goes on: the answer to a message they sent while you work, or a short status. It is posted at once as your message in the thread, and your work carries on after it. Use it before your next other tool call when the person asked you something mid-turn; your final answer still goes in your reply as usual.","inputSchema":{"type":"object","properties":{"text":{"type":"string","description":"What to say to the person, in plain words (markdown)."}},"required":["text"]}}]}} \ No newline at end of file +{"jsonrpc":"2.0","id":1,"result":{"tools":[{"name":"account_list","description":"List the accounts of this hub with what each has left: the Claude and Codex accounts, then each other provider's own login (Antigravity, Grok, Muse, Oh My Pi, Pi, OpenCode). Each: label, email, plan, state, remainingPercent (null when unknown), usage windows, whether it is held after running out and until when, which one the thread is on, and whether the person pinned that thread. A provider that reports no usage has usageReported false, a note saying so, and what the hub saw (seenToday, lastLimit). Use it to choose an `account` for thread_launch, delegate_task or thread_update.","inputSchema":{"type":"object","properties":{"provider":{"type":"string","description":"claude, codex, antigravity, grok, muse, omp, pi or opencode (default: all)."},"threadId":{"type":"string","description":"The thread to report on (default: this one)."}},"required":[]}},{"name":"settings_inspect","description":"Inspect supported hub-wide provider fallback settings and installed model capabilities. Never returns credentials.","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"settings_propose","description":"Propose a hub-wide fallback change for the person's one-time approval. This never applies the change itself. Do not supply credentials or secrets.","inputSchema":{"type":"object","properties":{"on":{"type":"string","description":"on or off."},"chain":{"type":"string","description":"Comma-separated installed provider/model hierarchy; empty only when off."}},"required":["on","chain"]}},{"name":"orchestrator_capabilities","description":"List the providers and models this Backplane can run, the delegation depth limit, and this thread's own provider, model and depth.","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"delegate_task","description":"Create a bounded subthread by delegating one task to a child agent of THIS thread, on any provider/model (see orchestrator_capabilities). The child sees only `prompt` of this conversation (no history) and works in this thread's directory; like every thread it has Backplane's instructions and the installed skills (KiStack's KiCad skills, the person's) and uses the one its task matches, so name a skill rather than pasting it. Its result arrives in this thread as a message when it finishes, so end your turn instead of polling; use task_status only when you need it mid-turn. Delegation is limited in depth; children of children are allowed up to the limit.","inputSchema":{"type":"object","properties":{"prompt":{"type":"string","description":"The complete task for the child, with every detail it needs."},"provider":{"type":"string","description":"claude, codex, grok, muse, antigravity, opencode, pi or omp (default: this thread's)."},"model":{"type":"string","description":"Model for the child (default: this thread's)."},"title":{"type":"string","description":"Short title for the child thread."},"project":{"type":"string","description":"Bots only, and required for them: the project's name or id (project_list); the child is a thread of its own there that the person can follow."},"account":{"type":"string","description":"The account to run on: its id, email or label (account_list shows them), or default for the CLI's own login. Claude and Codex only; it decides the provider when none is given."}},"required":["prompt"]}},{"name":"task_status","description":"Read a delegated task: state (queued, running, done, failed, cancelled), the child's thread, and its result summary once finished.","inputSchema":{"type":"object","properties":{"taskId":{"type":"string","description":"The task id delegate_task returned."}},"required":["taskId"]}},{"name":"task_cancel","description":"Cancel a running delegated task (stops its child agent). Finished tasks keep their result.","inputSchema":{"type":"object","properties":{"taskId":{"type":"string","description":"The task id."}},"required":["taskId"]}},{"name":"thread_list","description":"List the threads of this thread's project (id, title, provider, model, turn state, and phase: monitoring while work it owns runs after its turn), newest activity first. With `machine` (machine_list shows them), the threads of that other machine of the person's, whose ids work in the thread tools here; `project` narrows it to one project there.","inputSchema":{"type":"object","properties":{"machine":{"type":"string","description":"Another machine's name (or link id): list its threads."},"project":{"type":"string","description":"With machine: a project there, by name or id."}},"required":[]}},{"name":"machine_list","description":"List the person's machines linked to this one (this one first), whether each is here or away, and each one's projects with ids and a `key` (the project across machines: its normalized git remote, else /) you can give thread_launch. A thread elsewhere has an id like ~; thread_send, thread_read, thread_wait, thread_interrupt and thread_update take it, so you can work with a thread on any of their machines.","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"thread_read","description":"Read a thread's status (including turn state) and available timeline in this project (or on another machine, by its ~): messages and tool activity, oldest first (the last `limit` entries). Empty entries alone do not mean stopped or completed; inspect status.turn and status.phase: monitoring means the turn is over but work the thread owns (a background subagent, shell or monitor, or a delegated task) still runs (status.waiting counts it, status.work names it); only complete means nothing is left.","inputSchema":{"type":"object","properties":{"threadId":{"type":"string","description":"The thread to read."},"limit":{"type":"number","description":"How many entries (default 40)."}},"required":["threadId"]}},{"name":"thread_send","description":"Send a message to another thread in this project, or on another machine by its ~. It is delivered at once: an idle thread starts a turn with it, a running turn takes it (Claude at once; Codex, Grok and Muse with their next Backplane tool result, or as a new turn if theirs ends first).","inputSchema":{"type":"object","properties":{"threadId":{"type":"string","description":"The thread."},"text":{"type":"string","description":"The message."}},"required":["threadId","text"]}},{"name":"thread_launch","description":"Create a continuing subthread of this calling thread, with a first message on any provider/model. It nests under its launcher, counts in its subthreads badge, reports back and follows normal auto-settle rules; it can still be opened and messaged on its own. Use subthread false ONLY when the user explicitly requests a top-level conversation. Local subthreads must stay in their launcher\u2019s project; bots and launches on another machine have no local parent. Bots must name the project. Scratch is retired and cannot be a launch target; use a project from machine_list. Answers its threadId. Its reports come to you by themselves, as a message that wakes you: each time its turn ends (completed, failed or interrupted, with its last reply), and at once when it asks the person something; so end your turn instead of polling, and answer it with thread_send. report false launches it without reports; thread_update turns them off or on later. With `machine`, it starts on that other machine of the person's, in its project named by `project` (machine_list). With no `machine`, `project` may be a project's key, git remote or name on any of the person's machines: the hub picks the machine (this one if it has the project, else the one most recently active; one that is away starts it when it is back).","inputSchema":{"type":"object","properties":{"subthread":{"type":"boolean","description":"Nest under this calling thread (default true). False only for an explicitly requested top-level thread; required for cross-project launches."},"prompt":{"type":"string","description":"The first message, complete."},"title":{"type":"string","description":"A short title (default: from the prompt)."},"report":{"type":"boolean","description":"Whether its turn ends and asks are reported to you (default true)."},"provider":{"type":"string","description":"claude, codex, grok, muse, antigravity, opencode, pi or omp (default: the user's default)."},"model":{"type":"string","description":"Model (default: the provider's default)."},"project":{"type":"string","description":"The project's name, id or key (default: this thread's; bots must give one); on another machine its ~ from machine_list. A key, remote or name of a project on another machine starts it there."},"machine":{"type":"string","description":"Start it on another machine of the person's, in its project of that name (machine_list)."},"account":{"type":"string","description":"The account to run on: its id, email or label (account_list shows them), or default for the CLI's own login. Claude and Codex only; it decides the provider when none is given."}},"required":["prompt"]}},{"name":"thread_update","description":"Configure a thread's provider/model between turns without sending a message or starting an agent; answers the saved status. Running turns are rejected. Stopped queued work stays held until a new request or explicit resume. Fresh choices are silent; established history is kept for the next real prompt. With no provider/model: rename with title, regenerate the title with no title, or change a launched thread's reports with report. Give pinned true or false alone to pin a thread to the top of its project in the sidebar or unpin it (a pinned thread never settles by itself). Give parent alone to explicitly move a thread under a conversation in the same project, or empty to move to top level; this persists ThreadParentSet and wins over its launch relationship. Configuration cannot be combined with title/report/parent.","inputSchema":{"type":"object","properties":{"parent":{"type":"string","description":"Explicit parent move (same project); empty moves to top level. Use only when asked to move a thread; give without title/report/provider/model."},"threadId":{"type":"string","description":"The thread (default: this one), or its ~ on another machine."},"provider":{"type":"string","description":"claude, codex, grok, muse, antigravity, opencode, pi or omp. A different provider uses its default model unless model is given; accounts are unchanged."},"model":{"type":"string","description":"Set the selected provider's model; empty selects its default. May be used alone."},"title":{"type":"string","description":"The new title; empty to regenerate it."},"pinned":{"type":"boolean","description":"Pin (true) or unpin (false) the thread in the sidebar. Give alone."},"report":{"type":"boolean","description":"For a thread you launched: whether its reports come to you."},"account":{"type":"string","description":"Move the thread to this account between turns: its id, email or label, or default. The conversation is handed over with its next message. A thread the person pinned to an account moves only when their own latest message names the one you give. Give it without title, report or parent; with provider, it is an account of that provider."}},"required":[]}},{"name":"thread_wait","description":"Wait until a thread in this project has finished its turn, or until timeoutMs passes. Answers its state, whether it is done, and its last reply. For anything longer than a few minutes use wake_on instead and end your turn.","inputSchema":{"type":"object","properties":{"threadId":{"type":"string","description":"The thread."},"timeoutMs":{"type":"number","description":"How long to wait at most (default 30000, at most 600000)."}},"required":["threadId"]}},{"name":"thread_interrupt","description":"Stop the running turn of a thread in this project.","inputSchema":{"type":"object","properties":{"threadId":{"type":"string","description":"The thread."}},"required":["threadId"]}},{"name":"thread_settle","description":"Settle a thread in this project (default: this one): move it out of the active list as done, the same as the Settle button. Use it when the person asks you to settle, once your work is finished.","inputSchema":{"type":"object","properties":{"threadId":{"type":"string","description":"The thread; this thread when left out."}},"required":[]}},{"name":"deploy_restart","description":"Restart the Backplane hub into a new build safely. Answers at once: the restart waits until no thread is inside a tool call (a build, an edit) and the build lock (/tmp/bp-bend.lock) is free, then goes; every turn it cuts resumes by itself. With stage, a directory holding the built package (backplane, backplane-serve, web/ ...) is swapped into the install first. You are woken after the restart with the new version: end your turn, do not wait.","inputSchema":{"type":"object","properties":{"stage":{"type":"string","description":"Absolute path of a staged package to install first (default: the files are already in place)."},"note":{"type":"string","description":"Why, shown to the person."}},"required":[]}},{"name":"deploy_status","description":"Whether a deploy_restart waits, who asked, and what it still waits for (tool calls in flight, the build lock); under main, deploy_main's state (the commit building, staged, live).","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"deploy_main","description":"Deploy origin/main to this machine's hub: the hub fetches it in its source checkout (setting deploy.repo), builds it in a job of its own and restarts into it safely (as deploy_restart). Answers at once: queued, skipped (origin/main is already in the commit being built, staged or live: the answer names it) or not configured. One build runs at a time; requests during it make one more build of the newest origin/main. When the build ends you are told (commit, version, result): end your turn, do not wait or poll.","inputSchema":{"type":"object","properties":{"note":{"type":"string","description":"Why, shown with the request."}},"required":[]}},{"name":"deploy_cancel","description":"Cancel a waiting deploy_restart.","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"viewer_show","description":"Show a file in the user's Backplane viewer panel: a .kicad_pcb on the Board tab (kind 3d: the board in 3D), a .kicad_sch on the Schematic tab, and any .step/.stp or .glb on the Mech tab, the 3D design tab (the model turned in 3D, the project's parts in mech/ beside it, their renders a tap away), wherever the file is. Use it after changing a design so the user sees the result; the viewer also follows the file live.","inputSchema":{"type":"object","properties":{"path":{"type":"string","description":"Absolute path of the file."},"kind":{"type":"string","description":"board, schematic, 3d (a board in 3D) or mech (a STEP or GLB); default from the extension."}},"required":["path"]}},{"name":"kicad_export10","description":"Export an outside-project KiCad 10 copy. First returns a compatibility report; force accepts the reported changes. Never opens a GUI.","inputSchema":{"type":"object","properties":{"path":{"type":"string","description":"Absolute .kicad_pro path."},"force":{"type":"boolean","description":"Accept changes, including dropping blocked approximations (default false)."}},"required":["path"]}},{"name":"terminal_open","description":"Open a terminal in this chat that runs a command (through the user's shell, in this thread's folder) and that the user sees and types into right in the conversation. Use it to hand the user a small tool: a TUI, a picker, an interactive script, a live monitor, a REPL. It answers the terminal's id at once; when the command ends the terminal stays open at the user's shell. Read its screen with terminal_read; what it shows when the user next writes to you comes with their message. It stops (and greys out, a click restarts it) when the user sends another message, unless they pin it.","inputSchema":{"type":"object","properties":{"command":{"type":"string","description":"The command line, e.g. python3 tools/pick.py or htop."},"title":{"type":"string","description":"A short title shown above it."},"cols":{"type":"number","description":"Columns (default 80, 20 to 200)."},"rows":{"type":"number","description":"Rows (default 24, 3 to 60)."}},"required":["command"]}},{"name":"terminal_read","description":"Read a terminal of this chat: its state (running: the command runs; done N: it ended with status N and the shell is open; stopped or exited N: the terminal is closed) and the text on its screen. waitMs waits until the command ends, up to that long, for a script you want the result of.","inputSchema":{"type":"object","properties":{"id":{"type":"string","description":"The id terminal_open answered."},"waitMs":{"type":"number","description":"Wait for the command to end, at most this long (default 0, at most 120000)."}},"required":["id"]}},{"name":"terminal_send","description":"Type into a terminal of this chat, as the user would: text is sent as is (\\r is Enter, \\u0003 is ctrl+c, \\u001b[A is Up).","inputSchema":{"type":"object","properties":{"id":{"type":"string","description":"The terminal's id."},"text":{"type":"string","description":"The bytes to send, as text."}},"required":["id","text"]}},{"name":"terminal_close","description":"Stop a terminal of this chat (its program is hung up; the user can start it again).","inputSchema":{"type":"object","properties":{"id":{"type":"string","description":"The terminal's id."}},"required":["id"]}},{"name":"secret_request","description":"Ask the person for a secret (an API key, auth key, token or password) without it ever passing through the chat or reaching you: they get a masked box in this chat that names you and your purpose, and the value goes straight into Backplane's vault. Answers {secret, set}; when it is not set yet, end your turn: a message tells you once they saved it. Never ask for a secret in a message.","inputSchema":{"type":"object","properties":{"name":{"type":"string","description":"A short name for it, e.g. tailscale-bub or github-token (lower case, digits, - _ .)."},"purpose":{"type":"string","description":"What you need it for, in one line the person reads."}},"required":["name","purpose"]}},{"name":"secret_list","description":"List the secrets in Backplane's vault as handles: [{secret, set, purpose, usedAt}]. You never get a value.","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"secret_run","description":"Run a shell command (in this thread's folder) that uses secrets from the vault without you seeing them: env {VAR: name} puts a secret in the command's environment as $VAR, files {VAR: name} writes it to a private temporary file (removed after) whose path is $VAR, e.g. `tailscale up --auth-key=file:$TS` with files {TS: tailscale-bub}, or `gh auth login --with-token < $GH`. Prefer files over putting $VAR on a command line. Answers {code, stdout, stderr} with every secret masked.","inputSchema":{"type":"object","properties":{"command":{"type":"string","description":"The shell command."},"env":{"type":"object","description":"Environment variable name to secret name.","additionalProperties":{"type":"string"}},"files":{"type":"object","description":"Environment variable (gets the file's path) to secret name.","additionalProperties":{"type":"string"}},"cwd":{"type":"string","description":"Folder to run in (default this thread's)."},"timeout":{"type":"number","description":"Seconds before it is stopped (default 120, at most 600)."}},"required":["command"]}},{"name":"wake_on","description":"Subscribe to a local thread, work id, PR or absolute file path. A matching event posts a message in your thread and wakes you; end your turn instead of polling. Thread targets elsewhere are not supported yet.","inputSchema":{"type":"object","properties":{"kind":{"type":"string","description":"thread, work, pr or file."},"target":{"type":"string","description":"Thread/work id, owner/repo#N (or #N in a project), or absolute path."},"events":{"type":"array","items":{"type":"string"}},"once":{"type":"boolean","description":"Drop after delivery (default true)."},"note":{"type":"string","description":"Include this reminder in the wake message."}},"required":["kind","target"]}},{"name":"wake_list","description":"List your wake subscriptions.","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"wake_cancel","description":"Cancel one of your wake subscriptions.","inputSchema":{"type":"object","properties":{"id":{"type":"string","description":"The subscription id."}},"required":["id"]}},{"name":"work_run","description":"Start long or detached work (a build, a test run, a job on another machine) so Backplane owns it: when it ends you are woken with its exit code and the end of its output; if a restart of Backplane cuts it off you are told it was lost and can start it again. Use this instead of `&`, nohup or disown, then end your turn; never poll or sleep-wait.","inputSchema":{"type":"object","properties":{"command":{"type":"string","description":"The shell command, run in this thread's folder."},"lock":{"type":"string","description":"Optional named FIFO lock, held until work ends."},"note":{"type":"string","description":"What it is, in a few words."},"timeoutSec":{"type":"number","description":"Report a timeout after this many seconds; default 1200 (work.timeout.seconds setting), explicit 0 disables. Work keeps running; never killed."}},"required":["command"]}},{"name":"work_watch","description":"Have Backplane watch work that is already running and wake you when it ends: kind pid (a process) or file (a file that will contain the token this call returns). Then end your turn.","inputSchema":{"type":"object","properties":{"kind":{"type":"string","description":"pid or file."},"target":{"type":"string","description":"The pid, or the file's path."},"note":{"type":"string","description":"What it is."},"timeoutSec":{"type":"number","description":"Report a timeout after this many seconds; default 1200 (work.timeout.seconds setting), explicit 0 disables. Never kills the watched work."}},"required":["kind","target"]}},{"name":"lock_acquire","description":"Acquire a named FIFO lock without blocking; if queued, end your turn and wait for the grant message.","inputSchema":{"type":"object","properties":{"name":{"type":"string","description":"Lock name"},"note":{"type":"string","description":"Purpose"}},"required":["name"]}},{"name":"lock_release","description":"Release your named lock, granting the next waiter.","inputSchema":{"type":"object","properties":{"name":{"type":"string","description":"Lock name"}},"required":["name"]}},{"name":"lock_cancel","description":"Leave a named lock queue.","inputSchema":{"type":"object","properties":{"name":{"type":"string","description":"Lock name"}},"required":["name"]}},{"name":"lock_list","description":"List named lock holders, timestamps, notes and FIFO waiters.","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"work_list","description":"List the work Backplane watches for this thread (work_run and work_watch), with each one's state.","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"work_cancel","description":"Stop work started with work_run (or a watched unit or pid). It shows as cancelling until its end is confirmed.","inputSchema":{"type":"object","properties":{"id":{"type":"string","description":"The work's id."}},"required":["id"]}},{"name":"work_unwatch","description":"Stop watching work without stopping it: it may still run, and you will not be told when it ends.","inputSchema":{"type":"object","properties":{"id":{"type":"string","description":"The work's id."}},"required":["id"]}},{"name":"review_comments","description":"The design review comments on this thread's design (a person's or an agent's, pinned to a place on a board layer or a schematic sheet): the open ones with their replies, and how many are resolved.","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"review_comment","description":"Comment on the design, pinned to a place (op add: file, x, y in mm in the file's own coordinates, layer for a board, text), or answer (op add with parent), resolve, reopen, edit or drop a comment by its id. The person sees it pinned in the viewer.","inputSchema":{"type":"object","properties":{"op":{"type":"string","description":"add, resolve, reopen, edit or drop."},"id":{"type":"string","description":"The comment (resolve, reopen, edit, drop)."},"parent":{"type":"string","description":"The comment answered (an add that is a reply)."},"file":{"type":"string","description":"The board or schematic, from this thread's folder."},"x":{"type":"number","description":"X in mm."},"y":{"type":"number","description":"Y in mm."},"layer":{"type":"string","description":"A board's layer (F.Cu, B.Silkscreen...)."},"text":{"type":"string","description":"What the comment says."}},"required":["op"]}},{"name":"preview_open","description":"Open the Backplane browser (the user sees it live in the app's Browser tab), optionally at a URL. Use it to check web UIs, datasheets, distributor pages and docs.","inputSchema":{"type":"object","properties":{"url":{"type":"string","description":"URL to load; a bare host gets https://, localhost gets http://."},"width":{"type":"number","description":"Viewport width (default 1280)."},"height":{"type":"number","description":"Viewport height (default 800)."}},"required":[]}},{"name":"preview_navigate","description":"Go to a URL in the Backplane browser.","inputSchema":{"type":"object","properties":{"url":{"type":"string","description":"The URL."},"readiness":{"type":"string","description":"load (default), domContentLoaded or none."}},"required":["url"]}},{"name":"preview_snapshot","description":"Read the page: URL, title, visible text, interactive elements and an outline whose [ref=eN] marks are targets for click and type. Snapshot before acting.","inputSchema":{"type":"object","properties":{"screenshot":{"type":"boolean","description":"Also return a PNG screenshot."}},"required":[]}},{"name":"preview_click","description":"Click an element (ref, locator or selector) or a point (x, y in viewport pixels).","inputSchema":{"type":"object","properties":{"ref":{"type":"string","description":"A ref from preview_snapshot's outline, e.g. e5 (preferred)."},"locator":{"type":"string","description":"A Playwright selector, role or text based, e.g. role=button[name='Send'] or text=Continue."},"selector":{"type":"string","description":"A CSS selector."},"timeoutMs":{"type":"number","description":"Timeout in ms (default 15000, at most 60000)."},"x":{"type":"number","description":"X in viewport pixels."},"y":{"type":"number","description":"Y in viewport pixels."}},"required":[]}},{"name":"preview_type","description":"Type text into an element (or the focused one).","inputSchema":{"type":"object","properties":{"ref":{"type":"string","description":"A ref from preview_snapshot's outline, e.g. e5 (preferred)."},"locator":{"type":"string","description":"A Playwright selector, role or text based, e.g. role=button[name='Send'] or text=Continue."},"selector":{"type":"string","description":"A CSS selector."},"timeoutMs":{"type":"number","description":"Timeout in ms (default 15000, at most 60000)."},"text":{"type":"string","description":"The text, inserted literally."},"clear":{"type":"boolean","description":"Clear the field first."}},"required":["text"]}},{"name":"preview_press","description":"Press a key (Enter, Escape, Tab, ArrowDown, Backspace, a...).","inputSchema":{"type":"object","properties":{"key":{"type":"string","description":"Playwright key name."}},"required":["key"]}},{"name":"preview_scroll","description":"Scroll the page (dx, dy in pixels; positive is right/down), or an element with a target.","inputSchema":{"type":"object","properties":{"ref":{"type":"string","description":"A ref from preview_snapshot's outline, e.g. e5 (preferred)."},"locator":{"type":"string","description":"A Playwright selector, role or text based, e.g. role=button[name='Send'] or text=Continue."},"selector":{"type":"string","description":"A CSS selector."},"timeoutMs":{"type":"number","description":"Timeout in ms (default 15000, at most 60000)."},"dx":{"type":"number","description":"Horizontal pixels."},"dy":{"type":"number","description":"Vertical pixels."}},"required":[]}},{"name":"preview_evaluate","description":"Evaluate a JavaScript expression in the page and return its JSON value.","inputSchema":{"type":"object","properties":{"expression":{"type":"string","description":"The expression."}},"required":["expression"]}},{"name":"preview_wait_for","description":"Wait until an element is visible, some text appears, or the URL contains a string.","inputSchema":{"type":"object","properties":{"ref":{"type":"string","description":"A ref from preview_snapshot's outline, e.g. e5 (preferred)."},"locator":{"type":"string","description":"A Playwright selector, role or text based, e.g. role=button[name='Send'] or text=Continue."},"selector":{"type":"string","description":"A CSS selector."},"timeoutMs":{"type":"number","description":"Timeout in ms (default 15000, at most 60000)."},"text":{"type":"string","description":"Text to wait for."},"url":{"type":"string","description":"URL substring to wait for."}},"required":[]}},{"name":"preview_resize","description":"Resize the browser viewport.","inputSchema":{"type":"object","properties":{"width":{"type":"number","description":"Width."},"height":{"type":"number","description":"Height."}},"required":["width","height"]}},{"name":"preview_status","description":"The browser's state: open, URL, title, viewport.","inputSchema":{"type":"object","properties":{},"required":[]}},{"name":"kicad_edit","description":"Before creating or editing a KiCad schematic, symbol, footprint, or board, load and follow the matching KiStack skill (kistack:kicad-schematic, kistack:kicad-layout, kistack:kicad-symbol, kistack:kicad-footprint, kistack:kicad-pcb, kistack:kicad-bom, kistack:kicad-export, or its SKILL.md in ). Edit or read a KiCad board or schematic in ONE call: Backplane takes the document's lock, opens it, runs `ops` in order inside one commit, refills the pours, saves, and answers with what KiCad's own DRC with schematic parity (board) or ERC (schematic) now says that it did not say before. Name parts by reference; lengths are mm, angles degrees, layers as KiCad shows them (F.Cu); answers are short rows, never whole items, and say which KiCad served them (served_by: headless, embedded, or both; null when nothing reached KiCad). Prefer it to kicad_ipc and to reading or writing the files. Ops:\n- {route: \"/LED*\" or [nets, or parts \"R3\" / pads \"R3.2\" for the nets on them], width?, layers?: [\"B.Cu\"], vias?: false, ripup?: true}: routes what is unconnected on those nets with tracks at the net class's width (or `width`) that keep its clearance to all other copper, on the layers and with the via kinds the board itself uses (laser micro vias on a board that has them, no drilled via under an IC), straight runs at 0, 45 and 90 degrees with room over the clearance where there is room; ripup takes the nets' old tracks up first. Answers per net: length, vias, layers, or `failed` with why. Do not work out track coordinates yourself.\n- {place: {\"C5\": \"U1.26\", \"C6\": \"U1.31\"}, within: 2}: moves each part next to that pin (its pad on the pin's net within `within` mm; pad: \"1\" to say which), turned to fit, no courtyard over another, pads clear of other nets' copper. Do not search for free places yourself.\n- {set: refs, footprint: \"Lib:Name\"}: on a board, exchanges the footprint (pad 1 stays where it is, rotation, side, fields and each pad's net kept) and answers the pads' new places; on a schematic, sets the symbols' Footprint. Follow it in the same call with {route: refs}: that joins what the new pads left unconnected, and another net's track that now lies on one of those pads is taken up and routed again.\n- {add: [...], sheet?, fit?: [x0, y0, x1, y1]}: board {track: {from, to, width, layer, net}}, {via: {at, size, drill, net, layers?}}; schematic {symbol: {lib: \"Device:C\", ref, value, at, rot, footprint, fields, allow_empty?, pins: {\"1\": \"VCC\", \"2\": \"GND\"}}} (a symbol KiCad gives with no pins and nothing drawn, as an HTTP library part whose source symbol had not loaded, is refused unless allow_empty: true; pins is a convenience for power pins or occasional inter-block stubs \u2014 NEVER dump a whole schematic as a wall of floating pin labels; wire passives directly to IC pins with `wire`, group decoupling caps, box and label subcircuits with KiCad rectangles, and color related nets; the answer gives every pin's place and, from the saved netlist, its net), {wire: [\"U7.2\", [x, y], \"C11.1\"]} (a point may be a pin REF.PIN; between pins it runs square), {label: {text, at, type: local|global|hier}}, {junction: at}, {no_connect: at}; or KiCad's own item with @type. Lay a group of new parts out relative to each other; where it would lie over something of the sheet it is moved as one, on the 1.27 mm grid, to the nearest free room (inside fit: the area it must stay in, when given), and the answer says so; use the returned pin places to wire passives directly, and after building or editing a schematic, run ERC and visually inspect rendered PNGs (viewer_show / kicad-cli sch export svg -> PNG) against KiStack's kicad-schematic rules before moving on.\n- {find: {kind, ...match}}: the rows of a kind (board: footprint, pad, track, arc, via, zone, text, shape, net; schematic: symbol, wire, label, junction, no_connect, sheet). Match any row key (ref, value, net, layer, at, sheet, id ...): text takes * and ?, a list is any-of, near: [x, y, radius]. A pad's row has its copper's size, rot and layer. An answer over about 24 thousand characters stops there and says how many rows are left. fields: true adds a part's fields; raw: true gives KiCad's own items.\n- {move: refs, by: [dx, dy]} or to: [x, y], and/or rot (a symbol's texts move with it).\n- {set: refs or {kind, ...match}, ...row keys}: {set: [\"R1\", \"R2\"], value: \"10k\", fields: {MPN: \"...\"}}; {set: {kind: \"zone\", net: \"GND\"}, clearance: 0.2, min_width: 0.2, name: \"...\", priority: 1}; {set: {kind: \"track\", net: \"+5V\"}, width: 0.3}. raw: {...} merges into KiCad's own item (a placed symbol's library symbol is not changed by set: delete it and add the other).\n- {delete: ids or {kind, ...match}}.\n- {netclass: {name, clearance, track_width, diff_pair_width, diff_pair_gap, via_diameter, via_drill, patterns: [\"/USB*\"]}}: added or changed, the patterns assigned to it (a route after it in the same call uses it).\n- {rule: {name, condition, constraints: [{type: \"clearance\", min: 0.2}], layer, severity}} or {rule: {remove: name}}: custom design rules, by name.\n- {ipc: {type, message}}: any kicad_ipc command in the sequence (\"$doc\" and \"$project\" stand for the document and its project).\nA failing op drops the whole commit and saves nothing. The answer is {results: [one per op], saved: path, check: {new: [findings this edit added, on what it worked on], elsewhere?, left, gone}, nets?, shown}: the save is done and committed, the pours are refilled and the person's viewer shows it (you do not need a redundant viewer_show or kicad-cli check after a small incremental edit, except for schematic visual inspection: follow KiStack's kicad-schematic skill to render/inspect PNGs and verify netlists/ERC when finishing or reviewing a schematic); `check.new` empty means the edit added no violation and no unconnected item; `elsewhere` counts findings on items the edit did not work on that a refill or the save moved, which are not this edit's to chase. saved: false with not_saved says why nothing was written; deferred counts items the person is editing right now (applied when they finish). While the person is working in KiCad a change is answered with what they are doing instead: ask them if it touches that, else repeat the call with person_seen: true.","inputSchema":{"type":"object","properties":{"path":{"type":"string","description":"Absolute path of the board (.kicad_pcb) or schematic (.kicad_sch)."},"ops":{"type":"array","items":{"type":"object"},"description":"The edits, in order."},"message":{"type":"string","description":"What the commit is, in a few words (KiCad's undo history shows it)."},"save":{"type":"boolean","description":"Save after the edits (default true)."},"show":{"type":"boolean","description":"Show the saved document in the person's viewer (default true)."},"person_seen":{"type":"boolean","description":"You have seen what the person is doing in KiCad (the refusal showed it) and this edit does not touch it."},"check":{"type":"boolean","description":"Answer with what KiCad's DRC/ERC says that it did not before (default true)."}},"required":["path","ops"]}},{"name":"kicad_ipc","description":"Send one command to the project's headless KiCad over its IPC API (Backplane starts one KiCad per project). path is the project's .kicad_pro, .kicad_pcb or .kicad_sch (absolute); type is the fully-qualified protobuf command, e.g. kiapi.board.commands.GetItems, kiapi.common.commands.BeginCommit, kiapi.backplane.SketchRoute; message is the command's fields as JSON. The answer is the response as JSON. Headless KiCad has no selection or view state: always pass explicit item IDs (the KIIDs GetItems returns), wrap edits in BeginCommit/EndCommit, then SaveDocument (the viewers follow the saved files). Unsaved work is undone with EndCommit CMA_DROP. Backplane KiCad bp.4 supports partial footprint updates and CreateItems from a symbol library id, with symbol libraries loaded on demand. On runtimes without footprint-partial-update or symbol-from-libid, the hub refuses unsafe requests and explains the workaround: send the full FootprintInstance from GetItems, or LoadAllLibraries, wait for GetLibraryStatuses, then PlaceSymbolFromLibrary. Selection, view and RunAction commands are refused at once. When IPC is unavailable the error says why and names the fallback (edit the file directly or use kicad-cli, then re-read the file). In the person's open KiCad, an edit is saved by Backplane when it lands (an EndCommit that commits, or an item write outside a commit; the answer's `saved`), so a crash never loses it; the save also writes the person's own unsaved edits in that document (`save_note`). Pass save: false on each commit of a batch to save once at its end.","inputSchema":{"type":"object","properties":{"save":{"type":"boolean","description":"false: do not save this change yet (a batch of commits); save before ending the turn."},"path":{"type":"string","description":"Absolute path of the project's .kicad_pro, .kicad_pcb or .kicad_sch."},"type":{"type":"string","description":"The protobuf command, fully qualified (kiapi.board.commands.GetItems)."},"message":{"type":"object","description":"The command's fields as JSON (default {})."}},"required":["path","type"]}},{"name":"kicad_ipc_status","description":"The project's headless KiCad: its server's state (starting, ready, failed or stopped), its version, its start command line (argv), and the capabilities and commands it has (kiapi.backplane.GetCapabilities). Starts the server if it is not running. Headless KiCad has no selection or view state: always pass explicit item IDs (KIIDs from GetItems) in kicad_ipc, wrap edits in BeginCommit/EndCommit, then SaveDocument.","inputSchema":{"type":"object","properties":{"path":{"type":"string","description":"Absolute path of the project's .kicad_pro, .kicad_pcb or .kicad_sch."}},"required":["path"]}},{"name":"kicad_select","description":"Select parts, nets or pins in the person's KiCad editor open in Backplane (and light them in Backplane's Board and Schematic viewers), as a click on a reference in the chat does: use it to point the person at what you mean (\"U3 is the regulator\"). path is the project's .kicad_pro, .kicad_pcb or .kicad_sch (absolute). The answer says whether KiCad is open (kicad) and what it found (found, not_found). With KiCad closed the viewers still light the first part or net.","inputSchema":{"type":"object","properties":{"path":{"type":"string","description":"Absolute path of the project's .kicad_pro, .kicad_pcb or .kicad_sch."},"references":{"type":"array","items":{"type":"string"},"description":"Reference designators, e.g. [\"U3\", \"R12\"]."},"nets":{"type":"array","items":{"type":"string"},"description":"Net names, e.g. [\"GND\", \"/SDA\"]."},"pins":{"type":"array","items":{"type":"string"},"description":"Pins as ., e.g. [\"U3.4\"]."},"zoom":{"type":"boolean","description":"Zoom to what was found (default true)."},"show":{"type":"string","enum":["PCB","SCH"],"description":"Switch the pane to this editor first."}},"required":["path"]}},{"name":"kicad_bring_back","description":"Bring an older thread worktree's design changes (KiCad files, libraries, 3D models, mech/, mfg/, fab files) back to the project's main checkout, where KiCad work now lives. Without mode it only lists what differs; with mode \"apply\" (only once the person agreed) main's copies are backed up to .backplane/backup/ first, the worktree's files are copied in and committed to main, the worktree keeps only code, and the thread works in the main checkout for design files from then on.","inputSchema":{"type":"object","properties":{"thread":{"type":"string","description":"The thread whose worktree to bring back (default: this thread)."},"mode":{"type":"string","enum":["list","apply"],"description":"list (default) or apply."}},"required":[]}},{"name":"altium_status","description":"The person's running Altium Designer (Windows only): its build, the projects and documents open in it, and the focused document. Altium has no headless mode: it must be running on this machine with the project open.","inputSchema":{"type":"object","properties":{}}},{"name":"altium_script","description":"Run a DelphiScript inside the person's running Altium Designer (Windows only) and return what it printed. Write a script as Altium's scripting docs do: an optional `var` (and `const`) section, optional procedures and functions, then statements (no enclosing program or Run procedure; a single outer begin..end is fine). Call Emit(S) to print a line. The whole Altium API is available: GetWorkspace (projects, documents, compile, ERC), SchServer (schematic objects, PreProcess/PostProcess around edits), PCBServer (board objects, iterators, PreProcess/PostProcess), Client.SendMessage / ResetParameters+AddStringParameter+RunProcess (any menu command, e.g. 'PCB:RunDRC', 'WorkspaceManager:Compile', 'WorkspaceManager:SaveObject'). Errors come back as `error` (with Altium's message), not as dialogs. Every loop is cut short at the deadline so Altium never freezes. Edits are left unsaved in Altium (undoable there) unless the script saves; save the document (e.g. Client.SendMessage('WorkspaceManager:SaveObject', 'ObjectKind=Document|FileName=' + Path, 255, Client.CurrentView)) when the person should see it in Backplane's viewers, which read the files.","inputSchema":{"type":"object","properties":{"script":{"type":"string","description":"DelphiScript: [var section] [procedures/functions] statements. Emit(S) prints a line."},"timeout":{"type":"integer","description":"Seconds to wait (default 60, at most 600). Loops are cut short 3 s before it."}},"required":["script"]}},{"name":"altium_write","description":"Make or edit Altium Designer files directly, with no Altium running (any platform): footprints in a .PcbLib, symbols in a .SchLib, schematic sheets (.SchDoc), and the project's document list (.PrjPcb). One JSON spec; its parts run in the order pcblib, schlib, schdoc, project, so one call can make a footprint, the symbol that uses it and a sheet that places it. Paths are relative to the project folder; schematic coordinates are mils (Y up, 100 mil grid), footprint ones mm. pcblib: {path, footprints:[...], remove:[names]}; a footprint is {package: chip (size \"0603\", kind resistor|capacitor|inductor) | soic|sop|tssop|msop (pins, pitch, span, body [w,l], foot, lead, height) | sot23 (pins 3|5|6) | qfn|dfn (pins or nx/ny, pitch, body [x,y], term, lead, ep [w,h]) | header (rows, pins or cols, pitch, drill, pad) | custom (pads:[{number,x,y,w,h,shape rect|round|roundrect|oct,rotation,hole,slot,layer}], body [w,l]), name (default: the IPC-7351 name), description, height, lines:[{layer,from,to,width}]}: IPC-7351B lands, silk clear of copper, assembly outline, courtyard, 3D body. schlib: {path, symbols:[...], remove:[names]}; a symbol is {name, description, designator \"U?\", comment, footprint (name or list; from the pcblib of the same call unless footprint_library), parameters {Name: value}, pins:[{number, name, side left|right|top|bottom, type input|output|io|passive|power|open_collector|open_emitter|hiz, part, inverted, clock, hidden} or {gap:true, side}] (a box sized to them, one per part), or pins with at [x,y] (the wire end) and points left|right|up|down plus shapes:[{kind rect|line|polygon|arc|ellipse|text,...}], or template resistor|capacitor|inductor|diode|led}. A symbol or footprint of the same name is replaced; others are kept as they are. schdoc: {path, size A4|A3|...|Letter (new sheet), remove {parts:[designators], nets:[label/port names], at:[[x,y]]}, place:[{symbol, library (.SchLib path), designator, at [x,y], rotation 0|90|180|270, mirror, part, comment, parameters {}}], set:[{part, name, value, visible}], connect:[{pin \"U1.3\" or \"U1.VIN\", net, power: style|true (ground for GND nets by default), stub}] (a short wire from the pin with a net label or power port; net NC puts a no-ERC mark), wires:[[[x,y],...]], labels:[{net, at, rotation}], power:[{net, at, style bar|arrow|circle|wave|ground|signal_ground|earth, rotation}], junctions:[[x,y]], no_erc:[[x,y]]}. project: a .PrjPcb path; the written files are added to it (made when missing). The result lists what each file now holds, read back through Backplane's readers (pins with their wire ends, pads, parts, nets). If Altium has a written document open, it is reloaded when it has no unsaved edits. Before the first sheet, symbol or footprint, read KiStack's kicad-schematic, kicad-symbol or kicad-footprint SKILL.md completely (paths in ) and lay it out by its rules: this tool writes what the spec says and lays nothing out for you.","inputSchema":{"type":"object","properties":{"pcblib":{"type":"object","description":"{path, footprints:[...], remove:[names]}"},"schlib":{"type":"object","description":"{path, symbols:[...], remove:[names]}"},"schdoc":{"type":"object","description":"{path, size, remove, place, set, connect, wires, labels, power, junctions, no_erc}"},"project":{"type":"string","description":"A .PrjPcb to add the written files to (made when missing)."}},"required":[]}},{"name":"permission_prompt","description":"Internal to Backplane: asks the user before a tool runs. Do not call it yourself.","inputSchema":{"type":"object","properties":{"tool_name":{"type":"string","description":"The tool."},"input":{"type":"object","description":"Its input."},"tool_use_id":{"type":"string","description":"The call."}},"required":["tool_name","input"]}},{"name":"told_check","description":"Before telling the person something (a digest item, a reminder, news), check whether they were already told: by its topic key, or by text (matching words). Answers {told: bool, matches: [{key, text, channel, bot, at, ago}]}. Covers the last 7 days by default (up to 30) on this machine, including every alert already sent (asks, finished work, failures, merges, notify_person notes, which are recorded by themselves). Alerting is notify_person's policy (needs_you, done, or a routine's reminder or digest); this only tells you what was already said.","inputSchema":{"type":"object","properties":{"key":{"type":"string","description":"The topic key, e.g. lunch-dana-1028 (as given to told_mark)."},"text":{"type":"string","description":"The text you are about to say; matched by its words."},"days":{"type":"number","description":"How many days back (default 7, at most 30)."}},"required":[]}},{"name":"told_mark","description":"Record that you told the person something without an alert (in a digest, a room post, a chat answer, your Space, an email), so you and other bots skip it next time. Alerts, notify_person's included, are recorded by themselves. key: a short stable topic key (e.g. lunch-dana-1028); without one, it is made from the text. channel: digest, room, chat, email or other. Answers {key}.","inputSchema":{"type":"object","properties":{"key":{"type":"string","description":"A short stable topic key; made from the text when omitted."},"text":{"type":"string","description":"What you told them, in a sentence."},"channel":{"type":"string","description":"digest, room, chat, email or other (default chat)."}},"required":["text"]}},{"name":"task_board_list","description":"List the shared task board: open items by default (all includes done and dropped). Answers {text, items}: text is one line per item, [status] title (id; @owner; %project; due D; group), and items has the full records.","inputSchema":{"type":"object","properties":{"status":{"type":"string","description":"todo, doing, blocked, done or dropped; several separated by commas."},"owner":{"type":"string","description":"A bot's name or id, me for yourself, or person."},"project":{"type":"string","description":"A project's name or id."},"group":{"type":"string","description":"A section name."},"all":{"type":"boolean","description":"Include done and dropped items."}},"required":[]}},{"name":"task_board_add","description":"Add an item to the shared task board. Answers {id}.","inputSchema":{"type":"object","properties":{"title":{"type":"string","description":"What is to be done (at most 300 characters)."},"status":{"type":"string","description":"todo (default), doing, blocked, done or dropped."},"owner":{"type":"string","description":"A bot's name or id, me for yourself, or person (default)."},"project":{"type":"string","description":"A project's name or id."},"due":{"type":"string","description":"YYYY-MM-DD."},"group":{"type":"string","description":"A section name."},"links":{"type":"string","description":"URLs, thread ids or paths: a JSON array, or a string split on spaces and commas (at most 20)."},"notes":{"type":"string","description":"Notes (at most 4000 characters)."}},"required":["title"]}},{"name":"task_board_update","description":"Change an item on the task board: only the fields you give change. Answers {id}.","inputSchema":{"type":"object","properties":{"id":{"type":"string","description":"The item's id."},"title":{"type":"string","description":"New title."},"status":{"type":"string","description":"todo, doing, blocked, done or dropped."},"owner":{"type":"string","description":"A bot's name or id, me for yourself, or person."},"project":{"type":"string","description":"A project's name or id."},"due":{"type":"string","description":"YYYY-MM-DD, or empty to clear."},"group":{"type":"string","description":"A section name."},"links":{"type":"string","description":"Replaces the links: a JSON array, or a string split on spaces and commas."},"notes":{"type":"string","description":"Replaces the notes."},"notes_append":{"type":"string","description":"A line added to the notes."}},"required":["id"]}},{"name":"task_board_remove","description":"Delete an item from the task board for good. Prefer task_board_update with status dropped, which keeps a record.","inputSchema":{"type":"object","properties":{"id":{"type":"string","description":"The item's id."}},"required":["id"]}},{"name":"task_board_import","description":"Import a markdown todo list (checkbox items `- [ ]`, `- [x]`, `- [~]`; headings become groups). Lines without a checkbox are not imported and are returned as `skipped`. Importing the same list again adds nothing. Answers {added, duplicates, skipped}.","inputSchema":{"type":"object","properties":{"markdown":{"type":"string","description":"The list."},"project":{"type":"string","description":"Put every item in this project (a name or id)."},"owner":{"type":"string","description":"A bot's name or id, me for yourself, or person (default)."}},"required":["markdown"]}},{"name":"order_review","description":"The project's manufacturing review. gate (a buy thread, before exporting): Backplane checks the review and, unless it is current and passed, shows the person why and asks them; answers what it did. check: whether the design (its boards, schematics, models and fab files) was reviewed since it last changed; answers state (none, stale or current), verdict, summary and issues. record: after a manufacturing review, keep its verdict (ok or issues), a one-line summary and the issues, one short line each, with the design as it is now.","inputSchema":{"type":"object","properties":{"action":{"type":"string","description":"gate, check or record"},"verdict":{"type":"string","description":"record: ok or issues"},"summary":{"type":"string","description":"record: one line"},"issues":{"type":"array","items":{"type":"string"},"description":"record: what must change, one short line each (\"Shade: walls 0.6 mm, need 0.8\"), at most 8; none when ok."}},"required":["action"]}},{"name":"thread_reply","description":"Say something to the person in this thread now, while your turn goes on: the answer to a message they sent while you work, or a short status. It is posted at once as your message in the thread, and your work carries on after it. Use it before your next other tool call when the person asked you something mid-turn; your final answer still goes in your reply as usual.","inputSchema":{"type":"object","properties":{"text":{"type":"string","description":"What to say to the person, in plain words (markdown)."}},"required":["text"]}}]}} \ No newline at end of file