@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.
- package/AGENTS.md +63 -0
- package/CHANGELOG.md +792 -0
- package/CONTRIBUTING.md +154 -0
- package/LICENSE +55 -0
- package/README.md +290 -2
- package/README.zh.md +449 -0
- package/cordis.patch.yml +7 -0
- package/docs/design-rules.md +254 -0
- package/docs/dsh-version-sweep.md +73 -0
- package/docs/pitfalls.md +99 -0
- package/docs/project-status.md +100 -0
- package/docs/release.md +215 -0
- package/docs/schematic-workflow.md +297 -0
- package/docs/tools.md +184 -0
- package/jlc-extension/api-bridge.js +879 -0
- package/jlc-extension/extension.json +104 -0
- package/lib/bridge.mjs +4179 -0
- package/lib/client.js +1605 -0
- package/lib/extension-digest.json +6 -0
- package/lib/index.js +1261 -0
- package/package.json +144 -4
- package/src/bridge/design-intake.ts +133 -0
- package/src/bridge/design-rules.ts +228 -0
- package/src/bridge/eda-launch.ts +267 -0
- package/src/bridge/extension-package.ts +35 -0
- package/src/bridge/index.ts +3576 -0
- package/src/bridge/netlist-erc.ts +305 -0
- package/src/bridge/schematic-audit.ts +131 -0
- package/src/bridge/workflow-guide.ts +65 -0
- package/src/bridge-diagnostics.ts +185 -0
- package/src/client/EdaMcpSettingsCard.tsx +571 -0
- package/src/client/index.ts +40 -0
- package/src/client/locales.ts +83 -0
- package/src/client/settings-scope.ts +160 -0
- package/src/config-values.ts +60 -0
- package/src/guidance.ts +35 -0
- package/src/index.ts +365 -0
- package/src/loopback.ts +48 -0
- package/src/node-runtime.ts +120 -0
- package/src/routes.ts +377 -0
- package/src/skills-content.ts +309 -0
- package/src/skills.ts +91 -0
- package/test/config-values.test.ts +60 -0
- package/test/design-intake.test.ts +40 -0
- package/test/design-rules.test.ts +72 -0
- package/test/eda-launch.test.ts +114 -0
- package/test/extension-package.test.ts +27 -0
- package/test/extension-routes.test.ts +116 -0
- package/test/netlist-erc.test.ts +90 -0
- package/test/node-runtime.test.ts +65 -0
- package/test/schematic-audit.test.ts +71 -0
- package/test/seams.test.ts +164 -0
- package/test/skills.test.ts +68 -0
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
import { useEffect, useState, type CSSProperties, type ReactNode } from 'react'
|
|
2
|
+
import { createSnapshotStore, type SnapshotStore } from '@deepseek-ai/dsh-client-store'
|
|
3
|
+
import { Switch } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
4
|
+
import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
|
|
5
|
+
import type { EdaMcpKey } from './locales.ts'
|
|
6
|
+
import type { SettingsScope } from './settings-scope.ts'
|
|
7
|
+
|
|
8
|
+
export interface EdaMcpSettings {
|
|
9
|
+
enabled?: boolean
|
|
10
|
+
announceToAgent?: boolean
|
|
11
|
+
toolCallTimeoutMs?: number
|
|
12
|
+
allowRawApi?: boolean
|
|
13
|
+
edaExecutable?: string
|
|
14
|
+
allowAutoLayoutRouting?: boolean
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface EdaMcpSettingsCardState {
|
|
18
|
+
status: 'loading' | 'ready' | 'unavailable'
|
|
19
|
+
config?: EdaMcpSettings
|
|
20
|
+
writable: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface EdaMcpSettingsCardFace {
|
|
24
|
+
hooks: {
|
|
25
|
+
edaMcpSettingsCard: SnapshotStore<EdaMcpSettingsCardState>
|
|
26
|
+
}
|
|
27
|
+
save(draft: EdaMcpSettings): Promise<void>
|
|
28
|
+
resetAll(): Promise<void>
|
|
29
|
+
testConnection(): Promise<void>
|
|
30
|
+
reconnect(): Promise<void>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class EdaMcpSettingsCardController {
|
|
34
|
+
private readonly store = createSnapshotStore<EdaMcpSettingsCardState>({ status: 'loading', writable: false })
|
|
35
|
+
private readonly disposeScope: () => void
|
|
36
|
+
|
|
37
|
+
constructor(private readonly scope: SettingsScope<EdaMcpSettings>) {
|
|
38
|
+
this.disposeScope = scope.subscribe(() => { this.sync() })
|
|
39
|
+
this.sync()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private sync(): void {
|
|
43
|
+
const snapshot = this.scope.getSnapshot()
|
|
44
|
+
this.store.set({
|
|
45
|
+
status: snapshot.status,
|
|
46
|
+
config: snapshot.value,
|
|
47
|
+
writable: snapshot.writable,
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
inject(): EdaMcpSettingsCardFace {
|
|
52
|
+
return {
|
|
53
|
+
hooks: { edaMcpSettingsCard: this.store },
|
|
54
|
+
save: async (draft) => { await this.save(draft) },
|
|
55
|
+
resetAll: async () => { await this.resetAll() },
|
|
56
|
+
testConnection: async () => { await this.testConnection() },
|
|
57
|
+
reconnect: async () => { await this.reconnect() },
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
dispose(): void {
|
|
62
|
+
this.disposeScope()
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private async save(draft: EdaMcpSettings): Promise<void> {
|
|
66
|
+
for (const [field, value] of Object.entries(draft)) {
|
|
67
|
+
if (value === undefined || value === null || value === '') {
|
|
68
|
+
await this.scope.unset(field)
|
|
69
|
+
} else {
|
|
70
|
+
await this.scope.set(field, value)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private async resetAll(): Promise<void> {
|
|
76
|
+
const snapshot = this.scope.getSnapshot()
|
|
77
|
+
const user = snapshot.user as Record<string, unknown> | undefined
|
|
78
|
+
if (user === undefined) return
|
|
79
|
+
for (const field of Object.keys(user)) {
|
|
80
|
+
await this.scope.unset(field)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private async testConnection(): Promise<void> {
|
|
85
|
+
const response = await fetch('/api/dsh-eda-mcp/test', { method: 'POST' })
|
|
86
|
+
let body: { ok?: boolean; error?: string; message?: string; health?: { status?: string; clients?: number } } | undefined
|
|
87
|
+
try {
|
|
88
|
+
body = await response.json() as { ok?: boolean; error?: string; message?: string; health?: { status?: string; clients?: number } }
|
|
89
|
+
} catch {
|
|
90
|
+
body = undefined
|
|
91
|
+
}
|
|
92
|
+
if (!response.ok || body?.ok !== true) {
|
|
93
|
+
throw new Error(body?.error ?? body?.message ?? `HTTP ${response.status}`)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private async reconnect(): Promise<void> {
|
|
98
|
+
const response = await fetch('/api/dsh-eda-mcp/reconnect', { method: 'POST' })
|
|
99
|
+
let body: { ok?: boolean; error?: string; message?: string } | undefined
|
|
100
|
+
try {
|
|
101
|
+
body = await response.json() as { ok?: boolean; error?: string; message?: string }
|
|
102
|
+
} catch {
|
|
103
|
+
body = undefined
|
|
104
|
+
}
|
|
105
|
+
if (!response.ok || body?.ok !== true) {
|
|
106
|
+
throw new Error(body?.error ?? body?.message ?? `HTTP ${response.status}`)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export type EdaMcpSettingsCardProps =
|
|
112
|
+
PropsRuntime<'settings.section'>
|
|
113
|
+
& PropsLocale<'eda-mcp'>
|
|
114
|
+
& InjectFace<EdaMcpSettingsCardFace>
|
|
115
|
+
|
|
116
|
+
const cardStyle: CSSProperties = {
|
|
117
|
+
border: '1px solid var(--dsw-alias-border-l2)',
|
|
118
|
+
background: 'var(--dsw-alias-bg-layer-3)',
|
|
119
|
+
borderRadius: 12,
|
|
120
|
+
color: 'var(--dsw-alias-label-primary)',
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const headerStyle: CSSProperties = {
|
|
124
|
+
display: 'flex',
|
|
125
|
+
alignItems: 'flex-start',
|
|
126
|
+
gap: 12,
|
|
127
|
+
padding: '14px 16px',
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const titleStyle: CSSProperties = {
|
|
131
|
+
margin: 0,
|
|
132
|
+
color: 'var(--dsw-alias-label-primary)',
|
|
133
|
+
fontSize: 15,
|
|
134
|
+
fontWeight: 600,
|
|
135
|
+
lineHeight: 1.4,
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const descriptionStyle: CSSProperties = {
|
|
139
|
+
margin: '4px 0 0',
|
|
140
|
+
color: 'var(--dsw-alias-label-tertiary)',
|
|
141
|
+
fontSize: 13,
|
|
142
|
+
lineHeight: 1.5,
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const bodyStyle: CSSProperties = {
|
|
146
|
+
borderTop: '1px solid var(--dsw-alias-border-l2)',
|
|
147
|
+
margin: '0 16px',
|
|
148
|
+
padding: '8px 0 12px',
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const footerStyle: CSSProperties = {
|
|
152
|
+
borderTop: '1px solid var(--dsw-alias-border-l2)',
|
|
153
|
+
display: 'flex',
|
|
154
|
+
justifyContent: 'flex-end',
|
|
155
|
+
alignItems: 'center',
|
|
156
|
+
flexWrap: 'wrap',
|
|
157
|
+
gap: 8,
|
|
158
|
+
margin: '0 16px',
|
|
159
|
+
padding: '12px 0 16px',
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const fieldStyle: CSSProperties = {
|
|
163
|
+
display: 'flex',
|
|
164
|
+
flexDirection: 'column',
|
|
165
|
+
gap: 6,
|
|
166
|
+
padding: '12px 0',
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const labelStyle: CSSProperties = {
|
|
170
|
+
color: 'var(--dsw-alias-label-primary)',
|
|
171
|
+
fontSize: 13,
|
|
172
|
+
fontWeight: 500,
|
|
173
|
+
lineHeight: 1.5,
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const hintStyle: CSSProperties = {
|
|
177
|
+
color: 'var(--dsw-alias-label-tertiary)',
|
|
178
|
+
fontSize: 12,
|
|
179
|
+
lineHeight: 1.5,
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const inputStyle: CSSProperties = {
|
|
183
|
+
border: '1px solid var(--dsw-alias-border-l2)',
|
|
184
|
+
background: 'var(--dsw-alias-bg-layer-3)',
|
|
185
|
+
color: 'var(--dsw-alias-label-primary)',
|
|
186
|
+
borderRadius: 8,
|
|
187
|
+
padding: '0 12px',
|
|
188
|
+
height: 34,
|
|
189
|
+
fontSize: 13,
|
|
190
|
+
lineHeight: 1.5,
|
|
191
|
+
width: '100%',
|
|
192
|
+
boxSizing: 'border-box',
|
|
193
|
+
font: 'inherit',
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const buttonBaseStyle: CSSProperties = {
|
|
197
|
+
appearance: 'none',
|
|
198
|
+
font: 'inherit',
|
|
199
|
+
cursor: 'pointer',
|
|
200
|
+
border: '1px solid transparent',
|
|
201
|
+
borderRadius: 8,
|
|
202
|
+
padding: '6px 16px',
|
|
203
|
+
fontSize: 13,
|
|
204
|
+
lineHeight: 1.5,
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const primaryButtonStyle: CSSProperties = {
|
|
208
|
+
...buttonBaseStyle,
|
|
209
|
+
background: 'var(--dsw-alias-label-primary)',
|
|
210
|
+
color: 'var(--dsw-alias-bg-layer-3)',
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const secondaryButtonStyle: CSSProperties = {
|
|
214
|
+
...buttonBaseStyle,
|
|
215
|
+
borderColor: 'var(--dsw-alias-border-l2)',
|
|
216
|
+
background: 'transparent',
|
|
217
|
+
color: 'var(--dsw-alias-label-secondary)',
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const disabledButtonStyle: CSSProperties = {
|
|
221
|
+
opacity: 0.4,
|
|
222
|
+
cursor: 'default',
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
interface FieldProps {
|
|
226
|
+
label: string
|
|
227
|
+
hint: string
|
|
228
|
+
children: ReactNode
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function Field(props: FieldProps) {
|
|
232
|
+
return (
|
|
233
|
+
<div style={fieldStyle}>
|
|
234
|
+
<span style={labelStyle}>{props.label}</span>
|
|
235
|
+
{props.children}
|
|
236
|
+
<span style={hintStyle}>{props.hint}</span>
|
|
237
|
+
</div>
|
|
238
|
+
)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
interface NumberFieldProps {
|
|
242
|
+
label: string
|
|
243
|
+
hint: string
|
|
244
|
+
value: number | undefined
|
|
245
|
+
disabled?: boolean
|
|
246
|
+
onChange: (value: number | undefined) => void
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function NumberField(props: NumberFieldProps) {
|
|
250
|
+
return (
|
|
251
|
+
<Field label={props.label} hint={props.hint}>
|
|
252
|
+
<input
|
|
253
|
+
type="number"
|
|
254
|
+
value={props.value ?? ''}
|
|
255
|
+
disabled={props.disabled}
|
|
256
|
+
onChange={(event) => {
|
|
257
|
+
const text = event.target.value.trim()
|
|
258
|
+
if (text === '') {
|
|
259
|
+
props.onChange(undefined)
|
|
260
|
+
return
|
|
261
|
+
}
|
|
262
|
+
const parsed = Number(text)
|
|
263
|
+
props.onChange(Number.isFinite(parsed) ? parsed : undefined)
|
|
264
|
+
}}
|
|
265
|
+
style={inputStyle}
|
|
266
|
+
/>
|
|
267
|
+
</Field>
|
|
268
|
+
)
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
interface TextFieldProps {
|
|
272
|
+
label: string
|
|
273
|
+
hint: string
|
|
274
|
+
value: string | undefined
|
|
275
|
+
placeholder?: string
|
|
276
|
+
disabled?: boolean
|
|
277
|
+
onChange: (value: string | undefined) => void
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function TextField(props: TextFieldProps) {
|
|
281
|
+
return (
|
|
282
|
+
<Field label={props.label} hint={props.hint}>
|
|
283
|
+
<input
|
|
284
|
+
type="text"
|
|
285
|
+
value={props.value ?? ''}
|
|
286
|
+
placeholder={props.placeholder}
|
|
287
|
+
disabled={props.disabled}
|
|
288
|
+
onChange={(event) => {
|
|
289
|
+
const text = event.target.value.trim()
|
|
290
|
+
props.onChange(text === '' ? undefined : text)
|
|
291
|
+
}}
|
|
292
|
+
style={inputStyle}
|
|
293
|
+
/>
|
|
294
|
+
</Field>
|
|
295
|
+
)
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
interface BooleanFieldProps {
|
|
299
|
+
label: string
|
|
300
|
+
hint: string
|
|
301
|
+
value: boolean
|
|
302
|
+
disabled?: boolean
|
|
303
|
+
onChange: (value: boolean) => void
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function BooleanField(props: BooleanFieldProps) {
|
|
307
|
+
// The official settings pages use this exact primitive, so plugin toggles and
|
|
308
|
+
// built-in toggles look and behave identically.
|
|
309
|
+
return (
|
|
310
|
+
<Field label={props.label} hint={props.hint}>
|
|
311
|
+
<Switch
|
|
312
|
+
checked={props.value}
|
|
313
|
+
disabled={props.disabled === true}
|
|
314
|
+
label={props.label}
|
|
315
|
+
onChange={(next) => { props.onChange(next) }}
|
|
316
|
+
/>
|
|
317
|
+
</Field>
|
|
318
|
+
)
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export function EdaMcpSettingsCard(props: EdaMcpSettingsCardProps) {
|
|
322
|
+
const { t } = props
|
|
323
|
+
const state = props.useEdaMcpSettingsCard(snapshot => snapshot)
|
|
324
|
+
const [draft, setDraft] = useState<EdaMcpSettings>({})
|
|
325
|
+
const [seeded, setSeeded] = useState(false)
|
|
326
|
+
const [saving, setSaving] = useState(false)
|
|
327
|
+
const [testing, setTesting] = useState(false)
|
|
328
|
+
const [reconnecting, setReconnecting] = useState(false)
|
|
329
|
+
const [notice, setNotice] = useState<{ kind: 'ok' | 'error'; text: string } | undefined>()
|
|
330
|
+
const [verifyingExtension, setVerifyingExtension] = useState(false)
|
|
331
|
+
const [extensionVerdict, setExtensionVerdict] = useState<{ kind: 'ok' | 'error'; text: string } | undefined>()
|
|
332
|
+
const [extensionInfo, setExtensionInfo] = useState<{ version: string; bytes: number; sha256: string } | undefined>()
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
const verifyExtension = async (): Promise<void> => {
|
|
336
|
+
if (verifyingExtension) return
|
|
337
|
+
setVerifyingExtension(true)
|
|
338
|
+
try {
|
|
339
|
+
const response = await fetch('/api/dsh-eda-mcp/extension/verify')
|
|
340
|
+
const body = await response.json() as {
|
|
341
|
+
verified?: 'match' | 'mismatch' | 'unverified'
|
|
342
|
+
file?: string
|
|
343
|
+
local?: { sha256?: string }
|
|
344
|
+
error?: string
|
|
345
|
+
}
|
|
346
|
+
if (body.verified === 'match') {
|
|
347
|
+
const short = String(body.local?.sha256 ?? '').slice(0, 16) + '…'
|
|
348
|
+
setExtensionVerdict({ kind: 'ok', text: t('settings.verifyMatch').replace('{hash}', short) })
|
|
349
|
+
} else if (body.verified === 'mismatch') {
|
|
350
|
+
setExtensionVerdict({ kind: 'error', text: t('settings.verifyMismatch').replace('{hash}', String(body.file ?? '')) })
|
|
351
|
+
} else {
|
|
352
|
+
const reason = String(body.error ?? 'unknown')
|
|
353
|
+
setExtensionVerdict({ kind: 'error', text: t('settings.verifyUnverified').replace('{reason}', reason) })
|
|
354
|
+
}
|
|
355
|
+
} catch (error) {
|
|
356
|
+
const reason = error instanceof Error ? error.message : String(error)
|
|
357
|
+
setExtensionVerdict({ kind: 'error', text: t('settings.verifyUnverified').replace('{reason}', reason) })
|
|
358
|
+
} finally {
|
|
359
|
+
setVerifyingExtension(false)
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
useEffect(() => {
|
|
364
|
+
if (!seeded && state.status === 'ready') {
|
|
365
|
+
setDraft(state.config ?? {})
|
|
366
|
+
setSeeded(true)
|
|
367
|
+
}
|
|
368
|
+
}, [seeded, state.status, state.config])
|
|
369
|
+
|
|
370
|
+
if (state.status === 'loading') return null
|
|
371
|
+
|
|
372
|
+
const disabled = !state.writable || saving || testing || reconnecting
|
|
373
|
+
const update = (field: keyof EdaMcpSettings, value: unknown): void => {
|
|
374
|
+
setDraft(current => ({ ...current, [field]: value }))
|
|
375
|
+
}
|
|
376
|
+
const clearNotice = (): void => { setNotice(undefined) }
|
|
377
|
+
|
|
378
|
+
const onSave = async (): Promise<void> => {
|
|
379
|
+
setSaving(true)
|
|
380
|
+
setNotice(undefined)
|
|
381
|
+
try {
|
|
382
|
+
await props.save(draft)
|
|
383
|
+
setNotice({ kind: 'ok', text: t('settings.saved') })
|
|
384
|
+
} catch (error) {
|
|
385
|
+
setNotice({ kind: 'error', text: t('settings.saveFailed') + ': ' + (error instanceof Error ? error.message : String(error)) })
|
|
386
|
+
} finally {
|
|
387
|
+
setSaving(false)
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
const onReset = async (): Promise<void> => {
|
|
392
|
+
setSaving(true)
|
|
393
|
+
setNotice(undefined)
|
|
394
|
+
try {
|
|
395
|
+
await props.resetAll()
|
|
396
|
+
setDraft(state.config ?? {})
|
|
397
|
+
setNotice({ kind: 'ok', text: t('settings.saved') })
|
|
398
|
+
} catch (error) {
|
|
399
|
+
setNotice({ kind: 'error', text: t('settings.saveFailed') + ': ' + (error instanceof Error ? error.message : String(error)) })
|
|
400
|
+
} finally {
|
|
401
|
+
setSaving(false)
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
const onTest = async (): Promise<void> => {
|
|
406
|
+
setTesting(true)
|
|
407
|
+
setNotice(undefined)
|
|
408
|
+
try {
|
|
409
|
+
await props.save(draft)
|
|
410
|
+
await props.testConnection()
|
|
411
|
+
setNotice({ kind: 'ok', text: t('settings.testOk') })
|
|
412
|
+
} catch (error) {
|
|
413
|
+
setNotice({ kind: 'error', text: t('settings.testFailed') + ': ' + (error instanceof Error ? error.message : String(error)) })
|
|
414
|
+
} finally {
|
|
415
|
+
setTesting(false)
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
const onReconnect = async (): Promise<void> => {
|
|
420
|
+
setReconnecting(true)
|
|
421
|
+
setNotice(undefined)
|
|
422
|
+
try {
|
|
423
|
+
await props.save(draft)
|
|
424
|
+
await props.reconnect()
|
|
425
|
+
setNotice({ kind: 'ok', text: t('settings.reconnectOk') })
|
|
426
|
+
} catch (error) {
|
|
427
|
+
setNotice({ kind: 'error', text: t('settings.reconnectFailed') + ': ' + (error instanceof Error ? error.message : String(error)) })
|
|
428
|
+
} finally {
|
|
429
|
+
setReconnecting(false)
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const noticeStyle: CSSProperties = {
|
|
434
|
+
margin: '8px 0 0',
|
|
435
|
+
fontSize: 12,
|
|
436
|
+
lineHeight: 1.5,
|
|
437
|
+
color: notice?.kind === 'ok' ? 'var(--dsw-alias-state-success-primary)' : 'var(--dsw-alias-label-error)',
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
return (
|
|
441
|
+
<div style={cardStyle}>
|
|
442
|
+
<header style={headerStyle}>
|
|
443
|
+
<div>
|
|
444
|
+
<h3 style={titleStyle}>{t('settings.title')}</h3>
|
|
445
|
+
<p style={descriptionStyle}>{t('settings.description')}</p>
|
|
446
|
+
</div>
|
|
447
|
+
</header>
|
|
448
|
+
|
|
449
|
+
<div style={bodyStyle}>
|
|
450
|
+
<BooleanField
|
|
451
|
+
label={t('settings.enabled')}
|
|
452
|
+
hint={t('settings.enabledHint')}
|
|
453
|
+
value={draft.enabled ?? true}
|
|
454
|
+
disabled={disabled}
|
|
455
|
+
onChange={(value) => { clearNotice(); update('enabled', value) }}
|
|
456
|
+
/>
|
|
457
|
+
<BooleanField
|
|
458
|
+
label={t('settings.announceToAgent')}
|
|
459
|
+
hint={t('settings.announceToAgentHint')}
|
|
460
|
+
value={draft.announceToAgent ?? true}
|
|
461
|
+
disabled={disabled}
|
|
462
|
+
onChange={(value) => { clearNotice(); update('announceToAgent', value) }}
|
|
463
|
+
/>
|
|
464
|
+
<NumberField
|
|
465
|
+
label={t('settings.toolCallTimeoutMs')}
|
|
466
|
+
hint={t('settings.toolCallTimeoutMsHint')}
|
|
467
|
+
value={draft.toolCallTimeoutMs}
|
|
468
|
+
disabled={disabled}
|
|
469
|
+
onChange={(value) => { clearNotice(); update('toolCallTimeoutMs', value) }}
|
|
470
|
+
/>
|
|
471
|
+
<TextField
|
|
472
|
+
label={t('settings.edaExecutable')}
|
|
473
|
+
hint={t('settings.edaExecutableHint')}
|
|
474
|
+
value={draft.edaExecutable}
|
|
475
|
+
placeholder="lceda-pro.exe"
|
|
476
|
+
disabled={disabled}
|
|
477
|
+
onChange={(value) => { clearNotice(); update('edaExecutable', value) }}
|
|
478
|
+
/>
|
|
479
|
+
<BooleanField
|
|
480
|
+
label={t('settings.allowRawApi')}
|
|
481
|
+
hint={t('settings.allowRawApiHint')}
|
|
482
|
+
value={draft.allowRawApi ?? true}
|
|
483
|
+
disabled={disabled}
|
|
484
|
+
onChange={(value) => { clearNotice(); update('allowRawApi', value) }}
|
|
485
|
+
/>
|
|
486
|
+
<BooleanField
|
|
487
|
+
label={t('settings.allowAutoLayoutRouting')}
|
|
488
|
+
hint={t('settings.allowAutoLayoutRoutingHint')}
|
|
489
|
+
value={draft.allowAutoLayoutRouting ?? false}
|
|
490
|
+
disabled={disabled}
|
|
491
|
+
onChange={(value) => { clearNotice(); update('allowAutoLayoutRouting', value) }}
|
|
492
|
+
/>
|
|
493
|
+
|
|
494
|
+
<p style={{ ...hintStyle, margin: '8px 0 0' }}>{t('settings.portLabel')}</p>
|
|
495
|
+
|
|
496
|
+
<Field
|
|
497
|
+
label={extensionInfo === undefined
|
|
498
|
+
? t('settings.downloadExtension')
|
|
499
|
+
: t('settings.downloadExtensionVersioned').replace('{version}', extensionInfo.version)}
|
|
500
|
+
hint={t('settings.installHint')}
|
|
501
|
+
>
|
|
502
|
+
<a
|
|
503
|
+
href="/api/dsh-eda-mcp/extension.zip"
|
|
504
|
+
// No download name: the server sends the versioned file name, so the
|
|
505
|
+
// saved copy always states which build it is.
|
|
506
|
+
style={{ ...secondaryButtonStyle, textDecoration: 'none', display: 'inline-flex', width: 'fit-content' }}
|
|
507
|
+
>
|
|
508
|
+
{extensionInfo === undefined
|
|
509
|
+
? t('settings.downloadExtension')
|
|
510
|
+
: t('settings.downloadExtensionVersioned').replace('{version}', extensionInfo.version)}
|
|
511
|
+
</a>
|
|
512
|
+
<button
|
|
513
|
+
type="button"
|
|
514
|
+
onClick={() => { void verifyExtension() }}
|
|
515
|
+
disabled={verifyingExtension}
|
|
516
|
+
style={verifyingExtension ? { ...secondaryButtonStyle, ...disabledButtonStyle, marginLeft: 8 } : { ...secondaryButtonStyle, marginLeft: 8 }}
|
|
517
|
+
>
|
|
518
|
+
{verifyingExtension ? t('settings.verifyBusy') : t('settings.verifyExtension')}
|
|
519
|
+
</button>
|
|
520
|
+
{extensionInfo !== undefined
|
|
521
|
+
? <p style={{ ...hintStyle, margin: '6px 0 0' }}>{t('settings.extensionInfo')
|
|
522
|
+
.replace('{version}', extensionInfo.version)
|
|
523
|
+
.replace('{bytes}', String(extensionInfo.bytes))
|
|
524
|
+
.replace('{hash}', extensionInfo.sha256.slice(0, 16) + '…')}</p>
|
|
525
|
+
: null}
|
|
526
|
+
{extensionVerdict !== undefined
|
|
527
|
+
? <p role="status" style={{ ...hintStyle, margin: '6px 0 0', color: extensionVerdict.kind === 'ok' ? undefined : '#c0392b' }}>{extensionVerdict.text}</p>
|
|
528
|
+
: null}
|
|
529
|
+
</Field>
|
|
530
|
+
</div>
|
|
531
|
+
|
|
532
|
+
<footer style={footerStyle}>
|
|
533
|
+
{notice !== undefined
|
|
534
|
+
? <p style={noticeStyle} role="status">{notice.text}</p>
|
|
535
|
+
: null}
|
|
536
|
+
<button
|
|
537
|
+
type="button"
|
|
538
|
+
disabled={disabled}
|
|
539
|
+
style={disabled ? { ...primaryButtonStyle, ...disabledButtonStyle } : primaryButtonStyle}
|
|
540
|
+
onClick={() => { void onSave() }}
|
|
541
|
+
>
|
|
542
|
+
{t(saving ? 'settings.saving' : 'settings.save')}
|
|
543
|
+
</button>
|
|
544
|
+
<button
|
|
545
|
+
type="button"
|
|
546
|
+
disabled={disabled}
|
|
547
|
+
style={disabled ? { ...secondaryButtonStyle, ...disabledButtonStyle } : secondaryButtonStyle}
|
|
548
|
+
onClick={() => { void onReset() }}
|
|
549
|
+
>
|
|
550
|
+
{t('settings.resetAll')}
|
|
551
|
+
</button>
|
|
552
|
+
<button
|
|
553
|
+
type="button"
|
|
554
|
+
disabled={disabled}
|
|
555
|
+
style={disabled ? { ...secondaryButtonStyle, ...disabledButtonStyle } : secondaryButtonStyle}
|
|
556
|
+
onClick={() => { void onTest() }}
|
|
557
|
+
>
|
|
558
|
+
{t(testing ? 'settings.testingConnection' : 'settings.testConnection')}
|
|
559
|
+
</button>
|
|
560
|
+
<button
|
|
561
|
+
type="button"
|
|
562
|
+
disabled={disabled}
|
|
563
|
+
style={disabled ? { ...secondaryButtonStyle, ...disabledButtonStyle } : secondaryButtonStyle}
|
|
564
|
+
onClick={() => { void onReconnect() }}
|
|
565
|
+
>
|
|
566
|
+
{t(reconnecting ? 'settings.reconnecting' : 'settings.reconnect')}
|
|
567
|
+
</button>
|
|
568
|
+
</footer>
|
|
569
|
+
</div>
|
|
570
|
+
)
|
|
571
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Context as ClientContext } from '@deepseek-ai/cordis'
|
|
2
|
+
import type {} from '@deepseek-ai/dsh-client-locale/client'
|
|
3
|
+
import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
|
|
4
|
+
import type {} from '@deepseek-ai/dsh-client-ui-slots'
|
|
5
|
+
import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
|
|
6
|
+
import { EdaMcpSettingsCard, EdaMcpSettingsCardController, type EdaMcpSettings } from './EdaMcpSettingsCard.tsx'
|
|
7
|
+
import { createEdaMcpSettingsScope } from './settings-scope.ts'
|
|
8
|
+
import { en, zh, type EdaMcpKey } from './locales.ts'
|
|
9
|
+
|
|
10
|
+
const NS = 'eda-mcp'
|
|
11
|
+
|
|
12
|
+
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
13
|
+
interface LocaleNamespaceMap {
|
|
14
|
+
'eda-mcp': EdaMcpKey
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const inject = ['slots', 'locale']
|
|
19
|
+
|
|
20
|
+
export function apply(ctx: ClientContext): void {
|
|
21
|
+
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'eda-mcp: dictionaries')
|
|
22
|
+
|
|
23
|
+
const settingsScope = createEdaMcpSettingsScope<EdaMcpSettings>()
|
|
24
|
+
const controller = new EdaMcpSettingsCardController(settingsScope)
|
|
25
|
+
|
|
26
|
+
ctx.slots.inject('settings.section', () => {
|
|
27
|
+
const unregister = ctx.slots.register({
|
|
28
|
+
name: 'settings.section',
|
|
29
|
+
id: 'eda-mcp',
|
|
30
|
+
order: 40,
|
|
31
|
+
label: () => ctx.locale.bind(NS)('settings.title'),
|
|
32
|
+
locale: NS,
|
|
33
|
+
inject: () => controller.inject(),
|
|
34
|
+
}, EdaMcpSettingsCard)
|
|
35
|
+
return () => {
|
|
36
|
+
controller.dispose()
|
|
37
|
+
unregister()
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export const zh = {
|
|
2
|
+
'settings.title': '嘉立创EDA MCP',
|
|
3
|
+
'settings.description': '通过本地 MCP 桥接子进程连接嘉立创EDA专业版扩展,让 DSH 在原理图里放置器件、画导线/矩形/圆/文本。',
|
|
4
|
+
'settings.enabled': '启用插件',
|
|
5
|
+
'settings.enabledHint': '关闭后会卸载 MCP 桥接子进程,不再注册 mcp__jlceda__* 工具。',
|
|
6
|
+
'settings.announceToAgent': '向 Agent 公告本插件',
|
|
7
|
+
'settings.announceToAgentHint': '在系统提示中加入 dsh-eda-mcp 的坐标单位、连接排障等说明。',
|
|
8
|
+
'settings.toolCallTimeoutMs': 'EDA 调用超时(毫秒)',
|
|
9
|
+
'settings.toolCallTimeoutMsHint': '单次 EDA API 调用超时,默认 60000。',
|
|
10
|
+
'settings.allowRawApi': '允许通用 eda_api_call',
|
|
11
|
+
'settings.allowRawApiHint': '开启后 MCP 工具 eda_api_call 可调用白名单内的 JLCEDA 扩展 API。',
|
|
12
|
+
'settings.allowAutoLayoutRouting': '允许原理图自动布局 / 自动布线',
|
|
13
|
+
'settings.allowAutoLayoutRoutingHint': '默认关闭:布局按栅格手工摆放、布线手工走,版面检查用导出图片自行识别。开启后 eda_auto_layout / eda_auto_route 才可用。',
|
|
14
|
+
'settings.edaExecutable': '嘉立创EDA 可执行文件(可选)',
|
|
15
|
+
'settings.edaExecutableHint': '留空即自动探测:环境变量 → 注册表登记的文件关联 → 常见安装目录 → PATH。只有自动探测失败时才需要填完整路径。',
|
|
16
|
+
'settings.save': '保存',
|
|
17
|
+
'settings.saving': '保存中…',
|
|
18
|
+
'settings.saved': '已保存',
|
|
19
|
+
'settings.saveFailed': '保存失败',
|
|
20
|
+
'settings.resetAll': '恢复默认',
|
|
21
|
+
'settings.testConnection': '测试连接',
|
|
22
|
+
'settings.testingConnection': '测试中…',
|
|
23
|
+
'settings.testOk': '桥接服务在线',
|
|
24
|
+
'settings.testFailed': '桥接服务不可达',
|
|
25
|
+
'settings.reconnect': '重新连接',
|
|
26
|
+
'settings.reconnecting': '重连中…',
|
|
27
|
+
'settings.reconnectOk': '已重新启动桥接子进程',
|
|
28
|
+
'settings.reconnectFailed': '重连失败',
|
|
29
|
+
'settings.portLabel': '桥接 WebSocket 端口:39009(固定)',
|
|
30
|
+
'settings.downloadExtension': '下载 JLCEDA 扩展包',
|
|
31
|
+
'settings.downloadExtensionVersioned': '下载 JLCEDA 扩展包 v{version}',
|
|
32
|
+
'settings.extensionInfo': '本地 v{version} · {bytes} 字节 · sha256 {hash}',
|
|
33
|
+
'settings.extensionInfoUnknown': '扩展包信息不可用',
|
|
34
|
+
'settings.verifyExtension': '校验服务器副本',
|
|
35
|
+
'settings.verifyBusy': '校验中…',
|
|
36
|
+
'settings.verifyMatch': '一致:服务器上的 zip 与本地这份逐字节相同(sha256 {hash})',
|
|
37
|
+
'settings.verifyMismatch': '不一致:服务器那份与本地不同,请重新上传 {hash}',
|
|
38
|
+
'settings.verifyUnverified': '无法校验:{reason}',
|
|
39
|
+
'settings.installHint': '点下载会从下载服务器取回与本插件线协议一致的 zip(发送前校验 sha256,不一致则拒绝发送);在嘉立创EDA专业版中:扩展 → 导入 → 选择该 zip → 在扩展列表开启本扩展的「允许外部交互」。',
|
|
40
|
+
} as const
|
|
41
|
+
|
|
42
|
+
export const en = {
|
|
43
|
+
'settings.title': 'JLCEDA MCP',
|
|
44
|
+
'settings.description': 'Connect DSH to JLCEDA Pro through a local MCP bridge and draw schematics via the official extension API.',
|
|
45
|
+
'settings.enabled': 'Enable plugin',
|
|
46
|
+
'settings.enabledHint': 'When disabled, the bridge child is disposed and mcp__jlceda__* tools are unregistered.',
|
|
47
|
+
'settings.announceToAgent': 'Announce to Agent',
|
|
48
|
+
'settings.announceToAgentHint': 'Add dsh-eda-mcp coordinate and troubleshooting guidance to the system prompt.',
|
|
49
|
+
'settings.toolCallTimeoutMs': 'EDA call timeout (ms)',
|
|
50
|
+
'settings.toolCallTimeoutMsHint': 'Timeout for one EDA API call; default 60000.',
|
|
51
|
+
'settings.allowRawApi': 'Allow generic eda_api_call',
|
|
52
|
+
'settings.allowRawApiHint': 'Expose the eda_api_call tool restricted to the allow-listed JLCEDA APIs.',
|
|
53
|
+
'settings.edaExecutable': 'JLCEDA Pro executable (optional)',
|
|
54
|
+
'settings.allowAutoLayoutRouting': 'Allow automatic schematic layout / routing',
|
|
55
|
+
'settings.allowAutoLayoutRoutingHint': 'Off by default: place parts on the grid, route by hand, and check the sheet by exporting an image. Only with this on do eda_auto_layout / eda_auto_route run.',
|
|
56
|
+
'settings.edaExecutableHint': 'Leave empty to auto-detect: environment variable, the file-association command in the registry, conventional install directories, then PATH. Set a full path only when auto-detection fails.',
|
|
57
|
+
'settings.save': 'Save',
|
|
58
|
+
'settings.saving': 'Saving…',
|
|
59
|
+
'settings.saved': 'Saved',
|
|
60
|
+
'settings.saveFailed': 'Save failed',
|
|
61
|
+
'settings.resetAll': 'Reset defaults',
|
|
62
|
+
'settings.testConnection': 'Test connection',
|
|
63
|
+
'settings.testingConnection': 'Testing…',
|
|
64
|
+
'settings.testOk': 'Bridge service is online',
|
|
65
|
+
'settings.testFailed': 'Bridge service is unreachable',
|
|
66
|
+
'settings.reconnect': 'Reconnect',
|
|
67
|
+
'settings.reconnecting': 'Reconnecting…',
|
|
68
|
+
'settings.reconnectOk': 'Bridge child restarted',
|
|
69
|
+
'settings.reconnectFailed': 'Reconnect failed',
|
|
70
|
+
'settings.portLabel': 'Bridge WebSocket port: 39009 (fixed)',
|
|
71
|
+
'settings.downloadExtension': 'Download JLCEDA extension zip',
|
|
72
|
+
'settings.downloadExtensionVersioned': 'Download JLCEDA extension zip v{version}',
|
|
73
|
+
'settings.extensionInfo': 'Bundled v{version} · {bytes} bytes · sha256 {hash}',
|
|
74
|
+
'settings.extensionInfoUnknown': 'Extension package info unavailable',
|
|
75
|
+
'settings.verifyExtension': 'Verify server copy',
|
|
76
|
+
'settings.verifyBusy': 'Verifying…',
|
|
77
|
+
'settings.verifyMatch': 'Match: the served zip is byte-identical to the local one (sha256 {hash})',
|
|
78
|
+
'settings.verifyMismatch': 'Mismatch: the served zip differs — re-upload {hash}',
|
|
79
|
+
'settings.verifyUnverified': 'Could not verify: {reason}',
|
|
80
|
+
'settings.installHint': 'Download fetches the zip whose wire version matches this plugin from the download server (sha256 is verified before the file is sent; a mismatch is refused). Then in JLCEDA Pro: Extensions → Import → select that zip → enable "Allow external interactions".',
|
|
81
|
+
} as const
|
|
82
|
+
|
|
83
|
+
export type EdaMcpKey = keyof typeof zh
|