easyeda-mcp-pro 0.30.0 → 0.32.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/dist/bridge/manager.js +1 -1
- package/dist/bridge/manager.js.map +1 -1
- package/dist/bridge/protocol.d.ts +4 -0
- package/dist/bridge/protocol.js +1 -0
- package/dist/bridge/protocol.js.map +1 -1
- package/dist/bridge/types.d.ts +4 -0
- package/dist/bridge/types.js +4 -0
- package/dist/bridge/types.js.map +1 -1
- package/dist/config/profiles.js +5 -5
- package/dist/config/profiles.js.map +1 -1
- package/dist/config/version.d.ts +1 -1
- package/dist/config/version.js +1 -1
- package/dist/schematic-model/audit.d.ts +112 -0
- package/dist/schematic-model/audit.js +331 -0
- package/dist/schematic-model/audit.js.map +1 -0
- package/dist/schematic-model/index.d.ts +5 -0
- package/dist/schematic-model/index.js +6 -0
- package/dist/schematic-model/index.js.map +1 -0
- package/dist/schematic-model/model.d.ts +206 -0
- package/dist/schematic-model/model.js +84 -0
- package/dist/schematic-model/model.js.map +1 -0
- package/dist/schematic-model/net-names.d.ts +16 -0
- package/dist/schematic-model/net-names.js +176 -0
- package/dist/schematic-model/net-names.js.map +1 -0
- package/dist/schematic-model/normalization-plan.d.ts +194 -0
- package/dist/schematic-model/normalization-plan.js +669 -0
- package/dist/schematic-model/normalization-plan.js.map +1 -0
- package/dist/schematic-model/normalize.d.ts +26 -0
- package/dist/schematic-model/normalize.js +293 -0
- package/dist/schematic-model/normalize.js.map +1 -0
- package/dist/tools/L1_drc_erc.js +10 -12
- package/dist/tools/L1_drc_erc.js.map +1 -1
- package/dist/tools/L1_schematic_batch.d.ts +5 -0
- package/dist/tools/L1_schematic_batch.js +556 -0
- package/dist/tools/L1_schematic_batch.js.map +1 -0
- package/dist/tools/L1_schematic_read.js +411 -25
- package/dist/tools/L1_schematic_read.js.map +1 -1
- package/dist/tools/L1_schematic_write.js +76 -11
- package/dist/tools/L1_schematic_write.js.map +1 -1
- package/dist/tools/L1_transactions.d.ts +5 -0
- package/dist/tools/L1_transactions.js +350 -0
- package/dist/tools/L1_transactions.js.map +1 -0
- package/dist/tools/L2_workflows.js +129 -1
- package/dist/tools/L2_workflows.js.map +1 -1
- package/dist/tools/register.js +4 -0
- package/dist/tools/register.js.map +1 -1
- package/dist/tools/registry.js +31 -29
- package/dist/tools/registry.js.map +1 -1
- package/dist/transactions/easyeda.d.ts +25 -0
- package/dist/transactions/easyeda.js +129 -0
- package/dist/transactions/easyeda.js.map +1 -0
- package/dist/transactions/index.d.ts +4 -0
- package/dist/transactions/index.js +5 -0
- package/dist/transactions/index.js.map +1 -0
- package/dist/transactions/manager.d.ts +38 -0
- package/dist/transactions/manager.js +475 -0
- package/dist/transactions/manager.js.map +1 -0
- package/dist/transactions/model.d.ts +111 -0
- package/dist/transactions/model.js +2 -0
- package/dist/transactions/model.js.map +1 -0
- package/dist/transactions/stable.d.ts +4 -0
- package/dist/transactions/stable.js +57 -0
- package/dist/transactions/stable.js.map +1 -0
- package/dist/workflows/rp2040-servo-module-scaffold.d.ts +65 -0
- package/dist/workflows/rp2040-servo-module-scaffold.js +280 -0
- package/dist/workflows/rp2040-servo-module-scaffold.js.map +1 -0
- package/dist/workflows/schematic-safe-region.js +26 -0
- package/dist/workflows/schematic-safe-region.js.map +1 -1
- package/easyeda-bridge-extension.eext +0 -0
- package/package.json +4 -3
|
@@ -2,6 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { fetchComponentPins } from './schematic-helpers.js';
|
|
3
3
|
import { scanSheetForPinCollisions } from '../workflows/collision.js';
|
|
4
4
|
import { planSafeSchematicRegion } from '../workflows/schematic-safe-region.js';
|
|
5
|
+
import { auditImportedDesign, buildCanonicalSchematicModel, ImportedNormalizationPlanSchema, NormalizationComponentOverrideSchema, normalizeNetName, normalizeSchematicComponent, previewImportedNormalization, } from '../schematic-model/index.js';
|
|
5
6
|
const schematicRegionPreferenceSchema = z.enum([
|
|
6
7
|
'upper-left',
|
|
7
8
|
'upper-center',
|
|
@@ -13,6 +14,28 @@ const schematicRegionPreferenceSchema = z.enum([
|
|
|
13
14
|
'lower-center',
|
|
14
15
|
'lower-right',
|
|
15
16
|
]);
|
|
17
|
+
const importedNormalizationPreviewInputSchema = z
|
|
18
|
+
.object({
|
|
19
|
+
projectId: z.string().describe('The project/schematic ID to preview'),
|
|
20
|
+
componentLimit: z.coerce.number().int().min(1).max(500).default(500),
|
|
21
|
+
normalizeNetNames: z.boolean().default(true),
|
|
22
|
+
annotateReferences: z.boolean().default(true),
|
|
23
|
+
resolveMetadataExpressions: z.boolean().default(true),
|
|
24
|
+
componentOverrides: z.array(NormalizationComponentOverrideSchema).max(500).default([]),
|
|
25
|
+
})
|
|
26
|
+
.superRefine((value, ctx) => {
|
|
27
|
+
const seen = new Set();
|
|
28
|
+
value.componentOverrides.forEach((override, index) => {
|
|
29
|
+
if (seen.has(override.componentId)) {
|
|
30
|
+
ctx.addIssue({
|
|
31
|
+
code: 'custom',
|
|
32
|
+
message: `Duplicate component override for ${override.componentId}`,
|
|
33
|
+
path: ['componentOverrides', index, 'componentId'],
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
seen.add(override.componentId);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
16
39
|
const searchDeviceInputSchema = z.object({
|
|
17
40
|
key: z
|
|
18
41
|
.string()
|
|
@@ -135,6 +158,11 @@ function registerSchematicReadTools(registry, _config) {
|
|
|
135
158
|
project_id: z.string(),
|
|
136
159
|
nets: z.array(z.object({
|
|
137
160
|
net_name: z.string(),
|
|
161
|
+
raw_net_name: z.string(),
|
|
162
|
+
canonical_net_name: z.string(),
|
|
163
|
+
net_kind: z.enum(['signal', 'power', 'ground', 'power-flag', 'unnamed']),
|
|
164
|
+
normalization_rules: z.array(z.string()),
|
|
165
|
+
imported_alias: z.boolean(),
|
|
138
166
|
node_count: z.number().int().nonnegative(),
|
|
139
167
|
nodes: z.array(z.object({
|
|
140
168
|
component_ref: z.string(),
|
|
@@ -151,14 +179,22 @@ function registerSchematicReadTools(registry, _config) {
|
|
|
151
179
|
const nets = result;
|
|
152
180
|
return {
|
|
153
181
|
project_id: projectId,
|
|
154
|
-
nets: (nets ?? []).map((n) =>
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
182
|
+
nets: (nets ?? []).map((n) => {
|
|
183
|
+
const normalized = normalizeNetName(n.netName ?? '');
|
|
184
|
+
return {
|
|
185
|
+
net_name: n.netName ?? '',
|
|
186
|
+
raw_net_name: normalized.rawNetName,
|
|
187
|
+
canonical_net_name: normalized.canonicalNetName,
|
|
188
|
+
net_kind: normalized.kind,
|
|
189
|
+
normalization_rules: normalized.rules,
|
|
190
|
+
imported_alias: normalized.imported,
|
|
191
|
+
node_count: n.nodes?.length ?? 0,
|
|
192
|
+
nodes: (n.nodes ?? []).map((nd) => ({
|
|
193
|
+
component_ref: nd.component ?? '',
|
|
194
|
+
pin: nd.pin ?? '',
|
|
195
|
+
})),
|
|
196
|
+
};
|
|
197
|
+
}),
|
|
162
198
|
total: nets?.length ?? 0,
|
|
163
199
|
};
|
|
164
200
|
}
|
|
@@ -212,6 +248,23 @@ function registerSchematicReadTools(registry, _config) {
|
|
|
212
248
|
x: z.number().optional(),
|
|
213
249
|
y: z.number().optional(),
|
|
214
250
|
rotation: z.number().optional(),
|
|
251
|
+
component_kind: z.enum([
|
|
252
|
+
'part',
|
|
253
|
+
'power-symbol',
|
|
254
|
+
'power-flag',
|
|
255
|
+
'net-label',
|
|
256
|
+
'net-port',
|
|
257
|
+
'sheet-frame',
|
|
258
|
+
'annotation',
|
|
259
|
+
'helper',
|
|
260
|
+
'unknown',
|
|
261
|
+
]),
|
|
262
|
+
bom_eligible: z.boolean(),
|
|
263
|
+
electrical_eligible: z.boolean(),
|
|
264
|
+
annotated: z.boolean(),
|
|
265
|
+
symbol_source: z.enum(['native', 'imported', 'unknown']),
|
|
266
|
+
raw_value: z.string(),
|
|
267
|
+
raw_footprint: z.string(),
|
|
215
268
|
})),
|
|
216
269
|
total: z.number().int().nonnegative(),
|
|
217
270
|
not_available: z.boolean().optional(),
|
|
@@ -229,23 +282,33 @@ function registerSchematicReadTools(registry, _config) {
|
|
|
229
282
|
const comps = items ?? [];
|
|
230
283
|
return {
|
|
231
284
|
project_id: projectId,
|
|
232
|
-
components: comps.map((c) =>
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
285
|
+
components: comps.map((c, index) => {
|
|
286
|
+
const normalized = normalizeSchematicComponent(c, index);
|
|
287
|
+
return {
|
|
288
|
+
primitiveId: c.primitiveId,
|
|
289
|
+
reference: normalized.reference,
|
|
290
|
+
value: normalized.value,
|
|
291
|
+
footprint: normalized.footprint,
|
|
292
|
+
lcsc: normalized.lcsc,
|
|
293
|
+
manufacturer: normalized.manufacturer,
|
|
294
|
+
manufacturerId: normalized.manufacturerPart,
|
|
295
|
+
datasheet: normalized.datasheet,
|
|
296
|
+
deviceUuid: c.deviceUuid,
|
|
297
|
+
deviceLibraryUuid: c.deviceLibraryUuid,
|
|
298
|
+
deviceName: normalized.deviceName,
|
|
299
|
+
symbolName: normalized.symbolName,
|
|
300
|
+
x: normalized.x,
|
|
301
|
+
y: normalized.y,
|
|
302
|
+
rotation: normalized.rotation,
|
|
303
|
+
component_kind: normalized.componentKind,
|
|
304
|
+
bom_eligible: normalized.bomEligible,
|
|
305
|
+
electrical_eligible: normalized.electricalEligible,
|
|
306
|
+
annotated: normalized.annotated,
|
|
307
|
+
symbol_source: normalized.symbolSource,
|
|
308
|
+
raw_value: normalized.rawValue,
|
|
309
|
+
raw_footprint: normalized.rawFootprint,
|
|
310
|
+
};
|
|
311
|
+
}),
|
|
249
312
|
total: bridgeTotal ?? comps.length,
|
|
250
313
|
};
|
|
251
314
|
}
|
|
@@ -979,6 +1042,329 @@ function registerSchematicReadTools(registry, _config) {
|
|
|
979
1042
|
}
|
|
980
1043
|
},
|
|
981
1044
|
});
|
|
1045
|
+
registry.register({
|
|
1046
|
+
name: 'easyeda_schematic_audit_imported_design',
|
|
1047
|
+
title: 'Audit imported schematic design',
|
|
1048
|
+
description: 'Read the live schematic without modifying it, build a canonical model, and report imported ' +
|
|
1049
|
+
'net aliases, duplicate or missing references, unresolved metadata expressions, missing ' +
|
|
1050
|
+
'values/footprints, and ambiguous BOM classification. Includes a preview only; it never ' +
|
|
1051
|
+
'renames nets or changes components.',
|
|
1052
|
+
profile: 'core',
|
|
1053
|
+
evidence: ['runtime-probe', 'inferred'],
|
|
1054
|
+
risk: 'low',
|
|
1055
|
+
confirmWrite: false,
|
|
1056
|
+
group: 'schematic',
|
|
1057
|
+
version: '1.0.0',
|
|
1058
|
+
annotations: {
|
|
1059
|
+
readOnlyHint: true,
|
|
1060
|
+
destructiveHint: false,
|
|
1061
|
+
idempotentHint: true,
|
|
1062
|
+
},
|
|
1063
|
+
inputSchema: z.object({
|
|
1064
|
+
projectId: z.string().describe('The project/schematic ID to audit'),
|
|
1065
|
+
includeInfo: z
|
|
1066
|
+
.boolean()
|
|
1067
|
+
.default(true)
|
|
1068
|
+
.describe('Include informational imported-alias and power-flag findings'),
|
|
1069
|
+
componentLimit: z.coerce
|
|
1070
|
+
.number()
|
|
1071
|
+
.int()
|
|
1072
|
+
.min(1)
|
|
1073
|
+
.max(500)
|
|
1074
|
+
.default(500)
|
|
1075
|
+
.describe('Maximum number of component records to read from the live bridge'),
|
|
1076
|
+
}),
|
|
1077
|
+
outputSchema: z.object({
|
|
1078
|
+
project_id: z.string(),
|
|
1079
|
+
audit_schema_version: z.literal('imported-design-audit/v1'),
|
|
1080
|
+
status: z.enum(['clean', 'review', 'blocked']),
|
|
1081
|
+
read_only: z.literal(true),
|
|
1082
|
+
safe_to_normalize: z.boolean(),
|
|
1083
|
+
source: z.object({
|
|
1084
|
+
component_total: z.number().int().nonnegative(),
|
|
1085
|
+
component_items_read: z.number().int().nonnegative(),
|
|
1086
|
+
net_items_read: z.number().int().nonnegative(),
|
|
1087
|
+
source_truncated: z.boolean(),
|
|
1088
|
+
}),
|
|
1089
|
+
model_summary: z.object({
|
|
1090
|
+
component_count: z.number().int().nonnegative(),
|
|
1091
|
+
bom_component_count: z.number().int().nonnegative(),
|
|
1092
|
+
electrical_component_count: z.number().int().nonnegative(),
|
|
1093
|
+
net_count: z.number().int().nonnegative(),
|
|
1094
|
+
imported_component_count: z.number().int().nonnegative(),
|
|
1095
|
+
}),
|
|
1096
|
+
summary: z.object({
|
|
1097
|
+
finding_count: z.number().int().nonnegative(),
|
|
1098
|
+
error_count: z.number().int().nonnegative(),
|
|
1099
|
+
warning_count: z.number().int().nonnegative(),
|
|
1100
|
+
info_count: z.number().int().nonnegative(),
|
|
1101
|
+
imported_net_count: z.number().int().nonnegative(),
|
|
1102
|
+
aliased_net_count: z.number().int().nonnegative(),
|
|
1103
|
+
unannotated_component_count: z.number().int().nonnegative(),
|
|
1104
|
+
missing_footprint_count: z.number().int().nonnegative(),
|
|
1105
|
+
missing_value_count: z.number().int().nonnegative(),
|
|
1106
|
+
duplicate_reference_count: z.number().int().nonnegative(),
|
|
1107
|
+
ambiguous_bom_count: z.number().int().nonnegative(),
|
|
1108
|
+
unresolved_expression_count: z.number().int().nonnegative(),
|
|
1109
|
+
}),
|
|
1110
|
+
findings: z.array(z.object({
|
|
1111
|
+
code: z.string(),
|
|
1112
|
+
severity: z.enum(['info', 'warning', 'error']),
|
|
1113
|
+
message: z.string(),
|
|
1114
|
+
component_id: z.string().optional(),
|
|
1115
|
+
component_ref: z.string().optional(),
|
|
1116
|
+
net_name: z.string().optional(),
|
|
1117
|
+
raw_net_names: z.array(z.string()).optional(),
|
|
1118
|
+
evidence: z.record(z.string(), z.unknown()).optional(),
|
|
1119
|
+
suggested_action: z.string(),
|
|
1120
|
+
confidence: z.enum(['high', 'medium', 'low']),
|
|
1121
|
+
})),
|
|
1122
|
+
normalization_preview: z.object({
|
|
1123
|
+
net_aliases: z.array(z.object({
|
|
1124
|
+
canonical_net_name: z.string(),
|
|
1125
|
+
raw_net_names: z.array(z.string()),
|
|
1126
|
+
kind: z.enum(['signal', 'power', 'ground', 'power-flag', 'unnamed']),
|
|
1127
|
+
rules: z.array(z.string()),
|
|
1128
|
+
})),
|
|
1129
|
+
component_repairs: z.array(z.object({
|
|
1130
|
+
component_id: z.string(),
|
|
1131
|
+
reference: z.string(),
|
|
1132
|
+
actions: z.array(z.enum([
|
|
1133
|
+
'annotate-reference',
|
|
1134
|
+
'assign-footprint',
|
|
1135
|
+
'assign-value',
|
|
1136
|
+
'resolve-value-expression',
|
|
1137
|
+
'resolve-footprint-expression',
|
|
1138
|
+
'review-bom-classification',
|
|
1139
|
+
])),
|
|
1140
|
+
})),
|
|
1141
|
+
}),
|
|
1142
|
+
not_available: z.boolean().optional(),
|
|
1143
|
+
error: z.string().optional(),
|
|
1144
|
+
}),
|
|
1145
|
+
handler: async (ctx, params) => {
|
|
1146
|
+
const { projectId, includeInfo, componentLimit } = params;
|
|
1147
|
+
try {
|
|
1148
|
+
const [componentResult, netResult] = await Promise.all([
|
|
1149
|
+
ctx.bridge.call('schematic.listComponents', {
|
|
1150
|
+
projectId,
|
|
1151
|
+
limit: componentLimit,
|
|
1152
|
+
offset: 0,
|
|
1153
|
+
}),
|
|
1154
|
+
ctx.bridge.call('schematic.listNets', { projectId }),
|
|
1155
|
+
]);
|
|
1156
|
+
const componentData = componentResult;
|
|
1157
|
+
const components = componentData.items ?? [];
|
|
1158
|
+
const nets = Array.isArray(netResult) ? netResult : [];
|
|
1159
|
+
const componentTotal = componentData.total ?? components.length;
|
|
1160
|
+
const model = buildCanonicalSchematicModel({
|
|
1161
|
+
document: { projectId },
|
|
1162
|
+
components,
|
|
1163
|
+
nets,
|
|
1164
|
+
});
|
|
1165
|
+
const sourceTruncated = componentTotal > components.length;
|
|
1166
|
+
const audit = auditImportedDesign(model, { includeInfo, sourceTruncated });
|
|
1167
|
+
return {
|
|
1168
|
+
project_id: projectId,
|
|
1169
|
+
audit_schema_version: audit.schemaVersion,
|
|
1170
|
+
status: audit.status,
|
|
1171
|
+
read_only: true,
|
|
1172
|
+
safe_to_normalize: audit.safeToNormalize,
|
|
1173
|
+
source: {
|
|
1174
|
+
component_total: componentTotal,
|
|
1175
|
+
component_items_read: components.length,
|
|
1176
|
+
net_items_read: nets.length,
|
|
1177
|
+
source_truncated: sourceTruncated,
|
|
1178
|
+
},
|
|
1179
|
+
model_summary: {
|
|
1180
|
+
component_count: audit.modelSummary.componentCount,
|
|
1181
|
+
bom_component_count: audit.modelSummary.bomComponentCount,
|
|
1182
|
+
electrical_component_count: audit.modelSummary.electricalComponentCount,
|
|
1183
|
+
net_count: audit.modelSummary.netCount,
|
|
1184
|
+
imported_component_count: audit.modelSummary.importedComponentCount,
|
|
1185
|
+
},
|
|
1186
|
+
summary: {
|
|
1187
|
+
finding_count: audit.summary.findingCount,
|
|
1188
|
+
error_count: audit.summary.errorCount,
|
|
1189
|
+
warning_count: audit.summary.warningCount,
|
|
1190
|
+
info_count: audit.summary.infoCount,
|
|
1191
|
+
imported_net_count: audit.summary.importedNetCount,
|
|
1192
|
+
aliased_net_count: audit.summary.aliasedNetCount,
|
|
1193
|
+
unannotated_component_count: audit.summary.unannotatedComponentCount,
|
|
1194
|
+
missing_footprint_count: audit.summary.missingFootprintCount,
|
|
1195
|
+
missing_value_count: audit.summary.missingValueCount,
|
|
1196
|
+
duplicate_reference_count: audit.summary.duplicateReferenceCount,
|
|
1197
|
+
ambiguous_bom_count: audit.summary.ambiguousBomCount,
|
|
1198
|
+
unresolved_expression_count: audit.summary.unresolvedExpressionCount,
|
|
1199
|
+
},
|
|
1200
|
+
findings: audit.findings.map((finding) => ({
|
|
1201
|
+
code: finding.code,
|
|
1202
|
+
severity: finding.severity,
|
|
1203
|
+
message: finding.message,
|
|
1204
|
+
component_id: finding.componentId,
|
|
1205
|
+
component_ref: finding.componentRef,
|
|
1206
|
+
net_name: finding.netName,
|
|
1207
|
+
raw_net_names: finding.rawNetNames,
|
|
1208
|
+
evidence: finding.evidence,
|
|
1209
|
+
suggested_action: finding.suggestedAction,
|
|
1210
|
+
confidence: finding.confidence,
|
|
1211
|
+
})),
|
|
1212
|
+
normalization_preview: {
|
|
1213
|
+
net_aliases: audit.normalizationPreview.netAliases.map((alias) => ({
|
|
1214
|
+
canonical_net_name: alias.canonicalNetName,
|
|
1215
|
+
raw_net_names: alias.rawNetNames,
|
|
1216
|
+
kind: alias.kind,
|
|
1217
|
+
rules: alias.rules,
|
|
1218
|
+
})),
|
|
1219
|
+
component_repairs: audit.normalizationPreview.componentRepairs.map((repair) => ({
|
|
1220
|
+
component_id: repair.componentId,
|
|
1221
|
+
reference: repair.reference,
|
|
1222
|
+
actions: repair.actions,
|
|
1223
|
+
})),
|
|
1224
|
+
},
|
|
1225
|
+
};
|
|
1226
|
+
}
|
|
1227
|
+
catch (err) {
|
|
1228
|
+
return {
|
|
1229
|
+
project_id: projectId,
|
|
1230
|
+
audit_schema_version: 'imported-design-audit/v1',
|
|
1231
|
+
status: 'blocked',
|
|
1232
|
+
read_only: true,
|
|
1233
|
+
safe_to_normalize: false,
|
|
1234
|
+
source: {
|
|
1235
|
+
component_total: 0,
|
|
1236
|
+
component_items_read: 0,
|
|
1237
|
+
net_items_read: 0,
|
|
1238
|
+
source_truncated: true,
|
|
1239
|
+
},
|
|
1240
|
+
model_summary: {
|
|
1241
|
+
component_count: 0,
|
|
1242
|
+
bom_component_count: 0,
|
|
1243
|
+
electrical_component_count: 0,
|
|
1244
|
+
net_count: 0,
|
|
1245
|
+
imported_component_count: 0,
|
|
1246
|
+
},
|
|
1247
|
+
summary: {
|
|
1248
|
+
finding_count: 0,
|
|
1249
|
+
error_count: 0,
|
|
1250
|
+
warning_count: 0,
|
|
1251
|
+
info_count: 0,
|
|
1252
|
+
imported_net_count: 0,
|
|
1253
|
+
aliased_net_count: 0,
|
|
1254
|
+
unannotated_component_count: 0,
|
|
1255
|
+
missing_footprint_count: 0,
|
|
1256
|
+
missing_value_count: 0,
|
|
1257
|
+
duplicate_reference_count: 0,
|
|
1258
|
+
ambiguous_bom_count: 0,
|
|
1259
|
+
unresolved_expression_count: 0,
|
|
1260
|
+
},
|
|
1261
|
+
findings: [],
|
|
1262
|
+
normalization_preview: { net_aliases: [], component_repairs: [] },
|
|
1263
|
+
not_available: true,
|
|
1264
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1265
|
+
};
|
|
1266
|
+
}
|
|
1267
|
+
},
|
|
1268
|
+
});
|
|
1269
|
+
registry.register({
|
|
1270
|
+
name: 'easyeda_schematic_preview_imported_normalization',
|
|
1271
|
+
title: 'Preview imported schematic normalization',
|
|
1272
|
+
description: 'Read the live schematic and produce a deterministic, read-only normalization plan with a ' +
|
|
1273
|
+
'stable plan ID, model hash, proposed net-name/reference/metadata operations, validation ' +
|
|
1274
|
+
'gates, warnings, and blockers. This tool never writes to EasyEDA.',
|
|
1275
|
+
profile: 'core',
|
|
1276
|
+
evidence: ['runtime-probe', 'inferred'],
|
|
1277
|
+
risk: 'low',
|
|
1278
|
+
confirmWrite: false,
|
|
1279
|
+
group: 'schematic',
|
|
1280
|
+
version: '1.0.0',
|
|
1281
|
+
annotations: {
|
|
1282
|
+
readOnlyHint: true,
|
|
1283
|
+
destructiveHint: false,
|
|
1284
|
+
idempotentHint: true,
|
|
1285
|
+
},
|
|
1286
|
+
inputSchema: importedNormalizationPreviewInputSchema,
|
|
1287
|
+
outputSchema: z.object({
|
|
1288
|
+
project_id: z.string(),
|
|
1289
|
+
source: z.object({
|
|
1290
|
+
component_total: z.number().int().nonnegative(),
|
|
1291
|
+
component_items_read: z.number().int().nonnegative(),
|
|
1292
|
+
net_items_read: z.number().int().nonnegative(),
|
|
1293
|
+
source_truncated: z.boolean(),
|
|
1294
|
+
}),
|
|
1295
|
+
plan: ImportedNormalizationPlanSchema,
|
|
1296
|
+
not_available: z.boolean().optional(),
|
|
1297
|
+
error: z.string().optional(),
|
|
1298
|
+
}),
|
|
1299
|
+
handler: async (ctx, params) => {
|
|
1300
|
+
const { projectId, componentLimit, normalizeNetNames, annotateReferences, resolveMetadataExpressions, componentOverrides, } = params;
|
|
1301
|
+
const planOptions = {
|
|
1302
|
+
normalizeNetNames,
|
|
1303
|
+
annotateReferences,
|
|
1304
|
+
resolveMetadataExpressions,
|
|
1305
|
+
componentOverrides,
|
|
1306
|
+
};
|
|
1307
|
+
try {
|
|
1308
|
+
const [componentResult, netResult] = await Promise.all([
|
|
1309
|
+
ctx.bridge.call('schematic.listComponents', {
|
|
1310
|
+
projectId,
|
|
1311
|
+
limit: componentLimit,
|
|
1312
|
+
offset: 0,
|
|
1313
|
+
}),
|
|
1314
|
+
ctx.bridge.call('schematic.listNets', { projectId }),
|
|
1315
|
+
]);
|
|
1316
|
+
const componentData = Array.isArray(componentResult)
|
|
1317
|
+
? {
|
|
1318
|
+
total: componentResult.length,
|
|
1319
|
+
items: componentResult,
|
|
1320
|
+
}
|
|
1321
|
+
: componentResult;
|
|
1322
|
+
const components = componentData.items ?? [];
|
|
1323
|
+
const netData = Array.isArray(netResult)
|
|
1324
|
+
? netResult
|
|
1325
|
+
: (netResult?.items ?? []);
|
|
1326
|
+
const componentTotal = componentData.total ?? components.length;
|
|
1327
|
+
const sourceTruncated = componentTotal > components.length;
|
|
1328
|
+
const model = buildCanonicalSchematicModel({
|
|
1329
|
+
document: { projectId },
|
|
1330
|
+
components,
|
|
1331
|
+
nets: netData,
|
|
1332
|
+
});
|
|
1333
|
+
const plan = previewImportedNormalization(model, {
|
|
1334
|
+
...planOptions,
|
|
1335
|
+
sourceTruncated,
|
|
1336
|
+
});
|
|
1337
|
+
return {
|
|
1338
|
+
project_id: projectId,
|
|
1339
|
+
source: {
|
|
1340
|
+
component_total: componentTotal,
|
|
1341
|
+
component_items_read: components.length,
|
|
1342
|
+
net_items_read: netData.length,
|
|
1343
|
+
source_truncated: sourceTruncated,
|
|
1344
|
+
},
|
|
1345
|
+
plan,
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
catch (err) {
|
|
1349
|
+
const plan = previewImportedNormalization(buildCanonicalSchematicModel({ document: { projectId } }), {
|
|
1350
|
+
...planOptions,
|
|
1351
|
+
sourceTruncated: true,
|
|
1352
|
+
});
|
|
1353
|
+
return {
|
|
1354
|
+
project_id: projectId,
|
|
1355
|
+
source: {
|
|
1356
|
+
component_total: 0,
|
|
1357
|
+
component_items_read: 0,
|
|
1358
|
+
net_items_read: 0,
|
|
1359
|
+
source_truncated: true,
|
|
1360
|
+
},
|
|
1361
|
+
plan,
|
|
1362
|
+
not_available: true,
|
|
1363
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
},
|
|
1367
|
+
});
|
|
982
1368
|
}
|
|
983
1369
|
export { registerSchematicReadTools };
|
|
984
1370
|
//# sourceMappingURL=L1_schematic_read.js.map
|