Skip to content

Commit 59338d4

Browse files
authored
feat(skills): Stage Contract 迁移(全部 9 个 Skill)(#61)
* feat(skills): Stage Contract 迁移阶段 1 — 需求/设计/任务/初始化 为 flow-setup, flow-requirements, flow-design, flow-tasks 追加统一 Stage Contract: Trigger, Inputs, Preconditions, Procedure, Outputs, Failure, Idempotency, Prohibited Actions * feat(skills): Stage Contract 迁移阶段 2 — 编码/测试/审查/发布/交接 为 flow-code, flow-test, flow-review, flow-release, flow-handoff 追加统一 Stage Contract: Trigger, Inputs, Preconditions, Procedure, Outputs, Failure, Idempotency, Prohibited Actions
1 parent b182bc1 commit 59338d4

9 files changed

Lines changed: 305 additions & 0 deletions

File tree

assets/skills/flow-code/SKILL.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,40 @@ gh pr create --title "<title>" --body-file docs/dev/handoff/pr-body.md
123123
## 后续
124124
- **/test** — 触发 CI E2E 测试
125125
- **/review** — 审查 PR
126+
127+
## Contract
128+
129+
### Trigger
130+
`/code` 命令或 `@dev-lifecycle` Phase 3 触发。
131+
132+
### Inputs
133+
- Sub Issue 编号(来源:`/tasks` 产出)
134+
- task 文件 frontmatter 中的 `worktree_root`(来源:task 文件)
135+
136+
### Preconditions
137+
- `/tasks` 已完成 → Sub Issues 就绪
138+
- 前置依赖任务已合并
139+
140+
### Procedure
141+
1. 选择依赖已满足的 Sub Issue
142+
2. 创建或复用 Worktree(`git worktree add -b`
143+
3. 安装依赖 → 编码 + 单测 → commit + push
144+
4. 编排器创建 PR
145+
146+
### Outputs
147+
- Worktree 已创建(`.worktree/<task-slug>/`
148+
- 代码已推送
149+
- PR 已创建(Orchestrator 执行)
150+
151+
### Failure
152+
- Worktree 创建失败 → 检查分支冲突或目录残留
153+
- 测试失败 → 修复后重试
154+
155+
### Idempotency
156+
- Worktree 已存在 → 复用
157+
- 代码已提交 → 追加提交
158+
159+
### Prohibited Actions
160+
- Worker 不创建 PR、不操作 Issue
161+
- 不使用 `git add .`
162+
- 不直接 push 到默认分支

assets/skills/flow-design/SKILL.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,39 @@ git checkout $BASE && git pull origin $BASE
8181

8282
## 后续
8383
- **/tasks** — 基于设计方案拆解为 DAG 任务
84+
85+
## Contract
86+
87+
### Trigger
88+
`/design` 命令或 `@dev-lifecycle` Phase 1 触发。
89+
90+
### Inputs
91+
- `docs/prd/<title>.md` — 上游 PRD(来源:requirements 阶段产出)
92+
- Parent Issue 编号(来源:Goal metadata 或 `/requirements` 阶段产出)
93+
94+
### Preconditions
95+
- `/requirements` 已完成 → `docs/prd/<title>.md` 存在
96+
- Parent Issue 存在
97+
98+
### Procedure
99+
1. 阅读 PRD、已有 ADR、Out of Scope
100+
2. 输出技术方案到 `docs/dev/specs/<title>.md`
101+
3. 记录 ADR 到 `docs/adr/<YYYY-MM-DD>-<slug>.md`
102+
4. 附设计评论到 Parent Issue
103+
5. 通过 Planning PR 提交文档
104+
105+
### Outputs
106+
- `docs/dev/specs/<title>.md` — 技术方案
107+
- `docs/adr/<date>-<slug>.md` — ADR 决议
108+
109+
### Failure
110+
- ADR 与已有决策冲突 → 记录冲突并标注
111+
- Planning PR 合并失败 → 通知用户手动处理
112+
113+
### Idempotency
114+
- 技术方案已存在 → 读取并更新
115+
- ADR 已存在 → 不重复创建
116+
117+
### Prohibited Actions
118+
- 不直接 push 到默认分支
119+
- 不跳过 ADR 兼容性检查

assets/skills/flow-handoff/SKILL.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,32 @@ description: 打包上下文,跨会话传递进度
4545

4646
## Output
4747
- `docs/dev/handoff-<date>.md`
48+
49+
## Contract
50+
51+
### Trigger
52+
`/handoff` 命令触发。上下文窗口接近极限或需跨会话传递进度时使用。
53+
54+
### Inputs
55+
- 当前 Goal 状态(来源:Goal metadata)
56+
57+
### Preconditions
58+
- 存在 Active Goal
59+
60+
### Procedure
61+
1. 打包当前流程状态(阶段、任务、进度)
62+
2. 列出已完成和待完成项
63+
3. 确定下一步骤
64+
4. 保存到 handoff 文件
65+
66+
### Outputs
67+
- `docs/dev/handoff-<date>.md` — 交接文件
68+
69+
### Failure
70+
- 无 Goal → 仅输出当前会话摘要
71+
72+
### Idempotency
73+
- 同一天多次执行 → 覆盖前一次 handoff
74+
75+
### Prohibited Actions
76+
- 不修改代码或文档

assets/skills/flow-release/SKILL.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,38 @@ GitHub Releases 页面 → 检查 Release 草稿 → 点击 **Publish release**
4848

4949
## 后续
5050
无需后续阶段。Flow 完成。
51+
52+
## Contract
53+
54+
### Trigger
55+
`/release` 命令触发。**仅手动触发**,不包含在自动流程中。
56+
57+
### Inputs
58+
- 版本号类型(patch/minor/major,来源:用户指定)
59+
60+
### Preconditions
61+
- 所有 PR 已合并
62+
- 默认分支最新
63+
- 所有测试通过
64+
65+
### Procedure
66+
1. 确认版本号
67+
2. 更新版本(npm version)
68+
3. 生成 Changelog
69+
4. 创建 git tag → push → 触发 Release 草稿
70+
5. 人工审核发布 → npm publish
71+
72+
### Outputs
73+
- GitHub Release
74+
- npm 包已发布
75+
76+
### Failure
77+
- npm publish 失败 → 检查 npm 认证
78+
- tag 已存在 → 提示版本冲突
79+
80+
### Idempotency
81+
- 相同版本号 → 阻止
82+
83+
### Prohibited Actions
84+
- 不在自动模式中执行
85+
- 不跳过测试直接发布

assets/skills/flow-requirements/SKILL.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,37 @@ gh issue create \
4646

4747
## 下一阶段
4848
- **/design** — 基于此 PRD 进行技术设计
49+
50+
## Contract
51+
52+
### Trigger
53+
`/requirements` 命令或 `@dev-lifecycle` Phase 0 触发。
54+
55+
### Inputs
56+
- 用户提供的功能描述(来自消息文本)
57+
58+
### Preconditions
59+
- `/setup` 已完成(gh CLI 可用,docs 目录就绪)
60+
61+
### Procedure
62+
1. 按 interview-guide 进行需求访谈
63+
2. 输出 PRD 到 `docs/prd/<title>.md`
64+
3. 记录 Out of Scope 到 `docs/dev/out-of-scope.md`
65+
4. 创建 Parent GitHub Issue
66+
67+
### Outputs
68+
- `docs/prd/<title>.md` — PRD 文档
69+
- `docs/dev/out-of-scope.md` — 排除范围记录
70+
- GitHub Parent Issue
71+
72+
### Failure
73+
- gh CLI 不可用 → 提示先执行 /setup
74+
- Issue 创建失败 → 记录错误,不阻塞 PRD 写入
75+
76+
### Idempotency
77+
- 如果 PRD 文件已存在 → 更新而非覆盖
78+
- 如果 Parent Issue 已创建 → 追加评论而非重复创建
79+
80+
### Prohibited Actions
81+
- 不跳过访谈直接输出 PRD
82+
- 不省略 Out of Scope 记录

assets/skills/flow-review/SKILL.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,39 @@ fi
121121

122122
## 后续
123123
- **/release** — 发布(如所有 PR 已合并)
124+
125+
## Contract
126+
127+
### Trigger
128+
`/review` 命令或 `@dev-lifecycle` Phase 3 审查步骤触发。
129+
130+
### Inputs
131+
- PR 编号(来源:`/code` 产出)
132+
133+
### Preconditions
134+
- `/code` 已完成 → PR 已创建
135+
136+
### Procedure
137+
1. 获取 PR diff 和元数据
138+
2. 双轴审查(规范轴 + 规格轴)
139+
3. 输出结构化审查报告
140+
4. 编排器发布审查结果
141+
5. 等待 CI 通过后合并
142+
6. 关闭关联 Sub Issue
143+
7. 安全清理 Worktree(Preflight)
144+
145+
### Outputs
146+
- 结构化审查报告(APPROVED / CHANGES_REQUESTED)
147+
- PR 已合并(条件满足时)
148+
149+
### Failure
150+
- Critical/High → Request Changes
151+
- Worktree 清理失败 → 记录警告,不阻塞
152+
153+
### Idempotency
154+
- 已合并的 PR → 跳过
155+
- 已审查的 PR → 更新结论
156+
157+
### Prohibited Actions
158+
- 不使用默认 --force 清理
159+
- 不直接执行 gh pr merge(Orchestrator 执行)

assets/skills/flow-setup/SKILL.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,35 @@ echo "setup-complete" > .opencode/opencode-cabbage/setup-complete
4141
- `docs/` 目录已就绪
4242
- 开发环境已验证
4343
- 可开始 `/requirements`
44+
45+
## Contract
46+
47+
### Trigger
48+
`/setup` 命令触发。首次使用插件或切换新项目时执行。
49+
50+
### Inputs
51+
无外部输入。从当前工作目录检测项目状态。
52+
53+
### Preconditions
54+
无。不要求任何前置阶段。
55+
56+
### Procedure
57+
1. 创建 docs 目录结构
58+
2. 验证 gh CLI 和 GitHub 远程
59+
3. 写入完成标记
60+
61+
### Outputs
62+
- `docs/` 目录树(prd, adr, dev/specs, dev/tasks, dev/api, dev/db, dev/guides, dev/handoff)
63+
- `.opencode/opencode-cabbage/setup-complete` 标记文件
64+
65+
### Failure
66+
- 目录创建失败 → 报告错误并退出
67+
- gh auth 失败 → 提示用户执行 `gh auth login`
68+
69+
### Idempotency
70+
- 已存在的目录跳过
71+
- 已存在 `setup-complete` 标记则跳过全部步骤
72+
73+
### Prohibited Actions
74+
- 不删除已有目录或文件
75+
- 不修改项目代码

assets/skills/flow-tasks/SKILL.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,38 @@ Sub Issue 不在 `/tasks` 阶段关闭,而是在对应 PR 合并后自动关
107107

108108
## 后续
109109
- **/code** — 认领 Sub Issue 开始编码
110+
111+
## Contract
112+
113+
### Trigger
114+
`/tasks` 命令或 `@dev-lifecycle` Phase 2 触发。
115+
116+
### Inputs
117+
- `docs/dev/specs/<title>.md` — 技术方案
118+
- Parent Issue 编号
119+
120+
### Preconditions
121+
- `/design` 已完成 → 技术方案和 ADR 存在
122+
123+
### Procedure
124+
1. 基于技术方案拆解 DAG
125+
2. 创建 Task Manifest (`manifest.yaml`) 和任务文件
126+
3. 为每个任务创建 GitHub Sub Issue
127+
4. 通过 Planning PR 提交任务文件
128+
129+
### Outputs
130+
- `docs/dev/tasks/<feature-slug>/manifest.yaml` — 任务清单
131+
- `docs/dev/tasks/<feature-slug>/*.md` — 任务文件
132+
- GitHub Sub Issues(含依赖声明)
133+
134+
### Failure
135+
- DAG 存在环形依赖 → 阻止并报告
136+
- Sub Issue 创建失败 → 记录失败项
137+
138+
### Idempotency
139+
- 任务文件已存在 → 读取并更新
140+
- Sub Issue 已创建 → 更新而非重复创建
141+
142+
### Prohibited Actions
143+
- 不跳过 DAG 依赖检查
144+
- 不直接 push 到默认分支

assets/skills/flow-test/SKILL.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,34 @@ gh pr checks <pr-number> --watch
4242

4343
## 后续
4444
- **/review** — 审查 PR
45+
46+
## Contract
47+
48+
### Trigger
49+
`/test` 命令触发。在已创建的 PR 上运行 CI 测试。
50+
51+
### Inputs
52+
- PR 编号(来源:`/code` 产出)
53+
54+
### Preconditions
55+
- `/code` 已完成 → PR 已创建
56+
57+
### Procedure
58+
1. 检查 CI 配置是否存在
59+
2. 触发 CI 运行
60+
3. 监控运行状态
61+
4. 汇报结果
62+
63+
### Outputs
64+
- CI 运行结果摘要
65+
66+
### Failure
67+
- CI 失败 → 分析日志并建议修复
68+
- 无 CI 配置 → 引导用户创建 .github/workflows/ci.yml
69+
70+
### Idempotency
71+
- 重复触发同一 PR → 覆盖前一次运行
72+
73+
### Prohibited Actions
74+
- 不修改 CI 配置
75+
- 不触发非当前 PR 的 CI

0 commit comments

Comments
 (0)