Merge pull request #98 from rohitg00/fix/openclaw-cleanup

refactor: deduplicate OpenClaw adapter, fix clawdbot config
This commit is contained in:
Rohit Ghumare
2026-04-07 11:57:07 +01:00
committed by GitHub
6 changed files with 19 additions and 157 deletions
@@ -35,10 +35,10 @@ const ALL_AGENTS = AgentType.options;
describe('Agent Adapters', () => {
describe('getAllAdapters', () => {
it('should return all 44 registered adapters', () => {
it('should return all 45 registered adapters', () => {
const adapters = getAllAdapters();
expect(adapters).toBeInstanceOf(Array);
expect(adapters.length).toBe(44);
expect(adapters.length).toBe(45);
});
it('should include common agents', () => {
@@ -236,16 +236,6 @@ describe('ClawdbotAdapter', () => {
});
describe('isDetected', () => {
it('should detect Clawdbot from workspace skills directory', async () => {
mockExistsSync.mockImplementation((path) => {
return path === join(process.cwd(), 'skills');
});
const detected = await adapter.isDetected();
expect(detected).toBe(true);
});
it('should detect Clawdbot from global directory', async () => {
mockExistsSync.mockImplementation((path) => {
return path === join(homedir(), '.clawdbot');
@@ -287,7 +277,6 @@ describe('ClawdbotAdapter', () => {
await adapter.isDetected();
expect(mockExistsSync).toHaveBeenCalledWith(join(process.cwd(), 'skills'));
expect(mockExistsSync).toHaveBeenCalledWith(join(homedir(), '.clawdbot'));
expect(mockExistsSync).toHaveBeenCalledWith(join(process.cwd(), 'clawdbot.json'));
});
+3 -3
View File
@@ -10,9 +10,9 @@ const config = AGENT_CONFIG.clawdbot;
export class ClawdbotAdapter implements AgentAdapter {
readonly type: AgentType = 'clawdbot';
readonly name = 'Clawdbot';
readonly skillsDir = config.skillsDir;
readonly configFile = config.configFile;
readonly name: string = 'Clawdbot';
readonly skillsDir: string = config.skillsDir;
readonly configFile: string = config.configFile;
generateConfig(skills: Skill[]): string {
const enabledSkills = skills.filter(s => s.enabled);
+9 -86
View File
@@ -1,99 +1,22 @@
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 { ClawdbotAdapter } from './clawdbot.js';
import type { 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;
export class OpenClawAdapter extends ClawdbotAdapter {
override readonly type: AgentType = 'openclaw';
override readonly name = 'OpenClaw';
override readonly skillsDir = config.skillsDir;
override 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
override async isDetected(): Promise<boolean> {
const globalOpenClaw = join(homedir(), '.openclaw');
// OpenClaw config file
const openclawConfig = join(process.cwd(), 'openclaw.json');
return (
(existsSync(projectSkills) && existsSync(globalOpenClaw)) ||
existsSync(openclawConfig)
);
return existsSync(globalOpenClaw) || existsSync(openclawConfig);
}
}
+3 -10
View File
@@ -111,22 +111,15 @@ export const AGENT_CONFIG: Record<AgentType, AgentDirectoryConfig> = {
supportsAutoDiscovery: true,
},
// Clawdbot (legacy name for OpenClaw)
clawdbot: {
skillsDir: 'skills',
configFile: 'CLAUDE.md',
altSkillsDirs: ['.clawdbot/skills', '~/.openclaw/skills'],
globalSkillsDir: '~/.openclaw/skills',
skillsDir: '.clawdbot/skills',
configFile: 'AGENTS.md',
altSkillsDirs: ['skills', '~/.clawdbot/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',
@@ -1,48 +1,5 @@
export type AgentType =
| 'claude-code'
| 'cursor'
| 'windsurf'
| 'github-copilot'
| 'codex'
| 'gemini-cli'
| 'opencode'
| 'universal'
| 'antigravity'
| 'amp'
| 'clawdbot'
| 'droid'
| 'goose'
| 'kilo'
| 'kiro-cli'
| 'roo'
| 'trae'
| 'cline'
| 'codebuddy'
| 'commandcode'
| 'continue'
| 'crush'
| 'factory'
| 'mcpjam'
| 'mux'
| 'neovate'
| 'openhands'
| 'pi'
| 'qoder'
| 'qwen'
| 'vercel'
| 'zencoder'
| 'devin'
| 'aider'
| 'sourcegraph-cody'
| 'amazon-q'
| 'augment-code'
| 'replit-agent'
| 'bolt'
| 'lovable'
| 'tabby'
| 'tabnine'
| 'codegpt'
| 'playcode-agent';
import type { AgentType } from '@skillkit/core';
export type { AgentType };
export interface TranslationDisplay {
sourceFormat: string;