@pikecode/api-key-manager 1.0.15 → 1.0.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/config.js +10 -0
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -86,12 +86,20 @@ class ConfigManager {
|
|
|
86
86
|
|
|
87
87
|
_migrateAuthModes() {
|
|
88
88
|
// 迁移旧的 api_token 模式到新的 auth_token 模式
|
|
89
|
+
// 同时为旧配置添加 ideName 字段(默认为 'claude')
|
|
89
90
|
if (this.config.providers) {
|
|
90
91
|
Object.keys(this.config.providers).forEach(key => {
|
|
91
92
|
const provider = this.config.providers[key];
|
|
93
|
+
|
|
94
|
+
// 迁移旧的 api_token 模式到新的 auth_token 模式
|
|
92
95
|
if (provider.authMode === 'api_token') {
|
|
93
96
|
provider.authMode = 'auth_token';
|
|
94
97
|
}
|
|
98
|
+
|
|
99
|
+
// 为缺少 ideName 的旧配置添加默认值
|
|
100
|
+
if (!provider.ideName) {
|
|
101
|
+
provider.ideName = 'claude';
|
|
102
|
+
}
|
|
95
103
|
});
|
|
96
104
|
}
|
|
97
105
|
}
|
|
@@ -119,6 +127,8 @@ class ConfigManager {
|
|
|
119
127
|
|
|
120
128
|
async _performSave() {
|
|
121
129
|
try {
|
|
130
|
+
// 保存前确保迁移已应用
|
|
131
|
+
this._migrateAuthModes();
|
|
122
132
|
await fs.writeJSON(this.configPath, this.config, { spaces: 2 });
|
|
123
133
|
// 更新最后修改时间
|
|
124
134
|
const stat = await fs.stat(this.configPath);
|