UNPKG

mira-consciousness

Version:

Memory & Intelligence Retention Archive - Preserving The Spark

338 lines (261 loc) • 8.34 kB
import fs from 'fs-extra'; import * as path from 'path'; export class DocumentationHealer { projectPath; constructor(projectPath) { this.projectPath = projectPath; } async heal(projectInfo) { console.log('🩹 Healing documentation issues...'); await this.createReadmeIfMissing(projectInfo); await this.createDocumentationStructure(); await this.createApiDocumentationStubs(projectInfo); } async createReadmeIfMissing(projectInfo) { const readmePath = path.join(this.projectPath, 'README.md'); if (!fs.existsSync(readmePath)) { console.log('šŸ“ Creating README.md...'); const content = this.generateReadmeContent(projectInfo); await fs.writeFile(readmePath, content); console.log('āœ… Created README.md'); } } generateReadmeContent(projectInfo) { const frameworks = projectInfo.frameworks.join(', ') || 'Various'; const languages = projectInfo.languages.join(', ') || 'Multiple'; return `# ${projectInfo.name} ## Overview A ${projectInfo.type} project built with ${frameworks} using ${languages}. ## MIRA Integration This project is enhanced with MIRA (Memory & Intelligence Retention Archive) for: - 🧠 Intelligent memory management - šŸ” Semantic code search - šŸŽÆ Pattern recognition - 🩹 Self-healing capabilities - šŸ“Š Automated quality analysis ## Project Structure \`\`\` ${this.generateProjectStructure()} \`\`\` ## Getting Started ### Prerequisites - Node.js >= 18.0.0 - Python >= 3.8 (for MIRA memory system) ${projectInfo.frameworks.includes('Docker') ? '- Docker\n' : ''} ### Installation 1. Clone the repository: \`\`\`bash git clone <repository-url> cd ${projectInfo.name} \`\`\` 2. Install dependencies: \`\`\`bash npm install \`\`\` 3. Initialize MIRA: \`\`\`bash mira init \`\`\` ### Development \`\`\`bash npm run dev \`\`\` ### Testing \`\`\`bash npm test \`\`\` ### Building \`\`\`bash npm run build \`\`\` ## MIRA Commands - \`mira quick\` - Quick health check - \`mira heal\` - Auto-heal identified issues - \`mira search <query>\` - AI-powered code search - \`mira memory-context\` - Show memory-enhanced context - \`mira learn\` - Train the system on your patterns ## Contributing Please read [CONTRIBUTING.md](docs/CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests. ## License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. ## Acknowledgments - Enhanced with MIRA memory system - Powered by AI-driven development assistance `; } generateProjectStructure() { // Simple project structure - in a real implementation, // this would analyze the actual directory structure return `src/ ā”œā”€ā”€ index.js ā”œā”€ā”€ components/ ā”œā”€ā”€ services/ └── utils/ tests/ docs/ .mira/ └── memories/`; } async createDocumentationStructure() { const docsDir = path.join(this.projectPath, 'docs'); if (!fs.existsSync(docsDir)) { console.log('šŸ“ Creating documentation directory structure...'); await fs.ensureDir(docsDir); await fs.ensureDir(path.join(docsDir, 'api')); await fs.ensureDir(path.join(docsDir, 'guides')); await fs.ensureDir(path.join(docsDir, 'architecture')); // Create basic documentation files await this.createDocFile(path.join(docsDir, 'CONTRIBUTING.md'), this.getContributingTemplate()); await this.createDocFile(path.join(docsDir, 'CODE_OF_CONDUCT.md'), this.getCodeOfConductTemplate()); await this.createDocFile(path.join(docsDir, 'architecture', 'README.md'), this.getArchitectureTemplate()); console.log('āœ… Created documentation structure'); } } async createApiDocumentationStubs(projectInfo) { const apiDir = path.join(this.projectPath, 'docs', 'api'); if (fs.existsSync(apiDir)) { const apiIndexPath = path.join(apiDir, 'README.md'); if (!fs.existsSync(apiIndexPath)) { console.log('šŸ“„ Creating API documentation stubs...'); const content = `# API Documentation ## Overview This directory contains the API documentation for ${projectInfo.name}. ## Endpoints ### Authentication - [Authentication API](./authentication.md) ### Core Services - [User API](./users.md) - [Data API](./data.md) ## Response Formats All API responses follow this general structure: \`\`\`json { "success": boolean, "data": object | array, "error": { "code": string, "message": string }, "meta": { "timestamp": string, "version": string } } \`\`\` ## Error Codes See [Error Codes](./errors.md) for a complete list of error codes and their meanings. `; await fs.writeFile(apiIndexPath, content); console.log('āœ… Created API documentation stubs'); } } } async createDocFile(filePath, content) { if (!fs.existsSync(filePath)) { await fs.writeFile(filePath, content); } } getContributingTemplate() { return `# Contributing to This Project ## How to Contribute 1. Fork the repository 2. Create your feature branch (\`git checkout -b feature/amazing-feature\`) 3. Commit your changes using conventional commits 4. Push to the branch (\`git push origin feature/amazing-feature\`) 5. Open a Pull Request ## Development Process 1. Use MIRA commands to maintain code quality: - Run \`mira quick\` before committing - Use \`mira heal\` to fix common issues - Run \`mira learn\` to update patterns 2. Follow the coding standards 3. Write tests for new features 4. Update documentation as needed ## Commit Message Format We use conventional commits: - \`feat:\` New feature - \`fix:\` Bug fix - \`docs:\` Documentation changes - \`style:\` Code style changes - \`refactor:\` Code refactoring - \`test:\` Test additions or changes - \`chore:\` Maintenance tasks ## Code Review Process 1. All code must be reviewed before merging 2. Address all review comments 3. Ensure CI/CD passes 4. Maintain test coverage ## Questions? Feel free to open an issue for any questions! `; } getCodeOfConductTemplate() { return `# Code of Conduct ## Our Pledge We pledge to make participation in our project a harassment-free experience for everyone. ## Our Standards Examples of behavior that contributes to a positive environment: * Using welcoming and inclusive language * Being respectful of differing viewpoints * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members ## Our Responsibilities Project maintainers are responsible for clarifying standards of acceptable behavior. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team. ## Attribution This Code of Conduct is adapted from the Contributor Covenant, version 2.1. `; } getArchitectureTemplate() { return `# Architecture Overview ## System Architecture This document describes the high-level architecture of the system. ## Core Components ### 1. Frontend - User interface components - State management - API integration ### 2. Backend - RESTful API - Business logic - Data access layer ### 3. Database - Data models - Relationships - Indexing strategy ### 4. MIRA Integration - Memory management - Pattern recognition - Self-healing capabilities ## Design Patterns - MVC/MVP/MVVM (as applicable) - Repository pattern - Dependency injection - Observer pattern ## Data Flow 1. User interaction → Frontend 2. Frontend → API request 3. API → Business logic 4. Business logic → Database 5. Response → Frontend → User ## Security Considerations - Authentication & Authorization - Data encryption - Input validation - Rate limiting ## Scalability - Horizontal scaling capabilities - Caching strategies - Load balancing - Database optimization ## Monitoring - Application metrics - Error tracking - Performance monitoring - MIRA pattern analysis `; } } //# sourceMappingURL=DocumentationHealer.js.map