qwen-opencode-provider 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +41 -22
  2. package/index.js +34 -86
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,12 +1,6 @@
1
1
  # OpenCode Qwen Plugin
2
2
 
3
- OpenCode plugin for Qwen AI - auto adds provider with 28+ models.
4
-
5
- ## Features
6
-
7
- - **Auto-configure**: Automatically adds Qwen provider to OpenCode
8
- - **28+ Models**: All Qwen models pre-configured
9
- - **Native auth**: Uses OpenCode's built-in auth system (`/connect`)
3
+ OpenCode plugin for Qwen AI - auto-configures models when provider is added.
10
4
 
11
5
  ## Installation
12
6
 
@@ -17,25 +11,54 @@ Add to `opencode.json`:
17
11
  }
18
12
  ```
19
13
 
20
- ## Usage
14
+ ## Setup Provider
15
+
16
+ ### Step 1: Add Provider Config
17
+
18
+ Add this to your `opencode.json`:
19
+
20
+ ```json
21
+ {
22
+ "$schema": "https://opencode.ai/config.json",
23
+ "plugin": ["qwen-opencode-provider"],
24
+ "provider": {
25
+ "qwen": {
26
+ "npm": "@ai-sdk/openai-compatible",
27
+ "name": "Qwen AI",
28
+ "options": {
29
+ "baseURL": "https://qwen.aikit.club/v1"
30
+ },
31
+ "models": {
32
+ "qwen-max": { "name": "Qwen Max" },
33
+ "qwen2.5-max": { "name": "Qwen2.5 Max" },
34
+ "qwen2.5-plus": { "name": "Qwen2.5 Plus" },
35
+ "qwen2.5-turbo": { "name": "Qwen2.5 Turbo" },
36
+ "qwen2.5-coder-32b-instruct": { "name": "Qwen2.5 Coder 32B" },
37
+ "qwen3-coder": { "name": "Qwen3 Coder" },
38
+ "qwen3-max": { "name": "Qwen3 Max" },
39
+ "qwq-32b": { "name": "QWQ 32B" },
40
+ "qwen-deep-research": { "name": "Qwen Deep Research" }
41
+ }
42
+ }
43
+ }
44
+ }
45
+ ```
46
+
47
+ ### Step 2: Connect
21
48
 
22
- ### 1. Connect Qwen Account
23
49
  ```bash
24
50
  /connect
51
+ # Select: Other
52
+ # Enter: qwen
53
+ # Enter your Qwen token
25
54
  ```
26
- Search for "qwen" and enter your Qwen access token.
27
55
 
28
- ### 2. Get Your Token
56
+ ### Step 3: Get Token
57
+
29
58
  1. Visit https://chat.qwen.ai and login
30
59
  2. Open Developer Console (F12)
31
60
  3. Run: `localStorage.getItem('token')`
32
61
 
33
- ### 3. Select Model
34
- ```bash
35
- /models
36
- ```
37
- Choose any Qwen model.
38
-
39
62
  ## Supported Models
40
63
 
41
64
  | Model | Description |
@@ -53,14 +76,10 @@ Choose any Qwen model.
53
76
  | qwen-full-stack | Full-stack apps |
54
77
  | qwen-cogview | Image generation |
55
78
 
56
- ## API Features
79
+ ## Features
57
80
 
58
81
  - 👁️ Vision (image analysis)
59
82
  - 🌐 Web Search
60
83
  - 🧠 Thinking Mode
61
84
  - 🎨 Image Generation
62
85
  - 👨‍💻 Code Generation
63
-
64
- ## License
65
-
66
- MIT
package/index.js CHANGED
@@ -1,18 +1,33 @@
1
1
  /**
2
2
  * OpenCode Qwen API Plugin
3
3
  *
4
- * Automatically adds Qwen AI provider to OpenCode with 28+ models.
5
- * Uses OpenCode's built-in auth system (/connect).
4
+ * Automatically configures Qwen AI models when provider is added.
5
+ * No auto-creation of config files.
6
6
  *
7
- * Provider ID: qwen
8
- * Base URL: https://qwen.aikit.club/v1
7
+ * Usage:
8
+ * 1. Add to opencode.json: { "plugin": ["qwen-opencode-provider"] }
9
+ * 2. Add provider "qwen" to config (see below)
10
+ * 3. Run /connect and select "Other" -> "qwen"
11
+ *
12
+ * Provider config for opencode.json:
13
+ * {
14
+ * "provider": {
15
+ * "qwen": {
16
+ * "npm": "@ai-sdk/openai-compatible",
17
+ * "name": "Qwen AI",
18
+ * "options": {
19
+ * "baseURL": "https://qwen.aikit.club/v1"
20
+ * },
21
+ * "models": {
22
+ * "qwen-max": { "name": "Qwen Max" },
23
+ * "qwen2.5-max": { "name": "Qwen2.5 Max" },
24
+ * ...
25
+ * }
26
+ * }
27
+ * }
28
+ * }
9
29
  */
10
30
 
11
- import { readFileSync, writeFileSync, existsSync } from 'fs';
12
- import { join } from 'path';
13
- import { homedir } from 'os';
14
-
15
- const QWEN_BASE_URL = 'https://qwen.aikit.club/v1';
16
31
  const QWEN_PROVIDER_ID = 'qwen';
17
32
 
18
33
  const QWEN_MODELS = {
@@ -44,86 +59,19 @@ const QWEN_MODELS = {
44
59
  "qwen-cogview": { name: "Qwen CogView", description: "Image generation" }
45
60
  };
46
61
 
47
- function getConfigPath() {
48
- return join(homedir(), '.config', 'opencode', 'opencode.json');
49
- }
50
-
51
- function readConfig() {
52
- const configPath = getConfigPath();
53
- if (!existsSync(configPath)) return null;
54
- try {
55
- return JSON.parse(readFileSync(configPath, 'utf-8'));
56
- } catch {
57
- return null;
58
- }
59
- }
60
-
61
- function writeConfig(config) {
62
- writeFileSync(getConfigPath(), JSON.stringify(config, null, 2));
63
- }
64
-
65
- function isQwenProviderConfigured(config) {
66
- return config?.provider?.[QWEN_PROVIDER_ID] !== undefined;
67
- }
68
-
69
- function addQwenProvider() {
70
- let config = readConfig();
71
-
72
- const qwenConfig = {
73
- npm: "@ai-sdk/openai-compatible",
74
- name: "Qwen AI",
75
- options: {
76
- baseURL: QWEN_BASE_URL,
77
- headers: {
78
- "Authorization": "Bearer ${QWEN_API_KEY}"
79
- }
80
- },
81
- models: QWEN_MODELS
82
- };
83
-
84
- if (!config) {
85
- config = {
86
- $schema: "https://opencode.ai/config.json",
87
- provider: {
88
- [QWEN_PROVIDER_ID]: qwenConfig
89
- }
90
- };
91
- } else {
92
- if (!config.provider) config.provider = {};
93
- if (!isQwenProviderConfigured(config)) {
94
- config.provider[QWEN_PROVIDER_ID] = qwenConfig;
95
- }
96
- }
97
-
98
- writeConfig(config);
99
- return true;
100
- }
101
-
102
62
  export const QwenPlugin = async ({ client }) => {
103
- try {
104
- const config = readConfig();
105
- if (!isQwenProviderConfigured(config)) {
106
- addQwenProvider();
107
- await client.app.log({
108
- body: {
109
- service: "qwen-plugin",
110
- level: "info",
111
- message: "Qwen provider added to OpenCode config"
112
- }
113
- });
114
- }
115
- } catch (error) {
116
- // Silent fail
117
- }
118
-
119
63
  return {
120
- "installation.updated": async ({ installation }) {
64
+ "installation.updated": async ({ installation }) => {
65
+ // This hook runs when installation is updated
66
+ // Models are already defined in config, this is just for future updates
121
67
  try {
122
- const config = readConfig();
123
- if (config?.provider?.[QWEN_PROVIDER_ID]) {
124
- config.provider[QWEN_PROVIDER_ID].models = QWEN_MODELS;
125
- writeConfig(config);
126
- }
68
+ await client.app.log({
69
+ body: {
70
+ service: "qwen-plugin",
71
+ level: "info",
72
+ message: "Qwen plugin loaded - use /connect and select Other -> qwen"
73
+ }
74
+ });
127
75
  } catch (error) {
128
76
  // Silent fail
129
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qwen-opencode-provider",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "OpenCode plugin for Qwen API - auto adds provider with 28+ models",
5
5
  "main": "index.js",
6
6
  "type": "module",