Skills 技能系统
src/agents/skills/ 目录实现了完整的技能加载与管理。
加载优先级
后者覆盖前者:
- extra —
config.skills.load.extraDirs+ plugin skill dirs - bundled — openclaw 包内
skills/目录 - managed —
~/.openclaw/skills/(通过 clawhub 安装) - workspace —
./skills/(工作区本地技能)
关键文件
workspace.ts: 加载、合并、过滤、序列化技能config.ts: 技能配置检查、平台检测、allowlistfrontmatter.ts: SKILL.md frontmatter 解析(invocation policy, metadata)bundled-dir.ts: bundled 技能目录解析plugin-skills.ts: 从插件中发现技能目录refresh.ts: 技能变更监听
Frontmatter 元数据
yaml
---
name: skill-name
description: ...
primaryEnv: node|python|...
disableModelInvocation: true|false # 是否出现在 prompt 中
userInvocable: true|false # 是否可通过 /command 调用
command-dispatch: tool # 命令分发方式
command-tool: tool_name # 分发到的工具名
---过滤逻辑
shouldIncludeSkill(): 检查 config 路径条件、platform、二进制依赖- Bundled allowlist:
config.skills.allowBundled限制内置技能 skillFilter: 按名称过滤(用于子代理只加载特定技能)disableModelInvocation: 从 prompt 中排除(但仍可注册命令)
Prompt 注入
技能信息以 <available_skills> 格式注入 system prompt,模型在需要时读取 SKILL.md。