fix: Address review findings in Qwen converter

- Fix P1: Remove dead TOOL_MAP constant (defined but never referenced)
- Fix P1: Replace curl fallback for remote MCP servers with warn-and-skip,
  matching the kiro pattern — curl is not an MCP server
- Fix P1: Remove incorrect literal cwd field ("${extensionPath}${/}") from
  stdio MCP server config; the value was never interpolated
- Fix P1: Fix plugin.name → plugin.manifest.name in generateContextFile
  (plugin.name does not exist on ClaudePlugin; produced "# undefined")
- Fix P1: Wire qwenHome through resolveTargetOutputRoot; previously the
  --qwen-home CLI flag was parsed but silently discarded
- Fix P1: Remove hardcoded "compound-engineering" from qwen output path;
  now uses plugin.manifest.name via new qwenHome + pluginName params
- Fix P1: Collapse dead-code resolveQwenPaths branches (both returned
  identical structures; simplify to a single return)
- Fix P3: Remove rewriting of .opencode/ paths to .qwen/ — Claude plugins
  do not reference opencode paths, and rewriting them is incorrect
- Fix P3: inferTemperature now returns undefined for unrecognized agents
  instead of 0.3 (matching the explicit doc branch), letting the model
  use its default temperature
- Fix P2: Add lookbehind guards to rewriteQwenPaths() matching kiro pattern
  to avoid rewriting paths inside compound tokens or URLs
- Update --qwen-home default to ~/.qwen/extensions (plugin name appended)
- Add qwen-converter.test.ts with 16 tests covering all scenarios

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Kieran Klaassen
2026-03-01 14:38:42 -08:00
parent e1d5bdedb3
commit 305fea486f
4 changed files with 255 additions and 57 deletions

View File

@@ -45,7 +45,7 @@ export default defineCommand({
qwenHome: {
type: "string",
alias: "qwen-home",
description: "Write Qwen output to this Qwen extensions root (ex: ~/.qwen/extensions/compound-engineering)",
description: "Write Qwen output to this Qwen extensions root (ex: ~/.qwen/extensions)",
},
also: {
type: "string",
@@ -89,7 +89,7 @@ export default defineCommand({
const outputRoot = resolveOutputRoot(args.output)
const codexHome = resolveTargetHome(args.codexHome, path.join(os.homedir(), ".codex"))
const piHome = resolveTargetHome(args.piHome, path.join(os.homedir(), ".pi", "agent"))
const qwenHome = resolveTargetHome(args.qwenHome, path.join(os.homedir(), ".qwen", "extensions", "compound-engineering"))
const qwenHome = resolveTargetHome(args.qwenHome, path.join(os.homedir(), ".qwen", "extensions"))
const options = {
agentMode: String(args.agentMode) === "primary" ? "primary" : "subagent",
@@ -102,7 +102,7 @@ export default defineCommand({
throw new Error(`Target ${targetName} did not return a bundle.`)
}
const hasExplicitOutput = Boolean(args.output && String(args.output).trim())
const primaryOutputRoot = resolveTargetOutputRoot(targetName, outputRoot, codexHome, piHome, hasExplicitOutput)
const primaryOutputRoot = resolveTargetOutputRoot(targetName, outputRoot, codexHome, piHome, qwenHome, plugin.manifest.name, hasExplicitOutput)
await target.write(primaryOutputRoot, bundle)
console.log(`Installed ${plugin.manifest.name} to ${primaryOutputRoot}`)
@@ -123,7 +123,7 @@ export default defineCommand({
console.warn(`Skipping ${extra}: no output returned.`)
continue
}
const extraRoot = resolveTargetOutputRoot(extra, path.join(outputRoot, extra), codexHome, piHome, hasExplicitOutput)
const extraRoot = resolveTargetOutputRoot(extra, path.join(outputRoot, extra), codexHome, piHome, qwenHome, plugin.manifest.name, hasExplicitOutput)
await handler.write(extraRoot, extraBundle)
console.log(`Installed ${plugin.manifest.name} to ${extraRoot}`)
}
@@ -180,13 +180,14 @@ function resolveTargetOutputRoot(
outputRoot: string,
codexHome: string,
piHome: string,
qwenHome: string,
pluginName: string,
hasExplicitOutput: boolean,
): string {
if (targetName === "codex") return codexHome
if (targetName === "pi") return piHome
if (targetName === "qwen") {
const base = hasExplicitOutput ? outputRoot : path.join(os.homedir(), ".qwen", "extensions")
return path.join(base, "compound-engineering")
return path.join(qwenHome, pluginName)
}
if (targetName === "droid") return path.join(os.homedir(), ".factory")
if (targetName === "cursor") {

View File

@@ -14,23 +14,6 @@ export type ClaudeToQwenOptions = {
inferTemperature: boolean
}
const TOOL_MAP: Record<string, string> = {
bash: "bash",
read: "read",
write: "write",
edit: "edit",
grep: "grep",
glob: "glob",
list: "list",
webfetch: "webfetch",
skill: "skill",
patch: "patch",
task: "task",
question: "question",
todowrite: "todowrite",
todoread: "todoread",
}
export function convertClaudeToQwen(plugin: ClaudePlugin, options: ClaudeToQwenOptions): QwenBundle {
const agentFiles = plugin.agents.map((agent) => convertAgent(agent, options))
const cmdFiles = convertCommands(plugin.commands)
@@ -119,20 +102,15 @@ function convertMcp(servers: Record<string, ClaudeMcpServer>): Record<string, Qw
command: server.command,
args: server.args,
env: server.env,
cwd: "${extensionPath}${/}",
}
continue
}
if (server.url) {
// Qwen doesn't support remote MCP servers in the same way
// Convert to local with proxy or skip
console.warn(`Warning: Remote MCP server '${name}' with URL ${server.url} is not fully supported in Qwen format`)
result[name] = {
command: "curl",
args: [server.url],
env: server.headers,
}
// 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
@@ -172,10 +150,10 @@ function generateContextFile(plugin: ClaudePlugin): string {
const sections: string[] = []
// Plugin description
sections.push(`# ${plugin.name}`)
sections.push(`# ${plugin.manifest.name}`)
sections.push("")
if (plugin.description) {
sections.push(plugin.description)
if (plugin.manifest.description) {
sections.push(plugin.manifest.description)
sections.push("")
}
@@ -216,10 +194,8 @@ function generateContextFile(plugin: ClaudePlugin): string {
function rewriteQwenPaths(body: string): string {
return body
.replace(/~\/\.claude\//g, "~/.qwen/")
.replace(/\.claude\//g, ".qwen/")
.replace(/~\/\.config\/opencode\//g, "~/.qwen/")
.replace(/\.opencode\//g, ".qwen/")
.replace(/(?<=^|\s|["'`])~\/\.claude\//gm, "~/.qwen/")
.replace(/(?<=^|\s|["'`])\.claude\//gm, ".qwen/")
}
const CLAUDE_FAMILY_ALIASES: Record<string, string> = {
@@ -258,5 +234,5 @@ function inferTemperature(agent: ClaudeAgent): number | undefined {
if (/(brainstorm|creative|ideate|design|concept)/.test(sample)) {
return 0.6
}
return 0.3
return undefined
}

View File

@@ -53,23 +53,6 @@ export async function writeQwenBundle(outputRoot: string, bundle: QwenBundle): P
}
function resolveQwenPaths(outputRoot: string) {
const base = path.basename(outputRoot)
// Global install: ~/.qwen/extensions/<extension-name>
// Project install: .qwen/extensions/<extension-name> or <extension-name> at root
// If the output root already ends with "extensions" or contains ".qwen/extensions", write directly
if (base === "extensions" || outputRoot.includes(".qwen/extensions")) {
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"),
}
}
// Custom output directory - write directly to the output root (not nested)
// This is for project-level installs like ./my-extension
return {
root: outputRoot,
configPath: path.join(outputRoot, "qwen-extension.json"),