@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,164 @@
1
+ /**
2
+ * Seam compatibility test: the exact shapes this plugin probes at runtime.
3
+ *
4
+ * `node --experimental-strip-types test/seams.test.ts`
5
+ * `DSH_SEAM_ROOT=<dir with node_modules> node --experimental-strip-types test/seams.test.ts`
6
+ *
7
+ * The second form runs the same assertions against another DSH generation — that
8
+ * is how a new `@deepseek-ai/*` version line is checked before widening the
9
+ * supported ranges (see `scripts/seam-check.mjs`).
10
+ */
11
+ import { readFileSync, existsSync } from 'node:fs'
12
+ import { join } from 'node:path'
13
+ import { pathToFileURL } from 'node:url'
14
+
15
+ const seamRoot = process.env.DSH_SEAM_ROOT ?? process.cwd()
16
+ let failures = 0
17
+
18
+ // --- extension version single source of truth ----------------------------
19
+ // The extension announces its version over the WebSocket. It once carried a
20
+ // hand-written constant that went stale (manifest 0.3.6, runtime 0.3.5), so the
21
+ // bridge reported a version mismatch no matter what was imported. The build
22
+ // injects the manifest version into the placeholder; keep it that way.
23
+ {
24
+ const extensionDir = join(process.cwd(), 'jlc-extension')
25
+ const manifest = JSON.parse(readFileSync(join(extensionDir, 'extension.json'), 'utf8')) as { version: string }
26
+ const bridgeSource = readFileSync(join(extensionDir, 'api-bridge.js'), 'utf8')
27
+ report('extension manifest declares a version', /^\d+\.\d+\.\d+$/.test(manifest.version), manifest.version)
28
+ report('api-bridge.js keeps the version placeholder', bridgeSource.includes('__EXTENSION_VERSION__'))
29
+ report('api-bridge.js has no hard-coded version constant', !/var VERSION = '\d/.test(bridgeSource))
30
+ }
31
+
32
+ function report(label: string, ok: boolean, detail = ''): void {
33
+ if (!ok) failures += 1
34
+ console.log(`${ok ? 'PASS' : 'FAIL'} ${label}${detail === '' ? '' : ' — ' + detail}`)
35
+ }
36
+
37
+ /** Resolve a package's entry point the way Node would, without installing it. */
38
+ function packageEntry(name: string): string | undefined {
39
+ const dir = join(seamRoot, 'node_modules', ...name.split('/'))
40
+ const manifest = join(dir, 'package.json')
41
+ if (!existsSync(manifest)) return undefined
42
+ const pkg = JSON.parse(readFileSync(manifest, 'utf8'))
43
+ const exported = pkg.exports?.['.'] ?? pkg.exports
44
+ const target = typeof exported === 'string'
45
+ ? exported
46
+ : (typeof exported === 'object' ? (exported.import ?? exported.default ?? exported.require) : undefined)
47
+ const main = typeof target === 'string' ? target : (pkg.main ?? 'index.js')
48
+ return join(dir, main)
49
+ }
50
+
51
+ async function load(name: string): Promise<{ version: string; module: Record<string, unknown> } | undefined> {
52
+ const entry = packageEntry(name)
53
+ if (entry === undefined) return undefined
54
+ const pkg = JSON.parse(readFileSync(join(seamRoot, 'node_modules', ...name.split('/'), 'package.json'), 'utf8'))
55
+ const module = await import(pathToFileURL(entry).href)
56
+ return { version: pkg.version, module: module as Record<string, unknown> }
57
+ }
58
+
59
+ const PACKAGES = [
60
+ '@deepseek-ai/dsh-mcp-client',
61
+ '@deepseek-ai/dsh-settings',
62
+ '@deepseek-ai/dsh-system-prompt',
63
+ '@deepseek-ai/dsh-host-webserver',
64
+ ]
65
+
66
+ console.log(`seam root: ${seamRoot}`)
67
+ const loaded = new Map<string, { version: string; module: Record<string, unknown> }>()
68
+
69
+ for (const name of PACKAGES) {
70
+ const result = await load(name)
71
+ if (result === undefined) {
72
+ // A missing package is a failed probe, never a pass: an install that only
73
+ // half-succeeded used to print SKIP lines and then "ALL PASS", which would
74
+ // let an unverified version line be adopted.
75
+ failures += 1
76
+ console.log(`FAIL ${name} — not installed under ${seamRoot}; the install did not deliver this seam package`)
77
+ continue
78
+ }
79
+ loaded.set(name, result)
80
+ console.log(` ${name} = ${result.version}`)
81
+ }
82
+
83
+ // --- dsh-mcp-client: inject ['tools'], stdio config keys, serverName guard ----
84
+ {
85
+ const client = loaded.get('@deepseek-ai/dsh-mcp-client')
86
+ if (client !== undefined) {
87
+ const plugin = (client.module.default ?? client.module.apply ?? client.module) as Record<string, unknown>
88
+ const inject = (plugin.inject ?? (client.module as Record<string, unknown>).inject) as string[] | undefined
89
+ report('mcp-client exposes an inject list containing "tools"', Array.isArray(inject) && inject.includes('tools'), JSON.stringify(inject))
90
+ const config = plugin.Config ?? (client.module as Record<string, unknown>).Config
91
+ let schemaText = ''
92
+ try { schemaText = JSON.stringify(config?.toJSON?.() ?? '') } catch { schemaText = '' }
93
+ for (const key of ['serverName', 'command', 'args', 'env', 'cwd', 'toolCallTimeoutMs', 'failOnStartupError', 'reconnect']) {
94
+ report(`mcp-client Config declares "${key}"`, schemaText.includes(`"${key}"`), '')
95
+ }
96
+ }
97
+ }
98
+
99
+ // --- dsh-settings: the three generation faces our installer probes ----------
100
+ {
101
+ const settings = loaded.get('@deepseek-ai/dsh-settings')
102
+ if (settings !== undefined) {
103
+ const m = settings.module
104
+ const provider = (m.default ?? m.SettingsForms ?? m.Settings ?? m) as unknown
105
+ const faces = typeof provider === 'function' ? (provider as unknown as { prototype?: Record<string, unknown> }).prototype ?? {} : (provider as Record<string, unknown>)
106
+ const hasAny = ['configure', 'installSection', 'register'].filter(key => typeof (faces as Record<string, unknown>)[key] === 'function')
107
+ report('dsh-settings still exposes a settings face (configure / installSection / register)', hasAny.length > 0, hasAny.join(',') || 'none')
108
+ const entryPoints = ['default', 'SettingsProvider', 'SettingsForms', 'Settings', 'installSettingsSection']
109
+ .filter(key => typeof (m as Record<string, unknown>)[key] === 'function')
110
+ report('dsh-settings exports a provider entry point', entryPoints.length > 0, entryPoints.join(',') || Object.keys(m).slice(0, 12).join(','))
111
+ }
112
+ }
113
+
114
+ // --- dsh-system-prompt: section({ name, order, text }) ----------------------
115
+ {
116
+ const prompt = loaded.get('@deepseek-ai/dsh-system-prompt')
117
+ if (prompt !== undefined) {
118
+ const m = prompt.module
119
+ const service = (m.SystemPrompt ?? m.default ?? m.Service) as unknown
120
+ const proto = typeof service === 'function' ? (service as { prototype?: Record<string, unknown> }).prototype ?? {} : (service as Record<string, unknown>)
121
+ report('dsh-system-prompt Service has section()', typeof (proto as Record<string, unknown>).section === 'function', '')
122
+ const source = readFileSync(packageEntry('@deepseek-ai/dsh-system-prompt')!, 'utf8')
123
+ const takesObject = /section\(\{\s*name/.test(source) || /name:\s*["']harness:identity/.test(source)
124
+ report('dsh-system-prompt section() is called with a single { name, order, text } object', takesObject, '')
125
+ }
126
+ }
127
+
128
+ // --- dsh-host-webserver: register({ kind: 'exact', path, handler }) ---------
129
+ {
130
+ const webserver = loaded.get('@deepseek-ai/dsh-host-webserver')
131
+ if (webserver !== undefined) {
132
+ const source = readFileSync(packageEntry('@deepseek-ai/dsh-host-webserver')!, 'utf8')
133
+ report('dsh-host-webserver keeps the exact/prefix route tables', /route\.kind === "exact"/.test(source) || /route\.kind === 'exact'/.test(source), '')
134
+ report('dsh-host-webserver register() returns a disposer', /register\(route\)[\s\S]{0,400}table\.delete\(route\.path\)/.test(source), '')
135
+ }
136
+ }
137
+
138
+ // --- client-side packages: nothing is asserted, only recorded --------------
139
+ for (const name of ['@deepseek-ai/dsh-client-ui-slots', '@deepseek-ai/dsh-client-locale', '@deepseek-ai/dsh-client-ui-settings']) {
140
+ const entry = packageEntry(name)
141
+ if (entry !== undefined) {
142
+ const pkg = JSON.parse(readFileSync(join(seamRoot, 'node_modules', ...name.split('/'), 'package.json'), 'utf8'))
143
+ console.log(` (client) ${name} = ${pkg.version}`)
144
+ }
145
+ }
146
+
147
+ console.log(failures === 0 ? '\nALL PASS' : `\n${failures} FAILED`)
148
+ process.exit(failures === 0 ? 0 : 1)
149
+
150
+ // --- CI workflows must reference artefacts the build actually produces -------
151
+ // Two released pipelines broke on this exact class of drift: the bundle-path guard
152
+ // flagged our own documentation string, and check.yml uploaded an unversioned zip the
153
+ // build had stopped producing. Both are asserted here instead of being rediscovered.
154
+ {
155
+ const check = readFileSync(join(root, '.github/workflows/check.yml'), 'utf8')
156
+ const publish = readFileSync(join(root, '.github/workflows/publish.yml'), 'utf8')
157
+ report('check.yml uploads the versioned zip glob', check.includes('dsh-eda-bridge-extension-*.zip'))
158
+ report('check.yml runs the shared bundle guard', check.includes('pnpm guard:bundle'))
159
+ report('publish.yml runs the shared bundle guard', publish.includes('pnpm guard:bundle'))
160
+ report('no workflow re-implements the path guard inline', !/Select-String[\s\S]{0,200}node_modules/.test(check + publish))
161
+ const pkgJson = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'))
162
+ report('guard:bundle is wired into the scripts', typeof pkgJson.scripts?.['guard:bundle'] === 'string')
163
+ report('pnpm check runs the bundle guard', String(pkgJson.scripts?.check ?? '').includes('guard:bundle'))
164
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * The plugin registers its JLCEDA project playbook as a DSH skill. These assertions
3
+ * pin the provider contract AND the completeness of the manual: every section has to
4
+ * be there, because an incomplete playbook is what makes an agent improvise.
5
+ *
6
+ * `node --experimental-strip-types test/skills.test.ts`
7
+ */
8
+ import { EDA_SKILL_NAME, EDA_SKILL_PROVIDER, createEdaSkillProvider, skillBody, skillLineCount } from '../src/skills.ts'
9
+ import { SKILL_SECTIONS } from '../src/skills-content.ts'
10
+
11
+ let failures = 0
12
+ function report(label: string, ok: boolean, detail = ''): void {
13
+ if (!ok) failures += 1
14
+ console.log((ok ? 'PASS ' : 'FAIL ') + label + (detail === '' ? '' : ' — ' + detail))
15
+ }
16
+
17
+ const provider = createEdaSkillProvider()
18
+ const candidates = await provider.list()
19
+ const candidate = candidates[0]
20
+ const body = skillBody()
21
+
22
+ report('provider name is stable', provider.name === EDA_SKILL_PROVIDER, provider.name)
23
+ report('exactly one skill is offered', candidates.length === 1, String(candidates.length))
24
+ report('skill name is kebab-case', /^[a-z0-9]+(-[a-z0-9]+)*$/.test(EDA_SKILL_NAME), EDA_SKILL_NAME)
25
+ report('skill is model and user invocable', candidate.invocation.modelInvocable === true && candidate.invocation.userInvocable === true)
26
+ report('description states a trigger', candidate.description.includes('TRIGGER when'))
27
+ report('description states a non-trigger', candidate.description.includes('DO NOT TRIGGER'))
28
+ report('rank beats the user root (400)', candidate.rank > 400, String(candidate.rank))
29
+ report('playbook has every section (17: intake + base + PCB + external + delivery)', SKILL_SECTIONS.length === 17, String(SKILL_SECTIONS.length))
30
+ report('playbook is a real manual, not a summary', body.length > 6000 && skillLineCount() > 120, body.length + ' chars / ' + skillLineCount() + ' lines')
31
+
32
+ const definition = await provider.get(candidate)
33
+ report('definition carries the body', definition?.content === body)
34
+
35
+ for (const section of SKILL_SECTIONS) {
36
+ report('section present: ' + section.replace('## ', ''), body.includes(section))
37
+ }
38
+
39
+ const required = [
40
+ 'mcp__jlceda__',
41
+ 'eda_import_project',
42
+ 'eda_place_net_labels',
43
+ 'eda_move_component',
44
+ 'eda_export_netlist',
45
+ 'eda_run_drc',
46
+ 'pcb_import_changes',
47
+ 'pcb_draw_board_outline',
48
+ 'pcb_create_pour',
49
+ 'eda_design_audit',
50
+ 'eda_pcb_export_gerber',
51
+ 'eda_get_net_labels',
52
+ 'eda_list_api_methods',
53
+ '| 现象 | 原因 | 动作 |',
54
+ '## 12. 环境与生效规则(全新会话必读)',
55
+ '重启 DSH',
56
+ '重新导入',
57
+ '/api/dsh-eda-mcp/diagnostics',
58
+ 'activated:false',
59
+ '只递增最小位',
60
+ ]
61
+ for (const token of required) {
62
+ report('manual mentions ' + token, body.includes(token))
63
+ }
64
+
65
+ report('unknown skill resolves to undefined', (await provider.get({ ...candidate, name: 'nope' })) === undefined)
66
+
67
+ if (failures === 0) console.log('ALL PASS')
68
+ else { console.log(failures + ' FAILED'); process.exitCode = 1 }