@sylphx/flow 1.0.1 → 1.0.3
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 +12 -0
- package/package.json +10 -9
- package/src/commands/codebase-command.ts +168 -0
- package/src/commands/flow-command.ts +1137 -0
- package/src/commands/flow-orchestrator.ts +296 -0
- package/src/commands/hook-command.ts +444 -0
- package/src/commands/init-command.ts +92 -0
- package/src/commands/init-core.ts +322 -0
- package/src/commands/knowledge-command.ts +161 -0
- package/src/commands/run-command.ts +120 -0
- package/src/components/benchmark-monitor.tsx +331 -0
- package/src/components/reindex-progress.tsx +261 -0
- package/src/composables/functional/index.ts +14 -0
- package/src/composables/functional/useEnvironment.ts +171 -0
- package/src/composables/functional/useFileSystem.ts +139 -0
- package/src/composables/index.ts +5 -0
- package/src/composables/useEnv.ts +13 -0
- package/src/composables/useRuntimeConfig.ts +27 -0
- package/src/composables/useTargetConfig.ts +45 -0
- package/src/config/ai-config.ts +376 -0
- package/src/config/constants.ts +35 -0
- package/src/config/index.ts +27 -0
- package/src/config/rules.ts +43 -0
- package/src/config/servers.ts +371 -0
- package/src/config/targets.ts +126 -0
- package/src/core/agent-loader.ts +141 -0
- package/src/core/agent-manager.ts +174 -0
- package/src/core/ai-sdk.ts +603 -0
- package/src/core/app-factory.ts +381 -0
- package/src/core/builtin-agents.ts +9 -0
- package/src/core/command-system.ts +550 -0
- package/src/core/config-system.ts +550 -0
- package/src/core/connection-pool.ts +390 -0
- package/src/core/di-container.ts +155 -0
- package/src/core/error-handling.ts +519 -0
- package/src/core/formatting/bytes.test.ts +115 -0
- package/src/core/formatting/bytes.ts +64 -0
- package/src/core/functional/async.ts +313 -0
- package/src/core/functional/either.ts +109 -0
- package/src/core/functional/error-handler.ts +135 -0
- package/src/core/functional/error-types.ts +311 -0
- package/src/core/functional/index.ts +19 -0
- package/src/core/functional/option.ts +142 -0
- package/src/core/functional/pipe.ts +189 -0
- package/src/core/functional/result.ts +204 -0
- package/src/core/functional/validation.ts +138 -0
- package/src/core/headless-display.ts +96 -0
- package/src/core/index.ts +6 -0
- package/src/core/installers/file-installer.ts +303 -0
- package/src/core/installers/mcp-installer.ts +213 -0
- package/src/core/interfaces/index.ts +22 -0
- package/src/core/interfaces/repository.interface.ts +91 -0
- package/src/core/interfaces/service.interface.ts +133 -0
- package/src/core/interfaces.ts +129 -0
- package/src/core/loop-controller.ts +200 -0
- package/src/core/result.ts +351 -0
- package/src/core/rule-loader.ts +147 -0
- package/src/core/rule-manager.ts +240 -0
- package/src/core/service-config.ts +252 -0
- package/src/core/session-service.ts +121 -0
- package/src/core/state-detector.ts +389 -0
- package/src/core/storage-factory.ts +115 -0
- package/src/core/stream-handler.ts +288 -0
- package/src/core/target-manager.ts +161 -0
- package/src/core/type-utils.ts +427 -0
- package/src/core/unified-storage.ts +456 -0
- package/src/core/upgrade-manager.ts +300 -0
- package/src/core/validation/limit.test.ts +155 -0
- package/src/core/validation/limit.ts +46 -0
- package/src/core/validation/query.test.ts +44 -0
- package/src/core/validation/query.ts +20 -0
- package/src/db/auto-migrate.ts +322 -0
- package/src/db/base-database-client.ts +144 -0
- package/src/db/cache-db.ts +218 -0
- package/src/db/cache-schema.ts +75 -0
- package/src/db/database.ts +70 -0
- package/src/db/index.ts +252 -0
- package/src/db/memory-db.ts +153 -0
- package/src/db/memory-schema.ts +29 -0
- package/src/db/schema.ts +289 -0
- package/src/db/session-repository.ts +733 -0
- package/src/domains/codebase/index.ts +5 -0
- package/src/domains/codebase/tools.ts +139 -0
- package/src/domains/index.ts +8 -0
- package/src/domains/knowledge/index.ts +10 -0
- package/src/domains/knowledge/resources.ts +537 -0
- package/src/domains/knowledge/tools.ts +174 -0
- package/src/domains/utilities/index.ts +6 -0
- package/src/domains/utilities/time/index.ts +5 -0
- package/src/domains/utilities/time/tools.ts +291 -0
- package/src/index.ts +211 -0
- package/src/services/agent-service.ts +273 -0
- package/src/services/claude-config-service.ts +252 -0
- package/src/services/config-service.ts +258 -0
- package/src/services/evaluation-service.ts +271 -0
- package/src/services/functional/evaluation-logic.ts +296 -0
- package/src/services/functional/file-processor.ts +273 -0
- package/src/services/functional/index.ts +12 -0
- package/src/services/index.ts +13 -0
- package/src/services/mcp-service.ts +432 -0
- package/src/services/memory.service.ts +476 -0
- package/src/services/search/base-indexer.ts +156 -0
- package/src/services/search/codebase-indexer-types.ts +38 -0
- package/src/services/search/codebase-indexer.ts +647 -0
- package/src/services/search/embeddings-provider.ts +455 -0
- package/src/services/search/embeddings.ts +316 -0
- package/src/services/search/functional-indexer.ts +323 -0
- package/src/services/search/index.ts +27 -0
- package/src/services/search/indexer.ts +380 -0
- package/src/services/search/knowledge-indexer.ts +422 -0
- package/src/services/search/semantic-search.ts +244 -0
- package/src/services/search/tfidf.ts +559 -0
- package/src/services/search/unified-search-service.ts +888 -0
- package/src/services/smart-config-service.ts +385 -0
- package/src/services/storage/cache-storage.ts +487 -0
- package/src/services/storage/drizzle-storage.ts +581 -0
- package/src/services/storage/index.ts +15 -0
- package/src/services/storage/lancedb-vector-storage.ts +494 -0
- package/src/services/storage/memory-storage.ts +268 -0
- package/src/services/storage/separated-storage.ts +467 -0
- package/src/services/storage/vector-storage.ts +13 -0
- package/src/shared/agents/index.ts +63 -0
- package/src/shared/files/index.ts +99 -0
- package/src/shared/index.ts +32 -0
- package/src/shared/logging/index.ts +24 -0
- package/src/shared/processing/index.ts +153 -0
- package/src/shared/types/index.ts +25 -0
- package/src/targets/claude-code.ts +574 -0
- package/src/targets/functional/claude-code-logic.ts +185 -0
- package/src/targets/functional/index.ts +6 -0
- package/src/targets/opencode.ts +529 -0
- package/src/types/agent.types.ts +32 -0
- package/src/types/api/batch.ts +108 -0
- package/src/types/api/errors.ts +118 -0
- package/src/types/api/index.ts +55 -0
- package/src/types/api/requests.ts +76 -0
- package/src/types/api/responses.ts +180 -0
- package/src/types/api/websockets.ts +85 -0
- package/src/types/api.types.ts +9 -0
- package/src/types/benchmark.ts +49 -0
- package/src/types/cli.types.ts +87 -0
- package/src/types/common.types.ts +35 -0
- package/src/types/database.types.ts +510 -0
- package/src/types/mcp-config.types.ts +448 -0
- package/src/types/mcp.types.ts +69 -0
- package/src/types/memory-types.ts +63 -0
- package/src/types/provider.types.ts +28 -0
- package/src/types/rule.types.ts +24 -0
- package/src/types/session.types.ts +214 -0
- package/src/types/target-config.types.ts +295 -0
- package/src/types/target.types.ts +140 -0
- package/src/types/todo.types.ts +25 -0
- package/src/types.ts +40 -0
- package/src/utils/advanced-tokenizer.ts +191 -0
- package/src/utils/agent-enhancer.ts +114 -0
- package/src/utils/ai-model-fetcher.ts +19 -0
- package/src/utils/async-file-operations.ts +516 -0
- package/src/utils/audio-player.ts +345 -0
- package/src/utils/cli-output.ts +266 -0
- package/src/utils/codebase-helpers.ts +211 -0
- package/src/utils/console-ui.ts +79 -0
- package/src/utils/database-errors.ts +140 -0
- package/src/utils/debug-logger.ts +49 -0
- package/src/utils/error-handler.ts +53 -0
- package/src/utils/file-operations.ts +310 -0
- package/src/utils/file-scanner.ts +259 -0
- package/src/utils/functional/array.ts +355 -0
- package/src/utils/functional/index.ts +15 -0
- package/src/utils/functional/object.ts +279 -0
- package/src/utils/functional/string.ts +281 -0
- package/src/utils/functional.ts +543 -0
- package/src/utils/help.ts +20 -0
- package/src/utils/immutable-cache.ts +106 -0
- package/src/utils/index.ts +78 -0
- package/src/utils/jsonc.ts +158 -0
- package/src/utils/logger.ts +396 -0
- package/src/utils/mcp-config.ts +249 -0
- package/src/utils/memory-tui.ts +414 -0
- package/src/utils/models-dev.ts +91 -0
- package/src/utils/notifications.ts +169 -0
- package/src/utils/object-utils.ts +51 -0
- package/src/utils/parallel-operations.ts +487 -0
- package/src/utils/paths.ts +143 -0
- package/src/utils/process-manager.ts +155 -0
- package/src/utils/prompts.ts +120 -0
- package/src/utils/search-tool-builder.ts +214 -0
- package/src/utils/secret-utils.ts +179 -0
- package/src/utils/security.ts +537 -0
- package/src/utils/session-manager.ts +168 -0
- package/src/utils/session-title.ts +87 -0
- package/src/utils/settings.ts +182 -0
- package/src/utils/simplified-errors.ts +410 -0
- package/src/utils/sync-utils.ts +159 -0
- package/src/utils/target-config.ts +570 -0
- package/src/utils/target-utils.ts +394 -0
- package/src/utils/template-engine.ts +94 -0
- package/src/utils/test-audio.ts +71 -0
- package/src/utils/todo-context.ts +46 -0
- package/src/utils/token-counter.ts +288 -0
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -59554
- package/dist/lancedb.linux-x64-gnu-b7f0jgsz.node +0 -0
- package/dist/lancedb.linux-x64-musl-tgcv22rx.node +0 -0
- package/dist/shared/chunk-25dwp0dp.js +0 -89
- package/dist/shared/chunk-3pjb6063.js +0 -208
- package/dist/shared/chunk-4d6ydpw7.js +0 -2854
- package/dist/shared/chunk-4wjcadjk.js +0 -225
- package/dist/shared/chunk-5j4w74t6.js +0 -30
- package/dist/shared/chunk-5j8m3dh3.js +0 -58
- package/dist/shared/chunk-5thh3qem.js +0 -91
- package/dist/shared/chunk-6g9xy73m.js +0 -252
- package/dist/shared/chunk-7eq34c42.js +0 -23
- package/dist/shared/chunk-c2gwgx3r.js +0 -115
- package/dist/shared/chunk-cjd3mk4c.js +0 -1320
- package/dist/shared/chunk-g5cv6703.js +0 -368
- package/dist/shared/chunk-hpkhykhq.js +0 -574
- package/dist/shared/chunk-m2322pdk.js +0 -122
- package/dist/shared/chunk-nd5fdvaq.js +0 -26
- package/dist/shared/chunk-pgd3m6zf.js +0 -108
- package/dist/shared/chunk-qk8n91hw.js +0 -494
- package/dist/shared/chunk-rkkn8szp.js +0 -16855
- package/dist/shared/chunk-t16rfxh0.js +0 -61
- package/dist/shared/chunk-t4fbfa5v.js +0 -19
- package/dist/shared/chunk-t77h86w6.js +0 -276
- package/dist/shared/chunk-v0ez4aef.js +0 -71
- package/dist/shared/chunk-v29j2r3s.js +0 -32051
- package/dist/shared/chunk-vfbc6ew5.js +0 -765
- package/dist/shared/chunk-vmeqwm1c.js +0 -204
- package/dist/shared/chunk-x66eh37x.js +0 -137
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flow Orchestrator - Simplified flow management
|
|
3
|
+
* Separates concerns and reduces complexity
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import type { FlowOptions } from './flow-command.js';
|
|
8
|
+
import { StateDetector, type ProjectState } from '../core/state-detector.js';
|
|
9
|
+
import { UpgradeManager } from '../core/upgrade-manager.js';
|
|
10
|
+
import { targetManager } from '../core/target-manager.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Step 1: Check for available upgrades
|
|
14
|
+
*/
|
|
15
|
+
export async function checkUpgrades(
|
|
16
|
+
state: ProjectState,
|
|
17
|
+
options: FlowOptions
|
|
18
|
+
): Promise<void> {
|
|
19
|
+
if (options.initOnly || options.runOnly) return;
|
|
20
|
+
|
|
21
|
+
// Check Flow upgrade
|
|
22
|
+
if (await UpgradeManager.isUpgradeAvailable()) {
|
|
23
|
+
console.log(
|
|
24
|
+
chalk.yellow(
|
|
25
|
+
`📦 Sylphx Flow update available: ${state.version} → ${state.latestVersion}\n`
|
|
26
|
+
)
|
|
27
|
+
);
|
|
28
|
+
const { default: inquirer } = await import('inquirer');
|
|
29
|
+
const { upgrade } = await inquirer.prompt([
|
|
30
|
+
{
|
|
31
|
+
type: 'confirm',
|
|
32
|
+
name: 'upgrade',
|
|
33
|
+
message: 'Upgrade Sylphx Flow now?',
|
|
34
|
+
default: true,
|
|
35
|
+
},
|
|
36
|
+
]);
|
|
37
|
+
if (upgrade) {
|
|
38
|
+
options.upgrade = true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Check target upgrade (if target exists and outdated)
|
|
43
|
+
if (state.target && state.targetVersion && state.targetLatestVersion &&
|
|
44
|
+
state.targetVersion !== state.targetLatestVersion) {
|
|
45
|
+
// Simple version comparison
|
|
46
|
+
const isOutdated = compareVersions(state.targetVersion, state.targetLatestVersion) < 0;
|
|
47
|
+
|
|
48
|
+
if (isOutdated) {
|
|
49
|
+
console.log(
|
|
50
|
+
chalk.yellow(
|
|
51
|
+
`📦 ${state.target} update available: ${state.targetVersion} → ${state.targetLatestVersion}\n`
|
|
52
|
+
)
|
|
53
|
+
);
|
|
54
|
+
const { default: inquirer } = await import('inquirer');
|
|
55
|
+
const { upgradeTarget } = await inquirer.prompt([
|
|
56
|
+
{
|
|
57
|
+
type: 'confirm',
|
|
58
|
+
name: 'upgradeTarget',
|
|
59
|
+
message: `Upgrade ${state.target} now?`,
|
|
60
|
+
default: true,
|
|
61
|
+
},
|
|
62
|
+
]);
|
|
63
|
+
if (upgradeTarget) {
|
|
64
|
+
options.upgradeTarget = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Compare two version strings
|
|
72
|
+
*/
|
|
73
|
+
function compareVersions(v1: string, v2: string): number {
|
|
74
|
+
const parts1 = v1.split('.').map(Number);
|
|
75
|
+
const parts2 = v2.split('.').map(Number);
|
|
76
|
+
|
|
77
|
+
for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
|
|
78
|
+
const p1 = parts1[i] || 0;
|
|
79
|
+
const p2 = parts2[i] || 0;
|
|
80
|
+
if (p1 !== p2) {
|
|
81
|
+
return p1 - p2;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Step 2: Check component integrity and prompt for repair
|
|
89
|
+
*/
|
|
90
|
+
export async function checkComponentIntegrity(
|
|
91
|
+
state: ProjectState,
|
|
92
|
+
options: FlowOptions
|
|
93
|
+
): Promise<void> {
|
|
94
|
+
// Skip if not initialized or cleaning or init-only
|
|
95
|
+
if (!state.initialized || options.clean || options.initOnly) return;
|
|
96
|
+
|
|
97
|
+
// Skip in quick mode
|
|
98
|
+
if (options.quick) return;
|
|
99
|
+
|
|
100
|
+
// Find missing components (target-aware)
|
|
101
|
+
const missing: string[] = [];
|
|
102
|
+
if (!state.components.agents.installed) missing.push('agents');
|
|
103
|
+
if (!state.components.rules.installed) missing.push('rules');
|
|
104
|
+
|
|
105
|
+
// Only check hooks for Claude Code (OpenCode doesn't have separate hooks)
|
|
106
|
+
if (state.target !== 'opencode' && !state.components.hooks.installed) {
|
|
107
|
+
missing.push('hooks');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (!state.components.mcp.installed) missing.push('mcp');
|
|
111
|
+
|
|
112
|
+
// Only check output styles for Claude Code (OpenCode uses AGENTS.md)
|
|
113
|
+
if (state.target !== 'opencode' && !state.components.outputStyles.installed) {
|
|
114
|
+
missing.push('output styles');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (!state.components.slashCommands.installed) missing.push('slash commands');
|
|
118
|
+
|
|
119
|
+
// If no missing components, we're good
|
|
120
|
+
if (missing.length === 0) return;
|
|
121
|
+
|
|
122
|
+
// Prompt user to repair
|
|
123
|
+
console.log(chalk.yellow(`\n⚠️ Missing components detected: ${missing.join(', ')}\n`));
|
|
124
|
+
const { default: inquirer } = await import('inquirer');
|
|
125
|
+
const { repair } = await inquirer.prompt([
|
|
126
|
+
{
|
|
127
|
+
type: 'confirm',
|
|
128
|
+
name: 'repair',
|
|
129
|
+
message: 'Install missing components now?',
|
|
130
|
+
default: true,
|
|
131
|
+
},
|
|
132
|
+
]);
|
|
133
|
+
|
|
134
|
+
if (repair) {
|
|
135
|
+
// Set repair mode - will trigger component installation without full re-init
|
|
136
|
+
options.repair = true;
|
|
137
|
+
console.log(chalk.cyan('\n🔧 Repairing components...\n'));
|
|
138
|
+
} else {
|
|
139
|
+
console.log(chalk.dim('Skipping repair. Components may not work correctly.\n'));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Step 3: Handle target selection
|
|
145
|
+
* Returns the selected target ID
|
|
146
|
+
*/
|
|
147
|
+
export async function selectTarget(
|
|
148
|
+
state: ProjectState,
|
|
149
|
+
options: FlowOptions
|
|
150
|
+
): Promise<string | undefined> {
|
|
151
|
+
// Force target selection when cleaning
|
|
152
|
+
if (options.clean) {
|
|
153
|
+
const targetId = await targetManager.promptForTargetSelection();
|
|
154
|
+
console.log(chalk.green(`✅ Selected target: ${targetId}`));
|
|
155
|
+
return targetId;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Use existing target or option
|
|
159
|
+
return options.target || state.target;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Step 3: Initialize project
|
|
164
|
+
*/
|
|
165
|
+
export async function initializeProject(
|
|
166
|
+
targetId: string | undefined,
|
|
167
|
+
options: FlowOptions
|
|
168
|
+
): Promise<void> {
|
|
169
|
+
if (options.runOnly && !options.clean) return;
|
|
170
|
+
|
|
171
|
+
console.log(chalk.cyan.bold('━ Initializing Project\n'));
|
|
172
|
+
|
|
173
|
+
const { runInit } = await import('./init-command.js');
|
|
174
|
+
|
|
175
|
+
const initOptions = {
|
|
176
|
+
target: targetId,
|
|
177
|
+
verbose: options.verbose,
|
|
178
|
+
dryRun: options.dryRun,
|
|
179
|
+
clear: options.clean || false,
|
|
180
|
+
mcp: options.mcp !== false,
|
|
181
|
+
agents: options.agents !== false,
|
|
182
|
+
rules: options.rules !== false,
|
|
183
|
+
outputStyles: options.outputStyles !== false,
|
|
184
|
+
slashCommands: options.slashCommands !== false,
|
|
185
|
+
hooks: options.hooks !== false,
|
|
186
|
+
helpOption: () => {},
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
try {
|
|
190
|
+
await runInit(initOptions);
|
|
191
|
+
|
|
192
|
+
if (!options.dryRun) {
|
|
193
|
+
console.log(chalk.green.bold('\n✓ Initialization complete\n'));
|
|
194
|
+
} else {
|
|
195
|
+
console.log(chalk.dim('\n✓ Dry run complete - skipping execution\n'));
|
|
196
|
+
}
|
|
197
|
+
} catch (error) {
|
|
198
|
+
console.error(chalk.red.bold('\n✗ Initialization failed:'), error);
|
|
199
|
+
throw error;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Step 4: Launch target
|
|
205
|
+
*/
|
|
206
|
+
export async function launchTarget(
|
|
207
|
+
targetId: string | undefined,
|
|
208
|
+
prompt: string | undefined,
|
|
209
|
+
options: FlowOptions,
|
|
210
|
+
state: ProjectState
|
|
211
|
+
): Promise<void> {
|
|
212
|
+
if (options.initOnly) return;
|
|
213
|
+
|
|
214
|
+
// Resolve target
|
|
215
|
+
const resolvedTarget = await targetManager.resolveTarget({
|
|
216
|
+
target: targetId || state.target,
|
|
217
|
+
allowSelection: false,
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
console.log(chalk.cyan.bold(`━ Launching ${resolvedTarget}\n`));
|
|
221
|
+
|
|
222
|
+
// Check if target supports command execution
|
|
223
|
+
const { getTargetsWithCommandSupport } = await import('../config/targets.js');
|
|
224
|
+
const supportedTargets = getTargetsWithCommandSupport().map(t => t.id);
|
|
225
|
+
|
|
226
|
+
if (!supportedTargets.includes(resolvedTarget)) {
|
|
227
|
+
console.log(chalk.red.bold('✗ Unsupported target platform\n'));
|
|
228
|
+
console.log(
|
|
229
|
+
chalk.yellow(`Target '${resolvedTarget}' does not support agent execution.`)
|
|
230
|
+
);
|
|
231
|
+
console.log(chalk.cyan(`Supported platforms: ${supportedTargets.join(', ')}\n`));
|
|
232
|
+
throw new Error(`Unsupported target: ${resolvedTarget}`);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Handle Claude Code specific setup
|
|
236
|
+
if (resolvedTarget === 'claude-code') {
|
|
237
|
+
await setupClaudeCode(options);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Execute command
|
|
241
|
+
await executeCommand(resolvedTarget, prompt, options);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Setup Claude Code (provider + agent selection)
|
|
246
|
+
*/
|
|
247
|
+
async function setupClaudeCode(options: FlowOptions): Promise<void> {
|
|
248
|
+
const { SmartConfigService } = await import('../services/smart-config-service.js');
|
|
249
|
+
const { ConfigService } = await import('../services/config-service.js');
|
|
250
|
+
|
|
251
|
+
// Check if API keys are configured
|
|
252
|
+
if (!(await ConfigService.hasInitialSetup())) {
|
|
253
|
+
console.log(chalk.cyan('\n🔑 First-time setup for Claude Code:\n'));
|
|
254
|
+
await SmartConfigService.initialSetup();
|
|
255
|
+
console.log(chalk.green('\n✅ Claude Code setup complete!\n'));
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Select provider and agent
|
|
259
|
+
const runtimeChoices = await SmartConfigService.selectRuntimeChoices({
|
|
260
|
+
selectProvider: options.selectProvider,
|
|
261
|
+
selectAgent: options.selectAgent,
|
|
262
|
+
useDefaults: options.useDefaults,
|
|
263
|
+
provider: options.provider,
|
|
264
|
+
agent: options.agent,
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// Setup environment
|
|
268
|
+
await SmartConfigService.setupEnvironment(runtimeChoices.provider!);
|
|
269
|
+
|
|
270
|
+
// Store selected agent
|
|
271
|
+
options.agent = runtimeChoices.agent;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Execute the target command
|
|
276
|
+
*/
|
|
277
|
+
async function executeCommand(
|
|
278
|
+
targetId: string,
|
|
279
|
+
prompt: string | undefined,
|
|
280
|
+
options: FlowOptions
|
|
281
|
+
): Promise<void> {
|
|
282
|
+
const agent = options.agent || 'coder';
|
|
283
|
+
const verbose = options.verbose || false;
|
|
284
|
+
|
|
285
|
+
if (verbose || options.runOnly) {
|
|
286
|
+
console.log(`🤖 Agent: ${agent}`);
|
|
287
|
+
console.log(`🎯 Target: ${targetId}`);
|
|
288
|
+
if (prompt) {
|
|
289
|
+
console.log(`💬 Prompt: ${prompt}\n`);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Run the command
|
|
294
|
+
const { runCommand } = await import('./run-command.js');
|
|
295
|
+
await runCommand({ target: targetId, agent, prompt, verbose });
|
|
296
|
+
}
|