release-skill 0.1.1 → 0.1.4
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +2 -2
- package/.codex-plugin/plugin.json +3 -3
- package/CHANGELOG.md +89 -0
- package/INSTALL.md +216 -5
- package/INSTALL.zh-CN.md +358 -0
- package/README.md +411 -67
- package/README.zh-CN.md +377 -59
- package/adapters/claude/.claude-plugin/marketplace.json +1 -1
- package/adapters/claude/.claude-plugin/plugin.json +1 -1
- package/adapters/claude/bin/release-skill.bundle.mjs +79284 -0
- package/adapters/claude/bin/release-skill.mjs +34 -0
- package/adapters/claude/native/safe-write/binding.gyp +40 -0
- package/adapters/claude/native/safe-write/prebuilds/darwin-arm64/safe_write.node +0 -0
- package/adapters/claude/native/safe-write/prebuilds.json +24 -0
- package/adapters/claude/native/safe-write/src/safe_write.cc +2032 -0
- package/adapters/claude/schemas/.render-manifest.json +37 -0
- package/adapters/claude/schemas/approval-record.schema.json +115 -0
- package/adapters/claude/schemas/artifact-lock.schema.json +111 -0
- package/adapters/claude/schemas/artifact-plan.schema.json +52 -0
- package/adapters/claude/schemas/artifact-policy.schema.json +76 -0
- package/adapters/claude/schemas/evidence-event.schema.json +89 -0
- package/adapters/claude/schemas/release-plan.schema.json +860 -0
- package/adapters/claude/schemas/release-project.schema.json +736 -0
- package/adapters/claude/schemas/release-run.schema.json +342 -0
- package/adapters/claude/skills/release-assess/SKILL.md +5 -6
- package/adapters/claude/skills/release-help/SKILL.md +14 -18
- package/adapters/claude/skills/release-prepare/SKILL.md +16 -6
- package/adapters/claude/skills/release-publish/SKILL.md +7 -7
- package/adapters/claude/skills/release-reconcile/SKILL.md +6 -6
- package/adapters/claude/skills/release-setup/SKILL.md +95 -0
- package/adapters/claude/skills/release-verify/SKILL.md +7 -7
- package/adapters/codex/.codex-plugin/plugin.json +2 -2
- package/adapters/codex/bin/release-skill.bundle.mjs +79284 -0
- package/adapters/codex/bin/release-skill.mjs +34 -0
- package/adapters/codex/native/safe-write/binding.gyp +40 -0
- package/adapters/codex/native/safe-write/prebuilds/darwin-arm64/safe_write.node +0 -0
- package/adapters/codex/native/safe-write/prebuilds.json +24 -0
- package/adapters/codex/native/safe-write/src/safe_write.cc +2032 -0
- package/adapters/codex/schemas/.render-manifest.json +37 -0
- package/adapters/codex/schemas/approval-record.schema.json +115 -0
- package/adapters/codex/schemas/artifact-lock.schema.json +111 -0
- package/adapters/codex/schemas/artifact-plan.schema.json +52 -0
- package/adapters/codex/schemas/artifact-policy.schema.json +76 -0
- package/adapters/codex/schemas/evidence-event.schema.json +89 -0
- package/adapters/codex/schemas/release-plan.schema.json +860 -0
- package/adapters/codex/schemas/release-project.schema.json +736 -0
- package/adapters/codex/schemas/release-run.schema.json +342 -0
- package/adapters/codex/skills/release-assess/SKILL.md +12 -6
- package/adapters/codex/skills/release-help/SKILL.md +21 -18
- package/adapters/codex/skills/release-prepare/SKILL.md +23 -6
- package/adapters/codex/skills/release-publish/SKILL.md +14 -7
- package/adapters/codex/skills/release-reconcile/SKILL.md +13 -6
- package/adapters/codex/skills/release-setup/SKILL.md +102 -0
- package/adapters/codex/skills/release-verify/SKILL.md +14 -7
- package/bin/release-skill-cli.mjs +807 -0
- package/bin/release-skill.bundle.mjs +79284 -0
- package/bin/release-skill.mjs +23 -732
- package/native/safe-write/prebuilds/darwin-arm64/safe_write.node +0 -0
- package/native/safe-write/prebuilds.json +22 -2
- package/native/safe-write/src/safe_write.cc +11 -2
- package/package.json +8 -2
- package/references/02-project-config.md +55 -4
- package/references/05-evidence-and-errors.md +6 -2
- package/schemas/release-plan.schema.json +556 -65
- package/schemas/release-project.schema.json +406 -29
- package/schemas/release-run.schema.json +165 -18
- package/scripts/build-bundle.mjs +133 -0
- package/skills/release-assess/SKILL.md +5 -6
- package/skills/release-help/SKILL.md +14 -18
- package/skills/release-prepare/SKILL.md +16 -6
- package/skills/release-publish/SKILL.md +7 -7
- package/skills/release-reconcile/SKILL.md +6 -6
- package/skills/release-setup/SKILL.md +95 -0
- package/skills/release-verify/SKILL.md +7 -7
- package/skills-src/release-assess/SKILL.md +5 -6
- package/skills-src/release-help/SKILL.md +14 -18
- package/skills-src/release-prepare/SKILL.md +16 -6
- package/skills-src/release-publish/SKILL.md +7 -7
- package/skills-src/release-reconcile/SKILL.md +6 -6
- package/skills-src/release-setup/SKILL.md +95 -0
- package/skills-src/release-verify/SKILL.md +7 -7
- package/src/adapters/contract.mjs +3 -0
- package/src/adapters/git-github.mjs +84 -2
- package/src/adapters/npm.mjs +5 -13
- package/src/adapters/plugin-marketplace.mjs +132 -52
- package/src/adapters/push-snapshot.mjs +84 -17
- package/src/artifacts/policy.mjs +4 -7
- package/src/artifacts/safe-fs-backend-internal.mjs +69 -21
- package/src/commands/prepare.mjs +244 -20
- package/src/commands/publish.mjs +46 -0
- package/src/commands/reconcile.mjs +152 -0
- package/src/commands/setup.mjs +1525 -0
- package/src/commands/verify.mjs +122 -26
- package/src/core/approval.mjs +4 -6
- package/src/core/config.mjs +42 -8
- package/src/core/errors.mjs +4 -0
- package/src/core/pkg-root.mjs +22 -0
- package/src/core/plan.mjs +132 -4
- package/src/core/previous-public-baseline.mjs +21 -1
- package/src/core/run.mjs +4 -4
- package/src/core/trusted-resource.mjs +96 -0
- package/src/core/verification-gates.mjs +451 -0
- package/src/docs/version-gate.mjs +164 -0
- package/src/producers/build-adapters.mjs +512 -55
- package/src/snapshot/frozen.mjs +221 -7
- package/src/snapshot/public-map.mjs +7 -4
- package/src/snapshot/scan.mjs +2 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: release-setup
|
|
3
|
+
description: "首次接入 release-skill:只读发现发布单元与个性化验证候选,机械提取提案,经人工确认 setupDigest 后仅首次创建配置"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# release-setup
|
|
7
|
+
|
|
8
|
+
## 适用场景
|
|
9
|
+
|
|
10
|
+
项目尚无 `.release-skill/project.yaml`,或用户要求初始化、接入、校准发布规则时使用。配置已存在时只审计并路由到 `release-assess`,不得重新生成。
|
|
11
|
+
|
|
12
|
+
## 硬边界
|
|
13
|
+
|
|
14
|
+
- 默认只读。README、slogan、CHANGELOG、业务脚本和已有配置均为人工权威内容,不得重写或覆盖。
|
|
15
|
+
- 发现脚本不等于选择或授权。间接脚本以 `SIDE_EFFECTS_UNPROVEN` 排除;项目特有 hook/gate 只能人工增量注册。
|
|
16
|
+
- 仓库、公开文件等证据冲突时停止自动提案,交给人工修正权威事实后重新发现。
|
|
17
|
+
- 写入只允许 create-once(仅创建一次),必须同时提供 answers 与精确 `setupDigest`;无安全原生写入能力时失败关闭。
|
|
18
|
+
- Agent 的多次 shell 调用彼此独立;只能用首轮打印的会话目录绝对路径续接,不得假设变量仍存在。
|
|
19
|
+
|
|
20
|
+
## 首次接入
|
|
21
|
+
|
|
22
|
+
1. 检查入口:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" help --json
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
2. 只读发现并机械提取提案。完整报告仅写入临时会话目录;不要设置 `trap EXIT`,确认前必须保留会话文件:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
set -eu
|
|
32
|
+
PROJECT=<项目绝对路径>
|
|
33
|
+
SETUP_SESSION="$(mktemp -d "${TMPDIR:-/tmp}/release-setup.XXXXXX")"
|
|
34
|
+
REPORT="$SETUP_SESSION/discovery.json"
|
|
35
|
+
ANSWERS="$SETUP_SESSION/answers.json"
|
|
36
|
+
printf 'SETUP_SESSION=%s\nPROJECT=%s\n' "$SETUP_SESSION" "$PROJECT"
|
|
37
|
+
set +e
|
|
38
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" setup --root "$PROJECT" --json > "$REPORT"
|
|
39
|
+
SETUP_STATUS=$?
|
|
40
|
+
set -e
|
|
41
|
+
[ "$SETUP_STATUS" -eq 0 ] || [ "$SETUP_STATUS" -eq 2 ] || exit "$SETUP_STATUS"
|
|
42
|
+
node -e 'const fs=require("node:fs");const r=JSON.parse(fs.readFileSync(process.argv[1],"utf8"));if(!r.compactSummary){console.error("compactSummary missing");process.exit(2)}process.stdout.write(JSON.stringify(r.compactSummary,null,2)+"\n")' "$REPORT"
|
|
43
|
+
node -e 'const fs=require("node:fs");const r=JSON.parse(fs.readFileSync(process.argv[1],"utf8"));if((r.proposalConflicts??[]).length){console.error("proposal conflicts require human resolution");process.exit(2)}if(!r.recommendedAnswers){console.error("recommendedAnswers missing");process.exit(2)}fs.writeFileSync(process.argv[2],JSON.stringify(r.recommendedAnswers,null,2)+"\n",{flag:"wx",mode:0o600})' "$REPORT" "$ANSWERS"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
若 `proposalConflicts` 非空,暂停,让用户修正仓库/映射权威事实,删除本会话目录后从第 2 步重跑,不得猜测选边。无冲突时可人工增量编辑 `answers.json`:hook 写入 `recommendedAnswers.projectConfig.hooks` 对应的 `projectConfig.hooks`;gate 写入 `verificationGates`,并把同一 id 加入 `selectedGateIds`。人工文件保持 `mode: preserve`,跨单元共享源使用 `sourceScope: workspace`。
|
|
47
|
+
|
|
48
|
+
3. 使用上一步打印的两个绝对字面量重新赋值,运行绑定 dry-run;任何人工编辑后都必须重跑本步:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
set -eu
|
|
52
|
+
SETUP_SESSION=<上一步打印的会话目录绝对路径>
|
|
53
|
+
PROJECT=<上一步打印的项目绝对路径>
|
|
54
|
+
ANSWERS="$SETUP_SESSION/answers.json"
|
|
55
|
+
BOUND_REPORT="$SETUP_SESSION/bound.json"
|
|
56
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" setup --root "$PROJECT" --answers "$ANSWERS" --json > "$BOUND_REPORT"
|
|
57
|
+
node -e 'const fs=require("node:fs");const r=JSON.parse(fs.readFileSync(process.argv[1],"utf8"));if(!r.compactSummary||!r.setupDigest){console.error("bound setup report incomplete");process.exit(2)}process.stdout.write(JSON.stringify({compactSummary:r.compactSummary,setupDigest:r.setupDigest},null,2)+"\n")' "$BOUND_REPORT"
|
|
58
|
+
printf 'SETUP_SESSION=%s\nPROJECT=%s\n' "$SETUP_SESSION" "$PROJECT"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
只向用户展示绑定摘要、配置差异和精确 `setupDigest`,取得一次明确确认。
|
|
62
|
+
|
|
63
|
+
4. 确认后用原会话与已确认摘要首次创建。三个完整报告均重定向到文件,固定提取器成功后才清理会话目录:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
set -eu
|
|
67
|
+
SETUP_SESSION=<已确认会话目录的绝对路径>
|
|
68
|
+
PROJECT=<已确认项目的绝对路径>
|
|
69
|
+
CONFIRMED_SETUP_DIGEST=<用户确认的精确 setupDigest>
|
|
70
|
+
ANSWERS="$SETUP_SESSION/answers.json"
|
|
71
|
+
CREATED_REPORT="$SETUP_SESSION/created.json"
|
|
72
|
+
POST_REPORT="$SETUP_SESSION/post-setup.json"
|
|
73
|
+
ASSESS_REPORT="$SETUP_SESSION/assess.json"
|
|
74
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" setup --root "$PROJECT" --answers "$ANSWERS" --write --confirm-setup "$CONFIRMED_SETUP_DIGEST" --json > "$CREATED_REPORT"
|
|
75
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" setup --root "$PROJECT" --json > "$POST_REPORT"
|
|
76
|
+
set +e
|
|
77
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" assess --root "$PROJECT" --offline --json > "$ASSESS_REPORT"
|
|
78
|
+
ASSESS_EXIT=$?
|
|
79
|
+
set -e
|
|
80
|
+
[ "$ASSESS_EXIT" -eq 0 ] || [ "$ASSESS_EXIT" -eq 1 ] || exit "$ASSESS_EXIT"
|
|
81
|
+
node -e 'const fs=require("node:fs");const [c,p,a]=process.argv.slice(1).map(x=>JSON.parse(fs.readFileSync(x,"utf8")));if(c.status!=="CONFIG_CREATED"||p.status!=="ALREADY_CONFIGURED"){console.error("setup lifecycle verification failed");process.exit(2)}if(!["ASSESSED","NEEDS_INPUT","BLOCKED"].includes(a.status)){console.error("assessment report invalid");process.exit(2)}const blocking=(a.gaps??[]).filter(g=>g.severity==="error").map(({code,scope,message})=>({code,scope,message}));process.stdout.write(JSON.stringify({created:{status:c.status,compactSummary:c.compactSummary},postSetup:{status:p.status,compactSummary:p.compactSummary},assessment:{status:a.status,summary:a.summary,gapCount:(a.gaps??[]).length,blockingGaps:blocking}},null,2)+"\n")' "$CREATED_REPORT" "$POST_REPORT" "$ASSESS_REPORT"
|
|
82
|
+
node -e 'require("node:fs").rmSync(process.argv[1],{recursive:true,force:false})' "$SETUP_SESSION"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## 故障路由
|
|
86
|
+
|
|
87
|
+
- `NEEDS_INPUT`:审阅紧凑摘要;有冲突先修正权威事实并重跑。
|
|
88
|
+
- `LOCAL_ONLY_DETECTED`:只能建立本地配置,由用户决定是否创建远端渠道。
|
|
89
|
+
- `ALREADY_CONFIGURED` / `CONFIG_EXISTS`:不覆盖,转 `release-assess`。
|
|
90
|
+
- `SETUP_DIGEST_MISMATCH`:事实或 answers 已变化,重新只读发现与确认。
|
|
91
|
+
- `SAFE_WRITE_UNAVAILABLE`:保留只读报告,不启用普通路径写入兜底。
|
|
92
|
+
|
|
93
|
+
## 完成标准
|
|
94
|
+
|
|
95
|
+
完整报告未进入 Agent 上下文;跨 shell 只靠显式会话路径续接;无冲突提案由机器机械提取;写入仅创建一次且摘要精确匹配;创建后状态和 assess 只输出紧凑结果;人工文件保持原字节。
|
|
@@ -28,18 +28,17 @@ verify 只接受 `PUBLISHED` 状态的源 run;`VERIFIED` 是终态,不会再
|
|
|
28
28
|
## 正向执行路径
|
|
29
29
|
|
|
30
30
|
1. 确认有 `--run` 路径(必需),且源 run 状态为 PUBLISHED
|
|
31
|
-
2.
|
|
31
|
+
2. 使用插件根相对路径运行 CLI;若存在 consumer gate 或 npm `smokeBin`,先逐项审阅并增加 `--acknowledge-gate-side-effects`
|
|
32
32
|
3. 检查 exit code 和结构化状态:`VERIFIED`(全部通过)/ 失败(具体错误)
|
|
33
33
|
4. 只有 `VERIFIED` 才是 happy end
|
|
34
34
|
|
|
35
35
|
## 确定性脚本调用
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
|
-
#
|
|
39
|
-
"${
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
node "$RELEASE_SKILL_HOME/packages/release-skill/bin/release-skill.mjs" verify --root <path> --plan <plan-path> --run <run-path> --json
|
|
38
|
+
# 从插件根运行
|
|
39
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" verify --root <path> --plan <plan-path> --run <run-path> --json
|
|
40
|
+
# 计划含 consumer gate 或 smokeBin 时:
|
|
41
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" verify --root <path> --plan <plan-path> --run <run-path> --acknowledge-gate-side-effects --json
|
|
43
42
|
```
|
|
44
43
|
|
|
45
44
|
## 验证步骤
|
|
@@ -56,7 +55,7 @@ node "$RELEASE_SKILL_HOME/packages/release-skill/bin/release-skill.mjs" verify -
|
|
|
56
55
|
- 在 `os.tmpdir()` 创建隔离目录
|
|
57
56
|
- 执行 `npm install <package>@<version>` 带安全标志
|
|
58
57
|
- 验证安装的 `package.json` name 和 version 精确匹配
|
|
59
|
-
- 若配置了 `smokeBin`:验证 bin 路径安全(无逃逸、无 symlink
|
|
58
|
+
- 若配置了 `smokeBin`:验证 bin 路径安全(无逃逸、无 symlink),从精确安装根、隔离 HOME 和最小环境执行并验证输出;这会运行已安装代码,必须显式授权
|
|
60
59
|
- 若未配置 `smokeBin`:仅安装 + name/version 检查即通过
|
|
61
60
|
|
|
62
61
|
## 常见错误
|
|
@@ -68,3 +67,4 @@ node "$RELEASE_SKILL_HOME/packages/release-skill/bin/release-skill.mjs" verify -
|
|
|
68
67
|
| 远端状态不匹配 | POST_PUBLISH_VERIFY_FAILED | 停止 |
|
|
69
68
|
| npm 安装失败 | POST_PUBLISH_VERIFY_FAILED | 停止 |
|
|
70
69
|
| CLI 烟雾输出不匹配 | POST_PUBLISH_VERIFY_FAILED | 停止 |
|
|
70
|
+
| consumer gate / smokeBin 未授权 | GATE_FAILED | 展示命令和副作用,人工确认后加 `--acknowledge-gate-side-effects` |
|
|
@@ -23,16 +23,15 @@ description: Identify project topology and evaluate gaps in public documentation
|
|
|
23
23
|
|
|
24
24
|
## 正向执行路径
|
|
25
25
|
|
|
26
|
-
1.
|
|
27
|
-
2.
|
|
28
|
-
3.
|
|
29
|
-
4.
|
|
30
|
-
5. 若 `NEEDS_INPUT`,根据报告补充配置后重跑,使用最新输出作为唯一证据
|
|
26
|
+
1. 使用插件根相对路径运行 CLI:`node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" assess --root <path> --offline --json`
|
|
27
|
+
2. 检查 exit code:0 = 成功,非 0 = 根据错误码处理
|
|
28
|
+
3. 读取 JSON 报告中的 `status` 字段(`ASSESSED` / `NEEDS_INPUT` / `BLOCKED`)
|
|
29
|
+
4. 若 `NEEDS_INPUT`,根据报告补充配置后重跑,使用最新输出作为唯一证据
|
|
31
30
|
|
|
32
31
|
## 确定性脚本调用
|
|
33
32
|
|
|
34
33
|
```bash
|
|
35
|
-
"${
|
|
34
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" assess --root <path> --offline --json
|
|
36
35
|
# 输出到文件: 加 --output <report-path>
|
|
37
36
|
```
|
|
38
37
|
|
|
@@ -12,34 +12,29 @@ description: "Discoverable entry point for release-skill: dependency and environ
|
|
|
12
12
|
## 职责
|
|
13
13
|
|
|
14
14
|
- 依赖和环境检查:Node.js >= 22、Git 决定本地准备就绪度;npm/gh 另行决定生产依赖就绪度
|
|
15
|
-
-
|
|
15
|
+
- 能力说明:缺少配置时走 `help → setup → assess`;已有配置的安全默认路径是 `help → assess → prepare --offline`;已有公开版本的生产闭环是显式的 `prepare --online --production → approve → publish → verify`
|
|
16
16
|
- 最小示例:展示从 release-help 到 release-assess 的最短路径
|
|
17
17
|
- 只读诊断:运行 dry-run 检查,不修改任何文件
|
|
18
18
|
- 故障引导:根据错误码指向对应的修复 Skill
|
|
19
19
|
|
|
20
20
|
**阶段通过规则**: `status` 与 `readiness.localPreparation.status` 只判断本地 help/assess/prepare;其充要条件是 `READY` 且 exit code 为 0。`missingRequired` 列出缺失的 Node/Git。生产发布必须另外读取 `readiness.productionPublish`:缺少 npm/gh 时为 `NOT_READY`,依赖存在时仍是 `AUTH_CHECK_REQUIRED`,因为 help 不访问网络、不验证认证。Agent 无权把本地就绪解释为生产就绪。
|
|
21
21
|
|
|
22
|
-
**边界**: help 不修改文件系统、不执行外部写操作、不生成发布计划。优先探测 PATH 上的全局安装命令 `release-skill`,不可用时回退到源码路径。每个 unit 必须配置 `previousPublicBaseline`:首次发布且确认无前序版本用 none,已有版本用 bound + repo/ref/commit;none 不是绕过 publish 唯一性预检的开关。GitHub/npm
|
|
22
|
+
**边界**: help 不修改文件系统、不执行外部写操作、不生成发布计划。优先探测 PATH 上的全局安装命令 `release-skill`,不可用时回退到源码路径。每个 unit 必须配置 `previousPublicBaseline`:首次发布且确认无前序版本用 none,已有版本用 bound + repo/ref/commit;none 不是绕过 publish 唯一性预检的开关。v0.1.1 已完成 GitHub/npm 真实生产发布、冻结 Git ref 的 Claude/Codex 消费者安装、精确 npm 安装 smoke 与最终 VERIFIED;生产等价本地协议套件继续覆盖 fake gh/npm/Claude/Codex 和本地 bare Git。测试未做 OS 级禁网,且一次成功发布不能证明其他项目的认证、权限、限流或最终一致性行为;每个项目的首次生产发布仍应作为受监控 canary。
|
|
23
23
|
|
|
24
24
|
## 正向执行路径
|
|
25
25
|
|
|
26
|
-
1.
|
|
27
|
-
2.
|
|
28
|
-
3.
|
|
29
|
-
4.
|
|
30
|
-
5. 默认在审阅本地计划和快照后停止;只有用户明确要求且完成摘要审批时才路由到 `release-publish`
|
|
26
|
+
1. 使用插件根相对路径运行 CLI:`node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" help --json`
|
|
27
|
+
2. 检查 `readiness.localPreparation`;需要生产发布时再检查 `readiness.productionPublish`
|
|
28
|
+
3. 若环境就绪且缺少 `.release-skill/project.yaml`,先路由 `release-setup`;配置已存在才运行 `release-assess`
|
|
29
|
+
4. 默认在审阅本地计划和快照后停止;只有用户明确要求且完成摘要审批时才路由到 `release-publish`
|
|
31
30
|
|
|
32
31
|
## 确定性脚本调用
|
|
33
32
|
|
|
34
33
|
```bash
|
|
35
|
-
#
|
|
36
|
-
release-skill help --json
|
|
37
|
-
release-skill
|
|
38
|
-
|
|
39
|
-
# 从源码 checkout 运行
|
|
40
|
-
RELEASE_SKILL_HOME=/path/to/release-skill
|
|
41
|
-
node "$RELEASE_SKILL_HOME/packages/release-skill/bin/release-skill.mjs" help --json
|
|
42
|
-
node "$RELEASE_SKILL_HOME/packages/release-skill/bin/release-skill.mjs" assess --root <path> --offline --json
|
|
34
|
+
# 从插件根运行(自包含 bundle,无需 node_modules)
|
|
35
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" help --json
|
|
36
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" setup --root <path> --json
|
|
37
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" assess --root <path> --offline --json
|
|
43
38
|
```
|
|
44
39
|
|
|
45
40
|
## 故障路由
|
|
@@ -51,10 +46,11 @@ node "$RELEASE_SKILL_HOME/packages/release-skill/bin/release-skill.mjs" assess -
|
|
|
51
46
|
| pnpm 未安装 | 不影响本地准备;仅出现在 recommendations 中 |
|
|
52
47
|
| npm/gh 未安装 | 本地准备仍可就绪,但 `readiness.productionPublish.status` 为 `NOT_READY` |
|
|
53
48
|
| npm/gh 已安装 | 生产状态仍为 `AUTH_CHECK_REQUIRED`;发布前验证 `gh auth`、Git HTTPS credential 和 npm auth |
|
|
54
|
-
| CLI 入口不存在 |
|
|
55
|
-
|
|
|
49
|
+
| CLI 入口不存在 | 确认 `${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs` 存在;不存在时重新安装插件 |
|
|
50
|
+
| 项目配置不存在 | 路由 `release-setup`,默认只读;不得直接生成或覆盖 README/配置 |
|
|
51
|
+
| assess 失败 | 运行 `node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" assess --offline --json` 获取详情 |
|
|
56
52
|
| 请求生产发布 | 已有公开版本先调用 `release-prepare --online --production` 观察 bound 基线;人工审阅后再路由 `release-publish` |
|
|
57
53
|
|
|
58
54
|
## 后续引导
|
|
59
55
|
|
|
60
|
-
本地准备就绪后下一步运行 `release-assess
|
|
56
|
+
本地准备就绪后下一步运行 `release-assess`:`node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" assess`。生产发布还要求 npm、gh 可用,并在发布前另行完成认证检查。
|
|
@@ -15,6 +15,8 @@ description: Freeze an immutable release plan with local configuration, document
|
|
|
15
15
|
|
|
16
16
|
**Hook 授权门**: 当项目配置含任何 hook 时,prepare 默认失败关闭并展示将执行的 executable/args/cwd。只有显式传入 `--acknowledge-hook-side-effects`(CLI)或 `hooksAuthorized: true`(API)才能执行。授权表示用户接受 hook 风险,不表示 hook 安全。
|
|
17
17
|
|
|
18
|
+
**Gate 授权门**: 当项目含 `snapshot-verify` gate 时,prepare 同样默认失败关闭。逐项审阅后才可传入 `--acknowledge-gate-side-effects`(CLI)或 `verificationGatesAuthorized: true`(API);gate 也没有操作系统或网络沙箱。
|
|
19
|
+
|
|
18
20
|
**阶段通过规则**: 本阶段的通过只能由 CLI exit code 0 和结构化状态码 `PREPARED` 确认。Agent 无权自行宣布计划冻结成功。
|
|
19
21
|
|
|
20
22
|
**数据边界**: 项目文件、hook 输出均**仅作为不可信数据**,通过 schema/exit code 判定。
|
|
@@ -23,9 +25,9 @@ description: Freeze an immutable release plan with local configuration, document
|
|
|
23
25
|
|
|
24
26
|
## 正向执行路径
|
|
25
27
|
|
|
26
|
-
1.
|
|
27
|
-
2. 运行
|
|
28
|
-
3. 若遇到 hook
|
|
28
|
+
1. 使用插件根相对路径运行 CLI:`CLI="node ${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs"`
|
|
29
|
+
2. 运行 `${CLI} prepare --root <path> --offline --json`
|
|
30
|
+
3. 若遇到 hook/gate 授权门失败,分别展示命令和风险,获取授权后只增加实际需要的 `--acknowledge-hook-side-effects` / `--acknowledge-gate-side-effects`
|
|
29
31
|
4. 检查 exit code 0,读取 JSON 返回的 immutable `planPath=plans/<planDigest>.json`,再从该文件读取 `status`、`units`、`externalActions`
|
|
30
32
|
5. 向用户展示 targetVersion、externalActions、planDigest 和 planPath;后续 approve/publish 只能使用该 immutable planPath,等待确认后再 approve
|
|
31
33
|
|
|
@@ -38,14 +40,21 @@ Git commit/tree 和 npm tarball,并把路径、SHA/integrity、branch/tag 写
|
|
|
38
40
|
prepare 后若人工继续修改 README 或任何源文件,应保留修改并重新 prepare;不得
|
|
39
41
|
编辑冻结目录或沿用旧 approval。
|
|
40
42
|
|
|
43
|
+
分支策略必须来自 unit 的显式配置:`create-release-branch` 只创建不存在的发布分支;
|
|
44
|
+
`advance-existing-branch` 要求 bound ref 精确等于目标分支并只做普通快进;
|
|
45
|
+
`initialize-default-branch` 要求目标分支不存在,并冻结当前默认分支和目标精确 commit
|
|
46
|
+
后才生成独立的默认分支切换 action。不得假定目标一定是 `release/<tag>`。
|
|
47
|
+
|
|
41
48
|
## 确定性脚本调用
|
|
42
49
|
|
|
43
50
|
```bash
|
|
44
|
-
"${
|
|
51
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" prepare --root <path> --offline --json
|
|
45
52
|
# 生产 happy end:bound 基线必须 online;远端目标唯一性仍由 publish 全局预检
|
|
46
|
-
"${
|
|
53
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" prepare --root <path> --online --production --json
|
|
47
54
|
# 项目含 hook 时需显式授权:
|
|
48
|
-
"${
|
|
55
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" prepare --root <path> --offline --acknowledge-hook-side-effects --json
|
|
56
|
+
# 项目含 snapshot gate 时另行显式授权:
|
|
57
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" prepare --root <path> --offline --acknowledge-gate-side-effects --json
|
|
49
58
|
```
|
|
50
59
|
|
|
51
60
|
## 执行顺序
|
|
@@ -58,6 +67,7 @@ prepare 后若人工继续修改 README 或任何源文件,应保留修改并
|
|
|
58
67
|
| 错误码 | 处理 |
|
|
59
68
|
|---|---|
|
|
60
69
|
| GATE_FAILED (hook 授权) | 向用户展示 hook 命令和风险,获得授权后加 `--acknowledge-hook-side-effects` 重试 |
|
|
70
|
+
| GATE_FAILED (gate 授权) | 向用户展示 snapshot gate 命令和风险,获得授权后加 `--acknowledge-gate-side-effects` 重试 |
|
|
61
71
|
| GATE_FAILED (bound + offline) | 改用 `--online --production`,不得把 unobserved-offline plan 交给 publish |
|
|
62
72
|
| GATE_FAILED (前序基线漂移) | 先取得并比较实际远端内容;人工选择 merge/adopt/reject。merge/adopt 都必须把接受内容落回 human-owned 权威源,并把 `previousPublicBaseline` 更新为接受状态的精确 repo/ref/commit 后重新 online production prepare;reject 停止调查,禁止改 `mode: none` 绕过 |
|
|
63
73
|
| GATE_FAILED (其他) | 修复门失败原因后重试;以 CLI exit code 为准 |
|
|
@@ -18,7 +18,8 @@ description: 从已批准且摘要确认的生产计划发布冻结 Git branch/t
|
|
|
18
18
|
|
|
19
19
|
只发布 `prepare --production` 封存的 Git object 和 npm tarball,不从活动工作区重新
|
|
20
20
|
打包,不生成或覆盖 README。远端 branch/tag/Release/npm version 已存在、查询不确定、
|
|
21
|
-
|
|
21
|
+
认证失败或摘要漂移时,在全局预检阶段停止并交给人工。禁止覆盖、删除和自动回滚;
|
|
22
|
+
新建 ref 的 create-only CAS(`--force-with-lease=<ref>:`)只断言目标不存在,不授权覆盖。
|
|
22
23
|
|
|
23
24
|
## 授权门
|
|
24
25
|
|
|
@@ -30,15 +31,14 @@ description: 从已批准且摘要确认的生产计划发布冻结 Git branch/t
|
|
|
30
31
|
## 确定性执行
|
|
31
32
|
|
|
32
33
|
```bash
|
|
33
|
-
"${
|
|
34
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" publish --root <path> --plan <plan-path> \
|
|
34
35
|
--approval <approval-path> --confirm-production <planDigest> --json
|
|
35
36
|
```
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
执行顺序:全局只读预检 → `release/<tag>` 公开分支 → tag → npm tarball →
|
|
38
|
+
执行顺序:全局只读预检 → 配置的公开分支(按三种 `branchStrategy` 执行)→ 必要时
|
|
39
|
+
单独切换默认分支 → tag → npm tarball →
|
|
41
40
|
GitHub Release → Claude/Codex marketplace 隔离安装。每步 execute 后立即 observe;
|
|
41
|
+
默认分支 action 同时绑定名称和目标精确 commit;末尾再次核对分支/默认分支一致性。
|
|
42
42
|
失败停止后续动作并记录 PARTIAL。PUBLISHED 后运行 verify 复核全新消费者安装。
|
|
43
43
|
|
|
44
44
|
## 故障路由
|
|
@@ -47,7 +47,7 @@ GitHub Release → Claude/Codex marketplace 隔离安装。每步 execute 后立
|
|
|
47
47
|
|---|---|
|
|
48
48
|
| `BASELINE_CHANGED` | 保留人工修改,重新 prepare、审阅和 approve;不要覆盖修改。 |
|
|
49
49
|
| 摘要/制品不匹配 | 停止;重新 prepare,不修补冻结目录。 |
|
|
50
|
-
| 远端对象已存在 |
|
|
50
|
+
| 远端对象已存在 | 人工判断版本或远端状态;不得覆盖。create-only CAS 也必须失败关闭。 |
|
|
51
51
|
| 认证/网络/未知查询错误 | 失败关闭,修复环境后基于同一证据判断是否 reconcile。 |
|
|
52
52
|
| `PARTIAL` | 检查 `release-run.json`,不重跑整套发布、不删除成功对象。 |
|
|
53
53
|
|
|
@@ -29,8 +29,8 @@ marketplace 隔离消费者 checkpoint,但只恢复到 `PUBLISHED`;最终 np
|
|
|
29
29
|
|
|
30
30
|
## 正向执行路径
|
|
31
31
|
|
|
32
|
-
1.
|
|
33
|
-
2. 运行 `"${
|
|
32
|
+
1. 使用插件根相对路径运行 CLI,确认有 `--run` 路径(必需),且源 run 状态为 `PARTIAL`
|
|
33
|
+
2. 运行 `node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" reconcile --root <path> --plan <plan-path> --run <run-path> --json`
|
|
34
34
|
3. 检查 exit code 和结构化状态:`PUBLISHED`(恢复完成,待 verify)/ `PARTIAL`(需重试)/ `BLOCKED`(需人工决策)
|
|
35
35
|
4. 若 PARTIAL 且需重试,加 `--approval`;生产计划还必须加 `--confirm-production <planDigest>`
|
|
36
36
|
|
|
@@ -38,16 +38,16 @@ marketplace 隔离消费者 checkpoint,但只恢复到 `PUBLISHED`;最终 np
|
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
40
|
# reconcile
|
|
41
|
-
"${
|
|
41
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" reconcile --root <path> --plan <plan-path> --run <run-path> --json
|
|
42
42
|
# verify
|
|
43
|
-
"${
|
|
43
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" verify --root <path> --plan <plan-path> --run <reconcile-run-path> --json
|
|
44
44
|
# 重试(需 --approval)
|
|
45
|
-
"${
|
|
45
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" reconcile --root <path> --plan <plan-path> --run <run-path> --approval <approval-path> --confirm-production <planDigest> --json
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
## 幂等跳过逻辑
|
|
49
49
|
|
|
50
|
-
对每个 action: observe 远端状态 → 完全一致则跳过 → 不存在且在 approval 范围内则重试 → 不一致则 REMOTE_CONFLICT
|
|
50
|
+
对每个 action: observe 远端状态 → 完全一致则跳过 → 不存在且在 approval 范围内则重试 → 不一致则 REMOTE_CONFLICT 错误停止。`advance-existing-branch` 额外区分“冻结旧 commit”(可重试)、“计划新 commit”(已推进)和第三方 commit(冲突);不得把自己已成功的推进误判为前序基线漂移。
|
|
51
51
|
|
|
52
52
|
## 故障路由
|
|
53
53
|
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: release-setup
|
|
3
|
+
description: "首次接入 release-skill:只读发现发布单元与个性化验证候选,机械提取提案,经人工确认 setupDigest 后仅首次创建配置"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# release-setup
|
|
7
|
+
|
|
8
|
+
## 适用场景
|
|
9
|
+
|
|
10
|
+
项目尚无 `.release-skill/project.yaml`,或用户要求初始化、接入、校准发布规则时使用。配置已存在时只审计并路由到 `release-assess`,不得重新生成。
|
|
11
|
+
|
|
12
|
+
## 硬边界
|
|
13
|
+
|
|
14
|
+
- 默认只读。README、slogan、CHANGELOG、业务脚本和已有配置均为人工权威内容,不得重写或覆盖。
|
|
15
|
+
- 发现脚本不等于选择或授权。间接脚本以 `SIDE_EFFECTS_UNPROVEN` 排除;项目特有 hook/gate 只能人工增量注册。
|
|
16
|
+
- 仓库、公开文件等证据冲突时停止自动提案,交给人工修正权威事实后重新发现。
|
|
17
|
+
- 写入只允许 create-once(仅创建一次),必须同时提供 answers 与精确 `setupDigest`;无安全原生写入能力时失败关闭。
|
|
18
|
+
- Agent 的多次 shell 调用彼此独立;只能用首轮打印的会话目录绝对路径续接,不得假设变量仍存在。
|
|
19
|
+
|
|
20
|
+
## 首次接入
|
|
21
|
+
|
|
22
|
+
1. 检查入口:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" help --json
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
2. 只读发现并机械提取提案。完整报告仅写入临时会话目录;不要设置 `trap EXIT`,确认前必须保留会话文件:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
set -eu
|
|
32
|
+
PROJECT=<项目绝对路径>
|
|
33
|
+
SETUP_SESSION="$(mktemp -d "${TMPDIR:-/tmp}/release-setup.XXXXXX")"
|
|
34
|
+
REPORT="$SETUP_SESSION/discovery.json"
|
|
35
|
+
ANSWERS="$SETUP_SESSION/answers.json"
|
|
36
|
+
printf 'SETUP_SESSION=%s\nPROJECT=%s\n' "$SETUP_SESSION" "$PROJECT"
|
|
37
|
+
set +e
|
|
38
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" setup --root "$PROJECT" --json > "$REPORT"
|
|
39
|
+
SETUP_STATUS=$?
|
|
40
|
+
set -e
|
|
41
|
+
[ "$SETUP_STATUS" -eq 0 ] || [ "$SETUP_STATUS" -eq 2 ] || exit "$SETUP_STATUS"
|
|
42
|
+
node -e 'const fs=require("node:fs");const r=JSON.parse(fs.readFileSync(process.argv[1],"utf8"));if(!r.compactSummary){console.error("compactSummary missing");process.exit(2)}process.stdout.write(JSON.stringify(r.compactSummary,null,2)+"\n")' "$REPORT"
|
|
43
|
+
node -e 'const fs=require("node:fs");const r=JSON.parse(fs.readFileSync(process.argv[1],"utf8"));if((r.proposalConflicts??[]).length){console.error("proposal conflicts require human resolution");process.exit(2)}if(!r.recommendedAnswers){console.error("recommendedAnswers missing");process.exit(2)}fs.writeFileSync(process.argv[2],JSON.stringify(r.recommendedAnswers,null,2)+"\n",{flag:"wx",mode:0o600})' "$REPORT" "$ANSWERS"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
若 `proposalConflicts` 非空,暂停,让用户修正仓库/映射权威事实,删除本会话目录后从第 2 步重跑,不得猜测选边。无冲突时可人工增量编辑 `answers.json`:hook 写入 `recommendedAnswers.projectConfig.hooks` 对应的 `projectConfig.hooks`;gate 写入 `verificationGates`,并把同一 id 加入 `selectedGateIds`。人工文件保持 `mode: preserve`,跨单元共享源使用 `sourceScope: workspace`。
|
|
47
|
+
|
|
48
|
+
3. 使用上一步打印的两个绝对字面量重新赋值,运行绑定 dry-run;任何人工编辑后都必须重跑本步:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
set -eu
|
|
52
|
+
SETUP_SESSION=<上一步打印的会话目录绝对路径>
|
|
53
|
+
PROJECT=<上一步打印的项目绝对路径>
|
|
54
|
+
ANSWERS="$SETUP_SESSION/answers.json"
|
|
55
|
+
BOUND_REPORT="$SETUP_SESSION/bound.json"
|
|
56
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" setup --root "$PROJECT" --answers "$ANSWERS" --json > "$BOUND_REPORT"
|
|
57
|
+
node -e 'const fs=require("node:fs");const r=JSON.parse(fs.readFileSync(process.argv[1],"utf8"));if(!r.compactSummary||!r.setupDigest){console.error("bound setup report incomplete");process.exit(2)}process.stdout.write(JSON.stringify({compactSummary:r.compactSummary,setupDigest:r.setupDigest},null,2)+"\n")' "$BOUND_REPORT"
|
|
58
|
+
printf 'SETUP_SESSION=%s\nPROJECT=%s\n' "$SETUP_SESSION" "$PROJECT"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
只向用户展示绑定摘要、配置差异和精确 `setupDigest`,取得一次明确确认。
|
|
62
|
+
|
|
63
|
+
4. 确认后用原会话与已确认摘要首次创建。三个完整报告均重定向到文件,固定提取器成功后才清理会话目录:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
set -eu
|
|
67
|
+
SETUP_SESSION=<已确认会话目录的绝对路径>
|
|
68
|
+
PROJECT=<已确认项目的绝对路径>
|
|
69
|
+
CONFIRMED_SETUP_DIGEST=<用户确认的精确 setupDigest>
|
|
70
|
+
ANSWERS="$SETUP_SESSION/answers.json"
|
|
71
|
+
CREATED_REPORT="$SETUP_SESSION/created.json"
|
|
72
|
+
POST_REPORT="$SETUP_SESSION/post-setup.json"
|
|
73
|
+
ASSESS_REPORT="$SETUP_SESSION/assess.json"
|
|
74
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" setup --root "$PROJECT" --answers "$ANSWERS" --write --confirm-setup "$CONFIRMED_SETUP_DIGEST" --json > "$CREATED_REPORT"
|
|
75
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" setup --root "$PROJECT" --json > "$POST_REPORT"
|
|
76
|
+
set +e
|
|
77
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" assess --root "$PROJECT" --offline --json > "$ASSESS_REPORT"
|
|
78
|
+
ASSESS_EXIT=$?
|
|
79
|
+
set -e
|
|
80
|
+
[ "$ASSESS_EXIT" -eq 0 ] || [ "$ASSESS_EXIT" -eq 1 ] || exit "$ASSESS_EXIT"
|
|
81
|
+
node -e 'const fs=require("node:fs");const [c,p,a]=process.argv.slice(1).map(x=>JSON.parse(fs.readFileSync(x,"utf8")));if(c.status!=="CONFIG_CREATED"||p.status!=="ALREADY_CONFIGURED"){console.error("setup lifecycle verification failed");process.exit(2)}if(!["ASSESSED","NEEDS_INPUT","BLOCKED"].includes(a.status)){console.error("assessment report invalid");process.exit(2)}const blocking=(a.gaps??[]).filter(g=>g.severity==="error").map(({code,scope,message})=>({code,scope,message}));process.stdout.write(JSON.stringify({created:{status:c.status,compactSummary:c.compactSummary},postSetup:{status:p.status,compactSummary:p.compactSummary},assessment:{status:a.status,summary:a.summary,gapCount:(a.gaps??[]).length,blockingGaps:blocking}},null,2)+"\n")' "$CREATED_REPORT" "$POST_REPORT" "$ASSESS_REPORT"
|
|
82
|
+
node -e 'require("node:fs").rmSync(process.argv[1],{recursive:true,force:false})' "$SETUP_SESSION"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## 故障路由
|
|
86
|
+
|
|
87
|
+
- `NEEDS_INPUT`:审阅紧凑摘要;有冲突先修正权威事实并重跑。
|
|
88
|
+
- `LOCAL_ONLY_DETECTED`:只能建立本地配置,由用户决定是否创建远端渠道。
|
|
89
|
+
- `ALREADY_CONFIGURED` / `CONFIG_EXISTS`:不覆盖,转 `release-assess`。
|
|
90
|
+
- `SETUP_DIGEST_MISMATCH`:事实或 answers 已变化,重新只读发现与确认。
|
|
91
|
+
- `SAFE_WRITE_UNAVAILABLE`:保留只读报告,不启用普通路径写入兜底。
|
|
92
|
+
|
|
93
|
+
## 完成标准
|
|
94
|
+
|
|
95
|
+
完整报告未进入 Agent 上下文;跨 shell 只靠显式会话路径续接;无冲突提案由机器机械提取;写入仅创建一次且摘要精确匹配;创建后状态和 assess 只输出紧凑结果;人工文件保持原字节。
|
|
@@ -28,18 +28,17 @@ verify 只接受 `PUBLISHED` 状态的源 run;`VERIFIED` 是终态,不会再
|
|
|
28
28
|
## 正向执行路径
|
|
29
29
|
|
|
30
30
|
1. 确认有 `--run` 路径(必需),且源 run 状态为 PUBLISHED
|
|
31
|
-
2.
|
|
31
|
+
2. 使用插件根相对路径运行 CLI;若存在 consumer gate 或 npm `smokeBin`,先逐项审阅并增加 `--acknowledge-gate-side-effects`
|
|
32
32
|
3. 检查 exit code 和结构化状态:`VERIFIED`(全部通过)/ 失败(具体错误)
|
|
33
33
|
4. 只有 `VERIFIED` 才是 happy end
|
|
34
34
|
|
|
35
35
|
## 确定性脚本调用
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
|
-
#
|
|
39
|
-
"${
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
node "$RELEASE_SKILL_HOME/packages/release-skill/bin/release-skill.mjs" verify --root <path> --plan <plan-path> --run <run-path> --json
|
|
38
|
+
# 从插件根运行
|
|
39
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" verify --root <path> --plan <plan-path> --run <run-path> --json
|
|
40
|
+
# 计划含 consumer gate 或 smokeBin 时:
|
|
41
|
+
node "${CLAUDE_PLUGIN_ROOT}/bin/release-skill.mjs" verify --root <path> --plan <plan-path> --run <run-path> --acknowledge-gate-side-effects --json
|
|
43
42
|
```
|
|
44
43
|
|
|
45
44
|
## 验证步骤
|
|
@@ -56,7 +55,7 @@ node "$RELEASE_SKILL_HOME/packages/release-skill/bin/release-skill.mjs" verify -
|
|
|
56
55
|
- 在 `os.tmpdir()` 创建隔离目录
|
|
57
56
|
- 执行 `npm install <package>@<version>` 带安全标志
|
|
58
57
|
- 验证安装的 `package.json` name 和 version 精确匹配
|
|
59
|
-
- 若配置了 `smokeBin`:验证 bin 路径安全(无逃逸、无 symlink
|
|
58
|
+
- 若配置了 `smokeBin`:验证 bin 路径安全(无逃逸、无 symlink),从精确安装根、隔离 HOME 和最小环境执行并验证输出;这会运行已安装代码,必须显式授权
|
|
60
59
|
- 若未配置 `smokeBin`:仅安装 + name/version 检查即通过
|
|
61
60
|
|
|
62
61
|
## 常见错误
|
|
@@ -68,3 +67,4 @@ node "$RELEASE_SKILL_HOME/packages/release-skill/bin/release-skill.mjs" verify -
|
|
|
68
67
|
| 远端状态不匹配 | POST_PUBLISH_VERIFY_FAILED | 停止 |
|
|
69
68
|
| npm 安装失败 | POST_PUBLISH_VERIFY_FAILED | 停止 |
|
|
70
69
|
| CLI 烟雾输出不匹配 | POST_PUBLISH_VERIFY_FAILED | 停止 |
|
|
70
|
+
| consumer gate / smokeBin 未授权 | GATE_FAILED | 展示命令和副作用,人工确认后加 `--acknowledge-gate-side-effects` |
|
|
@@ -57,6 +57,9 @@ export const ActionType = Object.freeze({
|
|
|
57
57
|
// consumer marketplace install (production)
|
|
58
58
|
CLAUDE_MARKETPLACE_INSTALL: 'claude-marketplace-install',
|
|
59
59
|
CODEX_MARKETPLACE_INSTALL: 'codex-marketplace-install',
|
|
60
|
+
|
|
61
|
+
// default branch management
|
|
62
|
+
SET_DEFAULT_BRANCH: 'set-default-branch',
|
|
60
63
|
});
|
|
61
64
|
|
|
62
65
|
/**
|
|
@@ -25,7 +25,7 @@ async function run(command, args, options = {}) {
|
|
|
25
25
|
|
|
26
26
|
function isNotFound(error) {
|
|
27
27
|
const text = `${error?.stdout ?? ''}\n${error?.stderr ?? ''}\n${error?.message ?? ''}`;
|
|
28
|
-
return /(?:HTTP\s+404|\bstatus(?: code)?\s*[:=]?\s*404\b)/i.test(text);
|
|
28
|
+
return /(?:HTTP\s+404|\bstatus(?: code)?\s*[:=]?\s*404\b|(?:^|\n)\s*release not found\s*(?:\n|$))/i.test(text);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
function ghRepo(action) {
|
|
@@ -62,11 +62,40 @@ async function readRemoteTag(action, remoteUrl, exec) {
|
|
|
62
62
|
return stdout.trim().split(/\s+/)[0] ?? '';
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
function validateDefaultBranchAction(action) {
|
|
66
|
+
if (!action.repo || !action.oldBranch || !action.newBranch || !action.expectedNewBranchCommit) {
|
|
67
|
+
throw new Error('set-default-branch requires repo, oldBranch, newBranch, and expectedNewBranchCommit');
|
|
68
|
+
}
|
|
69
|
+
validateOid(action.expectedNewBranchCommit);
|
|
70
|
+
githubRepositoryUrl(action.repo, action.githubHost);
|
|
71
|
+
for (const [label, branch] of [['oldBranch', action.oldBranch], ['newBranch', action.newBranch]]) {
|
|
72
|
+
if (
|
|
73
|
+
typeof branch !== 'string' || branch.length === 0 || branch.startsWith('/') ||
|
|
74
|
+
branch.endsWith('/') || branch.includes('..') || branch.includes('\\') || /[\s~^:?*[\]]/.test(branch)
|
|
75
|
+
) {
|
|
76
|
+
throw new Error(`${label} is not a safe Git branch name`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (action.oldBranch === action.newBranch) {
|
|
80
|
+
throw new Error('set-default-branch oldBranch and newBranch must differ');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function readRemoteBranchCommit(action, exec) {
|
|
85
|
+
const remoteUrl = githubRepositoryUrl(action.repo, action.githubHost);
|
|
86
|
+
const { stdout } = await exec(
|
|
87
|
+
'git',
|
|
88
|
+
['ls-remote', '--heads', remoteUrl, `refs/heads/${action.newBranch}`],
|
|
89
|
+
{ shell: false },
|
|
90
|
+
);
|
|
91
|
+
return stdout.trim().split(/\s+/)[0] ?? '';
|
|
92
|
+
}
|
|
93
|
+
|
|
65
94
|
export function createGitGithubAdapter(deps = {}) {
|
|
66
95
|
const exec = deps.exec ?? run;
|
|
67
96
|
return Object.freeze({
|
|
68
97
|
name: NAME,
|
|
69
|
-
actionTypes: Object.freeze([ActionType.GIT_PUSH, ActionType.GIT_TAG, ActionType.GITHUB_RELEASE]),
|
|
98
|
+
actionTypes: Object.freeze([ActionType.GIT_PUSH, ActionType.GIT_TAG, ActionType.GITHUB_RELEASE, ActionType.SET_DEFAULT_BRANCH]),
|
|
70
99
|
|
|
71
100
|
async preflight(action, context) {
|
|
72
101
|
try {
|
|
@@ -104,6 +133,27 @@ export function createGitGithubAdapter(deps = {}) {
|
|
|
104
133
|
if (err.message?.includes('already exists')) throw err;
|
|
105
134
|
if (!isNotFound(err)) throw new Error(`cannot determine GitHub Release uniqueness: ${err.message}`);
|
|
106
135
|
}
|
|
136
|
+
} else if (action.actionType === ActionType.SET_DEFAULT_BRANCH) {
|
|
137
|
+
validateDefaultBranchAction(action);
|
|
138
|
+
await exec('gh', ['auth', 'status'], {
|
|
139
|
+
cwd: context.root,
|
|
140
|
+
shell: false,
|
|
141
|
+
env: { ...process.env, GH_HOST: action.githubHost ?? 'github.com' },
|
|
142
|
+
});
|
|
143
|
+
const { stdout: current } = await exec('gh', ['api', `repos/${action.repo}`, '--jq', '.default_branch'], {
|
|
144
|
+
cwd: context.root,
|
|
145
|
+
shell: false,
|
|
146
|
+
env: { ...process.env, GH_HOST: action.githubHost ?? 'github.com' },
|
|
147
|
+
});
|
|
148
|
+
if (current.trim() !== action.oldBranch) {
|
|
149
|
+
throw new Error(`default branch drift: expected ${action.oldBranch} but observed ${current.trim()}`);
|
|
150
|
+
}
|
|
151
|
+
const newBranchCommit = await readRemoteBranchCommit(action, exec);
|
|
152
|
+
if (newBranchCommit && newBranchCommit !== action.expectedNewBranchCommit) {
|
|
153
|
+
throw new Error(
|
|
154
|
+
`new default branch commit drift: expected ${action.expectedNewBranchCommit} but observed ${newBranchCommit}`,
|
|
155
|
+
);
|
|
156
|
+
}
|
|
107
157
|
} else {
|
|
108
158
|
throw new Error(`unsupported action type: ${action.actionType}`);
|
|
109
159
|
}
|
|
@@ -149,6 +199,27 @@ export function createGitGithubAdapter(deps = {}) {
|
|
|
149
199
|
'--title', action.name ?? `Release ${action.tag}`,
|
|
150
200
|
'--notes', action.notes ?? `Release ${action.tag}`,
|
|
151
201
|
], { cwd: context.root, shell: false, env: { ...process.env, GH_HOST: action.githubHost ?? 'github.com' } });
|
|
202
|
+
} else if (action.actionType === ActionType.SET_DEFAULT_BRANCH) {
|
|
203
|
+
validateDefaultBranchAction(action);
|
|
204
|
+
const { stdout: current } = await exec('gh', ['api', `repos/${action.repo}`, '--jq', '.default_branch'], {
|
|
205
|
+
cwd: context.root,
|
|
206
|
+
shell: false,
|
|
207
|
+
env: { ...process.env, GH_HOST: action.githubHost ?? 'github.com' },
|
|
208
|
+
});
|
|
209
|
+
if (current.trim() !== action.oldBranch) {
|
|
210
|
+
throw new Error(`default branch drift immediately before update: expected ${action.oldBranch} but observed ${current.trim()}`);
|
|
211
|
+
}
|
|
212
|
+
const newBranchCommit = await readRemoteBranchCommit(action, exec);
|
|
213
|
+
if (newBranchCommit !== action.expectedNewBranchCommit) {
|
|
214
|
+
throw new Error(
|
|
215
|
+
`new default branch commit drift immediately before update: expected ${action.expectedNewBranchCommit} but observed ${newBranchCommit || 'missing'}`,
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
await exec('gh', ['api', `repos/${action.repo}`, '-X', 'PATCH', '-f', `default_branch=${action.newBranch}`], {
|
|
219
|
+
cwd: context.root,
|
|
220
|
+
shell: false,
|
|
221
|
+
env: { ...process.env, GH_HOST: action.githubHost ?? 'github.com' },
|
|
222
|
+
});
|
|
152
223
|
} else {
|
|
153
224
|
throw new Error(`unsupported action type: ${action.actionType}`);
|
|
154
225
|
}
|
|
@@ -183,6 +254,17 @@ export function createGitGithubAdapter(deps = {}) {
|
|
|
183
254
|
{ cwd: context.root, shell: false, env: { ...process.env, GH_HOST: action.githubHost ?? 'github.com' } },
|
|
184
255
|
);
|
|
185
256
|
observation = { tag: release.tagName, commit: commitResult.stdout.trim(), releaseUrl: release.url };
|
|
257
|
+
} else if (action.actionType === ActionType.SET_DEFAULT_BRANCH) {
|
|
258
|
+
validateDefaultBranchAction(action);
|
|
259
|
+
const { stdout: current } = await exec('gh', ['api', `repos/${action.repo}`, '--jq', '.default_branch'], {
|
|
260
|
+
cwd: context.root,
|
|
261
|
+
shell: false,
|
|
262
|
+
env: { ...process.env, GH_HOST: action.githubHost ?? 'github.com' },
|
|
263
|
+
});
|
|
264
|
+
observation = {
|
|
265
|
+
defaultBranch: current.trim(),
|
|
266
|
+
newBranchCommit: await readRemoteBranchCommit(action, exec),
|
|
267
|
+
};
|
|
186
268
|
} else {
|
|
187
269
|
throw new Error(`unsupported action type: ${action.actionType}`);
|
|
188
270
|
}
|