save_user_conventions / reset_conventions_to_builtin 移除前端传路径的设计, 改为后端自行从 DB 查询所有项目路径(Windows 路径 + WSL UNC 路径), 确保 WSL 项目不再被漏同步;同步锁定蓝图数据:T4 关锁、blueprint-view frontmatter 修正
77 lines
4.7 KiB
Markdown
77 lines
4.7 KiB
Markdown
---
|
||
id: blueprint-governance
|
||
name: 蓝图治理
|
||
status: done
|
||
progress: 100
|
||
---
|
||
|
||
## 概述
|
||
将 dev-manager-tauri 的 `.blueprint/CONVENTIONS.md` 和 CLAUDE.md 蓝图区块作为唯一权威来源,向所有托管项目分发和同步规则,确保跨项目规则一致性。
|
||
|
||
## 决策记录
|
||
|
||
- CONVENTIONS.md 加 YAML frontmatter 版本号,应用以此判断是否需要同步
|
||
- CLAUDE.md 用 `<!-- BLUEPRINT_MANAGED_START -->` / `<!-- BLUEPRINT_MANAGED_END -->` 标记管理区,应用只替换标记内内容,不动项目自有内容
|
||
- 无 CLAUDE.md 时生成初始文件;有 CLAUDE.md 但无 MANAGED 区时追加到末尾
|
||
- MASTER_CONVENTIONS 通过 `include_str!()` 在编译时嵌入,保证 binary 自包含
|
||
- BlueprintStatus 四状态:none / rules_outdated / content_stale / synced
|
||
|
||
## 任务卡
|
||
|
||
### ✅ CONVENTIONS.md 版本化
|
||
- status: done
|
||
- complexity: S
|
||
- files: .blueprint/CONVENTIONS.md
|
||
- acceptance: frontmatter 加 version 和 updated 字段,格式为 semver(如 1.0.0)
|
||
|
||
### ✅ CLAUDE.md 模板定义
|
||
- status: done
|
||
- complexity: S
|
||
- files: src-tauri/src/commands/blueprint.rs
|
||
- acceptance: 在 Rust 中定义 CLAUDE.md MANAGED 区的标准内容模板,内容涵盖:蓝图飞轮流程、读取 manifest 指令、任务卡派发规则;模板版本与 CONVENTIONS.md 同步
|
||
|
||
### ✅ get_blueprint_status command
|
||
- status: done
|
||
- complexity: M
|
||
- files: src-tauri/src/commands/blueprint.rs, src-tauri/src/lib.rs, src/lib/commands.ts
|
||
- acceptance: 接收项目路径,返回四种状态之一:none / rules_outdated / content_stale / synced;判断依据:.blueprint/ 是否存在、CONVENTIONS.md 版本是否匹配 master、CLAUDE.md 是否有 MANAGED 区且版本匹配
|
||
|
||
### ✅ sync_blueprint_rules command
|
||
- status: done
|
||
- complexity: M
|
||
- files: src-tauri/src/commands/blueprint.rs, src-tauri/src/lib.rs, src/lib/commands.ts
|
||
- acceptance: 接收项目路径,执行三步:(1) 覆盖写入最新 CONVENTIONS.md;(2) 检测 CLAUDE.md 是否存在及 MANAGED 区状态,按三种情况(无文件/无区块/版本旧)分别处理;(3) 返回操作摘要
|
||
|
||
### ✅ 批量同步所有项目规则
|
||
- status: done
|
||
- complexity: S
|
||
- files: src/components/settings/SettingsPage.tsx
|
||
- acceptance: 设置页提供「同步所有项目蓝图规则」按钮,调用 sync_blueprint_rules 遍历所有已注册项目,返回每个项目的同步结果摘要
|
||
|
||
### ✅ 用户版 CONVENTIONS 存储层初始化
|
||
- status: done
|
||
- complexity: S
|
||
- files: src-tauri/src/commands/blueprint.rs, src-tauri/src/lib.rs
|
||
- acceptance: 新增 `USER_CONVENTIONS_DIR: OnceLock<PathBuf>` 和 `init_user_conventions_dir(app_data_dir)`,在 lib.rs setup() 中紧跟 db::init 调用;`effective_conventions_content() -> String` 优先读 app_data_dir/conventions/CONVENTIONS.md,文件不存在时 fallback 到编译时内置;`effective_conventions_version() -> String` 从 effective 内容解析 frontmatter version
|
||
|
||
### ✅ 用户版 CONVENTIONS 读写 command
|
||
- status: done
|
||
- complexity: M
|
||
- files: src-tauri/src/commands/blueprint.rs, src-tauri/src/lib.rs, src/lib/commands.ts
|
||
- depends: blueprint-governance
|
||
- acceptance: 新增三个 command:(1) `get_user_conventions_status` 返回 `{ source: "builtin"|"user", version, content, builtin_version, outdated_from_builtin }`;(2) `save_user_conventions(content)` 从 frontmatter 解析版本(失败时返回错误),写入用户版文件,清除 effective 内容缓存,自动触发遍历所有项目的 sync_blueprint_rules,返回 `{ version, synced_count }`;(3) `reset_conventions_to_builtin` 删除用户版文件并清除缓存;三个 command 注册到 invoke_handler,TS 封装完成
|
||
|
||
### ✅ sync/梦核/summary 切换为 effective 内容
|
||
- status: done
|
||
- complexity: S
|
||
- files: src-tauri/src/commands/blueprint.rs
|
||
- depends: blueprint-governance
|
||
- acceptance: `sync_blueprint_rules`、`generate_muhe_prompt`、`conventions_rules_summary`、`claude_managed_template` 全部改用 `effective_conventions_content()` 和 `effective_conventions_version()`,不再直接引用 MASTER_CONVENTIONS 常量;有用户版时分发用户版,无用户版时 fallback 内置版,行为与改前一致
|
||
|
||
### ✅ GovernancePanel 规则编辑器 UI
|
||
- status: done
|
||
- complexity: M
|
||
- files: src/components/dashboard/BlueprintModal.tsx, src/lib/commands.ts
|
||
- depends: blueprint-governance
|
||
- acceptance: GovernancePanel 新增规则来源 badge(「内置基线 vX.X.X」或「用户自定义 vX.X.X」);新增「应用梦核建议」区域:文本框用于粘贴新 CONVENTIONS 内容 + 确认按钮,确认后调用 save_user_conventions,成功显示「已同步 N 个项目」;有用户版时显示「重置为基线」按钮,调用 reset_conventions_to_builtin 后来源恢复为内置
|