@elizaos/plugin-agent-skills 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,372 @@
1
+ # Agent Skills Plugin for elizaOS
2
+
3
+ Implements the [Agent Skills specification](https://agentskills.io) with support for:
4
+ - Spec-compliant SKILL.md parsing and validation
5
+ - Progressive disclosure (metadata → instructions → resources)
6
+ - ClawHub registry integration for skill discovery
7
+ - Otto metadata compatibility for dependency management
8
+ - **Dual storage modes**: Memory (browser/virtual FS) and Filesystem (Node.js/native)
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install @elizaos/plugin-agent-skills
14
+ ```
15
+
16
+ ## Quick Start
17
+
18
+ ```typescript
19
+ import { agentSkillsPlugin } from '@elizaos/plugin-agent-skills';
20
+
21
+ // Add to your agent's plugins
22
+ const agent = createAgent({
23
+ plugins: [agentSkillsPlugin],
24
+ // ...
25
+ });
26
+ ```
27
+
28
+ ## Configuration
29
+
30
+ | Setting | Description | Default |
31
+ |---------|-------------|---------|
32
+ | `SKILLS_DIR` | Directory to load/install skills | `./skills` |
33
+ | `SKILLS_AUTO_LOAD` | Load installed skills on startup | `true` |
34
+ | `SKILLS_REGISTRY` | Skill registry URL | `https://clawhub.ai` |
35
+ | `SKILLS_STORAGE_TYPE` | Storage mode: `memory`, `filesystem`, or `auto` | `auto` |
36
+
37
+ ## Storage Modes
38
+
39
+ The plugin supports two storage backends for maximum flexibility:
40
+
41
+ ### Memory Storage (Browser/Virtual FS)
42
+
43
+ Skills are stored entirely in memory. Use this for:
44
+ - Browser environments without filesystem access
45
+ - Virtual FS scenarios (sandboxed environments)
46
+ - Ephemeral skill loading
47
+ - Testing
48
+
49
+ ```typescript
50
+ import { AgentSkillsService, MemorySkillStore } from '@elizaos/plugin-agent-skills';
51
+
52
+ // Create with explicit memory storage
53
+ const service = await AgentSkillsService.start(runtime, {
54
+ storageType: 'memory',
55
+ });
56
+
57
+ // Or use the store directly
58
+ const store = new MemorySkillStore('/virtual/skills');
59
+ await store.initialize();
60
+
61
+ // Load skills from content (no filesystem required)
62
+ await store.loadFromContent('my-skill', skillMdContent, additionalFiles);
63
+
64
+ // Load skills from downloaded zip
65
+ await store.loadFromZip('github', zipBuffer);
66
+ ```
67
+
68
+ ### Filesystem Storage (Node.js/Native)
69
+
70
+ Skills are stored on disk. Use this for:
71
+ - Node.js server environments
72
+ - CLI tools
73
+ - Persistent skill installations
74
+
75
+ ```typescript
76
+ import { AgentSkillsService, FileSystemSkillStore } from '@elizaos/plugin-agent-skills';
77
+
78
+ // Create with explicit filesystem storage
79
+ const service = await AgentSkillsService.start(runtime, {
80
+ storageType: 'filesystem',
81
+ skillsDir: './my-skills',
82
+ });
83
+
84
+ // Or use the store directly
85
+ const store = new FileSystemSkillStore('./skills');
86
+ await store.initialize();
87
+ ```
88
+
89
+ ### Auto Detection
90
+
91
+ By default (`storageType: 'auto'`), the plugin detects the environment:
92
+ - Browser environments → Memory storage
93
+ - Node.js environments → Filesystem storage
94
+
95
+ ```typescript
96
+ import { createStorage } from '@elizaos/plugin-agent-skills';
97
+
98
+ // Auto-detect based on environment
99
+ const storage = createStorage({ type: 'auto', basePath: './skills' });
100
+ ```
101
+
102
+ ### Transferring Skills Between Stores
103
+
104
+ Skills can be transferred between storage backends:
105
+
106
+ ```typescript
107
+ import { MemorySkillStore, FileSystemSkillStore, loadSkillFromStorage } from '@elizaos/plugin-agent-skills';
108
+
109
+ // Load from filesystem
110
+ const fsStore = new FileSystemSkillStore('./skills');
111
+ await fsStore.initialize();
112
+ const content = await fsStore.loadSkillContent('my-skill');
113
+
114
+ // Transfer to memory
115
+ const memStore = new MemorySkillStore();
116
+ await memStore.initialize();
117
+ await memStore.loadFromContent('my-skill', content);
118
+
119
+ // Use skill
120
+ const skill = await loadSkillFromStorage(memStore, 'my-skill');
121
+ ```
122
+
123
+ ## Progressive Disclosure
124
+
125
+ The plugin implements progressive disclosure for efficient context management:
126
+
127
+ ### Level 1: Metadata (~100 tokens per skill)
128
+ Skill name and description are always available in the system prompt.
129
+
130
+ ```xml
131
+ <available_skills>
132
+ <skill>
133
+ <name>pdf-processing</name>
134
+ <description>Extract text and tables from PDF files.</description>
135
+ <location>/path/to/skills/pdf-processing/SKILL.md</location>
136
+ </skill>
137
+ </available_skills>
138
+ ```
139
+
140
+ ### Level 2: Instructions (<5k tokens)
141
+ Full SKILL.md body loaded when a skill is triggered.
142
+
143
+ ### Level 3: Resources (unlimited)
144
+ Scripts, references, and assets loaded on-demand without entering context.
145
+
146
+ ## Skill Structure
147
+
148
+ ```
149
+ my-skill/
150
+ ├── SKILL.md # Required: instructions + metadata
151
+ ├── scripts/ # Optional: executable code
152
+ ├── references/ # Optional: documentation
153
+ └── assets/ # Optional: templates, resources
154
+ ```
155
+
156
+ ### SKILL.md Format
157
+
158
+ ```yaml
159
+ ---
160
+ name: my-skill
161
+ description: What this skill does and when to use it.
162
+ license: MIT
163
+ compatibility: Requires Python 3.10+
164
+ metadata:
165
+ author: my-org
166
+ version: "1.0"
167
+ otto:
168
+ emoji: "🔧"
169
+ requires:
170
+ bins: ["my-cli"]
171
+ install:
172
+ - id: brew
173
+ kind: brew
174
+ formula: my-tool
175
+ bins: ["my-cli"]
176
+ label: "Install my-tool (brew)"
177
+ ---
178
+
179
+ # My Skill
180
+
181
+ Instructions here...
182
+ ```
183
+
184
+ ## Actions
185
+
186
+ ### GET_SKILL_GUIDANCE
187
+ Main action for skill-powered assistance. Automatically finds, installs, and returns skill instructions.
188
+
189
+ ### SEARCH_SKILLS
190
+ Search the registry for available skills.
191
+
192
+ ### GET_SKILL_DETAILS
193
+ Get detailed information about a specific skill.
194
+
195
+ ### RUN_SKILL_SCRIPT
196
+ Execute scripts bundled with installed skills.
197
+
198
+ ### SYNC_SKILL_CATALOG
199
+ Refresh the skill catalog from the registry.
200
+
201
+ ## Providers
202
+
203
+ ### agent_skills (Medium Resolution)
204
+ Lists installed skills with descriptions. Default provider.
205
+
206
+ ### agent_skill_instructions (High Resolution)
207
+ Provides full instructions for contextually matched skills.
208
+
209
+ ### agent_skills_catalog (Dynamic)
210
+ Shows available skill categories when user asks about capabilities.
211
+
212
+ ## Otto Compatibility
213
+
214
+ The plugin supports Otto's extended metadata format for dependency management:
215
+
216
+ ```yaml
217
+ metadata:
218
+ otto:
219
+ emoji: "🐙"
220
+ requires:
221
+ bins: ["gh"]
222
+ install:
223
+ - id: brew
224
+ kind: brew
225
+ formula: gh
226
+ bins: ["gh"]
227
+ label: "Install GitHub CLI (brew)"
228
+ - id: apt
229
+ kind: apt
230
+ package: gh
231
+ bins: ["gh"]
232
+ label: "Install GitHub CLI (apt)"
233
+ ```
234
+
235
+ ## API Reference
236
+
237
+ ### Service
238
+
239
+ ```typescript
240
+ import { AgentSkillsService } from '@elizaos/plugin-agent-skills';
241
+
242
+ // Get loaded skills
243
+ const skills = service.getLoadedSkills();
244
+
245
+ // Get skill instructions
246
+ const instructions = service.getSkillInstructions('my-skill');
247
+
248
+ // Read a reference file
249
+ const content = await service.readReference('my-skill', 'api-docs.md');
250
+
251
+ // Install a skill from registry
252
+ await service.install('pdf-processing');
253
+
254
+ // Check storage mode
255
+ if (service.isMemoryMode()) {
256
+ // Load skill from content (memory mode only)
257
+ await service.loadSkillFromContent('custom-skill', skillMdContent);
258
+ }
259
+ ```
260
+
261
+ ### Storage
262
+
263
+ ```typescript
264
+ import {
265
+ MemorySkillStore,
266
+ FileSystemSkillStore,
267
+ createStorage,
268
+ loadSkillFromStorage,
269
+ type ISkillStorage,
270
+ } from '@elizaos/plugin-agent-skills';
271
+
272
+ // Create storage (auto-detects environment)
273
+ const storage = createStorage({ type: 'auto', basePath: './skills' });
274
+ await storage.initialize();
275
+
276
+ // List installed skills
277
+ const slugs = await storage.listSkills();
278
+
279
+ // Load skill content
280
+ const content = await storage.loadSkillContent('my-skill');
281
+
282
+ // Load skill into a Skill object
283
+ const skill = await loadSkillFromStorage(storage, 'my-skill');
284
+
285
+ // Memory-specific: load from content
286
+ if (storage.type === 'memory') {
287
+ await (storage as MemorySkillStore).loadFromContent('new-skill', content);
288
+ }
289
+
290
+ // Memory-specific: load from zip
291
+ if (storage.type === 'memory') {
292
+ await (storage as MemorySkillStore).loadFromZip('downloaded-skill', zipBuffer);
293
+ }
294
+ ```
295
+
296
+ ### Parser Utilities
297
+
298
+ ```typescript
299
+ import {
300
+ parseFrontmatter,
301
+ validateFrontmatter,
302
+ generateSkillsXml,
303
+ } from '@elizaos/plugin-agent-skills';
304
+
305
+ // Parse SKILL.md content
306
+ const { frontmatter, body } = parseFrontmatter(content);
307
+
308
+ // Validate frontmatter
309
+ const result = validateFrontmatter(frontmatter, 'skill-name');
310
+
311
+ // Generate XML for prompts
312
+ const xml = generateSkillsXml(skills, { includeLocation: true });
313
+ ```
314
+
315
+ ## Testing
316
+
317
+ The plugin includes comprehensive tests across TypeScript, Python, and Rust implementations.
318
+
319
+ ### Run Tests (Without API Key)
320
+
321
+ ```bash
322
+ # TypeScript - from monorepo root
323
+ bun run --filter @elizaos/plugin-agent-skills test
324
+
325
+ # Python
326
+ cd plugins/plugin-agent-skills/python
327
+ pip install -e ".[dev]"
328
+ pytest tests/ -v
329
+
330
+ # Rust
331
+ cd plugins/plugin-agent-skills/rust
332
+ cargo test
333
+ ```
334
+
335
+ ### Run Integration Tests with Anthropic API
336
+
337
+ Integration tests verify that skills work end-to-end with a real Anthropic API. They load real Otto skills, format them for prompt injection, and verify the agent can understand and use the skill instructions.
338
+
339
+ ```bash
340
+ # TypeScript
341
+ ANTHROPIC_API_KEY=your-key bun run --filter @elizaos/plugin-agent-skills test
342
+
343
+ # Python
344
+ ANTHROPIC_API_KEY=your-key pytest tests/test_integration.py -v
345
+
346
+ # Rust
347
+ ANTHROPIC_API_KEY=your-key cargo test --test integration_tests
348
+ ```
349
+
350
+ ### Test Coverage
351
+
352
+ | Language | Tests | Description |
353
+ |----------|-------|-------------|
354
+ | TypeScript | parser.test.ts | SKILL.md parsing, validation, XML generation |
355
+ | TypeScript | storage.test.ts | Memory and filesystem storage backends |
356
+ | TypeScript | integration.test.ts | Anthropic API integration, real skill loading |
357
+ | Python | test_parser.py | Parser functions, frontmatter extraction |
358
+ | Python | test_storage.py | Storage backends, skill loading |
359
+ | Python | test_integration.py | Anthropic API integration |
360
+ | Rust | parser_tests.rs | Parser, validation, XML generation |
361
+ | Rust | integration_tests.rs | Storage, Anthropic API integration |
362
+
363
+ ## Related
364
+
365
+ - [Agent Skills Specification](https://agentskills.io)
366
+ - [Claude Agent Skills](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/overview)
367
+ - [ClawHub Registry](https://clawhub.ai)
368
+ - [Otto](https://github.com/otto)
369
+
370
+ ## License
371
+
372
+ MIT