@pikecode/api-key-manager 1.0.16 → 1.0.17
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/commands/add.js +0 -4
- package/src/config.js +4 -5
- package/bin/cc.js +0 -101
package/package.json
CHANGED
package/src/commands/add.js
CHANGED
|
@@ -313,12 +313,8 @@ class ProviderAdder extends BaseCommand {
|
|
|
313
313
|
? await this.promptModelConfiguration()
|
|
314
314
|
: { primaryModel: null, smallFastModel: null };
|
|
315
315
|
|
|
316
|
-
// 如果是 Codex 快捷方式,确保 ideName 被设置为 'codex'
|
|
317
|
-
const finalIdeName = forceCodex ? 'codex' : answers.ideName;
|
|
318
|
-
|
|
319
316
|
await this.configManager.addProvider(answers.name, {
|
|
320
317
|
displayName: answers.displayName || answers.name,
|
|
321
|
-
ideName: finalIdeName, // 'claude' 或 'codex'
|
|
322
318
|
baseUrl: answers.baseUrl,
|
|
323
319
|
authToken: answers.authToken,
|
|
324
320
|
authMode: answers.authMode,
|
package/src/config.js
CHANGED
|
@@ -85,8 +85,7 @@ class ConfigManager {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
_migrateAuthModes() {
|
|
88
|
-
//
|
|
89
|
-
// 同时为旧配置添加 ideName 字段(默认为 'claude')
|
|
88
|
+
// 迁移旧配置以保持向后兼容
|
|
90
89
|
if (this.config.providers) {
|
|
91
90
|
Object.keys(this.config.providers).forEach(key => {
|
|
92
91
|
const provider = this.config.providers[key];
|
|
@@ -96,7 +95,7 @@ class ConfigManager {
|
|
|
96
95
|
provider.authMode = 'auth_token';
|
|
97
96
|
}
|
|
98
97
|
|
|
99
|
-
//
|
|
98
|
+
// 为旧配置添加 ideName 字段(历史兼容性字段,默认为 'claude')
|
|
100
99
|
if (!provider.ideName) {
|
|
101
100
|
provider.ideName = 'claude';
|
|
102
101
|
}
|
|
@@ -153,11 +152,11 @@ class ConfigManager {
|
|
|
153
152
|
this.config.providers[name] = {
|
|
154
153
|
name,
|
|
155
154
|
displayName: providerConfig.displayName || name,
|
|
156
|
-
ideName: providerConfig.ideName || 'claude', //
|
|
155
|
+
ideName: providerConfig.ideName || 'claude', // 历史兼容性字段
|
|
157
156
|
baseUrl: providerConfig.baseUrl,
|
|
158
157
|
authToken: providerConfig.authToken,
|
|
159
158
|
authMode: providerConfig.authMode || 'api_key',
|
|
160
|
-
tokenType: providerConfig.tokenType || 'api_key', //
|
|
159
|
+
tokenType: providerConfig.tokenType || 'api_key', // 仅在 authMode 为 'api_key' 时使用
|
|
161
160
|
launchArgs: providerConfig.launchArgs || [],
|
|
162
161
|
models: {
|
|
163
162
|
primary: providerConfig.primaryModel || null,
|
package/bin/cc.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { program } = require('commander');
|
|
4
|
-
const chalk = require('chalk');
|
|
5
|
-
const { main } = require('../src/index');
|
|
6
|
-
const { registry } = require('../src/CommandRegistry');
|
|
7
|
-
const pkg = require('../package.json');
|
|
8
|
-
const { checkForUpdates } = require('../src/utils/update-checker');
|
|
9
|
-
|
|
10
|
-
// Set up CLI
|
|
11
|
-
program
|
|
12
|
-
.name('akm')
|
|
13
|
-
.description('API密钥管理工具 - Manage and switch multiple API provider configurations')
|
|
14
|
-
.version(pkg.version, '-v, -V, --version', '显示版本号');
|
|
15
|
-
|
|
16
|
-
// Check for updates before any command runs
|
|
17
|
-
program.hook('preAction', async () => {
|
|
18
|
-
await checkForUpdates({ packageName: pkg.name, currentVersion: pkg.version });
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
// Default command - show provider selection
|
|
22
|
-
program
|
|
23
|
-
.argument('[provider]', '直接切换到指定供应商')
|
|
24
|
-
.action(async (provider) => {
|
|
25
|
-
try {
|
|
26
|
-
await main(provider);
|
|
27
|
-
} catch (error) {
|
|
28
|
-
console.error(chalk.red('❌ 执行失败:'), error.message);
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// Add command
|
|
34
|
-
program
|
|
35
|
-
.command('add')
|
|
36
|
-
.description('添加新供应商配置')
|
|
37
|
-
.action(async () => {
|
|
38
|
-
try {
|
|
39
|
-
await registry.executeCommand('add');
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.error(chalk.red('❌ 添加失败:'), error.message);
|
|
42
|
-
process.exit(1);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// Remove command
|
|
47
|
-
program
|
|
48
|
-
.command('remove')
|
|
49
|
-
.argument('[provider]', '要删除的供应商名称')
|
|
50
|
-
.description('删除供应商配置')
|
|
51
|
-
.action(async (provider) => {
|
|
52
|
-
try {
|
|
53
|
-
await registry.executeCommand('remove', provider);
|
|
54
|
-
} catch (error) {
|
|
55
|
-
console.error(chalk.red('❌ 删除失败:'), error.message);
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// List command
|
|
61
|
-
program
|
|
62
|
-
.command('list')
|
|
63
|
-
.description('列出所有供应商')
|
|
64
|
-
.action(async () => {
|
|
65
|
-
try {
|
|
66
|
-
await registry.executeCommand('list');
|
|
67
|
-
} catch (error) {
|
|
68
|
-
console.error(chalk.red('❌ 列表失败:'), error.message);
|
|
69
|
-
process.exit(1);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
// Current command
|
|
74
|
-
program
|
|
75
|
-
.command('current')
|
|
76
|
-
.description('显示当前配置')
|
|
77
|
-
.action(async () => {
|
|
78
|
-
try {
|
|
79
|
-
await registry.executeCommand('current');
|
|
80
|
-
} catch (error) {
|
|
81
|
-
console.error(chalk.red('❌ 获取当前配置失败:'), error.message);
|
|
82
|
-
process.exit(1);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
// Edit command
|
|
87
|
-
program
|
|
88
|
-
.command('edit')
|
|
89
|
-
.argument('[provider]', '要编辑的供应商名称')
|
|
90
|
-
.description('编辑供应商配置')
|
|
91
|
-
.action(async (provider) => {
|
|
92
|
-
try {
|
|
93
|
-
await registry.executeCommand('edit', provider);
|
|
94
|
-
} catch (error) {
|
|
95
|
-
console.error(chalk.red('❌ 编辑失败:'), error.message);
|
|
96
|
-
process.exit(1);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// Parse arguments
|
|
101
|
-
program.parse();
|