claudmax 1.0.5 → 1.0.6

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.
Files changed (2) hide show
  1. package/index.js +33 -17
  2. 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.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
- '# Alias for quick access',
245
- 'alias claude="claude"',
262
+ `export ANTHROPIC_BASE_URL="${API_BASE}/v1/messages"`,
246
263
  '',
247
264
  ].join('\n');
248
265
 
249
- const appended = appendToFile(profile, envBlock);
250
- if (appended) {
251
- console.log(` ${CHECK} Added environment variables to ${C.magenta(profile)}`);
252
- console.log(` ${INFO} ${C.dim('Run: source ' + profile + ' or restart your terminal')}`);
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,8 @@ function configureClaudeCLI(apiKey) {
270
284
 
271
285
  ensureDir(path.dirname(settingsPath));
272
286
 
273
- // settings.json
274
- const settings = readJson(settingsPath) || {};
275
- deepMerge(settings, {
287
+ // settings.json — start fresh to override OpusCode settings
288
+ const settings = {
276
289
  env: {
277
290
  ANTHROPIC_AUTH_TOKEN: apiKey,
278
291
  ANTHROPIC_BASE_URL: `${API_BASE}/v1/messages`,
@@ -283,7 +296,7 @@ function configureClaudeCLI(apiKey) {
283
296
  ANTHROPIC_DEFAULT_HAIKU_MODEL: 'claude-haiku-4-5-20251001',
284
297
  },
285
298
  hasCompletedOnboarding: true,
286
- });
299
+ };
287
300
  writeJson(settingsPath, settings);
288
301
  console.log(` ${CHECK} Wrote Claude Code settings: ${C.magenta(settingsPath)}`);
289
302
 
@@ -566,6 +579,9 @@ async function main() {
566
579
  apiKey = apiKey.trim();
567
580
  console.log('');
568
581
 
582
+ // ── Configure system ──────────────────────────────────────────────────────
583
+ const profile = configureSystem(apiKey);
584
+
569
585
  // ── Step 2: IDE selection ─────────────────────────────────────────────────
570
586
  console.log(C.bold('Step 2: Select IDEs to configure\n'));
571
587
 
@@ -602,7 +618,7 @@ async function main() {
602
618
  try {
603
619
  ide.configure(apiKey);
604
620
  } catch (err) {
605
- console.log(` ${CROSS} Failed to configure ${ide.name}: ${String(err.message || err)}`);
621
+ console.log(` ${CROSS} Failed to configure ${ide.name}: ${String(err && err.message ? err.message : err)}`);
606
622
  }
607
623
  }
608
624
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudmax",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "ClaudMax CLI — Configure Claude Code, Cursor, Windsurf, Cline, and Roo Code to use ClaudMax API gateway with one command",
5
5
  "main": "index.js",
6
6
  "bin": {