claudmax 1.0.5 → 1.0.8
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/index.js +34 -17
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -231,32 +231,46 @@ function configureSystem(apiKey) {
|
|
|
231
231
|
apiKey,
|
|
232
232
|
baseUrl: API_BASE,
|
|
233
233
|
configuredAt: new Date().toISOString(),
|
|
234
|
-
version: '1.0.
|
|
234
|
+
version: '1.0.5',
|
|
235
235
|
});
|
|
236
236
|
console.log(` ${CHECK} Saved config to ${C.magenta(CONFIG_FILE)}`);
|
|
237
237
|
|
|
238
238
|
// 2. Write environment variables to shell profile
|
|
239
239
|
const profile = getShellProfile();
|
|
240
|
+
|
|
241
|
+
// Remove any existing ClaudMax/OpusCode/OpusMax blocks first
|
|
242
|
+
const existing = fs.existsSync(profile) ? fs.readFileSync(profile, 'utf8') : '';
|
|
243
|
+
let cleaned = existing
|
|
244
|
+
.split('\n')
|
|
245
|
+
.filter(line => {
|
|
246
|
+
const trimmed = line.trim();
|
|
247
|
+
return (
|
|
248
|
+
!trimmed.startsWith('# ClaudMax') &&
|
|
249
|
+
!trimmed.startsWith('export ANTHROPIC_API_KEY=') &&
|
|
250
|
+
!trimmed.startsWith('export ANTHROPIC_BASE_URL=') &&
|
|
251
|
+
!trimmed.startsWith('export OPUSCODE') &&
|
|
252
|
+
!trimmed.startsWith('export OPUSMAX') &&
|
|
253
|
+
!trimmed.startsWith('# OpusCode') &&
|
|
254
|
+
!trimmed.startsWith('# OpusMax')
|
|
255
|
+
);
|
|
256
|
+
})
|
|
257
|
+
.join('\n');
|
|
258
|
+
|
|
240
259
|
const envBlock = [
|
|
241
260
|
'# ClaudMax Configuration',
|
|
242
|
-
`export ANTHROPIC_BASE_URL="${API_BASE}/v1/messages"`,
|
|
243
261
|
`export ANTHROPIC_API_KEY="${apiKey}"`,
|
|
244
|
-
|
|
245
|
-
'alias claude="claude"',
|
|
262
|
+
`export ANTHROPIC_BASE_URL="${API_BASE}/v1/messages"`,
|
|
246
263
|
'',
|
|
247
264
|
].join('\n');
|
|
248
265
|
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
} else {
|
|
254
|
-
console.log(` ${INFO} Environment variables already configured in ${C.magenta(profile)}`);
|
|
255
|
-
}
|
|
266
|
+
const newContent = cleaned.trimEnd() + '\n' + envBlock;
|
|
267
|
+
fs.writeFileSync(profile, newContent);
|
|
268
|
+
console.log(` ${CHECK} Updated environment variables in ${C.magenta(profile)}`);
|
|
269
|
+
console.log(` ${INFO} ${C.dim('Run: source ' + profile + ' or restart your terminal')}`);
|
|
256
270
|
|
|
257
271
|
// Set for current process too
|
|
258
|
-
process.env.ANTHROPIC_BASE_URL = `${API_BASE}/v1/messages`;
|
|
259
272
|
process.env.ANTHROPIC_API_KEY = apiKey;
|
|
273
|
+
process.env.ANTHROPIC_BASE_URL = `${API_BASE}/v1/messages`;
|
|
260
274
|
|
|
261
275
|
return profile;
|
|
262
276
|
}
|
|
@@ -270,9 +284,9 @@ function configureClaudeCLI(apiKey) {
|
|
|
270
284
|
|
|
271
285
|
ensureDir(path.dirname(settingsPath));
|
|
272
286
|
|
|
273
|
-
// settings.json
|
|
274
|
-
const
|
|
275
|
-
deepMerge(
|
|
287
|
+
// settings.json — use deepMerge to preserve OpusCode settings
|
|
288
|
+
const existing = readJson(settingsPath) || {};
|
|
289
|
+
const settings = deepMerge(existing, {
|
|
276
290
|
env: {
|
|
277
291
|
ANTHROPIC_AUTH_TOKEN: apiKey,
|
|
278
292
|
ANTHROPIC_BASE_URL: `${API_BASE}/v1/messages`,
|
|
@@ -399,7 +413,7 @@ function installMCPServer() {
|
|
|
399
413
|
return true;
|
|
400
414
|
} catch (err) {
|
|
401
415
|
const errMsg = String(err.stderr || err.message || '');
|
|
402
|
-
console.log(` ${WARN} Could not install ${MCP_PKG}: ${C.dim(errMsg.trim())}`);
|
|
416
|
+
console.log(` ${WARN} Could not install ${MCP_PKG}: ${C.dim(String(errMsg).trim())}`);
|
|
403
417
|
console.log(` ${INFO} Install manually later: ${C.bold('npm install -g ' + MCP_PKG)}`);
|
|
404
418
|
return false;
|
|
405
419
|
}
|
|
@@ -566,6 +580,9 @@ async function main() {
|
|
|
566
580
|
apiKey = apiKey.trim();
|
|
567
581
|
console.log('');
|
|
568
582
|
|
|
583
|
+
// ── Configure system ──────────────────────────────────────────────────────
|
|
584
|
+
const profile = configureSystem(apiKey);
|
|
585
|
+
|
|
569
586
|
// ── Step 2: IDE selection ─────────────────────────────────────────────────
|
|
570
587
|
console.log(C.bold('Step 2: Select IDEs to configure\n'));
|
|
571
588
|
|
|
@@ -602,7 +619,7 @@ async function main() {
|
|
|
602
619
|
try {
|
|
603
620
|
ide.configure(apiKey);
|
|
604
621
|
} catch (err) {
|
|
605
|
-
console.log(` ${CROSS} Failed to configure ${ide.name}: ${String(err.message
|
|
622
|
+
console.log(` ${CROSS} Failed to configure ${ide.name}: ${String(err && err.message ? err.message : err)}`);
|
|
606
623
|
}
|
|
607
624
|
}
|
|
608
625
|
} else {
|
package/package.json
CHANGED