duojie-helper 0.2.18 → 0.2.20

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/bin/cli.js CHANGED
@@ -48,8 +48,9 @@ program
48
48
  type: 'input',
49
49
  name: 'apiKey',
50
50
  message: '请输入你的 Duojie API Key (Ctrl+C 退出):',
51
+ filter: (input) => input.trim(),
51
52
  validate: (input) => {
52
- if (!input || input.trim().length < 10) {
53
+ if (!input || input.length < 10) {
53
54
  return 'API Key 不能为空且长度至少 10 位';
54
55
  }
55
56
  return true;
@@ -217,18 +218,21 @@ program
217
218
  type: 'input',
218
219
  name: 'apiKey',
219
220
  message: '请输入你的 Duojie API Key:',
221
+ filter: (input) => input.trim(),
220
222
  }
221
223
  ]);
222
224
  apiKey = answer.apiKey;
225
+ } else {
226
+ apiKey = apiKey.trim();
223
227
  }
224
228
 
225
229
  // 获取模型列表
226
230
  const spinner = ora('正在验证 API Key...').start();
227
- await fetchModels(apiKey.trim());
231
+ await fetchModels(apiKey);
228
232
  spinner.succeed('验证成功');
229
233
 
230
234
  const configSpinner = ora(`正在配置 ${tool}...`).start();
231
- const result = await configureTool(tool, apiKey.trim());
235
+ const result = await configureTool(tool, apiKey);
232
236
 
233
237
  if (result.success) {
234
238
  configSpinner.succeed(result.message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "duojie-helper",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "description": "Duojie API 一键配置助手 - 支持 Claude Code, Droid, OpenClaw, Cursor, Cline 等主流 AI 编程工具",
5
5
  "type": "module",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -105,12 +105,14 @@ export async function fetchModels(apiKey) {
105
105
  const id = model.id;
106
106
  // 跳过未在 pricing 页面公开的隐藏模型
107
107
  if (publicIds && !publicIds.has(id)) continue;
108
+ // 跳过含 image 的模型(图像生成类,不支持对话)
109
+ if (id.toLowerCase().includes('image')) continue;
108
110
  const endpoints = model.supported_endpoint_types || [];
109
111
 
110
- // 判断最佳协议
111
- let api = 'openai-completions'; // 默认
112
+ // 判断最佳协议:GPT 用 openai,其余统一用 anthropic-messages
113
+ let api = 'anthropic-messages'; // 默认
112
114
  if (id.startsWith('gpt')) {
113
- // GPT 模型优先用 openai-response,否则 openai
115
+ // GPT 模型优先用 openai-responses,否则 openai-completions
114
116
  if (endpoints.includes('openai-response')) {
115
117
  api = 'openai-responses';
116
118
  } else {
@@ -118,19 +120,12 @@ export async function fetchModels(apiKey) {
118
120
  }
119
121
  models.gpt.push({ id, name: id, api, endpoints });
120
122
  } else if (id.startsWith('claude')) {
121
- // Claude 模型用 anthropic
122
- api = 'anthropic-messages';
123
123
  models.claude.push({ id, name: id, api, endpoints });
124
124
  } else if (id.startsWith('gemini')) {
125
- // Gemini 模型
126
- api = endpoints.includes('anthropic') ? 'anthropic-messages' : 'openai-completions';
127
125
  models.gemini.push({ id, name: id, api, endpoints });
128
126
  } else if (id.startsWith('glm')) {
129
- // GLM 模型
130
- api = 'openai-completions';
131
127
  models.other.push({ id, name: id, api, endpoints });
132
128
  } else {
133
- api = endpoints.includes('anthropic') ? 'anthropic-messages' : 'openai-completions';
134
129
  models.other.push({ id, name: id, api, endpoints });
135
130
  }
136
131
  }
@@ -70,8 +70,8 @@ function generateDisplayName(modelId) {
70
70
  * @returns {string} provider 名称
71
71
  */
72
72
  function determineProvider(modelId, endpoints = []) {
73
- if (modelId.startsWith('claude')) return 'anthropic';
74
- return 'openai';
73
+ if (modelId.startsWith('gpt')) return 'openai';
74
+ return 'anthropic';
75
75
  }
76
76
 
77
77
  /**