ai-debug-local-mcp
Version:
🎯 ENHANCED AI GUIDANCE v4.1.2: Dramatically improved tool descriptions help AI users choose the right tools instead of 'close enough' options. Ultra-fast keyboard automation (10x speed), universal recording, multi-ecosystem debugging support, and compreh
187 lines • 6.16 kB
JavaScript
/**
* Python backend debugging formatter utilities
* Provides consistent formatting for Python debugging output
*/
export function formatKeyValue(key, value) {
return `**${key}**: ${value}`;
}
export function formatSection(title, items) {
if (!items || items.length === 0)
return [];
return [title, '', ...items, ''];
}
export function formatList(items) {
return items.map(item => `- ${item}`);
}
export function formatRecommendations(recommendations) {
if (!recommendations || recommendations.length === 0)
return [];
return [
'**💡 Recommendations:**',
'',
...recommendations.map(rec => `- ${rec}`),
''
];
}
export function formatTestResults(results) {
const sections = [];
if (results.passed > 0) {
sections.push(`✅ **Passed**: ${results.passed} tests`);
}
if (results.failed > 0) {
sections.push(`❌ **Failed**: ${results.failed} tests`);
}
if (results.skipped > 0) {
sections.push(`⏭️ **Skipped**: ${results.skipped} tests`);
}
if (results.errors > 0) {
sections.push(`⚠️ **Errors**: ${results.errors} tests`);
}
return sections;
}
export function formatPythonError(error) {
const sections = [];
if (error.type) {
sections.push(`**Error Type**: ${error.type}`);
}
if (error.message) {
sections.push(`**Message**: ${error.message}`);
}
if (error.file && error.line) {
sections.push(`**Location**: ${error.file}:${error.line}`);
}
if (error.traceback) {
sections.push('**Traceback**:');
sections.push('```python');
sections.push(error.traceback);
sections.push('```');
}
return sections;
}
export function formatPydanticValidation(validation) {
const sections = [];
if (validation.field) {
sections.push(`**Field**: ${validation.field}`);
}
if (validation.expectedType) {
sections.push(`**Expected Type**: ${validation.expectedType}`);
}
if (validation.actualType) {
sections.push(`**Actual Type**: ${validation.actualType}`);
}
if (validation.constraints) {
sections.push(`**Constraints**: ${validation.constraints.join(', ')}`);
}
return sections;
}
export function formatDatabaseSchema(schema) {
const sections = [];
if (schema.tableName) {
sections.push(`**Table**: ${schema.tableName}`);
}
if (schema.columns) {
sections.push('**Columns**:');
schema.columns.forEach((col) => {
sections.push(`- ${col.name}: ${col.type}${col.nullable ? ' (nullable)' : ''}`);
});
}
if (schema.indexes) {
sections.push('**Indexes**:');
schema.indexes.forEach((idx) => {
sections.push(`- ${idx.name}: ${idx.columns.join(', ')}`);
});
}
if (schema.foreignKeys) {
sections.push('**Foreign Keys**:');
schema.foreignKeys.forEach((fk) => {
sections.push(`- ${fk.column} → ${fk.referencedTable}.${fk.referencedColumn}`);
});
}
return sections;
}
export function formatApiEndpoint(endpoint) {
const sections = [];
if (endpoint.method && endpoint.path) {
sections.push(`**${endpoint.method.toUpperCase()}** ${endpoint.path}`);
}
if (endpoint.parameters) {
sections.push('**Parameters**:');
endpoint.parameters.forEach((param) => {
sections.push(`- ${param.name}: ${param.type}${param.required ? ' (required)' : ''}`);
});
}
if (endpoint.requestSchema) {
sections.push('**Request Schema**:');
sections.push('```json');
sections.push(JSON.stringify(endpoint.requestSchema, null, 2));
sections.push('```');
}
if (endpoint.responseSchema) {
sections.push('**Response Schema**:');
sections.push('```json');
sections.push(JSON.stringify(endpoint.responseSchema, null, 2));
sections.push('```');
}
return sections;
}
export function formatCodeAnalysis(analysis) {
const sections = [];
if (analysis.complexity) {
sections.push(`**Complexity Score**: ${analysis.complexity}/10`);
}
if (analysis.linesOfCode) {
sections.push(`**Lines of Code**: ${analysis.linesOfCode}`);
}
if (analysis.functions) {
sections.push(`**Functions**: ${analysis.functions.length}`);
if (analysis.functions.length > 0) {
analysis.functions.forEach((fn) => {
sections.push(`- ${fn.name}(): ${fn.complexity} complexity`);
});
}
}
if (analysis.classes) {
sections.push(`**Classes**: ${analysis.classes.length}`);
if (analysis.classes.length > 0) {
analysis.classes.forEach((cls) => {
sections.push(`- ${cls.name}: ${cls.methods.length} methods`);
});
}
}
if (analysis.issues) {
sections.push('**Potential Issues**:');
analysis.issues.forEach((issue) => {
sections.push(`- ${issue.severity}: ${issue.description} (Line ${issue.line})`);
});
}
return sections;
}
export function formatDependencyAnalysis(deps) {
const sections = [];
if (deps.installed) {
sections.push('**Installed Packages**:');
deps.installed.forEach((pkg) => {
sections.push(`- ${pkg.name}: ${pkg.version}`);
});
}
if (deps.missing) {
sections.push('**Missing Dependencies**:');
deps.missing.forEach((pkg) => {
sections.push(`- ${pkg}`);
});
}
if (deps.outdated) {
sections.push('**Outdated Packages**:');
deps.outdated.forEach((pkg) => {
sections.push(`- ${pkg.name}: ${pkg.current} → ${pkg.latest}`);
});
}
if (deps.conflicts) {
sections.push('**Version Conflicts**:');
deps.conflicts.forEach((conflict) => {
sections.push(`- ${conflict.package}: Required ${conflict.required}, installed ${conflict.installed}`);
});
}
return sections;
}
//# sourceMappingURL=python-formatter-utils.js.map