dsh-kicad-sch
Repository: https://github.com/550AW/dsh-kicad-sch · Version: 1.3.1
A DSH plugin that parses KiCad schematics — modern .kicad_sch and legacy
.sch — and turns Altium drawings into KiCad first, so an agent can answer
questions about a board's netlist without opening KiCad. The package name is
still kicad-sch; the public repository is dsh-kicad-sch.
Installation
The plugin is plain ESM JavaScript plus the bundled Altium Perl scripts. There
is no npm install and no build step.
From the GitHub repository or a release ZIP. Download
dsh-kicad-sch-1.3.1.zipfrom the release page (or clone/download the repository) and extract it to a folder. In DSH, callplugin_managerwithaction: "install_bundle"andtargetset to the extracted folder — the directory that containspackage.jsonandcordis.patch.yml:plugin_manager action: install_bundle target: <path-to-dsh-kicad-sch>From a local checkout. Use the same
install_bundleaction and pointtargetat your working copy, replacing<path-to-dsh-kicad-sch>with the absolute path of the directory that containspackage.json.
The bundle registers four tools once installed:
| Tool | What it does |
|---|---|
kicad_sch_read |
Components, pins, nets, labels, sub-sheets, and a problem list. Parameters: path, view (summary, components, nets, net, component, json), net, ref, limit (1–2000), pages (design default, or root), lenient. |
kicad_sch_render |
Writes an SVG plot of one page. Parameters: path, out, sheet (page path, page name, or leaf filename; the root page is the default), width (320–8000). |
kicad_sch_export |
Writes a KiCad-compatible .net netlist and a CSV BOM (<name>.net, <name>_bom.csv). Parameters: path, out_dir, netlist, bom, pages. |
altium_to_kicad |
Runs the bundled altium2kicad scripts on an Altium .SchDoc (optionally .PcbDoc), then parses the converted design. Parameters: path, out_dir, pcb, parse, lenient. |
Formats
- Modern
.kicad_sch— S-expression files written by KiCad 6 and later. Symbol definitions come from the file's ownlib_symbolsblock. - Legacy
.sch— EESchema "Schematic File Version 2–4" text, including the filesaltium2kicadwrites. Pin geometry comes from the.libcache in the same folder (<name>-cache.libpreferred).
Hierarchy
Every page is loaded from the root sheet. Global labels and power nets join by
name across pages; a child hierarchical_label joins the parent sheet pin with
the same text; local and hierarchical labels are page-scoped and named
/<sheet path>/<label>. References and multi-unit placements are resolved per
sheet instance from (instances …) blocks (and root (symbol_instances …) for
KiCad 6.0-era files). KiCad 7/8 local-label promotion is applied for files older
than the KiCad 9 schematic version and reported as promoted-local-labels.
Buses
Bus text is expanded with KiCad's rules: A[3..0], {x y z}, top{a_xyz}, and
(bus_alias …) (aliases expand only inside braces). Wire nets join a bus member
by full name; bus entries are decoration. Member grouping works on one page and
across pages through sheet pins: vector members pair by ascending index, group
members by local name (with KiCad's flat-index fallback), a net bridging several
buses takes the last bus's member name, and a global label or global power pin
renames the member it lands on. node test/bus-check.mjs pins these rules
against netlists exported by KiCad itself.
Behaviour notes (1.3.1)
These are the user-visible fixes made by the 1.3.1 adversarial audit; the full
list is in CHANGELOG.md.
- Netlist output is valid.
kicad_sch_exportwrites balanced s-expressions; the extra)that previously invalidated every netlist with connected nodes is gone, andtest/regression.mjsparses the exported file. - Missing Perl is reported clearly. Altium conversion no longer prints a
bare
FAILED unpack.pl; a step that cannot start reportsspawn failed: spawnSync perl ENOENT, so a missingperlonPATHis obvious. - Pathological input cannot hang the tools. Connectivity buckets are capped
at 4096 cells per wire (larger coordinates fall back to a bounding-box
filter) and a single bus vector expands at most 4096 members; a larger vector
such as
A[0..1000000000]is treated as plain label text. Both are safety limits, not normal-use limits. - Unknown pages are errors.
kicad_sch_renderwith asheetthat does not exist throwsno page "…" in this design (pages: …)and lists the available pages; an omitted or emptysheetstill renders the root page. - Failure lines use a colon. Altium step failures read
FAILED unpack.pl: <reason>instead of the old mojibake separator??.
Testing
The repository ships its test data under test/. Directories generated by the
tests (test/out/, test/fixtures/out/, and conversion work directories) are
created at runtime and are not tracked in the repository.
node test/run.mjs # 10/10 single-file KiCad QA checks
node test/suite.mjs # 24/24 KiCad QA netlist cases
node test/bus-check.mjs # 16/16 bus cases exported by KiCad
node test/export-check.mjs # netlist/BOM export shape and netlist parsing
node test/design-check.mjs <root.kicad_sch> # e.g. test/fixtures/qa-suite/issue16003/issue16003.kicad_sch
node test/legacy-check.mjs <legacy.sch> # e.g. test/fixtures/altium/vias-SchDoc.sch
node test/regression.mjs # 12/12 regression checks for the 1.3.1 fixes
node test/toolcheck.mjs # Altium → KiCad → parse, end to end
test/toolcheck.mjs runs a real Altium conversion and therefore needs Perl; its
two Altium checks fail with a clear spawn failed: spawnSync perl ENOENT when
Perl is not installed, which is an environment limitation rather than a plugin
defect. The other suites need no Perl.
Last full run (1.3.1): all suites above pass except the two Perl-dependent
Altium checks in test/toolcheck.mjs; test/regression.mjs covers every fix
below. A separate adversarial audit exercised the four tools with 61 targeted
probes — 37 file/parser cases, 19 tool-level cases (parameters, output schema,
concurrency, error text), and 5 DoS cases in isolated subprocesses — plus the
suites listed above, all green.
Dependencies and license
- Perl must be on
PATHforaltium_to_kicad(the bundled converter is a set of Perl scripts); setDSH_PERLto point at a specific interpreter. All other tools work without Perl.DSH_ALTIUM2KICADcan point at a different copy of the converter. - The repository as a whole is MIT (see
LICENSE). The bundledtools/altium2kicad/is upstream GPL-2.0 material, keeps its own license (tools/altium2kicad/LICENSE), and that directory is governed by GPL-2.0. - There are no other third-party dependencies and no packages to install.
Limits
- Auto-generated net names keep the
-PadNform; KiCad can use the pin name or unit letter instead (explicit and bus-derived names are exact). altium2kicadoutput quality is upstream's; conversion notes are included.- Legacy
.schwithout its.liblists components but leaves pins unknown. - A hierarchy is capped at 200 sheet instances and 24 levels; cycles and missing child files are reported as problems instead of aborting the load.
- A single bus vector expands at most 4096 members, and a wire contributes at most 4096 connection buckets; pathological coordinates fall back to a bounding-box filter.
Marketplace listing
This plugin is listed in awesome-dsh-plugin under the category tools:
Read KiCad schematics, render them to SVG, and export netlists and BOM CSVs, plus an Altium-to-KiCad converter that runs the altium2kicad Perl scripts.
The entry file lives in this repository as dsh-kicad-sch.yml so the catalogue text stays reviewable next to the code; the copy submitted upstream is data/plugins/550AW__dsh-kicad-sch.yml. Description changes start in that file.
No comments yet. Be the first to write one.