diff --git a/src-tauri/src/commands/ai/audit.rs b/src-tauri/src/commands/ai/audit.rs index f3a9315..138ea7d 100644 --- a/src-tauri/src/commands/ai/audit.rs +++ b/src-tauri/src/commands/ai/audit.rs @@ -44,7 +44,7 @@ pub(crate) fn risk_from_str(s: &str) -> Option { /// - delete_project/restore_project/purge_project → "删除/恢复/清除项目"+id /// - update_project → "修改项目"+field /// - bind_directory → "绑定目录"+path -/// - create_task → "创建任务"+title;create_project → "创建项目"+name;create_idea → "捕获想法"+title +/// - create_task → "创建任务"+title;create_project → "创建项目"+name;create_idea → "捕获灵感"+title /// - run_workflow → "运行工作流"+name /// args 无可读字段或工具未特化时,fallback 原 risk 模板(含风险等级提示)。 fn build_approval_reason(tool_name: &str, args: &serde_json::Value, risk_level: RiskLevel) -> String { @@ -80,7 +80,7 @@ fn build_approval_reason(tool_name: &str, args: &serde_json::Value, risk_level: } "create_idea" => { let title = s("title"); - if !title.is_empty() { format!("捕获想法:{}", title) } else { String::new() } + if !title.is_empty() { format!("捕获灵感:{}", title) } else { String::new() } } "run_workflow" => { let name = s("name"); diff --git a/src-tauri/src/commands/ai/prompt.rs b/src-tauri/src/commands/ai/prompt.rs index 1095ec6..13a9cbf 100644 --- a/src-tauri/src/commands/ai/prompt.rs +++ b/src-tauri/src/commands/ai/prompt.rs @@ -49,11 +49,11 @@ fn system_prompt_parts(lang: &str) -> (&'static str, &'static str) { "\n## Current Projects\n", ), _ => ( - "你是 DevFlow 的 AI 助手。你帮助用户管理项目、任务、想法和工作流。\n\ + "你是 DevFlow 的 AI 助手。你帮助用户管理项目、任务、灵感和工作流。\n\ 必须使用简体中文回复,禁止使用繁体中文字符。\n\n\ ## 当前能力\n\ 你可以通过工具调用执行以下操作:\n\ - - 创建/查询项目、任务、想法\n\ + - 创建/查询项目、任务、灵感\n\ - 运行工作流\n\ - 读取文件内容、列出目录、创建/写入文件\n\n\ ## 行为准则\n\ diff --git a/src-tauri/src/commands/ai/tool_registry.rs b/src-tauri/src/commands/ai/tool_registry.rs index 75b95db..c1f5c37 100644 --- a/src-tauri/src/commands/ai/tool_registry.rs +++ b/src-tauri/src/commands/ai/tool_registry.rs @@ -109,7 +109,7 @@ pub fn build_ai_tool_registry(db: &Arc) -> AiToolRegistry { })}, ); registry.register( - "list_ideas", "列出所有想法", + "list_ideas", "列出所有灵感", df_ai::ai_tools::object_schema(vec![]), RiskLevel::Low, { let db = db.clone(); Box::new(move |_args: serde_json::Value| { let db = db.clone(); @@ -265,7 +265,7 @@ pub fn build_ai_tool_registry(db: &Arc) -> AiToolRegistry { })}, ); registry.register( - "create_idea", "捕获一个新想法", + "create_idea", "捕获一个新灵感", df_ai::ai_tools::object_schema(vec![("title", "string", true), ("description", "string", false), ("tags", "string", false), ("source", "string", false)]), RiskLevel::Medium, { let db = db.clone(); Box::new(move |args: serde_json::Value| { diff --git a/src-tauri/src/commands/idea.rs b/src-tauri/src/commands/idea.rs index efa5305..9945518 100644 --- a/src-tauri/src/commands/idea.rs +++ b/src-tauri/src/commands/idea.rs @@ -1,4 +1,4 @@ -//! 想法相关命令 +//! 灵感相关命令 use serde::Deserialize; use tauri::State; @@ -11,7 +11,7 @@ use crate::state::AppState; use super::now_millis; -/// 创建想法入参 +/// 创建灵感入参 #[derive(Debug, Deserialize)] pub struct CreateIdeaInput { pub title: String, @@ -28,7 +28,7 @@ fn default_priority() -> i32 { 1 } -/// 列出想法,可选按 status 过滤(指定状态走 query 走白名单索引列,否则全量) +/// 列出灵感,可选按 status 过滤(指定状态走 query 走白名单索引列,否则全量) #[tauri::command] pub async fn list_ideas( state: State<'_, AppState>, @@ -40,7 +40,7 @@ pub async fn list_ideas( } } -/// 创建想法,返回完整记录 +/// 创建灵感,返回完整记录 #[tauri::command] pub async fn create_idea( state: State<'_, AppState>, @@ -70,7 +70,7 @@ pub async fn create_idea( Ok(record) } -/// 更新想法单个字段(字段名走 df-storage 白名单校验) +/// 更新灵感单个字段(字段名走 df-storage 白名单校验) #[tauri::command] pub async fn update_idea( state: State<'_, AppState>, @@ -85,13 +85,13 @@ pub async fn update_idea( .map_err(|e| e.to_string()) } -/// 删除想法 +/// 删除灵感 #[tauri::command] pub async fn delete_idea(state: State<'_, AppState>, id: String) -> Result { state.ideas.delete(&id).await.map_err(|e| e.to_string()) } -/// 将想法晋升为项目 — 复用 df-project 领域逻辑创建项目,回写想法 status=promoted/promoted_to +/// 将灵感晋升为项目 — 复用 df-project 领域逻辑创建项目,回写灵感 status=promoted/promoted_to #[tauri::command] pub async fn promote_idea( state: State<'_, AppState>, @@ -102,10 +102,10 @@ pub async fn promote_idea( .get_by_id(&id) .await .map_err(|e| e.to_string())? - .ok_or_else(|| format!("想法不存在: {id}"))?; + .ok_or_else(|| format!("灵感不存在: {id}"))?; if record.promoted_to.is_some() { - return Err(format!("想法已立项: {}", record.promoted_to.unwrap())); + return Err(format!("灵感已立项: {}", record.promoted_to.unwrap())); } // 复用 df-project 领域逻辑构造项目实体(create_from_idea) @@ -133,9 +133,9 @@ pub async fn promote_idea( .await .map_err(|e| e.to_string())?; - // 回写想法:status=promoted + promoted_to(update_full 单事务覆盖可变字段) + // 回写灵感:status=promoted + promoted_to(update_full 单事务覆盖可变字段) // 补偿删除:第二步失败时回滚第一步已建的 project,保证最终一致性(非原子,但防项目存留而 - // 想法状态未变的数据不一致)。Repository 方法各自持锁不支持跨 repo 共享事务对象,故选补偿 + // 灵感状态未变的数据不一致)。Repository 方法各自持锁不支持跨 repo 共享事务对象,故选补偿 // 删除而非真事务(改动最小,工程投入产出比最高)。 let updated = IdeaRecord { status: "promoted".to_string(), @@ -145,11 +145,11 @@ pub async fn promote_idea( }; if let Err(e) = state.ideas.update_full(&updated).await { // 回写失败:补偿删除已建项目,避免悬空项目(idea.promoted_to 仍空,可重试立项) - tracing::error!("想法 {id} 回写失败,补偿删除已建项目 {project_id}: {e}"); + tracing::error!("灵感 {id} 回写失败,补偿删除已建项目 {project_id}: {e}"); if let Err(del_err) = state.projects.purge_with_descendants(&project_id).await { tracing::error!("补偿删除项目 {project_id} 也失败(需人工清理): {del_err}"); } - return Err(format!("想法立项回写失败(已回滚项目创建): {}", e)); + return Err(format!("灵感立项回写失败(已回滚项目创建): {}", e)); } Ok(df_ideas::promotion::PromotionResult { @@ -161,22 +161,22 @@ pub async fn promote_idea( } // ============================================================ -// 想法评估 — 多维评分 + 对抗式评估 +// 灵感评估 — 多维评分 + 对抗式评估 // ============================================================ -/// 评估想法:多维评分 + 对抗式评估,结果写回 scores/score/ai_analysis,状态置 pending_review,返回更新后的记录 +/// 评估灵感:多维评分 + 对抗式评估,结果写回 scores/score/ai_analysis,状态置 pending_review,返回更新后的记录 #[tauri::command] pub async fn evaluate_idea( state: State<'_, AppState>, id: String, ) -> Result { - // 取出想法 + // 取出灵感 let record = state .ideas .get_by_id(&id) .await .map_err(|e| e.to_string())? - .ok_or_else(|| format!("想法不存在: {id}"))?; + .ok_or_else(|| format!("灵感不存在: {id}"))?; let idea = record_to_idea(&record); diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index c6b6a78..1e03430 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -46,7 +46,7 @@ pub fn run() { commands::task::create_task, commands::task::update_task, commands::task::delete_task, - // 想法 + // 灵感 commands::idea::list_ideas, commands::idea::create_idea, commands::idea::update_idea, diff --git a/src-tauri/src/state.rs b/src-tauri/src/state.rs index 6ff6dc5..36cefa6 100644 --- a/src-tauri/src/state.rs +++ b/src-tauri/src/state.rs @@ -135,7 +135,7 @@ impl LlmConcurrency { pub struct AppState { /// 数据库句柄(Arc 包装,便于在异步任务中重建 Repo) pub db: Arc, - /// 想法表 Repo + /// 灵感表 Repo pub ideas: IdeaRepo, /// 项目表 Repo pub projects: ProjectRepo, diff --git a/src/api/idea.ts b/src/api/idea.ts index de0e021..0e50c28 100644 --- a/src/api/idea.ts +++ b/src/api/idea.ts @@ -2,7 +2,7 @@ import { invoke } from '@tauri-apps/api/core' import type { IdeaRecord, CreateIdeaInput, PromotionResult } from './types' export const ideaApi = { - /** 列出想法,可选按 status 过滤(draft/pending_review/promoted 等) */ + /** 列出灵感,可选按 status 过滤(draft/pending_review/promoted 等) */ list(status?: string): Promise { return invoke('list_ideas', { status: status ?? null }) }, @@ -24,7 +24,7 @@ export const ideaApi = { return invoke('evaluate_idea', { id }) }, - /** 将想法晋升为项目,返回晋升结果(含 project_id) */ + /** 将灵感晋升为项目,返回晋升结果(含 project_id) */ promote(id: string): Promise { return invoke('promote_idea', { id }) }, diff --git a/src/api/types.ts b/src/api/types.ts index 5707c5c..a6be189 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -1,7 +1,7 @@ //! TypeScript 类型定义 — 与 Rust Record 结构体严格对齐 // ============================================================ -// 想法 +// 灵感 // ============================================================ export interface IdeaRecord { @@ -68,7 +68,7 @@ export interface AiScanResult { raw: string | null } -/** 想法晋升结果(后端 promote_idea 返回) */ +/** 灵感晋升结果(后端 promote_idea 返回) */ export interface PromotionResult { idea_id: string project_id: string diff --git a/src/i18n/zh-CN/aiTool.ts b/src/i18n/zh-CN/aiTool.ts index fe51fb0..9d34a91 100644 --- a/src/i18n/zh-CN/aiTool.ts +++ b/src/i18n/zh-CN/aiTool.ts @@ -21,7 +21,7 @@ export default { // completed 结果摘要(header 折叠态可见) taskCount: '{n} 项任务', projectCount: '{n} 个项目', - ideaCount: '{n} 条想法', + ideaCount: '{n} 条灵感', createdWithName: '已创建:{name}', created: '已创建', updatedField: '已更新 {field}', diff --git a/src/i18n/zh-CN/ideas.ts b/src/i18n/zh-CN/ideas.ts index f61b36f..8dceedd 100644 --- a/src/i18n/zh-CN/ideas.ts +++ b/src/i18n/zh-CN/ideas.ts @@ -15,7 +15,7 @@ export default { }, // 空状态 - emptyState: '选择一个想法查看详情', + emptyState: '选择一个灵感查看详情', // 对抗式评估 adversarialTitle: '⚖️ 对抗式评估', @@ -39,7 +39,7 @@ export default { 'with resources': '📦 配置资源后行动', 'research more': '🔍 需要更多研究', monitor: '👁️ 持续监控', - cancel: '❌ 取消想法', + cancel: '❌ 取消灵感', }, // 多维评分 @@ -62,17 +62,17 @@ export default { // 操作按钮 promoteToProject: '🚀 立项为项目', - deleteIdea: '🗑️ 删除想法', + deleteIdea: '🗑️ 删除灵感', // 捕捉模态框 - captureTitle: '✨ 捕捉新想法', + captureTitle: '✨ 捕捉新灵感', fieldTitle: '标题', fieldDesc: '描述', - titlePlaceholder: '一句话描述你的想法...', + titlePlaceholder: '一句话描述你的灵感...', descPlaceholder: '详细说明(可选)...', // 原生对话框文案(confirm / alert) - confirmDelete: '确定删除想法「{title}」?此操作不可撤销。', + confirmDelete: '确定删除灵感「{title}」?此操作不可撤销。', promoteFailed: '立项失败', evalFailed: '评估失败', }, diff --git a/src/i18n/zh-CN/projectDetail.ts b/src/i18n/zh-CN/projectDetail.ts index 2ee8537..1ae5e92 100644 --- a/src/i18n/zh-CN/projectDetail.ts +++ b/src/i18n/zh-CN/projectDetail.ts @@ -6,7 +6,7 @@ export default { delete: '🗑 删除', newTask: '+ 新任务', // 阶段 pipeline - stageIdea: '💡 想法', + stageIdea: '💡 灵感', stageRequirement: '📋 需求', stageCoding: '💻 编码', stageTesting: '🧪 测试', @@ -21,9 +21,9 @@ export default { confirmCreate: '确认创建', // 项目信息面板 infoTitle: '📋 项目信息', - sourceIdea: '来源想法', - viewIdea: '查看想法详情', - ideaDeleted: '原始想法已删除', + sourceIdea: '来源灵感', + viewIdea: '查看灵感详情', + ideaDeleted: '原始灵感已删除', createdAt: '创建时间', updatedAt: '更新时间', description: '描述', diff --git a/src/stores/project.ts b/src/stores/project.ts index 3d5da4e..a52df9e 100644 --- a/src/stores/project.ts +++ b/src/stores/project.ts @@ -142,12 +142,12 @@ function createStore() { } } - // ── 想法 CRUD ── + // ── 灵感 CRUD ── async function loadIdeas() { try { state.ideas = await ideaApi.list() } catch (e: any) { - state.error = e?.toString() ?? '加载想法失败' + state.error = e?.toString() ?? '加载灵感失败' } } @@ -157,7 +157,7 @@ function createStore() { state.ideas.push(record) return record } catch (e: any) { - state.error = e?.toString() ?? '创建想法失败' + state.error = e?.toString() ?? '创建灵感失败' return null } } @@ -175,7 +175,7 @@ function createStore() { await ideaApi.delete(id) state.ideas = state.ideas.filter(i => i.id !== id) } catch (e: any) { - state.error = e?.toString() ?? '删除想法失败' + state.error = e?.toString() ?? '删除灵感失败' } } @@ -309,7 +309,7 @@ function createStore() { type ProjectStore = ReturnType let _storeInstance: ProjectStore | null = null -/** 项目/任务/想法/工作流 全局状态(单例,多组件复用同一 reactive 包装) */ +/** 项目/任务/灵感/工作流 全局状态(单例,多组件复用同一 reactive 包装) */ export function useProjectStore(): ProjectStore { if (_storeInstance) return _storeInstance _storeInstance = createStore() diff --git a/src/views/Ideas.vue b/src/views/Ideas.vue index 1543f8a..d47a6c8 100644 --- a/src/views/Ideas.vue +++ b/src/views/Ideas.vue @@ -30,7 +30,7 @@
- +
- +

{{ currentIdea.title }}

@@ -179,7 +179,7 @@
- + - + @@ -234,7 +234,7 @@ const activeFilter = ref('all') const selectedId = ref(null) const searchQuery = ref('') -// ── 新建想法模态框 ── +// ── 新建灵感模态框 ── const showCaptureModal = ref(false) const newIdeaTitle = ref('') const newIdeaDesc = ref('')