根据 leaf Spec 或 design.md 自动生成代码。当用户说"生成代码"、"实现功能"、"写代码"时自动触发。支持 CAF v0.6.5 直接从 Spec 生成。
根据 leaf Spec(推荐)或 design.md(可选)自动生成代码。
CAF v0.6.5: 优先从
specs/SPEC-*.md(leaf=true) 直接生成代码;design.md仅在复杂/高风险场景作为可选中间层。
specs/SPEC-*.md, leaf: true, status: ready|done|draft*)design.md 存在且 status: donecharter.yaml#freeze.frozen: false,提醒用户先执行 /charter-freeze| 输入类型 | 路径 | 检查条件 |
|---|---|---|
| leaf Spec(推荐) | specs/SPEC-*.md |
leaf: true + `status: ready |
| design.md(可选) | docs/L3/{function}/design.md |
status: done |
* 关于 draft 状态:若 Spec 仍为
status: draft,需满足以下条件方可实现:
- Leaf Checklist 已手动确认(各项无阻塞)
- 用户明确指定该 Spec
- 实现完成后应将 Spec 状态更新为
done
/spec(生成 leaf Spec).agent/config/quality.{language_profile}.yaml从 leaf Spec(推荐路径):
specs/SPEC-{id}.md
├── frontmatter: source_requirements, interfaces, depends_on
├── Implementation Plan(步骤 + 文件列表)
├── Acceptance Tests(验收用例)
└── Interfaces Impact(接口影响)
从 design.md(可选路径):
docs/L3/{function}/design.md
├── 算法设计
├── 数据结构
└── 接口定义
从 charter.yaml 获取:
language_profile(单语言项目)components[*].language_profile(多组件项目)输出路径:
src/apps/{component}/(如 apps/api/, apps/widget/)读取对应语言配置并应用:
.agent/config/quality.python.yaml.agent/config/quality.typescript.yaml.agent/config/quality.java.yaml.agent/config/quality.cpp.yaml.agent/config/quality.swift.yaml规范要求:
{{profile.style.type_annotations}}{{profile.style.docstrings}}{{profile.style.linter}}根据 Implementation Plan 中的 Files / Modules 生成代码:
{{profile.source.structure}} 组织docs/L2/interfaces.md 接口契约| 组件 | 输出路径 |
|---|---|
| api-server | apps/api/**/*.py |
| chat-widget | apps/widget/**/*.tsx |
| admin-dashboard | apps/admin/**/*.tsx |
| 单语言项目 | src/**/*{{profile.source.extensions}} |
## 代码生成结果
**输入源**: specs/SPEC-{id}.md 或 design.md
**生成的文件**:
- 文件路径
- 文件路径
**语言配置**: python/typescript
**代码规范**: 遵循 quality.{language}.yaml
**质量检查**:
- Linting: PASS/FAIL
- 类型检查: PASS/FAIL
- 复杂度: 符合/超标
**下一步**:
- 运行 test-generator Skill 生成测试
- 或手动 Review 代码
重要: 若实现过程中需要新增/修改跨组件接口:
docs/L2/interfaces.md(唯一接口真源)docs/architecture/api-spec.md请根据 specs/SPEC-003.md 生成代码。
遵循 .agent/config/quality.python.yaml。
代码放入 apps/api/ 目录。