From d4cb3c05675d76361dfa4fbac0b49ddc2292238c Mon Sep 17 00:00:00 2001 From: lanrtop Date: Fri, 3 Jul 2026 10:37:18 +0900 Subject: [PATCH] =?UTF-8?q?fix(blueprint):=20=E6=8F=90=E7=A4=BA=E8=AF=8D?= =?UTF-8?q?=E5=B5=8C=E5=85=A5=20manifest=20=E7=A1=AC=E7=BA=A6=E6=9D=9F?= =?UTF-8?q?=E9=AA=A8=E6=9E=B6=E2=80=94=E2=80=94=E9=98=B2=E5=AD=90=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=20AI=20=E4=BA=A7=E5=87=BA=E9=9D=9E=E6=B3=95=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit noteapp 事故:新导入项目执行"更新蓝图描绘"后 manifest 解析失败 (missing field area)——子项目 AI 写出 project:/stable/in-progress/ depends_on 等自造格式。根因:CONVENTIONS 全文 900+ 行随提示词下发, manifest 规范埋在中间被忽略,且无"现有文件不合法必须重写"指令。 init/sync 双模板注入就近的严格 schema 骨架:合法字段清单、status 枚举、 非法示例点名、强制重写指令。 Rules-Applied: R02, R10 --- src-tauri/src/commands/blueprint.rs | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src-tauri/src/commands/blueprint.rs b/src-tauri/src/commands/blueprint.rs index 41c6cc6..64a98c3 100644 --- a/src-tauri/src/commands/blueprint.rs +++ b/src-tauri/src/commands/blueprint.rs @@ -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(), ) }