@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,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* eda-launch: executable discovery and launch argument shaping.
|
|
3
|
+
*
|
|
4
|
+
* `node --experimental-strip-types test/eda-launch.test.ts`
|
|
5
|
+
*
|
|
6
|
+
* No process is spawned: the resolver takes a `LaunchProbe` seam and the registry
|
|
7
|
+
* output is fed as text, so the cases below run identically on any machine.
|
|
8
|
+
*/
|
|
9
|
+
import {
|
|
10
|
+
buildLaunchArgs, buildLaunchScript, decodeRegistryOutput, envCandidates, parseExecutableFromCommand, parseRegStringValue,
|
|
11
|
+
parseRegValueNames, pathCandidates, registryCandidates, resolveExecutable,
|
|
12
|
+
type LaunchProbe,
|
|
13
|
+
} from '../src/bridge/eda-launch.ts'
|
|
14
|
+
|
|
15
|
+
let failures = 0
|
|
16
|
+
function check(label: string, actual: unknown, expected: unknown): void {
|
|
17
|
+
const ok = JSON.stringify(actual) === JSON.stringify(expected)
|
|
18
|
+
if (!ok) failures += 1
|
|
19
|
+
console.log(`${ok ? 'PASS' : 'FAIL'} ${label}`)
|
|
20
|
+
if (!ok) console.log(` got ${JSON.stringify(actual)}\n expected ${JSON.stringify(expected)}`)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function probe(overrides: Partial<LaunchProbe> & { files?: string[] } = {}): LaunchProbe {
|
|
24
|
+
const files = new Set(overrides.files ?? [])
|
|
25
|
+
return {
|
|
26
|
+
platform: overrides.platform ?? 'win32',
|
|
27
|
+
env: overrides.env ?? {},
|
|
28
|
+
exists: overrides.exists ?? ((path: string) => files.has(path)),
|
|
29
|
+
registryQuery: overrides.registryQuery ?? (() => undefined),
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// --- command line parsing ------------------------------------------------
|
|
34
|
+
check('quoted exe with %1', parseExecutableFromCommand('"D:\\lceda-pro\\lceda-pro.exe" "%1"'), 'D:\\lceda-pro\\lceda-pro.exe')
|
|
35
|
+
check('unquoted exe with %1', parseExecutableFromCommand('C:\\App\\lceda-pro.exe %1'), 'C:\\App\\lceda-pro.exe')
|
|
36
|
+
check('quoted exe without args', parseExecutableFromCommand('"C:\\Program Files\\LCEDA Pro\\lceda-pro.exe"'), 'C:\\Program Files\\LCEDA Pro\\lceda-pro.exe')
|
|
37
|
+
check('empty command', parseExecutableFromCommand(''), undefined)
|
|
38
|
+
check('undefined command', parseExecutableFromCommand(undefined), undefined)
|
|
39
|
+
check('unterminated quote is rejected', parseExecutableFromCommand('"C:\\broken'), undefined)
|
|
40
|
+
|
|
41
|
+
// --- registry output decoding -------------------------------------------
|
|
42
|
+
const gbkBytes = Buffer.from([0xBC, 0xD1, 0xC1, 0xA2, 0xB4, 0xB4]) // 佳立创 in GBK
|
|
43
|
+
check('GBK bytes decode to the right characters', decodeRegistryOutput(gbkBytes), '佳立创')
|
|
44
|
+
check('plain ASCII stays as-is', decodeRegistryOutput(Buffer.from(' X REG_SZ abc', 'utf8')), ' X REG_SZ abc')
|
|
45
|
+
check('valid UTF-8 is not re-decoded', decodeRegistryOutput(Buffer.from('嘉立创', 'utf8')), '嘉立创')
|
|
46
|
+
|
|
47
|
+
// --- registry output parsing --------------------------------------------
|
|
48
|
+
const regDefault = `\r\nHKEY_CURRENT_USER\\Software\\Classes\\嘉立创EDA库文件\\shell\\open\\command\r\n (默认) REG_SZ "D:\\lceda-pro\\lceda-pro.exe" "%1"\r\n\r\n`
|
|
49
|
+
check('REG_SZ payload', parseRegStringValue(regDefault), '"D:\\lceda-pro\\lceda-pro.exe" "%1"')
|
|
50
|
+
check('missing REG_SZ', parseRegStringValue('no such key'), undefined)
|
|
51
|
+
check('OpenWithProgids names', parseRegValueNames('HKEY_CURRENT_USER\\Software\\Classes\\.eprj2\\OpenWithProgids\r\n MyProgid REG_NONE\r\n Other REG_NONE\r\n'), ['MyProgid', 'Other'])
|
|
52
|
+
check('empty OpenWithProgids', parseRegValueNames(''), [])
|
|
53
|
+
|
|
54
|
+
// --- resolution order ----------------------------------------------------
|
|
55
|
+
const exeFromRegistry = 'D:\\lceda-pro\\lceda-pro.exe'
|
|
56
|
+
const registryOutput = (key: string): string | undefined => {
|
|
57
|
+
if (key.endsWith('.eprj2\\OpenWithProgids')) return ' JlcProEdaFile REG_NONE\r\n'
|
|
58
|
+
if (key.endsWith('JlcProEdaFile\\shell\\open\\command')) return ' (默认) REG_SZ "D:\\lceda-pro\\lceda-pro.exe" "%1"\r\n'
|
|
59
|
+
return undefined
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
check('registry hit', resolveExecutable(probe({ files: [exeFromRegistry], registryQuery: registryOutput })), { executable: exeFromRegistry, source: 'registry' })
|
|
63
|
+
|
|
64
|
+
check('config override wins', resolveExecutable(
|
|
65
|
+
probe({ files: ['C:\\custom\\lceda.exe', exeFromRegistry], registryQuery: registryOutput }),
|
|
66
|
+
{ executable: 'C:\\custom\\lceda.exe' },
|
|
67
|
+
), { executable: 'C:\\custom\\lceda.exe', source: 'config' })
|
|
68
|
+
|
|
69
|
+
check('a missing config override is skipped', resolveExecutable(
|
|
70
|
+
probe({ files: [exeFromRegistry], registryQuery: registryOutput }),
|
|
71
|
+
{ executable: 'C:\\does\\not\\exist.exe' },
|
|
72
|
+
), { executable: exeFromRegistry, source: 'registry' })
|
|
73
|
+
|
|
74
|
+
check('env var used when config is absent', resolveExecutable(
|
|
75
|
+
probe({ env: { DSH_EDA_EXECUTABLE: 'E:\\eda\\lceda-pro.exe' }, files: ['E:\\eda\\lceda-pro.exe', exeFromRegistry], registryQuery: registryOutput }),
|
|
76
|
+
), { executable: 'E:\\eda\\lceda-pro.exe', source: 'env' })
|
|
77
|
+
|
|
78
|
+
check('second env key is honoured', resolveExecutable(
|
|
79
|
+
probe({ env: { JLCEDA_EXECUTABLE: 'E:\\eda2\\lceda-pro.exe' }, files: ['E:\\eda2\\lceda-pro.exe'] }),
|
|
80
|
+
), { executable: 'E:\\eda2\\lceda-pro.exe', source: 'env' })
|
|
81
|
+
|
|
82
|
+
const programFilesExe = 'C:\\Program Files\\lceda-pro\\lceda-pro.exe'
|
|
83
|
+
check('install dir candidate', resolveExecutable(
|
|
84
|
+
probe({ env: { ProgramFiles: 'C:\\Program Files' }, files: [programFilesExe] }),
|
|
85
|
+
), { executable: programFilesExe, source: 'install-dir' })
|
|
86
|
+
|
|
87
|
+
check('PATH candidate', resolveExecutable(
|
|
88
|
+
probe({ env: { PATH: 'C:\\tools;D:\\bin' }, files: ['D:\\bin\\lceda-pro.exe'] }),
|
|
89
|
+
), { executable: 'D:\\bin\\lceda-pro.exe', source: 'path' })
|
|
90
|
+
|
|
91
|
+
check('nothing found', resolveExecutable(probe({ env: {} })), undefined)
|
|
92
|
+
check('registry is ignored off Windows', registryCandidates(probe({ platform: 'linux' })), [])
|
|
93
|
+
|
|
94
|
+
// --- candidate generation ------------------------------------------------
|
|
95
|
+
check('install candidates include Program Files', envCandidates(probe({ env: { ProgramFiles: 'C:\\Program Files' } })).includes(programFilesExe), true)
|
|
96
|
+
check('PATH candidates split on ;', pathCandidates(probe({ env: { PATH: 'A;B' } })), ['A\\lceda-pro.exe', 'A\\lceda-pro', 'A\\LCEDA Pro', 'B\\lceda-pro.exe', 'B\\lceda-pro', 'B\\LCEDA Pro'])
|
|
97
|
+
check('PATH candidates split on : off Windows', pathCandidates(probe({ platform: 'linux', env: { PATH: '/usr/bin:/opt' } })).slice(0, 2), ['/usr/bin/lceda-pro.exe', '/usr/bin/lceda-pro'])
|
|
98
|
+
|
|
99
|
+
// --- launch arguments ----------------------------------------------------
|
|
100
|
+
check('windows without project', buildLaunchArgs('win32', 'D:\\lceda-pro\\lceda-pro.exe'), { command: 'D:\\lceda-pro\\lceda-pro.exe', args: [] })
|
|
101
|
+
check('windows with project', buildLaunchArgs('win32', 'D:\\lceda-pro\\lceda-pro.exe', 'D:\\p\\a.eprj2'), { command: 'D:\\lceda-pro\\lceda-pro.exe', args: ['D:\\p\\a.eprj2'] })
|
|
102
|
+
check('blank project is ignored', buildLaunchArgs('win32', 'X.exe', ' '), { command: 'X.exe', args: [] })
|
|
103
|
+
check('macOS opens the app bundle', buildLaunchArgs('darwin', '/Applications/LCEDA Pro.app'), { command: 'open', args: ['-a', '/Applications/LCEDA Pro.app'] })
|
|
104
|
+
check('macOS opens the document', buildLaunchArgs('darwin', '/Applications/LCEDA Pro.app', '/p/a.eprj2'), { command: 'open', args: ['-a', '/Applications/LCEDA Pro.app', '/p/a.eprj2'] })
|
|
105
|
+
check('linux runs the binary', buildLaunchArgs('linux', '/opt/lceda-pro', '/p/a.eprj2'), { command: '/opt/lceda-pro', args: ['/p/a.eprj2'] })
|
|
106
|
+
|
|
107
|
+
// --- Windows hand-off script (explorer launch) ---------------------------
|
|
108
|
+
const scriptLines = buildLaunchScript('D:\\lceda-pro\\lceda-pro.exe').split('\r\n')
|
|
109
|
+
check('script starts with echo off', scriptLines[0], '@echo off')
|
|
110
|
+
check('script starts the app', scriptLines[1], 'start "" "D:\\lceda-pro\\lceda-pro.exe"')
|
|
111
|
+
check('script with a project quotes both paths', buildLaunchScript('C:\\a b\\lceda-pro.exe', 'D:\\p q\\x.eprj2').split('\r\n')[1], 'start "" "C:\\a b\\lceda-pro.exe" "D:\\p q\\x.eprj2"')
|
|
112
|
+
|
|
113
|
+
console.log(failures === 0 ? '\nALL PASS' : `\n${failures} FAILED`)
|
|
114
|
+
process.exit(failures === 0 ? 0 : 1)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { strict as assert } from 'node:assert'
|
|
2
|
+
import { compareDigest, extensionDownloadUrl, extensionZipName, sha256Of } from '../src/bridge/extension-package.ts'
|
|
3
|
+
|
|
4
|
+
const bytes = new TextEncoder().encode('PK\x03\x04fake-zip-body')
|
|
5
|
+
assert.equal(sha256Of(bytes), sha256Of(bytes), 'hash is stable')
|
|
6
|
+
assert.equal(sha256Of(bytes).length, 64, 'sha256 hex length')
|
|
7
|
+
assert.notEqual(sha256Of(bytes), sha256Of(new TextEncoder().encode('other')), 'different bytes differ')
|
|
8
|
+
|
|
9
|
+
assert.equal(extensionZipName('0.4.9'), 'dsh-eda-bridge-extension-0.4.9.zip')
|
|
10
|
+
assert.equal(
|
|
11
|
+
extensionDownloadUrl('http://159.75.130.207/eda', '0.4.9'),
|
|
12
|
+
'http://159.75.130.207/eda/dsh-eda-bridge-extension-0.4.9.zip',
|
|
13
|
+
'base without a trailing slash gets one',
|
|
14
|
+
)
|
|
15
|
+
assert.equal(
|
|
16
|
+
extensionDownloadUrl('https://example.test/dl/', '1.2.3'),
|
|
17
|
+
'https://example.test/dl/dsh-eda-bridge-extension-1.2.3.zip',
|
|
18
|
+
'trailing slash is not doubled',
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
assert.equal(compareDigest('ABC', 'abc'), 'match', 'case-insensitive')
|
|
22
|
+
assert.equal(compareDigest('aa', 'bb'), 'mismatch')
|
|
23
|
+
assert.equal(compareDigest(null, 'bb'), 'unverified', 'missing expected is not a pass')
|
|
24
|
+
assert.equal(compareDigest('aa', undefined), 'unverified')
|
|
25
|
+
assert.equal(compareDigest('', ''), 'unverified')
|
|
26
|
+
|
|
27
|
+
console.log('ALL PASS extension-package')
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { strict as assert } from 'node:assert'
|
|
2
|
+
import { createServer } from 'node:http'
|
|
3
|
+
import { mkdtempSync, writeFileSync } from 'node:fs'
|
|
4
|
+
import { tmpdir } from 'node:os'
|
|
5
|
+
import { join } from 'node:path'
|
|
6
|
+
import { makeEdaMcpRoutes, EDA_MCP_API } from '../src/routes.ts'
|
|
7
|
+
import { sha256Of } from '../src/bridge/extension-package.ts'
|
|
8
|
+
|
|
9
|
+
// The package ships no zip: only lib/extension-digest.json. These cases pin the contract that
|
|
10
|
+
// the download route serves the SERVER copy but only after it matches the build digest.
|
|
11
|
+
const goodBytes = Buffer.from('PK\x03\x04 pretending to be the extension zip')
|
|
12
|
+
const goodSha = sha256Of(goodBytes)
|
|
13
|
+
const digestDir = mkdtempSync(join(tmpdir(), 'dsh-digest-'))
|
|
14
|
+
const digestPath = join(digestDir, 'extension-digest.json')
|
|
15
|
+
writeFileSync(digestPath, JSON.stringify({
|
|
16
|
+
version: '0.4.9',
|
|
17
|
+
file: 'dsh-eda-bridge-extension-0.4.9.zip',
|
|
18
|
+
bytes: goodBytes.byteLength,
|
|
19
|
+
sha256: goodSha,
|
|
20
|
+
}))
|
|
21
|
+
|
|
22
|
+
function fakeReq(method: string, url = '/') {
|
|
23
|
+
return { method, url, socket: { remoteAddress: '127.0.0.1' }, headers: { host: '127.0.0.1' } }
|
|
24
|
+
}
|
|
25
|
+
function fakeRes() {
|
|
26
|
+
const captured: { status?: number; headers?: Record<string, string>; body?: unknown; bytes?: Buffer } = {}
|
|
27
|
+
const res = {
|
|
28
|
+
writeHead(status: number, headers: Record<string, string>) { captured.status = status; captured.headers = headers; return res },
|
|
29
|
+
end(payload?: unknown) { if (Buffer.isBuffer(payload)) captured.bytes = payload; else if (typeof payload === 'string') captured.body = payload; return res },
|
|
30
|
+
destroy() { return res }, getHeader() { return undefined }, setHeader() { return res },
|
|
31
|
+
}
|
|
32
|
+
return { res, captured }
|
|
33
|
+
}
|
|
34
|
+
function deps(base: string) {
|
|
35
|
+
return {
|
|
36
|
+
getConfig: () => ({}),
|
|
37
|
+
extensionDigestPath: digestPath,
|
|
38
|
+
extensionVersion: '0.4.9',
|
|
39
|
+
extensionDownloadBase: base,
|
|
40
|
+
reconnect: () => {},
|
|
41
|
+
bridgeLaunch: () => ({ command: 'node', args: [], source: 'test' }),
|
|
42
|
+
diagnostics: () => ({}),
|
|
43
|
+
launchConfig: () => ({}),
|
|
44
|
+
selfTest: async () => ({}),
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function routeOf(routes: ReturnType<typeof makeEdaMcpRoutes>, path: string) {
|
|
48
|
+
const route = routes.find(r => r.path === path)
|
|
49
|
+
assert.ok(route, 'route ' + path + ' must exist')
|
|
50
|
+
return route
|
|
51
|
+
}
|
|
52
|
+
async function withServer(handler: Parameters<typeof createServer>[1], run: (base: string) => Promise<void>) {
|
|
53
|
+
const server = createServer(handler)
|
|
54
|
+
await new Promise<void>(resolve => server.listen(0, '127.0.0.1', resolve))
|
|
55
|
+
const port = (server.address() as { port: number }).port
|
|
56
|
+
try { await run('http://127.0.0.1:' + port + '/eda/') } finally { await new Promise<void>(resolve => server.close(() => resolve())) }
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 1. matching served copy -> handed out, labelled as coming from the server
|
|
60
|
+
await withServer((_req, res) => { res.writeHead(200); res.end(goodBytes) }, async (base) => {
|
|
61
|
+
const { res, captured } = fakeRes()
|
|
62
|
+
await routeOf(makeEdaMcpRoutes(deps(base)), EDA_MCP_API.extensionZip).handler(fakeReq('GET') as never, res as never)
|
|
63
|
+
assert.equal(captured.status, 200)
|
|
64
|
+
assert.equal(captured.headers?.['x-extension-source'], 'server')
|
|
65
|
+
assert.equal(captured.headers?.['x-extension-sha256'], goodSha)
|
|
66
|
+
assert.equal(captured.headers?.['content-disposition'], 'attachment; filename="dsh-eda-bridge-extension-0.4.9.zip"')
|
|
67
|
+
assert.equal(sha256Of(captured.bytes as Buffer), goodSha, 'the bytes handed out are the served ones')
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
// 2. different wire version served -> refused, nothing downloaded
|
|
71
|
+
await withServer((_req, res) => { res.writeHead(200); res.end(Buffer.from('some other build')) }, async (base) => {
|
|
72
|
+
const { res, captured } = fakeRes()
|
|
73
|
+
await routeOf(makeEdaMcpRoutes(deps(base)), EDA_MCP_API.extensionZip).handler(fakeReq('GET') as never, res as never)
|
|
74
|
+
const body = JSON.parse(String(captured.body))
|
|
75
|
+
assert.equal(captured.status, 502)
|
|
76
|
+
assert.equal(body.expected.sha256, goodSha)
|
|
77
|
+
assert.equal(String(body.error).includes('refusing'), true)
|
|
78
|
+
assert.equal(captured.bytes, undefined, 'no bytes may be handed out on mismatch')
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
// 3. throttled server -> 429 surfaced as throttling
|
|
82
|
+
await withServer((_req, res) => { res.writeHead(429); res.end('slow down') }, async (base) => {
|
|
83
|
+
const { res, captured } = fakeRes()
|
|
84
|
+
await routeOf(makeEdaMcpRoutes(deps(base)), EDA_MCP_API.extensionZip).handler(fakeReq('GET') as never, res as never)
|
|
85
|
+
const body = JSON.parse(String(captured.body))
|
|
86
|
+
assert.equal(captured.status, 429)
|
|
87
|
+
assert.equal(body.httpStatus, 429)
|
|
88
|
+
assert.equal(String(body.error).includes('throttled'), true)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
// 4. verify route compares against the digest without any local zip
|
|
92
|
+
await withServer((_req, res) => { res.writeHead(200); res.end(goodBytes) }, async (base) => {
|
|
93
|
+
const { res, captured } = fakeRes()
|
|
94
|
+
await routeOf(makeEdaMcpRoutes(deps(base)), EDA_MCP_API.extensionVerify).handler(fakeReq('GET') as never, res as never)
|
|
95
|
+
const body = JSON.parse(String(captured.body))
|
|
96
|
+
assert.equal(body.verified, 'match')
|
|
97
|
+
assert.equal(body.expected.sha256, goodSha)
|
|
98
|
+
})
|
|
99
|
+
await withServer((_req, res) => { res.writeHead(200); res.end(Buffer.from('other')) }, async (base) => {
|
|
100
|
+
const { res, captured } = fakeRes()
|
|
101
|
+
await routeOf(makeEdaMcpRoutes(deps(base)), EDA_MCP_API.extensionVerify).handler(fakeReq('GET') as never, res as never)
|
|
102
|
+
const body = JSON.parse(String(captured.body))
|
|
103
|
+
assert.equal(body.verified, 'mismatch')
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
// 5. info route needs no network and reports the build digest
|
|
107
|
+
await withServer((_req, res) => { res.writeHead(500); res.end('must not be called') }, async (base) => {
|
|
108
|
+
const { res, captured } = fakeRes()
|
|
109
|
+
await routeOf(makeEdaMcpRoutes(deps(base)), EDA_MCP_API.extensionInfo).handler(fakeReq('GET') as never, res as never)
|
|
110
|
+
const body = JSON.parse(String(captured.body))
|
|
111
|
+
assert.equal(body.version, '0.4.9')
|
|
112
|
+
assert.equal(body.sha256, goodSha)
|
|
113
|
+
assert.equal(body.source, 'server')
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
console.log('ALL PASS extension-routes')
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { parseNetlist, runNetlistErc } from '../src/bridge/netlist-erc.ts'
|
|
2
|
+
|
|
3
|
+
let failed = 0
|
|
4
|
+
const report = (name: string, ok: boolean, detail: string) => {
|
|
5
|
+
if (!ok) failed += 1
|
|
6
|
+
console.log((ok ? 'PASS ' : 'FAIL ') + name + (ok ? '' : ' — ' + detail))
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const component = (designator: string, part: string, pins: Array<[string, string, string]>) => ({
|
|
10
|
+
props: { Designator: designator, 'Manufacturer Part': part, Footprint: designator + '-fp' },
|
|
11
|
+
pinInfoMap: Object.fromEntries(pins.map(([number, name, net]) => ['p' + number, { number, name, net }])),
|
|
12
|
+
})
|
|
13
|
+
const netlist = (components: any[]) => ({ components: Object.fromEntries(components.map((c, i) => ['u' + i, c])) })
|
|
14
|
+
|
|
15
|
+
// 1. a healthy minimal design passes
|
|
16
|
+
const good = netlist([
|
|
17
|
+
component('U1', 'STM32F103C8T6', [['1', 'VDD', '3V3'], ['2', 'VSS', 'GND'], ['5', 'OSC_IN', 'OSC_IN'], ['6', 'OSC_OUT', 'OSC_OUT'], ['7', 'NRST', 'NRST'], ['8', 'BOOT0', 'BOOT0']]),
|
|
18
|
+
component('Y1', '8MHz', [['1', 'X1', 'OSC_IN'], ['2', 'X2', 'OSC_OUT']]),
|
|
19
|
+
component('C1', '100nF', [['1', '1', '3V3'], ['2', '2', 'GND']]),
|
|
20
|
+
component('C2', '22pF', [['1', '1', 'OSC_IN'], ['2', '2', 'GND']]),
|
|
21
|
+
component('C3', '22pF', [['1', '1', 'OSC_OUT'], ['2', '2', 'GND']]),
|
|
22
|
+
component('C4', '100nF', [['1', '1', 'NRST'], ['2', '2', 'GND']]),
|
|
23
|
+
component('R1', '10k', [['1', '1', 'NRST'], ['2', '2', '3V3']]),
|
|
24
|
+
component('R2', '10k', [['1', '1', 'BOOT0'], ['2', '2', 'GND']]),
|
|
25
|
+
component('U2', 'LDO', [['1', 'VIN', '5V'], ['2', 'VOUT', '3V3'], ['3', 'GND', 'GND']]),
|
|
26
|
+
component('C5', '10uF', [['1', '1', '5V'], ['2', '2', 'GND']]),
|
|
27
|
+
])
|
|
28
|
+
const goodReport = runNetlistErc(good)
|
|
29
|
+
report('healthy design has no failures', goodReport.ok, JSON.stringify(goodReport.checks.filter(c => c.status === 'fail')))
|
|
30
|
+
report('healthy design finds no dangling nets', goodReport.checks.find(c => c.id === 'dangling-net')?.status === 'pass', '')
|
|
31
|
+
report('crystal check passes', goodReport.checks.find(c => c.id === 'crystal')?.status === 'pass', String(goodReport.checks.find(c => c.id === 'crystal')?.details))
|
|
32
|
+
report('reset check passes', goodReport.checks.find(c => c.id === 'reset')?.status === 'pass', '')
|
|
33
|
+
report('boot check passes', goodReport.checks.find(c => c.id === 'boot')?.status === 'pass', '')
|
|
34
|
+
report('component and net counts', goodReport.componentCount === 10 && goodReport.netCount >= 7, goodReport.componentCount + '/' + goodReport.netCount)
|
|
35
|
+
|
|
36
|
+
// 2. dangling net (single endpoint) fails
|
|
37
|
+
const dangling = runNetlistErc(netlist([
|
|
38
|
+
component('U1', 'STM32F103C8T6', [['1', 'VDD', '3V3'], ['2', 'VSS', 'GND'], ['3', 'PA1', 'PA1']]),
|
|
39
|
+
component('C1', '100nF', [['1', '1', '3V3'], ['2', '2', 'GND']]),
|
|
40
|
+
]))
|
|
41
|
+
report('single-endpoint net fails', dangling.checks.find(c => c.id === 'dangling-net')?.status === 'fail', '')
|
|
42
|
+
report('report ok=false when a net dangles', dangling.ok === false, '')
|
|
43
|
+
|
|
44
|
+
// 3. a part shorted onto one net (the measured 'series resistor with the same net on both ends')
|
|
45
|
+
const shorted = runNetlistErc(netlist([
|
|
46
|
+
component('U1', 'STM32F103C8T6', [['1', 'VDD', '3V3'], ['2', 'VSS', 'GND']]),
|
|
47
|
+
component('R1', '22R', [['1', '1', 'USB_DP'], ['2', '2', 'USB_DP']]),
|
|
48
|
+
component('U2', 'USB', [['1', 'D+', 'USB_DP'], ['2', 'D-', 'USB_DM'], ['3', 'GND', 'GND']]),
|
|
49
|
+
component('C1', '100nF', [['1', '1', '3V3'], ['2', '2', 'GND']]),
|
|
50
|
+
]))
|
|
51
|
+
report('shorted component fails', shorted.checks.find(c => c.id === 'shorted-component')?.status === 'fail', '')
|
|
52
|
+
|
|
53
|
+
// 4. USB pair missing D-
|
|
54
|
+
const usb = runNetlistErc(netlist([
|
|
55
|
+
component('U1', 'STM32F103C8T6', [['1', 'VDD', '3V3'], ['2', 'VSS', 'GND'], ['5', 'PA12', 'USB_DP']]),
|
|
56
|
+
component('C1', '100nF', [['1', '1', '3V3'], ['2', '2', 'GND']]),
|
|
57
|
+
component('J1', 'USB-C', [['1', 'D+', 'USB_DP'], ['2', 'CC1', 'CC1']]),
|
|
58
|
+
]))
|
|
59
|
+
report('USB pair check fails without D-', usb.checks.find(c => c.id === 'usb-data-pair')?.status === 'fail', '')
|
|
60
|
+
report('Type-C CC warns without a pull-down', usb.checks.find(c => c.id === 'type-c-cc')?.status === 'warn', '')
|
|
61
|
+
|
|
62
|
+
// 5. decoupling gap
|
|
63
|
+
const noDecoupling = runNetlistErc(netlist([
|
|
64
|
+
component('U1', 'STM32F103C8T6', [['1', 'VDD', '3V3'], ['2', 'VSS', 'GND']]),
|
|
65
|
+
]))
|
|
66
|
+
report('decoupling warns when a rail has no capacitor', noDecoupling.checks.find(c => c.id === 'decoupling')?.status === 'warn', '')
|
|
67
|
+
|
|
68
|
+
// 6. crystal without load cap
|
|
69
|
+
const crystal = runNetlistErc(netlist([
|
|
70
|
+
component('U1', 'STM32F103C8T6', [['1', 'VDD', '3V3'], ['2', 'VSS', 'GND'], ['5', 'OSC_IN', 'OSC_IN'], ['6', 'OSC_OUT', 'OSC_OUT']]),
|
|
71
|
+
component('Y1', '8MHz', [['1', 'X1', 'OSC_IN'], ['2', 'X2', 'OSC_OUT']]),
|
|
72
|
+
component('C1', '100nF', [['1', '1', '3V3'], ['2', '2', 'GND']]),
|
|
73
|
+
]))
|
|
74
|
+
report('crystal warns without load caps', crystal.checks.find(c => c.id === 'crystal')?.status === 'warn', String(crystal.checks.find(c => c.id === 'crystal')?.details))
|
|
75
|
+
|
|
76
|
+
// 7. unconnected pin + duplicate designator
|
|
77
|
+
const messy = runNetlistErc(netlist([
|
|
78
|
+
component('U1', 'STM32F103C8T6', [['1', 'VDD', '3V3'], ['2', 'VSS', 'GND'], ['3', 'PA1', '']]),
|
|
79
|
+
component('U1', 'STM32F103C8T6', [['1', 'VDD', '3V3'], ['2', 'VSS', 'GND']]),
|
|
80
|
+
]))
|
|
81
|
+
report('unconnected pin warns', messy.checks.find(c => c.id === 'unconnected-pin')?.status === 'warn', '')
|
|
82
|
+
report('duplicate designator fails', messy.checks.find(c => c.id === 'duplicate-designator')?.status === 'fail', '')
|
|
83
|
+
|
|
84
|
+
// 8. empty netlist is a skip, not a crash
|
|
85
|
+
const empty = runNetlistErc({})
|
|
86
|
+
report('empty netlist skips', empty.checks.length === 1 && empty.checks[0].status === 'skip', JSON.stringify(empty.checks))
|
|
87
|
+
report('parseNetlist survives junk', parseNetlist(null).components.length === 0, '')
|
|
88
|
+
|
|
89
|
+
console.log(failed === 0 ? 'ALL PASS' : failed + ' FAILED')
|
|
90
|
+
if (failed > 0) process.exitCode = 1
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node-executable resolution test.
|
|
3
|
+
*
|
|
4
|
+
* Runs on the Node the plugin requires (`engines.node >= 22.19`), which strips
|
|
5
|
+
* the TS types itself: `node --experimental-strip-types test/node-runtime.test.ts`.
|
|
6
|
+
*/
|
|
7
|
+
import { resolveBridgeRuntime } from '../src/node-runtime.ts'
|
|
8
|
+
|
|
9
|
+
const APP = 'D:\\DeepSeek Harness\\DeepSeek Harness.exe'
|
|
10
|
+
const PAYLOAD_NODE = 'D:\\DeepSeek Harness\\resources\\runtime\\primary-runtime\\dependencies\\node\\bin\\node.exe'
|
|
11
|
+
const PATH_NODE = 'C:\\tools\\nodejs\\node.exe'
|
|
12
|
+
|
|
13
|
+
let failures = 0
|
|
14
|
+
function check(label: string, actual: unknown, expected: unknown): void {
|
|
15
|
+
const ok = JSON.stringify(actual) === JSON.stringify(expected)
|
|
16
|
+
if (!ok) failures += 1
|
|
17
|
+
console.log(`${ok ? 'PASS' : 'FAIL'} ${label}`)
|
|
18
|
+
if (!ok) console.log(` got ${JSON.stringify(actual)}\n expected ${JSON.stringify(expected)}`)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const existsWith = (...paths: string[]) => (candidate: string) => paths.includes(candidate)
|
|
22
|
+
|
|
23
|
+
check('Node host keeps process.execPath', resolveBridgeRuntime({
|
|
24
|
+
env: {}, execPath: 'C:\\node\\node.exe', versions: {}, exists: existsWith(),
|
|
25
|
+
}), { command: 'C:\\node\\node.exe', extraEnv: {}, source: 'process.execPath (Node host)' })
|
|
26
|
+
|
|
27
|
+
check('Electron host finds the bundled desktop Node', resolveBridgeRuntime({
|
|
28
|
+
env: {}, execPath: APP, versions: { electron: '38.0.0' }, exists: existsWith(APP, PAYLOAD_NODE),
|
|
29
|
+
}), { command: PAYLOAD_NODE, extraEnv: {}, source: 'desktop runtime Node' })
|
|
30
|
+
|
|
31
|
+
const HOME = 'C:\\Users\\tester'
|
|
32
|
+
const USER_NODE = HOME + '\\.dsh\\dsh-runtimes\\dsh-primary-runtime\\dependencies\\node\\bin\\node.exe'
|
|
33
|
+
|
|
34
|
+
check('per-user runtime copy is preferred over the installer payload', resolveBridgeRuntime({
|
|
35
|
+
env: {}, execPath: APP, versions: { electron: '38.0.0' }, home: HOME,
|
|
36
|
+
exists: existsWith(APP, PAYLOAD_NODE, USER_NODE),
|
|
37
|
+
}), { command: USER_NODE, extraEnv: {}, source: 'per-user DSH runtime Node' })
|
|
38
|
+
|
|
39
|
+
check('payload copy still used when the per-user runtime is absent', resolveBridgeRuntime({
|
|
40
|
+
env: {}, execPath: APP, versions: { electron: '38.0.0' }, home: HOME,
|
|
41
|
+
exists: existsWith(APP, PAYLOAD_NODE),
|
|
42
|
+
}), { command: PAYLOAD_NODE, extraEnv: {}, source: 'desktop runtime Node' })
|
|
43
|
+
|
|
44
|
+
check('explicit override wins', resolveBridgeRuntime({
|
|
45
|
+
env: { DSH_EDA_MCP_NODE: PATH_NODE }, execPath: APP, versions: { electron: '38.0.0' }, exists: existsWith(APP, PAYLOAD_NODE, PATH_NODE),
|
|
46
|
+
}), { command: PATH_NODE, extraEnv: {}, source: 'DSH_EDA_MCP_NODE override' })
|
|
47
|
+
|
|
48
|
+
check('missing override falls through', resolveBridgeRuntime({
|
|
49
|
+
env: { DSH_EDA_MCP_NODE: 'C:\\nope\\node.exe' }, execPath: APP, versions: { electron: '38.0.0' }, exists: existsWith(APP, PAYLOAD_NODE),
|
|
50
|
+
}), { command: PAYLOAD_NODE, extraEnv: {}, source: 'desktop runtime Node' })
|
|
51
|
+
|
|
52
|
+
check('desktop launcher variable runs the app binary as Node', resolveBridgeRuntime({
|
|
53
|
+
env: { DSH_DESKTOP_NODE_EXECUTABLE: APP }, execPath: APP, versions: { electron: '38.0.0' }, exists: existsWith(APP),
|
|
54
|
+
}), { command: APP, extraEnv: { ELECTRON_RUN_AS_NODE: '1' }, source: 'DSH_DESKTOP_NODE_EXECUTABLE' })
|
|
55
|
+
|
|
56
|
+
check('PATH fallback when the payload ships no Node', resolveBridgeRuntime({
|
|
57
|
+
env: { PATH: 'C:\\tools\\nodejs;C:\\Windows' }, execPath: APP, versions: { electron: '38.0.0' }, exists: existsWith(APP, PATH_NODE),
|
|
58
|
+
}), { command: PATH_NODE, extraEnv: {}, source: 'PATH Node' })
|
|
59
|
+
|
|
60
|
+
check('last resort: Electron as Node', resolveBridgeRuntime({
|
|
61
|
+
env: { PATH: 'C:\\Windows' }, execPath: APP, versions: { electron: '38.0.0' }, exists: existsWith(APP),
|
|
62
|
+
}), { command: APP, extraEnv: { ELECTRON_RUN_AS_NODE: '1' }, source: 'process.execPath + ELECTRON_RUN_AS_NODE (Electron as Node)' })
|
|
63
|
+
|
|
64
|
+
console.log(failures === 0 ? '\nALL PASS' : `\n${failures} FAILED`)
|
|
65
|
+
process.exit(failures === 0 ? 0 : 1)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { auditSchematicGeometry } from '../src/bridge/schematic-audit.ts'
|
|
2
|
+
|
|
3
|
+
let failed = 0
|
|
4
|
+
const report = (name: string, ok: boolean, detail: string) => {
|
|
5
|
+
if (!ok) failed += 1
|
|
6
|
+
console.log((ok ? 'PASS ' : 'FAIL ') + name + (ok ? '' : ' — ' + detail))
|
|
7
|
+
}
|
|
8
|
+
const frame = { left: 0, right: 1170, top: 825, bottom: 0 }
|
|
9
|
+
const titleBlock = { left: 460, right: 1160, top: 190, bottom: 10 }
|
|
10
|
+
const box = (x: number, y: number, w = 60, h = 40) => ({ left: x - w / 2, right: x + w / 2, bottom: y - h / 2, top: y + h / 2 })
|
|
11
|
+
|
|
12
|
+
const clean = auditSchematicGeometry({
|
|
13
|
+
components: [
|
|
14
|
+
{ designator: 'U1', x: 300, y: 500, bounds: box(300, 500) },
|
|
15
|
+
{ designator: 'C1', x: 400, y: 500, bounds: box(400, 500) },
|
|
16
|
+
],
|
|
17
|
+
frame, titleBlock,
|
|
18
|
+
})
|
|
19
|
+
report('clean sheet passes everything', clean.ok && clean.counts.fail === 0, JSON.stringify(clean.checks.filter(c => c.status === 'fail')))
|
|
20
|
+
report('clean sheet reports the component count', clean.componentCount === 2, String(clean.componentCount))
|
|
21
|
+
|
|
22
|
+
const outside = auditSchematicGeometry({
|
|
23
|
+
components: [{ designator: 'U9', x: 1200, y: 500, bounds: box(1200, 500) }],
|
|
24
|
+
frame, titleBlock,
|
|
25
|
+
})
|
|
26
|
+
report('symbol outside the frame fails', outside.checks.find(c => c.id === 'outside-frame')?.status === 'fail', '')
|
|
27
|
+
|
|
28
|
+
const inTitle = auditSchematicGeometry({
|
|
29
|
+
components: [{ designator: 'R1', x: 800, y: 100, bounds: box(800, 100) }],
|
|
30
|
+
frame, titleBlock,
|
|
31
|
+
})
|
|
32
|
+
report('symbol on the title block fails', inTitle.checks.find(c => c.id === 'title-block')?.status === 'fail', '')
|
|
33
|
+
|
|
34
|
+
const overlapping = auditSchematicGeometry({
|
|
35
|
+
components: [
|
|
36
|
+
{ designator: 'U1', x: 300, y: 500, bounds: box(300, 500) },
|
|
37
|
+
{ designator: 'U2', x: 305, y: 505, bounds: box(305, 505) },
|
|
38
|
+
],
|
|
39
|
+
frame, titleBlock,
|
|
40
|
+
})
|
|
41
|
+
report('overlapping symbols fail', overlapping.checks.find(c => c.id === 'symbol-overlap')?.status === 'fail', '')
|
|
42
|
+
|
|
43
|
+
const touching = auditSchematicGeometry({
|
|
44
|
+
components: [
|
|
45
|
+
{ designator: 'U1', x: 300, y: 500, bounds: { left: 270, right: 330, bottom: 480, top: 520 } },
|
|
46
|
+
{ designator: 'U2', x: 360, y: 500, bounds: { left: 330, right: 390, bottom: 480, top: 520 } },
|
|
47
|
+
],
|
|
48
|
+
frame, titleBlock,
|
|
49
|
+
})
|
|
50
|
+
report('edge-touching symbols do not fail', touching.checks.find(c => c.id === 'symbol-overlap')?.status === 'pass', '')
|
|
51
|
+
|
|
52
|
+
const offGrid = auditSchematicGeometry({
|
|
53
|
+
components: [{ designator: 'C3', x: 303, y: 497, bounds: box(303, 497) }],
|
|
54
|
+
frame, titleBlock, grid: 10,
|
|
55
|
+
})
|
|
56
|
+
report('off-grid warns', offGrid.checks.find(c => c.id === 'grid')?.status === 'warn', '')
|
|
57
|
+
|
|
58
|
+
const labelInside = auditSchematicGeometry({
|
|
59
|
+
components: [{ designator: 'U1', x: 300, y: 500, bounds: box(300, 500) }],
|
|
60
|
+
frame, titleBlock,
|
|
61
|
+
labels: [{ text: 'GND', x: 300, y: 500 }, { text: 'PA1', x: 600, y: 500 }],
|
|
62
|
+
})
|
|
63
|
+
report('label inside a symbol warns', labelInside.checks.find(c => c.id === 'label-overlap')?.status === 'warn', '')
|
|
64
|
+
report('label outside symbols is fine', String(labelInside.checks.find(c => c.id === 'label-overlap')?.details?.length) === '1', JSON.stringify(labelInside.checks.find(c => c.id === 'label-overlap')))
|
|
65
|
+
|
|
66
|
+
const empty = auditSchematicGeometry({ components: [], frame, titleBlock })
|
|
67
|
+
report('empty sheet skips', empty.checks.length === 1 && empty.checks[0].status === 'skip', '')
|
|
68
|
+
report('missing bounds are tolerated', auditSchematicGeometry({ components: [{ designator: 'U1', x: 100, y: 100 }], frame, titleBlock }).checks.find(c => c.id === 'outside-frame')?.status === 'pass', '')
|
|
69
|
+
|
|
70
|
+
console.log(failed === 0 ? 'ALL PASS' : failed + ' FAILED')
|
|
71
|
+
if (failed > 0) process.exitCode = 1
|