duojie-helper 0.2.14 → 0.2.16
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.
- package/package.json +1 -1
- package/src/tools/claude.js +3 -2
- package/src/tools/cline.js +1 -1
- package/src/tools/codex.js +1 -1
- package/src/tools/continue.js +13 -5
- package/src/tools/cursor.js +2 -2
- package/src/tools/droid.js +14 -20
- package/src/tools/openclaw.js +12 -9
- package/src/tools/opencode.js +4 -1
package/package.json
CHANGED
package/src/tools/claude.js
CHANGED
|
@@ -78,8 +78,9 @@ export async function configureClaudeCode(apiKey) {
|
|
|
78
78
|
settings.env.ANTHROPIC_DEFAULT_OPUS_MODEL = opusModel;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
//
|
|
82
|
-
const
|
|
81
|
+
// 优先将默认主模型设为 gpt-5.2(如存在),否则回退到 opus/sonnet/首个 claude
|
|
82
|
+
const gpt52 = (models.gpt || []).find(m => m.id === 'gpt-5.2')?.id || null;
|
|
83
|
+
const defaultModel = gpt52 || opusModel || sonnetModel || claudeModels[0]?.id;
|
|
83
84
|
if (defaultModel) {
|
|
84
85
|
settings.model = defaultModel;
|
|
85
86
|
}
|
package/src/tools/cline.js
CHANGED
|
@@ -48,7 +48,7 @@ ${chalk.cyan('步骤 4:')} 填入以下配置:
|
|
|
48
48
|
${chalk.green('Base URL:')} ${baseUrl}
|
|
49
49
|
${chalk.green('API Key:')} ${apiKey}
|
|
50
50
|
${chalk.green('Model:')} 选择 "Enter model ID" 并输入模型名称
|
|
51
|
-
例如: claude-opus-4-6-kiro
|
|
51
|
+
例如: gpt-5.2 或 claude-opus-4-6-kiro
|
|
52
52
|
|
|
53
53
|
${chalk.cyan('步骤 5:')} 可选配置:
|
|
54
54
|
• ${chalk.green('Max Tokens:')} 8192 (推荐)
|
package/src/tools/codex.js
CHANGED
package/src/tools/continue.js
CHANGED
|
@@ -58,10 +58,10 @@ export async function configureContinue(apiKey) {
|
|
|
58
58
|
for (const m of models.gpt) {
|
|
59
59
|
duojieModels.push({
|
|
60
60
|
title: `Duojie ${m.name}`,
|
|
61
|
-
provider: "
|
|
61
|
+
provider: "anthropic",
|
|
62
62
|
model: m.id,
|
|
63
63
|
apiKey: apiKey,
|
|
64
|
-
apiBase: getApiBaseForProtocol('
|
|
64
|
+
apiBase: getApiBaseForProtocol('anthropic'),
|
|
65
65
|
completionOptions: {
|
|
66
66
|
maxTokens: 8192,
|
|
67
67
|
},
|
|
@@ -69,21 +69,29 @@ export async function configureContinue(apiKey) {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
// 添加其他模型
|
|
72
|
+
// 添加其他模型
|
|
73
73
|
const otherModels = [...(models.gemini || []), ...(models.other || [])];
|
|
74
74
|
for (const m of otherModels) {
|
|
75
75
|
duojieModels.push({
|
|
76
76
|
title: `Duojie ${m.name}`,
|
|
77
|
-
provider: "
|
|
77
|
+
provider: "anthropic",
|
|
78
78
|
model: m.id,
|
|
79
79
|
apiKey: apiKey,
|
|
80
|
-
apiBase: getApiBaseForProtocol('
|
|
80
|
+
apiBase: getApiBaseForProtocol('anthropic'),
|
|
81
81
|
completionOptions: {
|
|
82
82
|
maxTokens: 8192,
|
|
83
83
|
},
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
// 把默认模型尽量设为 gpt-5.2(如果存在),否则保持当前顺序
|
|
88
|
+
const gpt52 = duojieModels.find(m => m.model === 'gpt-5.2');
|
|
89
|
+
if (gpt52) {
|
|
90
|
+
const others = duojieModels.filter(m => m !== gpt52);
|
|
91
|
+
duojieModels.length = 0;
|
|
92
|
+
duojieModels.push(gpt52, ...others);
|
|
93
|
+
}
|
|
94
|
+
|
|
87
95
|
// 合并模型配置 - 移除旧的 Duojie 配置
|
|
88
96
|
const existingModels = config.models || [];
|
|
89
97
|
const filteredModels = existingModels.filter(m =>
|
package/src/tools/cursor.js
CHANGED
|
@@ -47,8 +47,8 @@ ${chalk.cyan('步骤 3:')} 填入以下配置:
|
|
|
47
47
|
${chalk.green('OpenAI API Key:')} ${apiKey}
|
|
48
48
|
${chalk.green('Override OpenAI Base URL:')} ${baseUrl}
|
|
49
49
|
${chalk.green('Model Name:')} 输入模型名称(注意大小写)
|
|
50
|
-
例如:
|
|
51
|
-
或:
|
|
50
|
+
例如: gpt-5.2
|
|
51
|
+
或: claude-opus-4-6-kiro
|
|
52
52
|
|
|
53
53
|
${chalk.cyan('步骤 4:')} 点击保存,然后在模型列表中选择刚添加的模型
|
|
54
54
|
|
package/src/tools/droid.js
CHANGED
|
@@ -3,6 +3,10 @@ import path from 'path';
|
|
|
3
3
|
import os from 'os';
|
|
4
4
|
import { API_CONFIG, getModels, getApiBaseForProtocol } from '../index.js';
|
|
5
5
|
|
|
6
|
+
function normalizeBaseUrl(url) {
|
|
7
|
+
return `${url || ''}`.replace(/\/+$/, '');
|
|
8
|
+
}
|
|
9
|
+
|
|
6
10
|
/**
|
|
7
11
|
* 获取 Droid (Factory) 配置路径
|
|
8
12
|
*/
|
|
@@ -65,24 +69,7 @@ function generateDisplayName(modelId) {
|
|
|
65
69
|
* @returns {string} provider 名称
|
|
66
70
|
*/
|
|
67
71
|
function determineProvider(modelId, endpoints = []) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (id.startsWith('gpt')) {
|
|
71
|
-
// GPT 模型使用 openai-response
|
|
72
|
-
return 'openai-response';
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Claude, Gemini, GLM 等使用 anthropic
|
|
76
|
-
if (id.startsWith('claude') || id.startsWith('gemini') || id.startsWith('glm')) {
|
|
77
|
-
return 'anthropic';
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// 其他模型根据 endpoints 判断
|
|
81
|
-
if (endpoints.includes('anthropic')) {
|
|
82
|
-
return 'anthropic';
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return 'openai-response';
|
|
72
|
+
return 'anthropic';
|
|
86
73
|
}
|
|
87
74
|
|
|
88
75
|
/**
|
|
@@ -126,15 +113,22 @@ export async function configureDroid(apiKey) {
|
|
|
126
113
|
...(models.gemini || []),
|
|
127
114
|
...(models.other || []),
|
|
128
115
|
];
|
|
116
|
+
|
|
117
|
+
// 默认模型优先放在列表前(便于用户在 UI 中选择)
|
|
118
|
+
const preferredId = 'gpt-5.2';
|
|
119
|
+
const preferred = allModels.find(m => m.id === preferredId) || null;
|
|
120
|
+
const orderedModels = preferred
|
|
121
|
+
? [preferred, ...allModels.filter(m => m.id !== preferredId)]
|
|
122
|
+
: allModels;
|
|
129
123
|
|
|
130
|
-
for (const m of
|
|
124
|
+
for (const m of orderedModels) {
|
|
131
125
|
const endpoints = endpointsMap[m.id] || [];
|
|
132
126
|
const provider = determineProvider(m.id, endpoints);
|
|
133
127
|
|
|
134
128
|
duojieModels.push({
|
|
135
129
|
model_display_name: generateDisplayName(m.id),
|
|
136
130
|
model: m.id,
|
|
137
|
-
base_url: getApiBaseForProtocol(provider),
|
|
131
|
+
base_url: normalizeBaseUrl(getApiBaseForProtocol(provider)),
|
|
138
132
|
api_key: apiKey,
|
|
139
133
|
provider: provider,
|
|
140
134
|
supports_vision: true,
|
package/src/tools/openclaw.js
CHANGED
|
@@ -85,36 +85,39 @@ export async function configureOpenClaw(apiKey) {
|
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
if (gptModels.length > 0) {
|
|
88
|
-
const gptApi = models.gpt[0]?.api === 'openai-responses' ? 'openai-responses' : 'openai-completions';
|
|
89
88
|
providers['duojie-gpt'] = {
|
|
90
|
-
baseUrl: getApiBaseForProtocol(
|
|
89
|
+
baseUrl: getApiBaseForProtocol('anthropic-messages'),
|
|
91
90
|
apiKey,
|
|
92
|
-
api:
|
|
91
|
+
api: 'anthropic-messages',
|
|
93
92
|
models: gptModels,
|
|
94
93
|
};
|
|
95
94
|
}
|
|
96
95
|
if (geminiModels.length > 0) {
|
|
97
96
|
providers['duojie-gemini'] = {
|
|
98
|
-
baseUrl: getApiBaseForProtocol('
|
|
97
|
+
baseUrl: getApiBaseForProtocol('anthropic-messages'),
|
|
99
98
|
apiKey,
|
|
100
|
-
api: '
|
|
99
|
+
api: 'anthropic-messages',
|
|
101
100
|
models: geminiModels,
|
|
102
101
|
};
|
|
103
102
|
}
|
|
104
103
|
if (otherModels.length > 0) {
|
|
105
104
|
providers['duojie-other'] = {
|
|
106
|
-
baseUrl: getApiBaseForProtocol('
|
|
105
|
+
baseUrl: getApiBaseForProtocol('anthropic-messages'),
|
|
107
106
|
apiKey,
|
|
108
|
-
api: '
|
|
107
|
+
api: 'anthropic-messages',
|
|
109
108
|
models: otherModels,
|
|
110
109
|
};
|
|
111
110
|
}
|
|
112
111
|
|
|
113
|
-
//
|
|
112
|
+
// 默认模型:优先 gpt-5.2(如存在)
|
|
113
|
+
const gpt52 = (models.gpt || []).find(m => m.id === 'gpt-5.2')?.id || null;
|
|
114
114
|
let defaultProvider = 'duojie-claude';
|
|
115
115
|
let defaultModelId = 'claude-opus-4-6-kiro';
|
|
116
116
|
|
|
117
|
-
if (
|
|
117
|
+
if (gpt52) {
|
|
118
|
+
defaultProvider = 'duojie-gpt';
|
|
119
|
+
defaultModelId = gpt52;
|
|
120
|
+
} else if (claudeModels.length > 0) {
|
|
118
121
|
defaultProvider = 'duojie-claude';
|
|
119
122
|
defaultModelId = (
|
|
120
123
|
claudeModels.find(m => m.id.includes('opus-4-6') && m.id.includes('kiro')) ||
|
package/src/tools/opencode.js
CHANGED
|
@@ -115,7 +115,7 @@ export async function configureOpenCode(apiKey) {
|
|
|
115
115
|
npm: '@ai-sdk/anthropic',
|
|
116
116
|
name: 'Duojie API',
|
|
117
117
|
options: {
|
|
118
|
-
baseURL:
|
|
118
|
+
baseURL: API_CONFIG.baseUrl,
|
|
119
119
|
},
|
|
120
120
|
models: duojieModels,
|
|
121
121
|
};
|
|
@@ -126,6 +126,8 @@ export async function configureOpenCode(apiKey) {
|
|
|
126
126
|
delete existingConfig.provider.duojie;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
const preferredModel = duojieModels['gpt-5.2'] ? 'duojie/gpt-5.2' : null;
|
|
130
|
+
|
|
129
131
|
const newConfig = {
|
|
130
132
|
...existingConfig,
|
|
131
133
|
$schema: existingConfig.$schema || 'https://opencode.ai/config.json',
|
|
@@ -133,6 +135,7 @@ export async function configureOpenCode(apiKey) {
|
|
|
133
135
|
...existingConfig.provider,
|
|
134
136
|
duojie: duojieProvider,
|
|
135
137
|
},
|
|
138
|
+
...(preferredModel ? { model: preferredModel } : {}),
|
|
136
139
|
};
|
|
137
140
|
|
|
138
141
|
// 6. 写入配置文件
|