duojie-helper 0.2.1 → 0.2.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "duojie-helper",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Duojie API 一键配置助手 - 支持 Claude Code, OpenClaw, Cursor, Cline 等主流 AI 编程工具",
5
5
  "type": "module",
6
6
  "bin": {
@@ -50,41 +50,40 @@ export async function configureClaudeCode(apiKey) {
50
50
  const models = getModels();
51
51
  const claudeModels = models.claude || [];
52
52
 
53
- // 查找各类型模型
53
+ // 查找各类型模型(优先查找 kiro 版本)
54
54
  let sonnetModel = null;
55
55
  let opusModel = null;
56
- let haikuModel = null;
57
56
 
58
57
  for (const m of claudeModels) {
59
58
  const id = m.id.toLowerCase();
60
- if (id.includes('sonnet') && !sonnetModel) {
61
- sonnetModel = m.id;
59
+ // 优先使用 kiro 版本的 opus
60
+ if (id.includes('opus') && id.includes('kiro')) {
61
+ opusModel = m.id;
62
62
  } else if (id.includes('opus') && !opusModel) {
63
63
  opusModel = m.id;
64
- } else if (id.includes('haiku') && !haikuModel) {
65
- haikuModel = m.id;
64
+ }
65
+ // sonnet 模型
66
+ if (id.includes('sonnet') && !sonnetModel) {
67
+ sonnetModel = m.id;
66
68
  }
67
69
  }
68
70
 
69
71
  // 4. 设置 Duojie API 环境变量
70
72
  settings.env.ANTHROPIC_API_KEY = apiKey;
71
- settings.env.ANTHROPIC_BASE_URL = `${API_CONFIG.baseUrl}/v1`;
73
+ settings.env.ANTHROPIC_BASE_URL = API_CONFIG.baseUrl;
72
74
  settings.env.API_TIMEOUT_MS = "300000";
73
75
  settings.env.ANTHROPIC_MAX_TOKENS = "8192";
74
76
 
75
- // 配置各类型模型
77
+ // 配置各类型模型(不配置 haiku/fast 模型)
76
78
  if (sonnetModel) {
77
79
  settings.env.ANTHROPIC_DEFAULT_SONNET_MODEL = sonnetModel;
78
80
  }
79
81
  if (opusModel) {
80
82
  settings.env.ANTHROPIC_DEFAULT_OPUS_MODEL = opusModel;
81
83
  }
82
- if (haikuModel) {
83
- settings.env.ANTHROPIC_DEFAULT_HAIKU_MODEL = haikuModel;
84
- }
85
84
 
86
- // 设置默认模型(优先 Opus
87
- const defaultModel = opusModel || sonnetModel || haikuModel || claudeModels[0]?.id;
85
+ // 设置默认主模型为 claude-opus-4-5-kiro(或可用的 opus
86
+ const defaultModel = opusModel || sonnetModel || claudeModels[0]?.id;
88
87
  if (defaultModel) {
89
88
  settings.model = defaultModel;
90
89
  }
@@ -94,9 +93,9 @@ export async function configureClaudeCode(apiKey) {
94
93
  configured: true,
95
94
  configuredAt: new Date().toISOString(),
96
95
  models: {
96
+ default: defaultModel,
97
97
  sonnet: sonnetModel,
98
98
  opus: opusModel,
99
- haiku: haikuModel,
100
99
  },
101
100
  };
102
101
 
@@ -117,7 +116,7 @@ export async function configureClaudeCode(apiKey) {
117
116
  await fs.writeJson(paths.claudeJson, claudeJson, { spaces: 2 });
118
117
 
119
118
  // 统计配置的模型数量
120
- const configuredModels = [sonnetModel, opusModel, haikuModel].filter(Boolean).length;
119
+ const configuredModels = [sonnetModel, opusModel].filter(Boolean).length;
121
120
 
122
121
  return {
123
122
  success: true,
@@ -182,7 +181,6 @@ configureClaudeCode.revoke = async function() {
182
181
  delete settings.env.ANTHROPIC_MAX_TOKENS;
183
182
  delete settings.env.ANTHROPIC_DEFAULT_SONNET_MODEL;
184
183
  delete settings.env.ANTHROPIC_DEFAULT_OPUS_MODEL;
185
- delete settings.env.ANTHROPIC_DEFAULT_HAIKU_MODEL;
186
184
 
187
185
  // 如果 env 为空,删除整个 env
188
186
  if (Object.keys(settings.env).length === 0) {
@@ -33,7 +33,7 @@ function getClineConfigPaths() {
33
33
  * Cline 需要通过 UI 手动配置,这里输出配置信息
34
34
  */
35
35
  export async function configureCline(apiKey) {
36
- const baseUrl = `${API_CONFIG.baseUrl}/v1`;
36
+ const baseUrl = API_CONFIG.baseUrl;
37
37
 
38
38
  // 生成配置说明
39
39
  const instructions = `
@@ -130,7 +130,7 @@ export async function configureCodex(apiKey) {
130
130
  // 构建新配置
131
131
  const duojieProvider = {
132
132
  name: 'Duojie',
133
- base_url: `${API_CONFIG.baseUrl}/v1`,
133
+ base_url: API_CONFIG.baseUrl,
134
134
  env_key: 'DUOJIE_API_KEY',
135
135
  wire_api: 'chat',
136
136
  };
@@ -178,7 +178,7 @@ export async function configureCodex(apiKey) {
178
178
  # Duojie API Provider
179
179
  [model_providers.duojie]
180
180
  name = "Duojie"
181
- base_url = "${API_CONFIG.baseUrl}/v1"
181
+ base_url = "${API_CONFIG.baseUrl}"
182
182
  env_key = "DUOJIE_API_KEY"
183
183
  wire_api = "chat"
184
184
  `;
@@ -45,7 +45,7 @@ export async function configureContinue(apiKey) {
45
45
  provider: "anthropic",
46
46
  model: m.id,
47
47
  apiKey: apiKey,
48
- apiBase: `${API_CONFIG.baseUrl}/v1`,
48
+ apiBase: API_CONFIG.baseUrl,
49
49
  completionOptions: {
50
50
  maxTokens: 8192,
51
51
  },
@@ -61,7 +61,7 @@ export async function configureContinue(apiKey) {
61
61
  provider: "openai",
62
62
  model: m.id,
63
63
  apiKey: apiKey,
64
- apiBase: `${API_CONFIG.baseUrl}/v1`,
64
+ apiBase: API_CONFIG.baseUrl,
65
65
  completionOptions: {
66
66
  maxTokens: 8192,
67
67
  },
@@ -77,7 +77,7 @@ export async function configureContinue(apiKey) {
77
77
  provider: "openai",
78
78
  model: m.id,
79
79
  apiKey: apiKey,
80
- apiBase: `${API_CONFIG.baseUrl}/v1`,
80
+ apiBase: API_CONFIG.baseUrl,
81
81
  completionOptions: {
82
82
  maxTokens: 8192,
83
83
  },
@@ -31,7 +31,7 @@ function getCursorConfigPaths() {
31
31
  * Cursor 需要通过 UI 手动配置自定义模型(需要高级会员)
32
32
  */
33
33
  export async function configureCursor(apiKey) {
34
- const baseUrl = `${API_CONFIG.baseUrl}/v1`;
34
+ const baseUrl = API_CONFIG.baseUrl;
35
35
 
36
36
  // 生成配置说明
37
37
  const instructions = `
@@ -94,7 +94,7 @@ export async function configureOpenClaw(apiKey) {
94
94
 
95
95
  if (claudeModels.length > 0) {
96
96
  providers['duojie-claude'] = {
97
- baseUrl: `${API_CONFIG.baseUrl}/v1`,
97
+ baseUrl: API_CONFIG.baseUrl,
98
98
  apiKey: apiKey,
99
99
  api: 'anthropic-messages',
100
100
  models: claudeModels,
@@ -105,7 +105,7 @@ export async function configureOpenClaw(apiKey) {
105
105
  // GPT 使用 openai-responses (如果支持) 或 openai-completions
106
106
  const gptApi = models.gpt[0]?.api || 'openai-responses';
107
107
  providers['duojie-gpt'] = {
108
- baseUrl: `${API_CONFIG.baseUrl}/v1`,
108
+ baseUrl: API_CONFIG.baseUrl,
109
109
  apiKey: apiKey,
110
110
  api: gptApi,
111
111
  models: gptModels,
@@ -114,7 +114,7 @@ export async function configureOpenClaw(apiKey) {
114
114
 
115
115
  if (geminiModels.length > 0) {
116
116
  providers['duojie-gemini'] = {
117
- baseUrl: `${API_CONFIG.baseUrl}/v1`,
117
+ baseUrl: API_CONFIG.baseUrl,
118
118
  apiKey: apiKey,
119
119
  api: 'anthropic-messages',
120
120
  models: geminiModels,
@@ -123,7 +123,7 @@ export async function configureOpenClaw(apiKey) {
123
123
 
124
124
  if (otherModels.length > 0) {
125
125
  providers['duojie-other'] = {
126
- baseUrl: `${API_CONFIG.baseUrl}/v1`,
126
+ baseUrl: API_CONFIG.baseUrl,
127
127
  apiKey: apiKey,
128
128
  api: 'openai-completions',
129
129
  models: otherModels,
@@ -117,7 +117,7 @@ export async function configureOpenCode(apiKey) {
117
117
  npm: '@ai-sdk/openai-compatible',
118
118
  name: 'Duojie API',
119
119
  options: {
120
- baseURL: `${API_CONFIG.baseUrl}/v1`,
120
+ baseURL: API_CONFIG.baseUrl,
121
121
  },
122
122
  models: duojieModels,
123
123
  };