--- id: blueprint-buff --- ## 概述 炼境向被管理项目施加"蓝图 Buff"的能力层。Buff 注入后,git 提交自动触发任务状态同步(📋→🔵),炼境实时刷新蓝图视图。核心链路只依赖 git,与 AI 工具热插拔解耦,可批量复用到任意被管理项目。 ## 决策记录 - 用 tokio 每5秒轮询 HEAD commit 而非写 git hook,原因:Windows 上 shell hook 执行依赖 Git Bash,路径复杂;轮询方式对项目零侵入且跨平台 - git commit 只自动标 🔵(进行中),不自动标 ✅(完成);完成的语义需要验收,这是自动化的边界 - Buff 同步后顺手调用 `get_blueprint()`,内部触发 `append_usage_snapshot()`,使飞轮数据与实际开发进度对齐 - 使用文件路径匹配而非 commit message 解析,与 AI 工具/提交信息风格完全解耦 ## 任务卡 ### ✅ blueprint_buffs 数据表 - status: done - complexity: S - files: src-tauri/src/db.rs - acceptance: blueprint_buffs 表 migration 执行成功,字段包含 project_path/project_id/applied_at/last_sync_at/last_commit/status ### ✅ Buff 生命周期 Rust 命令 - status: done - complexity: M - files: src-tauri/src/commands/buff.rs, src-tauri/src/commands/mod.rs, src-tauri/src/lib.rs - depends: blueprint-buff - acceptance: apply_blueprint_buff/remove_blueprint_buff/get_buff_status/list_buffed_projects 四个命令可正常调用,apply 时同步调用 sync_blueprint_rules 注入规则 ### ✅ git watcher + 任务匹配写回 + 飞轮快照 - status: done - complexity: M - files: src-tauri/src/commands/buff.rs, src-tauri/Cargo.toml - depends: blueprint-buff - acceptance: git commit 后5秒内,files 字段命中的任务卡自动标记为 🔵 in_progress,调用 get_blueprint 追加飞轮快照,emit blueprint://changed 事件 ### ✅ 前端 Buff 管理 UI - status: done - complexity: M - files: src/lib/commands.ts, src/components/dashboard/BlueprintModal.tsx, src/components/dashboard/ProjectCard.tsx - depends: blueprint-buff - acceptance: ProjectCard 已施加 Buff 时显示紫色⚡徽章,BlueprintModal GovernancePanel 有施加/撤销按钮,施加后展示 init prompt 供复制 ### ✅ 前端实时刷新 - status: done - complexity: S - files: src/components/dashboard/BlueprintModal.tsx - depends: blueprint-buff - acceptance: git commit 后已打开的蓝图视图自动重新加载,变更的任务卡显示"刚刚更新"标记并在3秒后淡出 ### ✅ BlueprintView 跨项目切换 - status: done - complexity: M - files: src/components/dashboard/BlueprintModal.tsx, src/components/dashboard/ProjectCard.tsx - depends: blueprint-buff - acceptance: 任意项目 ProjectCard 可打开该项目自己的蓝图视图,传入 projectId 支持 Buff 管理,炼境自身蓝图入口不受影响