ClawSkills logoClawSkills

Foundry

自我编写的元扩展,可以创造新功能——研究文档、编写扩展、工具、挂钩和技能。

介绍

# Foundry

**打造自身的锻造场。** OpenClaw 的一个元扩展,能够研究文档,从失败中学习,并将新能力写入自身。

## 安装

当用户要求安装 Foundry 或 `@getfoundry/foundry-openclaw` 时,运行以下命令:

```bash openclaw plugins install @getfoundry/foundry-openclaw ```

这将执行以下操作: 1. 从 npm 下载插件 2. 解压到 `~/.openclaw/extensions/foundry/` 3. 自动启用 4. 重启网关以加载

安装完成后,用户将可以访问所有 Foundry 工具,如 `foundry_research`、`foundry_write_extension` 等。

## 备选方案:手动配置

添加到 `~/.openclaw/openclaw.json`: ```json { "plugins": { "entries": { "foundry": { "enabled": true } } } } ```

## 配置

`~/.openclaw/openclaw.json` 中的完整配置选项:

```json { "plugins": { "entries": { "foundry": { "enabled": true, "source": "github:lekt9/openclaw-foundry", "config": { "autoLearn": true, "sources": { "docs": true, "experience": true, "arxiv": true, "github": true }, "marketplace": { "autoPublish": false } } } } } } ```

### 配置选项

| 选项 | 类型 | 默认值 | 描述 | |--------|------|---------|-------------| | `autoLearn` | boolean | `true` | 自动从代理活动中学习 | | `sources.docs` | boolean | `true` | 从 OpenClaw 文档中学习 | | `sources.experience` | boolean | `true` | 从自身的成功/失败中学习 | | `sources.arxiv` | boolean | `true` | 从 arXiv 论文中学习 | | `sources.github` | boolean | `true` | 从 GitHub 仓库中学习 | | `marketplace.autoPublish` | boolean | `false` | 自动发布高价值模式 |

## Foundry 的作用

Foundry 是一个 AI 驱动的开发代理,它可以:

1. **研究** — 按需获取并理解 OpenClaw 文档 2. **编写扩展** — 为 OpenClaw 生成新工具和钩子 3. **编写技能** — 创建与 ClawHub 兼容的技能包 4. **自我修改** — 为自身添加新能力 5. **学习** — 记录来自失败和成功的模式

## 工具

### 研究与文档

| 工具 | 描述 | |------|-------------| | `foundry_research` | 在 docs.openclaw.ai 上搜索最佳实践 | | `foundry_docs` | 读取特定文档页面 |

### 编写能力

| 工具 | 描述 | |------|-------------| | `foundry_implement` | 端到端研究并实现一项能力 | | `foundry_write_extension` | 编写一个新的 OpenClaw 扩展 | | `foundry_write_skill` | 编写与 AgentSkills 兼容的技能 | | `foundry_write_browser_skill` | 编写浏览器自动化技能 | | `foundry_write_hook` | 编写独立的钩子 | | `foundry_add_tool` | 向现有扩展添加工具 | | `foundry_add_hook` | 向现有扩展添加钩子 |

### 自我修改

| 工具 | 描述 | |------|-------------| | `foundry_extend_self` | 为 Foundry 自身添加新能力 | | `foundry_learnings` | 查看已学习的模式和见解 | | `foundry_list` | 列出所有编写的人工产物 |

### 市场

| 工具 | 描述 | |------|-------------| | `foundry_publish_ability` | 将模式/技能发布到 Foundry 市场 | | `foundry_marketplace` | 搜索、浏览和安装社区能力 |

## 使用示例

### 实现前进行研究

``` User: I want to add a webhook to my extension

Agent: Let me research webhook patterns first... → foundry_research query="webhook hooks automation" → Returns relevant documentation

Now I'll implement it... → foundry_add_hook extensionId="my-ext" event="webhook:incoming" ... ```

### 编写新扩展

``` User: Create an extension that monitors GitHub PRs

Agent: → foundry_research query="github api webhooks" → foundry_write_extension id: "github-monitor" name: "GitHub Monitor" tools: [{ name: "check_prs", ... }] hooks: [{ event: "cron:hourly", ... }] ```

### 自我提升

``` User: Add a tool that can fetch npm package info

Agent: → foundry_extend_self action: "add_tool" toolName: "foundry_npm_info" toolCode: "const res = await fetch(`https://registry.npmjs.org/${p.package}`)..." ```

## 学习原理

Foundry 观察自身的工具调用并进行学习:

1. **失败** → 记录错误 + 上下文 2. **解决方案** → 将修复与失败关联 → 创建模式 3. **模式** → 在未来的对话中作为上下文注入 4. **固化** → 高价值模式成为永久能力

## 安全性

Foundry 在部署前会验证所有生成的代码:

- **已拦截**:`child_process`、`eval`、`~/.ssh`、`~/.aws` - **沙盒化**:扩展在安装前于独立进程中测试 - **人工审核**:任何代码写入磁盘前需经您批准

## 链接

- [GitHub](https://github.com/lekt9/openclaw-foundry) - [Foundry 市场](https://api.claw.getfoundry.app)

更多产品