chore: Resolve merge conflict with main (openclaw + qwen + windsurf)
- Combine windsurf scope support from this branch with openclaw/qwen targets from main - Update resolve-output.ts utility to handle openclaw/qwen with openclawHome/qwenHome/pluginName - Add openclawHome/qwenHome args to install.ts and convert.ts - Register openclaw and qwen in targets/index.ts alongside windsurf - Add openclaw/qwen coverage to resolve-output.test.ts (4 new tests → 288 total) - Update README to document all 10 targets including windsurf and openclaw Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
16
README.md
16
README.md
@@ -8,7 +8,7 @@ A Claude Code plugin marketplace featuring the **Compound Engineering Plugin**
|
|||||||
## Claude Code Install
|
## Claude Code Install
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
/plugin marketplace add https://github.com/EveryInc/compound-engineering-plugin
|
/plugin marketplace add EveryInc/compound-engineering-plugin
|
||||||
/plugin install compound-engineering
|
/plugin install compound-engineering
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -18,9 +18,9 @@ A Claude Code plugin marketplace featuring the **Compound Engineering Plugin**
|
|||||||
/add-plugin compound-engineering
|
/add-plugin compound-engineering
|
||||||
```
|
```
|
||||||
|
|
||||||
## OpenCode, Codex, Droid, Pi, Gemini, Copilot, Kiro & Windsurf (experimental) Install
|
## OpenCode, Codex, Droid, Pi, Gemini, Copilot, Kiro, Windsurf, OpenClaw & Qwen (experimental) Install
|
||||||
|
|
||||||
This repo includes a Bun/TypeScript CLI that converts Claude Code plugins to OpenCode, Codex, Factory Droid, Pi, Gemini CLI, GitHub Copilot, Kiro CLI, and Windsurf.
|
This repo includes a Bun/TypeScript CLI that converts Claude Code plugins to OpenCode, Codex, Factory Droid, Pi, Gemini CLI, GitHub Copilot, Kiro CLI, Windsurf, OpenClaw, and Qwen Code.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# convert the compound-engineering plugin into OpenCode format
|
# convert the compound-engineering plugin into OpenCode format
|
||||||
@@ -44,11 +44,17 @@ bunx @every-env/compound-plugin install compound-engineering --to copilot
|
|||||||
# convert to Kiro CLI format
|
# convert to Kiro CLI format
|
||||||
bunx @every-env/compound-plugin install compound-engineering --to kiro
|
bunx @every-env/compound-plugin install compound-engineering --to kiro
|
||||||
|
|
||||||
|
# convert to OpenClaw format
|
||||||
|
bunx @every-env/compound-plugin install compound-engineering --to openclaw
|
||||||
|
|
||||||
# convert to Windsurf format (global scope by default)
|
# convert to Windsurf format (global scope by default)
|
||||||
bunx @every-env/compound-plugin install compound-engineering --to windsurf
|
bunx @every-env/compound-plugin install compound-engineering --to windsurf
|
||||||
|
|
||||||
# convert to Windsurf workspace scope
|
# convert to Windsurf workspace scope
|
||||||
bunx @every-env/compound-plugin install compound-engineering --to windsurf --scope workspace
|
bunx @every-env/compound-plugin install compound-engineering --to windsurf --scope workspace
|
||||||
|
|
||||||
|
# convert to Qwen Code format
|
||||||
|
bunx @every-env/compound-plugin install compound-engineering --to qwen
|
||||||
```
|
```
|
||||||
|
|
||||||
Local dev:
|
Local dev:
|
||||||
@@ -64,7 +70,9 @@ Pi output is written to `~/.pi/agent/` by default with prompts, skills, extensio
|
|||||||
Gemini output is written to `.gemini/` with skills (from agents), commands (`.toml`), and `settings.json` (MCP servers). Namespaced commands create directory structure (`workflows:plan` → `commands/workflows/plan.toml`). Skills use the identical SKILL.md standard and pass through unchanged.
|
Gemini output is written to `.gemini/` with skills (from agents), commands (`.toml`), and `settings.json` (MCP servers). Namespaced commands create directory structure (`workflows:plan` → `commands/workflows/plan.toml`). Skills use the identical SKILL.md standard and pass through unchanged.
|
||||||
Copilot output is written to `.github/` with agents (`.agent.md`), skills (`SKILL.md`), and `copilot-mcp-config.json`. Agents get Copilot frontmatter (`description`, `tools: ["*"]`, `infer: true`), commands are converted to agent skills, and MCP server env vars are prefixed with `COPILOT_MCP_`.
|
Copilot output is written to `.github/` with agents (`.agent.md`), skills (`SKILL.md`), and `copilot-mcp-config.json`. Agents get Copilot frontmatter (`description`, `tools: ["*"]`, `infer: true`), commands are converted to agent skills, and MCP server env vars are prefixed with `COPILOT_MCP_`.
|
||||||
Kiro output is written to `.kiro/` with custom agents (`.json` configs + prompt `.md` files), skills (from commands), pass-through skills, steering files (from CLAUDE.md), and `mcp.json`. Agents get `includeMcpJson: true` for MCP server access. Only stdio MCP servers are supported (HTTP servers are skipped with a warning).
|
Kiro output is written to `.kiro/` with custom agents (`.json` configs + prompt `.md` files), skills (from commands), pass-through skills, steering files (from CLAUDE.md), and `mcp.json`. Agents get `includeMcpJson: true` for MCP server access. Only stdio MCP servers are supported (HTTP servers are skipped with a warning).
|
||||||
Windsurf output defaults to global scope (`~/.codeium/windsurf/`). Claude agents become Windsurf skills (`skills/{name}/SKILL.md`), commands become flat workflows (`global_workflows/{name}.md` for global scope, `workflows/{name}.md` for workspace), and pass-through skills copy unchanged. MCP servers write to `mcp_config.json` (machine-readable, merged with existing config). Use `--scope workspace` for project-level output (`.windsurf/`). Env vars including secrets are included in `mcp_config.json` with a console warning for sensitive keys. The `--scope` flag is generic — Windsurf is the first target to support it.
|
OpenClaw output is written to `~/.openclaw/extensions/compound-engineering/` by default with `openclaw-extension.json` (extension config + MCP servers), `OPENCLAW.md` (context), an entry-point TypeScript skill file, agents (`.md`), commands (`.md`), and pass-through skills.
|
||||||
|
Windsurf output defaults to global scope (`~/.codeium/windsurf/`). Claude agents become Windsurf skills (`skills/{name}/SKILL.md`), commands become flat workflows (`global_workflows/{name}.md` for global scope, `workflows/{name}.md` for workspace), and pass-through skills copy unchanged. MCP servers write to `mcp_config.json` (machine-readable, merged with existing config). Use `--scope workspace` for project-level output (`.windsurf/`).
|
||||||
|
Qwen output is written to `~/.qwen/extensions/compound-engineering/` by default with `qwen-extension.json` (MCP servers), `QWEN.md` (context), agents (`.yaml`), commands (`.md`), and skills. Claude tool names are passed through unchanged. MCP server environment variables with placeholder values are extracted as settings in `qwen-extension.json`. Nested commands use colon separator (`workflows:plan` → `commands/workflows/plan.md`).
|
||||||
|
|
||||||
All provider targets are experimental and may change as the formats evolve.
|
All provider targets are experimental and may change as the formats evolve.
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- All 29 agent descriptions trimmed from ~1,400 to ~180 chars avg (examples moved to agent body)
|
- All 29 agent descriptions trimmed from ~1,400 to ~180 chars avg (examples moved to agent body)
|
||||||
- 18 manual commands marked `disable-model-invocation: true` (side-effect commands like `/lfg`, `/deploy-docs`, `/triage`, etc.)
|
- 18 manual commands marked `disable-model-invocation: true` (side-effect commands like `/lfg`, `/deploy-docs`, `/triage`, etc.)
|
||||||
- 6 manual skills marked `disable-model-invocation: true` (`orchestrating-swarms`, `git-worktree`, `skill-creator`, `compound-docs`, `file-todos`, `resolve-pr-parallel`)
|
- 6 manual skills marked `disable-model-invocation: true` (`orchestrating-swarms`, `git-worktree`, `skill-creator`, `compound-docs`, `file-todos`, `resolve-pr-parallel`)
|
||||||
- **git-worktree**: Remove confirmation prompt for worktree creation ([@Sam Xie](https://github.com/samxie))
|
- **git-worktree**: Remove confirmation prompt for worktree creation ([@Sam Xie](https://github.com/XSAM))
|
||||||
- **Prevent subagents from writing intermediary files** in compound workflow ([@Trevin Chow](https://github.com/trevin))
|
- **Prevent subagents from writing intermediary files** in compound workflow ([@Trevin Chow](https://github.com/trevin))
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
name: create-agent-skill
|
name: create-agent-skill
|
||||||
description: Create or edit Claude Code skills with expert guidance on structure and best practices
|
description: Create or edit Claude Code skills with expert guidance on structure and best practices
|
||||||
allowed-tools: Skill(create-agent-skills)
|
allowed-tools: Skill(create-agent-skills)
|
||||||
argument-hint: [skill description or requirements]
|
argument-hint: "[skill description or requirements]"
|
||||||
disable-model-invocation: true
|
disable-model-invocation: true
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: heal-skill
|
name: heal-skill
|
||||||
description: Fix incorrect SKILL.md files when a skill has wrong instructions or outdated API references
|
description: Fix incorrect SKILL.md files when a skill has wrong instructions or outdated API references
|
||||||
argument-hint: [optional: specific issue to fix]
|
argument-hint: "[optional: specific issue to fix]"
|
||||||
allowed-tools: [Read, Edit, Bash(ls:*), Bash(git:*)]
|
allowed-tools: [Read, Edit, Bash(ls:*), Bash(git:*)]
|
||||||
disable-model-invocation: true
|
disable-model-invocation: true
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export default defineCommand({
|
|||||||
to: {
|
to: {
|
||||||
type: "string",
|
type: "string",
|
||||||
default: "opencode",
|
default: "opencode",
|
||||||
description: "Target format (opencode | codex | droid | cursor | pi | copilot | gemini | kiro | windsurf)",
|
description: "Target format (opencode | codex | droid | cursor | pi | copilot | gemini | kiro | windsurf | openclaw | qwen)",
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
type: "string",
|
type: "string",
|
||||||
@@ -41,6 +41,16 @@ export default defineCommand({
|
|||||||
alias: "pi-home",
|
alias: "pi-home",
|
||||||
description: "Write Pi output to this Pi root (ex: ~/.pi/agent or ./.pi)",
|
description: "Write Pi output to this Pi root (ex: ~/.pi/agent or ./.pi)",
|
||||||
},
|
},
|
||||||
|
openclawHome: {
|
||||||
|
type: "string",
|
||||||
|
alias: "openclaw-home",
|
||||||
|
description: "Write OpenClaw output to this extensions root (ex: ~/.openclaw/extensions)",
|
||||||
|
},
|
||||||
|
qwenHome: {
|
||||||
|
type: "string",
|
||||||
|
alias: "qwen-home",
|
||||||
|
description: "Write Qwen output to this Qwen extensions root (ex: ~/.qwen/extensions)",
|
||||||
|
},
|
||||||
scope: {
|
scope: {
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "Scope level: global | workspace (default varies by target)",
|
description: "Scope level: global | workspace (default varies by target)",
|
||||||
@@ -88,6 +98,8 @@ export default defineCommand({
|
|||||||
const hasExplicitOutput = Boolean(args.output && String(args.output).trim())
|
const hasExplicitOutput = Boolean(args.output && String(args.output).trim())
|
||||||
const codexHome = resolveTargetHome(args.codexHome, path.join(os.homedir(), ".codex"))
|
const codexHome = resolveTargetHome(args.codexHome, path.join(os.homedir(), ".codex"))
|
||||||
const piHome = resolveTargetHome(args.piHome, path.join(os.homedir(), ".pi", "agent"))
|
const piHome = resolveTargetHome(args.piHome, path.join(os.homedir(), ".pi", "agent"))
|
||||||
|
const openclawHome = resolveTargetHome(args.openclawHome, path.join(os.homedir(), ".openclaw", "extensions"))
|
||||||
|
const qwenHome = resolveTargetHome(args.qwenHome, path.join(os.homedir(), ".qwen", "extensions"))
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
agentMode: String(args.agentMode) === "primary" ? "primary" : "subagent",
|
agentMode: String(args.agentMode) === "primary" ? "primary" : "subagent",
|
||||||
@@ -100,6 +112,9 @@ export default defineCommand({
|
|||||||
outputRoot,
|
outputRoot,
|
||||||
codexHome,
|
codexHome,
|
||||||
piHome,
|
piHome,
|
||||||
|
openclawHome,
|
||||||
|
qwenHome,
|
||||||
|
pluginName: plugin.manifest.name,
|
||||||
hasExplicitOutput,
|
hasExplicitOutput,
|
||||||
scope: resolvedScope,
|
scope: resolvedScope,
|
||||||
})
|
})
|
||||||
@@ -133,6 +148,9 @@ export default defineCommand({
|
|||||||
outputRoot: path.join(outputRoot, extra),
|
outputRoot: path.join(outputRoot, extra),
|
||||||
codexHome,
|
codexHome,
|
||||||
piHome,
|
piHome,
|
||||||
|
openclawHome,
|
||||||
|
qwenHome,
|
||||||
|
pluginName: plugin.manifest.name,
|
||||||
hasExplicitOutput,
|
hasExplicitOutput,
|
||||||
scope: handler.defaultScope,
|
scope: handler.defaultScope,
|
||||||
})
|
})
|
||||||
@@ -161,4 +179,3 @@ function resolveOutputRoot(value: unknown): string {
|
|||||||
}
|
}
|
||||||
return process.cwd()
|
return process.cwd()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export default defineCommand({
|
|||||||
to: {
|
to: {
|
||||||
type: "string",
|
type: "string",
|
||||||
default: "opencode",
|
default: "opencode",
|
||||||
description: "Target format (opencode | codex | droid | cursor | pi | copilot | gemini | kiro | windsurf)",
|
description: "Target format (opencode | codex | droid | cursor | pi | copilot | gemini | kiro | windsurf | openclaw | qwen)",
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
type: "string",
|
type: "string",
|
||||||
@@ -43,6 +43,16 @@ export default defineCommand({
|
|||||||
alias: "pi-home",
|
alias: "pi-home",
|
||||||
description: "Write Pi output to this Pi root (ex: ~/.pi/agent or ./.pi)",
|
description: "Write Pi output to this Pi root (ex: ~/.pi/agent or ./.pi)",
|
||||||
},
|
},
|
||||||
|
openclawHome: {
|
||||||
|
type: "string",
|
||||||
|
alias: "openclaw-home",
|
||||||
|
description: "Write OpenClaw output to this extensions root (ex: ~/.openclaw/extensions)",
|
||||||
|
},
|
||||||
|
qwenHome: {
|
||||||
|
type: "string",
|
||||||
|
alias: "qwen-home",
|
||||||
|
description: "Write Qwen output to this Qwen extensions root (ex: ~/.qwen/extensions)",
|
||||||
|
},
|
||||||
scope: {
|
scope: {
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "Scope level: global | workspace (default varies by target)",
|
description: "Scope level: global | workspace (default varies by target)",
|
||||||
@@ -91,6 +101,8 @@ export default defineCommand({
|
|||||||
const outputRoot = resolveOutputRoot(args.output)
|
const outputRoot = resolveOutputRoot(args.output)
|
||||||
const codexHome = resolveTargetHome(args.codexHome, path.join(os.homedir(), ".codex"))
|
const codexHome = resolveTargetHome(args.codexHome, path.join(os.homedir(), ".codex"))
|
||||||
const piHome = resolveTargetHome(args.piHome, path.join(os.homedir(), ".pi", "agent"))
|
const piHome = resolveTargetHome(args.piHome, path.join(os.homedir(), ".pi", "agent"))
|
||||||
|
const openclawHome = resolveTargetHome(args.openclawHome, path.join(os.homedir(), ".openclaw", "extensions"))
|
||||||
|
const qwenHome = resolveTargetHome(args.qwenHome, path.join(os.homedir(), ".qwen", "extensions"))
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
agentMode: String(args.agentMode) === "primary" ? "primary" : "subagent",
|
agentMode: String(args.agentMode) === "primary" ? "primary" : "subagent",
|
||||||
@@ -108,6 +120,9 @@ export default defineCommand({
|
|||||||
outputRoot,
|
outputRoot,
|
||||||
codexHome,
|
codexHome,
|
||||||
piHome,
|
piHome,
|
||||||
|
openclawHome,
|
||||||
|
qwenHome,
|
||||||
|
pluginName: plugin.manifest.name,
|
||||||
hasExplicitOutput,
|
hasExplicitOutput,
|
||||||
scope: resolvedScope,
|
scope: resolvedScope,
|
||||||
})
|
})
|
||||||
@@ -136,6 +151,9 @@ export default defineCommand({
|
|||||||
outputRoot: path.join(outputRoot, extra),
|
outputRoot: path.join(outputRoot, extra),
|
||||||
codexHome,
|
codexHome,
|
||||||
piHome,
|
piHome,
|
||||||
|
openclawHome,
|
||||||
|
qwenHome,
|
||||||
|
pluginName: plugin.manifest.name,
|
||||||
hasExplicitOutput,
|
hasExplicitOutput,
|
||||||
scope: handler.defaultScope,
|
scope: handler.defaultScope,
|
||||||
})
|
})
|
||||||
|
|||||||
240
src/converters/claude-to-openclaw.ts
Normal file
240
src/converters/claude-to-openclaw.ts
Normal file
@@ -0,0 +1,240 @@
|
|||||||
|
import { formatFrontmatter } from "../utils/frontmatter"
|
||||||
|
import type {
|
||||||
|
ClaudeAgent,
|
||||||
|
ClaudeCommand,
|
||||||
|
ClaudePlugin,
|
||||||
|
ClaudeMcpServer,
|
||||||
|
} from "../types/claude"
|
||||||
|
import type {
|
||||||
|
OpenClawBundle,
|
||||||
|
OpenClawCommandRegistration,
|
||||||
|
OpenClawPluginManifest,
|
||||||
|
OpenClawSkillFile,
|
||||||
|
} from "../types/openclaw"
|
||||||
|
import type { ClaudeToOpenCodeOptions } from "./claude-to-opencode"
|
||||||
|
|
||||||
|
export type ClaudeToOpenClawOptions = ClaudeToOpenCodeOptions
|
||||||
|
|
||||||
|
export function convertClaudeToOpenClaw(
|
||||||
|
plugin: ClaudePlugin,
|
||||||
|
_options: ClaudeToOpenClawOptions,
|
||||||
|
): OpenClawBundle {
|
||||||
|
const enabledCommands = plugin.commands.filter((cmd) => !cmd.disableModelInvocation)
|
||||||
|
|
||||||
|
const agentSkills = plugin.agents.map(convertAgentToSkill)
|
||||||
|
const commandSkills = enabledCommands.map(convertCommandToSkill)
|
||||||
|
const commands = enabledCommands.map(convertCommand)
|
||||||
|
|
||||||
|
const skills: OpenClawSkillFile[] = [...agentSkills, ...commandSkills]
|
||||||
|
|
||||||
|
const skillDirCopies = plugin.skills.map((skill) => ({
|
||||||
|
sourceDir: skill.sourceDir,
|
||||||
|
name: skill.name,
|
||||||
|
}))
|
||||||
|
|
||||||
|
const allSkillDirs = [
|
||||||
|
...agentSkills.map((s) => s.dir),
|
||||||
|
...commandSkills.map((s) => s.dir),
|
||||||
|
...plugin.skills.map((s) => s.name),
|
||||||
|
]
|
||||||
|
|
||||||
|
const manifest = buildManifest(plugin, allSkillDirs)
|
||||||
|
|
||||||
|
const packageJson = buildPackageJson(plugin)
|
||||||
|
|
||||||
|
const openclawConfig = plugin.mcpServers
|
||||||
|
? buildOpenClawConfig(plugin.mcpServers)
|
||||||
|
: undefined
|
||||||
|
|
||||||
|
const entryPoint = generateEntryPoint(commands)
|
||||||
|
|
||||||
|
return {
|
||||||
|
manifest,
|
||||||
|
packageJson,
|
||||||
|
entryPoint,
|
||||||
|
skills,
|
||||||
|
skillDirCopies,
|
||||||
|
commands,
|
||||||
|
openclawConfig,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildManifest(plugin: ClaudePlugin, skillDirs: string[]): OpenClawPluginManifest {
|
||||||
|
return {
|
||||||
|
id: plugin.manifest.name,
|
||||||
|
name: formatDisplayName(plugin.manifest.name),
|
||||||
|
kind: "tool",
|
||||||
|
skills: skillDirs.map((dir) => `skills/${dir}`),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildPackageJson(plugin: ClaudePlugin): Record<string, unknown> {
|
||||||
|
return {
|
||||||
|
name: `openclaw-${plugin.manifest.name}`,
|
||||||
|
version: plugin.manifest.version,
|
||||||
|
type: "module",
|
||||||
|
private: true,
|
||||||
|
description: plugin.manifest.description,
|
||||||
|
main: "index.ts",
|
||||||
|
openclaw: {
|
||||||
|
extensions: [
|
||||||
|
{
|
||||||
|
id: plugin.manifest.name,
|
||||||
|
entry: "./index.ts",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
keywords: [
|
||||||
|
"openclaw",
|
||||||
|
"openclaw-plugin",
|
||||||
|
...(plugin.manifest.keywords ?? []),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function convertAgentToSkill(agent: ClaudeAgent): OpenClawSkillFile {
|
||||||
|
const frontmatter: Record<string, unknown> = {
|
||||||
|
name: agent.name,
|
||||||
|
description: agent.description,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (agent.model && agent.model !== "inherit") {
|
||||||
|
frontmatter.model = agent.model
|
||||||
|
}
|
||||||
|
|
||||||
|
const body = rewritePaths(agent.body)
|
||||||
|
const content = formatFrontmatter(frontmatter, body)
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: agent.name,
|
||||||
|
content,
|
||||||
|
dir: `agent-${agent.name}`,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function convertCommandToSkill(command: ClaudeCommand): OpenClawSkillFile {
|
||||||
|
const frontmatter: Record<string, unknown> = {
|
||||||
|
name: `cmd-${command.name}`,
|
||||||
|
description: command.description,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (command.model && command.model !== "inherit") {
|
||||||
|
frontmatter.model = command.model
|
||||||
|
}
|
||||||
|
|
||||||
|
const body = rewritePaths(command.body)
|
||||||
|
const content = formatFrontmatter(frontmatter, body)
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: command.name,
|
||||||
|
content,
|
||||||
|
dir: `cmd-${command.name}`,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function convertCommand(command: ClaudeCommand): OpenClawCommandRegistration {
|
||||||
|
return {
|
||||||
|
name: command.name.replace(/:/g, "-"),
|
||||||
|
description: command.description ?? `Run ${command.name}`,
|
||||||
|
acceptsArgs: Boolean(command.argumentHint),
|
||||||
|
body: rewritePaths(command.body),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildOpenClawConfig(
|
||||||
|
servers: Record<string, ClaudeMcpServer>,
|
||||||
|
): Record<string, unknown> {
|
||||||
|
const mcpServers: Record<string, unknown> = {}
|
||||||
|
|
||||||
|
for (const [name, server] of Object.entries(servers)) {
|
||||||
|
if (server.command) {
|
||||||
|
mcpServers[name] = {
|
||||||
|
type: "stdio",
|
||||||
|
command: server.command,
|
||||||
|
args: server.args ?? [],
|
||||||
|
env: server.env,
|
||||||
|
}
|
||||||
|
} else if (server.url) {
|
||||||
|
mcpServers[name] = {
|
||||||
|
type: "http",
|
||||||
|
url: server.url,
|
||||||
|
headers: server.headers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { mcpServers }
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateEntryPoint(commands: OpenClawCommandRegistration[]): string {
|
||||||
|
const commandRegistrations = commands
|
||||||
|
.map((cmd) => {
|
||||||
|
// JSON.stringify produces a fully-escaped string literal safe for JS/TS source embedding
|
||||||
|
const safeName = JSON.stringify(cmd.name)
|
||||||
|
const safeDesc = JSON.stringify(cmd.description ?? "")
|
||||||
|
const safeNotFound = JSON.stringify(`Command ${cmd.name} not found. Check skills directory.`)
|
||||||
|
return ` api.registerCommand({
|
||||||
|
name: ${safeName},
|
||||||
|
description: ${safeDesc},
|
||||||
|
acceptsArgs: ${cmd.acceptsArgs},
|
||||||
|
requireAuth: false,
|
||||||
|
handler: (ctx) => ({
|
||||||
|
text: skills[${safeName}] ?? ${safeNotFound},
|
||||||
|
}),
|
||||||
|
});`
|
||||||
|
})
|
||||||
|
.join("\n\n")
|
||||||
|
|
||||||
|
return `// Auto-generated OpenClaw plugin entry point
|
||||||
|
// Converted from Claude Code plugin format by compound-plugin CLI
|
||||||
|
import { promises as fs } from "fs";
|
||||||
|
import path from "path";
|
||||||
|
import { fileURLToPath } from "url";
|
||||||
|
|
||||||
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
|
// Pre-load skill bodies for command responses
|
||||||
|
const skills: Record<string, string> = {};
|
||||||
|
|
||||||
|
async function loadSkills() {
|
||||||
|
const skillsDir = path.join(__dirname, "skills");
|
||||||
|
try {
|
||||||
|
const entries = await fs.readdir(skillsDir, { withFileTypes: true });
|
||||||
|
for (const entry of entries) {
|
||||||
|
if (!entry.isDirectory()) continue;
|
||||||
|
const skillPath = path.join(skillsDir, entry.name, "SKILL.md");
|
||||||
|
try {
|
||||||
|
const content = await fs.readFile(skillPath, "utf8");
|
||||||
|
// Strip frontmatter
|
||||||
|
const body = content.replace(/^---[\\s\\S]*?---\\n*/, "");
|
||||||
|
skills[entry.name.replace(/^cmd-/, "")] = body.trim();
|
||||||
|
} catch {
|
||||||
|
// Skill file not found, skip
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Skills directory not found
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function register(api) {
|
||||||
|
await loadSkills();
|
||||||
|
|
||||||
|
${commandRegistrations}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
function rewritePaths(body: string): string {
|
||||||
|
return body
|
||||||
|
.replace(/(?<=^|\s|["'`])~\/\.claude\//gm, "~/.openclaw/")
|
||||||
|
.replace(/(?<=^|\s|["'`])\.claude\//gm, ".openclaw/")
|
||||||
|
.replace(/\.claude-plugin\//g, "openclaw-plugin/")
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDisplayName(name: string): string {
|
||||||
|
return name
|
||||||
|
.split("-")
|
||||||
|
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
||||||
|
.join(" ")
|
||||||
|
}
|
||||||
238
src/converters/claude-to-qwen.ts
Normal file
238
src/converters/claude-to-qwen.ts
Normal file
@@ -0,0 +1,238 @@
|
|||||||
|
import { formatFrontmatter } from "../utils/frontmatter"
|
||||||
|
import type { ClaudeAgent, ClaudeCommand, ClaudeMcpServer, ClaudePlugin } from "../types/claude"
|
||||||
|
import type {
|
||||||
|
QwenAgentFile,
|
||||||
|
QwenBundle,
|
||||||
|
QwenCommandFile,
|
||||||
|
QwenExtensionConfig,
|
||||||
|
QwenMcpServer,
|
||||||
|
QwenSetting,
|
||||||
|
} from "../types/qwen"
|
||||||
|
|
||||||
|
export type ClaudeToQwenOptions = {
|
||||||
|
agentMode: "primary" | "subagent"
|
||||||
|
inferTemperature: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export function convertClaudeToQwen(plugin: ClaudePlugin, options: ClaudeToQwenOptions): QwenBundle {
|
||||||
|
const agentFiles = plugin.agents.map((agent) => convertAgent(agent, options))
|
||||||
|
const cmdFiles = convertCommands(plugin.commands)
|
||||||
|
const mcp = plugin.mcpServers ? convertMcp(plugin.mcpServers) : undefined
|
||||||
|
const settings = extractSettings(plugin.mcpServers)
|
||||||
|
|
||||||
|
const config: QwenExtensionConfig = {
|
||||||
|
name: plugin.manifest.name,
|
||||||
|
version: plugin.manifest.version || "1.0.0",
|
||||||
|
commands: "commands",
|
||||||
|
skills: "skills",
|
||||||
|
agents: "agents",
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mcp && Object.keys(mcp).length > 0) {
|
||||||
|
config.mcpServers = mcp
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings && settings.length > 0) {
|
||||||
|
config.settings = settings
|
||||||
|
}
|
||||||
|
|
||||||
|
const contextFile = generateContextFile(plugin)
|
||||||
|
|
||||||
|
return {
|
||||||
|
config,
|
||||||
|
agents: agentFiles,
|
||||||
|
commandFiles: cmdFiles,
|
||||||
|
skillDirs: plugin.skills.map((skill) => ({ sourceDir: skill.sourceDir, name: skill.name })),
|
||||||
|
contextFile,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function convertAgent(agent: ClaudeAgent, options: ClaudeToQwenOptions): QwenAgentFile {
|
||||||
|
const frontmatter: Record<string, unknown> = {
|
||||||
|
name: agent.name,
|
||||||
|
description: agent.description,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (agent.model && agent.model !== "inherit") {
|
||||||
|
frontmatter.model = normalizeModel(agent.model)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.inferTemperature) {
|
||||||
|
const temperature = inferTemperature(agent)
|
||||||
|
if (temperature !== undefined) {
|
||||||
|
frontmatter.temperature = temperature
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Qwen supports both YAML and Markdown for agents
|
||||||
|
// Using YAML format for structured config
|
||||||
|
const content = formatFrontmatter(frontmatter, rewriteQwenPaths(agent.body))
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: agent.name,
|
||||||
|
content,
|
||||||
|
format: "yaml",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function convertCommands(commands: ClaudeCommand[]): QwenCommandFile[] {
|
||||||
|
const files: QwenCommandFile[] = []
|
||||||
|
for (const command of commands) {
|
||||||
|
if (command.disableModelInvocation) continue
|
||||||
|
const frontmatter: Record<string, unknown> = {
|
||||||
|
description: command.description,
|
||||||
|
}
|
||||||
|
if (command.model && command.model !== "inherit") {
|
||||||
|
frontmatter.model = normalizeModel(command.model)
|
||||||
|
}
|
||||||
|
if (command.allowedTools && command.allowedTools.length > 0) {
|
||||||
|
frontmatter.allowedTools = command.allowedTools
|
||||||
|
}
|
||||||
|
const content = formatFrontmatter(frontmatter, rewriteQwenPaths(command.body))
|
||||||
|
files.push({ name: command.name, content })
|
||||||
|
}
|
||||||
|
return files
|
||||||
|
}
|
||||||
|
|
||||||
|
function convertMcp(servers: Record<string, ClaudeMcpServer>): Record<string, QwenMcpServer> {
|
||||||
|
const result: Record<string, QwenMcpServer> = {}
|
||||||
|
for (const [name, server] of Object.entries(servers)) {
|
||||||
|
if (server.command) {
|
||||||
|
result[name] = {
|
||||||
|
command: server.command,
|
||||||
|
args: server.args,
|
||||||
|
env: server.env,
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if (server.url) {
|
||||||
|
// Qwen only supports stdio (command-based) MCP servers — skip remote servers
|
||||||
|
console.warn(
|
||||||
|
`Warning: Remote MCP server '${name}' (URL: ${server.url}) is not supported in Qwen format. Qwen only supports stdio MCP servers. Skipping.`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractSettings(mcpServers?: Record<string, ClaudeMcpServer>): QwenSetting[] {
|
||||||
|
const settings: QwenSetting[] = []
|
||||||
|
if (!mcpServers) return settings
|
||||||
|
|
||||||
|
for (const [name, server] of Object.entries(mcpServers)) {
|
||||||
|
if (server.env) {
|
||||||
|
for (const [envVar, value] of Object.entries(server.env)) {
|
||||||
|
// Only add settings for environment variables that look like placeholders
|
||||||
|
if (value.startsWith("${") || value.includes("YOUR_") || value.includes("XXX")) {
|
||||||
|
settings.push({
|
||||||
|
name: formatSettingName(envVar),
|
||||||
|
description: `Environment variable for ${name} MCP server`,
|
||||||
|
envVar,
|
||||||
|
sensitive: envVar.toLowerCase().includes("key") || envVar.toLowerCase().includes("token") || envVar.toLowerCase().includes("secret"),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return settings
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatSettingName(envVar: string): string {
|
||||||
|
return envVar
|
||||||
|
.replace(/_/g, " ")
|
||||||
|
.toLowerCase()
|
||||||
|
.replace(/\b\w/g, (c) => c.toUpperCase())
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateContextFile(plugin: ClaudePlugin): string {
|
||||||
|
const sections: string[] = []
|
||||||
|
|
||||||
|
// Plugin description
|
||||||
|
sections.push(`# ${plugin.manifest.name}`)
|
||||||
|
sections.push("")
|
||||||
|
if (plugin.manifest.description) {
|
||||||
|
sections.push(plugin.manifest.description)
|
||||||
|
sections.push("")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Agents section
|
||||||
|
if (plugin.agents.length > 0) {
|
||||||
|
sections.push("## Agents")
|
||||||
|
sections.push("")
|
||||||
|
for (const agent of plugin.agents) {
|
||||||
|
sections.push(`- **${agent.name}**: ${agent.description || "No description"}`)
|
||||||
|
}
|
||||||
|
sections.push("")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commands section
|
||||||
|
if (plugin.commands.length > 0) {
|
||||||
|
sections.push("## Commands")
|
||||||
|
sections.push("")
|
||||||
|
for (const command of plugin.commands) {
|
||||||
|
if (!command.disableModelInvocation) {
|
||||||
|
sections.push(`- **/${command.name}**: ${command.description || "No description"}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sections.push("")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skills section
|
||||||
|
if (plugin.skills.length > 0) {
|
||||||
|
sections.push("## Skills")
|
||||||
|
sections.push("")
|
||||||
|
for (const skill of plugin.skills) {
|
||||||
|
sections.push(`- ${skill.name}`)
|
||||||
|
}
|
||||||
|
sections.push("")
|
||||||
|
}
|
||||||
|
|
||||||
|
return sections.join("\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
function rewriteQwenPaths(body: string): string {
|
||||||
|
return body
|
||||||
|
.replace(/(?<=^|\s|["'`])~\/\.claude\//gm, "~/.qwen/")
|
||||||
|
.replace(/(?<=^|\s|["'`])\.claude\//gm, ".qwen/")
|
||||||
|
}
|
||||||
|
|
||||||
|
const CLAUDE_FAMILY_ALIASES: Record<string, string> = {
|
||||||
|
haiku: "claude-haiku",
|
||||||
|
sonnet: "claude-sonnet",
|
||||||
|
opus: "claude-opus",
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeModel(model: string): string {
|
||||||
|
if (model.includes("/")) return model
|
||||||
|
if (CLAUDE_FAMILY_ALIASES[model]) {
|
||||||
|
const resolved = `anthropic/${CLAUDE_FAMILY_ALIASES[model]}`
|
||||||
|
console.warn(
|
||||||
|
`Warning: bare model alias "${model}" mapped to "${resolved}".`,
|
||||||
|
)
|
||||||
|
return resolved
|
||||||
|
}
|
||||||
|
if (/^claude-/.test(model)) return `anthropic/${model}`
|
||||||
|
if (/^(gpt-|o1-|o3-)/.test(model)) return `openai/${model}`
|
||||||
|
if (/^gemini-/.test(model)) return `google/${model}`
|
||||||
|
if (/^qwen-/.test(model)) return `qwen/${model}`
|
||||||
|
return `anthropic/${model}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function inferTemperature(agent: ClaudeAgent): number | undefined {
|
||||||
|
const sample = `${agent.name} ${agent.description ?? ""}`.toLowerCase()
|
||||||
|
if (/(review|audit|security|sentinel|oracle|lint|verification|guardian)/.test(sample)) {
|
||||||
|
return 0.1
|
||||||
|
}
|
||||||
|
if (/(plan|planning|architecture|strategist|analysis|research)/.test(sample)) {
|
||||||
|
return 0.2
|
||||||
|
}
|
||||||
|
if (/(doc|readme|changelog|editor|writer)/.test(sample)) {
|
||||||
|
return 0.3
|
||||||
|
}
|
||||||
|
if (/(brainstorm|creative|ideate|design|concept)/.test(sample)) {
|
||||||
|
return 0.6
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
@@ -7,6 +7,8 @@ import type { CopilotBundle } from "../types/copilot"
|
|||||||
import type { GeminiBundle } from "../types/gemini"
|
import type { GeminiBundle } from "../types/gemini"
|
||||||
import type { KiroBundle } from "../types/kiro"
|
import type { KiroBundle } from "../types/kiro"
|
||||||
import type { WindsurfBundle } from "../types/windsurf"
|
import type { WindsurfBundle } from "../types/windsurf"
|
||||||
|
import type { OpenClawBundle } from "../types/openclaw"
|
||||||
|
import type { QwenBundle } from "../types/qwen"
|
||||||
import { convertClaudeToOpenCode, type ClaudeToOpenCodeOptions } from "../converters/claude-to-opencode"
|
import { convertClaudeToOpenCode, type ClaudeToOpenCodeOptions } from "../converters/claude-to-opencode"
|
||||||
import { convertClaudeToCodex } from "../converters/claude-to-codex"
|
import { convertClaudeToCodex } from "../converters/claude-to-codex"
|
||||||
import { convertClaudeToDroid } from "../converters/claude-to-droid"
|
import { convertClaudeToDroid } from "../converters/claude-to-droid"
|
||||||
@@ -15,6 +17,8 @@ import { convertClaudeToCopilot } from "../converters/claude-to-copilot"
|
|||||||
import { convertClaudeToGemini } from "../converters/claude-to-gemini"
|
import { convertClaudeToGemini } from "../converters/claude-to-gemini"
|
||||||
import { convertClaudeToKiro } from "../converters/claude-to-kiro"
|
import { convertClaudeToKiro } from "../converters/claude-to-kiro"
|
||||||
import { convertClaudeToWindsurf } from "../converters/claude-to-windsurf"
|
import { convertClaudeToWindsurf } from "../converters/claude-to-windsurf"
|
||||||
|
import { convertClaudeToOpenClaw } from "../converters/claude-to-openclaw"
|
||||||
|
import { convertClaudeToQwen } from "../converters/claude-to-qwen"
|
||||||
import { writeOpenCodeBundle } from "./opencode"
|
import { writeOpenCodeBundle } from "./opencode"
|
||||||
import { writeCodexBundle } from "./codex"
|
import { writeCodexBundle } from "./codex"
|
||||||
import { writeDroidBundle } from "./droid"
|
import { writeDroidBundle } from "./droid"
|
||||||
@@ -23,6 +27,8 @@ import { writeCopilotBundle } from "./copilot"
|
|||||||
import { writeGeminiBundle } from "./gemini"
|
import { writeGeminiBundle } from "./gemini"
|
||||||
import { writeKiroBundle } from "./kiro"
|
import { writeKiroBundle } from "./kiro"
|
||||||
import { writeWindsurfBundle } from "./windsurf"
|
import { writeWindsurfBundle } from "./windsurf"
|
||||||
|
import { writeOpenClawBundle } from "./openclaw"
|
||||||
|
import { writeQwenBundle } from "./qwen"
|
||||||
|
|
||||||
export type TargetScope = "global" | "workspace"
|
export type TargetScope = "global" | "workspace"
|
||||||
|
|
||||||
@@ -112,4 +118,16 @@ export const targets: Record<string, TargetHandler> = {
|
|||||||
convert: convertClaudeToWindsurf as TargetHandler<WindsurfBundle>["convert"],
|
convert: convertClaudeToWindsurf as TargetHandler<WindsurfBundle>["convert"],
|
||||||
write: writeWindsurfBundle as TargetHandler<WindsurfBundle>["write"],
|
write: writeWindsurfBundle as TargetHandler<WindsurfBundle>["write"],
|
||||||
},
|
},
|
||||||
|
openclaw: {
|
||||||
|
name: "openclaw",
|
||||||
|
implemented: true,
|
||||||
|
convert: convertClaudeToOpenClaw as TargetHandler<OpenClawBundle>["convert"],
|
||||||
|
write: writeOpenClawBundle as TargetHandler<OpenClawBundle>["write"],
|
||||||
|
},
|
||||||
|
qwen: {
|
||||||
|
name: "qwen",
|
||||||
|
implemented: true,
|
||||||
|
convert: convertClaudeToQwen as TargetHandler<QwenBundle>["convert"],
|
||||||
|
write: writeQwenBundle as TargetHandler<QwenBundle>["write"],
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
96
src/targets/openclaw.ts
Normal file
96
src/targets/openclaw.ts
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
import path from "path"
|
||||||
|
import { promises as fs } from "fs"
|
||||||
|
import { backupFile, copyDir, ensureDir, pathExists, readJson, walkFiles, writeJson, writeText } from "../utils/files"
|
||||||
|
import type { OpenClawBundle } from "../types/openclaw"
|
||||||
|
|
||||||
|
export async function writeOpenClawBundle(outputRoot: string, bundle: OpenClawBundle): Promise<void> {
|
||||||
|
const paths = resolveOpenClawPaths(outputRoot)
|
||||||
|
await ensureDir(paths.root)
|
||||||
|
|
||||||
|
// Write openclaw.plugin.json
|
||||||
|
await writeJson(paths.manifestPath, bundle.manifest)
|
||||||
|
|
||||||
|
// Write package.json
|
||||||
|
await writeJson(paths.packageJsonPath, bundle.packageJson)
|
||||||
|
|
||||||
|
// Write index.ts entry point
|
||||||
|
await writeText(paths.entryPointPath, bundle.entryPoint)
|
||||||
|
|
||||||
|
// Write generated skills (agents + commands converted to SKILL.md)
|
||||||
|
for (const skill of bundle.skills) {
|
||||||
|
const skillDir = path.join(paths.skillsDir, skill.dir)
|
||||||
|
await ensureDir(skillDir)
|
||||||
|
await writeText(path.join(skillDir, "SKILL.md"), skill.content + "\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy original skill directories (preserving references/, assets/, scripts/)
|
||||||
|
// and rewrite .claude/ paths to .openclaw/ in markdown files
|
||||||
|
for (const skill of bundle.skillDirCopies) {
|
||||||
|
const destDir = path.join(paths.skillsDir, skill.name)
|
||||||
|
await copyDir(skill.sourceDir, destDir)
|
||||||
|
await rewritePathsInDir(destDir)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write openclaw.json config fragment if MCP servers exist
|
||||||
|
if (bundle.openclawConfig) {
|
||||||
|
const configPath = path.join(paths.root, "openclaw.json")
|
||||||
|
const backupPath = await backupFile(configPath)
|
||||||
|
if (backupPath) {
|
||||||
|
console.log(`Backed up existing config to ${backupPath}`)
|
||||||
|
}
|
||||||
|
const merged = await mergeOpenClawConfig(configPath, bundle.openclawConfig)
|
||||||
|
await writeJson(configPath, merged)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveOpenClawPaths(outputRoot: string) {
|
||||||
|
return {
|
||||||
|
root: outputRoot,
|
||||||
|
manifestPath: path.join(outputRoot, "openclaw.plugin.json"),
|
||||||
|
packageJsonPath: path.join(outputRoot, "package.json"),
|
||||||
|
entryPointPath: path.join(outputRoot, "index.ts"),
|
||||||
|
skillsDir: path.join(outputRoot, "skills"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function rewritePathsInDir(dir: string): Promise<void> {
|
||||||
|
const files = await walkFiles(dir)
|
||||||
|
for (const file of files) {
|
||||||
|
if (!file.endsWith(".md")) continue
|
||||||
|
const content = await fs.readFile(file, "utf8")
|
||||||
|
const rewritten = content
|
||||||
|
.replace(/~\/\.claude\//g, "~/.openclaw/")
|
||||||
|
.replace(/\.claude\//g, ".openclaw/")
|
||||||
|
.replace(/\.claude-plugin\//g, "openclaw-plugin/")
|
||||||
|
if (rewritten !== content) {
|
||||||
|
await fs.writeFile(file, rewritten, "utf8")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function mergeOpenClawConfig(
|
||||||
|
configPath: string,
|
||||||
|
incoming: Record<string, unknown>,
|
||||||
|
): Promise<Record<string, unknown>> {
|
||||||
|
if (!(await pathExists(configPath))) return incoming
|
||||||
|
|
||||||
|
let existing: Record<string, unknown>
|
||||||
|
try {
|
||||||
|
existing = await readJson<Record<string, unknown>>(configPath)
|
||||||
|
} catch {
|
||||||
|
console.warn(
|
||||||
|
`Warning: existing ${configPath} is not valid JSON. Writing plugin config without merging.`,
|
||||||
|
)
|
||||||
|
return incoming
|
||||||
|
}
|
||||||
|
|
||||||
|
// Merge MCP servers: existing takes precedence on conflict
|
||||||
|
const incomingMcp = (incoming.mcpServers ?? {}) as Record<string, unknown>
|
||||||
|
const existingMcp = (existing.mcpServers ?? {}) as Record<string, unknown>
|
||||||
|
const mergedMcp = { ...incomingMcp, ...existingMcp }
|
||||||
|
|
||||||
|
return {
|
||||||
|
...existing,
|
||||||
|
mcpServers: Object.keys(mergedMcp).length > 0 ? mergedMcp : undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
64
src/targets/qwen.ts
Normal file
64
src/targets/qwen.ts
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
import path from "path"
|
||||||
|
import { backupFile, copyDir, ensureDir, writeJson, writeText } from "../utils/files"
|
||||||
|
import type { QwenBundle, QwenExtensionConfig } from "../types/qwen"
|
||||||
|
|
||||||
|
export async function writeQwenBundle(outputRoot: string, bundle: QwenBundle): Promise<void> {
|
||||||
|
const qwenPaths = resolveQwenPaths(outputRoot)
|
||||||
|
await ensureDir(qwenPaths.root)
|
||||||
|
|
||||||
|
// Write qwen-extension.json config
|
||||||
|
const configPath = qwenPaths.configPath
|
||||||
|
const backupPath = await backupFile(configPath)
|
||||||
|
if (backupPath) {
|
||||||
|
console.log(`Backed up existing config to ${backupPath}`)
|
||||||
|
}
|
||||||
|
await writeJson(configPath, bundle.config)
|
||||||
|
|
||||||
|
// Write context file (QWEN.md)
|
||||||
|
if (bundle.contextFile) {
|
||||||
|
await writeText(qwenPaths.contextPath, bundle.contextFile + "\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write agents
|
||||||
|
const agentsDir = qwenPaths.agentsDir
|
||||||
|
await ensureDir(agentsDir)
|
||||||
|
for (const agent of bundle.agents) {
|
||||||
|
const ext = agent.format === "yaml" ? "yaml" : "md"
|
||||||
|
await writeText(path.join(agentsDir, `${agent.name}.${ext}`), agent.content + "\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write commands
|
||||||
|
const commandsDir = qwenPaths.commandsDir
|
||||||
|
await ensureDir(commandsDir)
|
||||||
|
for (const commandFile of bundle.commandFiles) {
|
||||||
|
// Support nested commands with colon separator
|
||||||
|
const parts = commandFile.name.split(":")
|
||||||
|
if (parts.length > 1) {
|
||||||
|
const nestedDir = path.join(commandsDir, ...parts.slice(0, -1))
|
||||||
|
await ensureDir(nestedDir)
|
||||||
|
await writeText(path.join(nestedDir, `${parts[parts.length - 1]}.md`), commandFile.content + "\n")
|
||||||
|
} else {
|
||||||
|
await writeText(path.join(commandsDir, `${commandFile.name}.md`), commandFile.content + "\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy skills
|
||||||
|
if (bundle.skillDirs.length > 0) {
|
||||||
|
const skillsRoot = qwenPaths.skillsDir
|
||||||
|
await ensureDir(skillsRoot)
|
||||||
|
for (const skill of bundle.skillDirs) {
|
||||||
|
await copyDir(skill.sourceDir, path.join(skillsRoot, skill.name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveQwenPaths(outputRoot: string) {
|
||||||
|
return {
|
||||||
|
root: outputRoot,
|
||||||
|
configPath: path.join(outputRoot, "qwen-extension.json"),
|
||||||
|
contextPath: path.join(outputRoot, "QWEN.md"),
|
||||||
|
agentsDir: path.join(outputRoot, "agents"),
|
||||||
|
commandsDir: path.join(outputRoot, "commands"),
|
||||||
|
skillsDir: path.join(outputRoot, "skills"),
|
||||||
|
}
|
||||||
|
}
|
||||||
52
src/types/openclaw.ts
Normal file
52
src/types/openclaw.ts
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
export type OpenClawPluginManifest = {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
kind: "tool"
|
||||||
|
configSchema?: {
|
||||||
|
type: "object"
|
||||||
|
additionalProperties: boolean
|
||||||
|
properties: Record<string, OpenClawConfigProperty>
|
||||||
|
required?: string[]
|
||||||
|
}
|
||||||
|
uiHints?: Record<string, OpenClawUiHint>
|
||||||
|
skills?: string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export type OpenClawConfigProperty = {
|
||||||
|
type: string
|
||||||
|
description?: string
|
||||||
|
default?: unknown
|
||||||
|
}
|
||||||
|
|
||||||
|
export type OpenClawUiHint = {
|
||||||
|
label: string
|
||||||
|
sensitive?: boolean
|
||||||
|
placeholder?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type OpenClawSkillFile = {
|
||||||
|
name: string
|
||||||
|
content: string
|
||||||
|
/** Subdirectory path inside skills/ (e.g. "agent-native-reviewer") */
|
||||||
|
dir: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type OpenClawCommandRegistration = {
|
||||||
|
name: string
|
||||||
|
description: string
|
||||||
|
acceptsArgs: boolean
|
||||||
|
/** The prompt body that becomes the command handler response */
|
||||||
|
body: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type OpenClawBundle = {
|
||||||
|
manifest: OpenClawPluginManifest
|
||||||
|
packageJson: Record<string, unknown>
|
||||||
|
entryPoint: string
|
||||||
|
skills: OpenClawSkillFile[]
|
||||||
|
/** Skill directories to copy verbatim (original Claude skills with references/) */
|
||||||
|
skillDirCopies: { sourceDir: string; name: string }[]
|
||||||
|
commands: OpenClawCommandRegistration[]
|
||||||
|
/** openclaw.json fragment for MCP servers */
|
||||||
|
openclawConfig?: Record<string, unknown>
|
||||||
|
}
|
||||||
48
src/types/qwen.ts
Normal file
48
src/types/qwen.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
export type QwenExtensionConfig = {
|
||||||
|
name: string
|
||||||
|
version: string
|
||||||
|
mcpServers?: Record<string, QwenMcpServer>
|
||||||
|
contextFileName?: string
|
||||||
|
commands?: string
|
||||||
|
skills?: string
|
||||||
|
agents?: string
|
||||||
|
settings?: QwenSetting[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export type QwenMcpServer = {
|
||||||
|
command?: string
|
||||||
|
args?: string[]
|
||||||
|
env?: Record<string, string>
|
||||||
|
cwd?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type QwenSetting = {
|
||||||
|
name: string
|
||||||
|
description: string
|
||||||
|
envVar: string
|
||||||
|
sensitive?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export type QwenAgentFile = {
|
||||||
|
name: string
|
||||||
|
content: string
|
||||||
|
format: "yaml" | "markdown"
|
||||||
|
}
|
||||||
|
|
||||||
|
export type QwenSkillDir = {
|
||||||
|
sourceDir: string
|
||||||
|
name: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type QwenCommandFile = {
|
||||||
|
name: string
|
||||||
|
content: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type QwenBundle = {
|
||||||
|
config: QwenExtensionConfig
|
||||||
|
agents: QwenAgentFile[]
|
||||||
|
commandFiles: QwenCommandFile[]
|
||||||
|
skillDirs: QwenSkillDir[]
|
||||||
|
contextFile?: string
|
||||||
|
}
|
||||||
@@ -7,10 +7,13 @@ export function resolveTargetOutputRoot(options: {
|
|||||||
outputRoot: string
|
outputRoot: string
|
||||||
codexHome: string
|
codexHome: string
|
||||||
piHome: string
|
piHome: string
|
||||||
|
openclawHome?: string
|
||||||
|
qwenHome?: string
|
||||||
|
pluginName?: string
|
||||||
hasExplicitOutput: boolean
|
hasExplicitOutput: boolean
|
||||||
scope?: TargetScope
|
scope?: TargetScope
|
||||||
}): string {
|
}): string {
|
||||||
const { targetName, outputRoot, codexHome, piHome, hasExplicitOutput, scope } = options
|
const { targetName, outputRoot, codexHome, piHome, openclawHome, qwenHome, pluginName, hasExplicitOutput, scope } = options
|
||||||
if (targetName === "codex") return codexHome
|
if (targetName === "codex") return codexHome
|
||||||
if (targetName === "pi") return piHome
|
if (targetName === "pi") return piHome
|
||||||
if (targetName === "droid") return path.join(os.homedir(), ".factory")
|
if (targetName === "droid") return path.join(os.homedir(), ".factory")
|
||||||
@@ -35,5 +38,13 @@ export function resolveTargetOutputRoot(options: {
|
|||||||
if (scope === "global") return path.join(os.homedir(), ".codeium", "windsurf")
|
if (scope === "global") return path.join(os.homedir(), ".codeium", "windsurf")
|
||||||
return path.join(process.cwd(), ".windsurf")
|
return path.join(process.cwd(), ".windsurf")
|
||||||
}
|
}
|
||||||
|
if (targetName === "openclaw") {
|
||||||
|
const home = openclawHome ?? path.join(os.homedir(), ".openclaw", "extensions")
|
||||||
|
return path.join(home, pluginName ?? "plugin")
|
||||||
|
}
|
||||||
|
if (targetName === "qwen") {
|
||||||
|
const home = qwenHome ?? path.join(os.homedir(), ".qwen", "extensions")
|
||||||
|
return path.join(home, pluginName ?? "plugin")
|
||||||
|
}
|
||||||
return outputRoot
|
return outputRoot
|
||||||
}
|
}
|
||||||
|
|||||||
200
tests/openclaw-converter.test.ts
Normal file
200
tests/openclaw-converter.test.ts
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
import { describe, expect, test } from "bun:test"
|
||||||
|
import { convertClaudeToOpenClaw } from "../src/converters/claude-to-openclaw"
|
||||||
|
import { parseFrontmatter } from "../src/utils/frontmatter"
|
||||||
|
import type { ClaudePlugin } from "../src/types/claude"
|
||||||
|
|
||||||
|
const fixturePlugin: ClaudePlugin = {
|
||||||
|
root: "/tmp/plugin",
|
||||||
|
manifest: { name: "compound-engineering", version: "1.0.0", description: "A plugin" },
|
||||||
|
agents: [
|
||||||
|
{
|
||||||
|
name: "security-reviewer",
|
||||||
|
description: "Security-focused agent",
|
||||||
|
capabilities: ["Threat modeling", "OWASP"],
|
||||||
|
model: "claude-sonnet-4-20250514",
|
||||||
|
body: "Focus on vulnerabilities in ~/.claude/settings.",
|
||||||
|
sourcePath: "/tmp/plugin/agents/security-reviewer.md",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
commands: [
|
||||||
|
{
|
||||||
|
name: "workflows:plan",
|
||||||
|
description: "Planning command",
|
||||||
|
argumentHint: "[FOCUS]",
|
||||||
|
model: "inherit",
|
||||||
|
allowedTools: ["Read"],
|
||||||
|
body: "Plan the work. See ~/.claude/settings for config.",
|
||||||
|
sourcePath: "/tmp/plugin/commands/workflows/plan.md",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "disabled-cmd",
|
||||||
|
description: "Disabled command",
|
||||||
|
model: "inherit",
|
||||||
|
allowedTools: [],
|
||||||
|
body: "Should be excluded.",
|
||||||
|
disableModelInvocation: true,
|
||||||
|
sourcePath: "/tmp/plugin/commands/disabled-cmd.md",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
skills: [
|
||||||
|
{
|
||||||
|
name: "existing-skill",
|
||||||
|
description: "Existing skill",
|
||||||
|
sourceDir: "/tmp/plugin/skills/existing-skill",
|
||||||
|
skillPath: "/tmp/plugin/skills/existing-skill/SKILL.md",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
hooks: undefined,
|
||||||
|
mcpServers: {
|
||||||
|
local: { command: "npx", args: ["-y", "some-mcp-server"] },
|
||||||
|
remote: { url: "https://mcp.example.com/api", headers: { Authorization: "Bearer token" } },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultOptions = {
|
||||||
|
agentMode: "subagent" as const,
|
||||||
|
inferTemperature: false,
|
||||||
|
permissions: "none" as const,
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("convertClaudeToOpenClaw", () => {
|
||||||
|
test("converts agents to skill files with SKILL.md content", () => {
|
||||||
|
const bundle = convertClaudeToOpenClaw(fixturePlugin, defaultOptions)
|
||||||
|
|
||||||
|
const skill = bundle.skills.find((s) => s.name === "security-reviewer")
|
||||||
|
expect(skill).toBeDefined()
|
||||||
|
expect(skill!.dir).toBe("agent-security-reviewer")
|
||||||
|
const parsed = parseFrontmatter(skill!.content)
|
||||||
|
expect(parsed.data.name).toBe("security-reviewer")
|
||||||
|
expect(parsed.data.description).toBe("Security-focused agent")
|
||||||
|
expect(parsed.data.model).toBe("claude-sonnet-4-20250514")
|
||||||
|
expect(parsed.body).toContain("Focus on vulnerabilities")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("converts commands to skill files (excluding disableModelInvocation)", () => {
|
||||||
|
const bundle = convertClaudeToOpenClaw(fixturePlugin, defaultOptions)
|
||||||
|
|
||||||
|
const cmdSkill = bundle.skills.find((s) => s.name === "workflows:plan")
|
||||||
|
expect(cmdSkill).toBeDefined()
|
||||||
|
expect(cmdSkill!.dir).toBe("cmd-workflows:plan")
|
||||||
|
|
||||||
|
const disabledSkill = bundle.skills.find((s) => s.name === "disabled-cmd")
|
||||||
|
expect(disabledSkill).toBeUndefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
test("commands list excludes disableModelInvocation commands", () => {
|
||||||
|
const bundle = convertClaudeToOpenClaw(fixturePlugin, defaultOptions)
|
||||||
|
|
||||||
|
const cmd = bundle.commands.find((c) => c.name === "workflows-plan")
|
||||||
|
expect(cmd).toBeDefined()
|
||||||
|
expect(cmd!.description).toBe("Planning command")
|
||||||
|
expect(cmd!.acceptsArgs).toBe(true)
|
||||||
|
|
||||||
|
const disabled = bundle.commands.find((c) => c.name === "disabled-cmd")
|
||||||
|
expect(disabled).toBeUndefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
test("command colons are replaced with dashes in command registrations", () => {
|
||||||
|
const bundle = convertClaudeToOpenClaw(fixturePlugin, defaultOptions)
|
||||||
|
|
||||||
|
const cmd = bundle.commands.find((c) => c.name === "workflows-plan")
|
||||||
|
expect(cmd).toBeDefined()
|
||||||
|
expect(cmd!.name).not.toContain(":")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("manifest includes plugin id, display name, and skills list", () => {
|
||||||
|
const bundle = convertClaudeToOpenClaw(fixturePlugin, defaultOptions)
|
||||||
|
|
||||||
|
expect(bundle.manifest.id).toBe("compound-engineering")
|
||||||
|
expect(bundle.manifest.name).toBe("Compound Engineering")
|
||||||
|
expect(bundle.manifest.kind).toBe("tool")
|
||||||
|
expect(bundle.manifest.skills).toContain("skills/agent-security-reviewer")
|
||||||
|
expect(bundle.manifest.skills).toContain("skills/cmd-workflows:plan")
|
||||||
|
expect(bundle.manifest.skills).toContain("skills/existing-skill")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("package.json uses plugin name and version", () => {
|
||||||
|
const bundle = convertClaudeToOpenClaw(fixturePlugin, defaultOptions)
|
||||||
|
|
||||||
|
expect(bundle.packageJson.name).toBe("openclaw-compound-engineering")
|
||||||
|
expect(bundle.packageJson.version).toBe("1.0.0")
|
||||||
|
expect(bundle.packageJson.type).toBe("module")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("skillDirCopies includes original skill directories", () => {
|
||||||
|
const bundle = convertClaudeToOpenClaw(fixturePlugin, defaultOptions)
|
||||||
|
|
||||||
|
const copy = bundle.skillDirCopies.find((s) => s.name === "existing-skill")
|
||||||
|
expect(copy).toBeDefined()
|
||||||
|
expect(copy!.sourceDir).toBe("/tmp/plugin/skills/existing-skill")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("stdio MCP servers included in openclaw config", () => {
|
||||||
|
const bundle = convertClaudeToOpenClaw(fixturePlugin, defaultOptions)
|
||||||
|
|
||||||
|
expect(bundle.openclawConfig).toBeDefined()
|
||||||
|
const mcp = (bundle.openclawConfig!.mcpServers as Record<string, unknown>)
|
||||||
|
expect(mcp.local).toBeDefined()
|
||||||
|
expect((mcp.local as any).type).toBe("stdio")
|
||||||
|
expect((mcp.local as any).command).toBe("npx")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("HTTP MCP servers included as http type in openclaw config", () => {
|
||||||
|
const bundle = convertClaudeToOpenClaw(fixturePlugin, defaultOptions)
|
||||||
|
|
||||||
|
const mcp = (bundle.openclawConfig!.mcpServers as Record<string, unknown>)
|
||||||
|
expect(mcp.remote).toBeDefined()
|
||||||
|
expect((mcp.remote as any).type).toBe("http")
|
||||||
|
expect((mcp.remote as any).url).toBe("https://mcp.example.com/api")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("paths are rewritten from .claude/ to .openclaw/ in skill content", () => {
|
||||||
|
const bundle = convertClaudeToOpenClaw(fixturePlugin, defaultOptions)
|
||||||
|
|
||||||
|
const agentSkill = bundle.skills.find((s) => s.name === "security-reviewer")
|
||||||
|
expect(agentSkill!.content).toContain("~/.openclaw/settings")
|
||||||
|
expect(agentSkill!.content).not.toContain("~/.claude/settings")
|
||||||
|
|
||||||
|
const cmdSkill = bundle.skills.find((s) => s.name === "workflows:plan")
|
||||||
|
expect(cmdSkill!.content).toContain("~/.openclaw/settings")
|
||||||
|
expect(cmdSkill!.content).not.toContain("~/.claude/settings")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("generateEntryPoint uses JSON.stringify for safe string escaping", () => {
|
||||||
|
const plugin: ClaudePlugin = {
|
||||||
|
...fixturePlugin,
|
||||||
|
commands: [
|
||||||
|
{
|
||||||
|
name: "tricky-cmd",
|
||||||
|
description: 'Has "quotes" and \\backslashes\\ and\nnewlines',
|
||||||
|
model: "inherit",
|
||||||
|
allowedTools: [],
|
||||||
|
body: "body",
|
||||||
|
sourcePath: "/tmp/cmd.md",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
const bundle = convertClaudeToOpenClaw(plugin, defaultOptions)
|
||||||
|
|
||||||
|
// Entry point must be valid JS/TS — JSON.stringify handles all special chars
|
||||||
|
expect(bundle.entryPoint).toContain('"tricky-cmd"')
|
||||||
|
expect(bundle.entryPoint).toContain('\\"quotes\\"')
|
||||||
|
expect(bundle.entryPoint).toContain("\\\\backslashes\\\\")
|
||||||
|
expect(bundle.entryPoint).toContain("\\n")
|
||||||
|
// No raw unescaped newline inside a string literal
|
||||||
|
const lines = bundle.entryPoint.split("\n")
|
||||||
|
const nameLine = lines.find((l) => l.includes("tricky-cmd") && l.includes("name:"))
|
||||||
|
expect(nameLine).toBeDefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
test("generateEntryPoint emits typed skills record", () => {
|
||||||
|
const bundle = convertClaudeToOpenClaw(fixturePlugin, defaultOptions)
|
||||||
|
expect(bundle.entryPoint).toContain("const skills: Record<string, string> = {}")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("plugin without MCP servers has no openclawConfig", () => {
|
||||||
|
const plugin: ClaudePlugin = { ...fixturePlugin, mcpServers: undefined }
|
||||||
|
const bundle = convertClaudeToOpenClaw(plugin, defaultOptions)
|
||||||
|
expect(bundle.openclawConfig).toBeUndefined()
|
||||||
|
})
|
||||||
|
})
|
||||||
238
tests/qwen-converter.test.ts
Normal file
238
tests/qwen-converter.test.ts
Normal file
@@ -0,0 +1,238 @@
|
|||||||
|
import { describe, expect, test } from "bun:test"
|
||||||
|
import { convertClaudeToQwen } from "../src/converters/claude-to-qwen"
|
||||||
|
import { parseFrontmatter } from "../src/utils/frontmatter"
|
||||||
|
import type { ClaudePlugin } from "../src/types/claude"
|
||||||
|
|
||||||
|
const fixturePlugin: ClaudePlugin = {
|
||||||
|
root: "/tmp/plugin",
|
||||||
|
manifest: { name: "compound-engineering", version: "1.2.0", description: "A plugin for engineers" },
|
||||||
|
agents: [
|
||||||
|
{
|
||||||
|
name: "security-sentinel",
|
||||||
|
description: "Security-focused agent",
|
||||||
|
capabilities: ["Threat modeling", "OWASP"],
|
||||||
|
model: "claude-sonnet-4-20250514",
|
||||||
|
body: "Focus on vulnerabilities in ~/.claude/settings.",
|
||||||
|
sourcePath: "/tmp/plugin/agents/security-sentinel.md",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "brainstorm-agent",
|
||||||
|
description: "Creative brainstormer",
|
||||||
|
model: "inherit",
|
||||||
|
body: "Generate ideas.",
|
||||||
|
sourcePath: "/tmp/plugin/agents/brainstorm-agent.md",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
commands: [
|
||||||
|
{
|
||||||
|
name: "workflows:plan",
|
||||||
|
description: "Planning command",
|
||||||
|
argumentHint: "[FOCUS]",
|
||||||
|
model: "inherit",
|
||||||
|
allowedTools: ["Read"],
|
||||||
|
body: "Plan the work. Config at ~/.claude/settings.",
|
||||||
|
sourcePath: "/tmp/plugin/commands/workflows/plan.md",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "disabled-cmd",
|
||||||
|
description: "Disabled",
|
||||||
|
model: "inherit",
|
||||||
|
allowedTools: [],
|
||||||
|
body: "Should be excluded.",
|
||||||
|
disableModelInvocation: true,
|
||||||
|
sourcePath: "/tmp/plugin/commands/disabled-cmd.md",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
skills: [
|
||||||
|
{
|
||||||
|
name: "existing-skill",
|
||||||
|
description: "Existing skill",
|
||||||
|
sourceDir: "/tmp/plugin/skills/existing-skill",
|
||||||
|
skillPath: "/tmp/plugin/skills/existing-skill/SKILL.md",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
hooks: undefined,
|
||||||
|
mcpServers: {
|
||||||
|
local: { command: "npx", args: ["-y", "some-mcp"], env: { API_KEY: "${YOUR_API_KEY}" } },
|
||||||
|
remote: { url: "https://mcp.example.com/api", headers: { Authorization: "Bearer token" } },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultOptions = {
|
||||||
|
agentMode: "subagent" as const,
|
||||||
|
inferTemperature: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("convertClaudeToQwen", () => {
|
||||||
|
test("converts agents to yaml format with frontmatter", () => {
|
||||||
|
const bundle = convertClaudeToQwen(fixturePlugin, defaultOptions)
|
||||||
|
|
||||||
|
const agent = bundle.agents.find((a) => a.name === "security-sentinel")
|
||||||
|
expect(agent).toBeDefined()
|
||||||
|
expect(agent!.format).toBe("yaml")
|
||||||
|
const parsed = parseFrontmatter(agent!.content)
|
||||||
|
expect(parsed.data.name).toBe("security-sentinel")
|
||||||
|
expect(parsed.data.description).toBe("Security-focused agent")
|
||||||
|
expect(parsed.data.model).toBe("anthropic/claude-sonnet-4-20250514")
|
||||||
|
expect(parsed.body).toContain("Focus on vulnerabilities")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("agent with inherit model has no model field in frontmatter", () => {
|
||||||
|
const bundle = convertClaudeToQwen(fixturePlugin, defaultOptions)
|
||||||
|
const agent = bundle.agents.find((a) => a.name === "brainstorm-agent")
|
||||||
|
expect(agent).toBeDefined()
|
||||||
|
const parsed = parseFrontmatter(agent!.content)
|
||||||
|
expect(parsed.data.model).toBeUndefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
test("inferTemperature injects temperature based on agent name/description", () => {
|
||||||
|
const bundle = convertClaudeToQwen(fixturePlugin, { ...defaultOptions, inferTemperature: true })
|
||||||
|
|
||||||
|
const sentinel = bundle.agents.find((a) => a.name === "security-sentinel")
|
||||||
|
const parsed = parseFrontmatter(sentinel!.content)
|
||||||
|
expect(parsed.data.temperature).toBe(0.1) // review/security → 0.1
|
||||||
|
|
||||||
|
const brainstorm = bundle.agents.find((a) => a.name === "brainstorm-agent")
|
||||||
|
const bParsed = parseFrontmatter(brainstorm!.content)
|
||||||
|
expect(bParsed.data.temperature).toBe(0.6) // brainstorm → 0.6
|
||||||
|
})
|
||||||
|
|
||||||
|
test("inferTemperature returns undefined for unrecognized agents (no temperature set)", () => {
|
||||||
|
const plugin: ClaudePlugin = {
|
||||||
|
...fixturePlugin,
|
||||||
|
agents: [{ name: "my-helper", description: "Generic helper", model: "inherit", body: "help", sourcePath: "/tmp/a.md" }],
|
||||||
|
}
|
||||||
|
const bundle = convertClaudeToQwen(plugin, { ...defaultOptions, inferTemperature: true })
|
||||||
|
const agent = bundle.agents[0]
|
||||||
|
const parsed = parseFrontmatter(agent.content)
|
||||||
|
expect(parsed.data.temperature).toBeUndefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
test("converts commands to command files excluding disableModelInvocation", () => {
|
||||||
|
const bundle = convertClaudeToQwen(fixturePlugin, defaultOptions)
|
||||||
|
|
||||||
|
const planCmd = bundle.commandFiles.find((c) => c.name === "workflows:plan")
|
||||||
|
expect(planCmd).toBeDefined()
|
||||||
|
const parsed = parseFrontmatter(planCmd!.content)
|
||||||
|
expect(parsed.data.description).toBe("Planning command")
|
||||||
|
expect(parsed.data.allowedTools).toEqual(["Read"])
|
||||||
|
|
||||||
|
const disabled = bundle.commandFiles.find((c) => c.name === "disabled-cmd")
|
||||||
|
expect(disabled).toBeUndefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
test("config uses plugin manifest name and version", () => {
|
||||||
|
const bundle = convertClaudeToQwen(fixturePlugin, defaultOptions)
|
||||||
|
expect(bundle.config.name).toBe("compound-engineering")
|
||||||
|
expect(bundle.config.version).toBe("1.2.0")
|
||||||
|
expect(bundle.config.commands).toBe("commands")
|
||||||
|
expect(bundle.config.skills).toBe("skills")
|
||||||
|
expect(bundle.config.agents).toBe("agents")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("stdio MCP servers are included in config", () => {
|
||||||
|
const bundle = convertClaudeToQwen(fixturePlugin, defaultOptions)
|
||||||
|
expect(bundle.config.mcpServers).toBeDefined()
|
||||||
|
const local = bundle.config.mcpServers!.local
|
||||||
|
expect(local.command).toBe("npx")
|
||||||
|
expect(local.args).toEqual(["-y", "some-mcp"])
|
||||||
|
// No cwd field
|
||||||
|
expect((local as any).cwd).toBeUndefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
test("remote MCP servers are skipped with a warning (not converted to curl)", () => {
|
||||||
|
const bundle = convertClaudeToQwen(fixturePlugin, defaultOptions)
|
||||||
|
// Only local (stdio) server should be present
|
||||||
|
expect(bundle.config.mcpServers).toBeDefined()
|
||||||
|
expect(bundle.config.mcpServers!.remote).toBeUndefined()
|
||||||
|
expect(bundle.config.mcpServers!.local).toBeDefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
test("placeholder env vars are extracted as settings", () => {
|
||||||
|
const bundle = convertClaudeToQwen(fixturePlugin, defaultOptions)
|
||||||
|
expect(bundle.config.settings).toBeDefined()
|
||||||
|
const apiKeySetting = bundle.config.settings!.find((s) => s.envVar === "API_KEY")
|
||||||
|
expect(apiKeySetting).toBeDefined()
|
||||||
|
expect(apiKeySetting!.sensitive).toBe(true)
|
||||||
|
expect(apiKeySetting!.name).toBe("Api Key")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("plugin with no MCP servers has no mcpServers in config", () => {
|
||||||
|
const plugin: ClaudePlugin = { ...fixturePlugin, mcpServers: undefined }
|
||||||
|
const bundle = convertClaudeToQwen(plugin, defaultOptions)
|
||||||
|
expect(bundle.config.mcpServers).toBeUndefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
test("context file uses plugin.manifest.name and manifest.description", () => {
|
||||||
|
const bundle = convertClaudeToQwen(fixturePlugin, defaultOptions)
|
||||||
|
expect(bundle.contextFile).toContain("# compound-engineering")
|
||||||
|
expect(bundle.contextFile).toContain("A plugin for engineers")
|
||||||
|
expect(bundle.contextFile).toContain("## Agents")
|
||||||
|
expect(bundle.contextFile).toContain("security-sentinel")
|
||||||
|
expect(bundle.contextFile).toContain("## Commands")
|
||||||
|
expect(bundle.contextFile).toContain("/workflows:plan")
|
||||||
|
// Disabled commands excluded
|
||||||
|
expect(bundle.contextFile).not.toContain("disabled-cmd")
|
||||||
|
expect(bundle.contextFile).toContain("## Skills")
|
||||||
|
expect(bundle.contextFile).toContain("existing-skill")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("paths are rewritten from .claude/ to .qwen/ in agent and command content", () => {
|
||||||
|
const bundle = convertClaudeToQwen(fixturePlugin, defaultOptions)
|
||||||
|
|
||||||
|
const agent = bundle.agents.find((a) => a.name === "security-sentinel")
|
||||||
|
expect(agent!.content).toContain("~/.qwen/settings")
|
||||||
|
expect(agent!.content).not.toContain("~/.claude/settings")
|
||||||
|
|
||||||
|
const cmd = bundle.commandFiles.find((c) => c.name === "workflows:plan")
|
||||||
|
expect(cmd!.content).toContain("~/.qwen/settings")
|
||||||
|
expect(cmd!.content).not.toContain("~/.claude/settings")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("opencode paths are NOT rewritten (only claude paths)", () => {
|
||||||
|
const plugin: ClaudePlugin = {
|
||||||
|
...fixturePlugin,
|
||||||
|
agents: [
|
||||||
|
{
|
||||||
|
name: "test-agent",
|
||||||
|
description: "test",
|
||||||
|
model: "inherit",
|
||||||
|
body: "See .opencode/config and ~/.config/opencode/settings",
|
||||||
|
sourcePath: "/tmp/a.md",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
const bundle = convertClaudeToQwen(plugin, defaultOptions)
|
||||||
|
const agent = bundle.agents[0]
|
||||||
|
// opencode paths should NOT be rewritten
|
||||||
|
expect(agent.content).toContain(".opencode/config")
|
||||||
|
expect(agent.content).not.toContain(".qwen/config")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("skillDirs passes through original skills", () => {
|
||||||
|
const bundle = convertClaudeToQwen(fixturePlugin, defaultOptions)
|
||||||
|
const skill = bundle.skillDirs.find((s) => s.name === "existing-skill")
|
||||||
|
expect(skill).toBeDefined()
|
||||||
|
expect(skill!.sourceDir).toBe("/tmp/plugin/skills/existing-skill")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("normalizeModel prefixes claude models with anthropic/", () => {
|
||||||
|
const plugin: ClaudePlugin = {
|
||||||
|
...fixturePlugin,
|
||||||
|
agents: [{ name: "a", description: "d", model: "claude-opus-4-5", body: "b", sourcePath: "/tmp/a.md" }],
|
||||||
|
}
|
||||||
|
const bundle = convertClaudeToQwen(plugin, defaultOptions)
|
||||||
|
const parsed = parseFrontmatter(bundle.agents[0].content)
|
||||||
|
expect(parsed.data.model).toBe("anthropic/claude-opus-4-5")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("normalizeModel passes through already-namespaced models unchanged", () => {
|
||||||
|
const plugin: ClaudePlugin = {
|
||||||
|
...fixturePlugin,
|
||||||
|
agents: [{ name: "a", description: "d", model: "google/gemini-2.0", body: "b", sourcePath: "/tmp/a.md" }],
|
||||||
|
}
|
||||||
|
const bundle = convertClaudeToQwen(plugin, defaultOptions)
|
||||||
|
const parsed = parseFrontmatter(bundle.agents[0].content)
|
||||||
|
expect(parsed.data.model).toBe("google/gemini-2.0")
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -90,4 +90,42 @@ describe("resolveTargetOutputRoot", () => {
|
|||||||
const result = resolveTargetOutputRoot({ ...baseOptions, targetName: "opencode" })
|
const result = resolveTargetOutputRoot({ ...baseOptions, targetName: "opencode" })
|
||||||
expect(result).toBe("/tmp/output")
|
expect(result).toBe("/tmp/output")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("openclaw uses openclawHome + pluginName", () => {
|
||||||
|
const result = resolveTargetOutputRoot({
|
||||||
|
...baseOptions,
|
||||||
|
targetName: "openclaw",
|
||||||
|
openclawHome: "/custom/openclaw/extensions",
|
||||||
|
pluginName: "my-plugin",
|
||||||
|
})
|
||||||
|
expect(result).toBe("/custom/openclaw/extensions/my-plugin")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("openclaw falls back to default home when not provided", () => {
|
||||||
|
const result = resolveTargetOutputRoot({
|
||||||
|
...baseOptions,
|
||||||
|
targetName: "openclaw",
|
||||||
|
pluginName: "my-plugin",
|
||||||
|
})
|
||||||
|
expect(result).toBe(path.join(os.homedir(), ".openclaw", "extensions", "my-plugin"))
|
||||||
|
})
|
||||||
|
|
||||||
|
test("qwen uses qwenHome + pluginName", () => {
|
||||||
|
const result = resolveTargetOutputRoot({
|
||||||
|
...baseOptions,
|
||||||
|
targetName: "qwen",
|
||||||
|
qwenHome: "/custom/qwen/extensions",
|
||||||
|
pluginName: "my-plugin",
|
||||||
|
})
|
||||||
|
expect(result).toBe("/custom/qwen/extensions/my-plugin")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("qwen falls back to default home when not provided", () => {
|
||||||
|
const result = resolveTargetOutputRoot({
|
||||||
|
...baseOptions,
|
||||||
|
targetName: "qwen",
|
||||||
|
pluginName: "my-plugin",
|
||||||
|
})
|
||||||
|
expect(result).toBe(path.join(os.homedir(), ".qwen", "extensions", "my-plugin"))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user