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:
Kieran Klaassen
2026-03-01 14:53:42 -08:00
17 changed files with 1297 additions and 11 deletions

View 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()
})
})

View 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")
})
})

View File

@@ -90,4 +90,42 @@ describe("resolveTargetOutputRoot", () => {
const result = resolveTargetOutputRoot({ ...baseOptions, targetName: "opencode" })
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"))
})
})