by adom
Let an AI (Claude, ChatGPT, Codex or any agent) run Altium Designer for you: create symbols and footprints, place parts (also from Altium 365), wire and annotate schematics, Update PCB, set the stack-up and rules, route, pour copper, add mounting holes and stitching vias, run ERC and DRC, and make Gerbers, BOMs and STEP. Free in Hydrogen; bring your own AI and Altium licence.
← Commit history
0.2.89: import_design reads EAGLE through Altium's Import Wizard, driven by page name; tool_update reads the offer from Altium's downloads page, apply answers needs_user, auto reads and sets Altium's update check; approval check before answering dialogs
14 files changed
+520−86
CHANGELOG.md+11−5bridge-rs/src/ab.rs+18bridge-rs/src/geom3d.rs+1bridge-rs/src/importdesign.rs+165−30bridge-rs/src/main.rs+1−1bridge-rs/src/toolupdate.rs+134−30bridge-rs/src/verbs.rs+7−7dev-skills/altium-bridge-test/fixtures/eagle-small.brd+63dev-skills/altium-bridge-test/fixtures/eagle-small.sch+84dev-skills/altium-bridge-test/run_verb_tests.py+16−5package.json+8−2page.json+9−3src/BRIDGE_VERSION+1−1src/bridge.json+2−2CHANGELOG.md+11−5@@ -1,11 +1,17 @@ # Changelog -## 0.2.89 (unreleased)+## 0.2.89 -- **`import_design` reads EAGLE** (EDA Bridge Standard #29): an EAGLE schematic and its board, together, into a new Altium project through Altium's Import Wizard, run outside the script engine with Altium's own import options.- - How the wizard is driven: the importer list answers no UI Automation, so EAGLE is picked with a real click. The EAGLE wizard's Load dialog takes the file name over UIA and only Enter. The later pages are answered with Next until Finish.- - `steps` lists every one. `kicad` still goes through Altium's KiCad importer.- - Written from the live mapping; not yet run end to end (next: the BQ25792 EAGLE pair on DESKTOP-BAR6S0F).+- **`import_design` reads EAGLE** (EDA Bridge Standard #29): an EAGLE schematic and its board, together, into a new Altium project through Altium's Import Wizard, run outside the script engine with Altium's own import options. Run end to end on a real 109-part, 4-layer board and a small fixture, on Altium Designer Develop 26.9.+ - The reply gives `design`, `parts`, `nets` and `warnings` (what the importer's log says it could not read), and `check`: the board's parts, nets and vias against the EAGLE file. The board is saved. `boardPath` and `name` are taken, `outputDir` sets the folder, and `steps` lists every wizard page.+ - The wizard is driven by the name of the page it shows. It reports no button as disabled, and a greyed Finish still closes it with nothing imported, so Finish is pressed only on its last page.+ - The importer list answers no UI Automation, so EAGLE is picked with a real click. The EAGLE wizard's Load dialog takes the file name over UIA and only Enter.+ - A second import of the same design goes in a new folder, `Imported (1) <name>.PrjPcb`.+- **`tool_update` answers the standard** (#29):+ - `check` gives `current` and each Altium's build, and `offered` from the newest release on Altium's public downloads page. Altium's own update pages can't be read. `noticeSeen` says Altium raised its Update Available box.+ - `apply` refuses with the unsaved documents. Otherwise it answers `needs_user` with `whatToApprove`, because Altium's installer asks for a Windows approval. With `humanIsPresent` it closes Altium and starts Altium's installer.+ - `auto` reads each edition's update check from Altium's preferences, and `on` sets it with Altium closed.+- **Approval check before answering dialogs:** `export_3d` and `import_design` ask for Adom Bridge's approval before they press anything. Adom Bridge refuses synthetic input without it, even for a bridge on the same machine, and `export_3d` could otherwise wait on a dialog nothing could answer. ## 0.2.88
bridge-rs/src/ab.rs+18@@ -31,6 +31,24 @@ pub fn call(command: &str, args: Value, forwarded: &[(String, String)], timeout_ } } +/// Adom Bridge's shell approval as `status` reports it. It gates synthetic input (UIA set and click, keys) even for a+/// bridge on the loopback, and a dialog flow without it fails silently: fusion-bridge#133 on a user's PC. Pure.+pub fn shell_approved(status: &Value) -> bool {+ let sh = &status["permissions"]["shell"];+ sh["autoApproved"].as_bool() == Some(true) || sh["willPrompt"].as_bool() == Some(false)+}++/// Before a flow that answers a tool's dialogs: is the input allowed? If not, raise the prompt and wait for a person,+/// up to `wait_s`. Err is the verb's whole answer: nothing was opened.+pub fn need_input_approval(what: &str, wait_s: u64) -> Result<(), Value> {+ if shell_approved(&call("status", json!({}), &[], 10)) { return Ok(()); }+ let g = call("request_shell_approval", json!({"wait": true, "timeoutSec": wait_s, "reason": what}), &[], wait_s + 15);+ if g["granted"].as_bool() == Some(true) || g["alreadyApproved"].as_bool() == Some(true) || shell_approved(&call("status", json!({}), &[], 10)) { return Ok(()); }+ Err(json!({"success": false, "errorCode": "needs_approval", "error": format!("Adom Bridge needs approval first: {what}. Nothing was opened."),+ "tellUser": format!("Adom Bridge needs your OK to {what}: click Approve (1 hr, 24 hr or Auto) in the Adom Bridge window, on its notification, or in Hydrogen."),+ "_hint": "The approval prompt has been raised. Once a person approves, call this again."}))+}+ /// ab's direct API returns {error, output, status, success} with the verb's real result JSON-encoded /// as a STRING in `output`. Surface the inner object, keeping the outer status fields. fn unwrap_output(v: Value) -> Value {
bridge-rs/src/geom3d.rs+1@@ -127,6 +127,7 @@ pub fn export_3d(args: &Value) -> Value { let dir = s("outputDir").map(std::path::PathBuf::from).unwrap_or_else(|| bpath.parent().unwrap_or(std::path::Path::new(".")).to_path_buf()); dir.join(format!("{stem}.{ext}")).to_string_lossy().to_string() }).replace('/', "\\");+ if let Err(e) = crate::ab::need_input_approval("answer Altium's export dialogs (the file name and the export options)", 90) { return e; } if let Some(e) = crate::support::must_open(&board, 60) { return e; } // a file already there would raise Windows' overwrite question: the caller asked for this path. Its folder must // exist: Windows' "Path does not exist" box stopped the save when the battery had just emptied it (2026-10-30)
bridge-rs/src/importdesign.rs+165−30@@ -8,8 +8,11 @@ //! list it, so it is found by title. Back / Next / Finish / Cancel take UIA Invoke. //! - Its importer grid needs a mouse click on "EAGLE Projects and Designs": UIA Select does not reach the Delphi grid, //! and Next would import the first row, 99SE DDB (which asks to close every document).-//! - Next hands over to "EAGLE Import Wizard" (TImporterWizardForm): design files (Add / Remove), library files, then-//! its later pages, answered with Next until Finish.+//! - Next hands over to "EAGLE Import Wizard" (TImporterWizardForm): design files (Add / Remove), library files,+//! "Analyzing Files" (all its buttons greyed; a Next pressed then is lost), Sheet_PCBMapping, Sheet_Report,+//! Sheet_IntLib (the output folder, DirEdit_IntLib; the project goes in "Imported <name>.PrjPcb" under it),+//! Sheet_Output (the import runs), Sheet_Finish. UIA reports no button as disabled and a greyed Finish still takes+//! Invoke and closes the wizard with nothing imported, so the page's name decides what is pressed. //! - Add opens "Load EAGLE Designs", an old-style Open dialog: its file name box (id 1148) takes SetValue, and only //! Enter takes it. use serde_json::{json, Value};@@ -32,8 +35,7 @@ fn window(title: &str, secs: u64) -> Option<i64> { let t0 = Instant::now(); while t0.elapsed().as_secs() < secs { let r = ab("desktop_find_window", json!({"titleContains": title}));- let o = if r["output"].is_string() { serde_json::from_str::<Value>(r["output"].as_str().unwrap_or("{}")).unwrap_or(r.clone()) } else { r.clone() };- if let Some(h) = o["windows"].as_array().and_then(|a| a.iter().find(|w| w["title"].as_str() == Some(title))).and_then(|w| w["hwnd"].as_i64()) { return Some(h); }+ if let Some(h) = r["windows"].as_array().and_then(|a| a.iter().find(|w| w["title"].as_str() == Some(title))).and_then(|w| w["hwnd"].as_i64()) { return Some(h); } std::thread::sleep(Duration::from_millis(500)); } None@@ -96,62 +98,166 @@ fn cancel_all() { } } +/// The page a wizard shows: the id of its Sheet_ node, or the empty string on a page without one.+fn page_of(tree: &[Value]) -> String {+ tree.iter().filter_map(|n| n["automationId"].as_str()).find(|a| a.starts_with("Sheet_")).unwrap_or("").to_string()+}++#[derive(Debug, PartialEq)]+pub enum Move { Finish, Next, Wait }++/// What to press on a page: Finish only on the last one, nothing while the import runs, and Next once per page, again+/// only when the page has not moved for a while (a Next pressed while it was analysing is lost). Pure.+pub fn move_for(page: &str, pressed_on: Option<&str>, waited: Duration) -> Move {+ match page {+ "Sheet_Finish" => Move::Finish,+ "Sheet_Output" => Move::Wait,+ p if pressed_on != Some(p) || waited >= Duration::from_secs(6) => Move::Next,+ _ => Move::Wait,+ }+}++/// Walk the EAGLE wizard's pages to its end, keeping Altium's own import options.+fn drive_pages(eagle: i64, out_dir: Option<&Path>, steps: &mut Vec<Value>) -> Result<(), String> {+ let t0 = Instant::now();+ let (mut pressed_on, mut pressed_at, mut shown, mut dir_set) = (None::<String>, Instant::now(), String::new(), out_dir.is_none());+ while t0.elapsed().as_secs() < 600 {+ let tree = nodes(eagle);+ if tree.len() <= 1 && window("EAGLE Import Wizard", 1).is_none() { return Err(format!("the EAGLE Import Wizard closed on {shown} before the import finished")); }+ let page = page_of(&tree);+ if page != shown { steps.push(json!({"step": "page", "page": page, "atSec": t0.elapsed().as_secs()})); shown = page.clone(); }+ if page == "Sheet_IntLib" && !dir_set {+ let want = out_dir.map(|d| d.to_string_lossy().replace('/', "\\")).unwrap_or_default();+ let _ = std::fs::create_dir_all(&want);+ ab("desktop_ui_set", json!({"hwnd": eagle, "automationId": "DirEdit_IntLib", "text": want}));+ let back = ab("desktop_find_controls", json!({"hwnd": eagle, "automationId": "DirEdit_IntLib"}));+ let norm = |v: &str| v.replace('\\', "/").trim_end_matches('/').to_ascii_lowercase();+ if !back["matches"].as_array().map(|a| a.iter().any(|m| m["value"].as_str().map(norm) == Some(norm(&want)))).unwrap_or(false) {+ return Err(format!("the wizard's output folder would not take {want}"));+ }+ steps.push(json!({"step": "output_dir", "dir": want}));+ dir_set = true;+ }+ match move_for(&page, pressed_on.as_deref(), pressed_at.elapsed()) {+ Move::Finish => {+ click(eagle, "Finish");+ let t1 = Instant::now();+ while window("EAGLE Import Wizard", 1).is_some() {+ if t1.elapsed().as_secs() > 30 { return Err("the EAGLE Import Wizard stayed open after Finish".into()); }+ std::thread::sleep(Duration::from_millis(500));+ }+ steps.push(json!({"step": "finish", "atSec": t0.elapsed().as_secs()}));+ return Ok(());+ }+ Move::Next => { click(eagle, "Next"); pressed_on = Some(page); pressed_at = Instant::now(); }+ Move::Wait => {}+ }+ std::thread::sleep(Duration::from_millis(700));+ }+ Err(format!("the EAGLE Import Wizard was still on {shown} after 10 minutes"))+}+ /// The EAGLE import, the agent stopped while it runs.-fn run_eagle(files: &[PathBuf], steps: &mut Vec<Value>) -> Result<(), String> {+fn run_eagle(files: &[PathBuf], out_dir: Option<&Path>, steps: &mut Vec<Value>) -> Result<(), String> { let exe = crate::lifecycle::x2_exe_pub().ok_or("X2.exe not found")?; let mut child = crate::lifecycle::spawn_helper_pub(&exe, "-RImporterManager:RunImporterManagerDialog")?;- let Some(wiz) = window("Import Wizard", 20) else { crate::lifecycle::wait_helper_pub(&mut child, Duration::from_secs(10)); return Err("Altium's Import Wizard did not open".into()); };+ // a freshly started Altium takes a while to show it+ let Some(wiz) = window("Import Wizard", 60) else { crate::lifecycle::wait_helper_pub(&mut child, Duration::from_secs(10)); return Err("Altium's Import Wizard did not open".into()); }; click(wiz, "Next");- std::thread::sleep(Duration::from_millis(800)); // the EAGLE row, clicked: the grid answers no UIA pattern- let row = nodes(wiz).into_iter().find(|n| n["name"].as_str() == Some("EAGLE Projects and Designs"));+ let t0 = Instant::now();+ let row = loop {+ let row = nodes(wiz).into_iter().find(|n| n["name"].as_str() == Some("EAGLE Projects and Designs"));+ if row.is_some() || t0.elapsed().as_secs() > 15 { break row; }+ std::thread::sleep(Duration::from_millis(500));+ }; let Some(r) = row.and_then(|n| n["rect"].as_object().cloned()) else { cancel_all(); return Err("no EAGLE row in the Import Wizard's list".into()); }; let c = ab("desktop_click", json!({"x": r["centerX"], "y": r["centerY"], "hwnd": wiz, "reason": "choose EAGLE in Altium's Import Wizard (its list answers no UI Automation)"})); steps.push(json!({"step": "choose_eagle", "ok": ok(&c)})); click(wiz, "Next"); let Some(eagle) = window("EAGLE Import Wizard", 20) else { cancel_all(); return Err("the EAGLE Import Wizard did not open (the importer chosen was not EAGLE)".into()); }; for f in files { if !add_file(eagle, f, steps) { cancel_all(); return Err(format!("{} could not be added", f.display())); } }- // the later pages keep Altium's own import options: Finish as soon as it is offered (a greyed Finish takes no- // Invoke), Next until then- let mut finished = false;- for i in 0..12 {- if click(eagle, "Finish") {- std::thread::sleep(Duration::from_millis(1500));- if window("EAGLE Import Wizard", 1).is_none() { steps.push(json!({"step": "finish", "page": i})); finished = true; break; }- }- if !click(eagle, "Next") { steps.push(json!({"step": "stuck", "page": i})); break; }- steps.push(json!({"step": "next", "page": i}));- std::thread::sleep(Duration::from_millis(1000));- if window("EAGLE Import Wizard", 1).is_none() { finished = true; break; }- }- if !finished { cancel_all(); return Err("the EAGLE Import Wizard never offered Finish".into()); }- // the import runs after Finish; the launcher returns when it is done+ drive_pages(eagle, out_dir, steps).inspect_err(|_| cancel_all())?;+ // the launcher returns once the wizard has closed crate::lifecycle::wait_helper_pub(&mut child, Duration::from_secs(600)); Ok(()) } -/// altium_import_design {format, filePath, outputDir?}+/// What the EAGLE board holds, to check the import against: elements, signals and vias. Pure.+pub fn eagle_board_counts(brd: &str) -> Value {+ let n = |t: &str| brd.matches(t).count();+ let signals = brd.split("<signals>").nth(1).and_then(|x| x.split("</signals>").next()).unwrap_or("");+ json!({"components": n("<element "), "nets": signals.matches("<signal ").count(), "vias": signals.matches("<via ").count()})+}++/// After the wizard: keep the board (the wizard leaves it modified) and read it against the EAGLE source.+fn check_board(prj: &Path, files: &[PathBuf]) -> Value {+ let board = prj.with_extension("PcbDoc");+ if !board.is_file() { return json!({"board": Value::Null}); }+ let b = board.to_string_lossy().to_string();+ let saved = crate::surfaces::save(&json!({"filePath": b}));+ let r = crate::verbs::dispatch("routing_state", &json!({"filePath": b}), &[]);+ let got = &r["counts"];+ let source = files.iter().find(|f| f.extension().map(|x| x.eq_ignore_ascii_case("brd")).unwrap_or(false))+ .and_then(|f| std::fs::read_to_string(f).ok()).map(|t| eagle_board_counts(&t));+ let matches = source.as_ref().map(|s| ["components", "nets", "vias"].iter().all(|k| s[*k] == got[*k]));+ json!({"board": b, "saved": saved.get("success"), "imported": got, "source": source, "matchesSource": matches, "unconnected": r["unconnected"]})+}++/// What the importer could not bring over: its log's ERROR lines, each kind once with its count. Pure.+pub fn log_warnings(log: &str) -> Vec<String> {+ let mut seen: Vec<(String, usize)> = Vec::new();+ for l in log.lines().map(str::trim).filter_map(|l| l.strip_prefix("ERROR:")) {+ let k = l.trim().to_string();+ match seen.iter_mut().find(|(s, _)| *s == k) { Some(e) => e.1 += 1, None => seen.push((k, 1)) }+ }+ seen.into_iter().map(|(k, n)| if n > 1 { format!("{k} ({n} times)") } else { k }).collect()+}++/// altium_import_design {format, filePath, boardPath?, name?, outputDir?} pub fn import_design(args: &Value) -> Value { if let Some(g) = crate::support::need_licensed() { return g; } let s = |k: &str| crate::support::s(args, k); let format = s("format").unwrap_or_default().to_ascii_lowercase(); let Some(path) = s("filePath") else { return json!({"success": false, "errorCode": "bad_args", "error": "filePath (the design to import) is required"}) }; match format.as_str() {- "kicad" => { let mut r = crate::outputs::import_kicad(args); r["format"] = json!("kicad"); r }+ "kicad" => { let mut r = crate::outputs::import_kicad(args); r["format"] = json!("kicad"); if r.get("project").is_some() { r["design"] = r["project"].clone(); } r } "eagle" => {- let files = eagle_files(&path);+ let mut files = eagle_files(&path);+ // a board with another name than its schematic+ if let Some(b) = s("boardPath").map(|b| PathBuf::from(b.replace('\\', "/"))) {+ if !b.is_file() { return json!({"success": false, "errorCode": "file_not_found", "error": format!("no EAGLE board at {}", b.display())}); }+ files.retain(|f| !f.extension().map(|x| x.eq_ignore_ascii_case("brd")).unwrap_or(false));+ files.push(b);+ } if files.is_empty() { return json!({"success": false, "errorCode": "file_not_found", "error": format!("no EAGLE .sch or .brd at {path}")}); }- let dir = s("outputDir").map(PathBuf::from).unwrap_or_else(|| files[0].parent().map(Path::to_path_buf).unwrap_or_default());+ let out_dir = s("outputDir").map(PathBuf::from);+ let dir = out_dir.clone().unwrap_or_else(|| files[0].parent().map(Path::to_path_buf).unwrap_or_default());+ if let Err(e) = crate::ab::need_input_approval("answer Altium's Import Wizard for the EAGLE import (its list, file dialog and buttons)", 90) { return e; } let since = SystemTime::now(); let stop = crate::lifecycle::stop(); if stop.get("success").and_then(|v| v.as_bool()) != Some(true) { return json!({"success": false, "errorCode": "agent_stop_failed", "stop": stop}); } let mut steps = Vec::new();- let run = run_eagle(&files, &mut steps);+ let run = run_eagle(&files, out_dir.as_deref(), &mut steps); let start = crate::lifecycle::start(Duration::from_secs(90)); let prj = new_project(&dir, since); match (run, prj) {- (Ok(()), Some(p)) => json!({"success": true, "format": "eagle", "files": files, "project": p, "steps": steps, "agentRestarted": start.get("success"),- "_hint": "Altium's Import Wizard made a new project from the EAGLE schematic and board, with its own import options. Open it with altium_open_project."}),+ (Ok(()), Some(p)) => {+ let check = check_board(&p, &files);+ let log = std::fs::read(p.with_extension("LOG")).map(|b| String::from_utf8_lossy(&b).to_string()).unwrap_or_default();+ // project_rename refuses an open project, and the wizard leaves this one open+ let renamed = s("name").map(|n| {+ for ext in ["PcbDoc", "SchDoc", "PrjPcb"] { crate::agent::call("close_document", &[("path", p.with_extension(ext).to_string_lossy().to_string())], None, Duration::from_secs(30)); }+ crate::project::project_rename(&json!({"project": p, "newName": n}))+ });+ let design = match (&renamed, s("name")) {+ (Some(r), Some(n)) if r.get("success").and_then(|b| b.as_bool()) != Some(false) => p.with_file_name(format!("{n}.PrjPcb")).to_string_lossy().to_string(),+ _ => p.to_string_lossy().to_string(),+ };+ json!({"success": true, "format": "eagle", "files": files, "design": design, "project": design, "parts": check["imported"]["components"], "nets": check["imported"]["nets"],+ "warnings": log_warnings(&log), "renamed": renamed, "steps": steps, "agentRestarted": start.get("success"), "check": check,+ "_hint": "Altium's Import Wizard made a new project from the EAGLE schematic and board with its own import options, and left it open. check compares the board with the EAGLE file. Compile it (altium_compile) before trusting the schematic: the wizard writes EAGLE's nets as ports, which ERC can report as multiple input ports. warnings is what the importer's log says it could not read. A second import of the same design goes in a new folder, Imported (1) <name>.PrjPcb: the first is left alone."})+ } (Ok(()), None) => json!({"success": false, "errorCode": "no_project", "error": format!("the wizard finished but no new .PrjPcb appeared under {}", dir.display()), "steps": steps, "agentRestarted": start.get("success")}), (Err(e), _) => json!({"success": false, "errorCode": "wizard_failed", "error": e, "steps": steps, "agentRestarted": start.get("success")}), }@@ -178,4 +284,33 @@ mod tests { assert!(f[0].ends_with("x.sch")); let _ = std::fs::remove_dir_all(&d); }++ #[test]+ fn the_log_says_what_did_not_come_over() {+ let w = log_warnings("Load board\n ERROR: Unhandled typepackages3d\n ERROR: Unhandled typepackages3d\n ERROR: Unhandled type <x>\nEndSection");+ assert_eq!(w, ["Unhandled typepackages3d (2 times)", "Unhandled type <x>"]);+ }++ #[test]+ fn a_page_decides_the_press() {+ let s = Duration::from_secs(1);+ assert_eq!(move_for("Sheet_Finish", None, s), Move::Finish);+ assert_eq!(move_for("Sheet_Output", None, s), Move::Wait, "the import is running");+ assert_eq!(move_for("Sheet_Report", Some("Sheet_PCBMapping"), s), Move::Next);+ assert_eq!(move_for("Sheet_Report", Some("Sheet_Report"), s), Move::Wait, "pressed already");+ assert_eq!(move_for("Sheet_Report", Some("Sheet_Report"), Duration::from_secs(7)), Move::Next, "the press was lost");+ assert_eq!(move_for("", None, s), Move::Next, "a page with no sheet name still moves");+ }++ #[test]+ fn the_page_is_the_sheet_node() {+ assert_eq!(page_of(&[json!({"automationId": "Button_Next"}), json!({"automationId": "Sheet_IntLib"})]), "Sheet_IntLib");+ assert_eq!(page_of(&[json!({"name": "x"})]), "");+ }++ #[test]+ fn a_board_counts_its_own_signals_only() {+ let c = eagle_board_counts(r#"<board><elements><element name="R1"/><element name="R2"/></elements><signals><signal name="A"><via x="1"/></signal><signal name="B"/></signals><via x="9"/></board>"#);+ assert_eq!(c, json!({"components": 2, "nets": 2, "vias": 1}));+ } }
bridge-rs/src/main.rs+1−1@@ -77,7 +77,7 @@ use tiny_http::{Header, Method, Response, Server}; /// Attached to every failed reply (see the /command handler). const REPORT_ISSUES: &str = "If this looks like an altium-bridge BUG (not a refusal you expected), report it: check for a duplicate with `adom-wiki issue list adom/altium-bridge`, then `adom-wiki issue create adom/altium-bridge --title \"<verb>: <one-line symptom>\" --category bug-report --body \"<what you ran, what you expected, what happened, the VERBATIM response JSON (and errorShot if present), bridgeVersion, the Altium version from altium_status, the OS>\"`. A relay, routing, toast or lifecycle problem belongs on adom/adom-bridge instead. Reports from real machines are how this bridge gets correct: three different Altium builds behaved three different ways in one weekend."; -pub const BRIDGE_VERSION: &str = "0.2.88";+pub const BRIDGE_VERSION: &str = "0.2.89"; fn json_response(status: u16, body: &serde_json::Value) -> Response<std::io::Cursor<Vec<u8>>> { let data = serde_json::to_vec(body).unwrap_or_else(|_| b"{}".to_vec());
bridge-rs/src/toolupdate.rs+134−30@@ -1,10 +1,20 @@-//! tool_update: Altium's own updates (EDA Bridge Standard #29, app tier). `check` gives every Altium on the machine-//! with its exact build; what Altium offers is shown on pages the bridge cannot read (Develop's Extensions & Updates page-//! lists extensions only, and none of its content is in the UI Automation tree, measured 2026-10-30), so `offered` is-//! null with the reason rather than a guess, and `apply` is refused by name. `auto` reads Altium's own update-check-//! settings from its preference files.+//! tool_update: Altium's own updates (EDA Bridge Standard #29, app tier).+//! - `check`: every Altium on the machine with its exact build (X2.EXE), against the newest release on Altium's public+//! downloads page. Altium's Extensions & Updates page is not in UI Automation and the "Update Available" box at+//! start-up names no version (measured 2026-10-30), so the page is where the version comes from; the box, which the+//! reaper closes, is reported as `noticeSeen`.+//! - `apply`: refuses with the unsaved documents. Altium's installer is Altium's own and asks for a Windows approval,+//! so with work safe the bridge starts it only when a person is there to approve (humanIsPresent) and answers+//! `needs_user` with what to approve.+//! - `auto`: Altium's update check is its UpdatesCheckFrequency preference (HKCU, ExtensionManager\AutoUpdatePrefs). It+//! reads any time; it is set only with Altium closed, because Altium writes its preferences back when it exits. use serde_json::{json, Value}; +const DOWNLOADS: &str = "https://www.altium.com/products/downloads";+/// Altium's "Never" in Preferences > System > Installation > Check frequency. The value `on: true` gives is its default.+const NEVER: i64 = 0;+const DEFAULT_FREQUENCY: i64 = 2;+ /// X2.EXE's product version. fn exe_version(exe: &str) -> Option<String> { let ps = format!("(Get-Item -LiteralPath '{}').VersionInfo.ProductVersion", exe.replace('\'', "''"));@@ -13,6 +23,27 @@ fn exe_version(exe: &str) -> Option<String> { (!v.is_empty()).then_some(v) } +/// A version's numbers. Pure.+fn numbers(v: &str) -> Vec<u32> { v.split('.').filter_map(|x| x.trim().parse().ok()).collect() }++/// The newest `version="a.b.c"` on Altium's downloads page. Pure.+pub fn newest_on_page(html: &str) -> Option<String> {+ html.split("version=\"").skip(1).filter_map(|t| t.split('"').next())+ .filter(|v| v.split('.').count() == 3 && !numbers(v).is_empty() && numbers(v).len() == 3)+ .max_by_key(|v| numbers(v)).map(str::to_string)+}++/// Is `latest` (a release, a.b.c) newer than `installed` (a build, a.b.c.d)? Pure.+pub fn is_newer(latest: &str, installed: &str) -> bool {+ let (l, i) = (numbers(latest), numbers(installed));+ l.iter().take(3).cmp(i.iter().take(3)) == std::cmp::Ordering::Greater+}++fn fetch_newest() -> Result<String, String> {+ let body = ureq::get(DOWNLOADS).timeout(std::time::Duration::from_secs(30)).call().map_err(|e| e.to_string())?.into_string().map_err(|e| e.to_string())?;+ newest_on_page(&body).ok_or_else(|| "the downloads page lists no version any more".to_string())+}+ /// The open documents with unsaved changes. fn unsaved() -> Vec<String> { let d = crate::project::document_info(&json!({}));@@ -20,7 +51,27 @@ fn unsaved() -> Vec<String> { .filter(|x| x["modified"] == json!(true)).filter_map(|x| x["path"].as_str().or(x["name"].as_str()).map(str::to_string)).collect() } -/// altium_tool_update {action: check | apply | auto, enabled?}+/// HKCU preference keys of each Altium: (key under HKCU, edition).+fn pref_keys() -> Vec<(String, String)> {+ let ps = "Get-ChildItem 'HKCU:\\Software\\Altium' -ErrorAction SilentlyContinue | ForEach-Object { $_.PSChildName }";+ let Ok(o) = std::process::Command::new("powershell").args(["-NoProfile", "-Command", ps]).output() else { return vec![] };+ String::from_utf8_lossy(&o.stdout).lines().map(str::trim).filter(|l| l.starts_with("Altium Designer") && !l.ends_with("_Security"))+ .map(|l| (format!("HKCU:\\Software\\Altium\\{l}\\DesignExplorer\\Preferences\\ExtensionManager\\AutoUpdatePrefs"),+ if l.contains("Develop") { "Altium Designer Develop".to_string() } else { "Altium Designer".to_string() })).collect()+}++fn read_frequency(key: &str) -> Option<i64> {+ let ps = format!("(Get-ItemProperty -LiteralPath '{key}' -Name UpdatesCheckFrequency -ErrorAction Stop).UpdatesCheckFrequency");+ let o = std::process::Command::new("powershell").args(["-NoProfile", "-Command", &ps]).output().ok()?;+ String::from_utf8_lossy(&o.stdout).trim().parse().ok()+}++fn write_frequency(key: &str, v: i64) -> bool {+ let ps = format!("Set-ItemProperty -LiteralPath '{key}' -Name UpdatesCheckFrequency -Value '{v}' -ErrorAction Stop");+ std::process::Command::new("powershell").args(["-NoProfile", "-Command", &ps]).status().map(|s| s.success()).unwrap_or(false)+}++/// altium_tool_update {action: check | apply | auto, on?, humanIsPresent?} pub fn tool_update(args: &Value) -> Value { let action = crate::support::s(args, "action").unwrap_or_else(|| "check".into()).to_ascii_lowercase(); let installs: Vec<Value> = crate::support::detect_installs().into_iter().map(|mut i| {@@ -33,40 +84,93 @@ pub fn tool_update(args: &Value) -> Value { }).collect(); if installs.is_empty() { return crate::support::not_installed(); } let running = crate::health::is_running();+ let first = installs[0]["version"].as_str().unwrap_or("").to_string(); match action.as_str() { "check" => {- // Altium Develop's Extensions page lists extensions only, no Altium build on offer, and none of its content- // is in the UI Automation tree (measured 2026-10-30): the installed builds are read here, exactly, and what- // is on offer is said to be unknown rather than guessed- json!({"success": true, "installs": installs, "running": running, "checked": false, "offered": Value::Null,- "why": "Altium shows its updates on pages the bridge cannot read: Develop's Extensions & Updates page lists extensions only, and its content is not exposed to UI Automation",- "_hint": "installs gives each Altium on this machine with its exact build (from X2.EXE). Whether a newer build is offered is not readable from Altium yet: the user sees it in Altium (Extensions & Updates, or Altium's installer)."})+ let notice = crate::dialogs::reaped_log(500).iter().any(|r| r.to_string().contains("update_notice"));+ match fetch_newest() {+ Ok(newest) => {+ let installs: Vec<Value> = installs.into_iter().map(|mut i| { let o = i["version"].as_str().map(|v| is_newer(&newest, v)).unwrap_or(false); i["offered"] = if o { json!(newest) } else { Value::Null }; i }).collect();+ // an update is offered when any Altium here is behind; current is then that one's build+ let behind = installs.iter().find(|i| !i["offered"].is_null());+ let offered = if behind.is_some() { json!(newest) } else { Value::Null };+ let current = behind.and_then(|i| i["version"].as_str()).unwrap_or(&first).to_string();+ json!({"success": true, "current": current, "offered": offered, "newest": newest, "offeredFrom": DOWNLOADS, "installs": installs, "running": running, "checked": true, "noticeSeen": notice,+ "_hint": "installs gives each Altium here with its exact build and the release it could move to. newest is the newest release on Altium's own downloads page. noticeSeen says Altium raised its Update Available box since the bridge started (it names no version; the bridge closes it)."})+ }+ Err(e) => json!({"success": true, "current": first, "offered": Value::Null, "installs": installs, "running": running, "checked": false, "noticeSeen": notice, "why": format!("Altium's downloads page could not be read: {e}"),+ "_hint": "installs is exact. Whether a newer release is offered is unknown: the page did not answer."}),+ } } "apply" => { let open = if running { unsaved() } else { vec![] };- json!({"success": false, "errorCode": "not_supported", "unsaved": open, "installs": installs,- "error": "the bridge cannot apply an Altium update yet: Altium's update pages are not readable or drivable through UI Automation",- "_hint": "The user updates Altium from inside it (Extensions & Updates) or with Altium's installer; save open work first (unsaved lists it)."})+ if !open.is_empty() {+ return json!({"success": false, "errorCode": "unsaved_work", "unsaved": open, "applied": false, "error": format!("{} open document(s) have unsaved changes: save them first", open.len()), "_hint": "apply never closes unsaved work. altium_save keeps them; call again after."});+ }+ let newest = match fetch_newest() { Ok(n) => n, Err(e) => return json!({"success": false, "errorCode": "check_failed", "applied": false, "current": first, "error": format!("Altium's downloads page could not be read: {e}")}) };+ let Some(target) = installs.iter().find(|i| i["version"].as_str().map(|v| is_newer(&newest, v)).unwrap_or(false)) else {+ return json!({"success": true, "applied": false, "current": first, "offered": Value::Null, "newest": newest, "needsRestart": false, "_hint": "Every Altium here is on the newest release: nothing to apply."});+ };+ let edition = target["edition"].clone();+ let what = format!("Windows asks for an administrator's approval for Altium's installer, then it updates {} to {newest}. Altium has to be closed for it.", edition.as_str().unwrap_or("Altium"));+ let base = json!({"success": false, "errorCode": "needs_user", "applied": false, "needsRestart": true, "current": target["version"], "offered": newest, "edition": edition, "whatToApprove": what});+ if args.get("humanIsPresent").and_then(|v| v.as_bool()) != Some(true) {+ let mut out = base;+ out["error"] = json!("the update needs a person at the Windows approval prompt, which refuses itself after about two minutes with nobody there");+ out["_hint"] = json!("Tell the user what will change, then call again with humanIsPresent:true when they are at the machine: the bridge closes Altium (nothing unsaved) and starts Altium's own installer. Or they update from Altium: Help > Check for Updates.");+ return out;+ }+ if running {+ let c = crate::verbs::dispatch("close", &json!({}), &[]);+ if c.get("success").and_then(|b| b.as_bool()) != Some(true) { return json!({"success": false, "errorCode": "close_failed", "applied": false, "error": "Altium did not close, so its installer was not started", "close": c}); }+ }+ let inst = std::path::Path::new(target["base_dir"].as_str().unwrap_or("")).join("System").join("Installation").join("AltiumInstaller.exe");+ let started = std::process::Command::new(&inst).arg("-Update").spawn();+ let mut out = base;+ match started {+ Ok(_) => { out["started"] = json!(inst); out["_hint"] = json!("Altium's installer is running: the person approves the Windows prompt and follows its pages. Check afterwards with action:check; altium_launch starts Altium again."); }+ Err(e) => { out["started"] = Value::Null; out["error"] = json!(format!("Altium's installer did not start: {e}")); out["errorCode"] = json!("installer_failed"); }+ }+ out } "auto" => {- // Altium's own update check lives in its preferences: read the keys that name it- let la = std::env::var("APPDATA").unwrap_or_default();- let mut found = Vec::new();- for d in std::fs::read_dir(std::path::Path::new(&la).join("Altium")).into_iter().flatten().flatten() {- for f in std::fs::read_dir(d.path()).into_iter().flatten().flatten() {- let p = f.path();- let Ok(t) = std::fs::read_to_string(&p) else { continue };- for l in t.lines().filter(|l| { let x = l.to_ascii_lowercase(); x.contains("update") && x.contains('=') && (x.contains("check") || x.contains("auto")) }).take(10) {- found.push(json!({"file": p.to_string_lossy(), "line": l.trim()}));- }+ // only the keys that hold the setting: an old install's key may have none+ let keys: Vec<(String, String)> = pref_keys().into_iter().filter(|(k, _)| read_frequency(k).is_some()).collect();+ let read: Vec<Value> = keys.iter().map(|(k, e)| { let f = read_frequency(k); json!({"edition": e, "checkFrequency": f, "auto": f.map(|v| v != NEVER)}) }).collect();+ let want = args.get("on").or(args.get("enabled")).and_then(|v| v.as_bool());+ if let Some(on) = want {+ if running {+ return json!({"success": false, "errorCode": "altium_running", "auto": read.first().map(|r| r["auto"].clone()), "settings": read,+ "error": "Altium writes its preferences back when it exits, so its update check is set with Altium closed", "_hint": "altium_close, then call again."}); }+ let value = if on { DEFAULT_FREQUENCY } else { NEVER };+ let done = keys.iter().filter(|(k, _)| read_frequency(k).map(|f| (f != NEVER) != on).unwrap_or(false)).all(|(k, _)| write_frequency(k, value));+ let back: Vec<Value> = keys.iter().map(|(k, e)| { let f = read_frequency(k); json!({"edition": e, "checkFrequency": f, "auto": f.map(|v| v != NEVER)}) }).collect();+ let all = back.iter().all(|b| b["auto"] == json!(on));+ return json!({"success": done && all && !back.is_empty(), "mutated": true, "auto": on, "settings": back, "needsRestart": false, "_hint": "Altium's check frequency, read back. Altium reads it when it starts."}); }- if args.get("enabled").is_some() {- return json!({"success": false, "errorCode": "not_supported_yet", "settings": found,- "error": "setting Altium's update check is not done yet: Altium rewrites its preferences on exit, so a change has to go through its Preferences dialog"});- }- json!({"success": true, "settings": found, "_hint": "Altium's update-check settings as its preference files hold them."})+ let auto = read.iter().find_map(|r| r["auto"].as_bool());+ json!({"success": true, "auto": auto, "settings": read, "_hint": "Altium's own update check for each edition: checkFrequency is its Preferences > System > Installation setting, 0 is never. auto with on sets it, Altium closed."}) } o => json!({"success": false, "errorCode": "bad_args", "error": format!("action is check, apply or auto (got {o})")}), } }++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn the_newest_release_on_the_page() {+ let html = r#"<a version="26.9.1" x><a version="26.11.1"><a version="26.10.1"><meta version="1.0"><a version="9.9.9.9">"#;+ assert_eq!(newest_on_page(html).as_deref(), Some("26.11.1"), "numbers, not text: 26.11 beats 26.9");+ assert_eq!(newest_on_page("<html/>"), None);+ }++ #[test]+ fn a_release_is_newer_by_its_three_numbers() {+ assert!(is_newer("26.11.1", "26.9.1.9"));+ assert!(!is_newer("26.11.1", "26.11.1.5"), "the same release at any build");+ assert!(!is_newer("26.9.1", "26.11.1.5"));+ }+}
bridge-rs/src/verbs.rs+7−7@@ -452,14 +452,14 @@ fn describe() -> Value { json!({"edited": "[pour name]", "results": "[ok:<key> | err:<why>] per change, in order", "rulesWritten": "[{pour, rule, kind, gapMm, ok}] the clearance rules scoped to each pour", "before": "[{name, net, layer, pourIndex, filledMm2, islands}]", "after": "the same after the repour"}), 600, "Name pours as pour_state does. A net with no layer edits every pour on that net. Thermals (connect) are the pour's PolygonConnect rule, clearance a Clearance rule scoped IsNamedPolygon: both are Altium rules, named in the reply.", &["pour_state", "apply_pours", "remove_pours", "repour", "add_rule"], &["Clearance and thermals are rules: a broader rule of higher priority can still win; run_drc tells.", "The board is left unsaved: altium_save keeps it."], json!({"filePath": "C:/proj/Board.PcbDoc", "pours": [{"net": "GND", "layer": "B.Cu", "set": {"clearanceMm": 0.3, "connect": "relief", "reliefWidthMm": 0.3, "removeIslands": true}}]})),- verb_doc("tool_update", "Altium's own updates. check gives every Altium on this machine with its exact build; whether a newer build is offered is not readable from Altium yet, so offered is null with the reason. auto reads Altium's own update-check settings. apply is refused by name until Altium's update pages can be driven.",- json!({"action": "check | apply | auto, default check", "enabled": "bool (auto): refused for now - Altium rewrites its preferences on exit"}),- json!({"installs": "[{edition, version, major, exe}]", "checked": "bool: whether an offer could be read (false today)", "offered": "the newer build on offer, or null", "why": "why offered is unknown", "unsaved": "[document] (apply)", "settings": "[{file, line}] (auto)"}), 60,- "Read-only: nothing is opened or changed in Altium.",- &["install", "readiness", "license_status"], &["Altium shows its updates on pages the bridge cannot read: the user updates Altium from inside it or with Altium's installer."], json!({"action": "check"})),+ verb_doc("tool_update", "Altium's own updates. check gives every Altium on this machine with its exact build and the newest release on Altium's downloads page. apply refuses with unsaved documents, and otherwise answers needs_user with what a person has to approve: with humanIsPresent it closes Altium and starts Altium's own installer. auto reads or sets Altium's own update check.",+ json!({"action": "check | apply | auto, default check", "on": "bool (auto): turn Altium's update check on or off, with Altium closed; omitted, it is read", "humanIsPresent": "bool (apply): a person is at the machine to approve the Windows prompt"}),+ json!({"current": "the installed version", "offered": "the newer release, or null", "newest": "the newest release on Altium's downloads page", "installs": "[{edition, version, major, exe, offered}]", "checked": "bool: the page answered", "noticeSeen": "bool: Altium raised its Update Available box since the bridge started", "applied": "bool", "whatToApprove": "string (apply)", "started": "the installer started (apply)", "unsaved": "[document] (apply)", "needsRestart": "bool", "auto": "bool", "settings": "[{edition, checkFrequency, auto}]"}), 150,+ "Updating Altium is the user's machine changing, so say so before apply with humanIsPresent.",+ &["install", "readiness", "license_status"], &["Altium's installer asks for a Windows approval that refuses itself after about two minutes with nobody there, so apply never starts it unasked; a refused prompt leaves a windowless AltiumInstaller.exe behind, which does nothing and can be ended.", "Altium writes its preferences back when it exits, so on is refused while Altium runs."], json!({"action": "check"})), verb_doc("import_design", "Bring a foreign design into a new Altium project: eagle through Altium's Import Wizard (the schematic and its board together), kicad through Altium's KiCad importer. A format the bridge does not drive yet is refused by name.",- json!({"format": "eagle | kicad (required)", "filePath": "the design: an EAGLE .sch or .brd (its pair beside it comes too), or a KiCad file (required)", "outputDir": "where to look for the new project, default the source's folder", "timeout": "seconds (kicad), default 300"}),- json!({"project": "the new .PrjPcb", "files": "[the files imported]", "steps": "[every wizard step and how it went]", "agentRestarted": "bool"}), 900,+ json!({"format": "eagle | kicad (required)", "filePath": "the design: an EAGLE .sch or .brd (its pair beside it comes too), or a KiCad file (required)", "boardPath": "the EAGLE board, when its name differs from the schematic's", "name": "rename the new project", "outputDir": "the folder the new project goes in, default the source's folder", "timeout": "seconds (kicad), default 300"}),+ json!({"design": "the new .PrjPcb", "project": "the same", "parts": "int", "nets": "int", "warnings": "[what the importer's log says it could not read]", "check": "{imported, source, matchesSource, unconnected}: the board against the EAGLE file", "files": "[the files imported]", "steps": "[every wizard step and how it went]", "agentRestarted": "bool"}), 900, "The wizard runs outside the script engine with Altium's own import options. Its importer list takes a real click (it answers no UI Automation), so EAGLE briefly moves the pointer.", &["import_kicad", "open_project", "project_info"], &["Altium's Import Wizard also reads PADS, OrCAD, P-CAD, Allegro, xDxDesigner, CADSTAR and Zuken: those are refused by name until the bridge drives them."], json!({"format": "eagle", "filePath": "C:/designs/Board.sch"})), verb_doc("export_3d", "The board's 3D model in another format than STEP, by Altium's own exporter (File > Export): Parasolid (.x_t) or VRML (.wrl). step answers through export_step; a format Altium does not write is refused by name.",
dev-skills/altium-bridge-test/fixtures/eagle-small.brdadded+63@@ -0,0 +1,63 @@+<?xml version="1.0" encoding="utf-8"?>+<!DOCTYPE eagle SYSTEM "eagle.dtd">+<eagle version="9.6.2">+<drawing>+<settings><setting alwaysvectorfont="no"/></settings>+<grid distance="0.1" unitdist="inch" unit="inch" style="lines" multiple="1" display="no" altdistance="0.01" altunitdist="inch" altunit="inch"/>+<layers>+<layer number="1" name="Top" color="4" fill="1" visible="yes" active="yes"/>+<layer number="16" name="Bottom" color="1" fill="1" visible="yes" active="yes"/>+<layer number="17" name="Pads" color="2" fill="1" visible="yes" active="yes"/>+<layer number="18" name="Vias" color="2" fill="1" visible="yes" active="yes"/>+<layer number="20" name="Dimension" color="15" fill="1" visible="yes" active="yes"/>+<layer number="21" name="tPlace" color="16" fill="1" visible="yes" active="yes"/>+<layer number="25" name="tNames" color="7" fill="1" visible="yes" active="yes"/>+<layer number="27" name="tValues" color="7" fill="1" visible="yes" active="yes"/>+<layer number="29" name="tStop" color="7" fill="3" visible="no" active="yes"/>+<layer number="31" name="tCream" color="7" fill="4" visible="no" active="yes"/>+<layer number="91" name="Nets" color="2" fill="1" visible="yes" active="yes"/>+<layer number="94" name="Symbols" color="4" fill="1" visible="yes" active="yes"/>+<layer number="95" name="Names" color="7" fill="1" visible="yes" active="yes"/>+<layer number="96" name="Values" color="7" fill="1" visible="yes" active="yes"/>+</layers>+<board>+<plain>+<wire x1="0" y1="0" x2="20" y2="0" width="0.1" layer="20"/>+<wire x1="20" y1="0" x2="20" y2="10" width="0.1" layer="20"/>+<wire x1="20" y1="10" x2="0" y2="10" width="0.1" layer="20"/>+<wire x1="0" y1="10" x2="0" y2="0" width="0.1" layer="20"/>+</plain>+<libraries>+<library name="adom-battery">+<packages>+<package name="R0603">+<smd name="1" x="-0.8" y="0" dx="0.8" dy="0.9" layer="1"/>+<smd name="2" x="0.8" y="0" dx="0.8" dy="0.9" layer="1"/>+<text x="0" y="1" size="0.6" layer="25">>NAME</text>+<text x="0" y="-1.6" size="0.6" layer="27">>VALUE</text>+</package>+</packages>+</library>+</libraries>+<attributes/>+<variantdefs/>+<classes><class number="0" name="default" width="0" drill="0"/></classes>+<designrules name="default"/>+<elements>+<element name="R1" library="adom-battery" package="R0603" value="1k" x="5" y="5"/>+<element name="R2" library="adom-battery" package="R0603" value="1k" x="15" y="5"/>+</elements>+<signals>+<signal name="IN"><contactref element="R1" pad="1"/></signal>+<signal name="MID">+<contactref element="R1" pad="2"/>+<contactref element="R2" pad="1"/>+<wire x1="5.8" y1="5" x2="10" y2="5" width="0.25" layer="1"/>+<via x="10" y="5" extent="1-16" drill="0.4"/>+<wire x1="10" y1="5" x2="14.2" y2="5" width="0.25" layer="1"/>+</signal>+<signal name="OUT"><contactref element="R2" pad="2"/></signal>+</signals>+</board>+</drawing>+</eagle>
dev-skills/altium-bridge-test/fixtures/eagle-small.schadded+84@@ -0,0 +1,84 @@+<?xml version="1.0" encoding="utf-8"?>+<!DOCTYPE eagle SYSTEM "eagle.dtd">+<eagle version="9.6.2">+<drawing>+<settings><setting alwaysvectorfont="no"/></settings>+<grid distance="0.1" unitdist="inch" unit="inch" style="lines" multiple="1" display="no" altdistance="0.01" altunitdist="inch" altunit="inch"/>+<layers>+<layer number="1" name="Top" color="4" fill="1" visible="yes" active="yes"/>+<layer number="16" name="Bottom" color="1" fill="1" visible="yes" active="yes"/>+<layer number="17" name="Pads" color="2" fill="1" visible="yes" active="yes"/>+<layer number="18" name="Vias" color="2" fill="1" visible="yes" active="yes"/>+<layer number="20" name="Dimension" color="15" fill="1" visible="yes" active="yes"/>+<layer number="21" name="tPlace" color="16" fill="1" visible="yes" active="yes"/>+<layer number="25" name="tNames" color="7" fill="1" visible="yes" active="yes"/>+<layer number="27" name="tValues" color="7" fill="1" visible="yes" active="yes"/>+<layer number="29" name="tStop" color="7" fill="3" visible="no" active="yes"/>+<layer number="31" name="tCream" color="7" fill="4" visible="no" active="yes"/>+<layer number="91" name="Nets" color="2" fill="1" visible="yes" active="yes"/>+<layer number="94" name="Symbols" color="4" fill="1" visible="yes" active="yes"/>+<layer number="95" name="Names" color="7" fill="1" visible="yes" active="yes"/>+<layer number="96" name="Values" color="7" fill="1" visible="yes" active="yes"/>+</layers>+<schematic>+<libraries>+<library name="adom-battery">+<packages>+<package name="R0603">+<smd name="1" x="-0.8" y="0" dx="0.8" dy="0.9" layer="1"/>+<smd name="2" x="0.8" y="0" dx="0.8" dy="0.9" layer="1"/>+<text x="0" y="1" size="0.6" layer="25">>NAME</text>+<text x="0" y="-1.6" size="0.6" layer="27">>VALUE</text>+</package>+</packages>+<symbols>+<symbol name="R">+<wire x1="-2.54" y1="1" x2="2.54" y2="1" width="0.254" layer="94"/>+<wire x1="2.54" y1="1" x2="2.54" y2="-1" width="0.254" layer="94"/>+<wire x1="2.54" y1="-1" x2="-2.54" y2="-1" width="0.254" layer="94"/>+<wire x1="-2.54" y1="-1" x2="-2.54" y2="1" width="0.254" layer="94"/>+<text x="-2.54" y="1.5" size="1.778" layer="95">>NAME</text>+<text x="-2.54" y="-3.2" size="1.778" layer="96">>VALUE</text>+<pin name="1" x="-5.08" y="0" visible="off" length="short" direction="pas"/>+<pin name="2" x="5.08" y="0" visible="off" length="short" direction="pas" rot="R180"/>+</symbol>+</symbols>+<devicesets>+<deviceset name="R" prefix="R" uservalue="yes">+<gates><gate name="G$1" symbol="R" x="0" y="0"/></gates>+<devices>+<device name="" package="R0603">+<connects>+<connect gate="G$1" pin="1" pad="1"/>+<connect gate="G$1" pin="2" pad="2"/>+</connects>+<technologies><technology name=""/></technologies>+</device>+</devices>+</deviceset>+</devicesets>+</library>+</libraries>+<classes><class number="0" name="default" width="0" drill="0"/></classes>+<parts>+<part name="R1" library="adom-battery" deviceset="R" device="" value="1k"/>+<part name="R2" library="adom-battery" deviceset="R" device="" value="1k"/>+</parts>+<sheets>+<sheet>+<plain/>+<instances>+<instance part="R1" gate="G$1" x="50.8" y="50.8"/>+<instance part="R2" gate="G$1" x="76.2" y="50.8"/>+</instances>+<busses/>+<nets>+<net name="IN" class="0"><segment><pinref part="R1" gate="G$1" pin="1"/><wire x1="45.72" y1="50.8" x2="40.64" y2="50.8" width="0.1524" layer="91"/><label x="40.64" y="50.8" size="1.778" layer="95"/></segment></net>+<net name="MID" class="0"><segment><pinref part="R1" gate="G$1" pin="2"/><pinref part="R2" gate="G$1" pin="1"/><wire x1="55.88" y1="50.8" x2="71.12" y2="50.8" width="0.1524" layer="91"/></segment></net>+<net name="OUT" class="0"><segment><pinref part="R2" gate="G$1" pin="2"/><wire x1="81.28" y1="50.8" x2="86.36" y2="50.8" width="0.1524" layer="91"/><label x="86.36" y="50.8" size="1.778" layer="95"/></segment></net>+</nets>+</sheet>+</sheets>+</schematic>+</drawing>+</eagle>
dev-skills/altium-bridge-test/run_verb_tests.py+16−5@@ -111,7 +111,10 @@ def matrix(w): M["launch"] = dict(phase=1, timeout=300, **ok(waitSec=150)) M["agent_start"] = dict(phase=1, **ok()) # 0.2.88: the standard's tool_update: every Altium here with its exact build (read-only)- M["tool_update"] = dict(phase=1, timeout=150, **ok(action="check"), check=lambda d: len(d.get("installs") or []) >= 1 and all(i.get("version") for i in d["installs"]) and "offered" in d)+ # 0.2.89: the offer is read from Altium's downloads page; apply without a person there starts nothing+ M["tool_update"] = dict(phase=1, timeout=150, **ok(action="check"), check=lambda d: len(d.get("installs") or []) >= 1 and all(i.get("version") for i in d["installs"]) and d.get("checked") is True and d.get("newest") and "offered" in d+ and w["call"]("altium_tool_update", {"action": "auto"}).get("auto") in (True, False)+ and (lambda a: a.get("applied") is False and not a.get("started") and (a.get("errorCode") in ("needs_user", "unsaved_work") or a.get("offered") is None))(w["call"]("altium_tool_update", {"action": "apply"}))) # 0.2.85: the standard's prewarm, with Altium up and the agent resident: idempotent, ready, nothing opened M["prewarm"] = dict(phase=1, timeout=150, **ok(), check=lambda d: d.get("ready") is True and any(x.get("step") == "agent" and x.get("done") for x in d.get("steps") or []))@@ -469,8 +472,16 @@ def matrix(w): # 0.2.88: the standard's export_3d through Altium's own Parasolid exporter (File > Export, its dialogs answered) M["export_3d"] = dict(phase=3.5, timeout=360, **ok(filePath=LB, format="parasolid", outputDir=D + "/export"), check=lambda d: (d.get("bytes") or 0) > 1000 and str(d.get("path", "")).lower().endswith(".x_t"))- # 0.2.88: the standard's import_design: a format the bridge does not drive yet is refused by name- M["import_design"] = dict(phase=3.5, **ref("PADS is not driven yet: a named refusal", format="pads", filePath=LB))+ # 0.2.89: the standard's import_design: a small EAGLE pair through Altium's Import Wizard, matched against its source;+ # a format the bridge does not drive yet is refused by name, and the imported project is closed again+ def eagle_ok(d):+ c = d.get("check") or {}+ good = (d.get("parts") == 2 and d.get("nets") == 3 and c.get("matchesSource") is True and c.get("unconnected") == 0+ and isinstance(d.get("warnings"), list) and str(d.get("design", "")).lower().endswith("eagle-small.prjpcb"))+ for ext in ("PcbDoc", "SchDoc", "PrjPcb"):+ w["call"]("altium_close_document", {"filePath": str(d.get("design", ""))[:-len("PrjPcb")] + ext})+ return good and w["call"]("altium_import_design", {"format": "pads", "filePath": LB}).get("errorCode") == "unsupported"+ M["import_design"] = dict(phase=3.5, timeout=300, **ok(format="eagle", filePath=D + "/eagle/eagle-small.sch"), check=eagle_ok) M["render_board_layers"] = dict(phase=3.5, timeout=700, **ok(filePath=LB, preset="top_copper", dpi=100), check=lambda d: str(d.get("path", "")).endswith(".png")) M["library_views"] = dict(phase=3.5, timeout=600, **anyo("symbol and footprint pictures of TST_SOIC8", libraryPath=SL, parts=["TST_SOIC8"], views=["symbol", "footprint"])) M["export_library_part"] = dict(phase=3.5, timeout=600, **anyo("the symbol and footprint in their own libraries, model missing named", part="TST_SOIC8", libraryPath=SL, outputDir=D + "/export"))@@ -634,13 +645,13 @@ def main(): call=lambda verb, args: ab(T, TH, verb, args)) # a check that needs a second verb's answer # fixtures -> scratch copies on the target- fx = [os.path.join(a.fixtures, n) for n in ("Adom_Test.SchLib", "Adom_Test.PcbLib")]+ fx = [os.path.join(a.fixtures, n) for n in ("Adom_Test.SchLib", "Adom_Test.PcbLib", "eagle-small.sch", "eagle-small.brd")] for f in fx: if not os.path.isfile(f): sys.exit(f"missing fixture {f}") ab(T, TH, "send_files", {"filePaths": fx}, timeout=300) dw = D.replace("/", "\\"); hw = home.replace("/", "\\")- ab(T, TH, "shell_execute", {"command": f'cmd /c rmdir /S /Q "{dw}" 2>nul & mkdir "{dw}" & move /Y "{hw}\\Downloads\\Adom_Test.SchLib" "{dw}\\Battery.SchLib" & move /Y "{hw}\\Downloads\\Adom_Test.PcbLib" "{dw}\\Battery.PcbLib"'})+ ab(T, TH, "shell_execute", {"command": f'cmd /c rmdir /S /Q "{dw}" 2>nul & mkdir "{dw}" & move /Y "{hw}\\Downloads\\Adom_Test.SchLib" "{dw}\\Battery.SchLib" & move /Y "{hw}\\Downloads\\Adom_Test.PcbLib" "{dw}\\Battery.PcbLib" & mkdir "{dw}\\eagle" & move /Y "{hw}\\Downloads\\eagle-small.sch" "{dw}\\eagle\\" & move /Y "{hw}\\Downloads\\eagle-small.brd" "{dw}\\eagle\\"'}) # 0.2.80: Altium's own simulation example (its sheet 3, a one-transistor amplifier) for simulate and export_spice ex = "C:\\Users\\Public\\Documents\\Altium\\{}\\Examples\\Simulation Quick Start" ab(T, TH, "shell_execute", {"command": f'cmd /c (if exist "{ex.format("ADDevelop")}" (xcopy /E /I /Y /Q "{ex.format("ADDevelop")}" "{dw}\\sim") else (xcopy /E /I /Y /Q "{ex.format("AD26")}" "{dw}\\sim")) >nul'})
package.json+8−2@@ -1,6 +1,6 @@ { "slug": "altium-bridge",- "version": "0.2.88",+ "version": "0.2.89", "type": "app", "description": "Let an AI (Claude, ChatGPT, Codex or any agent) run Altium Designer for you: create symbols and footprints, place parts (also from Altium 365), wire and annotate schematics, Update PCB, set the stack-up and rules, route, pour copper, add mounting holes and stitching vias, run ERC and DRC, and make Gerbers, BOMs and STEP. Free in Hydrogen; bring your own AI and Altium licence.", "tags": [@@ -284,7 +284,13 @@ "edit a polygon pour in altium", "place an enclosure step with my altium board", "does the board fit the enclosure altium",- "which altium version is installed"+ "which altium version is installed",+ "import an eagle design into altium",+ "eagle to altium",+ "import eagle board into altium",+ "check for altium updates",+ "is there a newer altium version",+ "turn off altium update check" ], "discovery_pitch": "An AI that runs Altium Designer in the user's own session: libraries, schematics, Update PCB, stack-up, routing, DRC, Gerbers and BOMs.", "sample_prompts": [
page.json+9−3@@ -4,7 +4,7 @@ "type": "app", "title": "Altium Bridge: AI for Altium Designer", "brief": "Let an AI (Claude, ChatGPT, Codex or any agent) run Altium Designer for you: create symbols and footprints, place parts (also from Altium 365), wire and annotate schematics, Update PCB, set the stack-up and rules, route, pour copper, add mounting holes and stitching vias, run ERC and DRC, and make Gerbers, BOMs and STEP. Free in Hydrogen; bring your own AI and Altium licence.",- "version": "0.2.88",+ "version": "0.2.89", "hero": { "type": "image", "path": "screenshots/hero.png"@@ -276,7 +276,13 @@ "edit a polygon pour in altium", "place an enclosure step with my altium board", "does the board fit the enclosure altium",- "which altium version is installed"+ "which altium version is installed",+ "import an eagle design into altium",+ "eagle to altium",+ "import eagle board into altium",+ "check for altium updates",+ "is there a newer altium version",+ "turn off altium update check" ], "discovery_pitch": "An AI that runs Altium Designer in the user's own session: libraries, schematics, Update PCB, stack-up, routing, DRC, Gerbers and BOMs.", "metadata": {},@@ -331,4 +337,4 @@ "tools/symbol_modes.py", "uninstall.sh" ]-}+}
src/BRIDGE_VERSION+1−1@@ -1 +1 @@-0.2.88+0.2.89
src/bridge.json+2−2@@ -2,7 +2,7 @@ "manifest_version": 1, "name": "altium", "displayName": "Altium Designer",- "version": "0.2.88",+ "version": "0.2.89", "description": "Drive Altium Designer from Adom: a resident DelphiScript agent (eval + the 1,100-command process launcher), the X2 -R command line, UIA over the VCL shell, dialogs by PID, screenshots of every Altium window, and Altium 365.", "homepage": "https://wiki.adom.inc/adom/altium-bridge", "docs": "https://wiki.adom.inc/adom/altium-bridge",@@ -302,7 +302,7 @@ "launch": 240, "panelize": 240, "impedance": 120,- "current_capacity": 120, "plan_route": 300, "place_decoupling": 300, "plan_fanout": 300, "estimate_cost": 120, "simulate": 900, "export_spice": 900, "update_footprints_from_library": 600, "lint_library": 600, "export_pos": 120, "verb_times": 15, "prewarm": 120, "render_board": 300, "log_tail": 60, "sch_batch": 900, "import_step": 180, "edit_pours": 600, "export_3d": 360, "tool_update": 120, "import_design": 900,+ "current_capacity": 120, "plan_route": 300, "place_decoupling": 300, "plan_fanout": 300, "estimate_cost": 120, "simulate": 900, "export_spice": 900, "update_footprints_from_library": 600, "lint_library": 600, "export_pos": 120, "verb_times": 15, "prewarm": 120, "render_board": 300, "log_tail": 60, "sch_batch": 900, "import_step": 180, "edit_pours": 600, "export_3d": 360, "tool_update": 150, "import_design": 900, "height_check": 150, "copper_balance": 240, "return_path": 240,