qwen-code-updater
Version:
Auto-updater wrapper for Qwen Code that checks for updates before execution
209 lines (144 loc) ⢠5.91 kB
Markdown
# Qwen Code Updater
[](https://badge.fury.io/js/qwen-code-updater)
[](https://opensource.org/licenses/MIT)
An auto-updater wrapper for [Qwen Code](https://github.com/QwenLM/Qwen) that automatically checks for updates before execution, ensuring you're always running the latest version.
## Features
- š **Automatic Updates**: Checks for and installs Qwen Code updates before execution
- ā” **Smart Caching**: Avoids redundant update checks with intelligent cooldown periods
- š§ **Zero Configuration**: Works out of the box with sensible defaults
- š **Detailed Logging**: Comprehensive logging for debugging and monitoring
- š **Rollback Support**: Version history tracking for potential rollbacks
- š”ļø **Error Handling**: Graceful fallback to current version if updates fail
- šÆ **Drop-in Replacement**: Use `qwen` command exactly as before
## Installation
Install globally using npm:
```bash
npm install -g qwen-code-updater
```
This will install the updater and make the `qwen` command available globally.
## Prerequisites
This package is a wrapper around the official Qwen Code CLI. You need to install it separately:
```bash
npm install -g @qwen-code/qwen-code@latest
```
## Usage
The installer automatically sets up an alias so you can use `qwen` exactly as before, but with automatic updates:
```bash
# The updater will automatically check for updates, then run your command
qwen your-command-here
# Skip update check for this run (useful for automation)
qwen --skip-update your-command-here
```
### Examples
```bash
# Start a new chat session (will check for updates first)
qwen
# Run with specific options
qwen --model qwen-plus "Write a hello world function"
# Skip update check for this execution
qwen --skip-update --help
```
### Direct Usage (Alternative)
You can also call the updater directly:
```bash
qwen-code-updater your-command-here
```
## How It Works
1. **Update Check**: Before executing your command, the wrapper checks if a newer version of Qwen Code is available
2. **Smart Updates**: If an update is found, it's automatically downloaded and installed
3. **Seamless Execution**: Your original command is then executed with the updated version
4. **Intelligent Caching**: Update checks are cached for 1 hour to avoid delays
## Configuration
The updater creates a configuration directory at `~/.qwen-code-updater/` containing:
- `config.json`: Settings and preferences
- `updater.log`: Detailed execution logs
### Environment Variables
- `QWEN_UPDATER_DEBUG=true`: Enable debug logging for troubleshooting
## Logging
Logs are automatically written to `~/.qwen-code-updater/updater.log`. Enable debug mode for more detailed logging:
```bash
export QWEN_UPDATER_DEBUG=true
qwen your-command
```
## Troubleshooting
### Common Issues
**Command not found: qwen**
```bash
# Ensure the package is installed globally
npm install -g qwen-code-updater
# Check if npm global bin is in your PATH
npm config get prefix
```
**Update check fails**
- The wrapper will proceed with your current Qwen Code version
- Check your internet connection
- Enable debug logging to see detailed error information
**Qwen Code not found**
```bash
# Install the official Qwen Code CLI
npm install -g @qwen-code/qwen-code@latest
```
### Debug Mode
Enable detailed logging:
```bash
export QWEN_UPDATER_DEBUG=true
qwen --version
```
Check the log file:
```bash
tail -f ~/.qwen-code-updater/updater.log
```
## Development
### Local Testing
```bash
# Clone the repository
git clone https://github.com/0xRaghu/qwen-code-updater.git
cd qwen-code-updater
# Install dependencies
npm install
# Link for local testing
npm link
# Test the command
qwen --version
```
### Package Structure
```
qwen-code-updater/
āāā bin/
ā āāā qwen-code-updater.js # Main CLI entry point
āāā lib/
ā āāā config.js # Configuration management
ā āāā logger.js # Logging utilities
ā āāā shell-detector.js # Shell detection and PATH management
ā āāā updater.js # Update checking and installation logic
āāā scripts/
ā āāā install.js # Post-install setup
ā āāā uninstall.js # Pre-uninstall cleanup
ā āāā cleanup.js # General cleanup utilities
āāā package.json
āāā README.md
āāā LICENSE
```
## Version Management
The updater maintains a version history for potential rollback scenarios. This information is stored in the configuration file and can be used for debugging or manual rollbacks if needed.
## Security
- All updates are fetched from the official npm registry
- Package integrity is verified before installation
- No sensitive data is logged or transmitted
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Related Projects
- [claude-code-updater](https://github.com/0xRaghu/claude-code-updater) - Auto-updater for Claude Code
- [gemini-cli-updater](https://github.com/0xRaghu/gemini-cli-updater) - Auto-updater for Gemini CLI
## Acknowledgments
- Thanks to the Qwen team for creating Qwen Code
- Inspired by similar auto-updater patterns in the developer tools ecosystem
---
**Note**: This is an unofficial wrapper around Qwen Code. For official support, please refer to the [Qwen Code documentation](https://github.com/QwenLM/Qwen).