UNPKG

mongodb-claude-setup

Version:

Intelligent MongoDB development ecosystem for Claude Code with modular agent installation

130 lines 5.47 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.uninstallComponents = uninstallComponents; const fs = __importStar(require("fs-extra")); const path = __importStar(require("path")); const chalk_1 = __importDefault(require("chalk")); const ora_1 = __importDefault(require("ora")); const inquirer_1 = __importDefault(require("inquirer")); const environment_1 = require("../utils/environment"); async function uninstallComponents(options) { const spinner = (0, ora_1.default)('Preparing uninstallation...').start(); try { const { claudeCodePath, mcpSettingsPath } = (0, environment_1.getClaudeCodePaths)(); if (!claudeCodePath || !mcpSettingsPath) { throw new Error('Claude Code installation not found'); } spinner.stop(); // Confirm uninstallation const { confirm } = await inquirer_1.default.prompt([ { type: 'confirm', name: 'confirm', message: options.all ? 'Are you sure you want to uninstall ALL MongoDB components? This cannot be undone.' : 'Are you sure you want to uninstall the specified components?', default: false } ]); if (!confirm) { console.log(chalk_1.default.yellow('Uninstallation cancelled.')); return; } const uninstallSpinner = (0, ora_1.default)('Uninstalling components...').start(); if (options.all) { await uninstallAllComponents(claudeCodePath, mcpSettingsPath); uninstallSpinner.succeed('All MongoDB components uninstalled successfully!'); } else if (options.agent) { const agents = options.agent.split(',').map(s => s.trim()); await uninstallAgents(agents, claudeCodePath); uninstallSpinner.succeed(`Uninstalled agents: ${agents.join(', ')}`); } else { uninstallSpinner.info('No components specified for uninstallation'); } console.log(chalk_1.default.blue('\n💡 Tip: Restart Claude Code to apply changes')); } catch (error) { spinner.fail('Uninstallation failed'); throw error; } } async function uninstallAllComponents(claudeCodePath, mcpSettingsPath) { // Remove agents const agentsDir = path.join(claudeCodePath, 'agents'); if (await fs.pathExists(agentsDir)) { const agentFiles = await fs.readdir(agentsDir); const mongoAgents = agentFiles.filter(file => file.startsWith('mongodb-')); for (const agentFile of mongoAgents) { await fs.remove(path.join(agentsDir, agentFile)); } } // Remove commands const commandsDir = path.join(claudeCodePath, 'commands'); if (await fs.pathExists(commandsDir)) { const commandFiles = await fs.readdir(commandsDir); const mongoCommands = commandFiles.filter(file => file.startsWith('mongo-')); for (const commandFile of mongoCommands) { await fs.remove(path.join(commandsDir, commandFile)); } } // Remove MCP servers from settings if (await fs.pathExists(mcpSettingsPath)) { const settings = await fs.readJSON(mcpSettingsPath); // Remove MongoDB-related MCP servers if (settings.mcpServers) { delete settings.mcpServers.mongodb; delete settings.mcpServers.context7; } await fs.writeJSON(mcpSettingsPath, settings, { spaces: 2 }); } } async function uninstallAgents(agentIds, claudeCodePath) { const agentsDir = path.join(claudeCodePath, 'agents'); if (await fs.pathExists(agentsDir)) { for (const agentId of agentIds) { const agentPath = path.join(agentsDir, `${agentId}.md`); if (await fs.pathExists(agentPath)) { await fs.remove(agentPath); } } } } //# sourceMappingURL=uninstaller.js.map