临时实现计划 是做什么的?
从粗略想法到可供实现-提交的制品的快速路径。以牺牲文档完备性换取速度。
何时使用
- 你已与用户讨论过某个粗略计划或想法
- 你希望实现-提交的TDD验证功能,而无需完整的提案链条
- 功能足够明确,无需进行广泛的设计迭代
前置条件
- 用户已批准的粗略计划(可以是对话、Markdown或思维模型形式)
- 已知的工作空间路径
- 已知的要修改的文件
编排器角色
你是机械路由(MECHANICAL ROUTER)。你不负责思考功能细节。 你的工作:
- 从用户处收集最小必要信息
- 创建功能目录结构
- 以适当的技能上下文生成子智能体
- 在各阶段之间传递输出
- 验证交叉引用
设置
from pydantic import BaseModel
from pathlib import Path
import os
class GatherResult(BaseModel):
feature_name: str
feature_id: str # NNNN格式
workspace: str
files_to_modify: list[str]
constraints: list[str]
test_names: list[str]
rough_plan_summary: str
class PhaseResult(BaseModel):
success: bool
artifact_path: str
errors: list[str]
# 子智能体上下文的技能路径
skills = {
"design": "skills/propose-feature-design/SKILL.md",
"test_plan": "skills/propose-feature-test-plan/SKILL.md",
"impl_plan": "skills/propose-implementation-plan/SKILL.md",
}
# 风格指南(如果可用)
style_guides = [
"docs/style/rust-design.md",
"docs/style/rust-test.md",
"docs/style/rust-impl.md",
]
阶段0:收集
从粗略计划中交互式收集或推断信息:
# 如果尚不清楚,请询问用户:
# 1. 功能名称 → 创建 docs/features/NNNN-name/
# 2. 要修改的文件 → commits[].files
# 3. 关键约束 → CC表格条目
# 4. 测试名称 → test-plan + commits[].tests
# 确定下一个功能ID
existing = list(Path("docs/features").glob("[0-9][0-9][0-9][0-9]-*"))
next_id = f"{len(existing):04d}"
feature_dir = f"docs/features/{next_id}-{feature_name}"
os.makedirs(feature_dir, exist_ok=True)
阶段1:最小化设计
使用propose-feature-design技能生成子智能体,但要求最小化输出。
result = spawn(
prompt=draft_spawn_prompt(SkillDefined(
"按照技能流程创建最小化design.md。"
"仅生成:概述(1段)、关键约束表格、模块结构。"
"跳过:架构图、解决方案机制文字、设计模式、设计决策。"
)),
context_files=[
skills["design"],
*[g for g in style_guides if exists(g)],
],
context_data={
"feature_dir": feature_dir,
"feature_name": gathered.feature_name,
"constraints": gathered.constraints,
"files": gathered.files_to_modify,
"rough_plan": gathered.rough_plan_summary,
"minimal_mode": True,
},
response_model=PhaseResult,
isolate_to=Cwd(gathered.workspace)
)
阶段2:最小化测试计划
使用propose-feature-test-plan技能生成子智能体。
result = spawn(
prompt=draft_spawn_prompt(SkillDefined(
"按照技能流程创建最小化test-plan.md。"
"仅生成:需求覆盖表格、关键约束验证表格。"
"跳过:详细测试实现说明、集成测试文字。"
)),
context_files=[
skills["test_plan"],
f"{feature_dir}/design.md", # 来自阶段1
*[g for g in style_guides if exists(g)],
],
context_data={
"feature_dir": feature_dir,
"test_names": gathered.test_names,
"constraints": gathered.constraints,
"minimal_mode": True,
},
response_model=PhaseResult,
isolate_to=Cwd(gathered.workspace)
)
阶段3:实现计划
使用propose-implementation-plan技能生成子智能体。
result = spawn(
prompt=draft_spawn_prompt(SkillDefined(
"按照技能流程创建implementation-plan.toml。"
"所有字段均需填写 - 无最小化模式。"
"确保tests[]与test-plan.md中的测试名称完全匹配。"
)),
context_files=[
skills["impl_plan"],
f"{feature_dir}/design.md",
f"{feature_dir}/test-plan.md",
*[g for g in style_guides if exists(g)],
],
context_data={
"feature_dir": feature_dir,
"workspace": gathered.workspace,
"files": gathered.files_to_modify,
"rough_plan": gathered.rough_plan_summary,
},
response_model=PhaseResult,
isolate_to=Cwd(gathered.workspace)
)
阶段4:验证交叉引用
生成验证器检查测试覆盖率。
class VerifyResult(BaseModel):
valid: bool
missing_tests: list[str] # 在test-plan中但不在impl-plan中
orphan_tests: list[str] # 在impl-plan中但不在test-plan中
missing_constraints: list[str] # CC-N未被覆盖
result = spawn(
prompt=draft_spawn_prompt(AdHoc(
intents=["验证implementation-plan.toml可用于实现-提交"],
context=["检查所有制品之间的交叉引用"],
goal=Verify(constraints=[
"test-plan.md中的每个测试在commits[].tests中恰好出现一次",
"design.md中的每个CC-N在test-plan.md中有验证",
"所有commits[].files存在或将被创建",
"TOML解析正确",
])
)),
context_files=[
f"{feature_dir}/design.md",
f"{feature_dir}/test-plan.md",
f"{feature_dir}/implementation-plan.toml",
],
response_model=VerifyResult,
read_only=True
)
if not result.parsed.valid:
# 返回阶段3,附带错误信息
pass
交接
验证通过后,制品即可供实现-提交使用:
docs/features/NNNN-feature-name/
├── design.md # 最小化:概述 + CC表格 + 模块结构
├── test-plan.md # 最小化:仅覆盖表格
└── implementation-plan.toml # 完整:所有必填字段
告知用户:
制品已就绪。运行 implement-commit 技能以执行TDD流水线。