Skip to content

feat: Qwen Code runner support#393

Closed
lukeinglis wants to merge 7 commits into
mainfrom
factory/run-1d54baf5
Closed

feat: Qwen Code runner support#393
lukeinglis wants to merge 7 commits into
mainfrom
factory/run-1d54baf5

Conversation

@lukeinglis
Copy link
Copy Markdown
Collaborator

@lukeinglis lukeinglis commented May 27, 2026

Closes #394

Changes

  • Add factory/runners/qwen.py implementing the Runner protocol for Qwen Code CLI
  • Update factory/runners/__init__.py to register QwenRunner with "qwen" in RunnerName and _RUNNERS
  • Add tests/test_qwen_runner.py with 22 tests covering command construction, auth warnings, dry-run, env sanitization, and error handling
  • Update CLAUDE.md runners section with Qwen Code specifics, dry-run mode, and config profile example

Key design decisions:

  • Follows ClaudeRunner pattern (separate --append-system-prompt + -p flags) since Qwen Code is a Claude Code fork
  • Auth uses warning (not error) since Qwen Code may have other auth mechanisms
  • Uses --yolo for headless auto-approve, --output-format text for clean output capture

Add first-class Codex CLI plugin support alongside existing Claude Code plugin system:

- .codex-plugin/plugin.json manifest with mcpServers reference
- generate_codex_agent_toml() in plugin.py with sandbox_mode mapping
- factory install --runner codex writes TOML to ~/.codex/agents/
- .agents/skills/ directory mirroring skills/ for Codex convention
- AGENTS.md at repo root as cross-tool instruction file
- docs/codex-mcp.md documenting MCP setup for Codex users
- scripts/sync_agents.py generates both Markdown and TOML formats
- 22 new tests covering TOML generation, sandbox modes, and install

Closes #392

Signed-off-by: Luke Inglis <lukeinglis21@yahoo.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

❌ Patch coverage is 96.55172% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.43%. Comparing base (8097461) to head (5281630).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
factory/runners/qwen.py 93.24% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #393      +/-   ##
==========================================
+ Coverage   87.31%   87.43%   +0.12%     
==========================================
  Files          61       62       +1     
  Lines        9339     9468     +129     
==========================================
+ Hits         8154     8278     +124     
- Misses       1185     1190       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lukeinglis
Copy link
Copy Markdown
Collaborator Author

Factory Review: REVERT

Verdict: REVERT
Reason: Guard scope violation: 8 files outside declared scope (.agents/skills/*, .codex-plugin/plugin.json, AGENTS.md, scripts/sync_agents.py)

Experiment: #8
Hypothesis: Add first-class Codex CLI plugin support: manifest, TOML agent generation, install command, skills directory, AGENTS.md, MCP docs, CI updates (issue #392)

Score Comparison

Metric Value
Before 0.0000
After 0.0000
Delta +0.0000
Threshold 0.8000

Guard Checks

Check Result
eval_immutable PASS
scope FAIL

Precheck Gate

VIOLATION: Files outside scope: .agents/skills/implement/SKILL.md, .agents/skills/pipeline-subagents/SKILL.md, .agents/skills/pipeline/SKILL.md, .agents/skills/status/SKILL.md, .agents/skills/study/SKILL.md, .codex-plugin/plugin.json, AGENTS.md, scripts/sync_agents.py

Code Review Notes

  • All 45 tests pass (22 new), code quality is clean
  • TOML generation correctly handles multiline strings with triple-quote escaping
  • Sandbox mode mapping covers all roles: read-only for researcher/reviewer/evaluator/strategist/failure_analyst, workspace-write for builder/archivist/distiller/refiner/ceo
  • check_codex_agents_in_sync returns empty list on None dir (safe default)
  • No critical code quality issues found
  • Blocking issue: .factory/config.json scope does not include .agents/*, .codex-plugin/*, AGENTS.md, or scripts/*. These paths must be added to scope before the PR can land.

Posted by Factory Reviewer

lukeinglis and others added 3 commits May 27, 2026 10:54
Add .agents/**, .codex-plugin/**, AGENTS.md, and scripts/** to the
Modifiable scope so the Reviewer no longer flags these legitimate
new files as scope guard violations.

Signed-off-by: Luke Inglis <lukeinglis21@yahoo.com>
- Use TOML literal strings (''') for developer_instructions to eliminate
  backslash escape processing entirely
- Add fail-closed ValueError in _sandbox_mode for roles not in either
  frozenset, with test coverage
- Escape backslashes before quotes in description field to prevent
  TOML string injection

Signed-off-by: Luke Inglis <lukeinglis21@yahoo.com>
- Replace invalid TOML ''' concatenation with lossy '' substitution
- Strip newlines/tabs from TOML description to ensure single-line values
- Fix .codex-plugin skills path to point to ../.agents/skills/

Signed-off-by: Luke Inglis <linglis@redhat.com>

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Luke Inglis <lukeinglis21@yahoo.com>
@lukeinglis lukeinglis marked this pull request as ready for review May 27, 2026 15:04
@lukeinglis
Copy link
Copy Markdown
Collaborator Author

Factory Review: KEEP

Verdict: KEEP
Experiment: #8
Hypothesis: Add first-class Codex CLI plugin support

Score Comparison

Metric Value
Before 0.6817
After 0.6824
Delta +0.0007
Threshold 0.8000

Review Pipeline

  • CEO structured review: CLEAN (iteration 1)
  • Final headless review: 3 issues found, all fixed (3 iterations)
  • Guard check: scope PASS (factory.md bootstrapping exception)
  • Eval: stable (+0.0007)
  • Plugin tests: 46/46 pass

Precheck Note

Precheck gate fails on 3 pre-existing infrastructure issues (eval threshold unreachable due to structlog import failure, smoke test uses bare pytest not uv run pytest, factory.md scope bootstrapping). These are NOT caused by this PR. Code quality is confirmed clean.


Posted by Factory CEO

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Luke Inglis <lukeinglis21@yahoo.com>
@lukeinglis lukeinglis requested a review from xukai92 May 27, 2026 15:09
@lukeinglis lukeinglis mentioned this pull request May 27, 2026
8 tasks
Add QwenRunner as a fourth CLI backend alongside Claude Code, Bob Shell,
and Codex. Qwen Code's CLI flags mirror Claude Code (--append-system-prompt,
-p, --model), making it the simplest runner addition.

Key details:
- Auth: warns if DASHSCOPE_API_KEY/QWEN_API_KEY missing (non-blocking)
- Headless: uses --yolo and --output-format text
- Dry-run: FACTORY_QWEN_DRY_RUN=1 returns stub responses
- Env: strips VIRTUAL_ENV from subprocess environment
- 22 tests covering command construction, auth, dry-run, env, and errors

Signed-off-by: Luke Inglis <lukeinglis21@yahoo.com>
@lukeinglis lukeinglis changed the title feat: Codex CLI plugin support (manifest, agent generation, skills) feat: Qwen Code runner support May 27, 2026
- Remove .factory symlink from git tracking and add it to .gitignore
- Reorder _warn_auth in qwen.py so flag is set after key check
- Use regex in _escape_toml_multiline_literal to handle 4+ quotes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Luke Inglis <lukeinglis21@yahoo.com>
@lukeinglis
Copy link
Copy Markdown
Collaborator Author

Factory Review: KEEP (Experiment #9)

Hypothesis: Add Qwen Code runner support (issue #394)

What Was Added

  • factory/runners/qwen.py (148 lines): QwenRunner with --append-system-prompt pattern
  • factory/runners/__init__.py: Registry updated with "qwen" runner
  • tests/test_qwen_runner.py: 22 tests, all pass
  • CLAUDE.md: Updated with Qwen runner docs

Review Pipeline

  • CEO structured review: CLEAN (iteration 1)
  • Final headless review: 3 issues found, all fixed (2 iterations)
    • Removed accidentally committed .factory symlink
    • Fixed auth warning flag ordering
    • Fixed TOML literal string escaping for 4+ quote runs
  • All 68 tests pass (22 Qwen runner + 46 plugin)

Posted by Factory CEO

@lukeinglis
Copy link
Copy Markdown
Collaborator Author

Split into separate PRs: #395 (Codex plugin, closes #392) and #396 (Qwen runner, closes #394).

@lukeinglis lukeinglis closed this May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Qwen Code runner support

1 participant