@qmingjun/dsh-eda-mcp 0.0.0-stage → 1.1.12

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.
Files changed (53) hide show
  1. package/AGENTS.md +63 -0
  2. package/CHANGELOG.md +792 -0
  3. package/CONTRIBUTING.md +154 -0
  4. package/LICENSE +55 -0
  5. package/README.md +290 -2
  6. package/README.zh.md +449 -0
  7. package/cordis.patch.yml +7 -0
  8. package/docs/design-rules.md +254 -0
  9. package/docs/dsh-version-sweep.md +73 -0
  10. package/docs/pitfalls.md +99 -0
  11. package/docs/project-status.md +100 -0
  12. package/docs/release.md +215 -0
  13. package/docs/schematic-workflow.md +297 -0
  14. package/docs/tools.md +184 -0
  15. package/jlc-extension/api-bridge.js +879 -0
  16. package/jlc-extension/extension.json +104 -0
  17. package/lib/bridge.mjs +4179 -0
  18. package/lib/client.js +1605 -0
  19. package/lib/extension-digest.json +6 -0
  20. package/lib/index.js +1261 -0
  21. package/package.json +144 -4
  22. package/src/bridge/design-intake.ts +133 -0
  23. package/src/bridge/design-rules.ts +228 -0
  24. package/src/bridge/eda-launch.ts +267 -0
  25. package/src/bridge/extension-package.ts +35 -0
  26. package/src/bridge/index.ts +3576 -0
  27. package/src/bridge/netlist-erc.ts +305 -0
  28. package/src/bridge/schematic-audit.ts +131 -0
  29. package/src/bridge/workflow-guide.ts +65 -0
  30. package/src/bridge-diagnostics.ts +185 -0
  31. package/src/client/EdaMcpSettingsCard.tsx +571 -0
  32. package/src/client/index.ts +40 -0
  33. package/src/client/locales.ts +83 -0
  34. package/src/client/settings-scope.ts +160 -0
  35. package/src/config-values.ts +60 -0
  36. package/src/guidance.ts +35 -0
  37. package/src/index.ts +365 -0
  38. package/src/loopback.ts +48 -0
  39. package/src/node-runtime.ts +120 -0
  40. package/src/routes.ts +377 -0
  41. package/src/skills-content.ts +309 -0
  42. package/src/skills.ts +91 -0
  43. package/test/config-values.test.ts +60 -0
  44. package/test/design-intake.test.ts +40 -0
  45. package/test/design-rules.test.ts +72 -0
  46. package/test/eda-launch.test.ts +114 -0
  47. package/test/extension-package.test.ts +27 -0
  48. package/test/extension-routes.test.ts +116 -0
  49. package/test/netlist-erc.test.ts +90 -0
  50. package/test/node-runtime.test.ts +65 -0
  51. package/test/schematic-audit.test.ts +71 -0
  52. package/test/seams.test.ts +164 -0
  53. package/test/skills.test.ts +68 -0
@@ -0,0 +1,154 @@
1
+ # Contributing
2
+
3
+ Thanks for taking a look. This document is short on purpose — the plugin is
4
+ small, and the checks below are the whole contract.
5
+
6
+ ## Repository layout
7
+
8
+ | Path | What it is |
9
+ |---|---|
10
+ | `src/index.ts` | DSH host half: settings seam, loopback routes, MCP client mount |
11
+ | `src/node-runtime.ts` | Picks the executable that can actually run the bridge (Node host vs. Electron desktop) |
12
+ | `src/config-values.ts` | Resolves DSH `volatile` config fields (live handles) to plain values |
13
+ | `src/bridge-diagnostics.ts` | Mount/bridge diagnostics and the host-side spawn self-test |
14
+ | `src/routes.ts` | Loopback HTTP routes: test, reconnect, diagnostics, self-test, settings bridge, extension zip |
15
+ | `src/guidance.ts` | System-prompt section injected when `announceToAgent` is on |
16
+ | `src/bridge/index.ts` | Standalone MCP (stdio) + WebSocket bridge child, zero dependencies |
17
+ | `src/bridge/design-rules.ts` | Enforceable half of the design rules: net naming, width tiers, via geometry |
18
+ | `src/client/` | Web settings card (slot `settings.section`) |
19
+ | `jlc-extension/` | JLCEDA Pro extension (allow-listed API bridge) packaged into the zip |
20
+ | `test/` | Node-runtime, config-value and design-rule unit tests |
21
+ | `docs/design-rules.md` | Normative schematic + PCB rule set, with the enforcement mapping |
22
+ | `docs/tools.md` | Generated reference for every MCP tool (`pnpm docs`) |
23
+ | `scripts/gen-tools-doc.mjs` | Regenerates `docs/tools.md` from the built bridge's `tools/list` |
24
+ | `build.mjs` | esbuild bundles + extension zip |
25
+
26
+ ## Development
27
+
28
+ Requirements: Node `^22.19.0 || >=24`, pnpm (the repo pins `pnpm@10.6.3` through
29
+ `packageManager`), and **Windows** for `pnpm build` — the extension zip is
30
+ packaged with PowerShell `Compress-Archive`.
31
+
32
+ ```sh
33
+ pnpm install
34
+ pnpm typecheck # tsc --noEmit
35
+ pnpm test # unit tests + the seam compatibility test
36
+ pnpm build # lib/*.js, lib/bridge.mjs, lib/client.js, dsh-eda-bridge-extension-<version>.zip
37
+ pnpm check # all three, in that order
38
+ pnpm docs # regenerate docs/tools.md from the built bridge
39
+ pnpm seam-check # assert the plugin's DSH contracts against another version line
40
+ ```
41
+
42
+ `pnpm seam-check` defaults to the registry's `latest`; pass a dist-tag or a version
43
+ to check a specific one:
44
+
45
+ ```sh
46
+ pnpm seam-check next # e.g. 0.2.1-rc.2
47
+ pnpm seam-check 0.2.0-rc.2
48
+ ```
49
+
50
+ It installs that generation's seam packages into a throwaway directory and runs
51
+ `test/seams.test.ts` against them, so it never touches this repo's `node_modules`.
52
+ When a new DSH line appears, run it first; only widen the ranges in `package.json`
53
+ once it passes. Note the semver trap: `^0.2.0-rc.2` does **not** cover `0.2.1-rc.x`
54
+ (a prerelease only matches a comparator with the same major.minor.patch), so each
55
+ new `0.2.x` prerelease line needs its own entry.
56
+
57
+ Install the working copy into a DSH profile as a link, so every rebuild is picked
58
+ up by a profile restart:
59
+
60
+ ```sh
61
+ dsh plugin --profile web add "link:/absolute/path/to/dsh-eda-mcp"
62
+ ```
63
+
64
+ The host half is loaded as a packaged ESM module: **a plugin reload does not
65
+ re-import a cached module**, so a change under `src/` needs `pnpm build` plus a
66
+ Host restart.
67
+
68
+ ## Tests
69
+
70
+ `test/node-runtime.test.ts` and `test/config-values.test.ts` cover the two places
71
+ where a wrong guess is invisible at runtime: which executable starts the bridge on
72
+ an Electron host, and how DSH hands `volatile` config fields to `apply()`. Add a
73
+ case there when you touch either file — both bugs they cover presented as "the
74
+ plugin silently does nothing".
75
+
76
+ ## Pull requests
77
+
78
+ - Keep a change to one concern; describe what you observed (commands, output) and
79
+ what changed.
80
+ - Run `pnpm check` before opening the PR.
81
+ - Update `CHANGELOG.md` under a new version heading when behaviour, the tool set,
82
+ the bridge protocol, or the EDA extension allow-list changes.
83
+ - Bridge and extension versions are compared by `eda_status` (`versionMismatch`):
84
+ bump `lib/bridge.mjs`'s `VERSION` and `jlc-extension/extension.json` **together
85
+ with** the EDA extension whenever the white-list or an internal helper changes,
86
+ and say so in the changelog so users know to re-import the zip.
87
+
88
+ ## Releases
89
+
90
+ **Tags are created only on the maintainer's explicit request.** Commits and pushes
91
+
92
+ The weekly DSH upgrade sweep (registry tags, seam check, the two manual contracts) is written
93
+ down in [`docs/dsh-version-sweep.md`](docs/dsh-version-sweep.md) — follow it instead of judging by
94
+ `latest` alone.
95
+ to `main` are normal work and land as *unreleased* changes (own heading in
96
+ `CHANGELOG.md`); creating a `v*` tag is a release decision and must be asked for
97
+ first. A pushed `v*` tag also triggers the `publish` workflow, so tagging by
98
+ accident means an accidental npm release.
99
+
100
+ ```sh
101
+ # only after the maintainer says "tag it"
102
+ # 1. move the unreleased changelog heading to the version, bump package.json, run pnpm check
103
+ # 2. commit, then tag and push
104
+ git commit -am "chore(release): 0.6.2"
105
+ git tag -a v0.6.2 -m "dsh-eda-mcp 0.6.2"
106
+ git push origin main --follow-tags
107
+ ```
108
+
109
+ `package.json.version` tracks the plugin package; `lib/bridge.mjs` + the EDA
110
+ extension have their own version pair (they are the wire contract between the
111
+ bridge process and JLCEDA, and `eda_status` reports a mismatch).
112
+
113
+ ### Uploading the extension zip to the download server
114
+
115
+ Every wire-version bump produces a new `dsh-eda-bridge-extension-<version>.zip` (it is
116
+ gitignored, so the file lives only in the npm tarball and on the download server). The
117
+ maintainer asked for the server copy to be refreshed on every update — do it in the same
118
+ session that bumps the extension, not later:
119
+
120
+ 1. upload the new zip to `/var/www/eda-download/` on `tencent` (`root@159.75.130.207`)
121
+ **without deleting older versions** — the version is in the filename, so old links keep
122
+ working;
123
+ 2. verify the transfer: the remote `sha256sum` must equal `Get-FileHash` locally, and
124
+ `curl -sI http://159.75.130.207/eda/<zip>` must answer `200` + `Content-Type:
125
+ application/zip` + the exact byte count;
126
+ 3. only then hand the link out:
127
+ `http://159.75.130.207/eda/dsh-eda-bridge-extension-<version>.zip`
128
+ (the listing at `http://159.75.130.207/eda/` shows every published zip).
129
+
130
+ The directory is served by one additive `location /eda/` block in
131
+ `/etc/nginx/conf.d/voice.conf`; adding or replacing files needs no nginx change and no
132
+ reload. Keep every other part of that server untouched.
133
+
134
+ ### Rate limit
135
+
136
+ `/eda/` is throttled to **5 requests/minute per IP with burst 5** (nginx `limit_req`,
137
+ `rate=5r/m`): six requests pass immediately, the seventh answers `429` with a readable body.
138
+ `127.0.0.1` and `::1` are exempt (geo key is empty), so server-side checks never throttle.
139
+ The zone lives in `/etc/nginx/conf.d/eda-ratelimit.conf`, the limit itself inside the `/eda/`
140
+ location; changing the rate needs `nginx -t` plus a reload.
141
+
142
+ Verifying an upload from an office IP can therefore hit the limit: `eda_extension_package`
143
+ reports that as `verified: 'unverified'` with `httpStatus: 429` — wait about a minute and
144
+ retry instead of suspecting the artifact. A `429` is never a checksum mismatch.
145
+
146
+ Publishing to npm is documented step by step in [`docs/release.md`](docs/release.md):
147
+ first release is manual (2FA / staged publishing), afterwards the `publish`
148
+ workflow releases on every `v*` tag through npm trusted publishing (OIDC, no
149
+ token in the repo). Run `npm pack --dry-run` before tagging — the tarball must
150
+ contain `lib/`, the extension zip and `docs/`.
151
+
152
+ ## License
153
+
154
+ Apache-2.0 — see [LICENSE](LICENSE).
package/LICENSE ADDED
@@ -0,0 +1,55 @@
1
+ Apache License
2
+
3
+ Version 2.0, January 2004
4
+
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
16
+
17
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
18
+
19
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
20
+
21
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
22
+
23
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
24
+
25
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
26
+
27
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
28
+
29
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
30
+
31
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
32
+
33
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
34
+
35
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
36
+
37
+ You must give any other recipients of the Work or Derivative Works a copy of this License; and
38
+
39
+ You must cause any modified files to carry prominent notices stating that You changed the files; and
40
+
41
+ You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
42
+
43
+ If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
44
+
45
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
46
+
47
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
48
+
49
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
50
+
51
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
52
+
53
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
54
+
55
+ END OF TERMS AND CONDITIONS
package/README.md CHANGED
@@ -1,3 +1,291 @@
1
- # Temporary Holding Version
1
+ # dsh-eda-mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![check](https://github.com/MCviseron/dsh-eda-mcp/actions/workflows/check.yml/badge.svg)](https://github.com/MCviseron/dsh-eda-mcp/actions/workflows/check.yml)
4
+ [![license](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
5
+ [![npm](https://img.shields.io/npm/v/dsh-eda-mcp.svg)](https://www.npmjs.com/package/dsh-eda-mcp)
6
+ [![node](https://img.shields.io/badge/node-%5E22.19%20%7C%7C%20%3E%3D24-brightgreen.svg)](package.json)
7
+
8
+ DeepSeek Harness (DSH) plugin that connects DSH to **嘉立创EDA专业版 / EasyEDA Pro** and lets the agent draw schematics through MCP tools.
9
+
10
+ > 中文文档:[README.zh.md](README.zh.md) · Tool reference: [docs/tools.md](docs/tools.md) · Changes: [CHANGELOG.md](CHANGELOG.md)
11
+
12
+ ## How it works
13
+
14
+ ```
15
+ DSH agent
16
+ └─ mcp__jlceda__eda_* tools
17
+ └─ @deepseek-ai/dsh-mcp-client (stdio)
18
+ └─ lib/bridge.mjs (local MCP + WebSocket server, 127.0.0.1:39009)
19
+ └─ JLCEDA Pro extension dsh-eda-bridge-extension-<version>.zip
20
+ └─ official EasyEDA Pro extension API (eda.sch_*)
21
+ ```
22
+
23
+ The DSH plugin starts a zero-dependency bridge child process. The bridge speaks MCP over stdio to DSH and WebSocket to a small JLCEDA Pro extension. The extension executes a strict allow-list of official EDA APIs, so the model cannot run arbitrary code inside JLCEDA.
24
+
25
+ ## Install
26
+
27
+ > Runtime requirement: DSH `0.1.1-rc.x`, `0.1.5-rc.x`, `0.2.0-rc.x`, `0.2.1-rc.x`, `0.2.2-rc.x` or `0.2.3-alpha.x` (Web GUI and the official Desktop). The host settings seam and the browser bundle are adapted to every generation, so one build loads on any of them.
28
+ >
29
+ > Verified generations: `0.1.5-rc.2` (this repo's dev set), `0.2.0-rc.2` / `0.2.1-rc.2` (desktop runtime and npm `next`), and **`0.2.1-rc.3` / `0.2.1-rc.5` / `0.2.2-rc.1` / `0.2.2-rc.3` / `0.2.3-alpha.1` / `0.2.3-alpha.3`** (sweeps: `pnpm seam-check` passed all seven seams for both; the two manual contracts still hold — `dsh-tools` keeps `super(ctx, 'tools')` and `dsh-plugin-manager` still reads `manifest.dsh?.bundle?.patch`).
30
+
31
+ ### 0. From npm (recommended)
32
+
33
+ ```sh
34
+ cd "$DSH_HOME/profiles/<profile>"
35
+ pnpm add dsh-eda-mcp # or use the plugin manager in the Web GUI
36
+ # restart DSH
37
+ ```
38
+
39
+ The published package ships `lib/` and `lib/extension-digest.json` (no zip), so no build toolchain
40
+ is needed. The extension zip is **downloaded, not bundled**: the settings card (or the link below)
41
+ fetches it from the download server and the plugin verifies the sha256 against its own manifest
42
+ before the file is handed to you — a served copy that does not match is refused instead of being
43
+ installed as a different wire version. Import it into JLCEDA Pro by hand.
44
+
45
+ Direct links (no package install needed):
46
+
47
+ - `http://159.75.130.207/eda/dsh-eda-bridge-extension-0.4.9.zip` (current wire version)
48
+ - `http://159.75.130.207/eda/` - directory listing of every uploaded extension zip
49
+
50
+ The filename always carries the wire version; check `eda_status` after importing and restart JLCEDA
51
+ Pro when the version differs from the bridge.
52
+
53
+ Verification: `eda_extension_package` reports the zip this plugin ships (path, bytes, sha256) and,
54
+ with `download: true`, fetches the served copy and compares the two byte for byte (`verified: match |
55
+ mismatch`). On a match it saves the file to `outDir` (default: the temp directory); on a mismatch it
56
+ writes nothing and tells you to re-upload. The zip build is reproducible, so equal sources always
57
+ produce the same sha256.
58
+
59
+ The download server throttles `/eda/` to 5 requests/minute per IP (burst 5, loopback exempt), so
60
+ a `429` shows up as `verified: 'unverified'` with `httpStatus: 429` — that is throttling, not a
61
+ checksum mismatch; wait a minute and retry.
62
+ The settings card serves the **bundled** copy (works offline, never throttled) and stamps
63
+ `x-extension-version` / `x-extension-sha256` on the response; its "Verify server copy" button calls
64
+ `/api/dsh-eda-mcp/extension/verify` and reports match / mismatch / why verification was impossible
65
+ (429 throttling included).
66
+ The settings card serves the **bundled** copy (works offline, never throttled) and stamps
67
+ `x-extension-version` / `x-extension-sha256` on the response; its "Verify server copy" button calls
68
+ `/api/dsh-eda-mcp/extension/verify` and reports match / mismatch / why verification was impossible
69
+ (429 throttling included).
70
+
71
+ ### 1. Install into the DSH web profile
72
+
73
+ ```sh
74
+ # directly from GitHub (pnpm runs the package's `prepare` build)
75
+ dsh plugin --profile web add "github:MCviseron/dsh-eda-mcp"
76
+
77
+ # or from a local clone, so every `pnpm build` is picked up by a profile restart
78
+ git clone https://github.com/MCviseron/dsh-eda-mcp.git
79
+ cd dsh-eda-mcp && pnpm install && dsh plugin --profile web add "link:$PWD"
80
+ ```
81
+
82
+ `dsh plugin` forwards to pnpm and reconciles `dsh.profile.bundles` automatically. Restart the running DSH Web profile after installation.
83
+
84
+ ### 1b. Running inside the official Desktop app
85
+
86
+ The Desktop app hosts plugins in **Electron**, so there `process.execPath` is `DeepSeek Harness.exe`, not Node: spawning it with `lib/bridge.mjs` starts (or single-instance-aborts) a second app instead of a bridge, and port 39009 never listens — the settings card exists, `/test` always fails and the agent gets no `mcp__jlceda__*` tools.
87
+
88
+ The plugin now resolves a real Node executable (`src/node-runtime.ts`), in order: `DSH_EDA_MCP_NODE` override → `DSH_NODE_EXECUTABLE` / `DSH_DESKTOP_NODE_EXECUTABLE` (with `ELECTRON_RUN_AS_NODE=1`) → `process.execPath` on a Node host → the Desktop payload's own `resources/runtime/primary-runtime/dependencies/node/bin/node.exe` → `node` on `PATH` → Electron-as-Node.
89
+
90
+ `POST /api/dsh-eda-mcp/test` reports which one it picked:
91
+
92
+ ```json
93
+ {"ok":true,"health":{"status":"ok","version":"0.3.5","clients":1},
94
+ "launch":{"command":"…\\runtime\\primary-runtime\\dependencies\\node\\bin\\node.exe","source":"desktop runtime Node"}}
95
+ ```
96
+
97
+ > The Desktop loads the packaged `lib/index.js`, and a plugin reload does **not** re-import a cached ESM module — after changing `src/`, run `node build.mjs` and restart the Desktop app.
98
+
99
+ ### 2. Import the JLCEDA Pro bridge extension
100
+
101
+ Build produces `dsh-eda-bridge-extension-<version>.zip` only — a second copy under the stable name only made it unclear which build you were looking at. In JLCEDA Pro:
102
+
103
+ 1. Open **扩展 → 导入** (Extensions → Import).
104
+ 2. Select `dsh-eda-bridge-extension-<version>.zip`.
105
+ 3. In the extension list find **DSH EDA MCP Bridge**.
106
+ 4. Enable it and, importantly, enable **允许外部交互 / Allow external interactions**.
107
+
108
+ The extension connects to `ws://127.0.0.1:39009/ws`. Keep JLCEDA Pro running and a schematic page open.
109
+
110
+ ### 3. Verify
111
+
112
+ In the DSH Web GUI settings page, the **嘉立创EDA MCP** card has a **测试连接** button. It checks the local bridge health endpoint. The MCP tools appear as `mcp__jlceda__eda_status`, `mcp__jlceda__eda_place_component`, `mcp__jlceda__eda_draw_wire`, etc.
113
+
114
+ ### 3c. After upgrading the Desktop app, installing this plugin can crash startup (stale profile lock)
115
+
116
+ Symptom: right after installing the plugin and restarting the Desktop app, startup dies with
117
+ `DesktopHostFatalError: dsh: startup failed: 1 required plugin did not activate`, listing a dozen plugins stuck waiting on `systemPrompt` / `tools`.
118
+
119
+ The plugin's own logic is not the cause: `%USERPROFILE%\.dsh\profiles\desktop` still holds a `pnpm-lock.yaml` from an **older DSH generation** (for example pinning every `@deepseek-ai/dsh-*` to `0.2.1-rc.3`) while the Desktop app is already `0.2.1-rc.5`. Because the older builds still satisfied the declared ranges, pnpm legitimately reused them and wrote a set of old-generation official plugins back into the profile; those cannot provide the `systemPrompt` / `tools` services the newer host expects, so `agent-loop` (required) fails to activate and startup aborts.
120
+
121
+ Fix (either one, then restart the Desktop app):
122
+
123
+ ```powershell
124
+ Remove-Item -Recurse -Force "$env:USERPROFILE\.dsh\profiles\desktop\node_modules"
125
+ Remove-Item -Force "$env:USERPROFILE\.dsh\profiles\desktop\pnpm-lock.yaml"
126
+ ```
127
+
128
+ - The "disable third-party plugins and restart" button does **not** help here: the broken pieces are official dependencies written into the profile, not the plugin itself.
129
+ - From 1.1.7 on, the declared official ranges are tightened to `^0.2.1-rc.5 || ^0.2.2-rc.1`, so an old lock (rc.2 / rc.3) no longer satisfies them and pnpm must re-resolve; `dsh-system-prompt` and `dsh-host-webserver` also left `dependencies` (they are type-only, never imported at runtime), which further reduces the chance of pulling official packages into the profile.
130
+
131
+ ## Design rules
132
+
133
+ The normative schematic + PCB rule set (zoning, placement, net naming, track widths, vias, copper pour,
134
+ DRC, silkscreen, fabrication output, pre-order checklist) lives in **[docs/design-rules.md](docs/design-rules.md)**.
135
+
136
+ The measurable half is enforced by the tools, not just documented:
137
+
138
+ | Rule | Enforcement |
139
+ |---|---|
140
+ | Net names | Letters, digits, `_`, `.`, `+`, `-`, max 255 chars. Space, `/`, brackets or CJK are **rejected** by every net-taking tool (`USB_DP/DM` would be split into two nets by the backend). |
141
+ | Track width | `pcb_draw_track` defaults by net role (signal 6 mil / power 16 mil) and **rejects anything below 6 mil (0.15 mm)** unless `force: true`. |
142
+ | Via size | `pcb_draw_via` defaults to a standard drill pair (0.2/0.4 mm signal, 0.3/0.6 mm power); ring = pad − hole must be ≥ 0.20 mm, a hole below 0.2 mm is rejected, below 0.3 mm is warned. |
143
+ | Pour / DRC | `eda_pcb_create_pour` returns the 6/10 mil clearance rule; `eda_design_audit` runs the DRC and the checklist. |
144
+
145
+ **`eda_design_audit`** is the one-call health check: per-net minimum width vs. role, via geometry, net names,
146
+ board outline, copper pour and PCB DRC, returned as `violations` / `warnings` / `checklist`. Run it before and
147
+ after routing.
148
+
149
+ ## MCP tools (schematic-first MVP)
150
+
151
+ | Tool | Purpose |
152
+ |---|---|
153
+ | `eda_status` | Bridge status and connected JLCEDA clients |
154
+ | `eda_launch` | Start JLCEDA Pro (optionally opening a `.eprj2` project) and wait until the extension connects |
155
+ | `eda_list_projects` / `eda_get_project` | List workspace projects (uuid + name) / read the current project |
156
+ | `eda_open_project` | Open a project by uuid, or by friendly name |
157
+ | `eda_create_project` | Create a project and return its uuid (optionally open it) |
158
+ | `eda_search_components` | Search JLCEDA library devices |
159
+ | `eda_place_component` | Place a component/symbol |
160
+ | `eda_place_net_flag` | Place VCC/GND/Power net flag |
161
+ | `eda_place_net_port` | Place IN/OUT/BI net port |
162
+ | `eda_draw_wire` | Draw a wire/polyline |
163
+ | `eda_draw_rectangle` | Draw a rectangle |
164
+ | `eda_draw_circle` | Draw a circle |
165
+ | `eda_draw_text` | Draw text |
166
+ | `eda_save_document` | Save the active schematic |
167
+ | `eda_zoom_to_fit` / `eda_zoom_to_region` | Zoom canvas |
168
+ | `eda_get_components` / `eda_get_wires` | Inspect primitives |
169
+ | `eda_delete_primitive` | Delete one primitive |
170
+ | `eda_api_call` | Allow-listed generic API call (can be disabled in settings) |
171
+ | `pcb_*` / `eda_pcb_*` (65 tools total) | PCB query, place/move/delete components, tracks, vias, regions, board outline, auto-place/auto-route, Gerber export |
172
+
173
+ Schematic/symbol coordinates are in **0.01 inch** units; PCB coordinates are in **mil**. Rotation values are `0/90/180/270`. Wire points are a flat array `[x1, y1, x2, y2, ...]`.
174
+
175
+ **What takes effect when** (read this before retrying anything): plugin source in `src/` needs `node build.mjs` plus a **DSH restart** — the running host keeps the old bundle in memory; the EDA extension in `jlc-extension/` needs the zip **re-imported** and JLCEDA Pro restarted (`eda_status.extensionVersions` must match `bridgeVersion`); only the bridge child can be restarted by the agent (`POST /api/dsh-eda-mcp/reconnect`). The generated `docs/schematic-workflow.md` chapter 12 has the full table, and the skill `jlceda-schematic-workflow` carries the same text.
176
+
177
+ Every PCB tool has an equivalent `eda_pcb_*` alias (`eda_pcb_get_components` = `pcb_get_components`). See `README.zh.md` for the full PCB table and the region-layer rules (`pcb_PrimitiveRegion.create` accepts copper layers and MULTI only, so the board outline stays a closed line loop on layer 11).
178
+
179
+ ## Tool reference
180
+
181
+ `docs/tools.md` is generated from the built bridge's MCP `tools/list` (81 tools) and is the authoritative list of names, parameters and required fields.
182
+
183
+ ## Workflows
184
+
185
+ ### A. Schematic (make connections real)
186
+
187
+ 1. `eda_get_page_info` for the A4 frame, title-block keep-out and safe areas; then `eda_search_components` + `eda_place_component` (out-of-frame placement is rejected and rolled back).
188
+ 2. Connect with `eda_draw_wire` **net** parameter (same-name nets merge) - the most reliable electrical connection. `eda_place_net_flag_at_pin` places power/ground flags. `eda_place_net_label_at_pin` prefers a REAL net label and reports `method: "netLabel"`; when it reports `method: "text"` the EDA build has no `createNetLabel` and the text label does **not** create an electrical connection - fall back to the wire net parameter.
189
+ 3. `eda_set_no_connect` for unused pins, `eda_draw_functional_box` to group, then `eda_run_drc` + `eda_save_document`.
190
+
191
+ ### B. Schematic -> PCB sync (EDA shows its own confirmation dialog)
192
+
193
+ 1. `eda_create_board` links schematic and PCB (first time only).
194
+ 2. `pcb_import_changes` is **asynchronous by default**: `pcb_Document.importChanges` opens EDA's confirmation dialog and blocks until it is answered, so the tool returns immediately with `componentsBefore` and keeps the import running in the background.
195
+ 3. Ask the user to click OK, then call `eda_pcb_wait_for_components`: it polls every 5 s by default (**minimum 3 s**, deliberately low) for up to 45 s (`pollIntervalMs` / `maxWaitMs`). Confirmation is detected as "new PCB components appeared that did not exist before".
196
+ 4. On `confirmed: true` run `pcb_save_document`; on `confirmed: false` ask the user and call again.
197
+
198
+ ### C. PCB layout and routing (long jobs are always polled)
199
+
200
+ 1. Outline: `pcb_draw_board_outline` (one closed `pcb_PrimitivePolyline` on layer 11).
201
+ 2. Placement: `eda_pcb_get_components` (`includePins: true` for accurate pad nets) + `eda_pcb_move_component`; `eda_pcb_auto_place` (blocking by default, `wait: false` for a background job).
202
+ 3. Routing: `eda_pcb_auto_route` **starts asynchronously** (EDA shows its own progress bar); poll `eda_pcb_job_status` until `running=false`. Never await it and never raise timeouts - a whole board or a 35+ pin net such as GND always exceeds any sane timeout while EDA keeps working. Use `eda_pcb_clear_routing` to start over.
203
+ 4. Check: `eda_pcb_run_drc` (`strict` includes warnings, `includeVerboseError` returns details) + `eda_pcb_get_drc_rules`.
204
+ 5. Finish: `eda_pcb_set_net_track_width` for power/GND, `eda_pcb_create_pour` for copper pours (`45grid`/`90grid`/`solid`, copper layers only), `eda_pcb_export_gerber` (base64 data URL, can be several MB).
205
+
206
+ ### D. Active-document rule
207
+
208
+ `sch_Net.*`, netlist export and the schematic get/getAll APIs only act on the **active tab**: with a PCB in front they return `[]` / `null`. `eda_get_nets` therefore degrades through `getCurrentProjectAllNets -> getAllNets -> parsing sch_Netlist.getNetlist` and reports `source`; when it is empty use `eda_get_active_document` and `eda_open_document` to bring the schematic page forward.
209
+ ## Configuration
210
+
211
+ The Web GUI settings card exposes:
212
+
213
+ - `enabled` — mount/unmount the MCP bridge.
214
+ - `announceToAgent` — inject plugin guidance into the system prompt.
215
+ - `toolCallTimeoutMs` — per-call EDA timeout.
216
+ - `allowRawApi` — expose the generic `eda_api_call` tool.
217
+
218
+ The WebSocket port is fixed at `39009` in the first version. Do not run another service on that port.
219
+
220
+ ## Development
221
+
222
+ Requirements: Node `^22.19.0 || >=24`, pnpm (pinned by `packageManager`), and Windows for the extension zip (PowerShell `Compress-Archive`).
223
+
224
+ ```sh
225
+ pnpm install
226
+ pnpm typecheck # tsc --noEmit
227
+ pnpm test # unit tests
228
+ pnpm build # bundles + extension zip
229
+ pnpm check # all three
230
+ ```
231
+
232
+ Build outputs:
233
+
234
+ - `lib/index.js` — DSH host plugin.
235
+ - `lib/client.js` — DSH Web GUI settings card.
236
+ - `lib/bridge.mjs` — standalone MCP/WebSocket bridge child.
237
+ - `dsh-eda-bridge-extension-<version>.zip` — JLCEDA Pro extension (the version is the wire contract).
238
+
239
+ `lib/` and the zip are build outputs and are git-ignored; the host loads the packaged `lib/index.js`, so a change under `src/` needs `pnpm build` plus a Host restart (a plugin reload does not re-import a cached ESM module).
240
+
241
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the repository layout, the release/tag flow, and the bridge/extension version rule. Publishing to npm — the first release is manual, then `v*` tags publish through trusted publishing (OIDC, no token) — is documented in [docs/release.md](docs/release.md).
242
+
243
+ ## Security
244
+
245
+ - The bridge listens on loopback only (`127.0.0.1`).
246
+ - The JLCEDA extension and the bridge both enforce the same API allow-list.
247
+ - Generic `eda_api_call` is allow-list-only and can be disabled.
248
+ - No raw JavaScript evaluation is exposed.
249
+
250
+ ## Known limitations
251
+
252
+ - The board outline is one `pcb_PrimitivePolyline` on layer 11 (polygon source + line width). It cannot be created with `pcb_PrimitiveLine` (a copper-track primitive; the core rejects layer 11) nor with `pcb_PrimitiveRegion` (`TPCB_LayersOfRegion` allows copper layers and MULTI(12) only). Verified against real `.eprj2` project files, where an outline is stored as `["POLY", id, 0, "", 11, 10, [...], 1]`.
253
+ - `pcb_Document.autoRouting` returns `success=false, duration=0` for every net when no net list is passed (empty `routingRange` in this EDA build), so `eda_pcb_auto_route` enumerates all net names first.
254
+ - Auto-routing is asynchronous by default: `eda_pcb_auto_route` returns as soon as EDA starts routing (EDA shows its own progress bar) and `eda_pcb_job_status` is polled until `running=false`. Awaiting a whole-board or many-pin net (e.g. GND) always exceeds any sane timeout while EDA keeps working.
255
+ - Schematic APIs (`sch_Net.*`, netlist export) only act on the ACTIVE document; when they return empty/null, use `eda_get_active_document` and `eda_open_document` to bring the schematic page to the front.
256
+ - `eda_pcb_export_gerber` returns the Gerber zip as a base64 data URL, which can be several MB for a large board.
257
+ - The JLCEDA extension socket is registered through `sys_WebSocket`, which has neither a close callback nor auto-reconnect; versions before 0.3.3 therefore had to be reconnected by hand after the DSH bridge child restarted. 0.3.3 adds a 10 s heartbeat that re-registers the socket when `pong` stops arriving.
258
+ - Screenshot/canvas image return is not yet wired into MCP image blocks.
259
+ - Changing the bridge WebSocket port requires editing both the bridge env and `jlc-extension/api-bridge.js`, then rebuilding/reimporting the extension zip.
260
+ - `dmt_Project.createProject` / `deleteProject` do nothing on this EDA build (3.2.186, signed in but semi-offline): the former returns no uuid for a directory team, a canonical team uuid, or either with/without a folderUuid, and the latter always returns `false` (verified with the project open and after switching away). **Create projects with `eda_import_project` instead** (importing a project file does create one — verified), and delete them in the app.
261
+ - In semi-offline mode EDA models **each local project directory as a "team"**: the `uuid` reported by `eda_list_teams` is the directory path, while a project record's `teamUuid` is a real uuid. `eda_list_projects` without a filter walks every team, so the first call is slower than one with `teamUuid`.
262
+ - Spawning `lceda-pro.exe` directly (even through ShellExecute) makes it exit with code 0 immediately; only handing the launch to the desktop shell (`explorer.exe`) starts it, so on Windows `eda_launch` always goes through explorer plus a temporary `.cmd`.
263
+ - A project path on the command line is **ignored by the app** (the active document stays HOME), so `eda_launch({ project })` only forwards the argument; the result carries `projectOpenedByArgument: false` and a `projectNote`. Use `eda_open_project` to actually open one.
264
+ - Schematic parts move with `eda_move_component` (`sch_PrimitiveComponent.modify`); net ports, net flags, net labels and text labels are deleted with `eda_delete_primitive` kinds `netport` / `netflag` / `netlabel` / `text`.
265
+ - The `net` argument of `eda_draw_wire` only sticks on a **floating** wire: once an endpoint touches a pin, EDA recomputes the net from connectivity (measured: `TESTNET` merged into `LED_A`). Joining same-named nets across regions requires `eda_place_net_port` or a net label.
266
+ - `sch_PrimitiveAttribute.createNetLabel` never resolves on EDA 3.2.186: the probe result is cached per session and placement degrades to a plain text label (no electrical meaning; the stub wire carries the net). Batch with `eda_place_net_labels`, enumerate with `eda_get_net_labels`, clean up with `eda_delete_primitive(kind:"text")`.
267
+ - Net port primitives do not appear in `eda_get_components` / BOM / netlist (application behaviour); audit them through `eda_get_net_labels`.
268
+ - Importing a `.epro2` copies its internal uuids (schematic/page/pcb), which can collide with the source project: `eda_import_project` reports them in `collisions`, but cannot regenerate them.
269
+ - `dmt_Project.copyProject` is as inert as `createProject` / `deleteProject` for local projects; copy with `eda_export_project` + `eda_import_project` instead.
270
+ - Automatic layout/routing is off by default (`allowAutoLayoutRouting`); `eda_auto_layout` / `eda_auto_route` only run with `force:true`.
271
+ - The extension and bridge wire versions must move **together** (currently 0.4.1, patch-only bumps): a changed allow-list requires re-importing the zip, otherwise new tools answer `API method not allowed`. `eda_status` reports every connected page's version in `extensionVersions`.
272
+
273
+ ## Repository
274
+
275
+ | Path | What it is |
276
+ |---|---|
277
+ | `src/index.ts`, `src/routes.ts`, `src/node-runtime.ts`, `src/config-values.ts`, `src/bridge-diagnostics.ts`, `src/guidance.ts` | DSH host half |
278
+ | `src/bridge/index.ts` | Standalone MCP/WebSocket bridge child |
279
+ | `src/bridge/design-rules.ts` | Enforceable design limits: net naming, width tiers, via geometry |
280
+ | `src/client/` | Web settings card |
281
+ | `jlc-extension/` | JLCEDA Pro extension packaged into the zip |
282
+ | `test/` | Unit tests |
283
+ | `docs/design-rules.md` | Normative schematic + PCB rule set |
284
+ | `docs/tools.md` | Generated tool reference (every MCP tool, its parameters, and required fields) |
285
+ | `docs/release.md` | Maintainer publishing runbook (npm, trusted publishing) |
286
+ | `scripts/gen-tools-doc.mjs` | Regenerates `docs/tools.md` from the built bridge |
287
+ | `build.mjs` | esbuild bundles (reproducible) + extension zip |
288
+
289
+ ## License
290
+
291
+ Apache-2.0 © dsh-eda-mcp contributors. See [LICENSE](LICENSE).