glm-switch 2.0.0
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/README.md +456 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +68 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands.d.ts +38 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +272 -0
- package/dist/commands.js.map +1 -0
- package/dist/config.d.ts +35 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +82 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/profiles.d.ts +92 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +283 -0
- package/dist/profiles.js.map +1 -0
- package/dist/settings.d.ts +28 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +217 -0
- package/dist/settings.js.map +1 -0
- package/package.json +36 -0
package/dist/profiles.js
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.DEFAULT_PROFILE_CONFIG = void 0;
|
|
37
|
+
exports.getProfilesDir = getProfilesDir;
|
|
38
|
+
exports.getProfilePath = getProfilePath;
|
|
39
|
+
exports.getActiveProfilePath = getActiveProfilePath;
|
|
40
|
+
exports.getDefaultProfilePath = getDefaultProfilePath;
|
|
41
|
+
exports.initializeProfilesDir = initializeProfilesDir;
|
|
42
|
+
exports.profileExists = profileExists;
|
|
43
|
+
exports.createProfile = createProfile;
|
|
44
|
+
exports.getProfile = getProfile;
|
|
45
|
+
exports.updateProfile = updateProfile;
|
|
46
|
+
exports.updateAllProfiles = updateAllProfiles;
|
|
47
|
+
exports.deleteProfile = deleteProfile;
|
|
48
|
+
exports.listProfiles = listProfiles;
|
|
49
|
+
exports.getActiveProfile = getActiveProfile;
|
|
50
|
+
exports.setActiveProfile = setActiveProfile;
|
|
51
|
+
exports.getDefaultProfile = getDefaultProfile;
|
|
52
|
+
exports.setDefaultProfile = setDefaultProfile;
|
|
53
|
+
exports.getValidConfigKeys = getValidConfigKeys;
|
|
54
|
+
const fs = __importStar(require("fs"));
|
|
55
|
+
const path = __importStar(require("path"));
|
|
56
|
+
const os = __importStar(require("os"));
|
|
57
|
+
/**
|
|
58
|
+
* Default profile configuration template
|
|
59
|
+
*/
|
|
60
|
+
exports.DEFAULT_PROFILE_CONFIG = {
|
|
61
|
+
ANTHROPIC_BASE_URL: 'https://api.z.ai/api/anthropic',
|
|
62
|
+
ANTHROPIC_AUTH_TOKEN: '',
|
|
63
|
+
ANTHROPIC_DEFAULT_HAIKU_MODEL: 'glm-4.5-air',
|
|
64
|
+
ANTHROPIC_DEFAULT_SONNET_MODEL: 'glm-4.7',
|
|
65
|
+
ANTHROPIC_DEFAULT_OPUS_MODEL: 'glm-4.7',
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Get the profiles directory path
|
|
69
|
+
*/
|
|
70
|
+
function getProfilesDir() {
|
|
71
|
+
const platform = os.platform();
|
|
72
|
+
if (platform === 'win32') {
|
|
73
|
+
const userProfile = process.env.USERPROFILE || process.env.HOME;
|
|
74
|
+
if (!userProfile) {
|
|
75
|
+
throw new Error('USERPROFILE environment variable not found');
|
|
76
|
+
}
|
|
77
|
+
return path.join(userProfile, '.claude', 'glm-switch');
|
|
78
|
+
}
|
|
79
|
+
else if (platform === 'darwin') {
|
|
80
|
+
const home = os.homedir();
|
|
81
|
+
return path.join(home, '.claude', 'glm-switch');
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
throw new Error(`Unsupported platform: ${platform}. Only Windows and macOS are supported.`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get profile file path for a given ID
|
|
89
|
+
*/
|
|
90
|
+
function getProfilePath(id) {
|
|
91
|
+
return path.join(getProfilesDir(), `profile-${id}.json`);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get active profile file path
|
|
95
|
+
*/
|
|
96
|
+
function getActiveProfilePath() {
|
|
97
|
+
return path.join(getProfilesDir(), 'active-profile.json');
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get default profile file path
|
|
101
|
+
*/
|
|
102
|
+
function getDefaultProfilePath() {
|
|
103
|
+
return path.join(getProfilesDir(), 'default-profile.json');
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Initialize profiles directory
|
|
107
|
+
*/
|
|
108
|
+
function initializeProfilesDir() {
|
|
109
|
+
const profilesDir = getProfilesDir();
|
|
110
|
+
if (!fs.existsSync(profilesDir)) {
|
|
111
|
+
fs.mkdirSync(profilesDir, { recursive: true });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Check if a profile exists
|
|
116
|
+
*/
|
|
117
|
+
function profileExists(id) {
|
|
118
|
+
return fs.existsSync(getProfilePath(id));
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Create a new profile
|
|
122
|
+
*/
|
|
123
|
+
function createProfile(id) {
|
|
124
|
+
if (profileExists(id)) {
|
|
125
|
+
throw new Error(`Profile ${id} already exists`);
|
|
126
|
+
}
|
|
127
|
+
// Validate ID is numeric
|
|
128
|
+
if (!/^\d+$/.test(id)) {
|
|
129
|
+
throw new Error('Profile ID must be numeric');
|
|
130
|
+
}
|
|
131
|
+
initializeProfilesDir();
|
|
132
|
+
const now = new Date().toISOString();
|
|
133
|
+
const profile = {
|
|
134
|
+
id,
|
|
135
|
+
config: { ...exports.DEFAULT_PROFILE_CONFIG },
|
|
136
|
+
createdAt: now,
|
|
137
|
+
updatedAt: now,
|
|
138
|
+
};
|
|
139
|
+
fs.writeFileSync(getProfilePath(id), JSON.stringify(profile, null, 2), 'utf8');
|
|
140
|
+
// Set as default profile if it's profile 0
|
|
141
|
+
if (id === '0' && !fs.existsSync(getDefaultProfilePath())) {
|
|
142
|
+
setDefaultProfile('0');
|
|
143
|
+
}
|
|
144
|
+
return profile;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Get a profile by ID
|
|
148
|
+
*/
|
|
149
|
+
function getProfile(id) {
|
|
150
|
+
if (!profileExists(id)) {
|
|
151
|
+
throw new Error(`Profile ${id} does not exist`);
|
|
152
|
+
}
|
|
153
|
+
const content = fs.readFileSync(getProfilePath(id), 'utf8');
|
|
154
|
+
return JSON.parse(content);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Update a specific key in a profile
|
|
158
|
+
*/
|
|
159
|
+
function updateProfile(id, key, value) {
|
|
160
|
+
const profile = getProfile(id);
|
|
161
|
+
if (!(key in profile.config)) {
|
|
162
|
+
throw new Error(`Invalid config key: ${key}`);
|
|
163
|
+
}
|
|
164
|
+
profile.config[key] = value;
|
|
165
|
+
profile.updatedAt = new Date().toISOString();
|
|
166
|
+
fs.writeFileSync(getProfilePath(id), JSON.stringify(profile, null, 2), 'utf8');
|
|
167
|
+
return profile;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Update a specific key in all profiles
|
|
171
|
+
*/
|
|
172
|
+
function updateAllProfiles(key, value) {
|
|
173
|
+
const profilesDir = getProfilesDir();
|
|
174
|
+
if (!fs.existsSync(profilesDir)) {
|
|
175
|
+
throw new Error('No profiles found. Run "glm-switch init 0" first.');
|
|
176
|
+
}
|
|
177
|
+
const files = fs.readdirSync(profilesDir);
|
|
178
|
+
const profileFiles = files.filter(f => f.startsWith('profile-') && f.endsWith('.json'));
|
|
179
|
+
if (profileFiles.length === 0) {
|
|
180
|
+
throw new Error('No profiles found. Run "glm-switch init 0" first.');
|
|
181
|
+
}
|
|
182
|
+
// Check if key is valid
|
|
183
|
+
const tempProfile = { config: { ...exports.DEFAULT_PROFILE_CONFIG } };
|
|
184
|
+
if (!(key in tempProfile.config)) {
|
|
185
|
+
throw new Error(`Invalid config key: ${key}`);
|
|
186
|
+
}
|
|
187
|
+
profileFiles.forEach(file => {
|
|
188
|
+
const filePath = path.join(profilesDir, file);
|
|
189
|
+
const profile = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
190
|
+
profile.config[key] = value;
|
|
191
|
+
profile.updatedAt = new Date().toISOString();
|
|
192
|
+
fs.writeFileSync(filePath, JSON.stringify(profile, null, 2), 'utf8');
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Delete a profile
|
|
197
|
+
*/
|
|
198
|
+
function deleteProfile(id) {
|
|
199
|
+
if (!profileExists(id)) {
|
|
200
|
+
throw new Error(`Profile ${id} does not exist`);
|
|
201
|
+
}
|
|
202
|
+
fs.unlinkSync(getProfilePath(id));
|
|
203
|
+
// Clear active profile if it was the deleted one
|
|
204
|
+
const activeId = getActiveProfile();
|
|
205
|
+
if (activeId === id) {
|
|
206
|
+
if (fs.existsSync(getActiveProfilePath())) {
|
|
207
|
+
fs.unlinkSync(getActiveProfilePath());
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* List all profiles
|
|
213
|
+
*/
|
|
214
|
+
function listProfiles() {
|
|
215
|
+
const profilesDir = getProfilesDir();
|
|
216
|
+
if (!fs.existsSync(profilesDir)) {
|
|
217
|
+
return [];
|
|
218
|
+
}
|
|
219
|
+
const files = fs.readdirSync(profilesDir);
|
|
220
|
+
const profileFiles = files.filter(f => f.startsWith('profile-') && f.endsWith('.json'));
|
|
221
|
+
const profiles = [];
|
|
222
|
+
profileFiles.forEach(file => {
|
|
223
|
+
const filePath = path.join(profilesDir, file);
|
|
224
|
+
const profile = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
225
|
+
profiles.push(profile);
|
|
226
|
+
});
|
|
227
|
+
// Sort by ID (numeric)
|
|
228
|
+
profiles.sort((a, b) => parseInt(a.id) - parseInt(b.id));
|
|
229
|
+
return profiles;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Get the active profile ID
|
|
233
|
+
*/
|
|
234
|
+
function getActiveProfile() {
|
|
235
|
+
const activeProfilePath = getActiveProfilePath();
|
|
236
|
+
if (!fs.existsSync(activeProfilePath)) {
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
const content = fs.readFileSync(activeProfilePath, 'utf8');
|
|
240
|
+
const data = JSON.parse(content);
|
|
241
|
+
return data.id || null;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Set the active profile
|
|
245
|
+
*/
|
|
246
|
+
function setActiveProfile(id) {
|
|
247
|
+
if (!profileExists(id)) {
|
|
248
|
+
throw new Error(`Profile ${id} does not exist`);
|
|
249
|
+
}
|
|
250
|
+
initializeProfilesDir();
|
|
251
|
+
const data = { id };
|
|
252
|
+
fs.writeFileSync(getActiveProfilePath(), JSON.stringify(data, null, 2), 'utf8');
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Get the default profile ID
|
|
256
|
+
*/
|
|
257
|
+
function getDefaultProfile() {
|
|
258
|
+
const defaultProfilePath = getDefaultProfilePath();
|
|
259
|
+
if (!fs.existsSync(defaultProfilePath)) {
|
|
260
|
+
return '0'; // Default to profile 0
|
|
261
|
+
}
|
|
262
|
+
const content = fs.readFileSync(defaultProfilePath, 'utf8');
|
|
263
|
+
const data = JSON.parse(content);
|
|
264
|
+
return data.id || '0';
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Set the default profile ID
|
|
268
|
+
*/
|
|
269
|
+
function setDefaultProfile(id) {
|
|
270
|
+
if (!profileExists(id)) {
|
|
271
|
+
throw new Error(`Profile ${id} does not exist`);
|
|
272
|
+
}
|
|
273
|
+
initializeProfilesDir();
|
|
274
|
+
const data = { id };
|
|
275
|
+
fs.writeFileSync(getDefaultProfilePath(), JSON.stringify(data, null, 2), 'utf8');
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Get valid config keys
|
|
279
|
+
*/
|
|
280
|
+
function getValidConfigKeys() {
|
|
281
|
+
return Object.keys(exports.DEFAULT_PROFILE_CONFIG);
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=profiles.js.map
|
|
@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SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAClF,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB;IAC/B,MAAM,kBAAkB,GAAG,qBAAqB,EAAE,CAAC;IAEnD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACvC,OAAO,GAAG,CAAC,CAAC,uBAAuB;IACrC,CAAC;IAED,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;IAC5D,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjC,OAAO,IAAI,CAAC,EAAE,IAAI,GAAG,CAAC;AACxB,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAAC,EAAU;IAC1C,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;IAClD,CAAC;IAED,qBAAqB,EAAE,CAAC;IAExB,MAAM,IAAI,GAAG,EAAE,EAAE,EAAE,CAAC;IACpB,EAAE,CAAC,aAAa,CAAC,qBAAqB,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACnF,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB;IAChC,OAAO,MAAM,CAAC,IAAI,CAAC,8BAAsB,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface Settings {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
env?: {
|
|
4
|
+
[key: string]: string;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Read and parse settings.json file (handles VS Code JSONC format)
|
|
9
|
+
* Creates file with default settings if it doesn't exist
|
|
10
|
+
*/
|
|
11
|
+
export declare function readSettings(filePath: string): Settings;
|
|
12
|
+
/**
|
|
13
|
+
* Write settings to file with backup (preserves VS Code format with comments)
|
|
14
|
+
*/
|
|
15
|
+
export declare function writeSettings(filePath: string, settings: Settings): void;
|
|
16
|
+
/**
|
|
17
|
+
* Check if settings has GLM configuration
|
|
18
|
+
*/
|
|
19
|
+
export declare function hasGLMConfig(settings: Settings, glmKeys: string[]): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Add GLM configuration to settings
|
|
22
|
+
*/
|
|
23
|
+
export declare function addGLMConfig(settings: Settings, glmConfig: Record<string, string>): Settings;
|
|
24
|
+
/**
|
|
25
|
+
* Remove GLM configuration from settings
|
|
26
|
+
*/
|
|
27
|
+
export declare function removeGLMConfig(settings: Settings, glmKeys: string[]): Settings;
|
|
28
|
+
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,QAAQ;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IACnB,GAAG,CAAC,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;CACH;AAmFD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CA0BvD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAgCxE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAK3E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,QAAQ,CAc5F;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,QAAQ,CAkB/E"}
|
package/dist/settings.js
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.readSettings = readSettings;
|
|
37
|
+
exports.writeSettings = writeSettings;
|
|
38
|
+
exports.hasGLMConfig = hasGLMConfig;
|
|
39
|
+
exports.addGLMConfig = addGLMConfig;
|
|
40
|
+
exports.removeGLMConfig = removeGLMConfig;
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
/**
|
|
44
|
+
* Remove comments from JSON string (VS Code settings.json supports comments)
|
|
45
|
+
*/
|
|
46
|
+
function stripJsonComments(jsonString) {
|
|
47
|
+
let result = '';
|
|
48
|
+
let inString = false;
|
|
49
|
+
let inSingleLineComment = false;
|
|
50
|
+
let inMultiLineComment = false;
|
|
51
|
+
let escapeNext = false;
|
|
52
|
+
for (let i = 0; i < jsonString.length; i++) {
|
|
53
|
+
const char = jsonString[i];
|
|
54
|
+
const nextChar = jsonString[i + 1];
|
|
55
|
+
// Handle escape sequences in strings
|
|
56
|
+
if (escapeNext) {
|
|
57
|
+
if (inString)
|
|
58
|
+
result += char;
|
|
59
|
+
escapeNext = false;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (char === '\\') {
|
|
63
|
+
if (inString)
|
|
64
|
+
result += char;
|
|
65
|
+
escapeNext = true;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
// Toggle string mode
|
|
69
|
+
if (char === '"' && !inSingleLineComment && !inMultiLineComment) {
|
|
70
|
+
inString = !inString;
|
|
71
|
+
result += char;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
// If in string, just add character
|
|
75
|
+
if (inString) {
|
|
76
|
+
result += char;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
// Handle comment start
|
|
80
|
+
if (char === '/' && !inSingleLineComment && !inMultiLineComment) {
|
|
81
|
+
if (nextChar === '/') {
|
|
82
|
+
inSingleLineComment = true;
|
|
83
|
+
i++; // Skip next slash
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
else if (nextChar === '*') {
|
|
87
|
+
inMultiLineComment = true;
|
|
88
|
+
i++; // Skip asterisk
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Handle comment end
|
|
93
|
+
if (inSingleLineComment && (char === '\n' || char === '\r')) {
|
|
94
|
+
inSingleLineComment = false;
|
|
95
|
+
result += char; // Keep newline
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (inMultiLineComment && char === '*' && nextChar === '/') {
|
|
99
|
+
inMultiLineComment = false;
|
|
100
|
+
i++; // Skip closing slash
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
// Skip characters in comments
|
|
104
|
+
if (inSingleLineComment || inMultiLineComment) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
// Add character to result
|
|
108
|
+
result += char;
|
|
109
|
+
}
|
|
110
|
+
// Remove trailing commas
|
|
111
|
+
result = result.replace(/,(\s*[}\]])/g, '$1');
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Read and parse settings.json file (handles VS Code JSONC format)
|
|
116
|
+
* Creates file with default settings if it doesn't exist
|
|
117
|
+
*/
|
|
118
|
+
function readSettings(filePath) {
|
|
119
|
+
if (!fs.existsSync(filePath)) {
|
|
120
|
+
// Create default settings file
|
|
121
|
+
const defaultSettings = {};
|
|
122
|
+
// Ensure directory exists
|
|
123
|
+
const dir = path.dirname(filePath);
|
|
124
|
+
if (!fs.existsSync(dir)) {
|
|
125
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
126
|
+
}
|
|
127
|
+
// Create file with empty JSON object
|
|
128
|
+
fs.writeFileSync(filePath, JSON.stringify(defaultSettings, null, 2), 'utf8');
|
|
129
|
+
return defaultSettings;
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
133
|
+
const cleanedContent = stripJsonComments(content);
|
|
134
|
+
return JSON.parse(cleanedContent);
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
if (error instanceof SyntaxError) {
|
|
138
|
+
throw new Error(`Invalid JSON in settings file: ${error.message}`);
|
|
139
|
+
}
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Write settings to file with backup (preserves VS Code format with comments)
|
|
145
|
+
*/
|
|
146
|
+
function writeSettings(filePath, settings) {
|
|
147
|
+
const backupPath = `${filePath}.backup`;
|
|
148
|
+
try {
|
|
149
|
+
// Create backup if file exists
|
|
150
|
+
if (fs.existsSync(filePath)) {
|
|
151
|
+
fs.copyFileSync(filePath, backupPath);
|
|
152
|
+
}
|
|
153
|
+
// Validate JSON structure
|
|
154
|
+
const jsonString = JSON.stringify(settings, null, 2);
|
|
155
|
+
JSON.parse(jsonString); // Validate it can be parsed
|
|
156
|
+
// Write to temp file first (atomic write)
|
|
157
|
+
const tempPath = `${filePath}.tmp`;
|
|
158
|
+
fs.writeFileSync(tempPath, jsonString, 'utf8');
|
|
159
|
+
// Rename temp to actual file
|
|
160
|
+
fs.renameSync(tempPath, filePath);
|
|
161
|
+
// Remove backup on success
|
|
162
|
+
if (fs.existsSync(backupPath)) {
|
|
163
|
+
fs.unlinkSync(backupPath);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
// Restore from backup on error
|
|
168
|
+
if (fs.existsSync(backupPath)) {
|
|
169
|
+
fs.copyFileSync(backupPath, filePath);
|
|
170
|
+
fs.unlinkSync(backupPath);
|
|
171
|
+
}
|
|
172
|
+
throw error;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Check if settings has GLM configuration
|
|
177
|
+
*/
|
|
178
|
+
function hasGLMConfig(settings, glmKeys) {
|
|
179
|
+
if (!settings.env)
|
|
180
|
+
return false;
|
|
181
|
+
// Check if at least one GLM key exists
|
|
182
|
+
return glmKeys.some(key => settings.env && key in settings.env);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Add GLM configuration to settings
|
|
186
|
+
*/
|
|
187
|
+
function addGLMConfig(settings, glmConfig) {
|
|
188
|
+
const newSettings = { ...settings };
|
|
189
|
+
if (!newSettings.env) {
|
|
190
|
+
newSettings.env = {};
|
|
191
|
+
}
|
|
192
|
+
// Merge GLM config into env
|
|
193
|
+
newSettings.env = {
|
|
194
|
+
...newSettings.env,
|
|
195
|
+
...glmConfig,
|
|
196
|
+
};
|
|
197
|
+
return newSettings;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Remove GLM configuration from settings
|
|
201
|
+
*/
|
|
202
|
+
function removeGLMConfig(settings, glmKeys) {
|
|
203
|
+
const newSettings = { ...settings };
|
|
204
|
+
if (!newSettings.env) {
|
|
205
|
+
return newSettings;
|
|
206
|
+
}
|
|
207
|
+
// Remove all GLM keys
|
|
208
|
+
glmKeys.forEach(key => {
|
|
209
|
+
delete newSettings.env[key];
|
|
210
|
+
});
|
|
211
|
+
// Remove env object if empty
|
|
212
|
+
if (Object.keys(newSettings.env).length === 0) {
|
|
213
|
+
delete newSettings.env;
|
|
214
|
+
}
|
|
215
|
+
return newSettings;
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+FA,oCA0BC;AAKD,sCAgCC;AAKD,oCAKC;AAKD,oCAcC;AAKD,0CAkBC;AAlND,uCAAyB;AACzB,2CAA6B;AAS7B;;GAEG;AACH,SAAS,iBAAiB,CAAC,UAAkB;IAC3C,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,mBAAm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pB,OAAO,WAAW,CAAC,GAAI,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,6BAA6B;IAC7B,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9C,OAAO,WAAW,CAAC,GAAG,CAAC;IACzB,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "glm-switch",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "CLI utility to switch between Claude API and GLM 4.6 models in Claude Code",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"glm-switch": "./dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"setup": "npm install && npm run build && npm link",
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"dev": "tsc --watch",
|
|
13
|
+
"clean": "rimraf dist"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"claude",
|
|
17
|
+
"glm",
|
|
18
|
+
"cli",
|
|
19
|
+
"switch",
|
|
20
|
+
"vscode"
|
|
21
|
+
],
|
|
22
|
+
"author": "",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"chalk": "^4.1.2",
|
|
26
|
+
"commander": "^11.1.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^20.10.0",
|
|
30
|
+
"rimraf": "^5.0.5",
|
|
31
|
+
"typescript": "^5.3.2"
|
|
32
|
+
},
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=16.0.0"
|
|
35
|
+
}
|
|
36
|
+
}
|