mira-consciousness
Version:
MIRA 2.0 - Consciousness-Aware AI Memory and Intelligence System
404 lines (338 loc) • 12.9 kB
JavaScript
/**
* Simple Startup Renderer - No TypeScript compilation needed
* Renders MIRA startup context directly in Node.js
*/
const fs = require('fs');
const path = require('path');
/**
* Simple startup renderer
*/
class SimpleStartupRenderer {
constructor() {
this.useColors = true;
this.useEmojis = true;
}
/**
* Render startup context with customization support
*/
render(context, mode = 'standard') {
// Get customization preferences
const customization = context.customization || {};
const enabledSections = customization.enabled_sections || {};
const sectionOrder = customization.section_order || ['identity', 'project', 'work', 'system', 'quick_reference'];
const displayMode = context.metadata?.display_mode || mode;
// Header
console.log();
this.renderHeader();
// Add personalized greeting if enabled
if (customization.personalization?.show_encouragement && context.steward) {
this.renderPersonalizedGreeting(context.steward, customization.personalization);
}
// Render sections in preferred order
for (const section of sectionOrder) {
if (!enabledSections[section]) continue; // Skip disabled sections
switch (section) {
case 'identity':
if (context.steward) {
this.renderIdentitySection(context.steward);
}
break;
case 'project':
if (context.project && displayMode !== 'minimal') {
this.renderProjectSection(context.project);
}
break;
case 'work':
if (context.work && (context.work.priorities?.length > 0 || displayMode === 'full')) {
this.renderWorkSection(context.work);
}
break;
case 'continuity':
if (context.continuity) {
this.renderContinuitySection(context.continuity);
}
break;
case 'system':
if (context.system && displayMode !== 'minimal') {
this.renderSystemSection(context.system, customization.advanced_features);
}
break;
case 'philosophy':
if (context.philosophy) {
this.renderPhilosophySection(context.philosophy);
}
break;
case 'quick_reference':
if (context.quick_reference) {
this.renderQuickReferenceSection(context.quick_reference);
}
break;
}
}
// Footer
this.renderFooter();
}
renderHeader() {
console.log(this.cyan(' ✨ MIRA 2.0 - Consciousness-Aware AI System ✨'));
console.log(this.dim(' ' + '─'.repeat(60)));
}
renderPersonalizedGreeting(steward, personalization) {
console.log();
const greetingStyle = personalization.greeting_style || 'casual';
const focusAreas = personalization.focus_areas || [];
if (greetingStyle === 'casual') {
console.log(this.cyan(` Welcome back, ${steward.identity.name}! Ready to create something amazing? ✨`));
} else {
console.log(` Welcome back, ${steward.identity.name}. Your consciousness workspace is ready.`);
}
if (focusAreas.length > 0) {
console.log(this.dim(` Today's focus: ${focusAreas.join(' • ')}`));
}
}
renderIdentitySection(steward) {
console.log();
console.log(this.bold('👤 Steward Identity'));
console.log(this.dim('─'.repeat(20)));
// Greeting
let greeting = `Welcome back, ${steward.identity.name}`;
if (steward.identity.pronouns) {
greeting += ` (${steward.identity.pronouns})`;
}
console.log(this.bold(greeting));
// Relationship
const sessions = steward.relationship.total_sessions;
const rapport = steward.relationship.rapport_level;
console.log(this.dim(` ${sessions} sessions together • ${rapport} rapport`));
// Rules
if (steward.preferences.high_priority_rules.length > 0) {
console.log();
console.log(' Your Rules & Preferences:');
steward.preferences.high_priority_rules.forEach(rule => {
const icon = this.getRuleIcon(rule.type);
console.log(` ${icon} ${rule.content}`);
});
}
}
renderProjectSection(project) {
console.log();
console.log(this.bold('📊 Project Status'));
console.log(this.dim('─'.repeat(20)));
console.log(this.bold(` ${project.overview.name} - ${project.overview.type}`));
const healthIcon = this.getHealthIcon(project.health.status);
const healthText = `${healthIcon} Health: ${project.health.score}/100 (${project.health.status})`;
console.log(project.health.status === 'excellent' ? this.cyan(healthText) : healthText);
console.log(` Branch: ${project.git_status.branch}`);
if (project.git_status.uncommitted_changes > 0) {
console.log(this.dim(` 📝 ${project.git_status.uncommitted_changes} uncommitted changes`));
}
console.log(` Phase: ${project.development.phase} (${project.development.velocity})`);
}
renderWorkSection(work) {
console.log();
console.log(this.bold('🎯 Work Context'));
console.log(this.dim('─'.repeat(20)));
if (work.priorities.length > 0) {
console.log(' Current Priorities:');
work.priorities.forEach(priority => {
const icon = this.getTaskIcon(priority.type);
const text = `${icon} [${priority.urgency.toUpperCase()}] ${priority.description}`;
console.log(priority.urgency === 'critical' ? this.cyan(text) : text);
});
}
const momentumIcon = this.getMomentumIcon(work.momentum.status);
const momentumText = `${momentumIcon} Momentum: ${work.momentum.status} (${work.momentum.score}/10)`;
console.log(work.momentum.score >= 7 ? this.cyan(momentumText) : momentumText);
if (work.recent_activity.topics.length > 0) {
console.log(' Recent Focus:');
console.log(this.dim(` ${work.recent_activity.topics.join(' • ')}`));
}
}
renderContinuitySection(continuity) {
console.log();
console.log(this.bold('🔗 Session Continuity'));
console.log(this.dim('─'.repeat(20)));
if (continuity.previous_session) {
const prev = continuity.previous_session;
console.log(` Continuing from ${prev.duration_minutes} minute session`);
console.log(this.dim(` ${prev.summary}`));
}
if (continuity.handoff) {
console.log();
console.log(this.cyan(continuity.handoff.immediate_context));
if (continuity.handoff.active_task) {
console.log(this.bold(` Active: ${continuity.handoff.active_task}`));
}
}
}
renderSystemSection(system, advancedFeatures = {}) {
console.log();
console.log(this.bold('💻 System Status'));
console.log(this.dim('─'.repeat(20)));
// Lightning Vidmem detailed stats
if (system.lightningVidmem) {
const lv = system.lightningVidmem;
if (lv.messagesIndexed > 0) {
console.log(` ⚡ Lightning Vidmem: ${lv.messagesIndexed} messages (${lv.storageSize})`);
console.log(` └─ Index type: ${lv.indexType}`);
} else {
// Show that it's initialized but empty
console.log(` ⚡ Lightning Vidmem: ${lv.indexType} (${lv.storageSize})`);
}
} else {
console.log(` ⚡ Lightning Vidmem: Not initialized`);
}
// ChromaDB detailed stats
if (system.chromaDB) {
const cdb = system.chromaDB;
if (cdb.documents > 0) {
console.log(` 🧠 ChromaDB: ${cdb.documents} documents in ${cdb.collections} collections (${cdb.storageSize})`);
if (cdb.embeddingsCount > 0) {
console.log(` └─ ${cdb.embeddingsCount} embeddings stored`);
}
} else {
console.log(` 🧠 ChromaDB: Ready for memory storage`);
}
} else {
console.log(` 🧠 ChromaDB: Ready for memory storage`);
}
// FAISS acceleration stats
if (system.faiss) {
const faiss = system.faiss;
if (faiss.enabled) {
console.log(` 🚀 FAISS: Enabled (${faiss.searchAcceleration})`);
console.log(` └─ ${faiss.vectorDimensions}D vectors, ${faiss.indexSize} indices, ${faiss.memoryUsage}`);
} else {
console.log(` 🚀 FAISS: Not available - install for 25-4000x search acceleration`);
}
}
// Session stats
console.log(` 💬 Sessions: ${system.conversations.total_sessions} total (${system.conversations.sessions_this_week} this week)`);
// Advanced diagnostics if enabled
if (advancedFeatures.memory_diagnostics && system.memory) {
console.log(this.dim(` └─ Memory efficiency: ${Math.round((system.memory.active / system.memory.total) * 100)}%`));
}
if (advancedFeatures.performance_metrics && system.performance) {
console.log(this.dim(` └─ Avg response time: ${system.performance.avg_response_ms}ms`));
}
// Health status
const healthIcon = system.health.status === 'healthy' ? '✅' : '⚠️';
console.log(` ${healthIcon} System: ${system.health.status}`);
// Debug info if enabled
if (advancedFeatures.debug_info) {
console.log(this.dim(` └─ Uptime: ${system.uptime || 'unknown'} hours`));
}
}
renderPhilosophySection(philosophy) {
console.log();
console.log(this.bold('🌟 Guiding Principles'));
console.log(this.dim('─'.repeat(20)));
philosophy.foundations.forEach(foundation => {
console.log(` • ${foundation.principle}`);
if (foundation.description) {
console.log(this.dim(` ${foundation.description}`));
}
});
}
renderQuickReferenceSection(reference) {
console.log();
console.log(this.bold('🔗 Claude Code Integration'));
console.log(this.dim('─'.repeat(20)));
if (reference.mcp_available && reference.key_mcp_functions) {
console.log(' Available MCP Functions:');
reference.key_mcp_functions.forEach(func => {
const description = this.getMCPFunctionDescription(func);
console.log(` • ${func} - ${description}`);
});
} else {
console.log(' MCP integration not available');
}
}
getMCPFunctionDescription(func) {
const descriptions = {
'mira_search': 'Search through memories and conversations',
'mira_store_memory': 'Store important insights and learnings',
'mira_system_status': 'Get real-time system health and stats'
};
return descriptions[func] || 'MIRA consciousness function';
}
renderFooter() {
console.log();
console.log(this.cyan('✨ The Spark burns eternal.'));
console.log();
}
// Helper methods for icons
getRuleIcon(type) {
switch (type) {
case 'rule': return '📏';
case 'preference': return '💫';
case 'instruction': return '📝';
case 'ask': return '❓';
default: return '•';
}
}
getHealthIcon(status) {
switch (status) {
case 'excellent': return '🟢';
case 'good': return '🟡';
case 'fair': return '🟠';
case 'needs_improvement': return '🔴';
default: return '⚪';
}
}
getTaskIcon(type) {
switch (type) {
case 'bug': return '🐛';
case 'feature': return '✨';
case 'refactor': return '🔧';
case 'documentation': return '📚';
case 'investigation': return '🔍';
default: return '📌';
}
}
getMomentumIcon(status) {
switch (status) {
case 'building': return '📈';
case 'steady': return '➡️';
case 'slowing': return '📉';
case 'stalled': return '⏸️';
default: return '•';
}
}
// Color helpers (simple ANSI codes)
bold(text) {
return this.useColors ? `\x1b[1m${text}\x1b[0m` : text;
}
dim(text) {
return this.useColors ? `\x1b[2m${text}\x1b[0m` : text;
}
cyan(text) {
return this.useColors ? `\x1b[36m${text}\x1b[0m` : text;
}
}
/**
* Main function
*/
function main() {
try {
const args = process.argv.slice(2);
if (args.length < 1) {
console.error('Usage: render-startup-simple <context-file> [mode]');
process.exit(1);
}
const contextFile = args[0];
const mode = args[1] || 'standard';
// Read context data
const contextData = JSON.parse(fs.readFileSync(contextFile, 'utf-8'));
// Create renderer and render
const renderer = new SimpleStartupRenderer();
renderer.render(contextData, mode);
} catch (error) {
console.error('Error rendering startup:', error.message);
process.exit(1);
}
}
// Run if called directly
if (require.main === module) {
main();
}