@zhushanwen/pi-cw-tool 0.5.3 → 0.5.5
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/README.md +3 -3
- package/package.json +5 -2
- package/src/cw-runner.ts +3 -1
- package/src/cw-spawn.ts +4 -2
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# @zhushanwen/pi-cw-tool
|
|
2
2
|
|
|
3
|
-
cw 2.0 的 pi extension
|
|
3
|
+
cw 2.0 的 pi extension 薄封装:
|
|
4
4
|
|
|
5
5
|
- **cw_query 工具**:只读查询透传(`status` / `frontier` / `tree` / `report`,参数面 `--unit` / `--root` / `--json` 按 cw 2.0 修正)。写命令(create / evidence submit / review submit / verify / run)不在工具面——经 bash 调 `cw`,用法以 cw-cli skill 为 SSOT。
|
|
6
6
|
- **pi-cw skill**:runner 实操指南(多 unit 任务 `cw run --spawn pi` 的后台运行、监控、escalation 处置、收尾回流)。
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
编排智能收在 cw 2.0 引擎(runner + 账本 gate),「层主不能自审」由账本层硬保证。
|
|
9
9
|
|
|
10
10
|
## 环境要求
|
|
11
11
|
|
|
@@ -18,4 +18,4 @@ pnpm typecheck # tsc --noEmit(含 test 配置)
|
|
|
18
18
|
pnpm test # vitest run
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
变更经
|
|
21
|
+
变更经 taiji 仓的 extensions 流程校验(`pnpm extensions:typecheck && pnpm extensions:lint && pnpm extensions:test`)。
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhushanwen/pi-cw-tool",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "Pi extension for cw 2.0: a read-only cw_query tool (status / frontier / tree / report passthrough) + the pi-cw skill (runner practical guide for multi-unit tasks: background run, monitoring, escalation, merge back).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.ts",
|
|
7
|
-
"
|
|
7
|
+
"taiji": {
|
|
8
8
|
"role": "universal"
|
|
9
9
|
},
|
|
10
10
|
"pi": {
|
|
@@ -41,6 +41,9 @@
|
|
|
41
41
|
"optional": true
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@zhushanwen/pi-ext-guards": "0.4.1"
|
|
46
|
+
},
|
|
44
47
|
"devDependencies": {
|
|
45
48
|
"@vitest/coverage-v8": "^4.1.9",
|
|
46
49
|
"vitest": "^4.1.8"
|
package/src/cw-runner.ts
CHANGED
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
* 与 Pi SDK 解耦(不 import pi 类型),纯逻辑 + 可注入 spawner,便于单测。
|
|
15
15
|
* 所有错误路径返回 `{ ok: false, error }`,不抛异常(由调用方映射为 tool 返回)。
|
|
16
16
|
*/
|
|
17
|
+
import { toErrorMessage } from "@zhushanwen/pi-ext-guards";
|
|
18
|
+
|
|
17
19
|
import type { CwSpawner } from "./cw-spawn.ts";
|
|
18
20
|
|
|
19
21
|
/**
|
|
@@ -187,7 +189,7 @@ export async function executeCwAction(
|
|
|
187
189
|
try {
|
|
188
190
|
result = await spawner(args, undefined, cwd, combined.signal);
|
|
189
191
|
} catch (err) {
|
|
190
|
-
const msg =
|
|
192
|
+
const msg = toErrorMessage(err);
|
|
191
193
|
return { ok: false, ...base, error: `cw spawn 失败: ${msg}` };
|
|
192
194
|
} finally {
|
|
193
195
|
if (timer) clearTimeout(timer);
|
package/src/cw-spawn.ts
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
import { existsSync } from "node:fs";
|
|
16
16
|
import { spawn } from "node:child_process";
|
|
17
17
|
|
|
18
|
+
import { isEnoentError } from "@zhushanwen/pi-ext-guards";
|
|
19
|
+
|
|
18
20
|
/**
|
|
19
21
|
* cwd 不存在时的可操作错误文案(错误 → 权威源 worktrees.json → 重试闭环)。
|
|
20
22
|
* @param cwd 不存在的路径
|
|
@@ -122,8 +124,8 @@ export const defaultCwSpawner: CwSpawner = (args, input, cwd, signal) =>
|
|
|
122
124
|
// [worktree-reaper-fix] 拼 cwd 进错误消息:ENOENT 的 err.message 只有 command 名,
|
|
123
125
|
// 无 cwd 线索会导致误诊(2026-08-11 事故 AI 误判"node 被卸载")。
|
|
124
126
|
// exitCode=-1 区分于正常退出码。
|
|
125
|
-
const errCwd = err
|
|
126
|
-
const hint = err
|
|
127
|
+
const errCwd = isEnoentError(err) ? `\ncwd: ${cwd}` : "";
|
|
128
|
+
const hint = isEnoentError(err) && !existsSync(cwd) ? `\n${cwdMissingError(cwd)}` : "";
|
|
127
129
|
finish({ stdout, stderr: `${stderr}\n[spawn error] ${err.message}${errCwd}${hint}`, exitCode: -1 });
|
|
128
130
|
});
|
|
129
131
|
child.on("close", (code: number | null) => {
|