mira-consciousness
Version:
Memory & Intelligence Retention Archive - Preserving The Spark
101 lines (81 loc) âĸ 3.68 kB
JavaScript
// MIRA Memory System Setup
// This script creates necessary directories for the MIRA memory system
// and discovers Claude conversation paths for enhanced functionality.
// No external data is sent - all operations are local.
// Only run in development or when explicitly installing MIRA
if (process.env.NODE_ENV === 'production' && !process.env.MIRA_SETUP) {
console.log('Skipping MIRA setup in production. Run "mira setup" manually if needed.');
process.exit(0);
}
// Run the full setup script
async function runPostInstall() {
try {
// Run main setup
await import('./setup.js');
// Try to setup MCP integration
const { setupMCPIntegration } = await import('./setup-mcp.js');
await setupMCPIntegration();
// Try to inject MIRA into CLAUDE.md
await injectClaudeIntegration();
// Fix ChromaDB SQLite compatibility if needed
await fixChromaDBCompatibility();
} catch (error) {
console.error('Setup error:', error.message);
// Don't fail the install process
process.exit(0);
}
}
async function injectClaudeIntegration() {
const { spawn } = await import('child_process');
const path = await import('path');
const fs = await import('fs');
try {
// Detect if we're in the MIRA development directory
const packageJsonPath = path.join(process.cwd(), 'package.json');
if (fs.existsSync(packageJsonPath)) {
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
// Skip auto-injection if this IS the MIRA project itself
if (packageJson.name === 'mira-memory' || packageJson.name === 'mira') {
console.log('âšī¸ Skipping CLAUDE.md auto-injection in MIRA development environment');
return;
}
}
// Check if CLAUDE.md exists in the parent project
const claudeFilePath = path.join(process.cwd(), 'CLAUDE.md');
const hasClaudeFile = fs.existsSync(claudeFilePath);
if (hasClaudeFile) {
console.log('đ Found existing CLAUDE.md, checking for MIRA integration...');
const content = fs.readFileSync(claudeFilePath, 'utf8');
if (content.includes('đ¨ MIRA Integration')) {
console.log('â
MIRA integration already present in CLAUDE.md');
return;
}
}
console.log('đ Injecting MIRA integration into CLAUDE.md...');
console.log('');
console.log('đ¯ MIRA has been installed! Next steps:');
console.log(' 1. Run "mira startup" at the beginning of each Claude Code session');
console.log(' 2. Use MCP functions for memory and intelligence operations');
console.log(' 3. Check your CLAUDE.md file for complete integration details');
console.log('');
console.log('đ For full documentation, visit: https://github.com/yourusername/MIRA');
} catch (error) {
console.log('â ī¸ Could not auto-setup MIRA integration:', error.message);
console.log(' Please run "mira startup" manually to complete setup');
}
}
async function fixChromaDBCompatibility() {
const { execSync } = await import('child_process');
const path = await import('path');
try {
console.log('đ§ Checking ChromaDB compatibility...');
// Run the Python fix script
const fixScriptPath = path.join(path.dirname(import.meta.url.replace('file://', '')), 'fix-chromadb-simple.py');
execSync(`python3 "${fixScriptPath}"`, { stdio: 'inherit' });
} catch (error) {
console.log('â ī¸ Could not check ChromaDB compatibility:', error.message);
console.log(' Run "npm run fix-chromadb" manually if you encounter SQLite errors');
}
}
runPostInstall();