@sylphx/flow 2.1.3 ā 2.1.5
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/CHANGELOG.md +28 -0
- package/README.md +44 -0
- package/package.json +79 -73
- package/src/commands/flow/execute-v2.ts +37 -29
- package/src/commands/flow/prompt.ts +5 -3
- package/src/commands/flow/types.ts +0 -2
- package/src/commands/flow-command.ts +20 -13
- package/src/commands/hook-command.ts +1 -3
- package/src/commands/settings/checkbox-config.ts +128 -0
- package/src/commands/settings/index.ts +6 -0
- package/src/commands/settings-command.ts +84 -156
- package/src/config/ai-config.ts +60 -41
- package/src/core/agent-loader.ts +11 -6
- package/src/core/attach/file-attacher.ts +172 -0
- package/src/core/attach/index.ts +5 -0
- package/src/core/attach-manager.ts +117 -171
- package/src/core/backup-manager.ts +35 -29
- package/src/core/cleanup-handler.ts +11 -8
- package/src/core/error-handling.ts +23 -30
- package/src/core/flow-executor.ts +58 -76
- package/src/core/formatting/bytes.ts +2 -4
- package/src/core/functional/async.ts +5 -4
- package/src/core/functional/error-handler.ts +2 -2
- package/src/core/git-stash-manager.ts +21 -10
- package/src/core/installers/file-installer.ts +0 -1
- package/src/core/installers/mcp-installer.ts +0 -1
- package/src/core/project-manager.ts +24 -18
- package/src/core/secrets-manager.ts +54 -73
- package/src/core/session-manager.ts +20 -22
- package/src/core/state-detector.ts +139 -80
- package/src/core/template-loader.ts +13 -31
- package/src/core/upgrade-manager.ts +122 -69
- package/src/index.ts +8 -5
- package/src/services/auto-upgrade.ts +1 -1
- package/src/services/config-service.ts +41 -29
- package/src/services/global-config.ts +3 -3
- package/src/services/target-installer.ts +11 -26
- package/src/targets/claude-code.ts +35 -81
- package/src/targets/opencode.ts +28 -68
- package/src/targets/shared/index.ts +7 -0
- package/src/targets/shared/mcp-transforms.ts +132 -0
- package/src/targets/shared/target-operations.ts +135 -0
- package/src/types/cli.types.ts +2 -2
- package/src/types/provider.types.ts +1 -7
- package/src/types/session.types.ts +11 -11
- package/src/types/target.types.ts +3 -1
- package/src/types/todo.types.ts +1 -1
- package/src/types.ts +1 -1
- package/src/utils/__tests__/package-manager-detector.test.ts +6 -6
- package/src/utils/agent-enhancer.ts +4 -4
- package/src/utils/config/paths.ts +3 -1
- package/src/utils/config/target-utils.ts +2 -2
- package/src/utils/display/banner.ts +2 -2
- package/src/utils/display/notifications.ts +58 -45
- package/src/utils/display/status.ts +29 -12
- package/src/utils/files/file-operations.ts +1 -1
- package/src/utils/files/sync-utils.ts +38 -41
- package/src/utils/index.ts +19 -27
- package/src/utils/package-manager-detector.ts +15 -5
- package/src/utils/security/security.ts +8 -4
- package/src/utils/target-selection.ts +6 -8
- package/src/utils/version.ts +4 -2
- package/src/commands/flow-orchestrator.ts +0 -328
- package/src/commands/init-command.ts +0 -92
- package/src/commands/init-core.ts +0 -331
- package/src/core/agent-manager.ts +0 -174
- package/src/core/loop-controller.ts +0 -200
- package/src/core/rule-loader.ts +0 -147
- package/src/core/rule-manager.ts +0 -240
- package/src/services/claude-config-service.ts +0 -252
- package/src/services/first-run-setup.ts +0 -220
- package/src/services/smart-config-service.ts +0 -269
- package/src/types/api.types.ts +0 -9
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* First Run Setup
|
|
3
|
-
* Quick configuration wizard for new users
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import chalk from 'chalk';
|
|
7
|
-
import inquirer from 'inquirer';
|
|
8
|
-
import { GlobalConfigService } from './global-config.js';
|
|
9
|
-
import { UserCancelledError } from '../utils/errors.js';
|
|
10
|
-
|
|
11
|
-
export interface QuickSetupResult {
|
|
12
|
-
target: 'claude-code' | 'opencode';
|
|
13
|
-
provider?: 'default' | 'kimi' | 'zai' | 'ask-every-time';
|
|
14
|
-
mcpServers: string[];
|
|
15
|
-
apiKeys: Record<string, Record<string, string>>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class FirstRunSetup {
|
|
19
|
-
private configService: GlobalConfigService;
|
|
20
|
-
|
|
21
|
-
constructor() {
|
|
22
|
-
this.configService = new GlobalConfigService();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Run setup wizard
|
|
27
|
-
*/
|
|
28
|
-
async run(): Promise<QuickSetupResult> {
|
|
29
|
-
try {
|
|
30
|
-
console.log(chalk.cyan.bold('\nāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā®'));
|
|
31
|
-
console.log(chalk.cyan.bold('ā ā'));
|
|
32
|
-
console.log(chalk.cyan.bold('ā Welcome to Sylphx Flow! ā'));
|
|
33
|
-
console.log(chalk.cyan.bold('ā Let\'s configure your environment ā'));
|
|
34
|
-
console.log(chalk.cyan.bold('ā ā'));
|
|
35
|
-
console.log(chalk.cyan.bold('ā°āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāÆ\n'));
|
|
36
|
-
|
|
37
|
-
// Step 1: Select target platform
|
|
38
|
-
console.log(chalk.cyan('š§ Setup (1/3) - Target Platform\n'));
|
|
39
|
-
const { target } = await inquirer.prompt([
|
|
40
|
-
{
|
|
41
|
-
type: 'list',
|
|
42
|
-
name: 'target',
|
|
43
|
-
message: 'Select your preferred platform:',
|
|
44
|
-
choices: [
|
|
45
|
-
{ name: 'Claude Code', value: 'claude-code' },
|
|
46
|
-
{ name: 'OpenCode', value: 'opencode' },
|
|
47
|
-
],
|
|
48
|
-
default: 'claude-code',
|
|
49
|
-
},
|
|
50
|
-
]);
|
|
51
|
-
|
|
52
|
-
let provider: string | undefined = 'ask-every-time';
|
|
53
|
-
const apiKeys: Record<string, Record<string, string>> = {};
|
|
54
|
-
|
|
55
|
-
// Step 2: Provider setup (Claude Code only)
|
|
56
|
-
if (target === 'claude-code') {
|
|
57
|
-
console.log(chalk.cyan('\nš§ Setup (2/3) - Provider\n'));
|
|
58
|
-
const { selectedProvider } = await inquirer.prompt([
|
|
59
|
-
{
|
|
60
|
-
type: 'list',
|
|
61
|
-
name: 'selectedProvider',
|
|
62
|
-
message: 'Select your preferred provider:',
|
|
63
|
-
choices: [
|
|
64
|
-
{ name: 'Ask me every time', value: 'ask-every-time' },
|
|
65
|
-
{ name: 'Default (Claude Code built-in)', value: 'default' },
|
|
66
|
-
{ name: 'Kimi (requires API key)', value: 'kimi' },
|
|
67
|
-
{ name: 'Z.ai (requires API key)', value: 'zai' },
|
|
68
|
-
],
|
|
69
|
-
default: 'ask-every-time',
|
|
70
|
-
},
|
|
71
|
-
]);
|
|
72
|
-
|
|
73
|
-
provider = selectedProvider;
|
|
74
|
-
|
|
75
|
-
// Configure API key if needed
|
|
76
|
-
if (provider === 'kimi' || provider === 'zai') {
|
|
77
|
-
const { apiKey } = await inquirer.prompt([
|
|
78
|
-
{
|
|
79
|
-
type: 'password',
|
|
80
|
-
name: 'apiKey',
|
|
81
|
-
message: provider === 'kimi' ? 'Enter Kimi API key:' : 'Enter Z.ai API key:',
|
|
82
|
-
mask: '*',
|
|
83
|
-
},
|
|
84
|
-
]);
|
|
85
|
-
|
|
86
|
-
apiKeys[provider] = { apiKey };
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Step 3: MCP Servers
|
|
91
|
-
const stepNumber = target === 'claude-code' ? '3/3' : '2/2';
|
|
92
|
-
console.log(chalk.cyan('\nš§ Setup (' + stepNumber + ') - MCP Servers\n'));
|
|
93
|
-
|
|
94
|
-
const { mcpServers } = await inquirer.prompt([
|
|
95
|
-
{
|
|
96
|
-
type: 'checkbox',
|
|
97
|
-
name: 'mcpServers',
|
|
98
|
-
message: 'Select MCP servers to enable:',
|
|
99
|
-
choices: [
|
|
100
|
-
{ name: 'GitHub Code Search (grep.app)', value: 'grep', checked: true },
|
|
101
|
-
{ name: 'Context7 Docs', value: 'context7', checked: true },
|
|
102
|
-
{ name: 'Playwright Browser Control', value: 'playwright', checked: true },
|
|
103
|
-
{ name: 'GitHub (requires GITHUB_TOKEN)', value: 'github' },
|
|
104
|
-
{ name: 'Notion (requires NOTION_API_KEY)', value: 'notion' },
|
|
105
|
-
],
|
|
106
|
-
},
|
|
107
|
-
]);
|
|
108
|
-
|
|
109
|
-
// Configure MCP API keys
|
|
110
|
-
const mcpServerRequirements: Record<string, string[]> = {
|
|
111
|
-
github: ['GITHUB_TOKEN'],
|
|
112
|
-
notion: ['NOTION_API_KEY'],
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
for (const serverKey of mcpServers) {
|
|
116
|
-
const requirements = mcpServerRequirements[serverKey];
|
|
117
|
-
if (requirements) {
|
|
118
|
-
const configMessage = 'Configure ' + requirements[0] + ' for ' + serverKey + '?';
|
|
119
|
-
const { shouldConfigure } = await inquirer.prompt([
|
|
120
|
-
{
|
|
121
|
-
type: 'confirm',
|
|
122
|
-
name: 'shouldConfigure',
|
|
123
|
-
message: configMessage,
|
|
124
|
-
default: true,
|
|
125
|
-
},
|
|
126
|
-
]);
|
|
127
|
-
|
|
128
|
-
if (shouldConfigure) {
|
|
129
|
-
const questions = requirements.map((key) => {
|
|
130
|
-
return {
|
|
131
|
-
type: 'password' as const,
|
|
132
|
-
name: key,
|
|
133
|
-
message: 'Enter ' + key + ':',
|
|
134
|
-
mask: '*',
|
|
135
|
-
};
|
|
136
|
-
});
|
|
137
|
-
const answers = await inquirer.prompt(questions);
|
|
138
|
-
|
|
139
|
-
apiKeys[serverKey] = answers;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Save configuration
|
|
145
|
-
await this.saveConfiguration({
|
|
146
|
-
target,
|
|
147
|
-
provider,
|
|
148
|
-
mcpServers,
|
|
149
|
-
apiKeys,
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
console.log(chalk.green('\nā Configuration saved to ~/.sylphx-flow/\n'));
|
|
153
|
-
|
|
154
|
-
return {
|
|
155
|
-
target,
|
|
156
|
-
provider: provider as any,
|
|
157
|
-
mcpServers,
|
|
158
|
-
apiKeys,
|
|
159
|
-
};
|
|
160
|
-
} catch (error: any) {
|
|
161
|
-
// Handle user cancellation (Ctrl+C)
|
|
162
|
-
if (error.name === 'ExitPromptError' || error.message?.includes('force closed')) {
|
|
163
|
-
throw new UserCancelledError('Setup cancelled by user');
|
|
164
|
-
}
|
|
165
|
-
throw error;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Save configuration to global config files
|
|
171
|
-
*/
|
|
172
|
-
private async saveConfiguration(result: QuickSetupResult): Promise<void> {
|
|
173
|
-
// Save global settings
|
|
174
|
-
await this.configService.saveSettings({
|
|
175
|
-
version: '1.0.0',
|
|
176
|
-
defaultTarget: result.target,
|
|
177
|
-
firstRun: false,
|
|
178
|
-
lastUpdated: new Date().toISOString(),
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
// Save provider config (Claude Code)
|
|
182
|
-
if (result.target === 'claude-code' && result.provider) {
|
|
183
|
-
const providerConfig = await this.configService.loadProviderConfig();
|
|
184
|
-
providerConfig.claudeCode.defaultProvider = result.provider;
|
|
185
|
-
|
|
186
|
-
// Save API keys
|
|
187
|
-
if (result.provider === 'kimi' && result.apiKeys.kimi) {
|
|
188
|
-
providerConfig.claudeCode.providers.kimi = {
|
|
189
|
-
apiKey: result.apiKeys.kimi.apiKey,
|
|
190
|
-
enabled: true,
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
if (result.provider === 'zai' && result.apiKeys.zai) {
|
|
194
|
-
providerConfig.claudeCode.providers.zai = {
|
|
195
|
-
apiKey: result.apiKeys.zai.apiKey,
|
|
196
|
-
enabled: true,
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
await this.configService.saveProviderConfig(providerConfig);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Save MCP config
|
|
204
|
-
const mcpConfig = await this.configService.loadMCPConfig();
|
|
205
|
-
for (const serverKey of result.mcpServers) {
|
|
206
|
-
mcpConfig.servers[serverKey] = {
|
|
207
|
-
enabled: true,
|
|
208
|
-
env: result.apiKeys[serverKey] || {},
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
await this.configService.saveMCPConfig(mcpConfig);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Check if we should run quick setup
|
|
216
|
-
*/
|
|
217
|
-
async shouldRun(): Promise<boolean> {
|
|
218
|
-
return await this.configService.isFirstRun();
|
|
219
|
-
}
|
|
220
|
-
}
|
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Smart Configuration Service
|
|
3
|
-
* Handles intelligent provider and agent selection with user preferences
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import inquirer from 'inquirer';
|
|
7
|
-
import chalk from 'chalk';
|
|
8
|
-
import { ConfigService, UserSettings, RuntimeChoices } from './config-service.js';
|
|
9
|
-
import { loadAllAgents } from '../core/agent-loader.js';
|
|
10
|
-
|
|
11
|
-
export interface SmartConfigOptions {
|
|
12
|
-
selectProvider?: boolean;
|
|
13
|
-
selectAgent?: boolean;
|
|
14
|
-
useDefaults?: boolean;
|
|
15
|
-
provider?: string;
|
|
16
|
-
agent?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export class SmartConfigService {
|
|
20
|
-
/**
|
|
21
|
-
* Initial setup - configure API keys once
|
|
22
|
-
*/
|
|
23
|
-
static async initialSetup(): Promise<void> {
|
|
24
|
-
console.log(chalk.cyan.bold('š Initial Setup - Configure API Keys\n'));
|
|
25
|
-
|
|
26
|
-
const userSettings = await ConfigService.loadHomeSettings();
|
|
27
|
-
const apiKeys = userSettings.apiKeys || {};
|
|
28
|
-
|
|
29
|
-
// Configure providers
|
|
30
|
-
const providers = [
|
|
31
|
-
{ id: 'kimi', name: 'Kimi', hasKey: !!apiKeys.kimi },
|
|
32
|
-
{ id: 'z.ai', name: 'Z.ai (Recommended)', hasKey: !!apiKeys['z.ai'] },
|
|
33
|
-
];
|
|
34
|
-
|
|
35
|
-
const missingProviders = providers.filter(p => !p.hasKey);
|
|
36
|
-
const existingProviders = providers.filter(p => p.hasKey);
|
|
37
|
-
|
|
38
|
-
// Ask which providers to configure
|
|
39
|
-
console.log(chalk.cyan('Available providers:\n'));
|
|
40
|
-
console.log(chalk.dim(' ⢠Default (uses Claude Code configuration)'));
|
|
41
|
-
providers.forEach(p => {
|
|
42
|
-
const status = p.hasKey ? chalk.green('ā') : chalk.yellow('ā');
|
|
43
|
-
console.log(` ${status} ${p.name}`);
|
|
44
|
-
});
|
|
45
|
-
console.log('');
|
|
46
|
-
|
|
47
|
-
const { selectedProvider } = await inquirer.prompt([
|
|
48
|
-
{
|
|
49
|
-
type: 'list',
|
|
50
|
-
name: 'selectedProvider',
|
|
51
|
-
message: 'Select provider:',
|
|
52
|
-
choices: [
|
|
53
|
-
{
|
|
54
|
-
name: 'Default (Use Claude Code configuration)',
|
|
55
|
-
value: 'default',
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
name: 'Kimi',
|
|
59
|
-
value: 'kimi',
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
name: 'Z.ai (Recommended)',
|
|
63
|
-
value: 'z.ai',
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
},
|
|
67
|
-
]);
|
|
68
|
-
|
|
69
|
-
if (selectedProvider !== 'default') {
|
|
70
|
-
await this.configureSelectedProviders([selectedProvider], apiKeys);
|
|
71
|
-
} else {
|
|
72
|
-
console.log(chalk.dim('Using Claude Code default configuration.'));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (existingProviders.length > 0) {
|
|
76
|
-
console.log(chalk.green('\nā
Already configured:'));
|
|
77
|
-
existingProviders.forEach(p => {
|
|
78
|
-
console.log(chalk.dim(` ⢠${p.name}`));
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Mark setup as completed (only save API keys, no defaults)
|
|
83
|
-
await ConfigService.saveHomeSettings({ hasCompletedSetup: true });
|
|
84
|
-
console.log(chalk.green('\nā Setup complete!\n'));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Configure selected providers
|
|
89
|
-
*/
|
|
90
|
-
private static async configureSelectedProviders(
|
|
91
|
-
selectedProviders: string[],
|
|
92
|
-
existingApiKeys: any
|
|
93
|
-
): Promise<void> {
|
|
94
|
-
for (const providerId of selectedProviders) {
|
|
95
|
-
const providerName = providerId === 'kimi' ? 'Kimi' : 'Z.ai';
|
|
96
|
-
console.log(chalk.cyan(`\nš Configure ${providerName}\n`));
|
|
97
|
-
|
|
98
|
-
const { apiKey } = await inquirer.prompt([
|
|
99
|
-
{
|
|
100
|
-
type: 'password',
|
|
101
|
-
name: 'apiKey',
|
|
102
|
-
message: `Enter API Key for ${providerName}:`,
|
|
103
|
-
mask: '*',
|
|
104
|
-
validate: (input) => input.length > 10 || 'API Key appears too short',
|
|
105
|
-
},
|
|
106
|
-
]);
|
|
107
|
-
|
|
108
|
-
existingApiKeys[providerId] = apiKey;
|
|
109
|
-
console.log(chalk.green(`ā API Key configured for ${providerName}`));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Save all API keys
|
|
113
|
-
await ConfigService.saveHomeSettings({ apiKeys: existingApiKeys });
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Runtime selection - choose provider and agent for this run
|
|
119
|
-
*
|
|
120
|
-
* DESIGN PRINCIPLE: Always Ask (Simple & Explicit)
|
|
121
|
-
* - Has args (--provider/--agent) ā Use them directly
|
|
122
|
-
* - No args ā Always prompt user
|
|
123
|
-
* - Never save runtime choices as defaults
|
|
124
|
-
*/
|
|
125
|
-
static async selectRuntimeChoices(options: SmartConfigOptions): Promise<RuntimeChoices> {
|
|
126
|
-
const config = await ConfigService.loadConfiguration();
|
|
127
|
-
const choices: RuntimeChoices = {};
|
|
128
|
-
|
|
129
|
-
// Handle provider selection
|
|
130
|
-
if (options.provider) {
|
|
131
|
-
// Explicit option provided via args
|
|
132
|
-
choices.provider = options.provider;
|
|
133
|
-
} else {
|
|
134
|
-
// Always prompt
|
|
135
|
-
choices.provider = await this.selectProvider(config.user);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// Handle agent selection
|
|
139
|
-
if (options.agent) {
|
|
140
|
-
// Explicit option provided via args
|
|
141
|
-
choices.agent = options.agent;
|
|
142
|
-
} else {
|
|
143
|
-
// Always prompt
|
|
144
|
-
choices.agent = await this.selectAgent();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return choices;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Select provider for this run
|
|
152
|
-
*/
|
|
153
|
-
private static async selectProvider(userSettings: UserSettings): Promise<string> {
|
|
154
|
-
const apiKeys = userSettings.apiKeys || {};
|
|
155
|
-
|
|
156
|
-
// Always show all 3 providers
|
|
157
|
-
const allProviders = [
|
|
158
|
-
{ id: 'default', name: 'Default (Claude Code configuration)', hasKey: true },
|
|
159
|
-
{ id: 'kimi', name: 'Kimi', hasKey: !!apiKeys.kimi },
|
|
160
|
-
{ id: 'z.ai', name: 'Z.ai (Recommended)', hasKey: !!apiKeys['z.ai'] },
|
|
161
|
-
];
|
|
162
|
-
|
|
163
|
-
const { provider } = await inquirer.prompt([
|
|
164
|
-
{
|
|
165
|
-
type: 'list',
|
|
166
|
-
name: 'provider',
|
|
167
|
-
message: 'Select provider:',
|
|
168
|
-
choices: allProviders.map(p => ({
|
|
169
|
-
name: p.hasKey ? p.name : `${p.name} (Need API key)`,
|
|
170
|
-
value: p.id,
|
|
171
|
-
})),
|
|
172
|
-
default: 'default',
|
|
173
|
-
},
|
|
174
|
-
]);
|
|
175
|
-
|
|
176
|
-
// If user selected a provider without API key, prompt for it
|
|
177
|
-
if (provider !== 'default' && !apiKeys[provider]) {
|
|
178
|
-
console.log(chalk.cyan(`\nš Configure ${provider} API key:\n`));
|
|
179
|
-
const { apiKey } = await inquirer.prompt([
|
|
180
|
-
{
|
|
181
|
-
type: 'password',
|
|
182
|
-
name: 'apiKey',
|
|
183
|
-
message: `Enter API Key for ${provider}:`,
|
|
184
|
-
mask: '*',
|
|
185
|
-
validate: (input) => input.length > 10 || 'API Key appears too short',
|
|
186
|
-
},
|
|
187
|
-
]);
|
|
188
|
-
|
|
189
|
-
// Save the API key
|
|
190
|
-
apiKeys[provider] = apiKey;
|
|
191
|
-
await ConfigService.saveHomeSettings({ apiKeys });
|
|
192
|
-
console.log(chalk.green(`ā API Key saved for ${provider}\n`));
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return provider;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Select agent for this run
|
|
200
|
-
*/
|
|
201
|
-
private static async selectAgent(): Promise<string> {
|
|
202
|
-
try {
|
|
203
|
-
const agents = await loadAllAgents(process.cwd());
|
|
204
|
-
|
|
205
|
-
if (agents.length === 0) {
|
|
206
|
-
console.log(chalk.yellow('ā No agents found, using "coder"'));
|
|
207
|
-
return 'coder';
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
const { agent } = await inquirer.prompt([
|
|
211
|
-
{
|
|
212
|
-
type: 'list',
|
|
213
|
-
name: 'agent',
|
|
214
|
-
message: 'Select agent:',
|
|
215
|
-
choices: agents.map(a => ({
|
|
216
|
-
name: a.metadata.name || a.id,
|
|
217
|
-
value: a.id,
|
|
218
|
-
})),
|
|
219
|
-
default: agents.find(a => a.id === 'coder')?.id || agents[0].id,
|
|
220
|
-
},
|
|
221
|
-
]);
|
|
222
|
-
|
|
223
|
-
return agent;
|
|
224
|
-
} catch (error) {
|
|
225
|
-
console.log(chalk.yellow('ā Could not load agents, using "coder"'));
|
|
226
|
-
return 'coder';
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Setup environment variables based on runtime choices
|
|
232
|
-
*/
|
|
233
|
-
static async setupEnvironment(provider: string): Promise<void> {
|
|
234
|
-
const userSettings = await ConfigService.loadHomeSettings();
|
|
235
|
-
const apiKeys = userSettings.apiKeys || {};
|
|
236
|
-
|
|
237
|
-
if (provider !== 'default' && !apiKeys[provider]) {
|
|
238
|
-
throw new Error(`No API key configured for provider: ${provider}`);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
const providerConfigs = {
|
|
242
|
-
default: {
|
|
243
|
-
description: 'Default (No Override)',
|
|
244
|
-
},
|
|
245
|
-
kimi: {
|
|
246
|
-
ANTHROPIC_BASE_URL: 'https://api.kimi.com/coding/',
|
|
247
|
-
description: 'Kimi',
|
|
248
|
-
},
|
|
249
|
-
'z.ai': {
|
|
250
|
-
ANTHROPIC_BASE_URL: 'https://api.z.ai/api/anthropic',
|
|
251
|
-
description: 'Z.ai Proxy',
|
|
252
|
-
},
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
// Setup environment based on provider
|
|
256
|
-
if (provider === 'default') {
|
|
257
|
-
// Don't override anything - use user's existing Claude Code configuration
|
|
258
|
-
console.log(chalk.dim(' ā Using Claude Code default configuration'));
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
const config = providerConfigs[provider as keyof typeof providerConfigs];
|
|
263
|
-
process.env.ANTHROPIC_BASE_URL = config.ANTHROPIC_BASE_URL;
|
|
264
|
-
process.env.ANTHROPIC_AUTH_TOKEN = apiKeys[provider]; // Claude Code uses ANTHROPIC_AUTH_TOKEN, not ANTHROPIC_API_KEY
|
|
265
|
-
|
|
266
|
-
// Success message
|
|
267
|
-
console.log(chalk.green(` ā Environment configured for ${provider}`));
|
|
268
|
-
}
|
|
269
|
-
}
|
package/src/types/api.types.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Backward compatibility layer for API types
|
|
3
|
-
* Re-exports from the organized API types module
|
|
4
|
-
*
|
|
5
|
-
* @deprecated Import from './types/api' instead
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// Re-export everything from the organized API types module
|
|
9
|
-
export * from './types/api/index.js';
|