@alvinveroy/codecompass
Version:
AI-powered MCP server for codebase navigation and LLM prompt optimization
81 lines (77 loc) • 3.42 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const llm_provider_1 = require("./llm-provider");
const config_service_1 = require("./config-service");
async function main() {
const args = process.argv.slice(2);
if (args.length === 0 || args[0] === '--help' || args[0] === '-h') {
console.log(`
CodeCompass LLM Provider CLI
Usage:
provider-cli [command]
Commands:
status Show current suggestion model and provider
switch <model_name> Switch to a different suggestion model (e.g., "llama3.1:8b", "deepseek-coder")
test Test the current LLM provider connection
Examples:
provider-cli status
provider-cli switch llama3.1:8b
provider-cli switch deepseek-coder
provider-cli test
`);
return;
}
const command = args[0];
switch (command) {
case 'status':
console.log(`Current Suggestion Model: ${config_service_1.configService.SUGGESTION_MODEL}`);
console.log(`Current Suggestion Provider: ${config_service_1.configService.SUGGESTION_PROVIDER}`);
console.log(`Current Embedding Provider: ${config_service_1.configService.EMBEDDING_PROVIDER}`);
break;
case 'switch': {
if (args.length < 2) {
console.error('Error: Missing model name argument. E.g., "llama3.1:8b" or "deepseek-coder"');
process.exit(1);
}
const modelName = args[1]; // Keep original casing, switchSuggestionModel will normalize
console.log(`Switching to suggestion model: ${modelName}...`);
const success = await (0, llm_provider_1.switchSuggestionModel)(modelName);
if (success) {
console.log(`Successfully switched to suggestion model: ${config_service_1.configService.SUGGESTION_MODEL} (Provider: ${config_service_1.configService.SUGGESTION_PROVIDER}).`);
console.log(`To make this change permanent, set the SUGGESTION_MODEL environment variable to '${config_service_1.configService.SUGGESTION_MODEL}' or update ~/.codecompass/model-config.json.`);
}
else {
console.error(`Failed to switch to model ${modelName}. Check the logs for details.`);
process.exit(1);
}
break;
}
case 'test': {
console.log(`Testing ${config_service_1.configService.LLM_PROVIDER} provider connection...`);
const llmProvider = await (0, llm_provider_1.getLLMProvider)();
const available = await llmProvider.checkConnection();
if (available) {
console.log(`${config_service_1.configService.LLM_PROVIDER} provider is available and working correctly.`);
}
else {
console.error(`${config_service_1.configService.LLM_PROVIDER} provider is not available. Check your configuration.`);
process.exit(1);
}
break;
}
default:
console.error(`Unknown command: ${command}`);
console.log('Use --help to see available commands');
process.exit(1);
}
}
main().catch((error) => {
if (error instanceof Error) {
console.error('Error:', error.message);
}
else {
console.error('An unknown error occurred:', error);
}
process.exit(1);
});