easyeda-mcp-pro 0.18.0 → 0.20.0
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/README.md +66 -29
- package/dist/bridge/types.d.ts +1 -0
- package/dist/bridge/types.js +1 -0
- package/dist/bridge/types.js.map +1 -1
- package/dist/circuit/circuit-ir.d.ts +2 -2
- package/dist/circuit/compiler.d.ts +7 -4
- package/dist/circuit/compiler.js +95 -29
- package/dist/circuit/compiler.js.map +1 -1
- package/dist/circuit/component-planning.d.ts +63 -0
- package/dist/circuit/component-planning.js +140 -0
- package/dist/circuit/component-planning.js.map +1 -0
- package/dist/circuit/index.d.ts +2 -0
- package/dist/circuit/index.js +2 -0
- package/dist/circuit/index.js.map +1 -1
- package/dist/config/profiles.js +5 -5
- package/dist/config/version.d.ts +1 -1
- package/dist/config/version.js +1 -1
- package/dist/remote/gateway.d.ts +74 -0
- package/dist/remote/gateway.js +484 -0
- package/dist/remote/gateway.js.map +1 -0
- package/dist/remote/index.d.ts +1 -0
- package/dist/remote/index.js +1 -0
- package/dist/remote/index.js.map +1 -1
- package/dist/remote/protocol.d.ts +1 -0
- package/dist/remote/session-router.d.ts +2 -0
- package/dist/remote/session-router.js +18 -9
- package/dist/remote/session-router.js.map +1 -1
- package/dist/server/transports/http.d.ts +7 -1
- package/dist/server/transports/http.js +68 -12
- package/dist/server/transports/http.js.map +1 -1
- package/dist/server/transports/oauth-resource-metadata.d.ts +12 -0
- package/dist/server/transports/oauth-resource-metadata.js +52 -0
- package/dist/server/transports/oauth-resource-metadata.js.map +1 -0
- package/dist/tools/L1_schematic_read.js +257 -2
- package/dist/tools/L1_schematic_read.js.map +1 -1
- package/dist/tools/L1_schematic_write.js +134 -0
- package/dist/tools/L1_schematic_write.js.map +1 -1
- package/easyeda-bridge-extension.eext +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,9 +7,6 @@
|
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
9
|
<p>
|
|
10
|
-
<a href="https://github.com/oaslananka/easyeda-mcp-pro/actions/workflows/ci.yml">
|
|
11
|
-
<img src="https://github.com/oaslananka/easyeda-mcp-pro/actions/workflows/ci.yml/badge.svg" alt="CI status" />
|
|
12
|
-
</a>
|
|
13
10
|
<a href="https://www.npmjs.com/package/easyeda-mcp-pro">
|
|
14
11
|
<img src="https://img.shields.io/npm/v/easyeda-mcp-pro.svg?logo=npm" alt="npm version" />
|
|
15
12
|
</a>
|
|
@@ -19,35 +16,70 @@
|
|
|
19
16
|
<a href="https://www.npmjs.com/package/easyeda-mcp-pro">
|
|
20
17
|
<img src="https://img.shields.io/node/v/easyeda-mcp-pro" alt="supported Node.js version" />
|
|
21
18
|
</a>
|
|
22
|
-
<a href="
|
|
23
|
-
<img src="https://img.shields.io/
|
|
19
|
+
<a href="LICENSE">
|
|
20
|
+
<img src="https://img.shields.io/npm/l/easyeda-mcp-pro.svg" alt="license" />
|
|
24
21
|
</a>
|
|
25
|
-
<a href="https://
|
|
26
|
-
<img src="https://
|
|
22
|
+
<a href="https://pnpm.io/">
|
|
23
|
+
<img src="https://img.shields.io/badge/pnpm-11.5.1-blue.svg" alt="pnpm" />
|
|
24
|
+
</a>
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
<p>
|
|
28
|
+
<a href="https://github.com/oaslananka/easyeda-mcp-pro/actions/workflows/ci.yml">
|
|
29
|
+
<img src="https://github.com/oaslananka/easyeda-mcp-pro/actions/workflows/ci.yml/badge.svg" alt="CI status" />
|
|
30
|
+
</a>
|
|
31
|
+
<a href="https://github.com/oaslananka/easyeda-mcp-pro/actions/workflows/deploy-docs.yml">
|
|
32
|
+
<img src="https://github.com/oaslananka/easyeda-mcp-pro/actions/workflows/deploy-docs.yml/badge.svg" alt="Docs status" />
|
|
27
33
|
</a>
|
|
28
34
|
<a href="https://github.com/oaslananka/easyeda-mcp-pro/security/policy">
|
|
29
35
|
<img src="https://img.shields.io/badge/security-policy-blue" alt="Security policy" />
|
|
30
36
|
</a>
|
|
31
|
-
<a href="https://
|
|
32
|
-
<img src="https://
|
|
37
|
+
<a href="https://scorecard.dev/viewer/?uri=github.com/oaslananka/easyeda-mcp-pro">
|
|
38
|
+
<img src="https://api.scorecard.dev/projects/github.com/oaslananka/easyeda-mcp-pro/badge" alt="OpenSSF Scorecard" />
|
|
39
|
+
</a>
|
|
40
|
+
<a href="https://www.bestpractices.dev/projects/13406">
|
|
41
|
+
<img src="https://www.bestpractices.dev/projects/13406/badge" alt="OpenSSF Best Practices" />
|
|
33
42
|
</a>
|
|
34
43
|
</p>
|
|
35
44
|
|
|
45
|
+
<p>
|
|
46
|
+
<a href="https://deepwiki.com/oaslananka/easyeda-mcp-pro">Ask DeepWiki</a> ·
|
|
47
|
+
<a href="docs/ROADMAP.md">Roadmap</a> ·
|
|
48
|
+
<a href="docs/OPENSSF_BEST_PRACTICES.md">OpenSSF evidence</a> ·
|
|
49
|
+
<a href="docs/SECURITY_ASSURANCE_CASE.md">Security assurance case</a>
|
|
50
|
+
</p>
|
|
51
|
+
|
|
36
52
|
<p>
|
|
37
53
|
<strong>Compliance docs:</strong>
|
|
38
54
|
<a href="THIRD_PARTY_NOTICES.md">Third-Party Notices</a>
|
|
39
55
|
·
|
|
40
56
|
<a href="docs/vendor-terms.md">Vendor Terms and Unsupported Workflows</a>
|
|
41
57
|
·
|
|
42
|
-
<a href="docs/OPENSSF_BEST_PRACTICES.md">OpenSSF Best Practices</a>
|
|
43
|
-
·
|
|
44
58
|
<a href="docs/REMOTE_MCP_MODES.md">Remote MCP Modes</a>
|
|
45
59
|
</p>
|
|
46
60
|
|
|
61
|
+
<p>
|
|
62
|
+
<a href="https://www.buymeacoffee.com/oaslananka">
|
|
63
|
+
<img src="https://img.buymeacoffee.com/button-api/?text=Buy%20me%20a%20coffee&emoji=%E2%98%95&slug=oaslananka&button_colour=FFDD00&font_colour=000000&font_family=Inter&outline_colour=000000&coffee_colour=ffffff" height="28" alt="Buy me a coffee" />
|
|
64
|
+
</a>
|
|
65
|
+
|
|
66
|
+
<a href="https://github.com/oaslananka/easyeda-mcp-pro">
|
|
67
|
+
<img src="https://img.shields.io/github/stars/oaslananka/easyeda-mcp-pro?style=for-the-badge&logo=github&label=Star%20on%20GitHub&color=FFA500&labelColor=181717" alt="Star on GitHub" />
|
|
68
|
+
</a>
|
|
69
|
+
</p>
|
|
70
|
+
|
|
47
71
|
</div>
|
|
48
72
|
|
|
49
73
|
---
|
|
50
74
|
|
|
75
|
+
## Trust and Supply Chain
|
|
76
|
+
|
|
77
|
+
easyeda-mcp-pro keeps its public OpenSSF Best Practices evidence in [`docs/OPENSSF_BEST_PRACTICES.md`](docs/OPENSSF_BEST_PRACTICES.md) and its security assurance case in [`docs/SECURITY_ASSURANCE_CASE.md`](docs/SECURITY_ASSURANCE_CASE.md). The header badges link to workflow-backed signals only: CI, generated docs deployment, the project security policy, OpenSSF Best Practices self-certification, and the OpenSSF Scorecard. Release integrity evidence (npm provenance, signed-release status) is tracked in [`docs/RELEASE_VERIFICATION.md`](docs/RELEASE_VERIFICATION.md).
|
|
78
|
+
|
|
79
|
+
**Current OpenSSF Best Practices status:** Passing (100%) — see [live badge](https://www.bestpractices.dev/projects/13406) and [Silver evidence map](docs/OPENSSF_BEST_PRACTICES.md#silver-evidence) for in-progress Silver criteria.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
51
83
|
## Quick Start
|
|
52
84
|
|
|
53
85
|
The fastest way to install and configure `easyeda-mcp-pro` for your favorite AI assistant or IDE:
|
|
@@ -643,6 +675,10 @@ The schematic write APIs use EasyEDA Pro extension APIs that EasyEDA currently m
|
|
|
643
675
|
- **stdio** (default): Standard MCP transport — works with Claude Desktop, Cursor, and most MCP clients
|
|
644
676
|
- **HTTP**: Streamable HTTP transport with `/healthz`, `/readyz`, `/mcp` endpoints, CORS, and optional OAuth — suitable for remote deployments
|
|
645
677
|
|
|
678
|
+
### Deployment modes
|
|
679
|
+
|
|
680
|
+
Beyond local stdio/HTTP, the server supports a hosted remote runtime (gateway, session router, and approval-scoped relay under `src/remote/`) for managed connector deployments such as Claude Web or ChatGPT app integrations, plus a self-hosted remote mode for user-managed endpoints. See [Remote MCP Modes](docs/REMOTE_MCP_MODES.md) for the full mode matrix and network/security boundaries of each.
|
|
681
|
+
|
|
646
682
|
### Bridge extension
|
|
647
683
|
|
|
648
684
|
```bash
|
|
@@ -682,7 +718,7 @@ pnpm typecheck # TypeScript
|
|
|
682
718
|
pnpm lint # ESLint
|
|
683
719
|
|
|
684
720
|
# Test
|
|
685
|
-
pnpm test # Vitest (
|
|
721
|
+
pnpm test # Vitest (804 tests across 66 files)
|
|
686
722
|
pnpm test:coverage # With coverage report
|
|
687
723
|
|
|
688
724
|
# Golden E2E fixture smoke tests are included in `pnpm test`
|
|
@@ -722,20 +758,27 @@ src/
|
|
|
722
758
|
├── index.ts # Entry point (stdio or HTTP)
|
|
723
759
|
├── bridge/ # EasyEDA Pro WebSocket bridge protocol
|
|
724
760
|
│ ├── manager.ts, protocol.ts, types.ts
|
|
725
|
-
├──
|
|
726
|
-
|
|
761
|
+
├── cli/ # Client auto-setup (setup/extension CLI commands)
|
|
762
|
+
├── config/ # Environment, tool profiles, feature flags
|
|
763
|
+
│ ├── env.ts, profiles.ts, feature-flags.ts, version.ts
|
|
764
|
+
├── remote/ # Hosted/self-hosted remote MCP gateway, session router, scopes
|
|
727
765
|
├── schemas/ # Shared Zod schemas
|
|
728
766
|
├── server/ # MCP server core
|
|
729
|
-
│ ├── factory.ts,
|
|
767
|
+
│ ├── factory.ts, resources-prompts.ts
|
|
730
768
|
│ └── transports/
|
|
731
|
-
│
|
|
769
|
+
│ ├── http.ts # HTTP/Streamable HTTP transport
|
|
770
|
+
│ └── oauth-resource-metadata.ts
|
|
732
771
|
├── storage/ # Node.js sqlite storage (cache, artifacts)
|
|
733
|
-
├── tools/ #
|
|
734
|
-
│ ├── register.ts, registry.ts, types.ts
|
|
735
|
-
│ ├──
|
|
736
|
-
│ ├──
|
|
737
|
-
|
|
738
|
-
|
|
772
|
+
├── tools/ # Up to 60 profile-gated MCP tool definitions
|
|
773
|
+
│ ├── register.ts, registry.ts, types.ts, transaction.ts
|
|
774
|
+
│ ├── L0_diagnostics_core.ts, L0_diagnostics_api.ts
|
|
775
|
+
│ ├── L1_schematic_read.ts, L1_schematic_write.ts
|
|
776
|
+
│ ├── L1_bom_core.ts, L1_bom_sourcing.ts
|
|
777
|
+
│ └── L1_drc_erc.ts, L1_board.ts, L1_export.ts, L1_pcb_constraints.ts, L1_pcb_write.ts
|
|
778
|
+
├── vendors/ # Supplier API clients (lcsc/, jlcpcb/, mouser/, digikey/)
|
|
779
|
+
└── ... # circuit, pcb-layout, net-validation, power-tree, production-qa,
|
|
780
|
+
# quote-gating, safety, observability, catalog, bom-quality,
|
|
781
|
+
# export-manifest, live, easyeda-runtime
|
|
739
782
|
|
|
740
783
|
easyeda-bridge-extension/ # EasyEDA Pro bridge extension workspace package
|
|
741
784
|
```
|
|
@@ -771,13 +814,7 @@ This repository uses automated workflows to manage dependencies and releases:
|
|
|
771
814
|
|
|
772
815
|
## Support the project
|
|
773
816
|
|
|
774
|
-
If this project helps you save time while working with EasyEDA Pro, BOM workflows, or MCP integrations, you can support ongoing development
|
|
775
|
-
|
|
776
|
-
<p align="left">
|
|
777
|
-
<a href="https://www.buymeacoffee.com/oaslananka">
|
|
778
|
-
<img src="https://img.buymeacoffee.com/button-api/?text=Buy%20me%20a%20coffee&emoji=%E2%98%95&slug=oaslananka&button_colour=FFDD00&font_colour=000000&font_family=Inter&outline_colour=000000&coffee_colour=ffffff" alt="Buy me a coffee" />
|
|
779
|
-
</a>
|
|
780
|
-
</p>
|
|
817
|
+
If this project helps you save time while working with EasyEDA Pro, BOM workflows, or MCP integrations, you can support ongoing development via the **Buy me a coffee** button at the top of this README.
|
|
781
818
|
|
|
782
819
|
---
|
|
783
820
|
|
package/dist/bridge/types.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare const EasyedaApiMethodSchema: z.ZodEnum<{
|
|
|
24
24
|
"pcb.addZone": "pcb.addZone";
|
|
25
25
|
"pcb.deleteComponent": "pcb.deleteComponent";
|
|
26
26
|
"schematic.searchDevice": "schematic.searchDevice";
|
|
27
|
+
"schematic.getSheetInfo": "schematic.getSheetInfo";
|
|
27
28
|
"schematic.listComponents": "schematic.listComponents";
|
|
28
29
|
"schematic.getNetDetail": "schematic.getNetDetail";
|
|
29
30
|
"schematic.validateNetlist": "schematic.validateNetlist";
|
package/dist/bridge/types.js
CHANGED
package/dist/bridge/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/bridge/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,IAAI,CAAC;IAC3C,cAAc;IACd,cAAc;IACd,gBAAgB;IAChB,oBAAoB;IACpB,wBAAwB;IACxB,0BAA0B;IAC1B,wBAAwB;IACxB,0BAA0B;IAC1B,mBAAmB;IACnB,2BAA2B;IAC3B,2BAA2B;IAC3B,yBAAyB;IACzB,yBAAyB;IACzB,2BAA2B;IAC3B,4BAA4B;IAC5B,2BAA2B;IAC3B,qBAAqB;IACrB,0BAA0B;IAC1B,UAAU;IACV,kBAAkB;IAClB,kBAAkB;IAClB,qBAAqB;IACrB,mBAAmB;IACnB,qBAAqB;IACrB,cAAc;IACd,cAAc;IACd,kBAAkB;IAClB,oBAAoB;IACpB,kBAAkB;IAClB,YAAY;IACZ,YAAY;IACZ,kBAAkB;IAClB,kBAAkB;IAClB,YAAY;IACZ,gBAAgB;IAChB,oBAAoB;IACpB,cAAc;IACd,YAAY;IACZ,aAAa;IACb,qBAAqB;IACrB,qBAAqB;IACrB,aAAa;CACd,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/bridge/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,IAAI,CAAC;IAC3C,cAAc;IACd,cAAc;IACd,gBAAgB;IAChB,oBAAoB;IACpB,wBAAwB;IACxB,0BAA0B;IAC1B,wBAAwB;IACxB,wBAAwB;IACxB,0BAA0B;IAC1B,mBAAmB;IACnB,2BAA2B;IAC3B,2BAA2B;IAC3B,yBAAyB;IACzB,yBAAyB;IACzB,2BAA2B;IAC3B,4BAA4B;IAC5B,2BAA2B;IAC3B,qBAAqB;IACrB,0BAA0B;IAC1B,UAAU;IACV,kBAAkB;IAClB,kBAAkB;IAClB,qBAAqB;IACrB,mBAAmB;IACnB,qBAAqB;IACrB,cAAc;IACd,cAAc;IACd,kBAAkB;IAClB,oBAAoB;IACpB,kBAAkB;IAClB,YAAY;IACZ,YAAY;IACZ,kBAAkB;IAClB,kBAAkB;IAClB,YAAY;IACZ,gBAAgB;IAChB,oBAAoB;IACpB,cAAc;IACd,YAAY;IACZ,aAAa;IACb,qBAAqB;IACrB,qBAAqB;IACrB,aAAa;CACd,CAAC,CAAC"}
|
|
@@ -173,9 +173,9 @@ export declare const PhysicalConstraintSchema: z.ZodObject<{
|
|
|
173
173
|
thermal: "thermal";
|
|
174
174
|
keepout: "keepout";
|
|
175
175
|
clearance: "clearance";
|
|
176
|
+
height: "height";
|
|
176
177
|
placement: "placement";
|
|
177
178
|
creepage: "creepage";
|
|
178
|
-
height: "height";
|
|
179
179
|
accessibility: "accessibility";
|
|
180
180
|
testability: "testability";
|
|
181
181
|
}>;
|
|
@@ -514,9 +514,9 @@ export declare const CircuitIRSchema: z.ZodObject<{
|
|
|
514
514
|
thermal: "thermal";
|
|
515
515
|
keepout: "keepout";
|
|
516
516
|
clearance: "clearance";
|
|
517
|
+
height: "height";
|
|
517
518
|
placement: "placement";
|
|
518
519
|
creepage: "creepage";
|
|
519
|
-
height: "height";
|
|
520
520
|
accessibility: "accessibility";
|
|
521
521
|
testability: "testability";
|
|
522
522
|
}>;
|
|
@@ -10,10 +10,13 @@
|
|
|
10
10
|
* 1. Validates the input DesignIntent.
|
|
11
11
|
* 2. Transforms functional block requirements into Blocks.
|
|
12
12
|
* 3. Creates power Rails from the DesignIntent's rail requirements.
|
|
13
|
-
* 4.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
13
|
+
* 4. Plans one candidate Device per Block: a deterministic refdes, a
|
|
14
|
+
* component role, and a package-family hint (see component-planning.ts).
|
|
15
|
+
* 5. Generates power Nets for each rail plus a synthesized common-ground Net.
|
|
16
|
+
* 6. Wires device/power-domain load relationships when unambiguous, and
|
|
17
|
+
* synthesizes candidate connector Interfaces.
|
|
18
|
+
* 7. Copies manufacturing, mechanical, and safety intent into CircuitIR fields.
|
|
19
|
+
* 8. Preserves all traceability IDs.
|
|
17
20
|
*
|
|
18
21
|
* @module
|
|
19
22
|
*/
|
package/dist/circuit/compiler.js
CHANGED
|
@@ -10,10 +10,13 @@
|
|
|
10
10
|
* 1. Validates the input DesignIntent.
|
|
11
11
|
* 2. Transforms functional block requirements into Blocks.
|
|
12
12
|
* 3. Creates power Rails from the DesignIntent's rail requirements.
|
|
13
|
-
* 4.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
13
|
+
* 4. Plans one candidate Device per Block: a deterministic refdes, a
|
|
14
|
+
* component role, and a package-family hint (see component-planning.ts).
|
|
15
|
+
* 5. Generates power Nets for each rail plus a synthesized common-ground Net.
|
|
16
|
+
* 6. Wires device/power-domain load relationships when unambiguous, and
|
|
17
|
+
* synthesizes candidate connector Interfaces.
|
|
18
|
+
* 7. Copies manufacturing, mechanical, and safety intent into CircuitIR fields.
|
|
19
|
+
* 8. Preserves all traceability IDs.
|
|
17
20
|
*
|
|
18
21
|
* @module
|
|
19
22
|
*/
|
|
@@ -21,6 +24,7 @@ import { DesignIntentSchema } from './design-intent.js';
|
|
|
21
24
|
import { CircuitIRSchema, CIRCUIT_IR_SCHEMA_VERSION, } from './circuit-ir.js';
|
|
22
25
|
import { ValidationStatus, NetType, ConstraintSeverity } from './types.js';
|
|
23
26
|
import { CircuitError, CircuitErrorCode, fromZodError } from './errors.js';
|
|
27
|
+
import { planComponents, getDeviceRole } from './component-planning.js';
|
|
24
28
|
// ── Defaults ──────────────────────────────────────────────────────────────
|
|
25
29
|
const DEFAULT_OPTIONS = {
|
|
26
30
|
skipValidation: false,
|
|
@@ -54,22 +58,6 @@ function compilePowerRails(designIntent, blocks) {
|
|
|
54
58
|
};
|
|
55
59
|
});
|
|
56
60
|
}
|
|
57
|
-
function compileDeviceStubs(blocks) {
|
|
58
|
-
// We create one stub Device per block as a placeholder. The user fills
|
|
59
|
-
// in actual MPNs during the planning step.
|
|
60
|
-
return blocks.map((block) => ({
|
|
61
|
-
id: `dev-${block.id}`,
|
|
62
|
-
ref: `U?`,
|
|
63
|
-
mpn: undefined,
|
|
64
|
-
manufacturer: undefined,
|
|
65
|
-
package: undefined,
|
|
66
|
-
datasheet: '',
|
|
67
|
-
lcsc: undefined,
|
|
68
|
-
blockRef: block.id,
|
|
69
|
-
designIntentRef: block.designIntentRef,
|
|
70
|
-
metadata: [],
|
|
71
|
-
}));
|
|
72
|
-
}
|
|
73
61
|
function compilePowerDomainId(rail) {
|
|
74
62
|
return `pd-${rail.id}`;
|
|
75
63
|
}
|
|
@@ -102,6 +90,77 @@ function compilePowerDomains(rails) {
|
|
|
102
90
|
metadata: [],
|
|
103
91
|
}));
|
|
104
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Synthesize a single common-ground net. Every board with at least one power
|
|
95
|
+
* rail needs a ground reference; this net is intentionally board-wide (not
|
|
96
|
+
* tied to a specific rail or power domain) since DesignIntent does not model
|
|
97
|
+
* multiple isolated ground planes.
|
|
98
|
+
*/
|
|
99
|
+
function compileGroundNet(rails) {
|
|
100
|
+
if (rails.length === 0)
|
|
101
|
+
return [];
|
|
102
|
+
return [
|
|
103
|
+
{
|
|
104
|
+
id: 'net-gnd',
|
|
105
|
+
name: 'GND',
|
|
106
|
+
type: NetType.Ground,
|
|
107
|
+
nodes: [],
|
|
108
|
+
designIntentRef: [],
|
|
109
|
+
metadata: [{ key: 'source', value: 'synthesized-common-ground' }],
|
|
110
|
+
},
|
|
111
|
+
];
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Synthesize a candidate Interface entry for each block whose planned
|
|
115
|
+
* component role is `connector`. Pinout is intentionally empty — DesignIntent
|
|
116
|
+
* does not specify pin-level connector detail — but the Interface node makes
|
|
117
|
+
* the connector's existence and traceability explicit before schematic entry.
|
|
118
|
+
*/
|
|
119
|
+
function compileInterfaceStubs(blocks, devices) {
|
|
120
|
+
const deviceByBlockRef = new Map(devices.map((d) => [d.blockRef, d]));
|
|
121
|
+
return blocks
|
|
122
|
+
.filter((block) => {
|
|
123
|
+
const device = deviceByBlockRef.get(block.id);
|
|
124
|
+
return device ? getDeviceRole(device) === 'connector' : false;
|
|
125
|
+
})
|
|
126
|
+
.map((block) => ({
|
|
127
|
+
id: `iface-${block.id}`,
|
|
128
|
+
name: block.name,
|
|
129
|
+
type: 'connector',
|
|
130
|
+
pinout: [],
|
|
131
|
+
blockRef: block.id,
|
|
132
|
+
designIntentRef: block.designIntentRef,
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Attach each device to the power domain it most plausibly draws from or
|
|
137
|
+
* supplies, and back-fill each power domain's `loadDeviceRefs`.
|
|
138
|
+
*
|
|
139
|
+
* This is intentionally conservative: DesignIntent does not specify which
|
|
140
|
+
* rail a given functional block operates on, so device-level power-domain
|
|
141
|
+
* assignment is only attempted when the design has exactly one rail overall
|
|
142
|
+
* (an unambiguous case). For multi-rail designs the compiler emits a warning
|
|
143
|
+
* instead of guessing a wrong rail assignment.
|
|
144
|
+
*/
|
|
145
|
+
function wirePowerDomainLoads(devices, rails, powerDomains) {
|
|
146
|
+
const warnings = [];
|
|
147
|
+
if (rails.length !== 1 || powerDomains.length !== 1) {
|
|
148
|
+
if (rails.length > 1) {
|
|
149
|
+
warnings.push(`Design declares ${rails.length} power rails; automatic device-to-rail power-domain ` +
|
|
150
|
+
`assignment was skipped because DesignIntent does not specify which rail each block ` +
|
|
151
|
+
`operates on. Assign each Device.powerDomainRef manually during CircuitIR review.`);
|
|
152
|
+
}
|
|
153
|
+
return { devices, powerDomains, warnings };
|
|
154
|
+
}
|
|
155
|
+
const domain = powerDomains[0];
|
|
156
|
+
if (!domain) {
|
|
157
|
+
return { devices, powerDomains, warnings };
|
|
158
|
+
}
|
|
159
|
+
const loadDeviceRefs = devices.map((device) => device.id);
|
|
160
|
+
const updatedDevices = devices.map((device) => ({ ...device, powerDomainRef: domain.id }));
|
|
161
|
+
const updatedDomains = powerDomains.map((pd) => pd.id === domain.id ? { ...pd, loadDeviceRefs } : pd);
|
|
162
|
+
return { devices: updatedDevices, powerDomains: updatedDomains, warnings };
|
|
163
|
+
}
|
|
105
164
|
function compileSignalClasses(designIntent, powerNets) {
|
|
106
165
|
const classes = [
|
|
107
166
|
{
|
|
@@ -175,7 +234,7 @@ function compilePhysicalConstraints(designIntent) {
|
|
|
175
234
|
}
|
|
176
235
|
return constraints;
|
|
177
236
|
}
|
|
178
|
-
function buildCircuitIR(designIntent, blocks, rails, devices, nets, powerDomains, signalClasses, physicalConstraints, opts) {
|
|
237
|
+
function buildCircuitIR(designIntent, blocks, rails, devices, nets, powerDomains, signalClasses, physicalConstraints, interfaces, opts) {
|
|
179
238
|
return {
|
|
180
239
|
$schema: CIRCUIT_IR_SCHEMA_VERSION,
|
|
181
240
|
metadata: {
|
|
@@ -191,7 +250,7 @@ function buildCircuitIR(designIntent, blocks, rails, devices, nets, powerDomains
|
|
|
191
250
|
powerDomains,
|
|
192
251
|
signalClasses,
|
|
193
252
|
physicalConstraints,
|
|
194
|
-
interfaces
|
|
253
|
+
interfaces,
|
|
195
254
|
constraints: [],
|
|
196
255
|
bom: { excludeRefs: [], preferredVendors: [] },
|
|
197
256
|
pcb: {
|
|
@@ -247,16 +306,23 @@ export function compile(input, options) {
|
|
|
247
306
|
const blocks = compileBlocks(designIntent);
|
|
248
307
|
// ── 3. Compile Power Rails ──────────────────────────────────────────────
|
|
249
308
|
const rails = compilePowerRails(designIntent, blocks);
|
|
250
|
-
// ── 4.
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
309
|
+
// ── 4. Plan candidate component roles, refdes, and package hints ───────
|
|
310
|
+
const componentPlan = planComponents(blocks);
|
|
311
|
+
warnings.push(...componentPlan.warnings);
|
|
312
|
+
// ── 5. Create power + ground nets ───────────────────────────────────────
|
|
313
|
+
const powerNets = compilePowerNets(rails);
|
|
314
|
+
const groundNet = compileGroundNet(rails);
|
|
315
|
+
const nets = [...powerNets, ...groundNet];
|
|
254
316
|
// ── 6. Compile professional planning context ───────────────────────────
|
|
255
|
-
const
|
|
256
|
-
|
|
317
|
+
const powerDomainWiring = wirePowerDomainLoads(componentPlan.devices, rails, compilePowerDomains(rails));
|
|
318
|
+
warnings.push(...powerDomainWiring.warnings);
|
|
319
|
+
const devices = powerDomainWiring.devices;
|
|
320
|
+
const powerDomains = powerDomainWiring.powerDomains;
|
|
321
|
+
const signalClasses = compileSignalClasses(designIntent, powerNets);
|
|
257
322
|
const physicalConstraints = compilePhysicalConstraints(designIntent);
|
|
323
|
+
const interfaces = compileInterfaceStubs(blocks, devices);
|
|
258
324
|
// ── 7. Build CircuitIR ──────────────────────────────────────────────────
|
|
259
|
-
const circuitIR = buildCircuitIR(designIntent, blocks, rails, devices, nets, powerDomains, signalClasses, physicalConstraints, opts);
|
|
325
|
+
const circuitIR = buildCircuitIR(designIntent, blocks, rails, devices, nets, powerDomains, signalClasses, physicalConstraints, interfaces, opts);
|
|
260
326
|
// ── 8. Validate output CircuitIR ────────────────────────────────────────
|
|
261
327
|
const parsed = CircuitIRSchema.safeParse(circuitIR);
|
|
262
328
|
if (!parsed.success) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../src/circuit/compiler.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../src/circuit/compiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAgB,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAEL,eAAe,EACf,yBAAyB,GAS1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAWxE,6EAA6E;AAE7E,MAAM,eAAe,GAAmB;IACtC,cAAc,EAAE,KAAK;IACrB,aAAa,EAAE,gBAAgB,CAAC,KAAK;CACtC,CAAC;AAaF,6EAA6E;AAE7E,SAAS,aAAa,CAAC,YAA0B;IAC/C,OAAO,YAAY,CAAC,YAAY,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC7D,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE;QACpB,IAAI,EAAE,EAAE,CAAC,IAAI;QACb,IAAI,EAAE,EAAE,CAAC,IAAI;QACb,WAAW,EAAE,EAAE,CAAC,OAAO;QACvB,eAAe,EAAE,CAAC,EAAE,aAAa,EAAE,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC;QAC7D,QAAQ,EAAE,EAAE;KACb,CAAC,CAAC,CAAC;AACN,CAAC;AAED,SAAS,iBAAiB,CAAC,YAA0B,EAAE,MAAe;IACpE,OAAO,YAAY,CAAC,YAAY,CAAC,KAAK,C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AM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;QAC5D,MAAM,IAAI,YAAY,CAAC;YACrB,IAAI,EAAE,gBAAgB,CAAC,cAAc;YACrC,OAAO,EAAE,wCAAwC;YACjD,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,IAAI;QACtB,YAAY;QACZ,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,6EAA6E;AAE7E;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,SAAoB,EACpB,MAA8D,EAC9D,OAAgB;IAEhB,OAAO;QACL,GAAG,SAAS;QACZ,QAAQ,EAAE;YACR,GAAG,SAAS,CAAC,QAAQ;YACrB,gBAAgB,EAAE,MAAM;SACzB;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAoB;IACpD,OAAO,SAAS,CAAC,QAAQ,CAAC,gBAAgB,KAAK,gBAAgB,CAAC,SAAS,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component role and refdes planning for CircuitIR device synthesis.
|
|
3
|
+
*
|
|
4
|
+
* Replaces generic `U?` device stubs with a deterministic, traceable
|
|
5
|
+
* component-role plan: a refdes family, a package/footprint hint, and a
|
|
6
|
+
* planning-state marker that differentiates a confidently-classified
|
|
7
|
+
* candidate device from a low-confidence placeholder.
|
|
8
|
+
*
|
|
9
|
+
* This module intentionally does not select real MPNs, manufacturers, or
|
|
10
|
+
* footprints — it narrows the search space (role + refdes + package family)
|
|
11
|
+
* so a human, BOM-sourcing tool, or downstream planning step can make the
|
|
12
|
+
* final manufacturable selection. See docs/circuit-ir.md for the full
|
|
13
|
+
* synthesis pipeline this module is part of.
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
import type { Block, Device } from './circuit-ir.js';
|
|
18
|
+
export type ComponentRole = 'power-regulator' | 'mcu-module' | 'sensor' | 'communication-ic' | 'analog-ic' | 'connector' | 'protection-diode' | 'fuse' | 'passive-support' | 'generic-ic';
|
|
19
|
+
/** Confidence that the role was inferred correctly from the DesignIntent block. */
|
|
20
|
+
export type RoleConfidence = 'high' | 'low';
|
|
21
|
+
export interface ComponentRolePlan {
|
|
22
|
+
role: ComponentRole;
|
|
23
|
+
confidence: RoleConfidence;
|
|
24
|
+
}
|
|
25
|
+
/** Deterministic refdes family per component role, matching common schematic convention. */
|
|
26
|
+
export declare const ROLE_REFDES_PREFIX: Record<ComponentRole, string>;
|
|
27
|
+
/** Conservative package/footprint family hint per role — not a final footprint selection. */
|
|
28
|
+
export declare const ROLE_PACKAGE_HINT: Record<ComponentRole, string>;
|
|
29
|
+
/** Metadata keys the compiler attaches to each planned Device. */
|
|
30
|
+
export declare const COMPONENT_PLAN_METADATA_KEYS: {
|
|
31
|
+
readonly role: "role";
|
|
32
|
+
readonly packageHint: "packageHint";
|
|
33
|
+
readonly planningState: "planningState";
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Determine a component role for a Block from its `type` and free-text
|
|
37
|
+
* `description` (the compiled block's purpose). Keyword matches on the
|
|
38
|
+
* description take priority over the coarse `type` field because the
|
|
39
|
+
* DesignIntent functional-block `type` is intentionally low-resolution
|
|
40
|
+
* (e.g. "power-management" covers both regulators and passive filter
|
|
41
|
+
* stages).
|
|
42
|
+
*/
|
|
43
|
+
export declare function determineComponentRole(block: {
|
|
44
|
+
type: string;
|
|
45
|
+
description?: string;
|
|
46
|
+
}): ComponentRolePlan;
|
|
47
|
+
export interface ComponentPlanResult {
|
|
48
|
+
devices: Device[];
|
|
49
|
+
warnings: string[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Plan one candidate Device per Block: a deterministic refdes, a component
|
|
53
|
+
* role, and a package-family hint, recorded as Device metadata alongside
|
|
54
|
+
* a `planningState` of `candidate` (role inferred with high confidence) or
|
|
55
|
+
* `placeholder` (role could not be determined; manual classification
|
|
56
|
+
* required).
|
|
57
|
+
*
|
|
58
|
+
* Refdes numbering is deterministic and stable across repeated compiles of
|
|
59
|
+
* the same DesignIntent, because it is derived solely from block order.
|
|
60
|
+
*/
|
|
61
|
+
export declare function planComponents(blocks: Block[]): ComponentPlanResult;
|
|
62
|
+
/** Read a Device's planned component role back out of its metadata, if present. */
|
|
63
|
+
export declare function getDeviceRole(device: Device): ComponentRole | undefined;
|