@huaqiu/dsh-kicad 0.6.4 → 0.6.6
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/lib/index.d.mts +1 -1
- package/lib/index.mjs +2 -6
- package/package.json +2 -2
- package/skills/kicad-ipc/SKILL.md +1 -1
- package/skills/kicad-ipc/references/ipc-pcb-workflows.md +0 -3
- package/skills/kicad-ipc/scripts/diagnose_ipc_connection.py +0 -3
- package/skills/kicad-ipc/scripts/kipy_common.py +1 -6
- package/skills/pcb-initial-placement/scripts/kipy_common.py +1 -6
- package/src/ipc.ts +1 -9
- package/src/tools.ts +2 -2
package/lib/index.d.mts
CHANGED
|
@@ -148,7 +148,7 @@ declare function runKicadScript(options: RunScriptOptions): Promise<ScriptRun>;
|
|
|
148
148
|
* Exit codes are part of the scripts' contract:
|
|
149
149
|
*
|
|
150
150
|
* - `diagnose_ipc_connection.py`: 0 ok, 1 unreachable, 2 `kipy` missing,
|
|
151
|
-
*
|
|
151
|
+
* 4 no board open.
|
|
152
152
|
* - every argparse script: 2 = rejected arguments (KiCad untouched).
|
|
153
153
|
* - anything else non-zero: a real KiCad/script failure.
|
|
154
154
|
*/
|
package/lib/index.mjs
CHANGED
|
@@ -354,7 +354,7 @@ async function runKicadScript(options) {
|
|
|
354
354
|
* Exit codes are part of the scripts' contract:
|
|
355
355
|
*
|
|
356
356
|
* - `diagnose_ipc_connection.py`: 0 ok, 1 unreachable, 2 `kipy` missing,
|
|
357
|
-
*
|
|
357
|
+
* 4 no board open.
|
|
358
358
|
* - every argparse script: 2 = rejected arguments (KiCad untouched).
|
|
359
359
|
* - anything else non-zero: a real KiCad/script failure.
|
|
360
360
|
*/
|
|
@@ -378,10 +378,6 @@ function classifyRun(run) {
|
|
|
378
378
|
kind: "FAILED_PRECONDITION",
|
|
379
379
|
message: "The kicad-python package (kipy) is not installed for the configured Python interpreter. Install the version matching the running KiCad. " + detail(run)
|
|
380
380
|
};
|
|
381
|
-
case 3: return {
|
|
382
|
-
kind: "FAILED_PRECONDITION",
|
|
383
|
-
message: "kicad-python and the connected KiCad disagree on the API version. Do not work around it — install the matching official package. " + detail(run)
|
|
384
|
-
};
|
|
385
381
|
case 4: return {
|
|
386
382
|
kind: "FAILED_PRECONDITION",
|
|
387
383
|
message: "Connected to KiCad, but no .kicad_pcb is open in PCB Editor. Open a board and retry. " + detail(run)
|
|
@@ -461,7 +457,7 @@ function renderJson(_args, value) {
|
|
|
461
457
|
* Kept in one place so the prompt contract cannot drift between tools — the
|
|
462
458
|
* same idiom as `@huaqiu/dsh-eda-host`.
|
|
463
459
|
*/
|
|
464
|
-
const ERROR_SEMANTICS = "IMPORTANT SEMANTICS: on ok:false, error.kind distinguishes the cause: \"FAILED_PRECONDITION\" (KiCad IPC cannot run at all — no kipy,
|
|
460
|
+
const ERROR_SEMANTICS = "IMPORTANT SEMANTICS: on ok:false, error.kind distinguishes the cause: \"FAILED_PRECONDITION\" (KiCad IPC cannot run at all — no kipy, or no .kicad_pcb open; ask the user to fix the environment, do NOT retry), \"UNAVAILABLE\" (KiCad is installed but unreachable — retry once after checking PCB Editor is open, the KiCad API service is enabled, and DSH has Full Access), \"DEADLINE_EXCEEDED\" (KiCad did not answer in time — retry a read once; for a write, re-read board state first), \"INVALID_ARGUMENT\" (the board was not touched — fix units/ranges and retry), \"INTERNAL\" (KiCad or the script failed; the commit was dropped so the board is unchanged). Do NOT fabricate board state from a failed call.";
|
|
465
461
|
/** Reading-only tools are safe to run alongside each other. */
|
|
466
462
|
const READ_ONLY = { isConcurrencySafe: () => true };
|
|
467
463
|
/** Mutating tools must never be batched into a parallel group. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huaqiu/dsh-kicad",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.mjs",
|
|
6
6
|
"types": "./lib/index.d.mts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@deepseek-ai/dsh-tools": "^0.2.1-rc.2"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@huaqiu/dsh-plugin-log": "0.6.
|
|
25
|
+
"@huaqiu/dsh-plugin-log": "0.6.6"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"lib",
|
|
@@ -40,7 +40,7 @@ description: "通过 KiCad IPC API 和官方 kicad-python 在打开的 PCB 中
|
|
|
40
40
|
|
|
41
41
|
## 连接与版本路由
|
|
42
42
|
|
|
43
|
-
1. 确认目标是 KiCad 9.0+,并使用官方包 `kicad-python`(Python 模块为 `kipy`)。先以 `KiCad()`
|
|
43
|
+
1. 确认目标是 KiCad 9.0+,并使用官方包 `kicad-python`(Python 模块为 `kipy`)。先以 `KiCad()` 连接,再通过 `get_board()` 取得当前 PCB。
|
|
44
44
|
2. KiCad 9/10 只能连接到启用 API 服务的运行中 GUI;由 KiCad 启动的 IPC 插件会提供 `KICAD_API_SOCKET` 和 `KICAD_API_TOKEN`。不要猜测、硬编码或扫描其他 KiCad 实例的连接端点。
|
|
45
45
|
3. KiCad 11 可使用 `KiCad(headless=True, file_path=...)` / `kicad-cli api-server` 处理无头任务。此前版本不可把 IPC SDK 当作脱离 GUI 的板文件库。
|
|
46
46
|
4. 若 KiCad 已打开但连接不到服务器,先判定不是 GUI 正忙:提示用户在 **偏好设置 → 插件** 中启用 KiCad API 服务,并在变更后重启 PCB Editor,再重新运行脚本。不要扫描命名管道、猜测 token 或以文件编辑替代连接。
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
- IPC API 从 KiCad 9.0 起提供。KiCad 9/10 通过运行中 PCB Editor 的 IPC 服务工作;KiCad 11 增加 `kicad-cli` 无头 API 服务。
|
|
8
8
|
- `kicad-python` 是官方 Python 绑定,入口是 `from kipy import KiCad`。由 KiCad 启动的插件应让 `KiCad()` 使用它提供的 `KICAD_API_SOCKET` 和 `KICAD_API_TOKEN`;不要自行伪造凭据。
|
|
9
|
-
- 首次连接后调用 `kicad.check_version()`。如果失败,停止并报告本机 KiCad 与 Python 包版本不匹配,而不是继续尝试写入。
|
|
10
9
|
- 若连接报错而 KiCad GUI 已打开,首先请用户在 **偏好设置 → 插件** 中启用 API 服务,重启 PCB Editor 后再试。KiCad 未启用 API 时,不存在可供脚本连接的服务端;`KICAD_API_SOCKET`、扫描命名管道或重试不能修复此配置。
|
|
11
10
|
- 在 DSH 运行时,IPC 客户端需要 **Full Access** 才能访问 KiCad 的 Windows 命名管道。若当前权限不是 Full Access,先请求用户在 DSH 中提升权限或重新在 Full Access 任务中执行;不应把这类权限拒绝描述为 KiCad 未运行或不断重试。
|
|
12
11
|
|
|
@@ -14,8 +13,6 @@
|
|
|
14
13
|
from kipy import KiCad
|
|
15
14
|
|
|
16
15
|
kicad = KiCad(timeout_ms=5000)
|
|
17
|
-
if not kicad.check_version():
|
|
18
|
-
raise RuntimeError("kicad-python 与已连接的 KiCad API 版本不匹配")
|
|
19
16
|
board = kicad.get_board()
|
|
20
17
|
```
|
|
21
18
|
|
|
@@ -11,14 +11,9 @@ from kipy.board_types import BoardLayer
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def connect_board(timeout_ms: int = 5000):
|
|
14
|
-
"""Return a
|
|
14
|
+
"""Return a KiCad connection and the currently open PCB board."""
|
|
15
15
|
kicad = KiCad(timeout_ms=timeout_ms)
|
|
16
16
|
|
|
17
|
-
if not kicad.check_version():
|
|
18
|
-
raise RuntimeError(
|
|
19
|
-
"kicad-python does not match the connected KiCad's API version; use the matching official package."
|
|
20
|
-
)
|
|
21
|
-
|
|
22
17
|
board = kicad.get_board()
|
|
23
18
|
if board is None:
|
|
24
19
|
raise RuntimeError("No PCB is open; please open a .kicad_pcb in PCB Editor first.")
|
|
@@ -11,14 +11,9 @@ from kipy.board_types import BoardLayer
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def connect_board(timeout_ms: int = 5000):
|
|
14
|
-
"""Return a
|
|
14
|
+
"""Return a KiCad connection and the currently open PCB board."""
|
|
15
15
|
kicad = KiCad(timeout_ms=timeout_ms)
|
|
16
16
|
|
|
17
|
-
if not kicad.check_version():
|
|
18
|
-
raise RuntimeError(
|
|
19
|
-
"kicad-python does not match the connected KiCad's API version; use the matching official package."
|
|
20
|
-
)
|
|
21
|
-
|
|
22
17
|
board = kicad.get_board()
|
|
23
18
|
if board is None:
|
|
24
19
|
raise RuntimeError("No PCB is open; please open a .kicad_pcb in PCB Editor first.")
|
package/src/ipc.ts
CHANGED
|
@@ -184,7 +184,7 @@ export async function runKicadScript(options: RunScriptOptions): Promise<ScriptR
|
|
|
184
184
|
* Exit codes are part of the scripts' contract:
|
|
185
185
|
*
|
|
186
186
|
* - `diagnose_ipc_connection.py`: 0 ok, 1 unreachable, 2 `kipy` missing,
|
|
187
|
-
*
|
|
187
|
+
* 4 no board open.
|
|
188
188
|
* - every argparse script: 2 = rejected arguments (KiCad untouched).
|
|
189
189
|
* - anything else non-zero: a real KiCad/script failure.
|
|
190
190
|
*/
|
|
@@ -234,14 +234,6 @@ export function classifyRun(run: ScriptRun): KicadError | undefined {
|
|
|
234
234
|
'Python interpreter. Install the version matching the running KiCad. ' +
|
|
235
235
|
detail(run),
|
|
236
236
|
}
|
|
237
|
-
case 3:
|
|
238
|
-
return {
|
|
239
|
-
kind: 'FAILED_PRECONDITION',
|
|
240
|
-
message:
|
|
241
|
-
'kicad-python and the connected KiCad disagree on the API version. ' +
|
|
242
|
-
'Do not work around it — install the matching official package. ' +
|
|
243
|
-
detail(run),
|
|
244
|
-
}
|
|
245
237
|
case 4:
|
|
246
238
|
return {
|
|
247
239
|
kind: 'FAILED_PRECONDITION',
|
package/src/tools.ts
CHANGED
|
@@ -76,8 +76,8 @@ export interface ToolExecLike {
|
|
|
76
76
|
*/
|
|
77
77
|
const ERROR_SEMANTICS =
|
|
78
78
|
`IMPORTANT SEMANTICS: on ok:false, error.kind distinguishes the cause: ` +
|
|
79
|
-
`"FAILED_PRECONDITION" (KiCad IPC cannot run at all — no kipy,
|
|
80
|
-
|
|
79
|
+
`"FAILED_PRECONDITION" (KiCad IPC cannot run at all — no kipy, or no ` +
|
|
80
|
+
`.kicad_pcb open; ask the user to fix the environment, do NOT ` +
|
|
81
81
|
`retry), "UNAVAILABLE" (KiCad is installed but unreachable — retry once after ` +
|
|
82
82
|
`checking PCB Editor is open, the KiCad API service is enabled, and DSH has ` +
|
|
83
83
|
`Full Access), "DEADLINE_EXCEEDED" (KiCad did not answer in time — retry a ` +
|