claude-code-memory-explorer 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/public/app.js +57 -12
- package/public/style.css +39 -0
- package/server.js +32 -0
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -57,7 +57,7 @@ function highlightSource(text, fileName) {
|
|
|
57
57
|
return esc(text);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
function linkifyImports(text,
|
|
60
|
+
function linkifyImports(text, _sourceId) {
|
|
61
61
|
if (!stackData.length) return { text, placeholders: [] };
|
|
62
62
|
const byName = Object.fromEntries(stackData.map((c) => [c.name, c]));
|
|
63
63
|
const placeholders = [];
|
|
@@ -183,14 +183,14 @@ function addRecentProject(p) {
|
|
|
183
183
|
localStorage.setItem('recentProjects', JSON.stringify(recent.slice(0, 10)));
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
function
|
|
186
|
+
function _removeRecentProject(p, e) {
|
|
187
187
|
e.stopPropagation();
|
|
188
188
|
const recent = getRecentProjects().filter((r) => r !== p);
|
|
189
189
|
localStorage.setItem('recentProjects', JSON.stringify(recent));
|
|
190
190
|
renderRecentProjects();
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
function
|
|
193
|
+
function _selectRecentProject(p) {
|
|
194
194
|
document.getElementById('projectPathInput').value = p;
|
|
195
195
|
}
|
|
196
196
|
|
|
@@ -206,9 +206,9 @@ function renderRecentProjects() {
|
|
|
206
206
|
recent
|
|
207
207
|
.map(
|
|
208
208
|
(p) =>
|
|
209
|
-
`<div class="recent-project-item" onclick="
|
|
209
|
+
`<div class="recent-project-item" onclick="_selectRecentProject('${escJs(p)}')">` +
|
|
210
210
|
`<span>${esc(p)}</span>` +
|
|
211
|
-
`<button class="recent-project-remove" onclick="
|
|
211
|
+
`<button class="recent-project-remove" onclick="_removeRecentProject('${escJs(p)}', event)" title="Remove">✕</button>` +
|
|
212
212
|
`</div>`,
|
|
213
213
|
)
|
|
214
214
|
.join('');
|
|
@@ -243,9 +243,10 @@ function bindModalKeys(inputId, modalId, submitFn) {
|
|
|
243
243
|
|
|
244
244
|
// #region RENDER_TREE
|
|
245
245
|
|
|
246
|
-
const SCOPE_ORDER = ['policy', 'user', 'project', 'rule', 'memory'];
|
|
246
|
+
const SCOPE_ORDER = ['policy', 'user', 'user-memory', 'project', 'rule', 'memory'];
|
|
247
247
|
const SCOPE_LABELS = {
|
|
248
248
|
policy: 'Managed Policy',
|
|
249
|
+
'user-memory': 'User Memory',
|
|
249
250
|
user: 'User',
|
|
250
251
|
project: 'Project',
|
|
251
252
|
rule: 'Rules',
|
|
@@ -315,7 +316,7 @@ function renderTree() {
|
|
|
315
316
|
const loadTitle = LOAD_TITLES[item.load] || item.load;
|
|
316
317
|
const meta = `${item.lines}L`;
|
|
317
318
|
const isConditional = item.load === 'conditional' || item.load === 'ondemand';
|
|
318
|
-
const pad = indent ?
|
|
319
|
+
const pad = indent ? ` style="padding-left:${12 + indent * 16}px"` : '';
|
|
319
320
|
let h = `<div class="tree-item${sel}${indent ? ' tree-child' : ''}${isConditional ? ' tree-conditional' : ''}" data-id="${esc(item.id)}" title="${esc(item.path)}" onclick="selectFile('${escJs(item.id)}')"${pad}>`;
|
|
320
321
|
h += `<span class="load-icon" title="${loadTitle}" style="color:var(--scope-${item.scope})">${loadIcon}</span>`;
|
|
321
322
|
h += `<span class="file-name">${esc(item.name)}</span>`;
|
|
@@ -398,6 +399,41 @@ function navigateGroup(direction) {
|
|
|
398
399
|
|
|
399
400
|
// #endregion RENDER_TREE
|
|
400
401
|
|
|
402
|
+
// #region MEMORY_INDEX
|
|
403
|
+
|
|
404
|
+
function parseMemoryIndex(content) {
|
|
405
|
+
const entries = [];
|
|
406
|
+
for (const line of content.split('\n')) {
|
|
407
|
+
const m = line.match(/^\s*-\s*\[([^\]]+)\]\(([^)]+\.md)\)\s*[—–-]\s*(.+)$/);
|
|
408
|
+
if (m) entries.push({ name: m[1], file: m[2], desc: m[3].trim() });
|
|
409
|
+
}
|
|
410
|
+
return entries;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
function renderMemoryIndexTable(entries) {
|
|
414
|
+
const TYPE_COLORS = { feedback: 'rule', user: 'user', project: 'project', reference: 'local' };
|
|
415
|
+
const byName = Object.fromEntries(stackData.map((s) => [s.name, s]));
|
|
416
|
+
let html = '<div class="memory-index">';
|
|
417
|
+
for (const entry of entries) {
|
|
418
|
+
const child = byName[entry.file];
|
|
419
|
+
const typeMatch = entry.file.match(/^([a-z]+)_/);
|
|
420
|
+
const type = typeMatch ? typeMatch[1] : 'memory';
|
|
421
|
+
const scopeColor = TYPE_COLORS[type] || 'memory';
|
|
422
|
+
const nameHtml = child
|
|
423
|
+
? `<a class="import-link" href="#" onclick="selectFile('${escJs(child.id)}');return false" title="${esc(child.path)}">${esc(entry.name)}</a>`
|
|
424
|
+
: `<span class="import-link unresolved" title="Not found: ${esc(entry.file)}">⚠ ${esc(entry.name)}</span>`;
|
|
425
|
+
html += `<div class="memory-index-row">`;
|
|
426
|
+
html += `<span class="scope-badge scope-${scopeColor} memory-index-type">${esc(type)}</span>`;
|
|
427
|
+
html += `<span class="memory-index-name">${nameHtml}</span>`;
|
|
428
|
+
html += `<span class="memory-index-desc">${esc(entry.desc)}</span>`;
|
|
429
|
+
html += `</div>`;
|
|
430
|
+
}
|
|
431
|
+
html += '</div>';
|
|
432
|
+
return html;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// #endregion MEMORY_INDEX
|
|
436
|
+
|
|
401
437
|
// #region RENDER_PREVIEW
|
|
402
438
|
|
|
403
439
|
async function renderPreview() {
|
|
@@ -461,7 +497,16 @@ async function renderPreview() {
|
|
|
461
497
|
const { text: processed, placeholders } = linkifyImports(text, source.id);
|
|
462
498
|
return restorePlaceholders(highlightSource(processed, source.name), placeholders);
|
|
463
499
|
};
|
|
464
|
-
|
|
500
|
+
|
|
501
|
+
// Memory index view — render structured table for MEMORY.md index files
|
|
502
|
+
if ((source.scope === 'memory' || source.scope === 'user-memory') && source.name === 'MEMORY.md') {
|
|
503
|
+
const entries = parseMemoryIndex(content);
|
|
504
|
+
if (entries.length) {
|
|
505
|
+
html += renderMemoryIndexTable(entries);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
if ((source.scope === 'memory' || source.scope === 'user-memory') && source.load === 'startup' && source.maxLines) {
|
|
465
510
|
const lines = content.split('\n');
|
|
466
511
|
const cutoff = source.maxLines;
|
|
467
512
|
if (lines.length > cutoff) {
|
|
@@ -481,8 +526,8 @@ async function renderPreview() {
|
|
|
481
526
|
}
|
|
482
527
|
|
|
483
528
|
function formatBytes(b) {
|
|
484
|
-
if (b < 1024) return b
|
|
485
|
-
return (b / 1024).toFixed(1)
|
|
529
|
+
if (b < 1024) return `${b}B`;
|
|
530
|
+
return `${(b / 1024).toFixed(1)}KB`;
|
|
486
531
|
}
|
|
487
532
|
|
|
488
533
|
async function openInEditor(filePath) {
|
|
@@ -564,7 +609,7 @@ async function loadData() {
|
|
|
564
609
|
renderPreview();
|
|
565
610
|
}
|
|
566
611
|
} catch (err) {
|
|
567
|
-
showToast(
|
|
612
|
+
showToast(`Failed to load: ${err.message}`, 'error');
|
|
568
613
|
}
|
|
569
614
|
}
|
|
570
615
|
|
|
@@ -660,7 +705,7 @@ document.addEventListener('keydown', (e) => {
|
|
|
660
705
|
});
|
|
661
706
|
})();
|
|
662
707
|
|
|
663
|
-
function
|
|
708
|
+
function _hubNavigate(app, url) {
|
|
664
709
|
if (!window.__HUB__?.enabled) return;
|
|
665
710
|
window.parent?.postMessage({ type: 'hub:navigate', app, url }, '*');
|
|
666
711
|
}
|
package/public/style.css
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
--scope-local: #8a9bb5;
|
|
25
25
|
--scope-rule: #a89bc4;
|
|
26
26
|
--scope-memory: #c4a06a;
|
|
27
|
+
--scope-user-memory: #9ab87a;
|
|
27
28
|
--scope-policy: #b58a8a;
|
|
28
29
|
--font-mono: 'IBM Plex Mono', monospace;
|
|
29
30
|
--font-serif: 'Playfair Display', serif;
|
|
@@ -400,6 +401,40 @@ body.light .tree-conditional .file-name {
|
|
|
400
401
|
text-decoration: none;
|
|
401
402
|
opacity: 0.6;
|
|
402
403
|
}
|
|
404
|
+
/* #region MEMORY_INDEX */
|
|
405
|
+
.memory-index {
|
|
406
|
+
padding: 8px 12px;
|
|
407
|
+
border-bottom: 1px solid var(--border);
|
|
408
|
+
display: flex;
|
|
409
|
+
flex-direction: column;
|
|
410
|
+
gap: 4px;
|
|
411
|
+
}
|
|
412
|
+
.memory-index-row {
|
|
413
|
+
display: grid;
|
|
414
|
+
grid-template-columns: 72px 160px 1fr;
|
|
415
|
+
align-items: baseline;
|
|
416
|
+
gap: 8px;
|
|
417
|
+
padding: 3px 0;
|
|
418
|
+
}
|
|
419
|
+
.memory-index-type {
|
|
420
|
+
flex-shrink: 0;
|
|
421
|
+
}
|
|
422
|
+
.memory-index-name {
|
|
423
|
+
font-size: 11px;
|
|
424
|
+
font-family: var(--font-mono);
|
|
425
|
+
white-space: nowrap;
|
|
426
|
+
overflow: hidden;
|
|
427
|
+
text-overflow: ellipsis;
|
|
428
|
+
}
|
|
429
|
+
.memory-index-desc {
|
|
430
|
+
font-size: 10px;
|
|
431
|
+
color: var(--text-muted);
|
|
432
|
+
white-space: nowrap;
|
|
433
|
+
overflow: hidden;
|
|
434
|
+
text-overflow: ellipsis;
|
|
435
|
+
}
|
|
436
|
+
/* #endregion MEMORY_INDEX */
|
|
437
|
+
|
|
403
438
|
.cutoff-line {
|
|
404
439
|
border-top: 2px dashed var(--error);
|
|
405
440
|
margin: 8px 0;
|
|
@@ -449,6 +484,10 @@ body.light .tree-conditional .file-name {
|
|
|
449
484
|
background: rgba(196, 149, 106, 0.18);
|
|
450
485
|
color: var(--scope-memory);
|
|
451
486
|
}
|
|
487
|
+
.scope-user-memory {
|
|
488
|
+
background: rgba(154, 184, 122, 0.18);
|
|
489
|
+
color: var(--scope-user-memory);
|
|
490
|
+
}
|
|
452
491
|
.scope-policy {
|
|
453
492
|
background: rgba(181, 138, 138, 0.18);
|
|
454
493
|
color: var(--scope-policy);
|
package/server.js
CHANGED
|
@@ -332,6 +332,38 @@ function discoverMemorySources(projectPath) {
|
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
334
|
|
|
335
|
+
// 7. User-level memory (~/.claude/memory/)
|
|
336
|
+
const userMemoryDir = path.join(os.homedir(), '.claude', 'memory');
|
|
337
|
+
if (fs.existsSync(userMemoryDir)) {
|
|
338
|
+
const userMemoryMd = path.join(userMemoryDir, 'MEMORY.md');
|
|
339
|
+
const userMemInfo = fileInfo(userMemoryMd);
|
|
340
|
+
if (userMemInfo) {
|
|
341
|
+
sources.push({
|
|
342
|
+
id: 'user-memory-index',
|
|
343
|
+
name: 'MEMORY.md',
|
|
344
|
+
scope: 'user-memory',
|
|
345
|
+
load: 'startup',
|
|
346
|
+
...userMemInfo,
|
|
347
|
+
maxLines: 200,
|
|
348
|
+
maxBytes: 25 * 1024,
|
|
349
|
+
...spreadImports(userMemInfo.path, userMemInfo.content),
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
for (const file of findMdFiles(userMemoryDir)) {
|
|
353
|
+
if (path.basename(file) === 'MEMORY.md') continue;
|
|
354
|
+
const info = fileInfo(file);
|
|
355
|
+
if (!info) continue;
|
|
356
|
+
sources.push({
|
|
357
|
+
id: `user-memory-${path.basename(file, '.md')}`,
|
|
358
|
+
name: path.basename(file),
|
|
359
|
+
scope: 'user-memory',
|
|
360
|
+
load: 'ondemand',
|
|
361
|
+
...info,
|
|
362
|
+
...spreadImports(info.path, info.content),
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
335
367
|
// Resolve imports recursively — add imported files as sources if not already present
|
|
336
368
|
const seen = new Set(sources.map(s => s.path));
|
|
337
369
|
const sourceByPath = Object.fromEntries(sources.map(s => [s.path, s]));
|