scalemax 0.1.7 → 0.1.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/dist/index.js CHANGED
@@ -31,6 +31,15 @@ function welcome() {
31
31
  console.log(chalk.cyan('╚══════════════════════════════╝'));
32
32
  console.log('\nThe fastest way to connect every AI coding client.\n');
33
33
  }
34
+ async function runInteractiveInstaller() {
35
+ welcome();
36
+ await runSystemAudit();
37
+ const apiKey = await ensureInstallerApiKey(process.env.HOME || process.env.USERPROFILE || process.cwd());
38
+ if (!apiKey)
39
+ return;
40
+ await configureCommand(process.stdin.isTTY ? { promptLaunch: true } : { all: true, promptLaunch: false });
41
+ outro(chalk.green('ScaleMax is ready.'));
42
+ }
34
43
  async function main() {
35
44
  if (!isNodeSupported()) {
36
45
  console.error(chalk.red(`ScaleMax requires Node.js >=18.17. Current: ${process.versions.node}`));
@@ -41,16 +50,14 @@ async function main() {
41
50
  const [, , command] = process.argv;
42
51
  try {
43
52
  if (!command) {
44
- welcome();
45
- await runSystemAudit();
46
- const apiKey = await ensureInstallerApiKey(process.env.HOME || process.env.USERPROFILE || process.cwd());
47
- if (!apiKey)
48
- return;
49
- await configureCommand({ promptLaunch: true });
50
- outro(chalk.green('ScaleMax is ready.'));
53
+ await runInteractiveInstaller();
51
54
  return;
52
55
  }
53
56
  switch (command) {
57
+ case 'init':
58
+ case 'setup':
59
+ await runInteractiveInstaller();
60
+ break;
54
61
  case 'login':
55
62
  await loginCommand();
56
63
  break;
@@ -79,6 +86,8 @@ async function main() {
79
86
 
80
87
  Commands:
81
88
  scalemax Interactive installer
89
+ scalemax init Interactive installer (alias for no-arg scalemax)
90
+ scalemax setup Interactive installer (alias)
82
91
  scalemax login Store or replace API key
83
92
  scalemax logout Remove API key
84
93
  scalemax doctor Run diagnostics
@@ -1,10 +1,11 @@
1
1
  import { intro, outro, password, select, confirm, isCancel, cancel } from '@clack/prompts';
2
2
  import chalk from 'chalk';
3
3
  import ora from 'ora';
4
- import { SCALEMAX_BASE_URL } from '../constants.js';
4
+ import { KEY_ENV, SCALEMAX_BASE_URL } from '../constants.js';
5
5
  import { validateApiKey } from './api.js';
6
6
  import { loadApiKey, removeApiKey, saveApiKey } from './keyStore.js';
7
7
  import { homeDir } from './paths.js';
8
+ import { sanitizeApiKey } from './apiKey.js';
8
9
  export function maskApiKey(apiKey) {
9
10
  const trimmed = apiKey.trim();
10
11
  if (trimmed.length <= 4)
@@ -17,7 +18,7 @@ export async function promptForValidatedKey(home, message = 'Enter your ScaleMax
17
18
  cancel('Installer cancelled.');
18
19
  return undefined;
19
20
  }
20
- const candidate = String(key).trim();
21
+ const candidate = sanitizeApiKey(key);
21
22
  const spinner = ora('Validating API key').start();
22
23
  const result = await validateApiKey(candidate);
23
24
  if (!result.ok) {
@@ -43,11 +44,18 @@ export async function ensureInstallerApiKey(home = homeDir()) {
43
44
  intro(chalk.cyan('ScaleMax Installer'));
44
45
  const existing = await loadApiKey(home);
45
46
  if (!existing) {
47
+ if (!process.stdin.isTTY)
48
+ throw new Error(`No ScaleMax API key found. Set ${KEY_ENV} or run \`scalemax login\` in an interactive terminal.`);
46
49
  const key = await promptForValidatedKey(home, 'Enter your ScaleMax API key:');
47
50
  if (key)
48
51
  outro(chalk.green('ScaleMax configuration saved.'));
49
52
  return key;
50
53
  }
54
+ if (!process.stdin.isTTY) {
55
+ console.log(chalk.green('✓ Existing ScaleMax configuration detected.'));
56
+ console.log(chalk.green('✓ Non-interactive mode: keeping existing key.'));
57
+ return existing;
58
+ }
51
59
  console.log(chalk.green('✓ Existing ScaleMax configuration detected.'));
52
60
  console.log('\nAPI key:');
53
61
  console.log(maskApiKey(existing));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scalemax",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Universal ScaleMax installer for AI coding clients",
5
5
  "type": "module",
6
6
  "bin": {