import { useState, useEffect, useRef } from "react"; import { generateBlueprintPrompt, syncBlueprintRules, type BlueprintStatus, type SyncResult } from "../../lib/commands"; interface Props { projectName: string; projectPath: string; bpStatus: BlueprintStatus["status"]; onClose: () => void; onSynced?: () => void; // 同步完成后通知父组件刷新状态 } // ── 规则同步确认模式(rules_outdated)──────────────────────────────────────── function SyncConfirmView({ projectName, projectPath, onClose, onSynced, }: { projectName: string; projectPath: string; onClose: () => void; onSynced?: () => void; }) { const [syncing, setSyncing] = useState(false); const [result, setResult] = useState(null); const [error, setError] = useState(null); const handleSync = async () => { setSyncing(true); setError(null); try { const res = await syncBlueprintRules(projectPath); setResult(res); onSynced?.(); } catch (e) { setError(String(e)); } finally { setSyncing(false); } }; return ( <> {/* 头部 */}

规则版本待更新

{projectName}

{/* 说明 */}

将执行以下操作:

  • 覆盖写入 .blueprint/CONVENTIONS.md(升级至最新版本)
  • 更新 CLAUDE.md 中的蓝图规则区块

不会影响项目的其他文件和蓝图内容。

{result && (

✓ 同步完成

{result.message}

)} {error && (
{error}
)}
{/* 底部操作 */}
{!result && ( )}
); } // ── 提示词生成模式(none / content_stale)──────────────────────────────────── function PromptView({ projectName, projectPath, bpStatus, onClose, }: { projectName: string; projectPath: string; bpStatus: "none" | "content_stale"; onClose: () => void; }) { const [prompt, setPrompt] = useState(""); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const [copied, setCopied] = useState(false); const textareaRef = useRef(null); const promptType = bpStatus === "none" ? "init" : "sync"; const title = bpStatus === "none" ? "初始化蓝图" : "同步蓝图描绘"; const hint = bpStatus === "none" ? "将以下提示词复制后粘贴给 Claude Opus,让它为项目创建蓝图" : "将以下提示词复制后粘贴给 Claude Opus,让它更新项目蓝图"; useEffect(() => { setLoading(true); setError(null); generateBlueprintPrompt(projectPath, promptType) .then(setPrompt) .catch((e) => setError(String(e))) .finally(() => setLoading(false)); }, [projectPath, promptType]); const handleCopy = () => { navigator.clipboard.writeText(prompt).then(() => { setCopied(true); setTimeout(() => setCopied(false), 2000); }); }; return ( <> {/* 头部 */}

{title}

{projectName}

{/* 说明 */}

🤖 {hint},由 Claude 负责理解和创作蓝图内容。

{/* 提示词区域 */}
{loading ? (
生成提示词中…
) : error ? (

{error}

) : (