fix: YAML frontmatter 解析 + call_capability iPet 兼容桥接
- SKILL.md 解析器支持跳过 YAML frontmatter (---...---)
修复导入的 Claude Code / Agent Skills 的元数据头导致
description 混入元数据的问题
- call_capability 桥接工具:兼容 iPet 遗留的
{name, prompt} 调用格式
按 name 查找 SkillRegistry,委托执行
- 清理 parser 中未使用的 in_desc 变量
This commit is contained in:
+32
@@ -275,6 +275,23 @@ async fn cmd_listen(
|
||||
}
|
||||
}));
|
||||
|
||||
// call_capability 桥接:iPet 兼容,按 skill 名调用
|
||||
tools_list.push(serde_json::json!({
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "call_capability",
|
||||
"description": "按名称调用一个 skill(等同于直接使用该 skill 的工具名)。name 参数为 skill 的名称,prompt 为自然语言需求",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": { "type": "string", "description": "要调用的 skill 名称" },
|
||||
"prompt": { "type": "string", "description": "给该 skill 的自然语言需求" }
|
||||
},
|
||||
"required": ["name"]
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
cfg.tools = Some(tools_list);
|
||||
|
||||
// 创建 Conversation
|
||||
@@ -331,6 +348,7 @@ async fn cmd_listen(
|
||||
let args = args_json.to_string();
|
||||
|
||||
Box::pin(async move {
|
||||
let user_id = current_user.lock().await.clone();
|
||||
match n.as_str() {
|
||||
"read_memories" => return Ok(memory_store.read().await),
|
||||
"write_memory" => {
|
||||
@@ -343,6 +361,20 @@ async fn cmd_listen(
|
||||
return Ok(memory_store.write(content).await);
|
||||
}
|
||||
"read_summaries" => return Ok(context::tools::read_summaries(&session).await),
|
||||
"call_capability" => {
|
||||
let cap_params: serde_json::Value = serde_json::from_str(&args).unwrap_or_default();
|
||||
let cap_name = cap_params.get("name").and_then(|v| v.as_str()).map(|s| s.to_string());
|
||||
if let Some(name) = cap_name {
|
||||
if let Some(ref reg) = reg {
|
||||
let mut ctx = ExecutionContext::new(&user_id);
|
||||
if let Some(a) = approval { ctx = ctx.with_approval(a); }
|
||||
ctx = ctx.with_wechat(send);
|
||||
let result = reg.execute(&name, cap_params, &ctx).await;
|
||||
return Ok(result.output);
|
||||
}
|
||||
}
|
||||
return Ok("请提供 name 参数(要调用的 skill 名称)".to_string());
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
let user_id = current_user.lock().await.clone();
|
||||
|
||||
Reference in New Issue
Block a user