feat: 支持 OpenClaw skill 格式 (SKILL.md + scripts/)

- scan_skills() 支持两种格式: .yaml 文件 和 目录/SKILL.md
- 解析 SKILL.md 的 YAML frontmatter 提取 name/description
- 自动扫描 scripts/ 子目录的 .py 脚本
- skill_exec 支持 asyncio 子进程执行脚本
- 新增示例 OpenClaw 技能: skills/time-tool/
This commit is contained in:
2026-04-23 23:53:45 +08:00
parent 1c42ba0812
commit 28da16829f
5 changed files with 215 additions and 7 deletions

View File

@@ -69,6 +69,10 @@ TOOLS = [get_stock_price] # 必须!供自动扫描
## 新增技能
支持两种格式:
### 格式1: .yaml 文件(简洁定义)
`skills/` 目录下创建 .yaml 文件:
```yaml
@@ -82,11 +86,41 @@ tools:
- get_stock_price
```
然后在 `config.yaml``skill_keywords` 中添加路由关键词:
### 格式2: OpenClaw 格式(目录 + SKILL.md + scripts/
`skills/` 目录下创建目录,放入 `SKILL.md``scripts/`
```
skills/
└── my-skill/
├── SKILL.md ← OpenClaw 标准格式
└── scripts/
└── do_something.py
```
SKILL.md 格式:
```markdown
---
name: my-skill
description: "我的自定义技能"
---
# 我的自定义技能
技能的详细说明和使用方法...
```
Agent 会自动扫描 SKILL.md 的 frontmatter 和 scripts/ 目录,执行脚本并将输出传给 LLM。
### 路由关键词
无论哪种格式,都需要在 `config.yaml``skill_keywords` 中添加路由:
```yaml
skill_keywords:
stock_analyst: ["股价", "股票", "行情"]
my-skill: ["关键词1", "关键词2"]
```
## 新增 MCP 服务器