fix: 修复 P2 三处 Bug
1. get_blueprint_status 对比 effective_conventions_version() 而非 master_conventions_version(),避免用户版 CONVENTIONS 生效后治理面板 永远显示「待更新」 2. sync_blueprint_rules 成功消息改用 effective_conventions_version() 3. parse_frontmatter_version_str 修正 break 条件,正确限定在 frontmatter 范围内解析,防止文档正文中的 version: 行被误匹配
This commit is contained in:
parent
7a81222686
commit
f1cecd1601
@ -72,12 +72,14 @@ pub(crate) fn effective_conventions_version() -> String {
|
|||||||
|
|
||||||
/// 从字符串内容解析 frontmatter version 字段。
|
/// 从字符串内容解析 frontmatter version 字段。
|
||||||
fn parse_frontmatter_version_str(content: &str) -> Option<String> {
|
fn parse_frontmatter_version_str(content: &str) -> Option<String> {
|
||||||
for line in content.lines() {
|
let mut lines = content.lines();
|
||||||
|
// 必须以 --- 开头才进入 frontmatter 模式
|
||||||
|
if lines.next()?.trim() != "---" { return None; }
|
||||||
|
for line in lines {
|
||||||
|
if line.trim() == "---" { break; } // 遇到关闭 --- 停止
|
||||||
if let Some(v) = line.strip_prefix("version: ") {
|
if let Some(v) = line.strip_prefix("version: ") {
|
||||||
return Some(v.trim().to_string());
|
return Some(v.trim().to_string());
|
||||||
}
|
}
|
||||||
// frontmatter 结束标志(第二个 ---)
|
|
||||||
if line == "---" && !content.starts_with("---\n") { break; }
|
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
@ -1001,10 +1003,11 @@ pub fn get_blueprint_status(project_path: String) -> Result<BlueprintStatus, Str
|
|||||||
// 读取 manifest updated 日期
|
// 读取 manifest updated 日期
|
||||||
let manifest_updated = read_manifest_updated(&bp_dir.join("manifest.yaml"));
|
let manifest_updated = read_manifest_updated(&bp_dir.join("manifest.yaml"));
|
||||||
|
|
||||||
// 判断状态
|
// 判断状态:对比当前生效版本(用户版优先,fallback 内置)
|
||||||
let rules_current = conventions_version.as_deref() == Some(master_conventions_version())
|
let effective_ver = effective_conventions_version();
|
||||||
|
let rules_current = conventions_version.as_deref() == Some(effective_ver.as_str())
|
||||||
&& claude_md_managed
|
&& claude_md_managed
|
||||||
&& claude_md_version.as_deref() == Some(master_conventions_version());
|
&& claude_md_version.as_deref() == Some(effective_ver.as_str());
|
||||||
|
|
||||||
let status = if !rules_current {
|
let status = if !rules_current {
|
||||||
"rules_outdated".to_string()
|
"rules_outdated".to_string()
|
||||||
@ -1020,7 +1023,7 @@ pub fn get_blueprint_status(project_path: String) -> Result<BlueprintStatus, Str
|
|||||||
claude_md_managed,
|
claude_md_managed,
|
||||||
claude_md_version,
|
claude_md_version,
|
||||||
manifest_updated,
|
manifest_updated,
|
||||||
master_version: master_conventions_version().to_string(),
|
master_version: effective_ver,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1078,7 +1081,7 @@ pub fn sync_blueprint_rules(project_path: String) -> Result<SyncResult, String>
|
|||||||
success: true,
|
success: true,
|
||||||
conventions_written: true,
|
conventions_written: true,
|
||||||
claude_md_action: claude_action.clone(),
|
claude_md_action: claude_action.clone(),
|
||||||
message: format!("CONVENTIONS.md 已同步至 v{},CLAUDE.md {claude_action}", master_conventions_version()),
|
message: format!("CONVENTIONS.md 已同步至 v{},CLAUDE.md {claude_action}", effective_conventions_version()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user