The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
fix(qwen): publish the adapter, handle CRLF, reject unknown flags
zakyirsyaad93e64754205b
diff --git a/package.json b/package.jsonindex 983370b3a..416c34a7d 100644--- a/package.json+++ b/package.json@@ -124,6 +124,7 @@"scripts/memory.js","scripts/memory-mcp.mjs","scripts/gemini-adapt-agents.js",+ "scripts/qwen-adapt-agents.js","scripts/harness-adapter-compliance.js","scripts/harness-audit.js","scripts/eval-harness.js",diff --git a/scripts/qwen-adapt-agents.js b/scripts/qwen-adapt-agents.jsindex 763a922e5..2ba199d6b 100644--- a/scripts/qwen-adapt-agents.js+++ b/scripts/qwen-adapt-agents.js@@ -59,7 +59,17 @@ function parseArgs(argv) {return { help: true };}- const positional = argv.filter(arg => !arg.startsWith('-'));+ const positional = [];+ for (const arg of argv) {+ if (arg.startsWith('-')) {+ // Reject rather than ignore. This script rewrites files in place, so+ // silently discarding an unrecognized flag would let `--dry-run` — or any+ // mistyped option — modify every installed agent and still exit 0.+ throw new Error(`Unknown option: ${arg}`);+ }+ positional.push(arg);+ }+if (positional.length > 1) {throw new Error('Expected at most one agents directory argument');}@@ -126,7 +136,13 @@ function adaptColor(line) {}function adaptFrontmatter(text) {- const match = text.match(/^---\n([\s\S]*?)\n---(\n|$)/);+ // Normalize CRLF first. Matching only LF would silently skip a Windows-saved+ // agent and report it as already compatible while `tools: Read` and+ // `color: teal` stayed in place. The original ending style is restored below.+ const usesCrlf = text.includes('\r\n');+ const source = usesCrlf ? text.replace(/\r\n/g, '\n') : text;++ const match = source.match(/^---\n([\s\S]*?)\n---(\n|$)/);if (!match) {return { text, changed: false };}@@ -174,8 +190,10 @@ function adaptFrontmatter(text) {return { text, changed: false };}+ const adapted = `---\n${updatedLines.join('\n')}\n---${match[2]}${source.slice(match[0].length)}`;+return {- text: `---\n${updatedLines.join('\n')}\n---${match[2]}${text.slice(match[0].length)}`,+ text: usesCrlf ? adapted.replace(/\n/g, '\r\n') : adapted,changed: true,};}diff --git a/tests/scripts/npm-publish-surface.test.js b/tests/scripts/npm-publish-surface.test.jsindex 02ca28943..a73b644c4 100644--- a/tests/scripts/npm-publish-surface.test.js+++ b/tests/scripts/npm-publish-surface.test.js@@ -83,6 +83,7 @@ function buildExpectedPublishPaths(repoRoot) {"scripts/uninstall.js","scripts/welcome.js","scripts/gemini-adapt-agents.js",+ "scripts/qwen-adapt-agents.js","scripts/sync-ecc-to-codex.sh","scripts/codex/legacy-sync-state.js","scripts/codex/install-global-git-hooks.sh",diff --git a/tests/scripts/qwen-adapt-agents.test.js b/tests/scripts/qwen-adapt-agents.test.jsindex e6640ee4b..1d71b2bed 100644--- a/tests/scripts/qwen-adapt-agents.test.js+++ b/tests/scripts/qwen-adapt-agents.test.js@@ -313,6 +313,57 @@ function runTests() {}})) passed++; else failed++;+ if (test('adapts a CRLF agent and preserves its line endings', () => {+ const tempDir = createTempDir();+ const agentsDir = path.join(tempDir, '.qwen', 'agents');++ try {+ writeAgent(+ agentsDir,+ 'windows.md',+ ['---', 'name: windows', 'tools: Read, Bash', 'color: teal', '---', '', 'Body line'].join('\r\n')+ );++ const result = run([agentsDir]);+ assert.strictEqual(result.code, 0, result.stderr);+ // A CRLF-only match used to report "already compatible" while leaving+ // Read/Bash/teal in place, so assert the update actually happened.+ assert.ok(result.stdout.includes('Updated 1 agent file(s)'), result.stdout);++ const updated = readAgent(agentsDir, 'windows.md');+ assert.ok(updated.includes('tools: read_file, run_shell_command'));+ assert.ok(updated.includes('color: cyan'));+ assert.ok(!updated.includes('Read,'));+ assert.ok(updated.includes('\r\n'), 'CRLF endings were lost');+ assert.ok(!/[^\r]\n/.test(updated), 'found a bare LF in a CRLF file');+ } finally {+ cleanupTempDir(tempDir);+ }+ })) passed++; else failed++;++ if (test('rejects an unknown flag without modifying any file', () => {+ const tempDir = createTempDir();+ const agentsDir = path.join(tempDir, '.qwen', 'agents');++ try {+ writeAgent(+ agentsDir,+ 'architect.md',+ ['---', 'name: architect', 'tools: Read, Bash', '---', '', 'Body'].join('\n')+ );+ const before = readAgent(agentsDir, 'architect.md');++ const result = run(['--dry-run', agentsDir]);+ assert.strictEqual(result.code, 1);+ assert.ok(result.stderr.includes('Unknown option: --dry-run'), result.stderr);+ // The point of rejecting: a flag that looks like a preview must not+ // rewrite installed agents and still exit 0.+ assert.strictEqual(readAgent(agentsDir, 'architect.md'), before);+ } finally {+ cleanupTempDir(tempDir);+ }+ })) passed++; else failed++;+console.log(`\nResults: Passed: ${passed}, Failed: ${failed}`);process.exit(failed > 0 ? 1 : 0);}