Skip to content

#1 Persistent memory for AI coding agents based on real-world benchmarks

fix: address review findings on DX improvements

Rohit Ghumare4c1184b185f8
diff --git a/README.md b/README.md
index f90e8bdc..eb3dfa22 100644
--- a/README.md
+++ b/README.md
@@ -310,7 +310,7 @@ Once hooks are installed, memory builds silently. No action needed — just use
### Session 1: Your agent works as usual
-```
+```text
You: "Add JWT auth to the Express API"
Agent: reads files, writes code, runs tests, fixes errors
```
@@ -332,7 +332,7 @@ agentmemory captures every tool use via PostToolUse hooks. At session end, 47 ra
You start a new session. Before the agent responds, the SessionStart hook fires and injects context (~1,900 tokens):
-```
+```text
Agent already knows:
- Auth uses jose JWT middleware in src/middleware/auth.ts
- Tests in test/auth.test.ts cover token validation
diff --git a/src/cli.ts b/src/cli.ts
index 2fc68ae7..aa3b8251 100644
--- a/src/cli.ts
+++ b/src/cli.ts
@@ -266,7 +266,7 @@ async function runStatus() {
const h = healthRes?.health;
const status = healthRes?.status || "unknown";
const version = healthRes?.version || "?";
- const sessions = Array.isArray(sessionsRes) ? sessionsRes.length : 0;
+ const sessions = Array.isArray(sessionsRes?.sessions) ? sessionsRes.sessions.length : 0;
const memories = h?.workers?.[0]?.function_count || 0;
const nodes = graphRes?.nodes || 0;
const edges = graphRes?.edges || 0;
diff --git a/src/viewer/index.html b/src/viewer/index.html
index 4e6d5bd5..9a20ca27 100644
--- a/src/viewer/index.html
+++ b/src/viewer/index.html
@@ -814,16 +814,18 @@
if (dateEl) dateEl.textContent = new Date().toLocaleDateString('en-US', { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric' });
function isDarkMode() { return document.documentElement.dataset.theme === 'dark'; }
- function applyTheme(dark) {
+ function applyTheme(dark, persist) {
document.documentElement.dataset.theme = dark ? 'dark' : 'light';
var btn = document.getElementById('theme-toggle');
if (btn) btn.textContent = dark ? 'LIGHT' : 'DARK';
- localStorage.setItem('agentmemory-theme', dark ? 'dark' : 'light');
+ if (persist) localStorage.setItem('agentmemory-theme', dark ? 'dark' : 'light');
}
- window.toggleTheme = function() { applyTheme(!isDarkMode()); };
+ window.toggleTheme = function() { applyTheme(!isDarkMode(), true); };
var savedTheme = localStorage.getItem('agentmemory-theme');
- if (savedTheme === 'dark' || (!savedTheme && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
- applyTheme(true);
+ if (savedTheme) {
+ applyTheme(savedTheme === 'dark', false);
+ } else if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
+ applyTheme(true, false);
}
var NODE_COLORS = {
@@ -1019,11 +1021,12 @@
html += '<div class="sub">' + (cb.failures || 0) + ' failures</div></div>';
}
var totalObs = d.sessions.reduce(function(a, s) { return a + (s.observationCount || 0); }, 0);
+ var tokenBudget = parseInt(new URLSearchParams(window.location.search).get('tokenBudget') || '2000', 10) || 2000;
var estFull = totalObs * 80;
- var estInjected = d.sessions.length * 2000;
+ var estInjected = d.sessions.length * tokenBudget;
var savings = estFull > 0 ? Math.round((1 - estInjected / Math.max(estFull, 1)) * 100) : 0;
if (savings < 0) savings = 0;
- html += '<div class="stat-card"><div class="label">Token Savings</div><div class="value">' + savings + '%</div><div class="sub">~' + estInjected.toLocaleString() + ' vs ~' + estFull.toLocaleString() + ' full</div></div>';
+ html += '<div class="stat-card"><div class="label">Token Savings</div><div class="value">' + savings + '%</div><div class="sub">~' + estInjected.toLocaleString() + ' vs ~' + estFull.toLocaleString() + ' full (budget: ' + tokenBudget + ')</div></div>';
html += '</div>';
if (snap.memory || snap.cpu) {