From 808ae8327144f664f70387fba7c281a810c4dd44 Mon Sep 17 00:00:00 2001 From: Rohit Ghumare <48523873+rohitg00@users.noreply.github.com> Date: Tue, 7 Apr 2026 11:48:05 +0100 Subject: [PATCH 1/2] refactor: deduplicate OpenClaw adapter, fix clawdbot config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to #86 — cleanup without changing contributor attribution. - OpenClawAdapter extends ClawdbotAdapter (removes 80 lines of copy-paste) - Revert clawdbot config to legacy paths (.clawdbot/skills, AGENTS.md) - OpenClaw detection: ~/.openclaw or openclaw.json - Widen ClawdbotAdapter property types for extensibility - Fix tests: adapter count 44→45, remove stale detection assertions --- .../agents/src/__tests__/adapters.test.ts | 4 +- .../agents/src/__tests__/clawdbot.test.ts | 11 --- packages/agents/src/clawdbot.ts | 6 +- packages/agents/src/openclaw.ts | 95 ++----------------- packages/core/src/agent-config.ts | 13 +-- 5 files changed, 17 insertions(+), 112 deletions(-) diff --git a/packages/agents/src/__tests__/adapters.test.ts b/packages/agents/src/__tests__/adapters.test.ts index 4bba8621..8e6c10dc 100644 --- a/packages/agents/src/__tests__/adapters.test.ts +++ b/packages/agents/src/__tests__/adapters.test.ts @@ -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', () => { diff --git a/packages/agents/src/__tests__/clawdbot.test.ts b/packages/agents/src/__tests__/clawdbot.test.ts index 28017bf5..59fcae40 100644 --- a/packages/agents/src/__tests__/clawdbot.test.ts +++ b/packages/agents/src/__tests__/clawdbot.test.ts @@ -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')); }); diff --git a/packages/agents/src/clawdbot.ts b/packages/agents/src/clawdbot.ts index 6dab33b2..d5675be7 100644 --- a/packages/agents/src/clawdbot.ts +++ b/packages/agents/src/clawdbot.ts @@ -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); diff --git a/packages/agents/src/openclaw.ts b/packages/agents/src/openclaw.ts index 5e6f28be..b8ee7d8f 100644 --- a/packages/agents/src/openclaw.ts +++ b/packages/agents/src/openclaw.ts @@ -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///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 ` - -## Available Skills - - - -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 \` or \`npx skillkit read \` -- 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 below -- Do not invoke a skill that is already loaded in your context -- Each skill invocation is stateless - - - - -${skillsXml} - - - - -`; - } - - parseConfig(content: string): string[] { - const skillNames: string[] = []; - const skillRegex = /([^<]+)<\/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 { - // OpenClaw workspace: skills/ dir at project root - const projectSkills = join(process.cwd(), 'skills'); - // OpenClaw global config + override async isDetected(): Promise { 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); } } diff --git a/packages/core/src/agent-config.ts b/packages/core/src/agent-config.ts index e271bcc0..4c5e7fe5 100644 --- a/packages/core/src/agent-config.ts +++ b/packages/core/src/agent-config.ts @@ -111,22 +111,15 @@ export const AGENT_CONFIG: Record = { 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', From 02fe3f25094a48fac0214e00ae94a727c87c7850 Mon Sep 17 00:00:00 2001 From: Rohit Ghumare <48523873+rohitg00@users.noreply.github.com> Date: Tue, 7 Apr 2026 11:52:16 +0100 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20TUI=20uses=20hardcoded=20AgentType?= =?UTF-8?q?=20=E2=80=94=20import=20from=20@skillkit/core=20instead?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The TUI had a manually-maintained 44-agent AgentType union in translator.service.ts that fell out of sync when openclaw was added to core. Replace with re-export from @skillkit/core so it stays in sync automatically. Fixes CI typecheck failure from #86. --- .../tui/src/services/translator.service.ts | 47 +------------------ 1 file changed, 2 insertions(+), 45 deletions(-) diff --git a/packages/tui/src/services/translator.service.ts b/packages/tui/src/services/translator.service.ts index d99e85c8..cae84585 100644 --- a/packages/tui/src/services/translator.service.ts +++ b/packages/tui/src/services/translator.service.ts @@ -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;