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:
lanrtop 2026-07-03 10:37:18 +09:00
parent 5e2e899075
commit d4cb3c0567

View File

@ -775,6 +775,40 @@ fn read_blueprint_summary(root: &Path) -> String {
if parts.is_empty() { "(蓝图目录为空)".to_string() } else { parts.join("\n\n") } 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( fn build_init_prompt(
project_name: &str, project_name: &str,
tech_stack: &str, tech_stack: &str,
@ -819,6 +853,8 @@ fn build_init_prompt(
{conventions} {conventions}
{schema_hint}
## ##
1. {module_hint} area// 1. {module_hint} area//
2. `.blueprint/manifest.yaml` areasmodulesedges 2. `.blueprint/manifest.yaml` areasmodulesedges
@ -830,6 +866,7 @@ fn build_init_prompt(
"#, "#,
conventions = effective_conventions_content(), conventions = effective_conventions_content(),
schema_hint = manifest_schema_hint(),
) )
} }
@ -912,6 +949,8 @@ fn build_sync_prompt(
{conventions} {conventions}
{schema_hint}
## ##
{tasks} {tasks}
@ -931,6 +970,7 @@ fn build_sync_prompt(
tasks = tasks, tasks = tasks,
output_hint = output_hint, output_hint = output_hint,
conventions = effective_conventions_content(), conventions = effective_conventions_content(),
schema_hint = manifest_schema_hint(),
) )
} }