( configManager: ConfigManager, registryClient: RegistryClient, forceUserLevel: boolean = false, forceProjectLevel: boolean = false )
| 344 | } |
| 345 | |
| 346 | async function interactiveAddCommand( |
| 347 | configManager: ConfigManager, |
| 348 | registryClient: RegistryClient, |
| 349 | forceUserLevel: boolean = false, |
| 350 | forceProjectLevel: boolean = false |
| 351 | ): Promise<void> { |
| 352 | const commands = await registryClient.getCommands() |
| 353 | |
| 354 | const categories = [...new Set(commands.map(c => c.category))].sort() |
| 355 | |
| 356 | const { category } = await inquirer.prompt([ |
| 357 | { |
| 358 | type: 'list', |
| 359 | name: 'category', |
| 360 | message: 'Select a category:', |
| 361 | choices: ['All', ...categories] |
| 362 | } |
| 363 | ]) |
| 364 | |
| 365 | const filteredCommands = category === 'All' |
| 366 | ? commands |
| 367 | : commands.filter(c => c.category === category) |
| 368 | |
| 369 | logger.info('Use SPACE to select/deselect, ENTER to confirm') |
| 370 | |
| 371 | const { selected } = await inquirer.prompt([ |
| 372 | { |
| 373 | type: 'checkbox', |
| 374 | name: 'selected', |
| 375 | message: 'Select commands to install:', |
| 376 | choices: filteredCommands.map(c => ({ |
| 377 | name: `${c.prefix}${c.name} - ${c.description}`, |
| 378 | value: c.name, |
| 379 | short: c.name |
| 380 | })), |
| 381 | validate: (answer: string[]) => { |
| 382 | if (answer.length < 1) { |
| 383 | return 'You must select at least one command!' |
| 384 | } |
| 385 | return true |
| 386 | } |
| 387 | } |
| 388 | ]) |
| 389 | |
| 390 | if (!selected || selected.length === 0) { |
| 391 | logger.warn('No commands selected') |
| 392 | return |
| 393 | } |
| 394 | |
| 395 | logger.info(`Installing ${selected.length} command(s)...`) |
| 396 | |
| 397 | for (const name of selected) { |
| 398 | await addCommand(name, configManager, registryClient, forceUserLevel, forceProjectLevel) |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | interface MCPOptions { |
| 403 | scope: 'local' | 'user' | 'project' |
no test coverage detected