refactor: 删除外置 skills 系统,全部工具转为内置

删除:
- resources/skills/ (9个外置 skill, bash/python/node 脚本)
- src/tools/registry.rs (SkillRegistry 加载/执行)
- src/tools/parser.rs (SKILL.md 解析)
- src/skills_importer.rs (skills 导入)
- cli.rs Skills 子命令
- main.rs cmd_skills / global_skills_dir

保留:
- src/tools/builtin.rs (内置工具注册 + 审批流程)
- src/tools/weather.rs (天气查询)
- src/tools/skill.rs (精简为 SkillSpec/RiskLevel/SkillResult/ExecutionContext)
- src/tools/approval.rs (审批管理器)

main.rs 简化: 移除 SkillRegistry 加载, executor 只走 BuiltinRegistry
This commit is contained in:
2026-06-03 10:28:28 +08:00
parent afc43ce692
commit 4d149982c5
29 changed files with 354 additions and 1651 deletions
+5 -28
View File
@@ -1,6 +1,6 @@
use crate::llm::types::{ConversationConfig, Message, StreamChunk};
use serde::Deserialize;
use async_trait::async_trait;
use serde::Deserialize;
use std::sync::Arc;
use tokio::sync::mpsc;
@@ -33,29 +33,6 @@ pub fn create_provider(_config: &ConversationConfig) -> Result<BoxedProvider, St
// ─── 内部:SSE 解析工具 ───
/// 从字节流中解析 SSE 行
pub(crate) fn parse_sse_line(line: &str) -> Option<(String, String)> {
// 支持两种格式:
// data: {...}
// event: ...
let line = line.trim();
if line.is_empty() || line.starts_with(':') {
return None;
}
if let Some(pos) = line.find(": ") {
let field = line[..pos].trim().to_string();
let value = line[pos + 2..].trim_start().to_string();
Some((field, value))
} else if let Some(pos) = line.find(':') {
let field = line[..pos].trim().to_string();
let value = line[pos + 1..].trim_start().to_string();
Some((field, value))
} else {
None
}
}
/// 流式块解析结果
pub(crate) enum ParsedChunk {
Text(String),
@@ -71,9 +48,7 @@ pub(crate) enum ParsedChunk {
}
/// 从 JSON body 中解析 DeepSeek/OpenAI 流式 delta
pub(crate) fn parse_chat_chunk(
line: &str,
) -> Option<ParsedChunk> {
pub(crate) fn parse_chat_chunk(line: &str) -> Option<ParsedChunk> {
if !line.starts_with("data: ") {
return None;
}
@@ -144,7 +119,9 @@ pub(crate) fn parse_chat_chunk(
if let Some(tool_calls) = &choice.delta.tool_calls {
for tc in tool_calls {
let idx = tc.index.unwrap_or(0);
let args = tc.function.as_ref()
let args = tc
.function
.as_ref()
.and_then(|f| f.arguments.clone())
.unwrap_or_default();
let name = tc.function.as_ref().and_then(|f| f.name.clone());