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
+6 -10
View File
@@ -44,7 +44,7 @@ impl ApprovalManager {
user_id: &str,
skill_name: &str,
) -> Result<(String, oneshot::Receiver<ApprovalDecision>), String> {
let code: u32 = rand::thread_rng().gen_range(100000..999999);
let code: u32 = rand::rng().random_range(100000..999999);
let code_str = code.to_string();
let code_hash = format!("{:x}", Sha256::digest(code_str.as_bytes()));
@@ -92,7 +92,9 @@ impl ApprovalManager {
let (result, name, code_hash) = {
let mut map = self.pending.lock().await;
let entries = map.get_mut(user_id)?;
if entries.is_empty() { return None; }
if entries.is_empty() {
return None;
}
let reply_hash = format!("{:x}", Sha256::digest(reply.as_bytes()));
let reply_trimmed = reply.trim();
@@ -157,11 +159,11 @@ impl ApprovalManager {
}
if let Some(ref pool) = self.pool {
for (_uid, _i, _code_hash) in &expired {
for (_uid, _i, code_hash) in &expired {
let _ = sqlx::query(
"UPDATE pending_approvals SET status = 'expired' WHERE code_hash = $1 AND status = 'pending'",
)
.bind(_code_hash)
.bind(code_hash)
.execute(pool.as_ref())
.await;
}
@@ -178,10 +180,4 @@ impl ApprovalManager {
}
map.retain(|_, v| !v.is_empty());
}
/// 获取某个用户的待审批条数
pub async fn pending_count(&self, user_id: &str) -> usize {
let map = self.pending.lock().await;
map.get(user_id).map(|v| v.len()).unwrap_or(0)
}
}