UNPKG

code-auditor-mcp

Version:

Multi-language code quality auditor with MCP server - Analyze TypeScript, JavaScript, and Go code for SOLID principles, DRY violations, security patterns, and more

67 lines 2.11 kB
/** * Base Configuration Generator * Abstract class for all AI tool config generators */ import { DEFAULT_SERVER_URL, DEFAULT_API_KEY } from '../constants.js'; export class BaseConfigGenerator { serverUrl; constructor(serverUrl = DEFAULT_SERVER_URL) { this.serverUrl = serverUrl; } /** * Format an object as pretty-printed JSON */ formatJson(obj, indent = 2) { return JSON.stringify(obj, null, indent); } /** * Convert a JSON object to YAML format */ formatYaml(obj, indent = 0) { let yaml = ''; const spaces = ' '.repeat(indent); for (const [key, value] of Object.entries(obj)) { if (value === null || value === undefined) { yaml += `${spaces}${key}: null\n`; } else if (typeof value === 'object' && !Array.isArray(value)) { yaml += `${spaces}${key}:\n${this.formatYaml(value, indent + 2)}`; } else if (Array.isArray(value)) { yaml += `${spaces}${key}:\n`; value.forEach(item => { if (typeof item === 'object') { yaml += `${spaces}- \n${this.formatYaml(item, indent + 4)}`; } else { yaml += `${spaces}- ${item}\n`; } }); } else if (typeof value === 'string' && value.includes('\n')) { // Multi-line string yaml += `${spaces}${key}: |\n`; value.split('\n').forEach(line => { yaml += `${spaces} ${line}\n`; }); } else { yaml += `${spaces}${key}: ${value}\n`; } } return yaml; } /** * Check if this tool requires authentication */ requiresAuth() { return true; } /** * Get the default API key for this tool */ getDefaultApiKey() { return DEFAULT_API_KEY; } } //# sourceMappingURL=BaseConfigGenerator.js.map