@pikecode/api-key-manager 1.0.15 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikecode/api-key-manager",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "A CLI tool for managing and switching multiple API provider configurations",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -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,13 +85,20 @@ class ConfigManager {
85
85
  }
86
86
 
87
87
  _migrateAuthModes() {
88
- // 迁移旧的 api_token 模式到新的 auth_token 模式
88
+ // 迁移旧配置以保持向后兼容
89
89
  if (this.config.providers) {
90
90
  Object.keys(this.config.providers).forEach(key => {
91
91
  const provider = this.config.providers[key];
92
+
93
+ // 迁移旧的 api_token 模式到新的 auth_token 模式
92
94
  if (provider.authMode === 'api_token') {
93
95
  provider.authMode = 'auth_token';
94
96
  }
97
+
98
+ // 为旧配置添加 ideName 字段(历史兼容性字段,默认为 'claude')
99
+ if (!provider.ideName) {
100
+ provider.ideName = 'claude';
101
+ }
95
102
  });
96
103
  }
97
104
  }
@@ -119,6 +126,8 @@ class ConfigManager {
119
126
 
120
127
  async _performSave() {
121
128
  try {
129
+ // 保存前确保迁移已应用
130
+ this._migrateAuthModes();
122
131
  await fs.writeJSON(this.configPath, this.config, { spaces: 2 });
123
132
  // 更新最后修改时间
124
133
  const stat = await fs.stat(this.configPath);
@@ -143,11 +152,11 @@ class ConfigManager {
143
152
  this.config.providers[name] = {
144
153
  name,
145
154
  displayName: providerConfig.displayName || name,
146
- ideName: providerConfig.ideName || 'claude', // 'claude' 或 'codex'
155
+ ideName: providerConfig.ideName || 'claude', // 历史兼容性字段
147
156
  baseUrl: providerConfig.baseUrl,
148
157
  authToken: providerConfig.authToken,
149
158
  authMode: providerConfig.authMode || 'api_key',
150
- tokenType: providerConfig.tokenType || 'api_key', // 'api_key' 或 'auth_token' - 仅在 authMode 为 'api_key' 时使用
159
+ tokenType: providerConfig.tokenType || 'api_key', // 仅在 authMode 为 'api_key' 时使用
151
160
  launchArgs: providerConfig.launchArgs || [],
152
161
  models: {
153
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();