Skip to content

Commit dc6a616

Browse files
committed
docs: add CHANGELOG, correct quota (1,000/day), fix repo URLs in README
- User-focused READMEs with comprehensive documentation - Comprehensive technical CHANGELOG following Keep a Changelog format - Correct quota documentation (1,000 req/day, not 2,000) - Fix repository references to point to original repo (gustavodiasdev) - Update badges and clone URLs following fork best practices - Documentation in both English (README.md) and Portuguese (README.pt-BR.md)
1 parent 52454fa commit dc6a616

3 files changed

Lines changed: 86 additions & 264 deletions

File tree

CHANGELOG.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
### 🔧 Fixes
11-
12-
- **Dynamic User-Agent detection** - User-Agent header now dynamically detects platform and architecture instead of hardcoded Linux/x64
13-
- Supports Linux, macOS, Windows, FreeBSD, OpenBSD, Solaris, AIX
14-
- Supports x64, arm64, ia32, ppc64, arm, mips architectures
15-
- Maintains qwen-code v0.12.0 client version for compatibility
16-
- Fixes authentication on non-Linux systems and ARM devices (M1/M2/M3 Macs, Raspberry Pi, etc.)
17-
18-
1910
## [1.5.0] - 2026-03-14 (Updated)
2011

2112
### 🚨 Critical Fixes

README.md

Lines changed: 42 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -8,90 +8,34 @@
88
<img src="assets/screenshot.png" alt="OpenCode with Qwen Code" width="800">
99
</p>
1010

11-
**Authenticate OpenCode CLI with your qwen.ai account.** This plugin enables you to use Qwen models (Coder, Max, Plus and more) with **2,000 free requests per day** - no API key or credit card required!
11+
**Authenticate OpenCode CLI with your qwen.ai account.** This plugin enables you to use the `coder-model` with **1,000 free requests per day** - no API key or credit card required!
1212

13-
[🇧🇷 Leia em Português](./README.pt-BR.md)
13+
[🇧🇷 Leia em Português](./README.pt-BR.md) | [📜 Changelog](./CHANGELOG.md)
1414

1515
## ✨ Features
1616

1717
- 🔐 **OAuth Device Flow** - Secure browser-based authentication (RFC 8628)
18-
-**Automatic Polling** - No need to press Enter after authorizing
19-
- 🆓 **2,000 req/day free** - Generous free tier with no credit card
20-
- 🧠 **1M context window** - 1 million token context
18+
- 🆓 **1,000 req/day free** - Generous free tier for personal use
19+
- 🧠 **1M context window** - Massive context support for large projects
2120
- 🔄 **Auto-refresh** - Tokens renewed automatically before expiration
21+
- ⏱️ **Reliability** - Built-in request throttling and automatic retry for transient errors
2222
- 🔗 **qwen-code compatible** - Reuses credentials from `~/.qwen/oauth_creds.json`
23-
- 🌐 **Dynamic Routing** - Automatic resolution of API base URL based on region
24-
- 🏎️ **KV Cache Support** - Official DashScope headers for high performance
25-
- 🎯 **Rate Limit Fix** - Official headers prevent aggressive rate limiting (Fixes #4)
26-
- 🔍 **Session Tracking** - Unique session/prompt IDs for proper quota recognition
27-
- 🎯 **Aligned with qwen-code** - Exposes same models as official Qwen Code CLI
28-
- ⏱️ **Request Throttling** - 1-2.5s intervals between requests (prevents 60 req/min limit)
29-
- 🔄 **Automatic Retry** - Exponential backoff with jitter for 429/5xx errors (up to 7 attempts)
30-
- 📡 **Retry-After Support** - Respects server's Retry-After header when rate limited
31-
32-
## 🆕 What's New in v1.5.0
33-
34-
### Rate Limiting Fix (Issue #4)
35-
36-
**Problem:** Users were experiencing aggressive rate limiting (2,000 req/day quota exhausted quickly).
37-
38-
**Solution:** Added official Qwen Code headers that properly identify the client:
39-
- `X-DashScope-CacheControl: enable` - Enables KV cache optimization
40-
- `X-DashScope-AuthType: qwen-oauth` - Marks as OAuth authentication
41-
- `X-DashScope-UserAgent` - Identifies as official Qwen Code client
42-
- `X-Metadata` - Session and prompt tracking for quota recognition
43-
44-
**Result:** Full daily quota now available without premature rate limiting.
45-
46-
### Automatic Retry & Throttling (v1.5.0+)
47-
48-
**Request Throttling:**
49-
- Minimum 1 second interval between requests
50-
- Additional 0.5-1.5s random jitter (more human-like)
51-
- Prevents hitting 60 req/min limit
52-
53-
**Automatic Retry:**
54-
- Up to 7 retry attempts for transient errors
55-
- Exponential backoff with +/- 30% jitter
56-
- Respects `Retry-After` header from server
57-
- Retries on 429 (rate limit) and 5xx (server errors)
58-
59-
**Result:** Smoother request flow and automatic recovery from rate limiting.
60-
61-
### Dynamic API Endpoint Resolution
62-
63-
The plugin now automatically detects and uses the correct API endpoint based on the `resource_url` returned by the OAuth server:
64-
65-
| resource_url | API Endpoint | Region |
66-
|-------------|--------------|--------|
67-
| `portal.qwen.ai` | `https://portal.qwen.ai/v1` | International |
68-
| `dashscope` | `https://dashscope.aliyuncs.com/compatible-mode/v1` | China |
69-
| `dashscope-intl` | `https://dashscope-intl.aliyuncs.com/compatible-mode/v1` | International |
70-
71-
This means the plugin works correctly regardless of which region your Qwen account is associated with.
72-
73-
### Aligned with qwen-code-0.12.0
74-
75-
-**coder-model** - Only model exposed (matches official Qwen Code CLI)
76-
-**Vision capabilities** - Supports image input
77-
-**Dynamic modalities** - Input modalities adapt based on model capabilities
78-
79-
## 📋 Prerequisites
80-
81-
- [OpenCode CLI](https://opencode.ai) installed
82-
- A [qwen.ai](https://chat.qwen.ai) account (free to create)
8323

8424
## 🚀 Installation
8525

8626
### 1. Install the plugin
8727

8828
```bash
29+
# Using npm
8930
cd ~/.config/opencode && npm install opencode-qwencode-auth
31+
32+
# Using bun (recommended)
33+
cd ~/.config/opencode && bun add opencode-qwencode-auth
9034
```
9135

9236
### 2. Enable the plugin
9337

94-
Edit `~/.config/opencode/opencode.jsonc`:
38+
Edit `~/.config/opencode/opencode.json`:
9539

9640
```json
9741
{
@@ -103,24 +47,23 @@ Edit `~/.config/opencode/opencode.jsonc`:
10347

10448
### 1. Login
10549

50+
Run the following command to start the OAuth flow:
51+
10652
```bash
10753
opencode auth login
10854
```
10955

11056
### 2. Select Provider
11157

112-
Choose **"Other"** and type `qwen-code`
58+
Choose **"Other"** and type `qwen-code`.
11359

11460
### 3. Authenticate
11561

116-
Select **"Qwen Code (qwen.ai OAuth)"**
117-
118-
- A browser window will open for you to authorize
119-
- The plugin automatically detects when you complete authorization
120-
- No need to copy/paste codes or press Enter!
62+
Select **"Qwen Code (qwen.ai OAuth)"**.
12163

122-
> [!TIP]
123-
> In the OpenCode TUI (graphical interface), the **Qwen Code** provider appears automatically in the provider list.
64+
- A browser window will open for you to authorize.
65+
- The plugin automatically detects when you complete authorization.
66+
- **No need to copy/paste codes or press Enter!**
12467

12568
## 🎯 Available Models
12669

@@ -130,67 +73,41 @@ Select **"Qwen Code (qwen.ai OAuth)"**
13073
|-------|---------|------------|----------|
13174
| `coder-model` | 1M tokens | 64K tokens | Official alias (Auto-routes to Qwen 3.5 Plus - Hybrid & Vision) |
13275

133-
> **Note:** This plugin aligns with the official `qwen-code-0.12.0` client, which exposes only the `coder-model` alias. This model automatically routes to the best available Qwen 3.5 Plus with hybrid reasoning and vision capabilities.
76+
> **Note:** This plugin aligns with the official `qwen-code` client. The `coder-model` alias automatically routes to the best available Qwen 3.5 Plus model with hybrid reasoning and vision capabilities.
13477
13578
### Using the model
13679

13780
```bash
13881
opencode --provider qwen-code --model coder-model
13982
```
14083

141-
## ⚙️ How It Works
142-
143-
```
144-
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
145-
│ OpenCode CLI │────▶│ qwen.ai OAuth │────▶│ Qwen Models │
146-
│ │◀────│ (Device Flow) │◀────│ API │
147-
└─────────────────┘ └──────────────────┘ └─────────────────┘
148-
```
84+
## 🔧 Troubleshooting
14985

150-
1. **Device Flow (RFC 8628)**: Opens your browser to `chat.qwen.ai` for authentication
151-
2. **Automatic Polling**: Detects authorization completion automatically
152-
3. **Token Storage**: Saves credentials to `~/.qwen/oauth_creds.json`
153-
4. **Auto-refresh**: Renews tokens 30 seconds before expiration
86+
### "Invalid access token" or "Token expired"
15487

155-
## 📊 Usage Limits
88+
The plugin usually handles refresh automatically. If you see this error immediately:
15689

157-
| Plan | Rate Limit | Daily Limit |
158-
|------|------------|-------------|
159-
| Free (OAuth) | 60 req/min | 2,000 req/day |
90+
1. **Re-authenticate:** Run `opencode auth login` again.
91+
2. **Clear cache:** Delete the credentials file and login again:
92+
```bash
93+
rm ~/.qwen/oauth_creds.json
94+
opencode auth login
95+
```
16096

161-
> [!NOTE]
162-
> Limits reset at midnight UTC. For higher limits, consider using an API key from [DashScope](https://dashscope.aliyun.com).
97+
### Rate limit exceeded (429 errors)
16398

164-
## 🔧 Troubleshooting
99+
If you hit the 1,000 requests/day limit:
100+
- Wait until midnight UTC for the quota to reset.
101+
- Consider using a [DashScope API Key](https://dashscope.aliyun.com) for professional use.
165102

166-
### Token expired
103+
### Enable Debug Logs
167104

168-
The plugin automatically renews tokens. If issues persist:
105+
If something isn't working, you can see detailed logs by setting the debug environment variable:
169106
170107
```bash
171-
# Remove old credentials
172-
rm ~/.qwen/oauth_creds.json
173-
174-
# Re-authenticate
175-
opencode auth login
108+
OPENCODE_QWEN_DEBUG=1 opencode
176109
```
177110
178-
### Provider not showing in `auth login`
179-
180-
The `qwen-code` provider is added via plugin. In the `opencode auth login` command:
181-
182-
1. Select **"Other"**
183-
2. Type `qwen-code`
184-
185-
### Rate limit exceeded (429 errors)
186-
187-
**As of v1.5.0, this should no longer occur!** The plugin now sends official Qwen Code headers that properly identify your client and prevent aggressive rate limiting.
188-
189-
If you still experience rate limiting:
190-
- Ensure you're using v1.5.0 or later: `npm update opencode-qwencode-auth`
191-
- Wait until midnight UTC for quota reset
192-
- Consider [DashScope API](https://dashscope.aliyun.com) for higher limits
193-
194111
## 🛠️ Development
195112
196113
```bash
@@ -201,48 +118,21 @@ cd opencode-qwencode-auth
201118
# Install dependencies
202119
bun install
203120
204-
# Type check
205-
bun run typecheck
206-
```
207-
208-
### Local testing
209-
210-
Edit `~/.config/opencode/package.json`:
211-
212-
```json
213-
{
214-
"dependencies": {
215-
"opencode-qwencode-auth": "file:///absolute/path/to/opencode-qwencode-auth"
216-
}
217-
}
218-
```
219-
220-
Then reinstall:
221-
222-
```bash
223-
cd ~/.config/opencode && npm install
121+
# Run tests
122+
bun run tests/debug.ts full
224123
```
225124
226-
## 📁 Project Structure
125+
### Project Structure
227126
228127
```
229128
src/
230-
├── constants.ts # OAuth endpoints, models config
231-
├── types.ts # TypeScript interfaces
232-
├── index.ts # Main plugin entry point
233-
├── qwen/
234-
│ └── oauth.ts # OAuth Device Flow + PKCE
235-
└── plugin/
236-
├── auth.ts # Credentials management
237-
└── utils.ts # Helper utilities
129+
├── qwen/ # OAuth implementation
130+
├── plugin/ # Token management & caching
131+
├── utils/ # Retry, locking and logging utilities
132+
├── constants.ts # Models and endpoints
133+
└── index.ts # Plugin entry point
238134
```
239135
240-
## 🔗 Related Projects
241-
242-
- [qwen-code](https://github.com/QwenLM/qwen-code) - Official Qwen coding CLI
243-
- [OpenCode](https://opencode.ai) - AI-powered CLI for development
244-
- [opencode-gemini-auth](https://github.com/jenslys/opencode-gemini-auth) - Similar plugin for Google Gemini
245-
246136
## 📄 License
247137
248138
MIT

0 commit comments

Comments
 (0)