@zhushanwen/pi-cw-tool 0.2.0

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 ADDED
@@ -0,0 +1,47 @@
1
+ # @zhushanwen/pi-cw-tool
2
+
3
+ 把 `cw`(Agent-agnostic 编码流程编排 CLI)包成 4 个 role-restricted pi 工具,按 role 限制可调 action。
4
+
5
+ ## 背景
6
+
7
+ v4 递归编排方案要求 cw 命令包成 pi 自定义工具(cw-tool),按 role 限制可调 action——把「独立 review」「层主不写码」从 prompt 软约束变成**工具白名单硬约束**。
8
+
9
+ ## 4 个工具
10
+
11
+ | 工具 | 谁用 | 允许的 cw action(白名单) |
12
+ |---|---|---|
13
+ | `cw_planning` | epic/feature/slice 层主 | design, execute, replan, retrospect, closeout + 只读(status, handoff, list, tree, frontier) |
14
+ | `cw_wave` | wave 层主 | design, replan, retrospect, closeout + 只读(**无 execute/test/design-review/exec-review**) |
15
+ | `cw_dev` | wave 内 dev | execute, test + 只读(status, handoff) |
16
+ | `cw_review` | 审 design/exec | design-review, exec-review + 只读(status) |
17
+
18
+ 层主的 cw-tool 不含审查命令 → 物理上调不了审查 → 必须派独立 review-agent。
19
+
20
+ ## 参数
21
+
22
+ 所有工具共享参数 schema:
23
+
24
+ - `action`(枚举,受限于此工具白名单)—— 第一道约束(LLM 输入)
25
+ - `unitId`(必传)—— `cw --unitId`
26
+ - `input?`(JSON 内容字符串)—— 经 stdin 传给 cw(`--input -`)
27
+ - `inputFile?`(文件路径)—— `--input <path>`(与 input 互斥)
28
+ - `commitHash?`(execute 关联 commit)—— `--commitHash`
29
+
30
+ ## 返回
31
+
32
+ 返回 `details.ok` 区分成功/失败(不抛异常):
33
+
34
+ - 成功:`{ ok:true, action, unitId, stdout, parsed, data? }`,`content.text` 为 cw 原始 stdout
35
+ - 失败(白名单拒绝 / 非零退出 / stderr 非空 / spawn 异常):`{ ok:false, action, unitId, error }`
36
+
37
+ ## cw 路径解析
38
+
39
+ 通过 `process.env.PATH` 解析(spawn 裸命令名 `cw`),不硬编码绝对路径。
40
+
41
+ ## 开发
42
+
43
+ ```bash
44
+ cd extensions/cw-tool
45
+ npx tsc --noEmit # 类型检查
46
+ npx vitest run # 测试(mock spawn,不真调 cw)
47
+ ```
package/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ // Re-export from src — Pi loads this file as the extension entry point.
2
+ export { default } from "./src/index.ts";
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@zhushanwen/pi-cw-tool",
3
+ "version": "0.2.0",
4
+ "description": "Pi extension wrapping the `cw` CLI as role-restricted tools (cw_planning / cw_wave / cw_dev / cw_review) with per-tool action whitelists — hard-guarantees no self-review by layer-owner agents.",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "pi": {
8
+ "extensions": [
9
+ "./index.ts"
10
+ ]
11
+ },
12
+ "keywords": [
13
+ "pi-package",
14
+ "cw",
15
+ "coding-workflow",
16
+ "tool",
17
+ "whitelist",
18
+ "role-restriction"
19
+ ],
20
+ "license": "MIT",
21
+ "files": [
22
+ "index.ts",
23
+ "src/"
24
+ ],
25
+ "peerDependencies": {
26
+ "@earendil-works/pi-coding-agent": "*",
27
+ "@earendil-works/pi-ai": "*",
28
+ "typebox": "*"
29
+ },
30
+ "peerDependenciesMeta": {
31
+ "@earendil-works/pi-ai": {
32
+ "optional": true
33
+ },
34
+ "typebox": {
35
+ "optional": true
36
+ }
37
+ },
38
+ "devDependencies": {
39
+ "vitest": "^4.1.8"
40
+ },
41
+ "scripts": {
42
+ "typecheck": "npx tsc --noEmit && npx tsc --noEmit -p tsconfig.test.json",
43
+ "test": "vitest run",
44
+ "test:watch": "vitest"
45
+ }
46
+ }