UNPKG

csvlod-ai-mcp-server

Version:

CSVLOD-AI MCP Server v3.0 with Quantum Context Intelligence - Revolutionary Context Intelligence Engine and Multimodal Processor for sovereign AI development

180 lines (168 loc) 6.33 kB
import * as fs from 'fs/promises'; import * as path from 'path'; export class CSVLODContext { async initialize(projectPath, type) { const filesCreated = []; // Create both .context and .csvlod directory structures const contextPath = path.join(projectPath, '.context'); const csvlodPath = path.join(projectPath, '.csvlod'); await fs.mkdir(contextPath, { recursive: true }); await fs.mkdir(csvlodPath, { recursive: true }); // Create CSVLOD structure based on type const structure = this.getStructureForType(type); for (const [category, description] of Object.entries(structure)) { const categoryPath = path.join(contextPath, category); await fs.mkdir(categoryPath, { recursive: true }); const readmePath = path.join(categoryPath, 'README.md'); await fs.writeFile(readmePath, this.generateCategoryReadme(category, description)); filesCreated.push(readmePath); } // Create AI-CONTEXT.md const aiContextPath = path.join(csvlodPath, 'AI-CONTEXT.md'); await fs.writeFile(aiContextPath, this.generateAIContext(type)); filesCreated.push(aiContextPath); // Create AGENT-MANIFEST.yaml const manifestPath = path.join(csvlodPath, 'AGENT-MANIFEST.yaml'); await fs.writeFile(manifestPath, this.generateManifest(type)); filesCreated.push(manifestPath); return { summary: `Created ${filesCreated.length} files for ${type} CSVLOD setup`, filesCreated, }; } async analyze(projectPath, options) { const contextPath = path.join(projectPath, '.context'); const aiContextPath = path.join(projectPath, '.csvlod', 'AI-CONTEXT.md'); const manifestPath = path.join(projectPath, '.csvlod', 'AGENT-MANIFEST.yaml'); const strengths = []; const improvements = []; let score = 0; // Check for essential files try { await fs.access(aiContextPath); strengths.push('AI-CONTEXT.md present'); score += 20; } catch { improvements.push('Missing AI-CONTEXT.md - essential for AI orientation'); } try { await fs.access(manifestPath); strengths.push('AGENT-MANIFEST.yaml present'); score += 20; } catch { improvements.push('Missing AGENT-MANIFEST.yaml - needed for agent capabilities'); } // Check context structure try { const categories = await fs.readdir(contextPath); const expectedCategories = ['considerations', 'standards', 'visions', 'landscapes', 'outlines', 'designs']; for (const expected of expectedCategories) { if (categories.includes(expected)) { strengths.push(`${expected} category present`); score += 10; } else { improvements.push(`Missing ${expected} category`); } } } catch { improvements.push('Missing .context directory structure'); } const result = { score, strengths, improvements, }; if (options?.includeMetrics) { result.metrics = { contextCoverage: score / 100, documentationQuality: strengths.length / (strengths.length + improvements.length), aiReadiness: score >= 80 ? 1.0 : score / 80, }; } return result; } getStructureForType(type) { const base = { considerations: 'Key principles and guidelines', standards: 'Technical and process standards', visions: 'Future state and goals', }; if (type === 'minimal') return base; const extended = { ...base, landscapes: 'Current state architecture', outlines: 'Implementation roadmaps', designs: 'Detailed technical specifications', }; if (type === 'enterprise') { return { ...extended, governance: 'Governance and compliance', metrics: 'KPIs and measurements', }; } return extended; } generateCategoryReadme(category, description) { return `# ${category.charAt(0).toUpperCase() + category.slice(1)} ${description} ## Purpose This directory contains ${category} artifacts following the CSVLOD-AI Framework principles. ## Contents - Place your ${category} documents here - Use meaningful filenames - Include metadata in front matter ## AI Usage AI agents will scan this directory to understand project ${category}. `; } generateAIContext(type) { return `# AI Context and Instructions ## Project Overview This project implements the CSVLOD-AI Framework for enhanced AI collaboration. ## Framework Type Implementation Type: ${type} ## Core Principles 1. **Context Over Prompts** - Rich context enables AI effectiveness 2. **Structure Enables Creativity** - Organization enhances AI capabilities 3. **Progressive Enhancement** - Start simple, evolve based on needs 4. **AI-Native Design** - Built for AI collaboration from the ground up ## Directory Structure - \`.context/\` - CSVLOD taxonomy implementation - \`.csvlod/AI-CONTEXT.md\` - This file, primary AI orientation - \`.csvlod/AGENT-MANIFEST.yaml\` - Agent capabilities and boundaries ## AI Agent Instructions 1. Always read this context first 2. Respect the CSVLOD structure 3. Maintain documentation currency 4. Follow established patterns `; } generateManifest(type) { return `version: "1.0" name: "CSVLOD-AI Project" description: "AI-native project following CSVLOD-AI Framework" type: "${type}" capabilities: operations: - context_analysis - documentation_generation - code_review - architecture_guidance boundaries: - respect_existing_patterns - maintain_documentation_sync - follow_csvlod_structure metadata: framework: "CSVLOD-AI" framework_version: "1.0.0" initialized: "${new Date().toISOString()}" `; } } //# sourceMappingURL=context.js.map