From 4d9c003470d0a585cef2eeb3fb3f3f2301824ee0 Mon Sep 17 00:00:00 2001 From: lanrtop Date: Wed, 8 Apr 2026 02:59:40 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=93=9D=E5=9B=BE=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E4=B8=89=E9=A1=B9=E4=BC=98=E5=8C=96=EF=BC=88P1/P3/P4?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit P1 - CONVENTIONS 版本号自动同步 - 删除手动维护的 MASTER_CONVENTIONS_VERSION 常量 - 新增 master_conventions_version() 从 frontmatter 自动解析,基于 OnceLock 缓存 - CLAUDE_MANAGED_TEMPLATE 改为 claude_managed_template() 函数,版本号随之自动同步 P3 - 梦核提示词精简 - 新增 conventions_rules_summary(),按白名单抽取规则段落 - 保留:何时更新蓝图、模块状态定义、可派发标准、迭代管理、飞轮外环、注意事项 - 跳过:任务卡格式、manifest 字段规范、流程说明等实现细节 - 提示词 CONVENTIONS 部分从 ~500 行压缩至关键规则段落 P4 - usage.json 补执行 delta - 快照新增 task_ids.done / task_ids.blocked(当前任务状态,供下次对比) - 快照新增 delta.newly_done / newly_blocked / unblocked(与上次快照的差量) - 梦核可据此看到执行轨迹,而非仅状态截面 --- src-tauri/src/commands/blueprint.rs | 143 ++++++++++++++++++++++++---- 1 file changed, 126 insertions(+), 17 deletions(-) diff --git a/src-tauri/src/commands/blueprint.rs b/src-tauri/src/commands/blueprint.rs index 79fe0f8..c1e088a 100644 --- a/src-tauri/src/commands/blueprint.rs +++ b/src-tauri/src/commands/blueprint.rs @@ -4,10 +4,24 @@ use std::path::Path; // ── 主节点:master CONVENTIONS.md 内容和版本(编译时嵌入)──────────────────── const MASTER_CONVENTIONS: &str = include_str!("../../../.blueprint/CONVENTIONS.md"); -const MASTER_CONVENTIONS_VERSION: &str = "1.4.2"; -// CLAUDE.md 蓝图管理区模板(版本与 CONVENTIONS 保持一致) -const CLAUDE_MANAGED_TEMPLATE: &str = r#" +/// 从 MASTER_CONVENTIONS frontmatter 自动解析版本号,无需手动维护常量。 +fn master_conventions_version() -> &'static str { + static VERSION: std::sync::OnceLock = std::sync::OnceLock::new(); + VERSION.get_or_init(|| { + for line in MASTER_CONVENTIONS.lines() { + if let Some(v) = line.strip_prefix("version: ") { + return v.trim().to_string(); + } + } + "unknown".to_string() + }) +} + +/// CLAUDE.md 蓝图管理区模板,版本号从 CONVENTIONS frontmatter 自动同步。 +fn claude_managed_template() -> String { + let ver = master_conventions_version(); + format!(r#" ## 项目蓝图 本项目使用 `.blueprint/` 目录维护项目全景架构图,驱动需求讨论和任务管理。 @@ -30,7 +44,8 @@ const CLAUDE_MANAGED_TEMPLATE: &str = r#""#; +"#) +} // ── manifest.yaml 对应结构 ─────────────────────────────────────────────────── @@ -896,7 +911,7 @@ pub fn get_blueprint_status(project_path: String) -> Result Result Result Result // 2. 处理 CLAUDE.md let claude_path = root.join("CLAUDE.md"); + let managed_template = claude_managed_template(); let claude_action = if !claude_path.exists() { // 创建新文件 - let content = format!("# {}\n\n{CLAUDE_MANAGED_TEMPLATE}\n", + let content = format!("# {}\n\n{managed_template}\n", root.file_name().and_then(|n| n.to_str()).unwrap_or("Project")); std::fs::write(&claude_path, content) .map_err(|e| format!("创建 CLAUDE.md 失败: {e}"))?; @@ -978,13 +994,13 @@ pub fn sync_blueprint_rules(project_path: String) -> Result if content.contains("