@weotro/dx 0.1.5 → 0.1.7

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.
@@ -0,0 +1,2 @@
1
+ policy:
2
+ allow_implicit_invocation: false
@@ -0,0 +1,96 @@
1
+ # Claude Code Runtime Contract
2
+
3
+ 仅在共享流程进入外部专家或 follow-up 分支时读取。
4
+
5
+ ## Codex 通道
6
+
7
+ Codex 永远不碰 Git 历史和 GitHub。它把改动落在工作树,由 Claude Code 主进程核验、验证和分组提交。
8
+
9
+ - **方案讨论 / 实现 / 重修复**:`Agent(subagent_type: "codex:codex-rescue")`。
10
+ - **普通 review**:Codex companion 的 `review` 子命令。
11
+ - **adversarial review**:Codex companion 的 `adversarial-review` 子命令。
12
+ - **定制上下文审查**:只读 `Agent(subagent_type: "codex:codex-rescue")`,prompt 明确禁止写操作和递归委派。
13
+
14
+ companion 每次调用都动态解析插件路径:
15
+
16
+ ```bash
17
+ CODEX_ROOT=$(/bin/ls -d ~/.claude/plugins/marketplaces/openai-codex/plugins/codex 2>/dev/null \
18
+ || /bin/ls -d ~/.claude/plugins/cache/openai-codex/codex/*/ 2>/dev/null | sort -V | tail -1) \
19
+ && node "$CODEX_ROOT/scripts/codex-companion.mjs" --help
20
+ ```
21
+
22
+ 插件升级会换版本目录,不把解析结果硬编码回技能。
23
+
24
+ 普通 review:
25
+
26
+ ```bash
27
+ CODEX_ROOT=$(/bin/ls -d ~/.claude/plugins/marketplaces/openai-codex/plugins/codex 2>/dev/null \
28
+ || /bin/ls -d ~/.claude/plugins/cache/openai-codex/codex/*/ 2>/dev/null | sort -V | tail -1) \
29
+ && node "$CODEX_ROOT/scripts/codex-companion.mjs" review --wait --base main
30
+ ```
31
+
32
+ 需要挑战方案时把 `review` 换成 `adversarial-review`。需要定制上下文时改派只读 Codex agent。
33
+
34
+ ## 补跑清单
35
+
36
+ Codex 沙箱不能绑本地端口、不能起 PostgreSQL 共享内存、不能写主仓 `.git` index、无网络下载。派发 prompt 原文附上以下主进程补跑项:
37
+
38
+ `dx db migrate`(实 apply)、后端 E2E、`dx build front --dev`、`flutter test`、Dart OpenAPI 生成(要下 Maven)、`git commit`。
39
+
40
+ ## 取结果
41
+
42
+ `codex:codex-rescue` 可能转后台。按 `workspaceRoot` 精确匹配当前仓库:
43
+
44
+ ```bash
45
+ python3 - <<'PY'
46
+ import glob, json, os
47
+ root = os.path.realpath(os.getcwd())
48
+ rows = []
49
+ for f in glob.glob(os.path.expanduser('~/.claude/plugins/data/codex-openai-codex/state/*/state.json')):
50
+ for j in json.load(open(f)).get('jobs', []):
51
+ if os.path.realpath(j.get('workspaceRoot', '')) == root:
52
+ rows.append((j.get('createdAt'), j.get('id'), j.get('kind'), j.get('status'), j.get('phase'), f))
53
+ for r in sorted(rows)[-5:]:
54
+ print(r)
55
+ PY
56
+ ```
57
+
58
+ 定位到 job 后读取同目录 `jobs/<id>.json`。只有 `status=completed` 且 `phase=done` 才算返回,报告正文取 `result.rawOutput`。
59
+
60
+ ## 等待与假死
61
+
62
+ 等待期间工作树由 Codex 独占,主进程只做不写工作树的并行事项。没别的工作时每 2 分钟取一次活性指纹:
63
+
64
+ ```bash
65
+ python3 - <<'LIVE'
66
+ import glob, json, os, subprocess
67
+ root = os.path.realpath(os.getcwd())
68
+ rows = []
69
+ for f in glob.glob(os.path.expanduser('~/.claude/plugins/data/codex-openai-codex/state/*/state.json')):
70
+ for j in json.load(open(f)).get('jobs', []):
71
+ if os.path.realpath(j.get('workspaceRoot', '')) == root:
72
+ rows.append((j.get('createdAt'), j.get('id'), j.get('status'), j.get('phase'), f))
73
+ if not rows:
74
+ raise SystemExit('no job for this workspace')
75
+ created, jid, status, phase, statefile = sorted(rows)[-1]
76
+ jf = os.path.join(os.path.dirname(statefile), 'jobs', jid + '.json')
77
+ size, mtime = (os.path.getsize(jf), int(os.path.getmtime(jf))) if os.path.exists(jf) else (0, 0)
78
+ dirty = len([l for l in subprocess.run(['git', 'status', '--porcelain'], capture_output=True, text=True).stdout.splitlines() if l.strip()])
79
+ print(f'{jid} status={status} phase={phase} out={size}/{mtime} dirty={dirty}')
80
+ LIVE
81
+ ```
82
+
83
+ 连续 3 次(约 6 分钟)三项全不变且仍为 running,按假死阻塞,报告 job id 与 phase。companion 的 `review --wait` / `adversarial-review --wait` 是前台阻塞调用,不走此轮询。
84
+
85
+ ## 阶段与报告映射
86
+
87
+ - 阶段四方案讨论:只读 Codex agent;主进程先写初步方案,最终拍板权在主进程。
88
+ - 阶段四实现与阶段 7.4 重修复:可写 Codex agent,prompt 要求不 commit、不 push、不碰 GitHub、不递归委派。
89
+ - 阶段 7.3:复杂度门禁命中且本 PR 尚未用过 Codex 审查时执行 review;需要挑战方案时执行 adversarial review。
90
+ - reviewer:`Claude Code 主进程自审 / codex native review / codex adversarial review / codex 只读 subagent`。
91
+
92
+ Codex 返回后主进程必须直读源码和 diff 核验,不采信转述。重改动实现通道不可用时阻塞;条件式独立审查不可用时由主进程完成本轮自审并在报告标明降级。
93
+
94
+ ## Follow-up
95
+
96
+ 使用 `Agent(subagent_type: "general-purpose", run_in_background: true)`,prompt 指定 worktree 绝对路径并要求调用 `cc-ship-issue-pr`。派发深度只允许一层;子 agent 发现的新 follow-up 只建 Issue。派不动 Codex 时子 agent 自己实现,并在 PR body 记录主进程直改。
@@ -7,13 +7,16 @@ description: 仅在用户显式调用 $git-release 或明确要求使用 git-rel
7
7
 
8
8
  ## 目标
9
9
 
10
- 在 `release/vX.Y.Z` 或 `release/vX.Y.Z-<prerelease>.N` 分支上,完成从发布前检查到 GitHub Release 创建的全流程;若当前不在 release 分支,则先从最新 `main` 自动创建目标 release 分支。
10
+ 在 `release/vX.Y.Z` 或 `release/vX.Y.Z-<prerelease>.N` 分支上,完成发布前检查、GitHub Release 创建和发布后运维回访 Issue 建立;若当前不在 release 分支,则先从最新 `main` 自动创建目标 release 分支。
11
11
 
12
12
  ## 执行原则
13
13
 
14
14
  - 全程使用中文输出。
15
15
  - 严格执行前置校验,任何硬性条件不满足时立即终止。
16
16
  - 发行说明必须结构化、可读、可追溯。
17
+ - 发布完成必须留下一个可追踪的部署后回访 Issue;终端里临时打印 checklist 不算完成。
18
+ - 本技能只编写回访 Issue,不执行生产验证。不得登录生产服务器、访问生产数据库、调用生产只读接口、查询生产监控或尝试取得生产凭据。
19
+ - GitHub Release 创建成功不代表已经部署。Issue 中部署、迁移、服务、数据和业务验收项默认全部未勾选,留给运维或后续回访 agent 执行并补充证据。
17
20
  - 命令默认在仓库根目录执行。
18
21
  - 若能从当前 release 分支或自动建分支流程唯一推断出合法版本号,直接使用该版本继续发布,不要询问用户确认。
19
22
 
@@ -156,7 +159,16 @@ gh release create v<VERSION> \
156
159
  EOF
157
160
  ```
158
161
 
159
- 4. 输出发布 URL 与发布后检查清单。
162
+ 4. 读回 Release,确认 tag、标题、正文和 URL 正确:`gh release view v<VERSION> --json tagName,name,body,url,isDraft,isPrerelease`。
163
+
164
+ ### 六、创建发布后运维回访 Issue
165
+
166
+ 1. 完整读取 [发布后回访契约](references/post-release-follow-up.md)。
167
+ 2. 只读取仓库内的部署配置、运维文档、发行说明、PR、迁移和 ops manifest,确定预期环境、品牌、target、服务、数据库、脚本与用户可观察变化。不得通过 SSH、生产域名、数据库、监控平台、云平台 API 或私有环境配置验证当前生产状态。
168
+ 3. 自动创建一个发布后回访 Issue。Issue 必须覆盖:部署前门禁、发布与服务器版本一致性、服务健康、迁移与运维脚本、数据结果、配置、可观测性、本次变更特有验收、回滚准备和延迟观察窗口。
169
+ 4. 部署与生产验证状态写为“待运维执行”。所有需要部署后取证的 checklist 保持未勾选,并写清执行对象、预期结果和应附的脱敏证据;不得因为 Release 已创建或 CI 状态正常而代替勾选。
170
+ 5. checklist 应明确要求运维或后续回访 agent 按仓库配置登录每台相关生产服务器,核对实际版本、进程或容器、health/readiness、日志、worker/cron、资源、迁移、配置和数据结果。本技能当前调用不执行这些检查。
171
+ 6. 使用 `gh issue view` 读回 Issue,确认没有占位符、每个生产目标和本次发布影响面都有对应未勾选检查项,并输出 Issue URL。
160
172
 
161
173
  ## 终止条件
162
174
 
@@ -166,6 +178,7 @@ EOF
166
178
  - 当前分支不符合 release 分支命名规则,且无法从 `main` 自动创建 release 分支。
167
179
  - 版本号格式非法或与现有 tag 冲突。
168
180
  - 自上次发布以来无新提交。
181
+ - 无法创建或读回发布后回访 Issue。
169
182
 
170
183
  ## 输出模板
171
184
 
@@ -191,4 +204,6 @@ EOF
191
204
  - 分支名
192
205
  - tag 推送状态
193
206
  - Release URL
194
- - 发布后清单
207
+ - 预期部署环境、品牌与 target
208
+ - 发布后回访 Issue URL
209
+ - 待运维执行与待观察项目数量
@@ -1,7 +1,7 @@
1
1
  interface:
2
2
  display_name: "Git Release"
3
- short_description: "在 release 分支上自动完成版本发布与发行说明生成"
4
- default_prompt: "使用 $git-release 按规范执行一次发布并生成高质量发行说明。"
3
+ short_description: "完成版本发布、生产服务器核验与发布后回访"
4
+ default_prompt: "使用 $git-release 执行发布,登录生产服务器核验版本、运维脚本和数据,并创建带证据的回访 Issue checklist。"
5
5
 
6
6
  policy:
7
7
  allow_implicit_invocation: false
@@ -0,0 +1,176 @@
1
+ # 发布后运维回访 Issue 契约
2
+
3
+ 本文件只在 GitHub Release 创建并读回成功后使用。目标是生成一张可交给运维或后续回访 agent 执行的部署与验证 checklist,不是在当前 `git-release` 调用中验证生产环境。
4
+
5
+ ## 职责边界
6
+
7
+ 当前 `git-release` agent 只做以下工作:
8
+
9
+ - 从仓库内的部署配置、运维文档、发行说明、提交、PR、迁移和 ops manifest 建立发布影响面;
10
+ - 创建并读回发布后回访 Issue;
11
+ - 把每个部署与验证动作写成可执行、可取证的未勾选检查项。
12
+
13
+ 当前调用不得连接或探测生产环境,包括 SSH、生产数据库、生产域名或 health 接口、监控平台、云平台部署 API、服务器日志和私有环境 profile。不得为了填写 Issue 尝试取得密钥、token、主机权限或数据库权限。
14
+
15
+ GitHub Release、tag、CI 状态或部署工作流的存在都不代表已经部署。Issue 的初始状态统一写为“待运维执行”,所有部署后检查项保持未勾选。
16
+
17
+ ## 完成边界
18
+
19
+ `git-release` 本次调用完成的最低条件是:
20
+
21
+ - Release 已读回确认;
22
+ - 已从仓库内真源确定预期环境、品牌、target、服务、数据库与运维脚本,无法确定的内容明确列为待运维补充;
23
+ - 回访 Issue 已创建并读回;
24
+ - 本次发布涉及的每个环境、品牌、target、迁移、配置和用户可观察变化都有检查项;
25
+ - 每个检查项写明执行对象、预期结果和应附的脱敏证据;
26
+ - 没有把未经生产取证的项目标成已完成,也没有声称实际生产版本或健康状态。
27
+
28
+ 回访 Issue 不要求在当前调用中关闭。运维或后续回访 agent 应在部署后更新同一个 Issue,逐项补证据并勾选。
29
+
30
+ ## 从仓库建立影响面
31
+
32
+ 只检查本地仓库真源,包括部署脚本、inventory、`dx/config/commands.json`、`dx/release/`、systemd/container 配置、runbook、迁移目录和 ops manifest。确定:
33
+
34
+ - 预期生产环境、品牌、target、服务和前端项目;
35
+ - 预期运行方式,例如 systemd、Docker、Kubernetes、PM2 或 serverless;
36
+ - 部署后可核对版本/commit 的文件、镜像标签、release 目录或运行参数;
37
+ - 数据库、队列、worker、cron、缓存和第三方连接需要验证的范围;
38
+ - 本次发布要求执行或确认的迁移、seed、回填、缓存刷新、配置生成和运维脚本;
39
+ - 发行说明中每个用户可观察变化对应的 smoke check。
40
+
41
+ 仓库未提供生产坐标或验证入口时,在 Issue 中写“待运维按私有配置补充”,不要猜测主机、域名、数据库或历史地址。
42
+
43
+ ## Checklist 编写规则
44
+
45
+ 每个检查项都应包含:
46
+
47
+ - **执行对象**:环境、品牌、target、服务、数据库或业务路径;
48
+ - **预期结果**:可判定通过或失败的状态;
49
+ - **证据要求**:脱敏命令摘要、版本/commit、迁移表结果、日志时间窗、监控链接或可观察行为;
50
+ - **执行时机**:部署前、部署后立即、观察窗口结束后或下一轮 cron 后。
51
+
52
+ 不要预填生产结果。Release/tag 已创建等 GitHub 事实可写在“发布信息”中,但不能代替部署与生产检查项。
53
+
54
+ ### 部署前门禁
55
+
56
+ - 不可变 tag/commit 与发布计划一致;
57
+ - 品牌 readiness、环境配置和部署矩阵通过;
58
+ - 新增或变更的环境变量、secret、feature flag 和第三方配置已准备;
59
+ - 发布窗口、执行人、观察人、分批策略与回滚入口已记录。
60
+
61
+ ### 发布与制品一致性
62
+
63
+ - tag、Release、版本文件和实际运行 commit 指向同一版本;
64
+ - 服务器制品、镜像、release 目录或前端 deployment 使用正确版本与 commit;
65
+ - 所有预期生产主机、品牌和 target 均已发布,没有漏发或版本漂移;
66
+ - Release 的 draft/prerelease 状态符合版本类型。
67
+
68
+ ### 服务器与服务状态
69
+
70
+ - 运维或后续回访 agent 按仓库配置登录每台相关生产服务器;
71
+ - 目标进程、容器、pod 或 function 正常运行,启动时间与本次部署一致;
72
+ - health/readiness、端口、反向代理和服务间连接正常;
73
+ - worker、cron、队列消费者和后台作业运行在目标版本;
74
+ - 最近日志没有启动失败、error、panic、持续 timeout、权限错误或重复重启;
75
+ - CPU、内存、磁盘、连接数等没有明显异常。
76
+
77
+ ### 运行时健康与可观测性
78
+
79
+ - 发布后错误率、延迟、5xx、告警和日志异常没有明显回归;
80
+ - 队列积压、定时任务、事件消费、webhook 和后台作业正常;
81
+ - 域名、TLS、静态资源、CDN、缓存版本和 source map 符合预期;
82
+ - 设置适合本次变更的观察窗口和最早复查时间。
83
+
84
+ ### 数据、配置与兼容性
85
+
86
+ - 本次迁移已应用到正确数据库,schema 与应用版本兼容;
87
+ - 新增或变更的运行时配置已生效,敏感值只记录存在性、长度或指纹;
88
+ - 公共 API、DTO、事件、数据库和客户端兼容性得到验证;
89
+ - 使用有边界的只读查询核对关键总数、不变量、状态分布和抽样结果;
90
+ - 数据修复或回填记录预期数量、实际数量、失败项和幂等/重跑状态。
91
+
92
+ ### 运维脚本执行状态
93
+
94
+ - 从 PR、迁移、release note、runbook 和 ops manifest 列出全部人工脚本;
95
+ - 每个脚本记录名称/版本、目标主机或数据库、预期效果和完成标记;
96
+ - 要求通过迁移表、任务表、审计日志、marker、状态子命令或数据结果判断 `已执行 / 未执行 / 无法确认 / 不适用`;
97
+ - “文件存在”或口头确认不算执行证据;
98
+ - 生产写脚本、迁移、回填、重启或重新部署由运维按授权流程执行,不由 `git-release` 当前调用执行。
99
+
100
+ ### 用户与业务路径
101
+
102
+ - 为发行说明中的每个用户可观察变化生成对应 smoke check;
103
+ - 覆盖本次受影响的登录/鉴权、核心读写、支付或其他高风险路径;
104
+ - 前端、管理端、移动端和多品牌分别验证,不能用一个端的通过代表全部端;
105
+ - 修复项复现旧失败条件并验证新行为,新增项验证成功路径和关键错误路径。
106
+
107
+ ### 回滚与延迟观察
108
+
109
+ - 记录上一稳定版本、回滚命令或恢复入口,以及迁移是否可逆;
110
+ - 对错误率、队列积压、定时任务、缓存过期等设置观察窗口;
111
+ - 明确关闭条件:所有必需项完成,阻塞项有结论,发现的问题已修复或拆成关联 Issue。
112
+
113
+ ## Issue 结构
114
+
115
+ 创建前读取仓库 Issue 模板和现有 labels,沿用其结构与可用标签。标题使用:
116
+
117
+ ```text
118
+ chore(release): 回访 v<VERSION> 部署结果
119
+ ```
120
+
121
+ 正文至少包含:
122
+
123
+ ```markdown
124
+ ## 发布信息
125
+
126
+ - 版本:v<VERSION>
127
+ - Release:<URL>
128
+ - Tag commit:<SHA>
129
+ - 预期部署环境/品牌/target:<从仓库配置得出的范围>
130
+ - 当前状态:待运维执行
131
+
132
+ ## 部署后检查清单
133
+
134
+ ### 部署前门禁
135
+
136
+ - [ ] <执行对象、预期结果、证据要求>
137
+
138
+ ### 发布与制品一致性
139
+
140
+ - [ ] <检查项>
141
+
142
+ ### 生产服务器与服务
143
+
144
+ - [ ] <检查项>
145
+
146
+ ### 运行时与可观测性
147
+
148
+ - [ ] <检查项>
149
+
150
+ ### 数据、配置与兼容性
151
+
152
+ - [ ] <检查项或“不适用”的判定任务>
153
+
154
+ ### 运维脚本
155
+
156
+ - [ ] <脚本、目标、预期结果与证据要求>
157
+
158
+ ### 本次变更验收
159
+
160
+ - [ ] <逐项映射发行说明/PR/Issue 的用户可观察变化>
161
+
162
+ ### 回滚与观察窗口
163
+
164
+ - [ ] <回滚入口确认任务>
165
+ - [ ] <观察指标、窗口、最早复查时间和负责人>
166
+
167
+ ## 发现与后续
168
+
169
+ - 当前状态:待运维执行
170
+ - 关联问题:无;发现异常后补充
171
+ - 关闭条件:所有必需检查完成且发现的问题有结论
172
+ ```
173
+
174
+ 正文通过 heredoc 或临时文件传给 `gh issue create --body-file`,禁止用字面量 `\n` 拼接。创建后用 `gh issue view <id> --json title,body,url,state` 读回。
175
+
176
+ 读回时确认:没有占位符;每个预期生产目标都有检查项;所有部署后检查项仍未勾选;Issue 没有声称已经登录服务器、部署成功或生产健康。
@@ -0,0 +1,27 @@
1
+ ---
2
+ name: oo-ship-issue-pr
3
+ description: 仅在用户显式调用 $oo-ship-issue-pr、/oo-ship-issue-pr 或明确要求使用 oo-ship-issue-pr 技能时使用;不要通过关键词、任务类型或上下文自动触发。
4
+ ---
5
+
6
+ # OO Ship Issue PR
7
+
8
+ Codex 入口:主进程执行轻改动,Claude Fable 5 优先承接重改动的方案讨论、实现与独立审查;Fable 额度不足时回退 Claude Opus 5,Claude 通道不可用时改派 fresh Codex subagent,不中断交付链。
9
+
10
+ ## 步骤一:加载共享流程
11
+
12
+ ```bash
13
+ AGENTS_ROOT="${AGENTS_HOME:-$HOME/.agents}"
14
+ SHIP_CORE="$AGENTS_ROOT/references/ship-issue-pr-core.md"
15
+ test -f "$SHIP_CORE"
16
+ ```
17
+
18
+ 完整读取 `SHIP_CORE` 后执行全部阶段。运行时映射如下:
19
+
20
+ - 主进程:当前 Codex。
21
+ - 外部专家:优先 Claude Fable 5;仅在 Fable 额度不足时回退 Claude Opus 5;Claude 通道不可用时改派 fresh Codex subagent。
22
+ - 入口显示名:`OO Ship Issue PR`。
23
+ - Follow-up:Codex `spawn_agent` 的 `worker` 角色。
24
+
25
+ 第一次进入外部专家或 follow-up 分支前,完整读取 [references/runtime.md](references/runtime.md)。该文件是本入口的平台调用契约;共享流程仍是交付语义的唯一真源。
26
+
27
+ 只有共享流程全部完成且 `mergedAt` 非空、Issue 回访完成,才输出 `OO Ship Issue PR 完成`。
@@ -0,0 +1,2 @@
1
+ policy:
2
+ allow_implicit_invocation: false
@@ -0,0 +1,92 @@
1
+ # Codex Runtime Contract
2
+
3
+ 仅在共享流程进入外部专家或 follow-up 分支时读取。
4
+
5
+ ## Claude 专家通道
6
+
7
+ ### 可用性探测与会话级熔断
8
+
9
+ 第一次需要外部专家时运行 `command -v claude` 和 `claude --version`,分别保留退出码、stdout 和 stderr。该探测不是交付硬门禁:任一命令非零、不可执行或超时,都把 Claude 通道标记为“本次不可用”,立即由 fresh Codex subagent 接管当前阶段;不得退出、输出阻塞或停止共享流程。
10
+
11
+ “本次不可用”状态持续到当前顶层 `oo-ship-issue-pr` 调用结束,覆盖后续方案讨论、实现、review、修复和回收阶段。状态一旦设置,后续不再探测或调用 Claude,每个需要外部专家的阶段都直接创建 fresh Codex subagent;subagent 也不可用时由 Codex 主进程降级接管。新的顶层 `oo-ship-issue-pr` 调用才重新探测 Claude。
12
+
13
+ 探测通过后,所有调用从当前 worktree 根目录执行,固定使用 `--effort medium --no-session-persistence`。首选模型是 Claude Fable 5(`--model fable`);仅在该次调用明确因 Fable 额度不足失败时,以完全相同的 prompt、权限模式和工具集合重试一次 Claude Opus 5(`--model opus`)。Claude 只写工作树;Git 历史、GitHub、权威验证和最终事实核验由 Codex 主进程负责。
14
+
15
+ ### 模型额度回退
16
+
17
+ Claude 通道未被标记为“本次不可用”时,每次外部专家调用都重新从 Fable 开始,不因上一轮曾回退而直接选择 Opus。保留每次尝试的退出码、stdout 和 stderr,并按以下顺序处理:
18
+
19
+ 1. Fable 返回 0:接受结果,不调用 Opus。
20
+ 2. Fable 非零,且输出明确表示当前模型的使用额度、配额或 credits 已耗尽(例如 `hit your limit`、`usage limit`、`quota exceeded`、`credit balance is too low`、`insufficient credits` 或带重置时间的额度提示):只重试一次 Opus。
21
+ 3. Fable 的失败属于未登录、认证、网络、超时、无效模型、参数、权限、工具或其他非额度错误:保留原错误,不调用 Opus,把 Claude 通道标记为“本次不可用”,立即进入 fresh subagent 回退。
22
+ 4. Opus 返回 0:接受 Opus 结果,并在阶段报告中记录本轮实际模型为 `Claude Opus 5`。
23
+ 5. Opus 失败:记录 Fable 与 Opus 两次证据,把 Claude 通道标记为“本次不可用”,停止 Claude 重试并立即进入 fresh subagent 回退。不得继续循环或换用其他 Claude 模型。
24
+
25
+ 下面命令块中的 `fable` 是首选尝试。命令非零时同时检查 stdout 与 stderr;只有命中上述额度回退条件,才将 `--model fable` 替换为 `--model opus` 原样重跑一次。重试前清空或更换 `RESULT_FILE`,避免把 Fable 的部分输出混入 Opus 结果。
26
+
27
+ ### 只读讨论、review 与 adversarial review
28
+
29
+ 把 Issue、验收标准、base、方案或已确认问题写入本次任务唯一的 `PROMPT_FILE`:
30
+
31
+ ```bash
32
+ claude -p \
33
+ --model fable \
34
+ --effort medium \
35
+ --permission-mode plan \
36
+ --tools "Read,Grep,Glob,Bash" \
37
+ --no-session-persistence \
38
+ < "$PROMPT_FILE" > "$RESULT_FILE"
39
+ ```
40
+
41
+ prompt 要求只读、不修改文件、不执行 Git/GitHub 写操作、不递归委派,并直接读取源码和 `git diff <base>...HEAD` 取证。
42
+
43
+ - 普通 review 以 findings 为主,按严重级排序;每项包含严重级、`文件:行号`、证据、影响和具体修法。
44
+ - adversarial review 先挑战方案假设、构造反例和失败路径,再输出同样格式的 findings;没有证据的问题不进入报告。
45
+
46
+ ### 重改动实现与修复
47
+
48
+ ```bash
49
+ claude -p \
50
+ --model fable \
51
+ --effort medium \
52
+ --permission-mode acceptEdits \
53
+ --tools "Read,Grep,Glob,Edit,Write,Bash" \
54
+ --no-session-persistence \
55
+ < "$PROMPT_FILE" > "$RESULT_FILE"
56
+ ```
57
+
58
+ prompt 必须包含 Issue、逐条验收标准、最终方案、涉及目录和 `AGENTS.md` 路由,并要求只改验收范围、不 commit、不 push、不碰 GitHub、不递归委派、保护已有未提交改动,最后报告修改路径和未运行验证。
59
+
60
+ ## Claude 不可用时的 fresh subagent
61
+
62
+ 可用性探测失败、当前调用在模型额度回退后仍无有效结果,或因安装、登录、认证、网络、超时、参数、权限、工具等原因无法使用 Claude 时,主进程立即调用 Codex `spawn_agent` 创建一个全新的 `worker` subagent 接管当前外部专家阶段。Claude 通道同时进入“本次不可用”状态,后续外部专家阶段直接走本节,不再尝试 Claude。每次回退都新建 agent,不复用此前 agent;使用 `fork_turns: "none"`,在 prompt 中完整提供任务上下文。
63
+
64
+ fallback prompt 必须包含:
65
+
66
+ - 当前 worktree 的绝对路径,以及只在该 worktree 工作。
67
+ - 当前阶段是只读方案讨论、只读 review、adversarial review、实现还是修复;只承接这一阶段,不运行完整 `oo-ship-issue-pr`。
68
+ - Issue 原文、逐条验收标准、base、主进程初步方案或最终方案,以及该阶段所需的 diff、已确认问题和验证上下文。
69
+ - 先读取根与涉及目录的 `AGENTS.md`;它不是代码库中唯一执行者,保护已有未提交改动,不回退其他人的修改。
70
+ - 只读阶段保持工作树不变;实现或修复阶段的所有权限定为 prompt 列出的验收范围和涉及文件,改动留在工作树。
71
+ - 不 commit、不 push、不操作 GitHub、不调用 Claude、不递归委派;最后返回证据、结论、修改路径和未运行验证。
72
+
73
+ 主进程等待 fresh subagent 返回后按外部专家的同一标准逐条复核,再继续共享流程。`spawn_agent` 本身不可用或派发失败时,主进程直接完成同一阶段并记录 `Codex 主进程降级`;Claude 通道不可用和 subagent 派发失败都不得单独中断交付链。
74
+
75
+ ## 结果、等待与补跑
76
+
77
+ Claude CLI 是前台同步调用。命令返回、成功模型的 `RESULT_FILE` 可完整读取且工作树稳定即算返回;非零退出按模型额度回退和会话级熔断规则处理,卡住时记录命令与原因,把 Claude 通道标记为“本次不可用”,然后进入 fresh subagent 回退。
78
+
79
+ Claude 通道不可用时由 fresh subagent 继续当前阶段;subagent 也不可用时由 Codex 主进程直接接管。Claude 或 subagent 执行过的验证只作参考,阶段五及后续轮次要求的全部权威验证由 Codex 主进程重新执行并阅读最新输出。
80
+
81
+ Claude 或 fresh subagent 返回后,Codex 主进程逐条直读源码复核,合并重复项并记录拒绝依据。
82
+
83
+ ## 阶段与报告映射
84
+
85
+ - 阶段四方案讨论:只读外部专家,记录实际使用的 Fable 5、Opus 5、fresh Codex subagent 或 Codex 主进程降级。
86
+ - 阶段四实现与阶段 7.4 重修复:可写外部专家,记录实际使用的 Fable 5、Opus 5、fresh Codex subagent 或 Codex 主进程降级。
87
+ - 阶段 7.3:复杂度门禁命中且本 PR 尚未用过外部专家审查时执行 review;需要挑战方案时执行 adversarial review。成功返回的 fresh Codex subagent 计入本 PR 唯一一次外部专家审查,Codex 主进程降级不计入。
88
+ - reviewer:`Codex 主进程自审 / Claude Fable 5 review / Claude Fable 5 adversarial review / Claude Opus 5 review / Claude Opus 5 adversarial review / fresh Codex subagent review / fresh Codex subagent adversarial review / Codex 主进程降级 review / Codex 主进程降级 adversarial review`,按本轮实际执行者填写。
89
+
90
+ ## Follow-up
91
+
92
+ 使用 Codex `spawn_agent` 的 `worker` 角色,prompt 指定 worktree 绝对路径并要求调用 `oo-ship-issue-pr`。明确告知 worker 它不是代码库中唯一执行者,不回退其他人的改动,只在指定 worktree 工作。派发深度只允许一层;worker 发现的新 follow-up 只建 Issue。
@@ -0,0 +1,83 @@
1
+ ---
2
+ name: prune-git-repository
3
+ description: 仅在用户显式调用 $prune-git-repository、/prune-git-repository 或明确要求使用 prune-git-repository 技能时使用;不要通过关键词、任务类型或上下文自动触发。
4
+ ---
5
+
6
+ # Prune Git Repository
7
+
8
+ Use the bundled scripts instead of rebuilding shell loops. Always run them from the target repository.
9
+
10
+ ## Authorization gate
11
+
12
+ Treat every execute mode as destructive.
13
+
14
+ 1. Require explicit current-turn authorization for the exact cleanup categories and thresholds.
15
+ 2. Run dry-run mode first and report counts, cutoff, keep sets, protected refs, and occupied branches.
16
+ 3. Pass `--execute` only after the authorization covers the previewed deletions.
17
+ 4. Never delete the base branch, remote default branch, current worktree, or current branch.
18
+ 5. Preserve unrelated working-tree changes. Do not infer permission to push recent local-only branches.
19
+
20
+ Read [pitfalls.md](references/pitfalls.md) before any execute run.
21
+
22
+ ## Workflow
23
+
24
+ When multiple categories are authorized, use this order:
25
+
26
+ 1. Inspect `git status`, remotes, default branch, `gh auth status`, and worktrees.
27
+ 2. Preview all selected scripts.
28
+ 3. Remove extra worktrees first so checked-out candidate branches can be deleted.
29
+ 4. Prune branches.
30
+ 5. Prune Releases and tags.
31
+ 6. Fetch/prune and run the scripts again without `--execute`; require zero remaining candidates.
32
+ 7. Verify `main...origin/main`, a clean current worktree, server-side refs through `ls-remote`, and matching local/remote tag sets.
33
+
34
+ ## Commands
35
+
36
+ Resolve the installed script directory once:
37
+
38
+ ```bash
39
+ PRUNE_SKILL_ROOT="${AGENTS_HOME:-$HOME/.agents}/skills/prune-git-repository"
40
+ ```
41
+
42
+ Preview branch cleanup:
43
+
44
+ ```bash
45
+ "$PRUNE_SKILL_ROOT/scripts/prune-branches.sh" \
46
+ --remote origin --base main --stale-days 20
47
+ ```
48
+
49
+ Execute the authorized branch cleanup:
50
+
51
+ ```bash
52
+ "$PRUNE_SKILL_ROOT/scripts/prune-branches.sh" \
53
+ --remote origin --base main --stale-days 20 --execute
54
+ ```
55
+
56
+ Preview or remove all linked worktrees except the current worktree:
57
+
58
+ ```bash
59
+ "$PRUNE_SKILL_ROOT/scripts/prune-worktrees.sh"
60
+ "$PRUNE_SKILL_ROOT/scripts/prune-worktrees.sh" --execute
61
+ ```
62
+
63
+ Preview or retain only the newest tags and GitHub Releases:
64
+
65
+ ```bash
66
+ "$PRUNE_SKILL_ROOT/scripts/prune-tags-releases.sh" \
67
+ --remote origin --keep 10
68
+ "$PRUNE_SKILL_ROOT/scripts/prune-tags-releases.sh" \
69
+ --remote origin --keep 10 --execute
70
+ ```
71
+
72
+ Use `--tags-only` only when the user explicitly excludes GitHub Releases. The combined mode requires the retained tag names and retained Release tag names to match; stop for user direction if they differ.
73
+
74
+ ## Reporting
75
+
76
+ Report:
77
+
78
+ - effective cutoff and keep set;
79
+ - deleted local/remote branch counts by reason;
80
+ - deleted local/remote tag and GitHub Release counts;
81
+ - removed and pruned worktree counts;
82
+ - any protected, occupied, failed, or deliberately retained items;
83
+ - final local/server counts, set diffs, `main` ahead/behind, and worktree status.
@@ -0,0 +1,6 @@
1
+ interface:
2
+ display_name: "清理 Git 仓库"
3
+ short_description: "安全清理旧分支、标签、Release 与 worktree"
4
+ default_prompt: "Use $prune-git-repository to preview and safely clean stale Git branches, old tags and Releases, and extra worktrees."
5
+ policy:
6
+ allow_implicit_invocation: false
@@ -0,0 +1,43 @@
1
+ # Failure modes and guardrails
2
+
3
+ Read this file before execute mode.
4
+
5
+ ## Raw output and `rtk`
6
+
7
+ - Use `rtk proxy git ...` for machine-readable Git output. Plain `rtk git worktree list --porcelain` may render human-friendly paths and remove `worktree ` prefixes.
8
+ - Use `rtk proxy gh ...` and `rtk proxy jq ...` when complete JSON or line lists are required. Plain `rtk` can replace the middle of a long list with a truncation marker; never feed rendered output back into deletion commands.
9
+ - Verify remote deletion with `rtk proxy git ls-remote`, not only local remote-tracking refs.
10
+ - `rtk rm -rf` may be protected/no-op. Remove registered worktrees with Git first. Use the narrowly scoped `find ... -exec /bin/rm -rf` fallback only after Git removal fails and the path is proven to be a non-current registered worktree.
11
+
12
+ ## Shell hazards
13
+
14
+ - Use Bash arrays for batches. Do not rely on scalar word splitting; zsh does not split scalar variables by default and can turn a whole batch into one invalid refspec.
15
+ - Never use `path` as a zsh loop variable; it is tied to `PATH` and can make `git`, `sed`, and `rtk` disappear mid-script. Use `wt_path`.
16
+ - Under `set -e`, avoid standalone arithmetic tests or `((count++))`; a zero result exits with status 1. Put arithmetic comparisons inside `if` and use `count=$((count + 1))`.
17
+ - Use exact refspecs (`:refs/heads/...`, `:refs/tags/...`) to avoid branch/tag ambiguity.
18
+
19
+ ## Branch classification
20
+
21
+ - Fetch with `--prune` before classifying.
22
+ - Determine merge state with `git merge-base --is-ancestor <tip> <remote/base>`; branch names and PR state are not topology evidence.
23
+ - Classify local and remote tips independently. A recent local branch can track an already-deleted or stale remote ref; do not publish it unless the user explicitly authorizes pushing it.
24
+ - Exclude the exact remote HEAD symref and base ref. `origin/HEAD` may render as `origin`, so filtering only the short name `HEAD` is unsafe.
25
+ - Protect branches checked out by any worktree. Remove authorized extra worktrees first or report the branch as occupied.
26
+ - Calculate the cutoff portably: macOS `date -v-<N>d`, GNU `date -d '<N> days ago'`.
27
+
28
+ ## Tags and Releases
29
+
30
+ - Use `git ls-remote --tags --refs`; without `--refs`, annotated tags add `^{}` pseudo-refs and corrupt counts.
31
+ - Fetch tags before sorting by `creatordate`. Compare local-only and remote-only tags explicitly.
32
+ - When tags and GitHub Releases are cleaned together, require the newest tag set and newest Release tag-name set to match before execution. Otherwise stopping is safer than leaving retained Releases without their tags.
33
+ - Retrieve all Releases with `gh release list --limit 1000 --json ...` through `rtk proxy`; re-query after deletion.
34
+ - Delete old Releases before their old tags, then synchronize and compare the retained tag sets.
35
+
36
+ ## Worktrees
37
+
38
+ - Read paths only from raw `git worktree list --porcelain` output.
39
+ - Canonicalize the current repository root and compare exact absolute paths. Never compare against a display path containing `~`.
40
+ - Use `git worktree remove --force --force` and wait for it to finish; dependency directories can make deletion slow.
41
+ - Run `git worktree prune --expire now` for missing or partially removed worktrees.
42
+ - If Git says a registered directory is not a working tree, delete only that already-validated registered directory, then prune. Never broaden the fallback to a parent directory shared with the current checkout.
43
+ - After cleanup, raw porcelain output must contain exactly the current worktree.