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.100: compile_intlib reports a written IntLib as success, and proves it on disk (#34)
10 files changed
+168−18
CHANGELOG.md+7@@ -1,5 +1,12 @@ # Changelog +## 0.2.100++- **`altium_compile_intlib` reports success when the IntLib is written** (#34). Every compile showed Altium's error box "Could not create integrated library ." and answered `agent_script_error`, although the `.IntLib` was written correctly. Compiling a LibPkg already builds its IntLib; the verb then built it a second time with `CreateIntegratedLibrary`, whose second argument is the output file, and passed it an empty name. That second build now runs only when you name an output, and it writes to that file without installing it.+- **The reply proves the file on disk.** It gives `intlib` (the path), `written` (true only when this call changed the file) and `bytes`, and lists the LibPkg's `sources`. `output` takes a folder (the IntLib inside is named after the LibPkg) or a full `.IntLib` path; without it the IntLib goes to the LibPkg's own output folder, `Project Outputs for <name>`.+- New refusals: `libpkg_not_found` for a path that does not exist, `intlib_not_written` when no new IntLib appeared, and `libpkg_sources_missing` (with `missingSources`) when a library the LibPkg lists is not on disk, since Altium then writes an IntLib without those parts.+- Tested on Altium Designer 26.11.1, with a LibPkg under a folder named with Ñ and ú: three compiles in a row, an output folder, a named `Mía.IntLib`, a LibPkg Altium had never opened, a missing LibPkg and one with a missing SchLib. Every one answered correctly with no error box, and each IntLib had all its parts (33,792 bytes). The battery's `compile_intlib` now compiles a real LibPkg instead of checking a refusal.+ ## 0.2.99 - **The dashboard never starts Altium on a machine you did not choose** (#33). It used to drive the first machine Adom Bridge listed, and opening it on a Linux computer launched Altium Designer on someone else's laptop.
README.md+1−1@@ -445,7 +445,7 @@ All 281 verbs, by area (prefix `altium_`). `altium_describe` returns the live ca - `altium_install_library`: Register a library file in Altium's Installed Libraries (IntegratedLibraryManager.InstallLibrary) so its parts appear in the Components panel. - `altium_install_library_bundle` - `altium_install_receipt`: The last bundle install's full receipt (proof frame included), for a client whose install call outlived ab's budget.-- `altium_compile_intlib`: Compile a .LibPkg into an integrated library (.IntLib).+- `altium_compile_intlib`: Compile a .LibPkg into an integrated library (.IntLib) and confirm the file on disk. - `altium_extract_intlib`: Extract the editable .SchLib/.PcbLib sources from a compiled .IntLib (Altium writes them next to the IntLib and opens them). - `altium_place_on_sch`: Place one symbol, or a ';' list of symbols, from the open SchLib on ONE new sheet (sheet sized FROM the measured parts: 500 mil gaps, 600 mil margins, A4 minimum; parts inside the frame as U1..Un with the part number as Comment); fills the title block from title/number/revision/drawnBy and places description as a text frame; saves to schPath when given. - `altium_place_on_pcb`: Place ONE footprint from a PcbLib on a new board and return a proof frame.
bridge-rs/src/library.rs+130−2@@ -331,12 +331,122 @@ pub fn install_library(args: &Value) -> Value { r } +/// The LibPkg's name without folder or extension: Altium names the IntLib after it.+fn libpkg_stem(libpkg: &str) -> String {+ let file = libpkg.rsplit(['\\', '/']).next().unwrap_or(libpkg);+ match file.rfind('.') { Some(i) if i > 0 => file[..i].to_string(), _ => file.to_string() }+}++/// Where `output` asks for the IntLib (altium-bridge#34). `None` = the LibPkg's own output folder+/// (`Project Outputs for <name>` unless the project says otherwise). A path ending in `.IntLib` is the file+/// itself; anything else is a folder, and the file inside it is named after the LibPkg.+pub fn intlib_target(libpkg: &str, output: &str) -> Option<String> {+ let o = output.trim();+ if o.is_empty() {+ return None;+ }+ if o.to_ascii_lowercase().ends_with(".intlib") {+ return Some(o.to_string());+ }+ Some(format!("{}\\{}.IntLib", o.trim_end_matches(['\\', '/']), libpkg_stem(libpkg)))+}++/// The IntLib a compile wrote into `folder`: `<stem>.IntLib` when it is there, else the newest `.IntLib` in it.+fn intlib_in(folder: &str, stem: &str) -> String {+ let dir = folder.replace('/', "\\");+ let dir = dir.trim_end_matches('\\');+ let named = format!("{dir}\\{stem}.IntLib");+ if std::path::Path::new(&named).is_file() {+ return named;+ }+ std::fs::read_dir(dir).ok().and_then(|rd| {+ rd.flatten()+ .filter(|e| e.path().extension().map(|x| x.eq_ignore_ascii_case("intlib")).unwrap_or(false))+ .filter_map(|e| Some((e.metadata().ok()?.modified().ok()?, e.path())))+ .max_by_key(|(t, _)| *t)+ .map(|(_, p)| p.to_string_lossy().into_owned())+ }).unwrap_or(named)+}++/// The source documents a LibPkg lists (`DocumentPath=`), made absolute against its folder.+pub fn libpkg_sources(libpkg: &str, text: &str) -> Vec<String> {+ let dir = match libpkg.rfind(['\\', '/']) { Some(i) => &libpkg[..i], None => "" };+ text.lines().filter_map(|l| {+ let t = l.trim();+ let v = t.get(..13).filter(|k| k.eq_ignore_ascii_case("documentpath=")).map(|_| t[13..].trim())?;+ if v.is_empty() { return None; }+ let v = v.replace('/', "\\");+ Some(if v.len() >= 2 && v.as_bytes()[1] == b':' || v.starts_with("\\\\") { v } else { format!("{dir}\\{v}") })+ }).collect()+}++/// altium-bridge#34: the reply now says where the IntLib is and that it was written by THIS call, read from the+/// file on disk, not inferred from the script finishing. pub fn compile_intlib(args: &Value) -> Value { let p = match s(args, "libpkgPath") { Some(l) if !l.is_empty() => l,- _ => return json!({"success": false, "error": "libpkgPath (.LibPkg) is required; output = destination dir"}),+ _ => return json!({"success": false, "error": "libpkgPath (.LibPkg) is required; output = destination folder or .IntLib path"}), };- lib_call(args, "compile_intlib", vec![("path", p), ("output", s_or(args, "output", ""))], None, 300)+ if !std::path::Path::new(&p).is_file() {+ return json!({"success": false, "errorCode": "libpkg_not_found", "error": format!("LibPkg not found: {p}"),+ "_hint": "libpkgPath is a path on the Windows machine running Altium. Check the folder and the .LibPkg name."});+ }+ // a source the LibPkg lists but the disk lacks still compiles, into an IntLib without its parts+ let bytes = std::fs::read(&p).unwrap_or_default();+ let sources = libpkg_sources(&p, &String::from_utf8(bytes.clone()).unwrap_or_else(|_| bytes.iter().map(|&c| c as char).collect()));+ let missing: Vec<&String> = sources.iter().filter(|f| !std::path::Path::new(f.as_str()).is_file()).collect();+ let target = intlib_target(&p, &s_or(args, "output", ""));+ if let Some(t) = &target {+ if let Some(dir) = std::path::Path::new(t).parent() {+ let _ = std::fs::create_dir_all(dir);+ }+ }+ let mtime = |f: &str| std::fs::metadata(f).ok().and_then(|m| Some((m.len(), m.modified().ok()?)));+ // the default file's time before the call: "written" means it changed, not merely that a file is there+ let default_file = |folder: &str| intlib_in(folder, &libpkg_stem(&p));+ let guess = target.clone().unwrap_or_else(|| {+ let dir = std::path::Path::new(&p).parent().map(|d| d.to_string_lossy().into_owned()).unwrap_or_default();+ default_file(&format!("{dir}\\Project Outputs for {}", libpkg_stem(&p)))+ });+ let before = mtime(&guess);+ // a project with its own output folder: no earlier time to compare with, so newer than this call's start+ let started = std::time::SystemTime::now() - Duration::from_secs(2);+ let mut r = lib_call(args, "compile_intlib", vec![("path", p.clone()), ("outfile", target.clone().unwrap_or_default())], None, 300);+ if r.get("success").and_then(|b| b.as_bool()) != Some(true) {+ return r;+ }+ let d = r.get("data").cloned().unwrap_or(json!({}));+ let folder = d.get("projectOutputPath").and_then(|v| v.as_str()).unwrap_or("").to_string();+ let file = target.clone().unwrap_or_else(|| default_file(&folder));+ let was = if file.replace('/', "\\").eq_ignore_ascii_case(&guess.replace('/', "\\")) { before } else { None };+ let fresh = mtime(&file).filter(|(_, t)| match was { Some((_, w)) => *t > w, None => *t >= started });+ r["intlib"] = json!(file);+ r["sources"] = json!(sources);+ if !missing.is_empty() && fresh.is_some() {+ r["success"] = json!(false);+ r["written"] = json!(true);+ r["errorCode"] = json!("libpkg_sources_missing");+ r["missingSources"] = json!(missing);+ r["error"] = json!(format!("the LibPkg lists {} source librar{} that {} not on disk, so the IntLib was written without {}", missing.len(),+ if missing.len() == 1 { "y" } else { "ies" }, if missing.len() == 1 { "is" } else { "are" }, if missing.len() == 1 { "its parts" } else { "their parts" }));+ r["_hint"] = json!("Fix the DocumentPath lines in the .LibPkg (they are relative to its folder) or put the libraries there, then compile again.");+ return r;+ }+ match fresh {+ Some((len, _)) => {+ r["written"] = json!(true);+ r["bytes"] = json!(len);+ r["_hint"] = json!("The IntLib on disk was written by this call. Next: altium_install_library {libraryPath: intlib} to use it in Altium, or altium_list_library on it to check its parts.");+ }+ None => {+ r["success"] = json!(false);+ r["written"] = json!(false);+ r["errorCode"] = json!("intlib_not_written");+ r["error"] = json!(format!("Altium compiled the LibPkg but no new IntLib appeared at {file}"));+ r["_hint"] = json!("A compile that stops on an error writes nothing. altium_compile {projectPath: <the .LibPkg>} lists Altium's messages for it (a source library not found, a symbol whose footprint is missing from the PcbLib).");+ }+ }+ r } pub fn extract_intlib(args: &Value) -> Value {@@ -1052,6 +1162,24 @@ pub fn uninstall_library(args: &Value) -> Value { mod tests { use super::*; + #[test]+ fn libpkg_sources_resolve_against_its_folder() {+ let pkg = r"C:\Lib\Mine.LibPkg";+ let text = "[Design]\r\nVersion=1.0\r\n\r\n[Document1]\r\nDocumentPath=Mine\\Mine.SchLib\r\n\r\n[Document2]\r\nDocumentPath=D:\\Shared\\Big.PcbLib\r\n[Document3]\r\nDocumentPath=\r\n";+ assert_eq!(libpkg_sources(pkg, text), vec![r"C:\Lib\Mine\Mine.SchLib".to_string(), r"D:\Shared\Big.PcbLib".to_string()]);+ }++ #[test]+ fn intlib_output_is_a_file_or_a_folder_named_after_the_libpkg() {+ let pkg = r"C:\Users\Iván\Resources\Librerias\LDO_5V_3V3_Board.LibPkg";+ // no output: the LibPkg's own output folder, and only DM_Compile runs (altium-bridge#34)+ assert_eq!(intlib_target(pkg, ""), None);+ assert_eq!(intlib_target(pkg, r"C:\out\"), Some(r"C:\out\LDO_5V_3V3_Board.IntLib".to_string()));+ assert_eq!(intlib_target(pkg, "C:/out"), Some(r"C:/out\LDO_5V_3V3_Board.IntLib".to_string()));+ assert_eq!(intlib_target(pkg, r"C:\out\Mine.IntLib"), Some(r"C:\out\Mine.IntLib".to_string()));+ assert_eq!(libpkg_stem("C:/a.b/Lib.LibPkg"), "Lib");+ }+ #[test] fn install_receipt_is_remembered_and_the_status_summary_stays_light() { remember_install(&json!({"success": true, "library": "L", "installId": "L-1", "thumbnailDataUrl": "data:x",
bridge-rs/src/main.rs+1−1@@ -81,7 +81,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.99";+pub const BRIDGE_VERSION: &str = "0.2.100"; 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/verbs.rs+5−5@@ -1509,11 +1509,11 @@ fn describe() -> Value { "Takes effect live, no restart. For a wiki bundle zip use altium_install_library_bundle (unpack + register + proof).", &["install_library_bundle", "list_library", "show_library"], &["'library not found' = the path must exist on THIS machine.", "Registers the file where it is: moving or deleting it later leaves a dead entry."], json!({"libraryPath": "C:/lib/Adom_ToF.SchLib"})),- verb_doc("compile_intlib", "Compile a .LibPkg into an integrated library (.IntLib).",- json!({"libpkgPath": "path to a .LibPkg (required)", "output": "destination directory", "timeout": "seconds, default 300"}),- json!({"data": "{libpkg, outputDir}", "roundtripMs": "int"}), 300,- "Then altium_install_library {libraryPath: <the .IntLib>}. Check the file exists: the reply does not verify it was written.",- &["extract_intlib", "install_library"], &["The LibPkg is opened as a project in the user's workspace and stays open.", "success only means the compile was dispatched; verify the .IntLib on disk."],+ verb_doc("compile_intlib", "Compile a .LibPkg into an integrated library (.IntLib) and confirm the file on disk.",+ json!({"libpkgPath": "path to a .LibPkg (required)", "output": "optional: a folder (the IntLib inside it is named after the LibPkg) or a full .IntLib path. Default: the LibPkg's own output folder, 'Project Outputs for <name>'", "timeout": "seconds, default 300"}),+ json!({"intlib": "path of the IntLib", "written": "true when this call wrote it (checked on disk)", "bytes": "int", "sources": "[the libraries the LibPkg lists]", "data": "{libpkg, outfile, projectOutputPath, projectFile}", "roundtripMs": "int"}), 300,+ "Then altium_install_library {libraryPath: intlib}. Compiling does not install it when output names a folder or file.",+ &["extract_intlib", "install_library", "compile"], &["The LibPkg is opened as a project in the user's workspace and stays open.", "intlib_not_written = Altium stopped on a compile error: altium_compile {projectPath: <the .LibPkg>} lists why.", "libpkg_sources_missing = a library the LibPkg lists is not on disk; Altium still writes an IntLib, without those parts (missingSources)."], json!({"libpkgPath": "C:/lib/Adom_ToF.LibPkg", "output": "C:/lib/out"})), verb_doc("extract_intlib", "Extract the editable .SchLib/.PcbLib sources from a compiled .IntLib (Altium writes them next to the IntLib and opens them).", json!({"intlibPath": "path to an .IntLib (required)", "timeout": "seconds, default 300"}),
dev-skills/altium-bridge-test/run_verb_tests.py+6−2@@ -577,7 +577,11 @@ def matrix(w): # NEVER the demo defaults here: the bundled OutJobs OPEN what they generate (an .xlsx app chooser # landed on the screen, 2026-09-20). A path that does not exist must be refused by name. M["run_outjob"] = dict(phase=4, **anyo("missing OutJob: named refusal", outjobPath=D + "/missing.OutJob"))- M["compile_intlib"] = dict(phase=4, **ref("no LibPkg in the fixtures: must refuse by name"))+ # altium-bridge#34: the setup writes Battery.LibPkg over the battery libraries. The compile must succeed with no+ # error box and the reply must prove the file was written (into its own folder, so nothing is installed)+ M["compile_intlib"] = dict(phase=4, timeout=300, **ok(libpkgPath=D + "/Battery.LibPkg", output=D + "/intlib"),+ check=lambda d: d.get("written") is True and (d.get("bytes") or 0) > 10000+ and str(d.get("intlib") or "").lower().endswith("battery.intlib")) M["extract_intlib"] = dict(phase=4, **ref("no IntLib in the fixtures: must refuse by name")) M["import_kicad"] = dict(phase=4, **ref("no KiCad file in the fixtures: must refuse by name")) M["import_part"] = dict(phase=4, **ref("no spec given: must refuse by name"))@@ -712,7 +716,7 @@ def main(): 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" & mkdir "{dw}\\eagle" & move /Y "{hw}\\Downloads\\eagle-small.sch" "{dw}\\eagle\\" & move /Y "{hw}\\Downloads\\eagle-small.brd" "{dw}\\eagle\\"'})+ 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\\" & (echo [Design]& echo Version=1.0& echo.& echo [Document1]& echo DocumentPath=Battery.SchLib& echo.& echo [Document2]& echo DocumentPath=Battery.PcbLib) > "{dw}\\Battery.LibPkg"'}) # 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+1−1@@ -1,6 +1,6 @@ { "slug": "altium-bridge",- "version": "0.2.99",+ "version": "0.2.100", "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": [
src/BRIDGE_VERSION+1−1@@ -1 +1 @@-0.2.99+0.2.100
src/agent/AdomAgent.pas.tmpl+15−4@@ -1279,13 +1279,20 @@ Begin End; { Compile a .LibPkg into a .IntLib: path=<LibPkg> output=<dir> }+{ Compile a LibPkg. path=<LibPkg> outfile=<full .IntLib path, or empty for the project's own output folder>+ (altium-bridge#34) Compiling a LibPkg IS building its IntLib: DM_Compile writes+ <output folder>\<name>.IntLib by itself. CreateIntegratedLibrary's second argument is the output FILE,+ not a folder, and its third installs the result; called after DM_Compile with an empty path it built+ the library a second time into a file with no name, and Altium answered 'Could not create integrated+ library .' after the real IntLib was already written. So CreateIntegratedLibrary runs only for a file+ the caller named, and does not install it. The bridge checks the file on disk afterwards. } Function CmdCompileIntLib(Lines : TStringList) : String; Var- Path, OutDir : String;+ Path, OutFile : String; Proj : IProject; Begin Path := Param(Lines, 'path');- OutDir := Param(Lines, 'output');+ OutFile := Param(Lines, 'outfile'); If Not FileExists(Path) Then Begin Result := '{' + JRaw('ok', 'false') + ',' + JStr('error', 'LibPkg not found: ' + Path) + '}';@@ -1297,9 +1304,13 @@ Begin Result := '{' + JRaw('ok', 'false') + ',' + JStr('error', 'could not open LibPkg') + '}'; Exit; End;+ { CreateIntegratedLibrary on a project not compiled yet writes an IntLib with no parts (2.5 KB, measured+ 2026-11-16), so the compile always runs first } Proj.DM_Compile;- IntegratedLibraryManager.CreateIntegratedLibrary(Proj, OutDir, True);- Result := '{' + JRaw('ok', 'true') + ',' + JStr('libpkg', Path) + ',' + JStr('outputDir', OutDir) + '}';+ If OutFile <> '' Then+ IntegratedLibraryManager.CreateIntegratedLibrary(Proj, OutFile, False);+ Result := '{' + JRaw('ok', 'true') + ',' + JStr('libpkg', Path) + ',' + JStr('outfile', OutFile) + ',' ++ JStr('projectOutputPath', Proj.DM_GetOutputPath) + ',' + JStr('projectFile', Proj.DM_ProjectFileName) + '}'; End; { The folder part of a path, ending in '\'. Built from Copy/Length only: SysUtils names that
src/bridge.json+1−1@@ -2,7 +2,7 @@ "manifest_version": 1, "name": "altium", "displayName": "Altium Designer",- "version": "0.2.99",+ "version": "0.2.100", "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",