Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/agents/src/clawdbot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 4 additions & 0 deletions packages/agents/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand All @@ -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(),
Expand Down Expand Up @@ -116,6 +119,7 @@ export async function detectAgent(): Promise<AgentType> {
'opencode',
'antigravity',
'amp',
'openclaw',
'clawdbot',
'droid',
'github-copilot',
Expand Down
104 changes: 104 additions & 0 deletions packages/agents/src/openclaw.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
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');
// Legacy clawdbot paths
const globalClawdbot = join(homedir(), '.clawdbot');
const clawdbotConfig = join(process.cwd(), 'clawdbot.json');

return (
(existsSync(projectSkills) && existsSync(globalOpenClaw)) ||
existsSync(openclawConfig) ||
existsSync(globalClawdbot) ||
existsSync(clawdbotConfig)
);
}
}
28 changes: 24 additions & 4 deletions packages/core/src/agent-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},

Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/agents/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -336,6 +337,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',
Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/commands/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/translator/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const AgentType = z.enum([
"gemini-cli",
"amp",
"clawdbot",
"openclaw",
"droid",
"github-copilot",
"goose",
Expand Down