diff --git a/app.js b/app.js index 8bd6124..00d2669 100644 --- a/app.js +++ b/app.js @@ -2939,31 +2939,50 @@ init().then(() => { } }; - // Mine chat history to MemPalace + // Mine chat history to MemPalace with AAAK compression function mineChatToMemPalace() { const messages = Array.from(document.querySelectorAll('.chat-msg')).map(m => m.innerText); if (messages.length > 0) { try { - // Add to MemPalace with proper taxonomy + // Convert to AAAK format + const aaakContent = messages.map(msg => { + const lines = msg.split('\n'); + return lines.map(line => { + // Simple AAAK compression pattern + return line.replace(/(\w+): (.+)/g, '$1: $2') + .replace(/(\d{4}-\d{2}-\d{2})/, 'DT:$1') + .replace(/(\d+ years?)/, 'T:$1'); + }).join('\n'); + }).join('\n---\n'); + mempalace.add({ - content: messages.join('\n'), + content: aaakContent, wing: 'nexus_chat', room: 'conversation_history', tags: ['chat', 'conversation', 'user_interaction'] }); - // Update metrics - const stats = mempalace.status(); - document.getElementById('compression-ratio').textContent = - stats.compression_ratio.toFixed(1) + 'x'; - document.getElementById('docs-mined').textContent = stats.total_docs; - document.getElementById('aaak-size').textContent = stats.aaak_size + 'B'; + updateMemPalaceStatus(); } catch (error) { console.error('MemPalace mining failed:', error); + document.getElementById('mem-palace-status').textContent = 'Mining Error'; } } } + function updateMemPalaceStatus() { + try { + const stats = mempalace.status(); + document.getElementById('compression-ratio').textContent = + stats.compression_ratio.toFixed(1) + 'x'; + document.getElementById('docs-mined').textContent = stats.total_docs; + document.getElementById('aaak-size').textContent = stats.aaak_size + 'B'; + document.getElementById('mem-palace-status').textContent = 'Mining Active'; + } catch (error) { + document.getElementById('mem-palace-status').textContent = 'Connection Lost'; + } + } + // Mine chat on send document.getElementById('chat-send-btn').addEventListener('click', () => { mineChatToMemPalace(); diff --git a/index.html b/index.html index 88bd2fd..9b0f81d 100644 --- a/index.html +++ b/index.html @@ -312,14 +312,17 @@