codemax-pro 1.0.0 → 1.1.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.
Files changed (2) hide show
  1. package/index.js +76 -27
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -4,6 +4,7 @@ const fs = require("fs");
4
4
  const path = require("path");
5
5
  const { execSync } = require("child_process");
6
6
  const readline = require("readline");
7
+ const crypto = require("crypto");
7
8
 
8
9
  const API_ENDPOINT = "https://api.codemax.pro";
9
10
 
@@ -103,6 +104,69 @@ async function validateKey(apiKey) {
103
104
  }
104
105
  }
105
106
 
107
+ function configureClaudeDesktop3P(home, apiKey) {
108
+ const isWin = process.platform === "win32";
109
+ const isMac = process.platform === "darwin";
110
+
111
+ // 1. Target Claude-3p/configLibrary
112
+ const baseDir = isWin
113
+ ? path.join(process.env.LOCALAPPDATA || path.join(home, "AppData", "Local"), "Claude-3p")
114
+ : isMac
115
+ ? path.join(home, "Library", "Application Support", "Claude-3p")
116
+ : path.join(home, ".config", "Claude-3p");
117
+
118
+ const configLibDir = path.join(baseDir, "configLibrary");
119
+ if (!fs.existsSync(configLibDir)) {
120
+ fs.mkdirSync(configLibDir, { recursive: true });
121
+ }
122
+
123
+ const metaPath = path.join(configLibDir, "_meta.json");
124
+ let meta = readJson(metaPath);
125
+ if (!meta.entries) meta.entries = [];
126
+
127
+ let profileId = meta.appliedId;
128
+ if (!profileId || !fs.existsSync(path.join(configLibDir, `${profileId}.json`))) {
129
+ profileId = crypto.randomUUID ? crypto.randomUUID() : `codemax-${Date.now()}`;
130
+ meta.appliedId = profileId;
131
+ meta.entries.push({ id: profileId, name: "CodeMax Gateway" });
132
+ }
133
+
134
+ const profilePath = path.join(configLibDir, `${profileId}.json`);
135
+ const profileData = {
136
+ inferenceGatewayBaseUrl: API_ENDPOINT,
137
+ inferenceGatewayApiKey: apiKey,
138
+ inferenceProvider: "gateway",
139
+ inferenceCredentialKind: "static",
140
+ };
141
+
142
+ writeJson(profilePath, profileData);
143
+ writeJson(metaPath, meta);
144
+
145
+ // 2. Target developer_settings.json
146
+ const devSettingsPath = path.join(baseDir, "developer_settings.json");
147
+ const devSettings = readJson(devSettingsPath);
148
+ devSettings.allowDevTools = true;
149
+ writeJson(devSettingsPath, devSettings);
150
+
151
+ // 3. Target claude_desktop_config.json for MCP fallback
152
+ const desktopConfigPath = isWin
153
+ ? path.join(process.env.APPDATA || path.join(home, "AppData", "Roaming"), "Claude", "claude_desktop_config.json")
154
+ : isMac
155
+ ? path.join(home, "Library", "Application Support", "Claude", "claude_desktop_config.json")
156
+ : path.join(home, ".config", "Claude", "claude_desktop_config.json");
157
+
158
+ const desktopConfig = readJson(desktopConfigPath);
159
+ if (!desktopConfig.env) desktopConfig.env = {};
160
+ Object.assign(desktopConfig.env, {
161
+ ANTHROPIC_BASE_URL: API_ENDPOINT,
162
+ ANTHROPIC_AUTH_TOKEN: apiKey,
163
+ ANTHROPIC_API_KEY: apiKey,
164
+ });
165
+ writeJson(desktopConfigPath, desktopConfig);
166
+
167
+ return profilePath;
168
+ }
169
+
106
170
  async function main() {
107
171
  log("");
108
172
  log(` ${c.cyan}╔══════════════════════════════════════════╗${c.reset}`);
@@ -165,7 +229,7 @@ async function main() {
165
229
  log("");
166
230
 
167
231
  // ── [3/5] Configure Claude Code CLI & VS Code settings ──
168
- info("[3/5] Configuring Claude Code & VS Code settings...");
232
+ info("[3/5] Configuring Claude Code CLI & VS Code...");
169
233
  const settingsPath = path.join(home, ".claude", "settings.json");
170
234
  try {
171
235
  const settings = readJson(settingsPath);
@@ -179,7 +243,6 @@ async function main() {
179
243
  CLAUDE_CODE_REMOTE: "1",
180
244
  });
181
245
 
182
- // Remove stale vars from previous installs
183
246
  const removeVars = [
184
247
  "ANTHROPIC_MODEL", "CLAUDE_CODE_SUBAGENT_MODEL", "ANTHROPIC_DEFAULT_MODEL",
185
248
  "ANTHROPIC_REASONING_MODEL",
@@ -190,34 +253,20 @@ async function main() {
190
253
  delete settings.model;
191
254
 
192
255
  writeJson(settingsPath, settings);
193
- ok(settingsPath);
256
+ ok("Claude Code CLI & VS Code Extension configured");
194
257
  } catch (e) {
195
258
  fail(`Failed: ${e.message}`);
196
259
  }
197
260
  log("");
198
261
 
199
- // ── [4/5] Configure Claude Desktop App ──
200
- info("[4/5] Configuring Claude Desktop App...");
201
- const isWin = process.platform === "win32";
202
- const isMac = process.platform === "darwin";
203
- const desktopConfigPath = isWin
204
- ? path.join(process.env.APPDATA || path.join(home, "AppData", "Roaming"), "Claude", "claude_desktop_config.json")
205
- : isMac
206
- ? path.join(home, "Library", "Application Support", "Claude", "claude_desktop_config.json")
207
- : path.join(home, ".config", "Claude", "claude_desktop_config.json");
208
-
262
+ // ── [4/5] Configure Claude Desktop App (Third-Party Inference Gateway) ──
263
+ info("[4/5] Configuring Claude Desktop App (Inference Gateway)...");
209
264
  try {
210
- const desktopConfig = readJson(desktopConfigPath);
211
- if (!desktopConfig.env) desktopConfig.env = {};
212
- Object.assign(desktopConfig.env, {
213
- ANTHROPIC_BASE_URL: API_ENDPOINT,
214
- ANTHROPIC_AUTH_TOKEN: apiKey,
215
- ANTHROPIC_API_KEY: apiKey,
216
- });
217
- writeJson(desktopConfigPath, desktopConfig);
218
- ok(`Claude Desktop configured (${desktopConfigPath})`);
265
+ const configuredPath = configureClaudeDesktop3P(home, apiKey);
266
+ ok("Claude Desktop Third-Party Gateway configured");
267
+ gray(` Config: ${configuredPath}`);
219
268
  } catch (e) {
220
- warn(`Claude Desktop config note: ${e.message}`);
269
+ warn(`Could not auto-configure Claude Desktop: ${e.message}`);
221
270
  }
222
271
  log("");
223
272
 
@@ -276,12 +325,12 @@ async function main() {
276
325
  log("");
277
326
  log(` ${c.white}What was configured:${c.reset}`);
278
327
  gray(` • API key validated ✓`);
279
- gray(` • Claude Code CLI & VS Code (~/.claude/settings.json)`);
280
- gray(` • Claude Desktop App`);
281
- gray(` • Claude Code CLI environment`);
328
+ gray(` • Claude Code CLI & VS Code Extension (~/.claude/settings.json)`);
329
+ gray(` • Claude Desktop App (Gateway Inference in Claude-3p/configLibrary)`);
330
+ gray(` • Claude Code CLI Environment`);
282
331
  log("");
283
332
  log(` ${c.gray}╭───────────────────────────────────────╮${c.reset}`);
284
- log(` ${c.gray}│ Base URL: api.codemax.pro │${c.reset}`);
333
+ log(` ${c.gray}│ Gateway: api.codemax.pro │${c.reset}`);
285
334
  log(` ${c.gray}│ Key: ${apiKey.substring(0, 8)}... │${c.reset}`);
286
335
  log(` ${c.gray}╰───────────────────────────────────────╯${c.reset}`);
287
336
  log("");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codemax-pro",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "One-command setup for CodeMax — configures Claude Code CLI, VS Code extension, and Claude Desktop automatically",
5
5
  "main": "index.js",
6
6
  "bin": {