easyeda-api

EasyEDA Pro API skill for AI agents. Use when working with EasyEDA Pro EDA software, including PCB design, schematic editing, footprint/symbol management, and project operations. Supports live debugging in EasyEDA and EasyEDA extension development. Provides complete API reference (120+ classes, 62 e

By easyeda · 437 installs

npx skills add easyeda/easyeda-api-skill --skill easyeda-api

Source repository · Upstream listing

EasyEDA Pro API Skill Control EasyEDA Pro (嘉立创EDA专业版) programmatically through AI. This skill provides: 1. Complete API reference — 120 classes, 62 enums, 70 interfaces, 19 type aliases 2. WebSocket bridge — Execute code in the running EasyEDA Pro client 3. Code patterns — Common operations for PCB, schematic, library, and project management 4. Document source format reference — File format specifications for project, schematic, and PCB sources when users need to analyze or modify EasyEDA document source directly instead of using the API This skill supports not only live debugging in EasyEDA, but also EasyEDA extension development. During EasyEDA extension development, AI agents can use the extension related documentation, API references, type information, usage examples, and bridge based debugging capabilities provided by this skill to look up APIs, write code, and validate behavior during integration and debugging. Architecture The server auto selects an available port from 49620 49629 on startup. Both AI and EDA clients auto discover the server by scanning the port range and verifying a handshake ( service: "easyeda bridge" ). Quick Start 1. Command Triggers When user says "嘉立创EDA,启动!" , "立创EDA,启动!" , or "EDA,启动!" : IMPORTANT: Session initialization — Reply immediately with this exact text to set the correct session title: Then proceed with the setup steps below. 2. Install dependencies (if needed) 3. Start bridge server ⚠️ IMPORTANT : The bridge server must run in the background. Do NOT run it in the foreground, or the AI will block waiting for the server to exit. 4. Connect EasyEDA Install the run api gateway.eext extension in EasyEDA Pro. Download link: https://jlc ext.com/item/oshwhub/run api gateway After the extension is loaded, it will automatically establish the WebSocket connection. 5. Verify connection and select EDA window The /eda windows response looks like: Handle based on window count : 0 windows : Tell user "No EasyEDA window is connected. Please ensure the EasyEDA extension (run api gateway.eext) is installed and loaded in EasyEDA. Download: https://jlc ext.com/item/oshwhub/run api gateway" 1 window : Auto selected as active. Tell user: "✅ Connected! Active EDA window: abc 123. Ready to work." 2+ windows : Show the available windows and ask user to select: Select a window : After selection, confirm: "✅ Active EDA window: abc 123. Ready to work." 6. Execute code on EDA API Documentation The full API reference is in the [references/](references/) directory: [references/ index.md](references/ index.md) — Master index of all classes, enums, interfaces, and types [references/ quick reference.md](references/ quick reference.md) — All method signatures for rapid lookup references/classes/ — 120 class docs (DMT , PCB , SCH , LIB , SYS , IPCB , ISCH ) references/enums/ — 62 enum docs references/interfaces/ — 70 interface docs references/types/ — 19 type alias docs How to look up API 1. Start with index.md to find the right class/module for the task 2. Read the class doc (e.g., references/classes/DMT Board.md ) for all methods and signatures 3. Use quick reference.md for fast method signature lookup across all classes 4. Check enums/interfaces for parameter types and return types Document Source Format Documentation If the user needs to analyze or modify EasyEDA document source directly instead of using the API, use the documents in the [format/](format/) directory. [format/index.md](format/index.md) — Overview of the EasyEDA document source format references and version notes format/project/ — Project source structure, metadata, blobs, variants, and grouping data format/schematic/ — Schematic source format, including structure, wires, shapes, pins, components, and tables format/pcb/ — PCB source format, including primitives, pads and vias, shapes, text, attributes, rules, and panel data Use these files when the task is about understanding source layout, generating compatible document source, or editing source data that will later be imported back into EasyEDA. API Module Overview Prefix Domain Key Classes DMT Document management Board, EditorControl, Folder, Panel, Pcb, Project, Schematic, SelectControl, Team, Workspace PCB PCB & Footprint Document, Drc, Event, Layer, Net, Primitive, PrimitiveComponent, PrimitiveLine, PrimitivePad, PrimitivePour, PrimitiveVia, SelectControl SCH Schematic Document, Event, Primitive, PrimitiveComponent, PrimitiveWire, SelectControl LIB Library 3DModel, Cbb, Classification, Device, Footprint, LibrariesList, PanelLibrary, SelectControl, Symbol SYS System Dialog, Environment, FileManager, FileSystem, FontManager, HeaderMenu, I18n, IFrame, LoadingAndProgressBar, Log, Message, MessageBox, MessageBus, PanelControl, Setting, ShortcutKey, Storage, Timer, ToastMessage, WebSocket, Window IPCB PCB interfaces (图元) PrimitiveArc, PrimitiveComponent, PrimitivePad, PrimitiveFill, PrimitivePour, PrimitiveRegion, PrimitiveVia, ... ISCH Schematic interfaces (图元) PrimitiveArc, PrimitiveComponent, PrimitiveWire, PrimitiveText, PrimitiveRectangle, ... EPCB / ESCH Enums PrimitiveType, Layer, PadType, ... Code Execution Context All code runs inside EasyEDA Pro's browser runtime as: Critical rules: The eda object provides access to all API modules (e.g., eda.dmt Board , eda.pcb Primitive ). Always refer to the API documentation for correct usage. Do not add comments to the generated code, as the code is typically executed as a single line. Always use return to get results — console.log output is NOT captured. All API methods returning promises must be await ed. Code runs in browser context — no Node.js APIs (fs, path, etc.) available. Use eda.sys Message.showToastMessage(msg) for user visible notifications. When reviewing API documentation and encountering enumerations, do not guess the enumeration values. You must use the enumeration members, for example: EPCB LayerId.TOP instead of 1 for the layer parameter in PCB primitive creation. Extension Runtime Constraints When writing EasyEDA extensions, standard browser APIs are forbidden in the main process. Use EDA provided alternatives: Purpose ❌ Forbidden ✅ Use Instead Get user input — eda.sys Dialog.showInputDialog() User selection — eda.sys Dialog.showSelectDialog() Show message alert() eda.sys Dialog.showInformationMessage() Confirm action confirm() eda.sys Dialog.showConfirmationMessage() Toast notification DOM manipulation eda.sys Message.showToastMessage() Store data localStorage (main process) eda.sys Storage.setExtensionUserConfig(key, value) Custom UI Manipulate host DOM eda.sys IFrame.openIFrame() Show HTML showInformationMessage(html) Must use iframe Open link window.open() eda.sys Window.open() Browser hardware API Use in main process Available in iframe ( navigator.serial , etc.) Note: localStorage , window , document etc. are available inside sys IFrame but NOT in the main extension process. Extension ↔ IFrame Data Passing The main extension process and sys IFrame iframe are isolated contexts . To pass data between them: Option A (Recommended): Use eda.sys Storage as a bridge Option B: Both contexts can access eda directly — call the same API from either side Communication Protocol Port Discovery The bridge server listens on the first available port in 49620 49629 . To find the server, scan the range and verify the service identity: Handshake HTTP : GET /health returns { "service": "easyeda bridge", "edaConnected": bool, ... } WebSocket : On connect, server sends { "type": "handshake", "service": "easyeda bridge" } Clients MUST verify service === "easyeda bridge" before using the connection Message Format JSON messages over WebSocket / HTTP: Field Type Description type "execute" \ "result" \ "error" \ "ping" \ "pong" \ "handshake" Message type id string Request UUID for matching request/response code string JavaScript code to execute (for execute type) result any Execution result (for result type) error string Error message (for error type) service string Service identifier (for handshake type) timestamp number Unix milliseconds Common Patterns Project & Board Operations Example: Open a project by name and open its first schematic page Notes: dmt Project.getAllProjectsUuid() is not a global no arg enumerator in practice. To reliably find a project by name, iterate teams first, then folders. openProject(projectUuid) may discard unsaved changes in the currently opened project. Be careful before calling it. PCB Primitive Operations PCB Async Primitive Pattern (IMPORTANT) For modifying PCB/SCH primitives, you must use the async pattern: Schematic Operations Library Operations System Functions DRC (Design Rule Check) Common Mistakes Read API Signatures Carefully (CRITICAL) Before calling ANY API method, you MUST read the full signature from references/ — including parameter types, return type, and remarks. AI agents frequently make these errors due to skimming documentation: Error 1: Not await ing Promise returning methods Almost all EDA API methods return Promise<T . If you forget await , you get a Promise object instead of the actual result. How to know if a method needs await : Check the return type in the signature. If it says Promise<... , you MUST await it. Error 2: Using raw numbers instead of enum values Many parameters expect specific enum values. Using wrong numbers silently produces incorrect behavior. Always look up enums in references/enums/ before using numeric constants. Error 3: Assuming parameter types without checking Different APIs use different units, different ID formats, and different optional parameter conventions. Never assume. Summary — Before every API call: 1. Read the signature — parameter types, return type, all in references/classes/ 2. await if Promise — check return type for Promise<... 3. Use enums — look up in references/enums/ instead of guessing numbers/strings 4. Check remarks — the "备注" section often has critical usage notes Coordinate Unit (CRITICAL) Different domains use different coordinate units: Domain Unit Conversion PCB 1mil 1mm ≈ 39.37 units Schematic 0.01inch (10mil) 1mm ≈ 3.937 units This is the 1 mistake AI agents make. Mixing up the units will place components incorrectly. PCB: 1 unit = 1mil = 0.001 inch = 0.0254 mm Schematic: 1 unit = 0.01inch = 10mil = 0.254 mm If you use the wrong unit, components will be placed 10x too far from their intended position. Document State (CRITICAL) After creating a project, you MUST open it before operating on documents within it. When operating on documents, always verify: 1. Project is opened — Use eda.dmt Project.getCurrentProjectInfo() to verify 2. Correct document is active — Use eda.dmt SelectControl.getCurrentDocumentInfo() to check document type 3. Document type matches API domain — PCB APIs require active PCB document, SCH APIs require active Schematic document Operating on the wrong document type will return errors or null results. For example: Executing PCB APIs without an active PCB document ( documentType !== EDMT EditorDocumentType.PCB ) → error/null Executing SCH APIs without an active Schematic document ( documentType !== EDMT EditorDocumentType.SCHEMATIC PAGE ) → error/null IFrame Con