Skip to content

feat: add Qwen Code runtime support with dynamic hook adapter resolution#26

Merged
josstei merged 6 commits into
josstei:mainfrom
B-A-M-N:feat/qwen-runtime-support
Apr 15, 2026
Merged

feat: add Qwen Code runtime support with dynamic hook adapter resolution#26
josstei merged 6 commits into
josstei:mainfrom
B-A-M-N:feat/qwen-runtime-support

Conversation

@B-A-M-N

@B-A-M-N B-A-M-N commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds Qwen Code runtime support through native Gemini-extension compatibility, with a proper dynamic hook adapter resolution system that replaces the legacy single-adapter pattern.

What Changed

Core

  • src/core/resolve-hook-adapter.js — New dispatcher that selects Gemini or Qwen adapter based on MAESTRO_RUNTIME, with candidate-path probing for both canonical source and deployed contexts
  • src/platforms/qwen/ — Qwen hook adapter mapping events to internal phases (SubagentStart→BeforeAgent, SubagentStop→AfterAgent), runtime config, and hook entrypoints
  • src/manifest.js — Qwen entries for hook deployment; removed conflicting dual-writer entries for hooks/hook-adapter.js

Migration

  • All Gemini hook entrypoints now use loadHookAdapter() resolver pattern instead of direct adapter imports
  • Removed legacy hooks/hook-adapter.js (replaced by resolver-based dispatch)
  • Fixed generator to skip Qwen entry-point generation for shared commands/maestro/*.toml (prevents non-deterministic overwrite conflict)

Docs

  • docs/runtime-qwen.md — Full runtime documentation (installation, hooks, tool mapping, policy parity notes)
  • README.md — Qwen badge, install instructions, command table, runtime reference
  • ARCHITECTURE.md — Qwen runtime doc reference

Tests (27 new)

  • tests/core/resolve-hook-adapter.test.js — Resolver: gemini default, qwen, unknown fails loudly
  • tests/core/qwen-hook-adapter.normalize.test.js — Normalization: SessionStart, SubagentStart, SubagentStop, SessionEnd, PreToolUse, fallbacks
  • tests/core/qwen-hook-adapter.format.test.js — Output: allow/deny, success, event-specific shape

Verification

  • All 212 tests pass
  • Zero-diff clean (generator produces no changes)
  • Resolver works in both canonical source and deployed hooks contexts
  • No placeholder leakage ({{skills_block}}) in generated TOMLs
  • Smoke test: Gemini and Qwen hook entrypoints both exit cleanly with correct output

@B-A-M-N

B-A-M-N commented Apr 11, 2026

Copy link
Copy Markdown
Contributor Author

@josstei added Qwen Code support here — small, self-contained change following the existing provider pattern.

Tested locally and confirmed working. Should be low-risk, but happy to adjust if you want it integrated differently.

@josstei

josstei commented Apr 12, 2026

Copy link
Copy Markdown
Owner

@B-A-M-N - I'm trimming down amount of generated files and should have a more streamlined build in the coming day or so. Once complete i'll get cracking on this one. Thanks for contributing!

@josstei josstei self-assigned this Apr 12, 2026
@B-A-M-N

B-A-M-N commented Apr 12, 2026

Copy link
Copy Markdown
Contributor Author

@josstei Sounds good. If anything in the new build conflicts with this, just let me know and I’ll adjust on my end to keep it aligned and minimize extra work. Always happy to help.

@B-A-M-N B-A-M-N force-pushed the feat/qwen-runtime-support branch from ec976d5 to a25a356 Compare April 13, 2026 15:09
@josstei josstei changed the base branch from main to dev April 13, 2026 15:45
@B-A-M-N B-A-M-N force-pushed the feat/qwen-runtime-support branch from a25a356 to 487e425 Compare April 13, 2026 16:15
@B-A-M-N

B-A-M-N commented Apr 13, 2026

Copy link
Copy Markdown
Contributor Author

Rebased and completed Qwen support for the current dev architecture.

What was fixed:

  • isolated Qwen hooks into qwen/hooks.json (SubagentStart / SubagentStop)
  • reverted hooks/hooks.json to Gemini-only
  • corrected Qwen hook payload mapping (last_assistant_message instead of Gemini-style response fields)
  • updated adapter output to Qwen-native response format ({ continue, decision, reason, hookSpecificOutput })
  • decision only emitted when controlling flow — no unconditional allow
  • added Qwen agent generation under qwen/agents/ (22 agents)
  • corrected Qwen tool naming and context docs (edit, todo_write)
  • ensured Qwen assets are shipped in the package (QWEN.md, qwen-extension.json, qwen/)

Validation:

  • 365 tests passing
  • zero generator drift

This should now be aligned with dev structurally and behaviorally, not just rebased superficially.

@josstei josstei changed the base branch from dev to main April 14, 2026 03:58
josstei pushed a commit that referenced this pull request Apr 14, 2026
Comprehensive analysis of the Qwen adapter contract mismatch,
fabricated PR description claims, binary artifacts, and fork
divergence from the #38 refactor.

https://claude.ai/code/session_01RrDPZpKY1X3o6jX5HXKPEZ

@josstei josstei left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! A few issues with this PR that need to be resolved before it can be merged. Details are in inline comments and below.

Critical:

  • The Qwen adapter does not conform to the internal context contract used by the hook logic handlers. agentInput, agentResult, and agentName are missing from the normalized output, which breaks before-agent-logic.js and after-agent-logic.js at runtime. See inline comment on qwen-adapter.js.
  • The PR description references files and tests that do not exist on this branch (SHA 2e09fb3): src/core/resolve-hook-adapter.js, docs/runtime-qwen.md, and three test files under tests/core/ (which itself does not exist). No Qwen-specific tests were added.

High:

  • Three binary .db files under .gemini_security/ are included. These are development artifacts and should be removed. See inline comment on graphiti.db.
  • No test coverage exists for the Qwen adapter. The existing platform-adapters.test.js only covers Claude and Gemini.
  • The PR branch predates #38 ("extract lib/ foundation layer and decompose src/") merged to main on Apr 14. The 329-file diff is fork divergence, not intentional changes. A fresh rebase onto current main is needed to resolve conflicts and produce a reviewable diff.

Generated by Claude Code

Comment thread src/platforms/shared/adapters/qwen-adapter.js
Comment thread .gemini_security/graphiti.db Outdated
Comment thread src/platforms/shared/hook-runner.js
B-A-M-N and others added 3 commits April 14, 2026 20:10
…nfig

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
…ayload contract

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
@B-A-M-N B-A-M-N force-pushed the feat/qwen-runtime-support branch from accf3c0 to 30d398e Compare April 15, 2026 01:11
@B-A-M-N

B-A-M-N commented Apr 15, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up: fixed the failing source-of-truth-check in 669e75f.

Cause: the generator discovered qwen as a runtime but src/generator/entry-point-expander.js still treated it as unknown.

Fix: Qwen now intentionally returns no generated entry points/core commands, matching the branch design.

Re-verified locally with:

  • node scripts/generate.js --dry-run
  • node --test tests/transforms/*.test.js tests/integration/*.test.js

The previously failing generator/zero-diff cases are now green locally.

@josstei josstei merged commit ff5199a into josstei:main Apr 15, 2026
3 checks passed
josstei added a commit that referenced this pull request Apr 17, 2026
Qwen Code runtime support landed via #26 with a dedicated adapter
(src/platforms/qwen/runtime-config.js), extension manifest
(qwen-extension.json), generated qwen/ output, QWEN.md context file,
and SubagentStart/SubagentStop hooks. The README still documented
only Gemini CLI, Claude Code, and Codex.

Adds:
- Qwen Code badge
- Qwen row in Runtime Targets table
- Prerequisite note for ~/.qwen/settings.json experimental subagents
- Qwen Code installation subsection
- Qwen Code Quick Start example
- Note that Qwen Code uses the same /maestro:* surface as Gemini CLI
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.

2 participants