@huaqiu/dsh-tool-kicad-schematic-gen 0.0.0-stage → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +22 -2
- package/README.zh.md +49 -0
- package/cordis.patch.yml +4 -0
- package/lib/builder.d.ts +486 -0
- package/lib/builder.js +1134 -0
- package/lib/client.js +1196 -0
- package/lib/flat--E2zWV_r.js +1507 -0
- package/lib/index.d.ts +421 -0
- package/lib/index.js +7430 -0
- package/package.json +67 -3
- package/skills/kicad-schematic-design/SKILL.md +82 -0
- package/skills/kicad-schematic-design/assets/drawing-patterns/decoupling-bank.mjs +25 -0
- package/skills/kicad-schematic-design/assets/drawing-patterns/decoupling-bank.png +0 -0
- package/skills/kicad-schematic-design/assets/drawing-patterns/generate.mjs +59 -0
- package/skills/kicad-schematic-design/assets/drawing-patterns/geometry.mjs +17 -0
- package/skills/kicad-schematic-design/assets/drawing-patterns/label-alignment.mjs +8 -0
- package/skills/kicad-schematic-design/assets/drawing-patterns/label-sides.png +0 -0
- package/skills/kicad-schematic-design/assets/drawing-patterns/label-vertical.png +0 -0
- package/skills/kicad-schematic-design/assets/drawing-patterns/ldo-fixed-on.mjs +45 -0
- package/skills/kicad-schematic-design/assets/drawing-patterns/ldo-fixed-on.png +0 -0
- package/skills/kicad-schematic-design/assets/drawing-patterns/led-power-indicator.mjs +15 -0
- package/skills/kicad-schematic-design/assets/drawing-patterns/led-power-indicator.png +0 -0
- package/skills/kicad-schematic-design/assets/drawing-patterns/pullup-button.mjs +18 -0
- package/skills/kicad-schematic-design/assets/drawing-patterns/pullup-button.png +0 -0
- package/skills/kicad-schematic-design/assets/drawing-patterns/reference-label-sides.png +0 -0
- package/skills/kicad-schematic-design/assets/drawing-patterns/reference-label-vertical.png +0 -0
- package/skills/kicad-schematic-design/assets/drawing-patterns/reference-ldo.png +0 -0
- package/skills/kicad-schematic-design/assets/drawing-patterns/render.mjs +26 -0
- package/skills/kicad-schematic-design/assets/mixed-design/design.mjs +40 -0
- package/skills/kicad-schematic-design/assets/mixed-design/modules/load.mjs +15 -0
- package/skills/kicad-schematic-design/assets/modular-design/design.mjs +42 -0
- package/skills/kicad-schematic-design/assets/modular-design/modules/input.mjs +16 -0
- package/skills/kicad-schematic-design/assets/modular-design/modules/output.mjs +16 -0
- package/skills/kicad-schematic-design/assets/modular-design/shared/parts.mjs +9 -0
- package/skills/kicad-schematic-design/assets/runtime.mjs +21 -0
- package/skills/kicad-schematic-design/references/component-pcb.md +22 -0
- package/skills/kicad-schematic-design/references/drawing-patterns/decoupling-bank.md +9 -0
- package/skills/kicad-schematic-design/references/drawing-patterns/label-alignment.md +22 -0
- package/skills/kicad-schematic-design/references/drawing-patterns/ldo-fixed-on.md +11 -0
- package/skills/kicad-schematic-design/references/drawing-patterns/led-power-indicator.md +7 -0
- package/skills/kicad-schematic-design/references/drawing-patterns/pullup-button.md +9 -0
- package/skills/kicad-schematic-design/references/drawing-patterns/reset-enable.md +34 -0
- package/skills/kicad-schematic-design/references/drawing-patterns.md +46 -0
- package/skills/kicad-schematic-design/references/editing.md +66 -0
- package/skills/kicad-schematic-design/references/flat-project.md +11 -0
- package/skills/kicad-schematic-design/references/flat-reuse.md +28 -0
- package/skills/kicad-schematic-design/references/hierarchy.md +19 -0
- package/skills/kicad-schematic-design/references/kicad10-hierarchy-template/hierarchy_template.kicad_pro +37 -0
- package/skills/kicad-schematic-design/references/kicad10-hierarchy-template/hierarchy_template.kicad_sch +14 -0
- package/skills/kicad-schematic-design/references/kicad10-hierarchy-template/hierarchy_template.kicad_sym +3 -0
- package/skills/kicad-schematic-design/references/kicad10-hierarchy-template/schematic/hierarchy_template_sheet_1.kicad_sch +14 -0
- package/skills/kicad-schematic-design/references/kicad10-hierarchy-template/sym-lib-table +1 -0
- package/skills/kicad-schematic-design/references/kicad10-hierarchy.md +16 -0
- package/skills/kicad-schematic-design/references/mixed-design.md +23 -0
- package/skills/kicad-schematic-design/references/modular-scripts.md +39 -0
- package/skills/kicad-schematic-design/references/module-analysis.md +40 -0
- package/skills/kicad-schematic-design/references/module-footprints.md +36 -0
- package/skills/kicad-schematic-design/references/module-layout.md +35 -0
- package/skills/kicad-schematic-design/references/module-selection.md +35 -0
- package/skills/kicad-schematic-design/references/power-symbols.md +82 -0
- package/skills/kicad-schematic-design/references/programming.md +128 -0
- package/skills/kicad-schematic-design/references/troubleshooting.md +13 -0
- package/skills/kicad-schematic-design/scripts/run-design.mjs +20 -0
- package/skills/kicad-schematic-design/templates/frame-style.json +11 -0
- package/skills/kicad-schematic-design/templates/module-frame.kicad_sch.fragment +6 -0
- package/skills/kicad-schematic-design/templates/project.kicad_pro +28 -0
- package/src/builder.ts +4 -0
- package/src/client/composer-chip.ts +328 -0
- package/src/client/index.ts +131 -0
- package/src/client/latest-overview.ts +10 -0
- package/src/client/overview-result.ts +23 -0
- package/src/client/place.ts +18 -0
- package/src/client/schematic-ref.ts +272 -0
- package/src/client/sidebar-entry.ts +230 -0
- package/src/components/config.ts +53 -0
- package/src/components/datasheet.ts +266 -0
- package/src/components/footprint-download.ts +50 -0
- package/src/components/identity.ts +10 -0
- package/src/components/import-component.ts +107 -0
- package/src/components/import-symbol.ts +199 -0
- package/src/components/index.ts +15 -0
- package/src/components/models.ts +226 -0
- package/src/components/module-footprints.ts +97 -0
- package/src/components/project-footprint.ts +43 -0
- package/src/components/service.ts +31 -0
- package/src/components/tools.ts +276 -0
- package/src/config.ts +51 -0
- package/src/index.ts +46 -0
- package/src/modules/config.ts +13 -0
- package/src/modules/download-core/download.ts +259 -0
- package/src/modules/download-core/index.ts +94 -0
- package/src/modules/download-core/save.ts +108 -0
- package/src/modules/kicad-download.ts +142 -0
- package/src/modules/register.ts +15 -0
- package/src/modules/search.ts +139 -0
- package/src/modules/tools.ts +133 -0
- package/src/runtime-paths.ts +46 -0
- package/src/schematic/analysis-tool.ts +130 -0
- package/src/schematic/assembly.ts +282 -0
- package/src/schematic/builder.ts +607 -0
- package/src/schematic/config.ts +28 -0
- package/src/schematic/connections.ts +64 -0
- package/src/schematic/edit.ts +206 -0
- package/src/schematic/flat-input.ts +100 -0
- package/src/schematic/flat-layout.ts +204 -0
- package/src/schematic/flat.ts +379 -0
- package/src/schematic/footprint-links.ts +57 -0
- package/src/schematic/fs-compat.d.ts +7 -0
- package/src/schematic/import-flat.ts +159 -0
- package/src/schematic/index.ts +13 -0
- package/src/schematic/input.ts +192 -0
- package/src/schematic/label-leads.ts +70 -0
- package/src/schematic/module-analysis.ts +322 -0
- package/src/schematic/overview.ts +98 -0
- package/src/schematic/ports.ts +39 -0
- package/src/schematic/power-layout.ts +131 -0
- package/src/schematic/preview-config.ts +11 -0
- package/src/schematic/preview-diagnostics.ts +116 -0
- package/src/schematic/preview-regions.ts +113 -0
- package/src/schematic/preview.ts +346 -0
- package/src/schematic/project.ts +455 -0
- package/src/schematic/sexpr.ts +101 -0
- package/src/schematic/symbol-units.ts +29 -0
- package/src/schematic/tools.ts +556 -0
- package/src/schematic/verify.ts +226 -0
- package/src/skills.ts +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 深圳华秋智联股份有限公司
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @huaqiu/dsh-tool-kicad-schematic-gen
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
One installable plugin containing twelve tools and the kicad-schematic-design skill. Internal modules preserve the former component-library, module-catalog and schematic-tool contracts. Component search is provided by the KiCad built-in plugin @huaqiu/dsh-tool-part-search and its search_hqsch_parts tool.
|
|
6
|
+
|
|
7
|
+
Configuration is grouped under components, modules.search, modules.download and schematic. Templates ship under skills/kicad-schematic-design; the public scripting API is available at ./builder. Module downloads resolve the current HQ Edge host at execution time, so a missing host does not prevent other tools or the skill from loading.
|
|
8
|
+
|
|
9
|
+
Imports remain workspace scoped and use DSH sandbox policy. Model inspection reports pin/pad summaries; paired import checks unique pin/pad number sets, but does not verify electrical suitability or package dimensions. Placement and routing are explicitly authored in design scripts. Datasheet extraction preserves missing/truncated status.
|
|
10
|
+
|
|
11
|
+
Build, typecheck and test from the repository workspace. Restart the KiCad assistant after replacing the old bundles. See [merge notes](../../docs/SCHEMATIC-MERGE.md).
|
|
12
|
+
|
|
13
|
+
Paired import: `import_kicad_component({manufacturer_id, mpn, projectDir})` downloads a symbol and footprint, registers `sym-lib-table` and `fp-lib-table`, and returns `footprintId`. Place with `addSymbol({libraryPath, libId, footprint: footprintId, ...})`. Success requires both usable models and matching unique pin/pad number sets. Public tool arguments use required `manufacturer_id` and `mpn`, matching `@huaqiu/dsh-tool-part-search`; imports also accept optional `projectDir` (defaults to the workspace root). `mfgId` is retained only by the internal identity parser for legacy direct callers; schema-validated tool calls must use `manufacturer_id`. See the skill's [component and PCB reference](skills/kicad-schematic-design/references/component-pcb.md).
|
|
14
|
+
|
|
15
|
+
Power symbols: declare actual shared nets with the builder's `requiredPowerSymbols` option. `powerLabelCatalog(nets)` returns current-build label UUIDs, coordinates and imported-module names for reproducible placement. `checkPowerSymbols()` and render/save reject missing symbols or unconverted labels for declared nets. Layout warnings still require visual review. See [power-symbol delivery](skills/kicad-schematic-design/references/power-symbols.md).
|
|
16
|
+
|
|
17
|
+
`planPowerPlacements({libraryPath, nets})` plans bounded rotations, horizontal text placement and short straight leads before conversion. Diagnostics list unresolved overlaps and unmeasured objects; visual review remains required.
|
|
18
|
+
|
|
19
|
+
Standalone common-only symbols with pins (e.g. SW-PTB-2_0_1) are automatically normalized in project copies to unit 1 without changing pins or graphics. Model summaries and import results report builderCompatibility.normalization=common_only_to_unit_1. Inherited, empty, malformed or alternate-only definitions are not normalized. Unsupported imports report part, symbol, sections and source URL.
|
|
20
|
+
|
|
21
|
+
最终概览卡片:正式预览传入 `delivery: true` 和包含全部本地库的 `projectDir`,显示页面切换、缩放、ZIP 下载。复用已有 PNG,不重新生成电路,无重新生成/详情按钮。需 KiCad Harness 的 webServer 与前端加载支持;不可用时仍返回本地预览路径。快照保存在插件 `.overview-cache/`,重启后可读取;移除该目录后历史卡片下载将失效。ZIP 为工程目录内相关设计文件与库的快照,不收集脚本、预览或外部库。
|
|
22
|
+
|
|
23
|
+
Module analysis queries use `analyze_kicad_module({schematicPath, view, reference?, pin?, net?, offset?, kicadCliPath?})`, with explicit `view`. Downloads already return a summary: query only needed components, grouped nets or grouped BOM. CLI/project options are resolved internally; optional absolute `kicadCliPath` is for recovery using the existing `get_eda_host_info` result. On `CLI_START_FAILED`, retry analysis with that path and `view:summary`, without downloading again. Successful paths are reused; default CLI command names preserve automatic discovery. Probe errors return `error:{code,executable}` and retain causes; capability failures are distinct from startup failures. Matching same-stem projects and downloaded `.source.kicad_pro` files are discovered. Detail output contains `status`, `items`, and optional `nextOffset`/`warnings`; missing `nextOffset` means completion. Component custom fields require a reference filter. Partial results are reused for detail queries; after fixing configuration use `view:summary` to retry. Full local artifacts are preserved. This replaces the previous analysis query arguments and response contract; existing callers must migrate. See [module analysis](skills/kicad-schematic-design/references/module-analysis.md).
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# @huaqiu/dsh-tool-kicad-schematic-gen
|
|
2
|
+
|
|
3
|
+
将四个原理图插件统一安装为一个插件,内部继续分为 components、modules、schematic 与设计技能。
|
|
4
|
+
|
|
5
|
+
| 模块 | 工具 |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| 器件模型与文档 | get_kicad_component_models、get_kicad_datasheet、import_kicad_symbol、import_kicad_component |
|
|
8
|
+
| 电路模块搜索下载 | eda_module_rag_search、eda_module_category_search、eda_module_precise_search、download_eda_module_schematic |
|
|
9
|
+
| 原理图工具 | get_kicad_module_ports、render_kicad_module_preview、create_kicad_hierarchy、edit_kicad_flat_schematic |
|
|
10
|
+
|
|
11
|
+
同时注册 kicad-schematic-design 技能。元件搜索由KiCad 内置的 @huaqiu/dsh-tool-part-search 提供,调用 search_hqsch_parts。该搜索插件随 KiCad 提供,可在插件管理器中启用;原理图插件本身不注册它的四个查询工具。两者间将搜索结果的 manufacturer.id 映射为 manufacturer_id,mpn 保持不变;公开工具统一要求 manufacturer_id 和 mpn,不再暴露 mfgId;两个导入工具额外支持可选 projectDir,默认工作区根目录。内部身份解析保留旧调用兼容,经过工具 Schema 校验的调用必须使用 manufacturer_id。
|
|
12
|
+
|
|
13
|
+
配置分为 components、modules.search、modules.download、schematic,使用原配置的默认限额。flatTemplateDir 默认指向本包技能模板。Node 22.19+,KiCad 10 CLI 路径可通过 schematic.kicadCliPath 配置。
|
|
14
|
+
|
|
15
|
+
模块下载按调用时的 HQ Edge 宿主与当前项目校验;没有 HQ Edge 时只让该下载调用失败,其它工具仍注册。符号导入继续使用会话文件系统及沙箱策略。工具不是自动电气验证;模型摘要不检查引脚焊盘匹配,手册文字可能被截断,构建库的放置和布线由设计脚本显式指定。
|
|
16
|
+
|
|
17
|
+
公开脚本入口是 lib/builder.js 或包的 ./builder 导出。设计技能、资源与模板位于 skills/kicad-schematic-design/。
|
|
18
|
+
|
|
19
|
+
新导入器件库默认保存到 `project/libraries/symbols/` 和 `project/libraries/footprints/`,库表保留在 project 根目录,使用 `${KIPRJMOD}` 相对路径注册。相同器件重复导入复用原文件;旧项目已有根目录库时保持兼容,不自动移动。脚本使用导入返回的实际 libraryPath 和 footprintId;概览 ZIP 会递归收集 libraries 下的器件库。
|
|
20
|
+
|
|
21
|
+
复用模块的封装通过 `localize_kicad_module_footprints` 的 list/import/check 流程本地化。模块下载现在保留 ZIP 中的 `.kicad_mod` 并返回 footprints 列表;缺失时使用明确选择的 manufacturer_id/mpn 查询在线封装。原嵌入符号、引脚和布线不替换,编号集合不匹配时拒绝导入。映射存入 `libraries/mappings/`,在设计脚本中使用 `importModule({...,footprintMappingPath})` 持久应用;来源变化后旧映射会拒绝使用。正式 delivery 在生成概览前验证根图和子页的本地封装引用。映射和封装一并进入项目 ZIP;尺寸、电气功能及 3D 完整性仍需单独确认。已有工程不会在插件加载时自动选择或替换器件。
|
|
22
|
+
|
|
23
|
+
KiCad CLI 自动从当前运行时安装位置或 PATH 查找,也可通过 KICAD_CLI_PATH 或 schematic.kicadCliPath 指定。skill 加载时提供本机插件目录及符号库路径,脚本通过 DSH_SCHEMATIC_PLUGIN_DIR、KICAD_SYMBOL_DIR 使用这些路径。
|
|
24
|
+
|
|
25
|
+
路径发现由配置与 skill 共用缓存,环境变量变化后重新识别。模型已有 get_eda_host_info 返回结果时,可以把其中的 kicad-cli 绝对路径传给 render_kicad_module_preview 的可选 kicadCliPath;只影响当前调用,不修改默认配置。原理图文件生成和预览不要求 PCB IPC 诊断或 Python 路径查询。
|
|
26
|
+
|
|
27
|
+
正式概览快照保存到当前 DSH_HOME/plugin-data/dsh-tool-kicad-schematic-gen/overview-cache;没有 DSH_HOME 时使用用户数据目录,不要求插件安装目录可写。快照完整写入后才发布,旧会话仍可读取插件目录中原有的 .overview-cache。不会自动删除历史快照;手动清理对应快照后,旧会话中的下载和放置操作将失效。
|
|
28
|
+
|
|
29
|
+
在工作区根目录执行 pnpm --filter @huaqiu/dsh-tool-kicad-schematic-gen build、typecheck 或 test。使用配套 DSH CLI 注册本目录,替换旧四个插件,并重新打开 KiCad AI 助手。历史备份和旧脚本兼容见 [合并说明](../../docs/SCHEMATIC-MERGE.md)。
|
|
30
|
+
|
|
31
|
+
成套器件导入:`import_kicad_component({manufacturer_id, mpn, projectDir})` 同时下载符号与封装,登记两个项目库表,返回 `footprintId`。放置时传 `footprint: imported.footprintId`。两种实际模型可用且引脚/焊盘编号集合匹配才成功;仍需手册核对尺寸与功能。公开调用只使用 `manufacturer_id`,旧 `mfgId` 仅在内部解析层为历史直接调用保留。
|
|
32
|
+
|
|
33
|
+
电源符号:在构建选项中声明实际共享网络 `requiredPowerSymbols`。`powerLabelCatalog(nets)` 返回本次标签 UUID、网络、坐标和导入模块名,按这些条件定位后生成 placements,不引用上一轮 UUID。`checkPowerSymbols()` 与 render/save 检查声明网络的标准符号和残留标签;未完成时拒绝保存。遮挡提示仍需局部预览确认,详见 [电源符号交付](skills/kicad-schematic-design/references/power-symbols.md)。
|
|
34
|
+
|
|
35
|
+
`planPowerPlacements({libraryPath, nets})` 在转换前批量规划方向、水平文字与短引出线,返回 placements 和剩余问题诊断;局部预览仍需确认。
|
|
36
|
+
|
|
37
|
+
含引脚的独立公共单元符号(如 SW-PTB-2_0_1)在项目副本中自动规范为单元 1,保留引脚与图形。模型摘要和导入结果通过 builderCompatibility.normalization=common_only_to_unit_1 报告;继承、空单元、异常命名及仅替代图形的符号不做自动规范。不支持的导入错误包含器件、符号、单元名称及源文件 URL。
|
|
38
|
+
|
|
39
|
+
最终概览卡片:正式预览传入 `delivery: true` 和包含全部本地库的 `projectDir`,显示页面切换、缩放、ZIP 下载。复用已有 PNG,不重新生成电路,无重新生成/详情按钮。需 KiCad Harness 的 webServer 与前端加载支持;不可用时仍返回本地预览路径。快照保存在插件 `.overview-cache/`,重启后可读取;移除该目录后历史卡片下载将失效。ZIP 为工程目录内相关设计文件与库的快照,不收集脚本、预览或外部库。
|
|
40
|
+
# 生成流程耗时优化
|
|
41
|
+
|
|
42
|
+
- 模块封装 `import` 返回 `stage: prepared`,仅表示本地库和映射准备完成;源文件默认不改写。`check_mapping` 验证来源应用映射后的状态,`check` 检查实际候选或最终原理图,避免混淆。
|
|
43
|
+
- 封装准备最多 4 并发;项目库表按项目串行写入。批次验证失败不写库,错误返回失败 assignment 索引;已验证下载在当前进程缓存 15 分钟(最多 128 项、16 MiB),退出进程后清空。瞬时网络/429/5xx 错误内部最多重试一次,格式和编号错误不自动重试。
|
|
44
|
+
- 使用现有供应商符号缓存对齐逻辑读取模块,支持旧式 `(module ...)` 封装的焊盘元数据,不改写源封装。编号核对不等于尺寸或电气验证。
|
|
45
|
+
- builder 新增 `attachPinLabel`,支持显式方向、引线长度与通道错列;不推断引脚方向或自动避障。
|
|
46
|
+
- 技能目录 `scripts/run-design.mjs` 使用参数数组启动生成脚本,将退出码、执行时间和完整输出保存为 UTF-8 JSON;终端仅返回摘要,避免 PowerShell 转义、输出截断和 BOM 返工。模块封装准备提前进行,文档与脚本复用连接计划。
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
模块分析查询:`analyze_kicad_module({schematicPath, view, reference?, pin?, net?, offset?, kicadCliPath?})`。`view` 必填;下载已给分析摘要,直接查询所需 `components`、`nets` 或 `bom`。CLI/源工程默认内部解析;路径或启动失败 `CLI_START_FAILED` 时,复用 `get_eda_host_info` 返回的 kicad-cli 绝对路径,通过可选 `kicadCliPath` + `view:summary` 直接重试分析,不重新下载。成功路径后续复用,默认命令名不会覆盖自动发现;探测失败返回 `error:{code,executable}` 并区分启动、能力不支持、超时和命令失败。任意本地图采用同名 `.kicad_pro`,下载模块重启后可识别同名 `.source.kicad_pro`。详情返回 `status`、`items`、可选 `nextOffset`/`warnings`;网络按组分块,BOM 按全部物料字段与装配状态合并,器件自定义字段在指定 `reference` 时返回。部分失败结果供详情查询复用,修复后用 `view:summary` 重试。缺失 `nextOffset` 表示结束;不可用数据会明确警告。完整本地分析文件仍保留,详见 [模块分析](skills/kicad-schematic-design/references/module-analysis.md)。此接口替换旧版分析查询参数及返回结构,旧调用需同步更新。
|
package/cordis.patch.yml
ADDED
package/lib/builder.d.ts
ADDED
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
//#region src/schematic/flat-layout.d.ts
|
|
2
|
+
/** Axis-aligned range in schematic millimetres. Text ranges are conservative estimates. */
|
|
3
|
+
interface FlatBounds {
|
|
4
|
+
left: number;
|
|
5
|
+
top: number;
|
|
6
|
+
right: number;
|
|
7
|
+
bottom: number;
|
|
8
|
+
}
|
|
9
|
+
/** PNG placement metadata; image data is never returned to the model. */
|
|
10
|
+
interface FlatImage {
|
|
11
|
+
pixels: [number, number];
|
|
12
|
+
ppi: number;
|
|
13
|
+
scale: number;
|
|
14
|
+
size: [number, number];
|
|
15
|
+
}
|
|
16
|
+
/** Template-controlled margins, grid, and conservative text metrics. */
|
|
17
|
+
interface FlatLayoutStyle {
|
|
18
|
+
contentPadding: number;
|
|
19
|
+
grid: number;
|
|
20
|
+
textWidthFactor: number;
|
|
21
|
+
textHeightFactor: number;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/schematic/flat.d.ts
|
|
25
|
+
/** Coordinates in schematic millimetres. */
|
|
26
|
+
type FlatPoint = [number, number];
|
|
27
|
+
/** Explicit wire endpoint; pin numbers use the retained source symbol cache. */
|
|
28
|
+
type FlatEndpoint = FlatPoint | {
|
|
29
|
+
reference: string;
|
|
30
|
+
pin: string;
|
|
31
|
+
};
|
|
32
|
+
/** One graphic module frame and its visible explanation. */
|
|
33
|
+
type FlatFrame = {
|
|
34
|
+
name: string;
|
|
35
|
+
description: string;
|
|
36
|
+
} & ({
|
|
37
|
+
start: FlatPoint;
|
|
38
|
+
end: FlatPoint;
|
|
39
|
+
autoBounds?: false;
|
|
40
|
+
} | {
|
|
41
|
+
autoBounds: true;
|
|
42
|
+
objectUuids?: string[];
|
|
43
|
+
excludeUuids: string[];
|
|
44
|
+
});
|
|
45
|
+
/** Final frame coordinates, including automatically calculated ranges. */
|
|
46
|
+
interface ResolvedFlatFrame {
|
|
47
|
+
name: string;
|
|
48
|
+
description: string;
|
|
49
|
+
start: FlatPoint;
|
|
50
|
+
end: FlatPoint;
|
|
51
|
+
}
|
|
52
|
+
/** Supported edits; deleting a component does not delete surrounding wires. */
|
|
53
|
+
interface FlatPlan {
|
|
54
|
+
removeReferences: string[];
|
|
55
|
+
removeUuids: string[];
|
|
56
|
+
/** Selected source annotations only; electrical objects are rejected. */
|
|
57
|
+
removeTextUuids: string[];
|
|
58
|
+
setValues: Array<{
|
|
59
|
+
reference: string;
|
|
60
|
+
value: string;
|
|
61
|
+
}>;
|
|
62
|
+
setLabels: Array<{
|
|
63
|
+
uuid: string;
|
|
64
|
+
name?: string;
|
|
65
|
+
at?: FlatPoint;
|
|
66
|
+
angle?: number;
|
|
67
|
+
}>;
|
|
68
|
+
addWires: Array<{
|
|
69
|
+
from: FlatEndpoint;
|
|
70
|
+
to: FlatEndpoint;
|
|
71
|
+
via: FlatPoint[];
|
|
72
|
+
}>;
|
|
73
|
+
frames: FlatFrame[];
|
|
74
|
+
}
|
|
75
|
+
/** Editable top-level object returned by list action. */
|
|
76
|
+
interface FlatObject {
|
|
77
|
+
type: string;
|
|
78
|
+
uuid: string;
|
|
79
|
+
reference?: string;
|
|
80
|
+
libId?: string;
|
|
81
|
+
unit?: number;
|
|
82
|
+
angle?: number;
|
|
83
|
+
mirror?: string;
|
|
84
|
+
footprint?: string;
|
|
85
|
+
dnp?: boolean;
|
|
86
|
+
value?: string;
|
|
87
|
+
name?: string;
|
|
88
|
+
at?: FlatPoint;
|
|
89
|
+
from?: FlatPoint;
|
|
90
|
+
to?: FlatPoint;
|
|
91
|
+
pinError?: string;
|
|
92
|
+
pins?: Array<{
|
|
93
|
+
number: string;
|
|
94
|
+
name: string;
|
|
95
|
+
at: FlatPoint;
|
|
96
|
+
electricalType: string;
|
|
97
|
+
}>;
|
|
98
|
+
bounds?: FlatBounds;
|
|
99
|
+
boundsError?: string;
|
|
100
|
+
image?: FlatImage;
|
|
101
|
+
}
|
|
102
|
+
/** Deployment-selected templates shared with the flat skill. */
|
|
103
|
+
interface FlatTemplates {
|
|
104
|
+
project: Record<string, unknown> & {
|
|
105
|
+
meta: {
|
|
106
|
+
filename: string;
|
|
107
|
+
version: number;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
frame: string;
|
|
111
|
+
style: FlatLayoutStyle & {
|
|
112
|
+
inset: number;
|
|
113
|
+
titleOffset: number;
|
|
114
|
+
descriptionBottom: number;
|
|
115
|
+
lineHeight: number;
|
|
116
|
+
wireWidth: number;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/** List editable IDs and pin locations without inspecting net connectivity or writing files.
|
|
120
|
+
* @param source Exact source schematic text.
|
|
121
|
+
* @param style Optional template-selected text allowances for layout measurements.
|
|
122
|
+
* @returns Object IDs and component pins, plus PNG geometry and optional conservative bounds.
|
|
123
|
+
*/
|
|
124
|
+
declare function listFlatObjects(source: string, style?: FlatLayoutStyle): FlatObject[];
|
|
125
|
+
/** Apply an explicit plan and create a project copy in memory; no endpoint audit or external processes run.
|
|
126
|
+
* @param source Existing single-sheet source with embedded symbols.
|
|
127
|
+
* @param projectName ASCII project filename stem.
|
|
128
|
+
* @param plan Explicit edits and module frames with manual or automatic bounds.
|
|
129
|
+
* @param templates Validated project and graphic templates.
|
|
130
|
+
* @returns New schematic and project text, resolved frame coordinates, and applied edit counts.
|
|
131
|
+
*/
|
|
132
|
+
declare function buildFlatCopy(source: string, projectName: string, plan: FlatPlan, templates: FlatTemplates): {
|
|
133
|
+
schematic: string;
|
|
134
|
+
project: string;
|
|
135
|
+
resolvedFrames: ResolvedFlatFrame[];
|
|
136
|
+
changes: {
|
|
137
|
+
removedObjects: number;
|
|
138
|
+
changedValues: number;
|
|
139
|
+
changedLabels: number;
|
|
140
|
+
addedWireSegments: number;
|
|
141
|
+
addedFrames: number;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/schematic/import-flat.d.ts
|
|
146
|
+
/** Explicit module placement and shared network names; other named nets remain private. */
|
|
147
|
+
interface FlatImportSpec {
|
|
148
|
+
name: string;
|
|
149
|
+
offset: FlatPoint;
|
|
150
|
+
nets: Record<string, string>;
|
|
151
|
+
}
|
|
152
|
+
/** Imported object identities, renamed references and source-label anchors on the final sheet. */
|
|
153
|
+
interface FlatImportResult {
|
|
154
|
+
references: Record<string, string>;
|
|
155
|
+
ports: Record<string, FlatPoint[]>;
|
|
156
|
+
netNames: Record<string, string>;
|
|
157
|
+
objectUuids: string[];
|
|
158
|
+
}
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/schematic/power-layout.d.ts
|
|
161
|
+
interface PowerPlacementPlan {
|
|
162
|
+
placements: NonNullable<PowerLabelSpec['placements']>;
|
|
163
|
+
diagnostics: {
|
|
164
|
+
plannedCount: number;
|
|
165
|
+
rotatedCount: number;
|
|
166
|
+
movedCount: number;
|
|
167
|
+
candidateCount: number;
|
|
168
|
+
unresolved: Array<{
|
|
169
|
+
uuid: string;
|
|
170
|
+
net: string;
|
|
171
|
+
at: FlatPoint;
|
|
172
|
+
obstacleUuids: string[];
|
|
173
|
+
}>;
|
|
174
|
+
unmeasuredObjectUuids: string[];
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
interface PowerPlanningOptions extends Pick<PowerLabelSpec, 'libraryPath' | 'nets'> {
|
|
178
|
+
clearanceMm?: number;
|
|
179
|
+
/** Maximum short cardinal lead, 0 disables movement. Default 5.08 mm. */
|
|
180
|
+
maxMoveMm?: number;
|
|
181
|
+
}
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/schematic/builder.d.ts
|
|
184
|
+
/** Explicit instance placement in millimetres; library files must be trusted project inputs. */
|
|
185
|
+
interface SymbolPlacement {
|
|
186
|
+
libraryPath: string;
|
|
187
|
+
libId: string;
|
|
188
|
+
reference: string;
|
|
189
|
+
at: FlatPoint;
|
|
190
|
+
value?: string;
|
|
191
|
+
angle?: 0 | 90 | 180 | 270;
|
|
192
|
+
mirror?: 'x' | 'y';
|
|
193
|
+
unit?: number;
|
|
194
|
+
footprint?: string;
|
|
195
|
+
referenceAt?: FlatPoint;
|
|
196
|
+
valueAt?: FlatPoint;
|
|
197
|
+
fieldAngle?: number;
|
|
198
|
+
hideReference?: boolean;
|
|
199
|
+
hideValue?: boolean;
|
|
200
|
+
}
|
|
201
|
+
/** Explicit deployment templates and page choice; no implicit file discovery. */
|
|
202
|
+
interface SchematicOptions {
|
|
203
|
+
projectName: string;
|
|
204
|
+
templateDir: string;
|
|
205
|
+
paper: 'A4' | 'A3' | 'A2' | 'A1' | 'A0';
|
|
206
|
+
title: string;
|
|
207
|
+
/** Explicit shared power nets required before render/save; never inferred from names. */
|
|
208
|
+
requiredPowerSymbols?: Record<string, string>;
|
|
209
|
+
}
|
|
210
|
+
/** Planned module rectangle; origin and size use sheet millimetres. */
|
|
211
|
+
interface ModuleRegionSpec {
|
|
212
|
+
name: string;
|
|
213
|
+
description: string;
|
|
214
|
+
origin: FlatPoint;
|
|
215
|
+
size: FlatPoint;
|
|
216
|
+
}
|
|
217
|
+
/** Explicit shared-net conversion; library Value must equal each selected network name. */
|
|
218
|
+
interface PowerLabelSpec {
|
|
219
|
+
libraryPath: string;
|
|
220
|
+
nets: Record<string, string>;
|
|
221
|
+
placements?: Record<string, {
|
|
222
|
+
at: FlatPoint;
|
|
223
|
+
via?: FlatPoint[];
|
|
224
|
+
angle?: 0 | 90 | 180 | 270;
|
|
225
|
+
valueAt?: FlatPoint;
|
|
226
|
+
}>;
|
|
227
|
+
}
|
|
228
|
+
/** Conservative power-symbol overlap hint; not an electrical check. */
|
|
229
|
+
interface PowerLayoutWarning {
|
|
230
|
+
code: 'POWER_LAYOUT_OVERLAP';
|
|
231
|
+
uuid: string;
|
|
232
|
+
reference: string;
|
|
233
|
+
otherUuid: string;
|
|
234
|
+
otherType: string;
|
|
235
|
+
}
|
|
236
|
+
/** Converted label identity and final symbol pin position; explicit movement adds connected wire segments. */
|
|
237
|
+
interface PowerLabelReplacement {
|
|
238
|
+
uuid: string;
|
|
239
|
+
reference: string;
|
|
240
|
+
net: string;
|
|
241
|
+
libId: string;
|
|
242
|
+
at: FlatPoint;
|
|
243
|
+
}
|
|
244
|
+
/** Current-build label identity and sheet coordinates; module identifies imported provenance. */
|
|
245
|
+
interface PowerLabelEntry {
|
|
246
|
+
uuid: string;
|
|
247
|
+
net: string;
|
|
248
|
+
at: FlatPoint;
|
|
249
|
+
angle: number;
|
|
250
|
+
type: 'label' | 'global_label';
|
|
251
|
+
module?: string;
|
|
252
|
+
}
|
|
253
|
+
/** Structural completion check, not connectivity or layout verification. */
|
|
254
|
+
interface PowerSymbolStatus {
|
|
255
|
+
net: string;
|
|
256
|
+
libId: string;
|
|
257
|
+
symbolCount: number;
|
|
258
|
+
remainingLabelUuids: string[];
|
|
259
|
+
}
|
|
260
|
+
/** Region-local script operations; changing its origin in the script moves the regenerated group. */
|
|
261
|
+
declare class ModuleRegion {
|
|
262
|
+
private readonly schematic;
|
|
263
|
+
private readonly origin;
|
|
264
|
+
/** Keep one planned origin for symbols, properties, wire bends and annotations.
|
|
265
|
+
* @param schematic Owning sheet. @param origin Planned top-left sheet coordinate.
|
|
266
|
+
*/
|
|
267
|
+
constructor(schematic: Schematic, origin: FlatPoint);
|
|
268
|
+
/** Convert a region-relative coordinate to sheet coordinates.
|
|
269
|
+
* @param local Millimetres from the region's top-left. @returns Sheet coordinate.
|
|
270
|
+
*/
|
|
271
|
+
at(local: FlatPoint): FlatPoint;
|
|
272
|
+
/** Place an instance with region-relative position and explicit property anchors.
|
|
273
|
+
* @param spec Actual symbol and local placement. @returns Instance UUID.
|
|
274
|
+
*/
|
|
275
|
+
addSymbol(spec: SymbolPlacement): string;
|
|
276
|
+
/** Resolve a placed pin as a region-relative coordinate.
|
|
277
|
+
* @param reference Placed instance. @param number Actual pin number. @returns Local coordinate.
|
|
278
|
+
*/
|
|
279
|
+
pin(reference: string, number: string): FlatPoint;
|
|
280
|
+
private endpoint;
|
|
281
|
+
/** Route local points or named pins through local explicit bends.
|
|
282
|
+
* @param from Local point or pin. @param to Local point or pin. @param via Local bends.
|
|
283
|
+
* @returns Segment UUIDs.
|
|
284
|
+
*/
|
|
285
|
+
wire(from: FlatEndpoint, to: FlatEndpoint, via?: FlatPoint[]): string[];
|
|
286
|
+
/** Add a local network label.
|
|
287
|
+
* @param name Network name. @param at Local point or pin. @param angle Orthogonal angle. @returns UUID.
|
|
288
|
+
*/
|
|
289
|
+
label(name: string, at: FlatEndpoint, angle?: 0 | 90 | 180 | 270): string;
|
|
290
|
+
/** Mark an explicit branch or intentionally unused pin.
|
|
291
|
+
* @param kind Marker kind. @param at Local point or pin. @returns UUID.
|
|
292
|
+
*/
|
|
293
|
+
marker(kind: 'junction' | 'no_connect', at: FlatEndpoint): string;
|
|
294
|
+
/** Add an explicitly connected child-sheet port at a local point or actual pin.
|
|
295
|
+
* @param name Port name. @param at Local point or actual pin. @param angle Text rotation.
|
|
296
|
+
* @returns Label UUID.
|
|
297
|
+
*/
|
|
298
|
+
hierarchicalLabel(name: string, at: FlatEndpoint, angle?: 0 | 90 | 180 | 270): string;
|
|
299
|
+
}
|
|
300
|
+
/** Build a circuit through explicit script calls; generation errors throw before save. */
|
|
301
|
+
declare class Schematic {
|
|
302
|
+
private readonly options;
|
|
303
|
+
private readonly rootId;
|
|
304
|
+
private readonly definitions;
|
|
305
|
+
private readonly instances;
|
|
306
|
+
private readonly graphics;
|
|
307
|
+
private readonly references;
|
|
308
|
+
private placedPins;
|
|
309
|
+
private readonly frames;
|
|
310
|
+
private readonly regions;
|
|
311
|
+
private readonly importedModules;
|
|
312
|
+
private readonly objectModules;
|
|
313
|
+
private readonly requiredPowerSymbols;
|
|
314
|
+
private readonly templates;
|
|
315
|
+
/** Load validated templates. @param options Project identity, page and template directory. */
|
|
316
|
+
constructor(options: SchematicOptions);
|
|
317
|
+
/** Reserve a non-overlapping fixed module frame before placing its circuit.
|
|
318
|
+
* @param spec Model-planned size, origin, title and explanation.
|
|
319
|
+
* @returns Local-coordinate operations; no content fitting or automatic placement is performed.
|
|
320
|
+
*/
|
|
321
|
+
region(spec: ModuleRegionSpec): ModuleRegion;
|
|
322
|
+
private source;
|
|
323
|
+
/** Persist source-reference mappings in scripts after importModule returns final references. */
|
|
324
|
+
assignFootprints(mappings: Record<string, string>): void;
|
|
325
|
+
/** Merge an existing single-sheet circuit, isolating private nets and renumbering instances.
|
|
326
|
+
* @param spec Source path, unique module name, global translation and explicit shared nets.
|
|
327
|
+
* @returns Reference map, translated label anchors, net names and object UUIDs for frames.
|
|
328
|
+
*/
|
|
329
|
+
importModule(spec: FlatImportSpec & {
|
|
330
|
+
sourcePath: string;
|
|
331
|
+
footprintMappingPath?: string;
|
|
332
|
+
}): FlatImportResult;
|
|
333
|
+
/** Place a symbol using its actual library definition, expanding simple inheritance.
|
|
334
|
+
* @param spec Exact library symbol and model-selected placement.
|
|
335
|
+
* @returns UUID for grouping this instance in a frame.
|
|
336
|
+
*/
|
|
337
|
+
addSymbol(spec: SymbolPlacement): string;
|
|
338
|
+
/** Read every placed pin in one catalog, including rotation and mirror transforms.
|
|
339
|
+
* @returns Instance identities, exact sheet pins and explicit pin errors; no connectivity is inferred.
|
|
340
|
+
*/
|
|
341
|
+
pinCatalog(): ReturnType<typeof listFlatObjects>;
|
|
342
|
+
/** Resolve a placed symbol's numbered pin; ambiguous multi-unit matches fail.
|
|
343
|
+
* @param reference Placed reference. @param number Actual library pin number.
|
|
344
|
+
* @returns Transformed sheet coordinates in millimetres.
|
|
345
|
+
*/
|
|
346
|
+
pin(reference: string, number: string): FlatPoint;
|
|
347
|
+
private endpoint;
|
|
348
|
+
/** Add explicitly routed orthogonal wire segments; no junctions are inferred.
|
|
349
|
+
* @param from Pin or coordinate. @param to Pin or coordinate. @param via Explicit intermediate bends.
|
|
350
|
+
* @returns UUIDs of generated segments for frame grouping.
|
|
351
|
+
*/
|
|
352
|
+
wire(from: FlatEndpoint, to: FlatEndpoint, via?: FlatPoint[]): string[];
|
|
353
|
+
/** Add a local electrical label at a pin or wire point.
|
|
354
|
+
* @param name Exact network name. @param at Explicit anchor. @param angle Text rotation.
|
|
355
|
+
* @returns Label UUID for grouping.
|
|
356
|
+
*/
|
|
357
|
+
label(name: string, at: FlatEndpoint, angle?: 0 | 90 | 180 | 270): string;
|
|
358
|
+
/** List only explicitly selected local/global labels in this build, before conversion.
|
|
359
|
+
* UUIDs are fresh each build; select by module/net/coordinates and use this returned UUID.
|
|
360
|
+
* @param nets Exact shared networks, never a heuristic power-name filter.
|
|
361
|
+
* @returns Detached label records in sheet millimetres; hierarchical labels are excluded.
|
|
362
|
+
*/
|
|
363
|
+
powerLabelCatalog(nets: readonly string[]): PowerLabelEntry[];
|
|
364
|
+
/** Verify constructor-declared power-symbol delivery requirements before publication.
|
|
365
|
+
* Each exact net must have a genuine power definition, matching libId and Value,
|
|
366
|
+
* and no unconverted local/global label. Does not infer or merge power domains.
|
|
367
|
+
* @returns Per-net completion counts; throws without mutating the sheet on failure.
|
|
368
|
+
*/
|
|
369
|
+
checkPowerSymbols(): PowerSymbolStatus[];
|
|
370
|
+
/** Plan bounded cardinal rotations, readable text positions and safe short straight leads.
|
|
371
|
+
* Does not mutate the sheet; consume placements in replacePowerLabels in this same build.
|
|
372
|
+
* Unresolved conservative overlaps are returned, not presented as a clean layout.
|
|
373
|
+
*/
|
|
374
|
+
planPowerPlacements(spec: PowerPlanningOptions): PowerPlacementPlan;
|
|
375
|
+
/** Replace explicitly shared local/global power labels using zero-length-pin power symbols.
|
|
376
|
+
* @param spec Trusted library, exact net map and optional label-UUID placements with caller-routed bends.
|
|
377
|
+
* @returns Replaced labels with retained UUIDs and network names; moved anchors receive explicit connecting wires.
|
|
378
|
+
*/
|
|
379
|
+
replacePowerLabels(spec: PowerLabelSpec): PowerLabelReplacement[];
|
|
380
|
+
/** Locate conservative overlaps around power symbols and their visible fields.
|
|
381
|
+
* @returns Suspected object intersections; attached wire endpoints are excluded. Review hints in preview.
|
|
382
|
+
*/
|
|
383
|
+
powerLayoutWarnings(): PowerLayoutWarning[];
|
|
384
|
+
/** Add a passive hierarchy port connected at an explicit anchor; no connection is inferred.
|
|
385
|
+
* @param name Port name. @param at Actual pin or sheet coordinate. @param angle Text rotation.
|
|
386
|
+
* @returns Label UUID for a generated child sheet.
|
|
387
|
+
*/
|
|
388
|
+
hierarchicalLabel(name: string, at: FlatEndpoint, angle?: 0 | 90 | 180 | 270): string;
|
|
389
|
+
/** Add an explicit branch junction or intentionally unconnected pin marker.
|
|
390
|
+
* @param kind Marker kind. @param at Pin or coordinate.
|
|
391
|
+
* @returns Marker UUID.
|
|
392
|
+
*/
|
|
393
|
+
marker(kind: 'junction' | 'no_connect', at: FlatEndpoint): string;
|
|
394
|
+
/** Add a module frame with manual bounds or explicitly grouped automatic bounds.
|
|
395
|
+
* @param frame Visible title, explanation and range selection; omitted excludeUuids resolves to an empty list.
|
|
396
|
+
*/
|
|
397
|
+
frame(frame: {
|
|
398
|
+
name: string;
|
|
399
|
+
description: string;
|
|
400
|
+
} & ({
|
|
401
|
+
start: FlatPoint;
|
|
402
|
+
end: FlatPoint;
|
|
403
|
+
autoBounds?: false;
|
|
404
|
+
} | {
|
|
405
|
+
autoBounds: true;
|
|
406
|
+
objectUuids?: string[];
|
|
407
|
+
excludeUuids?: string[];
|
|
408
|
+
})): void;
|
|
409
|
+
/** Serialize the current design with existing frame and project templates.
|
|
410
|
+
* @returns Schematic text, project JSON text, resolved frames and edit counts.
|
|
411
|
+
*/
|
|
412
|
+
render(): ReturnType<typeof buildFlatCopy>;
|
|
413
|
+
/** Write a new output pair without overwriting existing files; use a unique candidate directory.
|
|
414
|
+
* @param directory Explicit output directory; created recursively when absent.
|
|
415
|
+
* @returns Written paths, resolved frames and conservative power-layout warnings from the saved design. Errors may leave a partial pair.
|
|
416
|
+
*/
|
|
417
|
+
save(directory: string): {
|
|
418
|
+
schematicPath: string;
|
|
419
|
+
projectPath: string;
|
|
420
|
+
frames: ResolvedFlatFrame[];
|
|
421
|
+
layoutWarnings: PowerLayoutWarning[];
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
//#endregion
|
|
425
|
+
//#region src/runtime-paths.d.ts
|
|
426
|
+
/** Explicit paths override discovery; default command names still discover the host and PATH. */
|
|
427
|
+
declare function resolveKiCadPaths(executable?: string, env?: NodeJS.ProcessEnv): {
|
|
428
|
+
kicadCliPath: string;
|
|
429
|
+
symbolDir?: string;
|
|
430
|
+
};
|
|
431
|
+
//#endregion
|
|
432
|
+
//#region src/schematic/label-leads.d.ts
|
|
433
|
+
interface LabelTarget {
|
|
434
|
+
pin(reference: string, number: string): FlatPoint;
|
|
435
|
+
wire(from: FlatPoint, to: FlatPoint, via?: FlatPoint[]): unknown;
|
|
436
|
+
label(name: string, at: FlatPoint, angle?: number): unknown;
|
|
437
|
+
}
|
|
438
|
+
/** Explicit, reusable label fanout. Caller chooses outward direction and clear lanes.
|
|
439
|
+
* Coordinates stay in the target's coordinate system (sheet or region).
|
|
440
|
+
* This does not infer pin orientation, avoid obstacles or validate connectivity.
|
|
441
|
+
*/
|
|
442
|
+
declare function attachPinLabel(target: LabelTarget, spec: {
|
|
443
|
+
reference: string;
|
|
444
|
+
pin: string;
|
|
445
|
+
net: string;
|
|
446
|
+
direction: 'left' | 'right' | 'up' | 'down';
|
|
447
|
+
length?: number;
|
|
448
|
+
lane?: number;
|
|
449
|
+
pitch?: number;
|
|
450
|
+
}): {
|
|
451
|
+
at: FlatPoint;
|
|
452
|
+
label: unknown;
|
|
453
|
+
};
|
|
454
|
+
/** One side of a symbol: straight leads and labels over wires by default.
|
|
455
|
+
* Does not infer pin sides or reroute existing connections. Inspect warnings in preview.
|
|
456
|
+
*/
|
|
457
|
+
declare function attachPinLabels(target: LabelTarget, spec: {
|
|
458
|
+
reference: string;
|
|
459
|
+
pins: {
|
|
460
|
+
pin: string;
|
|
461
|
+
net: string;
|
|
462
|
+
}[];
|
|
463
|
+
direction: 'left' | 'right' | 'up' | 'down';
|
|
464
|
+
length?: number;
|
|
465
|
+
alignAt?: number;
|
|
466
|
+
minPitch?: number;
|
|
467
|
+
textPosition?: 'overWire' | 'outside';
|
|
468
|
+
}): {
|
|
469
|
+
items: {
|
|
470
|
+
pin: string;
|
|
471
|
+
net: string;
|
|
472
|
+
at: FlatPoint;
|
|
473
|
+
end: FlatPoint;
|
|
474
|
+
label: unknown;
|
|
475
|
+
}[];
|
|
476
|
+
warnings: ({
|
|
477
|
+
code: "LABEL_PITCH_TIGHT";
|
|
478
|
+
pins: string[];
|
|
479
|
+
pitch: number;
|
|
480
|
+
} | {
|
|
481
|
+
code: "LABEL_LEAD_SHORT";
|
|
482
|
+
pins: string[];
|
|
483
|
+
})[];
|
|
484
|
+
};
|
|
485
|
+
//#endregion
|
|
486
|
+
export { ModuleRegion, ModuleRegionSpec, PowerLabelEntry, PowerLabelReplacement, PowerLabelSpec, PowerLayoutWarning, type PowerPlacementPlan, type PowerPlanningOptions, PowerSymbolStatus, Schematic, SchematicOptions, SymbolPlacement, attachPinLabel, attachPinLabels, resolveKiCadPaths };
|