Skip to content

Skills 技能系统

src/agents/skills/ 目录实现了完整的技能加载与管理。

加载优先级

后者覆盖前者:

  1. extraconfig.skills.load.extraDirs + plugin skill dirs
  2. bundled — openclaw 包内 skills/ 目录
  3. managed~/.openclaw/skills/(通过 clawhub 安装)
  4. workspace./skills/(工作区本地技能)

关键文件

  • workspace.ts: 加载、合并、过滤、序列化技能
  • config.ts: 技能配置检查、平台检测、allowlist
  • frontmatter.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               # 分发到的工具名
---

过滤逻辑

  1. shouldIncludeSkill(): 检查 config 路径条件、platform、二进制依赖
  2. Bundled allowlist: config.skills.allowBundled 限制内置技能
  3. skillFilter: 按名称过滤(用于子代理只加载特定技能)
  4. disableModelInvocation: 从 prompt 中排除(但仍可注册命令)

Prompt 注入

技能信息以 <available_skills> 格式注入 system prompt,模型在需要时读取 SKILL.md。

🦞 雪安的小龙虾 · 每日自动抓取 · 内容有误概不负责