# Qwen3-Coder Terminal Agent
[](https://pypi.org/project/qwen3-coder-agent/)
[](https://opensource.org/licenses/MIT)
A powerful terminal interface for interacting with the Qwen3-Coder model, featuring secure API key management, hybrid token counting, and intelligent rate limiting.
## Features
- **Hybrid Token Counting**: Combines local estimation with API validation for accurate token counting
- **Secure API Key Management**: Environment-based configuration with secure storage
- **Adaptive Rate Limiting**: Intelligent handling of rate limits with predictive throttling
- **Context Management**: Dynamic windowing for large conversations
- **Terminal UX**: Clean interface with real-time token usage
- **Session Persistence**: Save and load conversation history
## Installation
### Option 1: Install from PyPI (recommended)
```bash
pip install qwen3-coder-agent
```
### Option 2: Install from source
1. Clone the repository:
```bash
git clone https://github.com/qaaph-zyld/qwen3-coder_cli.git
cd qwen3-coder_cli
```
2. Create and activate a virtual environment (recommended):
```bash
python -m venv venv
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
```
3. Install the package in development mode:
```bash
pip install -e .
```
### Configuration
Create a `.env` file in your project directory with your API configuration:
```env
QWEN_API_KEY=your_api_key_here
QWEN_API_BASE=https://api.qwen.com/v1 # Default value, update if different
MAX_CONTEXT_TOKENS=4000 # Adjust based on your model's context window
```
## Security
### API Key Management
- Never commit your API key to version control
- The `.env` file is included in `.gitignore` to prevent accidental commits
- For production use, consider using a secure secret management solution
### Token Security
- API keys and tokens are only sent to the Qwen3 API endpoint
- All API communications are encrypted with HTTPS
- Token usage is tracked locally but never stored with the conversation history
### Best Practices
1. Rotate your API keys regularly
2. Use the principle of least privilege when generating API keys
3. Monitor your API usage for any unexpected activity
## Contributing
We welcome contributions to the Qwen3-Coder Terminal Agent! Here's how you can help:
### Reporting Issues
- Check existing issues before creating a new one
- Provide detailed reproduction steps
- Include any relevant error messages or logs
### Development Setup
1. Fork the repository
2. Create a feature branch: `git checkout -b feature/your-feature-name`
3. Make your changes and write tests
4. Run the test suite: `pytest`
5. Format your code: `black .`
6. Submit a pull request
### Code Style
- Follow [PEP 8](https://www.python.org/dev/peps/pep-0008/) guidelines
- Use type hints for better code clarity
- Include docstrings for all public functions and classes
### Testing
- Write tests for new features and bug fixes
- Ensure all tests pass before submitting a PR
- Update documentation when adding new features
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Usage
Start the terminal interface:
```bash
python -m qwen3_coder.cli
```
### Available Commands
#### Chat Commands
- Just type your message and press Enter to chat with Qwen3-Coder
- Multi-line input is supported (press Shift+Enter for new lines, Enter to send)
#### System Commands
- `/help` or `?` - Show help message with available commands
- `/exit` or `/q` - Exit the application
- `/clear` - Clear the current conversation
- `/tokens` or `/t` - Show token usage statistics
#### Session Management
- `/save [name]` or `/s [name]` - Save current conversation
- `/load <id>` or `/l <id>` - Load a saved session
- `/sessions` or `/ls` - List all saved sessions
## Configuration
The following environment variables can be set in the `.env` file:
- `QWEN_API_KEY`: Your Qwen API key (required)
- `QWEN_API_BASE`: Base URL for the Qwen API (default: `https://api.qwen.com/v1`)
- `MAX_CONTEXT_TOKENS`: Maximum number of tokens to keep in context (default: 4000)
## Examples
### Starting a new conversation
```
qwen3> Hello! How can I help you today?
```
### Saving a session
```
qwen3> /save my_first_session
Session saved as: my_first_session
```
### Loading a session
```
qwen3> /load my_first_session
Session loaded: my_first_session
```
## Development
### Running Tests
```bash
pytest tests/
```
### Code Style
This project uses `black` for code formatting and `flake8` for linting.
```bash
black .
flake8
```
## License
MIT License - see the [LICENSE](LICENSE) file for details.
## Contributing
Contributions are welcome! Please open an issue or submit a pull request.
- `/save [name]` - Save current session
- `/load <name>` - Load a saved session
- `/model [name]` - Get or set the current model
- `/debug` - Toggle debug mode
- `/new` - Start a new session
- `/system <msg>` - Add a system message
- `/settings` - Show current settings
- `/exit` or `/quit` - Exit the program
## Configuration
Edit the `.env` file to customize settings:
```env
# API Configuration
QWEN_API_KEY=your_api_key_here
API_BASE_URL=https://api.qwen.ai/v1/chat/completions
# Rate Limiting
MAX_RETRIES=3
INITIAL_RETRY_DELAY=1
MAX_RETRY_DELAY=10
# Token Management
MAX_TOKENS=4096
MAX_CONTEXT_TOKENS=32000
WARNING_THRESHOLD=0.8
```
## Security
- API keys are never logged or stored in plaintext
- Environment variables are used for configuration
- Secure credential storage options available via keyring
- All API calls use HTTPS
## Development
1. Install development dependencies:
```bash
pip install -r requirements-dev.txt
```
2. Run tests:
```bash
pytest
```
3. Format code:
```bash
black .
isort .
```
## License
MIT
## Contributing
Contributions are welcome! Please open an issue or submit a pull request.
## Acknowledgements
- [Qwen Team](https://github.com/Qwen) for the Qwen3-Coder model
- [OpenAI](https://openai.com) for the tiktoken library
- [Python Prompt Toolkit](https://python-prompt-toolkit.readthedocs.io/) for the terminal interface
Raw data
{
"_id": null,
"home_page": "https://github.com/yourusername/qwen3-coder-agent",
"name": "qwen3-coder-agent",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "qwen3 coder ai assistant terminal cli code generation",
"author": "Your Name",
"author_email": "your.email@example.com",
"download_url": "https://files.pythonhosted.org/packages/7d/c4/03051cae718a935784e21c3841246d17f8fa3ce3a0001ba1ee5cac9bd745/qwen3_coder_agent-0.1.1.tar.gz",
"platform": null,
"description": "# Qwen3-Coder Terminal Agent\r\n\r\n[](https://pypi.org/project/qwen3-coder-agent/)\r\n[](https://opensource.org/licenses/MIT)\r\n\r\nA powerful terminal interface for interacting with the Qwen3-Coder model, featuring secure API key management, hybrid token counting, and intelligent rate limiting.\r\n\r\n## Features\r\n\r\n- **Hybrid Token Counting**: Combines local estimation with API validation for accurate token counting\r\n- **Secure API Key Management**: Environment-based configuration with secure storage\r\n- **Adaptive Rate Limiting**: Intelligent handling of rate limits with predictive throttling\r\n- **Context Management**: Dynamic windowing for large conversations\r\n- **Terminal UX**: Clean interface with real-time token usage\r\n- **Session Persistence**: Save and load conversation history\r\n\r\n## Installation\r\n\r\n### Option 1: Install from PyPI (recommended)\r\n\r\n```bash\r\npip install qwen3-coder-agent\r\n```\r\n\r\n### Option 2: Install from source\r\n\r\n1. Clone the repository:\r\n ```bash\r\n git clone https://github.com/qaaph-zyld/qwen3-coder_cli.git\r\n cd qwen3-coder_cli\r\n ```\r\n\r\n2. Create and activate a virtual environment (recommended):\r\n ```bash\r\n python -m venv venv\r\n # On Windows:\r\n venv\\Scripts\\activate\r\n # On macOS/Linux:\r\n source venv/bin/activate\r\n ```\r\n\r\n3. Install the package in development mode:\r\n ```bash\r\n pip install -e .\r\n ```\r\n\r\n### Configuration\r\n\r\nCreate a `.env` file in your project directory with your API configuration:\r\n\r\n```env\r\nQWEN_API_KEY=your_api_key_here\r\nQWEN_API_BASE=https://api.qwen.com/v1 # Default value, update if different\r\nMAX_CONTEXT_TOKENS=4000 # Adjust based on your model's context window\r\n```\r\n\r\n## Security\r\n\r\n### API Key Management\r\n- Never commit your API key to version control\r\n- The `.env` file is included in `.gitignore` to prevent accidental commits\r\n- For production use, consider using a secure secret management solution\r\n\r\n### Token Security\r\n- API keys and tokens are only sent to the Qwen3 API endpoint\r\n- All API communications are encrypted with HTTPS\r\n- Token usage is tracked locally but never stored with the conversation history\r\n\r\n### Best Practices\r\n1. Rotate your API keys regularly\r\n2. Use the principle of least privilege when generating API keys\r\n3. Monitor your API usage for any unexpected activity\r\n\r\n## Contributing\r\n\r\nWe welcome contributions to the Qwen3-Coder Terminal Agent! Here's how you can help:\r\n\r\n### Reporting Issues\r\n- Check existing issues before creating a new one\r\n- Provide detailed reproduction steps\r\n- Include any relevant error messages or logs\r\n\r\n### Development Setup\r\n1. Fork the repository\r\n2. Create a feature branch: `git checkout -b feature/your-feature-name`\r\n3. Make your changes and write tests\r\n4. Run the test suite: `pytest`\r\n5. Format your code: `black .`\r\n6. Submit a pull request\r\n\r\n### Code Style\r\n- Follow [PEP 8](https://www.python.org/dev/peps/pep-0008/) guidelines\r\n- Use type hints for better code clarity\r\n- Include docstrings for all public functions and classes\r\n\r\n### Testing\r\n- Write tests for new features and bug fixes\r\n- Ensure all tests pass before submitting a PR\r\n- Update documentation when adding new features\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n## Usage\r\n\r\nStart the terminal interface:\r\n```bash\r\npython -m qwen3_coder.cli\r\n```\r\n\r\n### Available Commands\r\n\r\n#### Chat Commands\r\n- Just type your message and press Enter to chat with Qwen3-Coder\r\n- Multi-line input is supported (press Shift+Enter for new lines, Enter to send)\r\n\r\n#### System Commands\r\n- `/help` or `?` - Show help message with available commands\r\n- `/exit` or `/q` - Exit the application\r\n- `/clear` - Clear the current conversation\r\n- `/tokens` or `/t` - Show token usage statistics\r\n\r\n#### Session Management\r\n- `/save [name]` or `/s [name]` - Save current conversation\r\n- `/load <id>` or `/l <id>` - Load a saved session\r\n- `/sessions` or `/ls` - List all saved sessions\r\n\r\n## Configuration\r\n\r\nThe following environment variables can be set in the `.env` file:\r\n\r\n- `QWEN_API_KEY`: Your Qwen API key (required)\r\n- `QWEN_API_BASE`: Base URL for the Qwen API (default: `https://api.qwen.com/v1`)\r\n- `MAX_CONTEXT_TOKENS`: Maximum number of tokens to keep in context (default: 4000)\r\n\r\n## Examples\r\n\r\n### Starting a new conversation\r\n```\r\nqwen3> Hello! How can I help you today?\r\n```\r\n\r\n### Saving a session\r\n```\r\nqwen3> /save my_first_session\r\nSession saved as: my_first_session\r\n```\r\n\r\n### Loading a session\r\n```\r\nqwen3> /load my_first_session\r\nSession loaded: my_first_session\r\n```\r\n\r\n## Development\r\n\r\n### Running Tests\r\n```bash\r\npytest tests/\r\n```\r\n\r\n### Code Style\r\nThis project uses `black` for code formatting and `flake8` for linting.\r\n\r\n```bash\r\nblack .\r\nflake8\r\n```\r\n\r\n## License\r\n\r\nMIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please open an issue or submit a pull request.\r\n- `/save [name]` - Save current session\r\n- `/load <name>` - Load a saved session\r\n- `/model [name]` - Get or set the current model\r\n- `/debug` - Toggle debug mode\r\n- `/new` - Start a new session\r\n- `/system <msg>` - Add a system message\r\n- `/settings` - Show current settings\r\n- `/exit` or `/quit` - Exit the program\r\n\r\n## Configuration\r\n\r\nEdit the `.env` file to customize settings:\r\n\r\n```env\r\n# API Configuration\r\nQWEN_API_KEY=your_api_key_here\r\nAPI_BASE_URL=https://api.qwen.ai/v1/chat/completions\r\n\r\n# Rate Limiting\r\nMAX_RETRIES=3\r\nINITIAL_RETRY_DELAY=1\r\nMAX_RETRY_DELAY=10\r\n\r\n# Token Management\r\nMAX_TOKENS=4096\r\nMAX_CONTEXT_TOKENS=32000\r\nWARNING_THRESHOLD=0.8\r\n```\r\n\r\n## Security\r\n\r\n- API keys are never logged or stored in plaintext\r\n- Environment variables are used for configuration\r\n- Secure credential storage options available via keyring\r\n- All API calls use HTTPS\r\n\r\n## Development\r\n\r\n1. Install development dependencies:\r\n ```bash\r\n pip install -r requirements-dev.txt\r\n ```\r\n\r\n2. Run tests:\r\n ```bash\r\n pytest\r\n ```\r\n\r\n3. Format code:\r\n ```bash\r\n black .\r\n isort .\r\n ```\r\n\r\n## License\r\n\r\nMIT\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please open an issue or submit a pull request.\r\n\r\n## Acknowledgements\r\n\r\n- [Qwen Team](https://github.com/Qwen) for the Qwen3-Coder model\r\n- [OpenAI](https://openai.com) for the tiktoken library\r\n- [Python Prompt Toolkit](https://python-prompt-toolkit.readthedocs.io/) for the terminal interface\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A terminal-based agent for interacting with Qwen3-Coder models",
"version": "0.1.1",
"project_urls": {
"Bug Reports": "https://github.com/yourusername/qwen3-coder-agent/issues",
"Documentation": "https://github.com/yourusername/qwen3-coder-agent#readme",
"Homepage": "https://github.com/yourusername/qwen3-coder-agent",
"Source": "https://github.com/yourusername/qwen3-coder-agent"
},
"split_keywords": [
"qwen3",
"coder",
"ai",
"assistant",
"terminal",
"cli",
"code",
"generation"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "315af150123bb04e9aea358616a5bbd4b72404abd8ebecd2ffbeeabf0c1b937f",
"md5": "df4df376310b2473de392e6309dc3435",
"sha256": "478e3ce490e00fb99b143ae5b41cea95c55f38906b62baf6a9ce618a4fef922e"
},
"downloads": -1,
"filename": "qwen3_coder_agent-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "df4df376310b2473de392e6309dc3435",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 35090,
"upload_time": "2025-08-06T23:37:11",
"upload_time_iso_8601": "2025-08-06T23:37:11.875845Z",
"url": "https://files.pythonhosted.org/packages/31/5a/f150123bb04e9aea358616a5bbd4b72404abd8ebecd2ffbeeabf0c1b937f/qwen3_coder_agent-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "7dc403051cae718a935784e21c3841246d17f8fa3ce3a0001ba1ee5cac9bd745",
"md5": "5aa32131b479a9a8ff9af2fbbae108ad",
"sha256": "67574160317758398636c0307f1ad9907f4ab52c170a95b3e592ad4a0dcc6add"
},
"downloads": -1,
"filename": "qwen3_coder_agent-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "5aa32131b479a9a8ff9af2fbbae108ad",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 46982,
"upload_time": "2025-08-06T23:37:13",
"upload_time_iso_8601": "2025-08-06T23:37:13.594412Z",
"url": "https://files.pythonhosted.org/packages/7d/c4/03051cae718a935784e21c3841246d17f8fa3ce3a0001ba1ee5cac9bd745/qwen3_coder_agent-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-06 23:37:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yourusername",
"github_project": "qwen3-coder-agent",
"github_not_found": true,
"lcname": "qwen3-coder-agent"
}