@weotro/dx 0.1.5 → 0.1.6

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,40 @@
1
+ ---
2
+ name: cc-ship-issue-pr
3
+ description: 仅在用户显式调用 $cc-ship-issue-pr、/cc-ship-issue-pr 或明确要求使用 cc-ship-issue-pr 技能时使用,派发 follow-up 交付的 subagent 也从这里进入;不要通过关键词、任务类型或上下文自动触发。
4
+ ---
5
+
6
+ # CC Ship Issue PR
7
+
8
+ Claude Code 入口:主进程守门并执行轻改动,Codex 承接重改动的方案讨论、实现与独立审查。
9
+
10
+ ## 步骤一:Claude Code 门禁
11
+
12
+ 任何文件检查、Git/GitHub 操作或共享流程加载之前执行:
13
+
14
+ ```bash
15
+ if [[ -z "${CLAUDECODE:-}" ]]; then
16
+ echo "cc-ship-issue-pr 仅允许 Claude Code 调用;当前运行时不是 Claude Code,已退出。"
17
+ exit 64
18
+ fi
19
+ ```
20
+
21
+ 门禁失败后立即结束。门禁通过的完成标准是 `CLAUDECODE` 非空。
22
+
23
+ ## 步骤二:加载共享流程
24
+
25
+ ```bash
26
+ AGENTS_ROOT="${AGENTS_HOME:-$HOME/.agents}"
27
+ SHIP_CORE="$AGENTS_ROOT/references/ship-issue-pr-core.md"
28
+ test -f "$SHIP_CORE"
29
+ ```
30
+
31
+ 完整读取 `SHIP_CORE` 后执行全部阶段。运行时映射如下:
32
+
33
+ - 主进程:当前 Claude Code。
34
+ - 外部专家:Codex。
35
+ - 入口显示名:`CC Ship Issue PR`。
36
+ - Follow-up:Claude Code `Agent(subagent_type: "general-purpose", run_in_background: true)`。
37
+
38
+ 第一次进入外部专家或 follow-up 分支前,完整读取 [references/runtime.md](references/runtime.md)。该文件是本入口的平台调用契约;共享流程仍是交付语义的唯一真源。
39
+
40
+ 只有共享流程全部完成且 `mergedAt` 非空、Issue 回访完成,才输出 `CC Ship Issue PR 完成`。
@@ -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,14 @@ 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 不算完成。
17
18
  - 命令默认在仓库根目录执行。
18
19
  - 若能从当前 release 分支或自动建分支流程唯一推断出合法版本号,直接使用该版本继续发布,不要询问用户确认。
19
20
 
@@ -156,7 +157,19 @@ gh release create v<VERSION> \
156
157
  EOF
157
158
  ```
158
159
 
159
- 4. 输出发布 URL 与发布后检查清单。
160
+ 4. 读回 Release,确认 tag、标题、正文和 URL 正确:`gh release view v<VERSION> --json tagName,name,body,url,isDraft,isPrerelease`。
161
+
162
+ ### 六、生产环境验证与发布后回访
163
+
164
+ 1. 完整读取 [发布后回访契约](references/post-release-follow-up.md)。
165
+ 2. 从仓库实际部署配置和运维文档确定生产服务器、连接方式、服务、品牌、target、版本标记、数据库和只读验证入口;禁止猜测主机或使用历史地址。
166
+ 3. 直接登录每台相关生产服务器,核对实际运行版本/commit、进程或容器、health/readiness、关键日志、worker/cron 和资源状态,确认部署事实而不是依赖流水线状态。
167
+ 4. 根据发行说明、PR、迁移和运维脚本识别本次需要人工执行的脚本,使用迁移表、任务记录、审计日志、marker、状态命令和数据结果验证是否已经执行且结果符合预期。检查默认只读;未经当前用户明确授权,不执行生产写脚本、迁移、回填、重启或重新部署。
168
+ 5. 自动创建一个发布后回访 Issue。Issue 必须覆盖:发布与服务器版本一致性、服务健康、运维脚本执行状态、数据结果、配置、可观测性、本次变更特有验收、回滚准备和延迟观察窗口。
169
+ 6. 立即执行当前可验证的检查;只有附有脱敏命令、查询结果摘要、日志位置或可观察结果的项目才能勾选。缺生产权限或需要观察窗口的项目保持未勾选,并写清所需权限或最早检查时间。
170
+ 7. 使用 `gh issue view` 读回 Issue,确认没有占位符、每个生产目标和本次发布影响面都有对应检查项,并输出 Issue URL。
171
+
172
+ GitHub Release 已创建但无法登录生产服务器、实际版本不匹配、必需运维脚本未执行或数据不符合预期时,仍然创建回访 Issue,把状态标为阻塞并立即向用户报告证据、影响、建议动作和重新验证项;不得静默修复或用“Release 已创建”掩盖生产问题。
160
173
 
161
174
  ## 终止条件
162
175
 
@@ -166,6 +179,7 @@ EOF
166
179
  - 当前分支不符合 release 分支命名规则,且无法从 `main` 自动创建 release 分支。
167
180
  - 版本号格式非法或与现有 tag 冲突。
168
181
  - 自上次发布以来无新提交。
182
+ - 无法创建或读回发布后回访 Issue。
169
183
 
170
184
  ## 输出模板
171
185
 
@@ -191,4 +205,6 @@ EOF
191
205
  - 分支名
192
206
  - tag 推送状态
193
207
  - Release URL
194
- - 发布后清单
208
+ - 生产服务器、实际运行版本与验证状态
209
+ - 发布后回访 Issue URL
210
+ - 已验证、阻塞、待授权、待观察项目数量
@@ -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,158 @@
1
+ # 发布后回访契约
2
+
3
+ 本文件只在 GitHub Release 创建成功后读取。目标是把部署后的未知风险变成一个有证据、可关闭的 Issue,而不是生成一张固定且无法证明完成的清单。
4
+
5
+ ## 完成边界
6
+
7
+ `git-release` 本次调用完成的最低条件是:
8
+
9
+ - Release 已读回确认;
10
+ - 已从实际配置确定或明确无法确定生产服务器与验证入口;
11
+ - 已登录所有相关生产服务器核对实际运行状态,或记录无法访问的证据;
12
+ - 发布后回访 Issue 已创建并读回;
13
+ - 本次发布涉及的每个环境、品牌、target、迁移、配置和用户可观察变化都有检查项;
14
+ - 当前能自动验证的项目已执行,只有带证据的项目被勾选。
15
+
16
+ 回访 Issue 不要求在当前调用中关闭。需要观察窗口、人工账号或业务确认的项目保持未勾选,避免为了“流程完成”伪造通过状态。
17
+
18
+ ## 生产服务器核验
19
+
20
+ 先检查仓库真实部署配置和运维文档,包括部署脚本、inventory、`dx/config/commands.json`、`dx/release/`、systemd/container 配置和 runbook。确定:
21
+
22
+ - 生产主机、SSH 入口、区域、品牌、服务与前端 target;
23
+ - 服务由 systemd、Docker、Kubernetes、PM2、serverless 或其他方式运行;
24
+ - 服务器上可验证版本/commit 的文件、环境变量、镜像标签、健康接口或运行参数;
25
+ - 数据库、队列、worker、cron、缓存和第三方连接的只读检查入口;
26
+ - 本次发布要求人工执行的迁移、回填、缓存刷新、配置生成或运维脚本。
27
+
28
+ 逐台登录本次涉及的生产服务器,使用仓库已有状态命令或等价的只读命令检查实际状态。按运行方式核对进程、容器、镜像、release 目录、符号链接、启动时间、health/readiness 和最近日志;命令必须收敛到明确服务,避免无边界扫描整台服务器。
29
+
30
+ 服务器验证默认只读。不要执行重启、重新部署、迁移、回填、数据修复、缓存清空或其他生产写操作;发现需要执行时,在 Issue 和当前回复中写明命令、原因、影响和验证方式,等待用户对该具体动作授权。
31
+
32
+ 如果缺少主机信息、SSH 权限或数据库只读权限,在 Issue 中明确写“生产验证受阻”,附已检查的配置位置和失败命令。此状态属于阻塞,不得写成部署成功。
33
+
34
+ ## 动态生成检查项
35
+
36
+ 先从发行说明、提交、PR、Issue、运维提醒和部署配置建立“发布影响面”,再为每个影响面生成至少一个可验证检查。只保留本次适用的分支,但以下类别必须逐项判定是否适用,不能静默跳过。
37
+
38
+ ### 发布与制品一致性
39
+
40
+ - tag、Release、版本文件和服务器实际运行 commit 指向同一版本;
41
+ - 服务器上的制品、镜像、release 目录或构建产物使用正确版本与 commit;
42
+ - 所有预期生产主机、品牌和 target 都运行目标版本,没有漏发、错发或部分节点仍运行旧版;
43
+ - Release 不是意外的 draft/prerelease,除非版本本身要求如此。
44
+
45
+ ### 服务器与服务状态
46
+
47
+ - 目标进程、容器、pod 或 function 正常运行,启动时间与本次发布一致;
48
+ - health/readiness、端口、反向代理和服务间连接正常;
49
+ - worker、cron、队列消费者和后台作业运行在目标版本;
50
+ - 最近日志没有启动失败、error、panic、timeout、权限错误或重复重启;
51
+ - CPU、内存、磁盘、连接数等没有因本次发布出现明显异常。
52
+
53
+ ### 运行时健康与可观测性
54
+
55
+ - health/readiness、关键进程、容器或 serverless function 健康;
56
+ - 发布后错误率、延迟、5xx、告警、日志异常没有明显回归;
57
+ - 队列积压、定时任务、事件消费、webhook 或后台作业正常;
58
+ - 域名、TLS、静态资源、CDN、缓存版本和 source map 符合预期。
59
+
60
+ ### 数据、配置与兼容性
61
+
62
+ - 本次迁移已应用到正确数据库,schema 与应用版本兼容;
63
+ - 新增或变更的环境变量、secret、feature flag 和第三方配置已生效;
64
+ - 公共 API、DTO、事件、数据库和客户端兼容性按发行说明验证;
65
+ - 使用有边界的只读查询核对关键总数、不变量、状态分布和抽样结果;不得在输出中泄露密钥、令牌、个人信息或业务敏感原始数据;
66
+ - 涉及数据修复或回填时,记录预期数量、实际数量、失败项和幂等/重跑状态。
67
+
68
+ ### 运维脚本执行状态
69
+
70
+ - 从本次 PR、迁移、release note 和 runbook 列出所有需要人工执行的脚本,不能只检查熟悉的脚本;
71
+ - 对每个脚本记录名称/版本、目标主机或数据库、预期效果和可验证完成标记;
72
+ - 通过迁移表、任务表、审计日志、marker、脚本状态子命令或数据结果判断 `已执行 / 未执行 / 无法确认 / 不适用`;
73
+ - “文件存在”或“有人说跑过”不算执行证据;
74
+ - 未经授权不代替运维执行写脚本。未执行或结果异常时立即报告,并给出建议命令和执行后的复核查询。
75
+
76
+ ### 用户与业务路径
77
+
78
+ - 为发行说明中的每个用户可观察变化生成对应 smoke check;
79
+ - 覆盖登录/鉴权、核心读写路径、支付或其他高风险业务路径中本次受影响的部分;
80
+ - 前端、管理端、移动端或多品牌变更分别验证对应入口,不能用一个端的通过代表全部端;
81
+ - 修复项要复现旧失败条件并验证新行为,新增项要验证成功路径和关键错误路径。
82
+
83
+ ### 回滚与延迟观察
84
+
85
+ - 记录上一稳定版本、回滚命令或恢复入口,以及迁移是否可逆;
86
+ - 对需要时间才能暴露的问题设置观察窗口和最早复查时间,例如错误率、队列积压、定时任务或缓存过期;
87
+ - 明确 Issue 关闭条件:所有必需项完成,阻塞项有结论,发现的问题已修复或拆成关联 Issue。
88
+
89
+ ## Issue 结构
90
+
91
+ 创建前先读取仓库 Issue 模板和现有 labels,沿用其结构与可用标签。标题使用:
92
+
93
+ ```text
94
+ chore(release): 回访 v<VERSION> 部署结果
95
+ ```
96
+
97
+ 正文至少包含:
98
+
99
+ ```markdown
100
+ ## 发布信息
101
+
102
+ - 版本:v<VERSION>
103
+ - Release:<URL>
104
+ - Tag commit:<SHA>
105
+ - 部署环境/品牌/target:<实际范围>
106
+ - 生产服务器与服务:<脱敏主机标识和实际范围>
107
+ - 实际运行版本/commit:<逐目标结果>
108
+ - 生产验证时间:<时间与时区>
109
+ - 验证状态:通过 / 阻塞 / 发现异常
110
+
111
+ ## 部署后检查清单
112
+
113
+ ### 发布与制品一致性
114
+
115
+ - [ ] <检查对象、预期结果、验证命令或证据位置>
116
+
117
+ ### 生产服务器与服务
118
+
119
+ - [ ] <检查项>
120
+
121
+ ### 运行时与可观测性
122
+
123
+ - [ ] <检查项>
124
+
125
+ ### 数据、配置与兼容性
126
+
127
+ - [ ] <检查项或“不适用 + 证据”>
128
+
129
+ ### 运维脚本
130
+
131
+ - [ ] <脚本、目标、预期结果、执行状态与证据>
132
+
133
+ ### 本次变更验收
134
+
135
+ - [ ] <逐项映射发行说明/PR/Issue 的用户可观察变化>
136
+
137
+ ### 回滚与观察窗口
138
+
139
+ - [ ] <回滚入口已确认>
140
+ - [ ] <观察指标、窗口、最早复查时间、负责人或所需权限>
141
+
142
+ ## 发现与后续
143
+
144
+ - 当前阻塞:无 / <失败证据与恢复动作>
145
+ - 关联问题:无 / #<issue>
146
+ - 关闭条件:<所有必需检查完成且发现的问题有结论>
147
+ ```
148
+
149
+ 正文通过 heredoc 或临时文件传给 `gh issue create --body-file`,禁止用字面量 `\n` 拼接。创建后用 `gh issue view <id> --json title,body,url,state` 读回。
150
+
151
+ ## 勾选与问题处理
152
+
153
+ - 勾选项必须同时写入证据:脱敏命令与结果摘要、日志位置、只读查询汇总、监控链接或具体可观察结果。
154
+ - “服务器能登录”“进程在运行”“页面能开”不能替代版本、脚本和数据的专项验证。
155
+ - 检查失败时保留未勾选状态,在“发现与后续”记录严重级、时间、主机/服务、证据、影响和建议动作,并立即在当前回复中报告。
156
+ - 发现问题后默认只报告和保全证据,不静默修改生产环境。修复需要生产写操作时等待用户对具体动作授权。
157
+ - 新发现的问题超出本次回访可直接修复的范围时创建关联 Issue;回访 Issue 保持打开,直到该问题有明确处置结果。
158
+ - 不适用项必须写出判定依据;不要为了模板完整保留空占位项。
@@ -0,0 +1,44 @@
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
+ ## 步骤一:Codex 门禁
11
+
12
+ 任何文件检查、Git/GitHub 操作或共享流程加载之前执行:
13
+
14
+ ```bash
15
+ if [[ -n "${CLAUDECODE:-}" ]]; then
16
+ echo "oo-ship-issue-pr 仅允许 Codex 调用;检测到 Claude Code 运行时,已退出。"
17
+ exit 64
18
+ fi
19
+ if [[ -z "${CODEX_THREAD_ID:-}" && -z "${CODEX_SESSION_ID:-}" ]]; then
20
+ echo "oo-ship-issue-pr 仅允许 Codex 调用;当前运行时不是 Codex,已退出。"
21
+ exit 64
22
+ fi
23
+ ```
24
+
25
+ `CLAUDECODE` 存在时优先拒绝,避免 Codex 启动的 Claude 子进程继承 `CODEX_*` 后误过门禁。门禁通过的完成标准是 `CLAUDECODE` 为空,且至少一个 Codex 身份变量非空。
26
+
27
+ ## 步骤二:加载共享流程
28
+
29
+ ```bash
30
+ AGENTS_ROOT="${AGENTS_HOME:-$HOME/.agents}"
31
+ SHIP_CORE="$AGENTS_ROOT/references/ship-issue-pr-core.md"
32
+ test -f "$SHIP_CORE"
33
+ ```
34
+
35
+ 完整读取 `SHIP_CORE` 后执行全部阶段。运行时映射如下:
36
+
37
+ - 主进程:当前 Codex。
38
+ - 外部专家:优先 Claude Fable 5;仅在 Fable 额度不足时回退 Claude Opus 5;Claude 通道不可用时改派 fresh Codex subagent。
39
+ - 入口显示名:`OO Ship Issue PR`。
40
+ - Follow-up:Codex `spawn_agent` 的 `worker` 角色。
41
+
42
+ 第一次进入外部专家或 follow-up 分支前,完整读取 [references/runtime.md](references/runtime.md)。该文件是本入口的平台调用契约;共享流程仍是交付语义的唯一真源。
43
+
44
+ 只有共享流程全部完成且 `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.