plan-governance-cli 1.1.1 → 1.1.2
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 +21 -15
- package/bin/plan-governance-cli.mjs +30 -24
- package/package.json +1 -1
- package/resources/manifest.json +1 -2
- package/resources/skill/SKILL.md +1 -1
- package/resources/skill/references/cli.md +2 -2
- package/resources/skill/references/verification.md +1 -1
- package/scripts/init_plan_governance.py +5 -33
package/README.md
CHANGED
|
@@ -111,7 +111,6 @@ plan-governance-cli init \
|
|
|
111
111
|
.git/
|
|
112
112
|
docs/PLAN_MAP.md
|
|
113
113
|
docs/plans/api-compat-migration.md
|
|
114
|
-
CLAUDE.md
|
|
115
114
|
AGENTS.md
|
|
116
115
|
```
|
|
117
116
|
|
|
@@ -119,12 +118,11 @@ AGENTS.md
|
|
|
119
118
|
|
|
120
119
|
如果目标目录还不是 Git 仓库,初始化流程会先执行 `git init`;已有 `.git/` 时会跳过,不重复初始化。
|
|
121
120
|
|
|
122
|
-
`--update-agent-rules` 会创建或更新 `
|
|
121
|
+
`--update-agent-rules` 会创建或更新 `AGENTS.md` 中带标记的计划治理章节,只写稳定执行规则,不写具体计划内容。具体计划仍以 `docs/PLAN_MAP.md` 和 `docs/plans/*.md` 为准。
|
|
123
122
|
|
|
124
|
-
|
|
123
|
+
也可以使用含义更直接的别名:
|
|
125
124
|
|
|
126
125
|
```bash
|
|
127
|
-
--update-claude-md
|
|
128
126
|
--update-agents-md
|
|
129
127
|
```
|
|
130
128
|
|
|
@@ -144,7 +142,7 @@ plan-governance-cli init \
|
|
|
144
142
|
--update-agent-rules-only
|
|
145
143
|
```
|
|
146
144
|
|
|
147
|
-
|
|
145
|
+
`--update-agents-md-only` 与上述兼容别名作用相同,也只更新 `AGENTS.md`。
|
|
148
146
|
|
|
149
147
|
如果要升级已有项目的辅助文件,刷新检查脚本并更新代理规则,但不覆盖 `docs/`,运行:
|
|
150
148
|
|
|
@@ -157,7 +155,7 @@ plan-governance-cli init \
|
|
|
157
155
|
`--upgrade-existing` 会:
|
|
158
156
|
|
|
159
157
|
- 按兼容模式覆盖更新项目中的 `scripts/check_plan_governance.py`
|
|
160
|
-
- 创建或更新 `
|
|
158
|
+
- 创建或更新 `AGENTS.md` 中带标记的计划治理章节,既有其他代理入口保持原样
|
|
161
159
|
- 保留已有 `docs/PLAN_MAP.md` 和 `docs/plans/*.md`
|
|
162
160
|
- 提示缺失的治理文档
|
|
163
161
|
|
|
@@ -209,13 +207,20 @@ plan-governance-cli graph code impact --repo modelpad --file Sources/ModelPadCor
|
|
|
209
207
|
|
|
210
208
|
[验证规范](resources/skill/references/verification.md)统一维护单次复核、任务复用、证据复用、修复自验与用户验收;其他会话从同一 skill 读取。需要独立复核且授权明确时自动安排只读 subagent,复用已有同范围任务/结果,等待异常先核准任务 ID 和状态,且复核者不得再委派复核;不为普通小改逐次派发。技术完成待用户验收的适用功能计划仍保持实施中。
|
|
211
209
|
|
|
212
|
-
|
|
210
|
+
恢复已有计划时可读取派生工作集:
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
plan-governance-cli workset . --json
|
|
214
|
+
plan-governance-cli workset . --json --strict-readiness
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
工作集返回活跃计划、阶段、阻塞、下一动作、并行提示和最近证据,不写计划或自动执行动作;严格模式让活跃计划的机械准入缺陷返回非零。需要缩小恢复上下文时使用最近记录窗口:
|
|
213
218
|
|
|
214
219
|
```bash
|
|
215
220
|
plan-governance-cli workset . --json --evidence-limit 3
|
|
216
221
|
```
|
|
217
222
|
|
|
218
|
-
每个计划保留末尾三条记录,并给出省略数量和原文位置;默认完整输出和门禁判断保持。窗口用于恢复阅读,必要时去掉参数回查完整记录,详见 [CLI 参考](resources/skill/references/cli.md#当前工作集)
|
|
223
|
+
每个计划保留末尾三条记录,并给出省略数量和原文位置;默认完整输出和门禁判断保持。窗口用于恢复阅读,必要时去掉参数回查完整记录,详见 [CLI 参考](resources/skill/references/cli.md#当前工作集)。
|
|
219
224
|
|
|
220
225
|
## 按需读取规则
|
|
221
226
|
|
|
@@ -230,10 +235,10 @@ plan-governance-cli guide cli # CLI 操作
|
|
|
230
235
|
|
|
231
236
|
SKILL 保留任务边界、自主执行原则和按需入口,三份 references 按需读取并随 manifest/setup/npm 分发。已有项目只刷新受管入口,不迁移旧计划、不改用户块外内容。选择同一版本的规范来源,安装副本与仓库同版本号也可能有不同内容。
|
|
232
237
|
|
|
233
|
-
|
|
238
|
+
也可以不全局安装,直接使用当前公开版本:
|
|
234
239
|
|
|
235
240
|
```bash
|
|
236
|
-
npx --yes --package plan-governance-cli@
|
|
241
|
+
npx --yes --package plan-governance-cli@latest plan-governance-cli check . --strict-readiness
|
|
237
242
|
```
|
|
238
243
|
|
|
239
244
|
npm 包内部仍使用版本化的 Python 检查器,但用户不需要直接调用或复制该脚本。旧项目已有本地脚本时仍可保留作为兼容或回滚路径。
|
|
@@ -252,11 +257,10 @@ npm 包内部仍使用版本化的 Python 检查器,但用户不需要直接
|
|
|
252
257
|
|
|
253
258
|
```bash
|
|
254
259
|
plan-governance-cli setup --target codex --dry-run
|
|
255
|
-
plan-governance-cli setup --target
|
|
256
|
-
plan-governance-cli setup --target all
|
|
260
|
+
plan-governance-cli setup --target codex --force
|
|
257
261
|
```
|
|
258
262
|
|
|
259
|
-
`setup`
|
|
263
|
+
`setup` 只向 Codex 同步 npm 包 manifest 指定的 skill、代理元数据和模板文件,必须恰好指定一次 `--target codex`。旧版或重复 target、混合 help、缺失 target 都会在写入前失败;目标之外的用户目录不会被读取、修改或删除。默认先用 `--dry-run` 查看差异,目标文件有本地修改时不会静默覆盖。检查器、初始化器和 hook runtime 由 npm 包内部调用,不复制到项目或 skill 目录;项目初始化器只维护 `AGENTS.md`,当前实现不自动安装 hook 配置。
|
|
260
264
|
|
|
261
265
|
初始化项目时使用包内初始化器:
|
|
262
266
|
|
|
@@ -268,7 +272,7 @@ plan-governance-cli init --root . --plan api-compat-migration --title "API 兼
|
|
|
268
272
|
|
|
269
273
|
## Hook runtime
|
|
270
274
|
|
|
271
|
-
本仓库提供只读 hook runtime,供 Codex
|
|
275
|
+
本仓库提供只读 hook runtime,供 Codex 项目级 hooks 手动接入。脚本只输出短提示和检查结果,不修改治理文档,不更新 `最后更新`,不安装或修改全局配置。
|
|
272
276
|
|
|
273
277
|
```bash
|
|
274
278
|
plan-governance-cli hook --event session-start
|
|
@@ -366,7 +370,7 @@ python3 -m pytest
|
|
|
366
370
|
| `设计中` | 正在明确范围、契约和门禁 |
|
|
367
371
|
| `待实施` | 当前阶段门禁已通过,但尚未开始 |
|
|
368
372
|
| `实施中` | 当前阶段正在修改代码或文档 |
|
|
369
|
-
| `已完成` |
|
|
373
|
+
| `已完成` | 实现、测试、证据、文档及适用用户验收均已完成 |
|
|
370
374
|
| `已替代` | 被另一个计划取代 |
|
|
371
375
|
| `已合并` | 并入另一个计划 |
|
|
372
376
|
| `已废弃` | 明确不再推进 |
|
|
@@ -377,6 +381,8 @@ python3 -m pytest
|
|
|
377
381
|
|
|
378
382
|
新旧计划统一采用单次复核行为:普通改动自验,高风险或高影响独立检查一次后由实施者修复自验,原发现保留。旧 `风险分流` 标签和缺省六列格式只作为兼容记录形式,不恢复多次独立门禁;固定字段、历史保护和严格检查语义以[阶段门规范](resources/skill/references/verification.md#step-0-与阶段门)为准。
|
|
379
383
|
|
|
384
|
+
派发独立复核时显式传入推理强度,不依赖全局 subagent 默认值:安全、权限、隐私、资金、数据完整性等高风险复核使用 `high`,其他独立复核使用 `medium`。该分层只影响本次复核的思考强度,不改变是否复核或单次复核规则。
|
|
385
|
+
|
|
380
386
|
使用 `check --strict-readiness` 做准入/CI/发布机械检查;默认检查兼容告警,机械通过不代替真实风险判断、业务验收或用户接受。
|
|
381
387
|
|
|
382
388
|
## Codex 使用方式
|
|
@@ -79,11 +79,23 @@ function loadManifest() {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
function parseSetupArgs(args) {
|
|
82
|
+
if (args.length === 1 && ["-h", "--help"].includes(args[0])) {
|
|
83
|
+
console.log("用法:plan-governance-cli setup --target codex [--destination DIR] [--dry-run] [--force]");
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
82
87
|
const options = { target: null, destination: null, dryRun: false, force: false };
|
|
83
88
|
for (let index = 0; index < args.length; index += 1) {
|
|
84
89
|
const arg = args[index];
|
|
85
90
|
if (arg === "--target") {
|
|
86
|
-
options.target
|
|
91
|
+
if (options.target !== null) {
|
|
92
|
+
throw new Error("setup 的 --target 只能指定一次");
|
|
93
|
+
}
|
|
94
|
+
const value = args[++index];
|
|
95
|
+
if (!value || value.startsWith("-")) {
|
|
96
|
+
throw new Error("setup 的 --target 缺少值");
|
|
97
|
+
}
|
|
98
|
+
options.target = value;
|
|
87
99
|
} else if (arg === "--destination") {
|
|
88
100
|
options.destination = args[++index];
|
|
89
101
|
} else if (arg === "--dry-run") {
|
|
@@ -91,18 +103,14 @@ function parseSetupArgs(args) {
|
|
|
91
103
|
} else if (arg === "--force") {
|
|
92
104
|
options.force = true;
|
|
93
105
|
} else if (arg === "-h" || arg === "--help") {
|
|
94
|
-
|
|
95
|
-
return null;
|
|
106
|
+
throw new Error("setup 的 --help 必须单独使用");
|
|
96
107
|
} else {
|
|
97
108
|
throw new Error(`setup 不支持参数:${arg}`);
|
|
98
109
|
}
|
|
99
110
|
}
|
|
100
111
|
|
|
101
|
-
if (
|
|
102
|
-
throw new Error("setup
|
|
103
|
-
}
|
|
104
|
-
if (options.destination && options.target === "all") {
|
|
105
|
-
throw new Error("--destination 只能与单个 setup target 一起使用");
|
|
112
|
+
if (options.target !== "codex") {
|
|
113
|
+
throw new Error("setup 仅支持 --target codex");
|
|
106
114
|
}
|
|
107
115
|
return options;
|
|
108
116
|
}
|
|
@@ -112,12 +120,11 @@ function expandTarget(target) {
|
|
|
112
120
|
return target.replace(/^~(?=\/|$)/, home);
|
|
113
121
|
}
|
|
114
122
|
|
|
115
|
-
function
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}));
|
|
123
|
+
function targetRoot(manifest, options) {
|
|
124
|
+
return {
|
|
125
|
+
name: "codex",
|
|
126
|
+
root: resolve(options.destination ? options.destination : expandTarget(manifest.skill.targets.codex)),
|
|
127
|
+
};
|
|
121
128
|
}
|
|
122
129
|
|
|
123
130
|
function resourceFiles(manifest) {
|
|
@@ -148,17 +155,16 @@ function setup(args) {
|
|
|
148
155
|
|
|
149
156
|
const plans = [];
|
|
150
157
|
try {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
plans.push({ target: target.name, destination, existing, sourceContent });
|
|
158
|
+
const target = targetRoot(manifest, options);
|
|
159
|
+
for (const file of files) {
|
|
160
|
+
accessSync(file.source, constants.R_OK);
|
|
161
|
+
const destination = resolve(target.root, file.relative);
|
|
162
|
+
const existing = existsSync(destination) ? readFileSync(destination, "utf8") : null;
|
|
163
|
+
const sourceContent = readFileSync(file.source, "utf8");
|
|
164
|
+
if (existing !== null && existing !== sourceContent && !options.force) {
|
|
165
|
+
throw new Error(`目标文件存在本地差异,未覆盖:${destination}(如确认覆盖请加 --force)`);
|
|
161
166
|
}
|
|
167
|
+
plans.push({ target: target.name, destination, existing, sourceContent });
|
|
162
168
|
}
|
|
163
169
|
} catch (error) {
|
|
164
170
|
return fail(error.message);
|
package/package.json
CHANGED
package/resources/manifest.json
CHANGED
package/resources/skill/SKILL.md
CHANGED
|
@@ -13,7 +13,7 @@ description: 维护已有项目计划,或为需要跨阶段、跨会话协调
|
|
|
13
13
|
|
|
14
14
|
首次接手读取地图、当前相关计划及必要契约;恢复只核对当前阶段、实际差异和最近证据。只实施已授权且准入的范围;实质边界变化时调整受影响计划,日常进展随工作同步。事实源与格式见 planning。
|
|
15
15
|
|
|
16
|
-
按 verification
|
|
16
|
+
按 verification 验证:普通改动自验,高风险或高影响的同一交付范围独立检查一次,修复由实施者自验;派发独立复核时显式传入推理强度,高风险用 `high`,其余用 `medium`。旧策略名和旧记录格式不改变此行为。适用检查通过后完成交付;未解决问题如实保留。交付说明完成结果、必要证据和剩余事项,明确约定的用户体验验收继续有效。
|
|
17
17
|
|
|
18
18
|
## 按需读取
|
|
19
19
|
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
## 分发与资源
|
|
20
20
|
|
|
21
|
-
SKILL、三个 references、agents 元数据与 assets 由同一 npm 包的 manifest 分发。`plan-governance-cli setup --target codex
|
|
21
|
+
SKILL、三个 references、agents 元数据与 assets 由同一 npm 包的 manifest 分发。`plan-governance-cli setup --target codex --dry-run` 查看 Codex 同步差异;实际覆盖需既有用户授权并按 setup 冲突提示处理,不自动清理目标之外的用户目录。setup 只支持 Codex 单目标同步;项目初始化器只维护 `AGENTS.md`。项目升级不迁移旧计划,受管块外内容必须保持。
|
|
22
22
|
|
|
23
23
|
仅更新计划格式不等于更新项目入口。已有项目在任务交接、没有进行中的实施或复核时更新受管入口;升级不批量回写历史,旧策略名和六列格式按 verification 解释为统一单次行为。安装副本与仓库开发规则有差异时说明本次选用来源,不能因版本号相同就混读正文。
|
|
24
24
|
|
|
@@ -54,7 +54,7 @@ plan-governance-cli init \
|
|
|
54
54
|
--update-agent-rules-only
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
升级已有项目的辅助文件,刷新 `scripts/check_plan_governance.py
|
|
57
|
+
升级已有项目的辅助文件,刷新 `scripts/check_plan_governance.py` 和 `AGENTS.md`,但不覆盖 `docs/` 或其他代理入口:
|
|
58
58
|
|
|
59
59
|
```bash
|
|
60
60
|
plan-governance-cli init \
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
同一交付范围只检查一次,通常在实现和自验收敛后、交付或高影响外部动作前;需要设计准入时将这一次前置,后续实施与完成自验。已审范围内的增量和修复合并处理,确有新增高风险范围才另行判断,不把每个修复拆成新范围;后续独立通过不能清除这一次检查留下的发现。
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
授权明确时自动安排一名未参与实现或测试编写的只读复核者,提供范围、差异、风险和证据入口,并要求其自行完成、不得再委派复核。创建复核 subagent 时必须显式传入推理强度,不依赖全局默认:涉及安全、权限、隐私、资金、数据完整性或同类高风险后果时用 `high`,其他独立复核用 `medium`;推理强度不改变是否复核、复核次数或完成判定。派发前复用已有同范围任务或结果;等待失败先核对准确任务 ID 与实际状态,只有确认原任务不存在或不可恢复才补发。冻结受审范围并告知变化。独立者给出发现后,实施者修复并验证原问题及受影响回归,不再送审,未解决则保持未完成。检查不可用/超时直接记录状态,不能伪填已完成结论;业务缺陷描述中的“超时”不代表检查未完成。复核不代替外部授权。
|
|
26
26
|
|
|
27
27
|
## Step 0 与阶段门
|
|
28
28
|
|
|
@@ -19,8 +19,6 @@ VALID_STATUSES = {
|
|
|
19
19
|
"已废弃",
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
CLAUDE_SECTION_BEGIN = "<!-- plan-governance:start -->"
|
|
23
|
-
CLAUDE_SECTION_END = "<!-- plan-governance:end -->"
|
|
24
22
|
AGENTS_SECTION_BEGIN = "<!-- plan-governance:start -->"
|
|
25
23
|
AGENTS_SECTION_END = "<!-- plan-governance:end -->"
|
|
26
24
|
|
|
@@ -72,10 +70,6 @@ def managed_section(begin, end):
|
|
|
72
70
|
return f"{begin}\n{agent_rules_body()}{end}\n"
|
|
73
71
|
|
|
74
72
|
|
|
75
|
-
def claude_md_section():
|
|
76
|
-
return managed_section(CLAUDE_SECTION_BEGIN, CLAUDE_SECTION_END)
|
|
77
|
-
|
|
78
|
-
|
|
79
73
|
def agents_md_section():
|
|
80
74
|
return managed_section(AGENTS_SECTION_BEGIN, AGENTS_SECTION_END)
|
|
81
75
|
|
|
@@ -105,16 +99,6 @@ def update_managed_file(root, filename, section, begin, end):
|
|
|
105
99
|
return target
|
|
106
100
|
|
|
107
101
|
|
|
108
|
-
def update_claude_md(root):
|
|
109
|
-
return update_managed_file(
|
|
110
|
-
root,
|
|
111
|
-
"CLAUDE.md",
|
|
112
|
-
claude_md_section(),
|
|
113
|
-
CLAUDE_SECTION_BEGIN,
|
|
114
|
-
CLAUDE_SECTION_END,
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
|
|
118
102
|
def update_agents_md(root):
|
|
119
103
|
return update_managed_file(
|
|
120
104
|
root,
|
|
@@ -126,7 +110,7 @@ def update_agents_md(root):
|
|
|
126
110
|
|
|
127
111
|
|
|
128
112
|
def update_agent_rules(root):
|
|
129
|
-
return [
|
|
113
|
+
return [update_agents_md(root)]
|
|
130
114
|
|
|
131
115
|
|
|
132
116
|
def plan_map_content(plan_slug, title, status, phase):
|
|
@@ -303,19 +287,16 @@ def parse_args(argv):
|
|
|
303
287
|
parser.add_argument("--status", default="设计中", choices=sorted(VALID_STATUSES), help="初始状态。")
|
|
304
288
|
parser.add_argument("--phase", default="阶段 0", help="当前阶段名称。")
|
|
305
289
|
parser.add_argument("--copy-checker", action="store_true", help="复制检查脚本到目标仓库 scripts/。")
|
|
306
|
-
parser.add_argument("--update-claude-md", action="store_true", help="创建或更新目标仓库 CLAUDE.md 中的计划治理规则。")
|
|
307
290
|
parser.add_argument("--update-agents-md", action="store_true", help="创建或更新目标仓库 AGENTS.md 中的计划治理规则。")
|
|
308
|
-
parser.add_argument("--update-agent-rules", action="store_true", help="
|
|
309
|
-
parser.add_argument("--update-claude-md-only", action="store_true", help="只创建或更新 CLAUDE.md,不初始化或覆盖 docs/。")
|
|
291
|
+
parser.add_argument("--update-agent-rules", action="store_true", help="创建或更新目标仓库 AGENTS.md 中的计划治理规则。")
|
|
310
292
|
parser.add_argument("--update-agents-md-only", action="store_true", help="只创建或更新 AGENTS.md,不初始化或覆盖 docs/。")
|
|
311
|
-
parser.add_argument("--update-agent-rules-only", action="store_true", help="只创建或更新
|
|
293
|
+
parser.add_argument("--update-agent-rules-only", action="store_true", help="只创建或更新 AGENTS.md,不初始化或覆盖 docs/。")
|
|
312
294
|
parser.add_argument("--upgrade-existing", action="store_true", help="升级已有项目的辅助文件:刷新检查脚本和代理规则,不覆盖 docs/。")
|
|
313
295
|
parser.add_argument("--migrate-plan-map-last-updated", action="store_true", help="将旧五列表 PLAN_MAP.md 迁移为包含最后更新的六列表。")
|
|
314
296
|
parser.add_argument("--last-updated-date", default=date.today().isoformat(), help="迁移 PLAN_MAP.md 时填入的最后更新日期,默认今天。")
|
|
315
297
|
parser.add_argument("--force", action="store_true", help="允许覆盖已存在的治理文件。")
|
|
316
298
|
args = parser.parse_args(argv)
|
|
317
299
|
only_modes = [
|
|
318
|
-
args.update_claude_md_only,
|
|
319
300
|
args.update_agents_md_only,
|
|
320
301
|
args.update_agent_rules_only,
|
|
321
302
|
args.upgrade_existing,
|
|
@@ -332,12 +313,6 @@ def main(argv=None):
|
|
|
332
313
|
args = parse_args(argv or sys.argv[1:])
|
|
333
314
|
root = Path(args.root).expanduser().resolve()
|
|
334
315
|
|
|
335
|
-
if args.update_claude_md_only:
|
|
336
|
-
target = update_claude_md(root)
|
|
337
|
-
print(f"已写入:{target}")
|
|
338
|
-
print("CLAUDE.md 已更新;未修改 docs/。")
|
|
339
|
-
return 0
|
|
340
|
-
|
|
341
316
|
if args.update_agents_md_only:
|
|
342
317
|
target = update_agents_md(root)
|
|
343
318
|
print(f"已写入:{target}")
|
|
@@ -390,11 +365,8 @@ def main(argv=None):
|
|
|
390
365
|
created.append(copy_checker(root, args.force))
|
|
391
366
|
if args.update_agent_rules:
|
|
392
367
|
created.extend(update_agent_rules(root))
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
created.append(update_claude_md(root))
|
|
396
|
-
if args.update_agents_md:
|
|
397
|
-
created.append(update_agents_md(root))
|
|
368
|
+
elif args.update_agents_md:
|
|
369
|
+
created.append(update_agents_md(root))
|
|
398
370
|
|
|
399
371
|
for path in created:
|
|
400
372
|
print(f"已写入:{path}")
|