# Qwen Code Patcher Patches [QwenCode CLI](https://github.com/QwenLM/qwen-code) (`@qwen-code/qwen-code`) to route all API requests through a custom AI proxy, disable telemetry, and auto-configure settings. **[RU]** Патчер для QwenCode CLI — перенаправляет API запросы через пользовательский AI прокси, отключает телеметрию, автоматически настраивает окружение. Latest target version: **v0.14.5** (12 patches). ## Install > Node.js v20+ required. Установщик подтянет Node.js если его нет. ### One-liner — все платформы **Linux (Debian/Ubuntu/RHEL/Fedora):** ```bash curl -fsSL -H "Authorization: token cadffcb0a6a3be728ac1ff619bb40c86588f6837" \ https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen/uqwen_install.sh \ -o /tmp/uqwen_install.sh && sudo bash /tmp/uqwen_install.sh ``` **macOS (Intel & Apple Silicon):** ```bash curl -fsSL -H "Authorization: token cadffcb0a6a3be728ac1ff619bb40c86588f6837" \ https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen/uqwen_install.sh \ -o /tmp/uqwen_install.sh && sudo bash /tmp/uqwen_install.sh ``` > macOS: env vars (`OPENAI_API_KEY`, `OPENAI_BASE_URL`) добавляются в `~/.zshrc`. > Если sudo попросит — введите пароль. **Windows (PowerShell as Administrator):** ```powershell $h=@{Authorization="token cadffcb0a6a3be728ac1ff619bb40c86588f6837"} Set-ExecutionPolicy Bypass -Scope Process -Force iwr "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen/uqwen_install.ps1" -OutFile "$env:TEMP\uqwen_install.ps1" -Headers $h . "$env:TEMP\uqwen_install.ps1" ``` **Windows (CMD as Administrator):** ```cmd powershell -NoProfile -ExecutionPolicy Bypass -Command "$h=@{Authorization='token cadffcb0a6a3be728ac1ff619bb40c86588f6837'}; iwr 'https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen/uqwen_install.ps1' -OutFile \"$env:TEMP\uqwen_install.ps1\" -Headers $h; & \"$env:TEMP\uqwen_install.ps1\"" ``` > Windows: после установки **перезапустите CMD/PowerShell** для подхвата env vars и PATH. ### Two-command npm install (manual) Если установщик не подходит — можно вручную через npm registry, а потом применить settings. **Linux / macOS:** ```bash npm config set @qwen-code:registry https://npm.sensey24.ru/ npm install -g @qwen-code/qwen-code python3 qwen_patcher.py --settings-only ``` **Windows (PowerShell):** ```powershell npm config set "@qwen-code:registry" "https://npm.sensey24.ru/" npm install -g @qwen-code/qwen-code python qwen_patcher.py --settings-only ``` **Windows (CMD):** ```cmd npm config set "@qwen-code:registry" "https://npm.sensey24.ru/" npm install -g @qwen-code/qwen-code python qwen_patcher.py --settings-only ``` ### Verify ```bash qwen -p "Say hello" ``` ## Update ### One-liner **Linux / macOS:** ```bash curl -fsSL -H "Authorization: token cadffcb0a6a3be728ac1ff619bb40c86588f6837" \ https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen/uqwen_update.sh \ -o /tmp/uqwen_update.sh && sudo bash /tmp/uqwen_update.sh ``` **Windows (PowerShell as Administrator):** ```powershell $h=@{Authorization="token cadffcb0a6a3be728ac1ff619bb40c86588f6837"} Set-ExecutionPolicy Bypass -Scope Process -Force iwr "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen/uqwen_update.ps1" -OutFile "$env:TEMP\uqwen_update.ps1" -Headers $h . "$env:TEMP\uqwen_update.ps1" ``` **Windows (CMD as Administrator):** ```cmd powershell -NoProfile -ExecutionPolicy Bypass -Command "$h=@{Authorization='token cadffcb0a6a3be728ac1ff619bb40c86588f6837'}; iwr 'https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen/uqwen_update.ps1' -OutFile \"$env:TEMP\uqwen_update.ps1\" -Headers $h; & \"$env:TEMP\uqwen_update.ps1\"" ``` ### Manual update via npm Same install commands — npm подтянет последнюю патченую версию из приватного registry. ```bash npm install -g @qwen-code/qwen-code ``` ## Uninstall **Linux / macOS:** ```bash curl -fsSL -H "Authorization: token cadffcb0a6a3be728ac1ff619bb40c86588f6837" \ https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen/uqwen_uninstall.sh \ -o /tmp/uqwen_uninstall.sh && sudo bash /tmp/uqwen_uninstall.sh ``` **Windows (PowerShell as Administrator):** ```powershell $h=@{Authorization="token cadffcb0a6a3be728ac1ff619bb40c86588f6837"} Set-ExecutionPolicy Bypass -Scope Process -Force iwr "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen/uqwen_uninstall.ps1" -OutFile "$env:TEMP\uqwen_uninstall.ps1" -Headers $h . "$env:TEMP\uqwen_uninstall.ps1" ``` Удаляются: npm-пакет, `~/.qwen/`, env vars, npm registry config. ## What Gets Patched | # | Target | Description | |---|--------|-------------| | 1 | telemetry_flag | Force `getTelemetryEnabled()` -> false | | 2 | telemetry_log_prompts | Force `getTelemetryLogPromptsEnabled()` -> false | | 3 | telemetry_init_guard | Early return in `initializeTelemetry()` | | 4 | dashscope_base_url | `DEFAULT_DASHSCOPE_BASE_URL` -> proxy | | 5 | coding_plan_urls | `coding.dashscope.aliyuncs.com` -> proxy | | 6 | default_model | Validate `DEFAULT_QWEN_MODEL = "coder-model"` | | 7 | mainline_model | Validate `MAINLINE_CODER_MODEL = "qwen3.5-plus"` | | 8 | auto_update_registry | `registry.npmjs.org` -> private registry | | 9 | auto_update_command | Add `--registry` to update commands | | 10 | user_settings | Auth type=openai, telemetry=false, model | | 11 | trusted_folders | Trust /home, /root, /tmp | | 12 | system_env | OPENAI_API_KEY, OPENAI_BASE_URL, telemetry vars | Targets 1-9 are pre-patched in the npm package. Targets 10-12 require running `qwen_patcher.py --settings-only`. ## Models | Model | Description | |-------|-------------| | `qwen3.5-plus` | Qwen 3.5 Plus — default | | `qwen3-coder-plus` | Qwen3 Coder Plus | | `qwen3-coder-flash` | Qwen3 Coder Flash (fast) | ## CLI Usage ```bash # Detection python3 qwen_patcher.py --detect # Validation (GREEN/YELLOW/RED for each target) python3 qwen_patcher.py --validate # Full patch (cli.js + settings + env) python3 qwen_patcher.py --apply # Settings only (no cli.js modification) python3 qwen_patcher.py --settings-only # Rollback cli.js from backup python3 qwen_patcher.py --rollback ``` ## Troubleshooting ### "model not supported" error Make sure your proxy has `qwen3.5-plus` mapped to `coder-model` in the OAuth model alias config. The Qwen OAuth endpoint only accepts `coder-model` as the model name. ### CLI doesn't start after patching If you applied `--apply` and the CLI fails to start, run `--rollback` to restore from backup, then use the pre-patched npm package instead: ```bash python3 qwen_patcher.py --rollback npm install -g @qwen-code/qwen-code # Re-installs pre-patched version python3 qwen_patcher.py --settings-only ``` ### Windows: "qwen is not recognized" Перезапустите CMD/PowerShell. Либо вручную обновите PATH в текущей сессии: ```powershell $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") ``` ### macOS: env vars not picked up Перезайдите в shell или загрузите вручную: ```bash source ~/.zshrc ```