本文件为 Codex(Codex.ai/code)提供 lebitai/agent 仓库的协作规范。
LEBITAI Agent 是自有品牌的智能体开发平台 + 运行时 + 前台交付层,核心链路自建。详细架构设计见 docs/architecture/00-overview.md
- 语言约定: 搜索英文,回复中文,代码注释英文
- Git 提交: commit message 必须英文
- 禁止硬编码: 产品文案统一由 i18n JSON 维护
- 最小化修改: 控制变更面,避免影响无关模块
- Plan 模式: 方案需 xiaoliwe 评审后才能执行代码修改
- Context7 MCP: 遇到库/API 文档、代码生成、配置步骤时,主动使用 Context7 MCP 获取最新文档,无需用户显式要求
- Simplicity First: Make every change as simple as possible. Impact minimal code.
- No Laziness: Find root causes. No temporary fixes. Senior developer standards.
- Minimal Impact: Changes should only touch what's necessary. Avoid introducing bugs.
- 遵循 Clean Code 原则(结构、命名、依赖、测试)
- 关注圈复杂度:能拆则拆、能复用则复用
- 模块化设计:合适场景用设计模式,但不为模式而模式
- i18n: 默认中文,禁止页面代码硬编码文案
- 环境变量:
.env不提交,同步维护.env.example
禁止在根目录创建未经许可的文件
| 类型 | 允许文件 |
|---|---|
| 入口文档 | README.md, AGENTS.md, LICENSE |
| 配置文件 | .env*, *.json, *.yml, *.ts, Makefile |
| 忽略规则 | .gitignore, .prettierignore, .editorconfig |
禁止: 进度日志→docs/progress/,临时文件→.gitignore,新文档→docs/
- 默认不创建任何新文档
- 仅在明确要求时才生成 README/设计文档
- No backward compatibility, break old formats freely
提交前必须: golangci-lint run
| 指标 | 限制 | 说明 |
|---|---|---|
| 圈复杂度 | ≤ 15 | 超过需拆分 |
| 函数行数 | ≤ 80 | 单函数最大行数 |
| 函数参数 | ≤ 5 | 超过用结构体封装 |
| 嵌套深度 | ≤ 4 | if/for 嵌套层数 |
rustfmt格式化cargo clippy -- -D warnings(警告视为错误)
- UI 文本提取到
locales/ - 样式分离到独立 CSS/LESS 文件
- 响应式布局,适配不同屏幕
- 主分支:
main(唯一稳定分支,禁止直接开发) - 提交格式:
feat/fix/docs/refactor/test/chore - 提交语言: 必须英文
- 协作者: 仅 xiaoliwe(禁止 AI 账号)
⚠️ AI 提醒规则: 如发现在main分支上进行功能开发、修复、重构或文档编写,必须提醒用户新开分支。
git checkout main && git pull
git checkout -b <type>/<module>-<description>
git add . && git commit -m "<type>(<scope>): <message>"
git push origin <branch-name>
# PR 审核通过后合并,72小时内分支不删除分支命名:
| 类型 | 格式 | 示例 |
|---|---|---|
| 新功能 | feat/<module>-<description> |
feat/league-ranking-tabs |
| 修复 | fix/<module>-<description> |
fix/knowledge-book-learning |
| 重构 | refactor/<description> |
refactor/api-response-format |
| 文档 | docs/<description> |
docs/deployment-guide |
⚠️ 源自 PR #287 空合并事故:commit-msg hook 静默失败导致 commit 未生效,空分支被推送并合并。
| 步骤 | 操作后 | 验证命令 | 失败处理 |
|---|---|---|---|
| 1 | git commit |
git log -1 --oneline 确认 commit 存在 |
exit code ≠ 0 则重试,husky 损坏时加 --no-verify |
| 2 | git push 前 |
git log --oneline HEAD --not origin/main 确认不为空 |
列表为空则停止,排查 commit 丢失原因 |
| 3 | gh pr create 前 |
git diff --stat origin/main..HEAD 确认文件变更正确 |
变更列表为空则禁止创建 PR |
Worktree 特殊说明: .husky/_/husky.sh 在 worktree 中可能不存在,遇到 hook 失败时使用 git commit --no-verify。