Skip to content

Commit 4873f36

Browse files
docs: README in English with Portuguese translation
- Main README.md in English for international community - README.pt-BR.md in Brazilian Portuguese - Cross-links between both versions
1 parent 7468e82 commit 4873f36

2 files changed

Lines changed: 232 additions & 67 deletions

File tree

README.md

Lines changed: 69 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
# opencode-qwen-auth
22

3-
Plugin de autenticação OAuth para [OpenCode CLI](https://opencode.ai) que permite usar modelos Qwen3-Coder através da sua conta [qwen.ai](https://chat.qwen.ai) com **2.000 requisições gratuitas por dia**.
3+
OAuth authentication plugin for [OpenCode CLI](https://opencode.ai) that enables Qwen3-Coder models through your [qwen.ai](https://chat.qwen.ai) account with **2,000 free requests per day**.
44

5-
## Funcionalidades
5+
[Leia em Português](./README.pt-BR.md)
66

7-
- **OAuth Device Flow** - Autenticação segura via navegador (RFC 8628)
8-
- **Polling Automático** - Detecta automaticamente quando você autoriza no navegador
9-
- **2.000 req/dia grátis** - Sem necessidade de cartão de crédito
10-
- **1M de contexto** - Modelos com janela de contexto de 1 milhão de tokens
11-
- **Auto-refresh** - Renova tokens automaticamente quando expiram
12-
- **Compatível com qwen-code** - Reutiliza credenciais existentes de `~/.qwen/oauth_creds.json`
7+
## Features
138

14-
## Instalação
9+
- **OAuth Device Flow** - Secure browser-based authentication (RFC 8628)
10+
- **Automatic Polling** - Automatically detects when you authorize in the browser
11+
- **2,000 req/day free** - No credit card required
12+
- **1M context window** - Models with 1 million token context windows
13+
- **Auto-refresh** - Automatically renews tokens when they expire
14+
- **qwen-code compatible** - Reuses existing credentials from `~/.qwen/oauth_creds.json`
1515

16-
### 1. Adicione o plugin ao OpenCode
16+
## Installation
1717

18-
Edite `~/.opencode/package.json`:
18+
### 1. Add the plugin to OpenCode
19+
20+
Edit `~/.opencode/package.json`:
1921

2022
```json
2123
{
@@ -25,137 +27,137 @@ Edite `~/.opencode/package.json`:
2527
}
2628
```
2729

28-
Edite `~/.opencode/opencode.jsonc`:
30+
Edit `~/.opencode/opencode.jsonc`:
2931

3032
```json
3133
{
3234
"plugin": ["opencode-qwen-auth"]
3335
}
3436
```
3537

36-
### 2. Instale as dependências
38+
### 2. Install dependencies
3739

3840
```bash
3941
cd ~/.opencode && npm install
4042
```
4143

42-
### 3. Autentique
44+
### 3. Authenticate
4345

44-
Inicie o OpenCode e selecione o provider **Qwen Code**:
46+
Start OpenCode and select the **Qwen Code** provider:
4547

4648
```bash
4749
opencode
4850
```
4951

50-
Ou via linha de comando (selecione "Other" e digite `qwen-code`):
52+
Or via command line (select "Other" and type `qwen-code`):
5153

5254
```bash
5355
opencode auth login
5456
```
5557

56-
Escolha **"Qwen Code (qwen.ai OAuth)"** e autorize no navegador.
58+
Choose **"Qwen Code (qwen.ai OAuth)"** and authorize in your browser.
5759

58-
### 4. Use os modelos Qwen
60+
### 4. Use Qwen models
5961

6062
```bash
6163
opencode --provider qwen-code --model qwen3-coder-plus
6264
```
6365

64-
## Modelos Disponíveis
66+
## Available Models
6567

66-
| Modelo | Contexto | Output | Descrição |
67-
|--------|----------|--------|-----------|
68-
| `qwen3-coder-plus` | 1M tokens | 64K tokens | Modelo mais capaz para programação |
69-
| `qwen3-coder-flash` | 1M tokens | 64K tokens | Respostas mais rápidas |
68+
| Model | Context | Output | Description |
69+
|-------|---------|--------|-------------|
70+
| `qwen3-coder-plus` | 1M tokens | 64K tokens | Most capable coding model |
71+
| `qwen3-coder-flash` | 1M tokens | 64K tokens | Faster responses |
7072

71-
## Como Funciona
73+
## How It Works
7274

73-
1. **Device Flow (RFC 8628)**: Ao fazer login, o plugin abre seu navegador para `chat.qwen.ai`
74-
2. **Polling Automático**: O plugin detecta automaticamente quando você autoriza (sem precisar pressionar Enter)
75-
3. **Armazenamento**: Credenciais são salvas em `~/.qwen/oauth_creds.json` (compatível com qwen-code)
76-
4. **Auto-refresh**: Tokens são renovados automaticamente 30 segundos antes de expirar
75+
1. **Device Flow (RFC 8628)**: When logging in, the plugin opens your browser to `chat.qwen.ai`
76+
2. **Automatic Polling**: The plugin automatically detects when you authorize (no need to press Enter)
77+
3. **Storage**: Credentials are saved to `~/.qwen/oauth_creds.json` (compatible with qwen-code)
78+
4. **Auto-refresh**: Tokens are automatically renewed 30 seconds before expiration
7779

78-
## Limites de Uso
80+
## Usage Limits
7981

80-
| Plano | Rate Limit | Limite Diário |
81-
|-------|------------|---------------|
82-
| Gratuito (OAuth) | 60 req/min | 2.000 req/dia |
82+
| Plan | Rate Limit | Daily Limit |
83+
|------|------------|-------------|
84+
| Free (OAuth) | 60 req/min | 2,000 req/day |
8385

84-
## Desenvolvimento Local
86+
## Local Development
8587

8688
```bash
87-
# Clone o repositório
89+
# Clone the repository
8890
git clone https://github.com/gustavodiasdev/opencode-qwen-auth.git
8991
cd opencode-qwen-auth
9092

91-
# Instale dependências
93+
# Install dependencies
9294
bun install
9395

94-
# Verifique tipos
96+
# Type check
9597
bun run typecheck
9698

97-
# Link local no OpenCode
98-
# Edite ~/.opencode/package.json:
99+
# Local link in OpenCode
100+
# Edit ~/.opencode/package.json:
99101
{
100102
"dependencies": {
101-
"opencode-qwen-auth": "file:/caminho/absoluto/para/opencode-qwen-auth"
103+
"opencode-qwen-auth": "file:/absolute/path/to/opencode-qwen-auth"
102104
}
103105
}
104106

105-
# Reinstale
107+
# Reinstall
106108
cd ~/.opencode && npm install
107109
```
108110

109-
## Estrutura do Projeto
111+
## Project Structure
110112

111113
```
112114
src/
113-
├── constants.ts # Constantes (endpoints OAuth, modelos)
114-
├── types.ts # Interfaces TypeScript
115-
├── index.ts # Plugin principal
116-
├── cli.ts # CLI standalone (opcional)
115+
├── constants.ts # Constants (OAuth endpoints, models)
116+
├── types.ts # TypeScript interfaces
117+
├── index.ts # Main plugin
118+
├── cli.ts # Standalone CLI (optional)
117119
├── qwen/
118-
│ └── oauth.ts # Lógica OAuth Device Flow + PKCE
120+
│ └── oauth.ts # OAuth Device Flow + PKCE logic
119121
└── plugin/
120-
├── auth.ts # Gerenciamento de credenciais
121-
├── client.ts # Cliente API Qwen
122-
└── utils.ts # Utilitários
122+
├── auth.ts # Credentials management
123+
├── client.ts # Qwen API client
124+
└── utils.ts # Utilities
123125
```
124126

125127
## Troubleshooting
126128

127-
### Token expirado
129+
### Token expired
128130

129-
O plugin renova tokens automaticamente. Se houver problemas:
131+
The plugin automatically renews tokens. If issues persist:
130132

131133
```bash
132-
# Remova credenciais antigas
134+
# Remove old credentials
133135
rm ~/.qwen/oauth_creds.json
134136

135-
# Re-autentique
137+
# Re-authenticate
136138
opencode auth login
137139
```
138140

139-
### Provider não aparece no `auth login`
141+
### Provider not showing in `auth login`
140142

141-
O provider `qwen-code` é adicionado via plugin. No comando `opencode auth login`:
142-
1. Selecione **"Other"**
143-
2. Digite `qwen-code`
143+
The `qwen-code` provider is added via plugin. In the `opencode auth login` command:
144+
1. Select **"Other"**
145+
2. Type `qwen-code`
144146

145-
No TUI (interface gráfica do OpenCode), o provider aparece automaticamente.
147+
In the TUI (OpenCode graphical interface), the provider appears automatically.
146148

147-
### Rate limit excedido
149+
### Rate limit exceeded
148150

149-
Se atingir o limite diário (2.000 requisições):
150-
- Aguarde até meia-noite UTC para reset
151-
- Considere usar API Key do [DashScope](https://dashscope.aliyun.com) para limites maiores
151+
If you hit the daily limit (2,000 requests):
152+
- Wait until midnight UTC for quota reset
153+
- Consider using an API Key from [DashScope](https://dashscope.aliyun.com) for higher limits
152154

153-
## Projetos Relacionados
155+
## Related Projects
154156

155-
- [qwen-code](https://github.com/QwenLM/qwen-code) - CLI oficial do Qwen para programação
156-
- [OpenCode](https://opencode.ai) - CLI de IA para desenvolvimento
157-
- [opencode-gemini-auth](https://github.com/jenslys/opencode-gemini-auth) - Plugin similar para Google Gemini
157+
- [qwen-code](https://github.com/QwenLM/qwen-code) - Official Qwen coding CLI
158+
- [OpenCode](https://opencode.ai) - AI CLI for development
159+
- [opencode-gemini-auth](https://github.com/jenslys/opencode-gemini-auth) - Similar plugin for Google Gemini
158160

159-
## Licença
161+
## License
160162

161163
MIT

README.pt-BR.md

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# opencode-qwen-auth
2+
3+
Plugin de autenticação OAuth para [OpenCode CLI](https://opencode.ai) que permite usar modelos Qwen3-Coder através da sua conta [qwen.ai](https://chat.qwen.ai) com **2.000 requisições gratuitas por dia**.
4+
5+
[Read in English](./README.md)
6+
7+
## Funcionalidades
8+
9+
- **OAuth Device Flow** - Autenticação segura via navegador (RFC 8628)
10+
- **Polling Automático** - Detecta automaticamente quando você autoriza no navegador
11+
- **2.000 req/dia grátis** - Sem necessidade de cartão de crédito
12+
- **1M de contexto** - Modelos com janela de contexto de 1 milhão de tokens
13+
- **Auto-refresh** - Renova tokens automaticamente quando expiram
14+
- **Compatível com qwen-code** - Reutiliza credenciais existentes de `~/.qwen/oauth_creds.json`
15+
16+
## Instalação
17+
18+
### 1. Adicione o plugin ao OpenCode
19+
20+
Edite `~/.opencode/package.json`:
21+
22+
```json
23+
{
24+
"dependencies": {
25+
"opencode-qwen-auth": "github:gustavodiasdev/opencode-qwen-auth"
26+
}
27+
}
28+
```
29+
30+
Edite `~/.opencode/opencode.jsonc`:
31+
32+
```json
33+
{
34+
"plugin": ["opencode-qwen-auth"]
35+
}
36+
```
37+
38+
### 2. Instale as dependências
39+
40+
```bash
41+
cd ~/.opencode && npm install
42+
```
43+
44+
### 3. Autentique
45+
46+
Inicie o OpenCode e selecione o provider **Qwen Code**:
47+
48+
```bash
49+
opencode
50+
```
51+
52+
Ou via linha de comando (selecione "Other" e digite `qwen-code`):
53+
54+
```bash
55+
opencode auth login
56+
```
57+
58+
Escolha **"Qwen Code (qwen.ai OAuth)"** e autorize no navegador.
59+
60+
### 4. Use os modelos Qwen
61+
62+
```bash
63+
opencode --provider qwen-code --model qwen3-coder-plus
64+
```
65+
66+
## Modelos Disponíveis
67+
68+
| Modelo | Contexto | Output | Descrição |
69+
|--------|----------|--------|-----------|
70+
| `qwen3-coder-plus` | 1M tokens | 64K tokens | Modelo mais capaz para programação |
71+
| `qwen3-coder-flash` | 1M tokens | 64K tokens | Respostas mais rápidas |
72+
73+
## Como Funciona
74+
75+
1. **Device Flow (RFC 8628)**: Ao fazer login, o plugin abre seu navegador para `chat.qwen.ai`
76+
2. **Polling Automático**: O plugin detecta automaticamente quando você autoriza (sem precisar pressionar Enter)
77+
3. **Armazenamento**: Credenciais são salvas em `~/.qwen/oauth_creds.json` (compatível com qwen-code)
78+
4. **Auto-refresh**: Tokens são renovados automaticamente 30 segundos antes de expirar
79+
80+
## Limites de Uso
81+
82+
| Plano | Rate Limit | Limite Diário |
83+
|-------|------------|---------------|
84+
| Gratuito (OAuth) | 60 req/min | 2.000 req/dia |
85+
86+
## Desenvolvimento Local
87+
88+
```bash
89+
# Clone o repositório
90+
git clone https://github.com/gustavodiasdev/opencode-qwen-auth.git
91+
cd opencode-qwen-auth
92+
93+
# Instale dependências
94+
bun install
95+
96+
# Verifique tipos
97+
bun run typecheck
98+
99+
# Link local no OpenCode
100+
# Edite ~/.opencode/package.json:
101+
{
102+
"dependencies": {
103+
"opencode-qwen-auth": "file:/caminho/absoluto/para/opencode-qwen-auth"
104+
}
105+
}
106+
107+
# Reinstale
108+
cd ~/.opencode && npm install
109+
```
110+
111+
## Estrutura do Projeto
112+
113+
```
114+
src/
115+
├── constants.ts # Constantes (endpoints OAuth, modelos)
116+
├── types.ts # Interfaces TypeScript
117+
├── index.ts # Plugin principal
118+
├── cli.ts # CLI standalone (opcional)
119+
├── qwen/
120+
│ └── oauth.ts # Lógica OAuth Device Flow + PKCE
121+
└── plugin/
122+
├── auth.ts # Gerenciamento de credenciais
123+
├── client.ts # Cliente API Qwen
124+
└── utils.ts # Utilitários
125+
```
126+
127+
## Troubleshooting
128+
129+
### Token expirado
130+
131+
O plugin renova tokens automaticamente. Se houver problemas:
132+
133+
```bash
134+
# Remova credenciais antigas
135+
rm ~/.qwen/oauth_creds.json
136+
137+
# Re-autentique
138+
opencode auth login
139+
```
140+
141+
### Provider não aparece no `auth login`
142+
143+
O provider `qwen-code` é adicionado via plugin. No comando `opencode auth login`:
144+
1. Selecione **"Other"**
145+
2. Digite `qwen-code`
146+
147+
No TUI (interface gráfica do OpenCode), o provider aparece automaticamente.
148+
149+
### Rate limit excedido
150+
151+
Se atingir o limite diário (2.000 requisições):
152+
- Aguarde até meia-noite UTC para reset
153+
- Considere usar API Key do [DashScope](https://dashscope.aliyun.com) para limites maiores
154+
155+
## Projetos Relacionados
156+
157+
- [qwen-code](https://github.com/QwenLM/qwen-code) - CLI oficial do Qwen para programação
158+
- [OpenCode](https://opencode.ai) - CLI de IA para desenvolvimento
159+
- [opencode-gemini-auth](https://github.com/jenslys/opencode-gemini-auth) - Plugin similar para Google Gemini
160+
161+
## Licença
162+
163+
MIT

0 commit comments

Comments
 (0)