smart-aipi 1.4.0 → 1.4.1
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/lib/setup.js +44 -4
- package/package.json +1 -1
package/lib/setup.js
CHANGED
|
@@ -71,12 +71,53 @@ function readJSON(filePath) {
|
|
|
71
71
|
// ─── Claude Code ──────────────────────────────────────────────────────────────
|
|
72
72
|
async function setupClaude(deps) {
|
|
73
73
|
console.log(chalk.bold('\n Setting up Claude Code with Smart AIPI\n'));
|
|
74
|
-
const key = await getOrCreateKey(deps);
|
|
75
|
-
if (!key)
|
|
76
|
-
return;
|
|
77
74
|
const home = homedir();
|
|
78
75
|
const settingsPath = join(home, '.claude', 'settings.json');
|
|
79
76
|
const claudeJsonPath = join(home, '.claude.json');
|
|
77
|
+
// Check for existing Claude Code installation with OAuth
|
|
78
|
+
const claudeJson = readJSON(claudeJsonPath);
|
|
79
|
+
if (claudeJson.oauthAccount) {
|
|
80
|
+
console.log(chalk.yellow(' Warning: Claude Code is already set up with an Anthropic account.'));
|
|
81
|
+
console.log(chalk.yellow(' Writing Smart AIPI env vars to the global settings will override'));
|
|
82
|
+
console.log(chalk.yellow(' your existing Anthropic connection.\n'));
|
|
83
|
+
const { proceed } = await inquirer.prompt([{
|
|
84
|
+
type: 'list',
|
|
85
|
+
name: 'proceed',
|
|
86
|
+
message: 'How would you like to proceed?',
|
|
87
|
+
choices: [
|
|
88
|
+
{ name: 'Show manual setup instructions (safe — no files changed)', value: 'manual' },
|
|
89
|
+
{ name: 'Write to global settings anyway (replaces Anthropic connection)', value: 'write' },
|
|
90
|
+
{ name: 'Cancel', value: 'cancel' }
|
|
91
|
+
]
|
|
92
|
+
}]);
|
|
93
|
+
if (proceed === 'cancel')
|
|
94
|
+
return;
|
|
95
|
+
if (proceed === 'manual') {
|
|
96
|
+
const key = await getOrCreateKey(deps);
|
|
97
|
+
if (!key)
|
|
98
|
+
return;
|
|
99
|
+
console.log(chalk.cyan('\n To use Smart AIPI with Claude Code, add this to'));
|
|
100
|
+
console.log(chalk.cyan(' ~/.claude/settings.json (or a project-level .claude/settings.json):\n'));
|
|
101
|
+
console.log(chalk.dim(` {
|
|
102
|
+
"env": {
|
|
103
|
+
"ANTHROPIC_BASE_URL": "https://api.smartaipi.com",
|
|
104
|
+
"ANTHROPIC_API_KEY": "${key}",
|
|
105
|
+
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5-20251001"
|
|
106
|
+
},
|
|
107
|
+
"model": "claude-opus-4-6"
|
|
108
|
+
}\n`));
|
|
109
|
+
console.log(chalk.dim(' Or export the env vars in your shell:\n'));
|
|
110
|
+
console.log(chalk.dim(` export ANTHROPIC_BASE_URL=https://api.smartaipi.com`));
|
|
111
|
+
console.log(chalk.dim(` export ANTHROPIC_API_KEY=${key}\n`));
|
|
112
|
+
console.log(chalk.dim(' Tip: Use a project-level .claude/settings.json to keep your'));
|
|
113
|
+
console.log(chalk.dim(' global Anthropic connection intact.\n'));
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
// proceed === 'write' — fall through to write the settings
|
|
117
|
+
}
|
|
118
|
+
const key = await getOrCreateKey(deps);
|
|
119
|
+
if (!key)
|
|
120
|
+
return;
|
|
80
121
|
// Write ~/.claude/settings.json
|
|
81
122
|
const settings = readJSON(settingsPath);
|
|
82
123
|
settings.env = {
|
|
@@ -89,7 +130,6 @@ async function setupClaude(deps) {
|
|
|
89
130
|
settings.model = 'claude-opus-4-6';
|
|
90
131
|
writeJSON(settingsPath, settings);
|
|
91
132
|
// Patch ~/.claude.json to skip setup wizard
|
|
92
|
-
const claudeJson = readJSON(claudeJsonPath);
|
|
93
133
|
claudeJson.hasCompletedOnboarding = true;
|
|
94
134
|
writeJSON(claudeJsonPath, claudeJson);
|
|
95
135
|
console.log(chalk.green(' Claude Code configured!\n'));
|