fix(blueprint): 提示词嵌入 manifest 硬约束骨架——防子项目 AI 产出非法格式
noteapp 事故:新导入项目执行"更新蓝图描绘"后 manifest 解析失败 (missing field area)——子项目 AI 写出 project:/stable/in-progress/ depends_on 等自造格式。根因:CONVENTIONS 全文 900+ 行随提示词下发, manifest 规范埋在中间被忽略,且无"现有文件不合法必须重写"指令。 init/sync 双模板注入就近的严格 schema 骨架:合法字段清单、status 枚举、 非法示例点名、强制重写指令。 Rules-Applied: R02, R10
This commit is contained in:
parent
5e2e899075
commit
d4cb3c0567
@ -775,6 +775,40 @@ fn read_blueprint_summary(root: &Path) -> String {
|
||||
if parts.is_empty() { "(蓝图目录为空)".to_string() } else { parts.join("\n\n") }
|
||||
}
|
||||
|
||||
/// manifest.yaml 硬约束骨架——就近、简短、高亮,防止子项目 AI 凭感觉或沿用非法旧格式。
|
||||
/// (CONVENTIONS 全文 900+ 行,manifest 规范埋在中间,实测会被忽略——noteapp 事故)
|
||||
fn manifest_schema_hint() -> &'static str {
|
||||
r##"## ⚠️ manifest.yaml 严格格式(解析器强校验,违反则蓝图无法识别)
|
||||
|
||||
```yaml
|
||||
version: 1
|
||||
name: 项目名
|
||||
iteration: 1
|
||||
updated: YYYY-MM-DD
|
||||
|
||||
areas: # 至少定义一个
|
||||
- id: frontend
|
||||
name: 前端
|
||||
color: "#3B82F6"
|
||||
|
||||
modules:
|
||||
- id: kebab-case-id # 必填,唯一
|
||||
name: 显示名称 # 必填
|
||||
area: frontend # 必填!必须是上方 areas 中已定义的 id
|
||||
status: done # 必填,只允许:done | in_progress | planned | concept | blocked | abandoned
|
||||
position: [0, 0] # 可选
|
||||
|
||||
edges: # 可选
|
||||
- from: module-a
|
||||
to: module-b
|
||||
type: dependency # 只允许 dependency | related
|
||||
```
|
||||
|
||||
硬性规定:
|
||||
- 禁止自造字段与取值(如 `project:`、`stable`、`in-progress`、`depends_on:` 均非法)——依赖关系写入顶层 edges
|
||||
- **若项目中已存在不符合此格式的 manifest.yaml,必须重写为合法格式**(保留其中的有效信息),不要沿用旧结构"##
|
||||
}
|
||||
|
||||
fn build_init_prompt(
|
||||
project_name: &str,
|
||||
tech_stack: &str,
|
||||
@ -819,6 +853,8 @@ fn build_init_prompt(
|
||||
|
||||
{conventions}
|
||||
|
||||
{schema_hint}
|
||||
|
||||
## 你的任务
|
||||
1. 识别项目的主要功能模块({module_hint}),合理划分 area(前端/后端/基础设施等)
|
||||
2. 创建 `.blueprint/manifest.yaml`(含 areas、modules、edges)
|
||||
@ -830,6 +866,7 @@ fn build_init_prompt(
|
||||
请直接输出需要创建的文件内容。
|
||||
"#,
|
||||
conventions = effective_conventions_content(),
|
||||
schema_hint = manifest_schema_hint(),
|
||||
)
|
||||
}
|
||||
|
||||
@ -912,6 +949,8 @@ fn build_sync_prompt(
|
||||
|
||||
{conventions}
|
||||
|
||||
{schema_hint}
|
||||
|
||||
## 你的任务
|
||||
{tasks}
|
||||
|
||||
@ -931,6 +970,7 @@ fn build_sync_prompt(
|
||||
tasks = tasks,
|
||||
output_hint = output_hint,
|
||||
conventions = effective_conventions_content(),
|
||||
schema_hint = manifest_schema_hint(),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user