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

246 lines (220 loc) 7.94 kB
import * as fs from 'fs/promises'; import * as path from 'path'; export class CSVLODGenerator { async generate(component, targetPath, options) { switch (component) { case 'context': return this.generateContext(targetPath, options); case 'manifest': return this.generateManifest(targetPath, options); case 'prompt': return this.generatePrompt(targetPath, options); case 'structure': return this.generateStructure(targetPath, options); default: throw new Error(`Unknown component type: ${component}`); } } async generateContext(targetPath, options) { const framework = options?.framework || 'generic'; const language = options?.language || 'typescript'; const content = `# AI Context and Instructions ## Project Overview This ${framework} project is built with ${language} following CSVLOD-AI Framework principles. ## Technology Stack - **Framework**: ${framework} - **Language**: ${language} - **Architecture**: CSVLOD-AI compliant - **AI Integration**: ${options?.aiTools ? 'Enabled' : 'Planned'} ## Core Architecture 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 ## Project Structure \`\`\` . ├── .context/ # CSVLOD taxonomy ├── src/ # Source code ├── tests/ # Test files ├── docs/ # Documentation ├── .csvlod/ │ ├── AI-CONTEXT.md # This file │ └── AGENT-MANIFEST.yaml # Agent capabilities \`\`\` ## Development Guidelines - Follow ${framework} best practices - Maintain comprehensive documentation - Write AI-friendly code comments - Keep context files updated ## AI Agent Instructions 1. Always read this context first 2. Respect existing patterns and conventions 3. Maintain documentation synchronization 4. Follow CSVLOD structure for new artifacts 5. Ask for clarification when uncertain `; // Ensure .csvlod directory exists const csvlodPath = path.join(targetPath, '.csvlod'); await fs.mkdir(csvlodPath, { recursive: true }); const outputPath = path.join(csvlodPath, 'AI-CONTEXT.md'); await fs.writeFile(outputPath, content); return { outputPath, preview: content.substring(0, 500) + '...', }; } async generateManifest(targetPath, options) { const framework = options?.framework || 'generic'; const content = `version: "1.0" name: "${path.basename(targetPath)}" description: "AI-native ${framework} project following CSVLOD-AI Framework" metadata: framework: "${framework}" language: "${options?.language || 'typescript'}" csvlod_version: "1.0.0" ai_tools: ${options?.aiTools || false} capabilities: operations: core: - code_generation - code_review - documentation_update - refactoring_suggestions ${framework.toLowerCase()}_specific: - component_generation - testing_assistance - performance_optimization - security_review boundaries: - respect_existing_patterns - maintain_type_safety - follow_framework_conventions - preserve_test_coverage tools: development: - eslint - prettier - typescript ai_specific: - context_validator - prompt_enhancer - documentation_generator workflow: pre_commit: - validate_context - check_documentation_sync post_update: - regenerate_context_index - update_ai_instructions `; // Ensure .csvlod directory exists const csvlodPath = path.join(targetPath, '.csvlod'); await fs.mkdir(csvlodPath, { recursive: true }); const outputPath = path.join(csvlodPath, 'AGENT-MANIFEST.yaml'); await fs.writeFile(outputPath, content); return { outputPath, preview: content.substring(0, 500) + '...', }; } async generatePrompt(targetPath, options) { const promptType = options?.framework || 'setup'; const content = `# CSVLOD-AI ${promptType} Prompt ## Purpose This prompt guides AI agents in ${promptType} operations following CSVLOD-AI Framework principles. ## Context Requirements <context_prerequisites> - .csvlod/AI-CONTEXT.md loaded - .csvlod/AGENT-MANIFEST.yaml parsed - .context/ structure accessible </context_prerequisites> ## Execution Instructions <execution_steps> 1. **Load Context** - Read .csvlod/AI-CONTEXT.md first - Parse .csvlod/AGENT-MANIFEST.yaml for capabilities - Scan .context/ directories 2. **Analyze Current State** - Identify existing patterns - Check documentation currency - Validate structure compliance 3. **Execute ${promptType}** - Follow CSVLOD principles - Maintain consistency - Update documentation 4. **Validate Results** - Check against standards - Ensure documentation sync - Verify AI-readiness </execution_steps> ## Success Criteria - [ ] Context fully understood - [ ] CSVLOD structure maintained - [ ] Documentation updated - [ ] No placeholders remaining - [ ] AI can understand changes ## Example Usage \`\`\` AI: I'll ${promptType} following CSVLOD-AI principles. First, let me load the context... [Reads .csvlod/AI-CONTEXT.md] [Parses .csvlod/AGENT-MANIFEST.yaml] [Executes ${promptType}] \`\`\` `; const outputPath = path.join(targetPath, `csvlod-${promptType}-prompt.md`); await fs.writeFile(outputPath, content); return { outputPath, preview: content.substring(0, 500) + '...', }; } async generateStructure(targetPath, options) { // Create full CSVLOD directory structure const structure = [ '.context/considerations', '.context/standards', '.context/visions', '.context/landscapes', '.context/outlines', '.context/designs', ]; const created = []; for (const dir of structure) { const dirPath = path.join(targetPath, dir); await fs.mkdir(dirPath, { recursive: true }); const readmePath = path.join(dirPath, 'README.md'); const category = path.basename(dir); const content = `# ${category.charAt(0).toUpperCase() + category.slice(1)} This directory contains ${category} artifacts for the project. ## Purpose ${this.getCategoryPurpose(category)} ## Contents - Add your ${category} documents here - Use descriptive filenames - Include metadata in front matter ## AI Usage AI agents will scan this directory to understand project ${category}. `; await fs.writeFile(readmePath, content); created.push(readmePath); } return { outputPath: path.join(targetPath, '.context'), preview: `Created CSVLOD structure with ${created.length} README files`, }; } getCategoryPurpose(category) { const purposes = { considerations: 'High-level principles, constraints, and key decisions that guide the project', standards: 'Technical standards, coding conventions, and quality requirements', visions: 'Future state architecture, goals, and strategic direction', landscapes: 'Current state documentation, existing systems, and dependencies', outlines: 'Implementation plans, roadmaps, and phased approaches', designs: 'Detailed technical specifications, API designs, and component architectures', }; return purposes[category] || 'Project artifacts and documentation'; } } //# sourceMappingURL=generator.js.map