feat: add OpenClaw agent adapter (Clawdbot rebrand) (#86)

feat: add OpenClaw agent adapter (Clawdbot rebrand)
This commit is contained in:
Rohit Ghumare
2026-04-07 11:40:08 +01:00
committed by GitHub
8 changed files with 140 additions and 6 deletions
+1 -2
View File
@@ -69,10 +69,9 @@ ${skillsXml}
}
async isDetected(): Promise<boolean> {
const projectSkills = join(process.cwd(), 'skills');
const globalClawdbot = join(homedir(), '.clawdbot');
const clawdbotConfig = join(process.cwd(), 'clawdbot.json');
return existsSync(projectSkills) || existsSync(globalClawdbot) || existsSync(clawdbotConfig);
return existsSync(globalClawdbot) || existsSync(clawdbotConfig);
}
}
+4
View File
@@ -8,6 +8,7 @@ import { OpenCodeAdapter } from './opencode.js';
import { AntigravityAdapter } from './antigravity.js';
import { AmpAdapter } from './amp.js';
import { ClawdbotAdapter } from './clawdbot.js';
import { OpenClawAdapter } from './openclaw.js';
import { DroidAdapter } from './droid.js';
import { FactoryAdapter } from './factory.js';
import { GitHubCopilotAdapter } from './github-copilot.js';
@@ -29,6 +30,7 @@ export * from './opencode.js';
export * from './antigravity.js';
export * from './amp.js';
export * from './clawdbot.js';
export * from './openclaw.js';
export * from './droid.js';
export * from './factory.js';
export * from './github-copilot.js';
@@ -53,6 +55,7 @@ const adapters: Record<AgentType, AgentAdapter> = {
antigravity: new AntigravityAdapter(),
amp: new AmpAdapter(),
clawdbot: new ClawdbotAdapter(),
openclaw: new OpenClawAdapter(),
droid: new DroidAdapter(),
'github-copilot': new GitHubCopilotAdapter(),
goose: new GooseAdapter(),
@@ -120,6 +123,7 @@ export async function detectAgent(): Promise<AgentType> {
'opencode',
'antigravity',
'amp',
'openclaw',
'clawdbot',
'droid',
'github-copilot',
+99
View File
@@ -0,0 +1,99 @@
import { existsSync } from 'node:fs';
import { join } from 'node:path';
import { homedir } from 'node:os';
import type { AgentAdapter } from './base.js';
import { createSkillXml } from './base.js';
import type { Skill, AgentType } from '@skillkit/core';
import { AGENT_CONFIG } from '@skillkit/core';
const config = AGENT_CONFIG.openclaw;
/**
* OpenClaw Agent Adapter
*
* OpenClaw (formerly Clawdbot) is a local-first AI agent framework with a
* persistent gateway daemon. Skills use an extended YAML frontmatter schema
* with `permissions`, `triggers`, and `metadata.openclaw.requires` fields.
*
* Key differences from Claude Code:
* - Skills dir: `skills/` (not `.claude/skills/`)
* - Global skills: `~/.openclaw/skills/`
* - Config: `~/.openclaw/openclaw.json`
* - SKILL.md frontmatter includes: permissions, triggers, metadata.openclaw
* - Gateway loads skills contextually per-agent at runtime
* - Skills are organized by department: skills/<dept>/<name>/SKILL.md
*/
export class OpenClawAdapter implements AgentAdapter {
readonly type: AgentType = 'openclaw';
readonly name = 'OpenClaw';
readonly skillsDir = config.skillsDir;
readonly configFile = config.configFile;
generateConfig(skills: Skill[]): string {
const enabledSkills = skills.filter(s => s.enabled);
if (enabledSkills.length === 0) {
return '';
}
const skillsXml = enabledSkills.map(createSkillXml).join('\n\n');
return `<skills_system priority="1">
## Available Skills
<!-- SKILLS_TABLE_START -->
<usage>
When users ask you to perform tasks, check if any of the available skills below can help complete the task more effectively. Skills provide specialized capabilities and domain knowledge.
How to use skills:
- Invoke: \`skillkit read <skill-name>\` or \`npx skillkit read <skill-name>\`
- The skill content will load with detailed instructions on how to complete the task
- Base directory provided in output for resolving bundled resources (references/, scripts/, assets/)
Usage notes:
- Only use skills listed in <available_skills> below
- Do not invoke a skill that is already loaded in your context
- Each skill invocation is stateless
</usage>
<available_skills>
${skillsXml}
</available_skills>
<!-- SKILLS_TABLE_END -->
</skills_system>`;
}
parseConfig(content: string): string[] {
const skillNames: string[] = [];
const skillRegex = /<name>([^<]+)<\/name>/g;
let match;
while ((match = skillRegex.exec(content)) !== null) {
skillNames.push(match[1].trim());
}
return skillNames;
}
getInvokeCommand(skillName: string): string {
return `skillkit read ${skillName}`;
}
async isDetected(): Promise<boolean> {
// OpenClaw workspace: skills/ dir at project root
const projectSkills = join(process.cwd(), 'skills');
// OpenClaw global config
const globalOpenClaw = join(homedir(), '.openclaw');
// OpenClaw config file
const openclawConfig = join(process.cwd(), 'openclaw.json');
return (
(existsSync(projectSkills) && existsSync(globalOpenClaw)) ||
existsSync(openclawConfig)
);
}
}
+24 -4
View File
@@ -111,13 +111,33 @@ export const AGENT_CONFIG: Record<AgentType, AgentDirectoryConfig> = {
supportsAutoDiscovery: true,
},
// Clawdbot
// Clawdbot (legacy name for OpenClaw)
clawdbot: {
skillsDir: '.clawdbot/skills',
configFile: 'AGENTS.md',
altSkillsDirs: ['skills'],
skillsDir: 'skills',
configFile: 'CLAUDE.md',
altSkillsDirs: ['.clawdbot/skills', '~/.openclaw/skills'],
globalSkillsDir: '~/.openclaw/skills',
configFormat: 'xml',
usesFrontmatter: true,
frontmatterFields: [
'name', 'description', 'version', 'scan_exempt',
'permissions', 'triggers', 'metadata',
],
supportsAutoDiscovery: true,
},
// OpenClaw (same as clawdbot — rebranded)
openclaw: {
skillsDir: 'skills',
configFile: 'CLAUDE.md',
altSkillsDirs: ['~/.openclaw/skills'],
globalSkillsDir: '~/.openclaw/skills',
configFormat: 'xml',
usesFrontmatter: true,
frontmatterFields: [
'name', 'description', 'version', 'scan_exempt',
'permissions', 'triggers', 'metadata',
],
supportsAutoDiscovery: true,
},
+3
View File
@@ -227,6 +227,7 @@ export const AGENT_DISCOVERY_PATHS: Record<AgentType, string[]> = {
'antigravity': ['.antigravity/agents'],
'amp': ['.amp/agents'],
'clawdbot': ['.clawdbot/agents', 'agents'],
'openclaw': ['agents', '.openclaw/agents'],
'droid': ['.droid/agents'],
'github-copilot': ['.github/agents', '.github/instructions', '.github/custom-agents'],
'goose': ['.goose/agents'],
@@ -277,6 +278,7 @@ export const ALL_AGENT_DISCOVERY_PATHS = [
'.cline/agents',
'.clawdbot/agents',
'.codebuddy/agents',
'.openclaw/agents',
'.codex/agents',
'.commandcode/agents',
'.continue/agents',
@@ -336,6 +338,7 @@ export const CUSTOM_AGENT_FORMAT_MAP: Record<AgentType, AgentFormatCategory> = {
'antigravity': 'claude-agent',
'amp': 'claude-agent',
'clawdbot': 'claude-agent',
'openclaw': 'claude-agent',
'droid': 'claude-agent',
'github-copilot': 'universal',
'goose': 'claude-agent',
+7
View File
@@ -73,6 +73,13 @@ const AGENT_FORMATS: Record<AgentType, AgentCommandFormat> = {
supportsSlashCommands: true,
supportsCommandFiles: true,
},
openclaw: {
agent: 'openclaw',
extension: '.md',
directory: '.claude/commands',
supportsSlashCommands: true,
supportsCommandFiles: true,
},
droid: {
agent: 'droid',
extension: '.md',
+1
View File
@@ -21,6 +21,7 @@ export const AGENT_FORMAT_MAP: Record<AgentType, FormatCategory> = {
'antigravity': 'skill-md',
'amp': 'skill-md',
'clawdbot': 'skill-md',
'openclaw': 'skill-md',
'droid': 'skill-md',
'goose': 'skill-md',
'kilo': 'skill-md',
+1
View File
@@ -9,6 +9,7 @@ export const AgentType = z.enum([
"gemini-cli",
"amp",
"clawdbot",
"openclaw",
"droid",
"github-copilot",
"goose",