Skip to content

Support Qwen Code CLI hooks (same as Gemini CLI integration) #1222

@Fathi123-max

Description

@Fathi123-max

Summary

Qwen Code is an LLM-powered coding assistant with a CLI interface and BeforeTool hook system architecturally very similar to Gemini CLI. This feature request is to add first-class RTK support for Qwen Code.

Current Status

RTK currently supports 10+ AI coding tools:

  • ✅ Claude Code
  • ✅ GitHub Copilot (VS Code + CLI)
  • ✅ Cursor
  • ✅ Gemini CLI
  • ✅ Cline / Roo Code
  • ✅ Windsurf
  • ✅ Codex
  • ✅ OpenCode
  • ✅ OpenClaw
  • ⏳ Mistral Vibe (planned)

Qwen Code is missing from this list.

Why Qwen Code?

Qwen Code is gaining adoption as a powerful open-source alternative to Claude Code and Copilot. Users would benefit from RTK's 60-90% token savings just like other supported agents.

Technical Feasibility

JSON Format Similarity to Gemini CLI

Qwen Code BeforeTool Input:

{
  "tool_name": "run_shell_command",
  "tool_input": { "command": "git status" }
}

Expected RTK Output:

{
  "decision": "allow",
  "hookSpecificOutput": {
    "tool_input": { "command": "rtk git status" }
  }
}

This is virtually identical to Gemini CLI's hook format (see hooks/README.md#Gemini-CLI).

Implementation Effort

Minimal — RTK already has:

  1. Command rewrite logic (src/discover/registry.rs) — reusable
  2. Gemini CLI handler (src/hooks/hook_cmd.rs::run_gemini()) — can be reused or slightly adapted
  3. Settings.json patching (src/hooks/init.rs::patch_gemini_settings()) — template exists
  4. Installation CLI (rtk init -g --gemini) — pattern established

Proposal: Add rtk init -g --qwen command that:

  • Creates ~/.qwen/hooks/rtk-rewrite.sh (or similar)
  • Patches ~/.qwen/settings.json with BeforeTool hook entry
  • Installs QWEN.md (RTK awareness doc)

This is a straightforward extension of the existing Gemini CLI support.

Expected Outcome

After implementation, users can:

# 1. Install RTK for Qwen Code
rtk init -g --qwen

# 2. Restart Qwen Code

# 3. Commands auto-rewrite transparently
git status       # → internally: rtk git status
cargo test       # → internally: rtk cargo test
npm list         # → internally: rtk npm list
# etc. (all 100+ supported commands)

# 4. Check savings
rtk gain

Resources

Qwen Code Documentation

(If you have Qwen Code's official hook API docs, link them here. E.g., official Qwen Code repository or docs URL.)


I'm happy to:

  • ✅ Test early builds on Qwen Code
  • ✅ Provide hook API documentation if available
  • ✅ Contribute a PR if you want community implementation

Thanks for the amazing RTK project! 🚀

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions