forked from DevOps/deploy.stack
docs: 新增 AI 生成 commit message 硬约束规则
Signed-off-by: cnphpbb <moqiruyi@126.com>
This commit is contained in:
41
AGENTS.md
41
AGENTS.md
@@ -232,6 +232,47 @@ git push origin main
|
|||||||
仓库早期 commit 有少量非 Conventional 风格(如 `Add lsd config and color theme`),
|
仓库早期 commit 有少量非 Conventional 风格(如 `Add lsd config and color theme`),
|
||||||
**新增 commit 一律遵循本规范**,历史风格不强制改写。
|
**新增 commit 一律遵循本规范**,历史风格不强制改写。
|
||||||
|
|
||||||
|
### AI 生成 commit message 的硬约束
|
||||||
|
|
||||||
|
当 AI 助手(或 IDE agent)被要求生成 commit message 时,**只输出 commit text 本身**,严禁夹带任何元评论、解释或代码块包裹。
|
||||||
|
|
||||||
|
**输出黑名单(出现即视为违规):**
|
||||||
|
|
||||||
|
- 前置说明:`我看了你的改动…`、`建议使用下面的 commit message:`、`以下为 commit:`
|
||||||
|
- 元评论词汇:`分析`、`考虑`、`由于`、`因为`、`建议`、`注意`、`这里`、`本次`、`因为需要`
|
||||||
|
- 复述 diff:把 `git diff` 的关键行直接放进 commit
|
||||||
|
- 解释"为什么改":commit 只描述"改了什么",不写动机
|
||||||
|
- 多版本候选/对比:不要 `Option 1 / Option 2` 或 `---begin--- / ---end---`
|
||||||
|
- markdown 代码块包裹:直接给纯文本,除非用户明确要求
|
||||||
|
|
||||||
|
**输出前自检清单:**
|
||||||
|
|
||||||
|
- [ ] 只包含 commit text,无任何前后缀
|
||||||
|
- [ ] subject ≤ 50 字符、无句末标点、动词开头、首字母小写
|
||||||
|
- [ ] type 在 `{feat, fix, docs, refactor, perf, build, chore, style, test}` 内
|
||||||
|
- [ ] scope 准确(服务名小写或顶层目录名)
|
||||||
|
- [ ] body 每行 ≤ 72 字符、不重复 subject
|
||||||
|
- [ ] 中英文不混用、保持与项目历史一致
|
||||||
|
- [ ] 未泄露 `password|secret|token|key` 等敏感词
|
||||||
|
|
||||||
|
**正确示例:**
|
||||||
|
|
||||||
|
```
|
||||||
|
feat(gitea): bump image to 1.25.2
|
||||||
|
```
|
||||||
|
|
||||||
|
**错误示例(AI 常见错误):**
|
||||||
|
|
||||||
|
```
|
||||||
|
我看了你的改动,主要是更新了镜像版本,建议使用:
|
||||||
|
|
||||||
|
feat(gitea): bump image to 1.25.2
|
||||||
|
|
||||||
|
这次改动把版本从 1.24 升到 1.25.2,主要修复了…
|
||||||
|
```
|
||||||
|
|
||||||
|
> **注意**:thinking 块属于模型内部推理,**无法在 commit 场景关闭**,但它对最终 commit 输出无污染。用户的关注点应放在"最终输出是否干净"。
|
||||||
|
|
||||||
## AGENTS.md 维护规则
|
## AGENTS.md 维护规则
|
||||||
|
|
||||||
AGENTS.md 是给 AI 助手(Claude Code、Codex、Hermes 等)和协作者阅读的项目宪法。
|
AGENTS.md 是给 AI 助手(Claude Code、Codex、Hermes 等)和协作者阅读的项目宪法。
|
||||||
|
|||||||
Reference in New Issue
Block a user