优化: P0 shell stdout修复+灵感路由+3工具新增+ai-md全局CSS+import路径统一
P0 修复:
- B-260615-37: shell.rs 补 Stdio::piped() 修复 run_command stdout/stderr 恒空
(tokio 默认 inherit 导致 wait_with_output 读不到 pipe)
P1 功能:
- B-260615-36: 路由加 /ideas/:id + Ideas.vue 接 route.params.id + watch
(修复项目详情点「来源灵感」跳空白页)
- F-260615-08: 新增 file_info 工具(元信息: exists/size/lines/binary/dir)
- F-260615-09: 新增 append_file 工具(追加写入, RiskLevel::Medium)
- F-260615-12: 新增 search_files 工具(文件名 glob 搜索,递归,限50条)
+ search_files_recursive 辅助函数 + i18n zh/en 3工具×2命名空间
DRY/重构:
- CR-260615-09: .ai-md 样式5份→全局 src/styles/ai-md.css(75行)
AiChat.vue 删71行重复 + main.ts 引入 + typo修正(.a-md→.ai-md)
- 全量 import 路径统一为 @/ 别名(stores/composables/views ~28文件)
vite.config.ts 加 resolve.alias.{ '@': '/src' }
- i18n 批量改进: store error fallback 11处中文→t() / ToolCard ARG_LABEL
/ useAiSend queue文案 / Dashboard 空态 / Ideas.vue null守卫
- cargo check 0 error / vue-tsc 0 error
This commit is contained in:
@@ -31,6 +31,26 @@ pub(crate) async fn get_active_provider(state: &AppState) -> Result<AiProviderRe
|
||||
}
|
||||
}
|
||||
|
||||
/// 当前运行环境信息(注入 system prompt,供 LLM 写日期/命令时参考)
|
||||
///
|
||||
/// - 日期:LLM 无法自行获取当前日期,不注入则写文件日期全靠猜(常从项目已有文件名模式推断出错)
|
||||
/// - 操作系统:LLM 写 shell 命令需知道平台(dir vs ls、路径分隔符等)
|
||||
///
|
||||
/// 两项合计约 25 token,消除一整类系统性错误。
|
||||
fn env_info_line() -> String {
|
||||
let today = chrono::Local::now().format("%Y-%m-%d");
|
||||
let os = if cfg!(target_os = "windows") {
|
||||
"Windows"
|
||||
} else if cfg!(target_os = "macos") {
|
||||
"macOS"
|
||||
} else if cfg!(target_os = "linux") {
|
||||
"Linux"
|
||||
} else {
|
||||
"Unknown"
|
||||
};
|
||||
format!("当前日期: {today} | 运行环境: {os}\n\n")
|
||||
}
|
||||
|
||||
/// 按语言返回系统提示词的 (固定前缀, 项目上下文标题)
|
||||
fn system_prompt_parts(lang: &str) -> (&'static str, &'static str) {
|
||||
match lang {
|
||||
@@ -67,10 +87,11 @@ fn system_prompt_parts(lang: &str) -> (&'static str, &'static str) {
|
||||
}
|
||||
}
|
||||
|
||||
/// 构建系统提示词(固定前缀 + 当前项目上下文)
|
||||
/// 构建系统提示词(环境信息 + 固定前缀 + 当前项目上下文)
|
||||
pub(crate) async fn build_system_prompt(state: &AppState, lang: &str) -> String {
|
||||
let (prefix, ctx_label) = system_prompt_parts(lang);
|
||||
let mut prompt = String::from(prefix);
|
||||
let mut prompt = env_info_line();
|
||||
prompt.push_str(prefix);
|
||||
|
||||
// 附加当前数据上下文
|
||||
if let Ok(projects) = state.projects.list_active().await {
|
||||
|
||||
Reference in New Issue
Block a user