agent-knowledge 1.1.5 → 1.2.0
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/CHANGELOG.md +37 -0
- package/README.md +46 -1
- package/dist/dashboard.d.ts.map +1 -1
- package/dist/dashboard.js +76 -3
- package/dist/dashboard.js.map +1 -1
- package/dist/knowledge/graph.d.ts +64 -0
- package/dist/knowledge/graph.d.ts.map +1 -0
- package/dist/knowledge/graph.js +213 -0
- package/dist/knowledge/graph.js.map +1 -0
- package/dist/knowledge/scoring.d.ts +57 -0
- package/dist/knowledge/scoring.d.ts.map +1 -0
- package/dist/knowledge/scoring.js +193 -0
- package/dist/knowledge/scoring.js.map +1 -0
- package/dist/knowledge/search.d.ts.map +1 -1
- package/dist/knowledge/search.js +17 -1
- package/dist/knowledge/search.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +172 -5
- package/dist/server.js.map +1 -1
- package/dist/ui/app.js +278 -7
- package/dist/ui/index.html +12 -0
- package/dist/ui/styles.css +170 -0
- package/docs/ARCHITECTURE.md +66 -1
- package/docs/DASHBOARD.md +19 -13
- package/docs/SETUP.md +17 -3
- package/package.json +2 -2
package/dist/ui/app.js
CHANGED
|
@@ -40,6 +40,8 @@
|
|
|
40
40
|
knowledgeGrid: $('knowledge-grid'),
|
|
41
41
|
knowledgeEmpty: $('knowledge-empty'),
|
|
42
42
|
knowledgeCategories: $('knowledge-categories'),
|
|
43
|
+
knowledgeSearchInput: $('knowledge-search-input'),
|
|
44
|
+
knowledgeSearchResults: $('knowledge-search-results'),
|
|
43
45
|
searchInput: $('search-input'),
|
|
44
46
|
searchResults: $('search-results'),
|
|
45
47
|
searchEmpty: $('search-empty'),
|
|
@@ -396,11 +398,17 @@
|
|
|
396
398
|
.join('');
|
|
397
399
|
const time = relativeTime(entry.updated || entry.created);
|
|
398
400
|
|
|
401
|
+
const maturity = entry.maturity || 'candidate';
|
|
402
|
+
const accessCount = entry.access_count || 0;
|
|
403
|
+
|
|
399
404
|
return `<div class="knowledge-card" data-path="${esc(entry.path || entry.id || '')}" tabindex="0" role="button">
|
|
400
|
-
<
|
|
401
|
-
<span class="
|
|
402
|
-
|
|
403
|
-
|
|
405
|
+
<div class="card-header-row">
|
|
406
|
+
<span class="card-category" data-cat="${esc(cat)}">
|
|
407
|
+
<span class="material-symbols-outlined" style="font-size:14px">${icon}</span>
|
|
408
|
+
${esc(cat)}
|
|
409
|
+
</span>
|
|
410
|
+
<span class="maturity-badge" data-maturity="${esc(maturity)}">${esc(maturity)}${accessCount > 0 ? ` <span class="maturity-reads">· ${accessCount} reads</span>` : ''}</span>
|
|
411
|
+
</div>
|
|
404
412
|
${time ? `<span class="card-date">${time}</span>` : ''}
|
|
405
413
|
<div class="card-title">${esc(title)}</div>
|
|
406
414
|
${tags ? `<div class="card-tags">${tags}</div>` : ''}
|
|
@@ -419,15 +427,97 @@
|
|
|
419
427
|
async function openKnowledgePanel(path) {
|
|
420
428
|
if (!path) return;
|
|
421
429
|
try {
|
|
422
|
-
const
|
|
430
|
+
const [entryRes, linksRes] = await Promise.allSettled([
|
|
431
|
+
api(`/knowledge/${encodeURIComponent(path)}`),
|
|
432
|
+
api(`/knowledge/${encodeURIComponent(path)}/links`),
|
|
433
|
+
]);
|
|
434
|
+
const data = entryRes.status === 'fulfilled' ? entryRes.value : {};
|
|
435
|
+
const links = linksRes.status === 'fulfilled' ? linksRes.value : [];
|
|
423
436
|
const title = data.title || data.path || path;
|
|
424
437
|
const content = data.content || data.body || '';
|
|
425
|
-
openPanel('knowledge', { title, content, meta: data });
|
|
438
|
+
openPanel('knowledge', { title, content, meta: data, links, entryPath: path });
|
|
426
439
|
} catch (err) {
|
|
427
440
|
toast(`Failed to load entry: ${err.message}`, 'error');
|
|
428
441
|
}
|
|
429
442
|
}
|
|
430
443
|
|
|
444
|
+
// ── Knowledge Search ───────────────────────────────────────────────────────
|
|
445
|
+
|
|
446
|
+
const doKnowledgeSearch = debounce(async () => {
|
|
447
|
+
const q = (el.knowledgeSearchInput ? el.knowledgeSearchInput.value : '').trim();
|
|
448
|
+
if (!q) {
|
|
449
|
+
el.knowledgeSearchResults.style.display = 'none';
|
|
450
|
+
el.knowledgeGrid.style.display = '';
|
|
451
|
+
el.knowledgeEmpty.classList.add('hidden');
|
|
452
|
+
renderKnowledge();
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
try {
|
|
456
|
+
const params = new URLSearchParams({ q, max_results: '20' });
|
|
457
|
+
const cat = state.knowledge.activeCategory;
|
|
458
|
+
if (cat !== 'all') params.set('category', cat);
|
|
459
|
+
const results = await api(`/knowledge/search?${params}`);
|
|
460
|
+
renderKnowledgeSearchResults(Array.isArray(results) ? results : [], q);
|
|
461
|
+
} catch (err) {
|
|
462
|
+
toast(`Knowledge search failed: ${err.message}`, 'error');
|
|
463
|
+
}
|
|
464
|
+
}, 300);
|
|
465
|
+
|
|
466
|
+
function renderKnowledgeSearchResults(results, query) {
|
|
467
|
+
if (results.length === 0) {
|
|
468
|
+
el.knowledgeSearchResults.style.display = 'none';
|
|
469
|
+
el.knowledgeGrid.style.display = 'none';
|
|
470
|
+
el.knowledgeEmpty.classList.remove('hidden');
|
|
471
|
+
el.knowledgeEmpty.querySelector('.empty-text').textContent = 'No results found';
|
|
472
|
+
el.knowledgeEmpty.querySelector('.empty-hint').textContent =
|
|
473
|
+
`No knowledge entries match "${query}"`;
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
el.knowledgeEmpty.classList.add('hidden');
|
|
478
|
+
el.knowledgeGrid.style.display = 'none';
|
|
479
|
+
el.knowledgeSearchResults.style.display = '';
|
|
480
|
+
el.knowledgeSearchResults.innerHTML = results
|
|
481
|
+
.map((r) => {
|
|
482
|
+
const title = r.title || r.path || '';
|
|
483
|
+
const excerpt = r.excerpt || '';
|
|
484
|
+
const score = r.score;
|
|
485
|
+
const maturity = r.maturity || 'candidate';
|
|
486
|
+
const accessCount = r.access_count || 0;
|
|
487
|
+
const decayF = r.decay_factor;
|
|
488
|
+
const matMult = r.maturity_multiplier;
|
|
489
|
+
const path = r.path || '';
|
|
490
|
+
|
|
491
|
+
let scoreBreakdown = '';
|
|
492
|
+
if (score != null) {
|
|
493
|
+
const parts = [];
|
|
494
|
+
parts.push(`relevance: ${score.toFixed(2)}`);
|
|
495
|
+
if (decayF != null) parts.push(`decay: ${decayF.toFixed(2)}`);
|
|
496
|
+
if (matMult != null) parts.push(`maturity: x${matMult.toFixed(1)}`);
|
|
497
|
+
const finalScore = score * (decayF || 1) * (matMult || 1);
|
|
498
|
+
scoreBreakdown = `<div class="score-breakdown">Score: ${finalScore.toFixed(2)} (${parts.join(' \u00d7 ')})</div>`;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
return `<div class="result-item knowledge-result-item" data-path="${esc(path)}" tabindex="0" role="button">
|
|
502
|
+
<div class="result-meta">
|
|
503
|
+
<span class="maturity-badge" data-maturity="${esc(maturity)}">${esc(maturity)}${accessCount > 0 ? ` <span class="maturity-reads">· ${accessCount} reads</span>` : ''}</span>
|
|
504
|
+
<span class="result-entry-title">${esc(title)}</span>
|
|
505
|
+
${score != null ? `<span class="score-container">${formatScore(score, {})}</span>` : ''}
|
|
506
|
+
</div>
|
|
507
|
+
<div class="result-excerpt">${highlightExcerpt(excerpt, query)}</div>
|
|
508
|
+
${scoreBreakdown}
|
|
509
|
+
</div>`;
|
|
510
|
+
})
|
|
511
|
+
.join('');
|
|
512
|
+
|
|
513
|
+
el.knowledgeSearchResults.querySelectorAll('.knowledge-result-item').forEach((card) => {
|
|
514
|
+
card.addEventListener('click', () => openKnowledgePanel(card.dataset.path));
|
|
515
|
+
card.addEventListener('keydown', (e) => {
|
|
516
|
+
if (e.key === 'Enter') openKnowledgePanel(card.dataset.path);
|
|
517
|
+
});
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
|
|
431
521
|
// ── Search ─────────────────────────────────────────────────────────────────
|
|
432
522
|
|
|
433
523
|
const doSearch = debounce(async () => {
|
|
@@ -720,17 +810,52 @@
|
|
|
720
810
|
const category = entry.category || meta.category || '';
|
|
721
811
|
const tags = entry.tags || meta.tags || [];
|
|
722
812
|
const updated = entry.updated || meta.updated || '';
|
|
813
|
+
const maturity = meta.maturity || 'candidate';
|
|
814
|
+
const accessCount = meta.access_count || 0;
|
|
723
815
|
|
|
724
816
|
let metaHtml = '<div class="panel-meta">';
|
|
725
817
|
if (category)
|
|
726
818
|
metaHtml += `<span class="card-category" data-cat="${esc(category)}">${esc(category)}</span>`;
|
|
819
|
+
metaHtml += `<span class="maturity-badge" data-maturity="${esc(maturity)}">${esc(maturity)}${accessCount > 0 ? ` <span class="maturity-reads">· ${accessCount} reads</span>` : ''}</span>`;
|
|
727
820
|
if (tags.length)
|
|
728
821
|
metaHtml += tags.map((t) => `<span class="card-tag">${esc(t)}</span>`).join('');
|
|
729
822
|
if (updated) metaHtml += `<span class="panel-meta-date">${esc(updated)}</span>`;
|
|
730
823
|
metaHtml += '</div>';
|
|
731
824
|
|
|
732
825
|
const body = stripFrontmatter(data.content);
|
|
733
|
-
|
|
826
|
+
let html = metaHtml + `<div class="prose">${renderMd(body)}</div>`;
|
|
827
|
+
|
|
828
|
+
// Related entries section
|
|
829
|
+
const links = data.links || [];
|
|
830
|
+
if (links.length > 0) {
|
|
831
|
+
const entryPath = data.entryPath || '';
|
|
832
|
+
html += '<div class="panel-section related-section">';
|
|
833
|
+
html +=
|
|
834
|
+
'<h4 class="panel-section-title"><span class="material-symbols-outlined" style="font-size:16px;vertical-align:middle;margin-right:4px">hub</span>Related</h4>';
|
|
835
|
+
html += '<div class="related-entries">';
|
|
836
|
+
links.forEach((link) => {
|
|
837
|
+
const linkedPath = link.source === entryPath ? link.target : link.source;
|
|
838
|
+
const relType = link.rel_type || 'related_to';
|
|
839
|
+
const strength = link.strength != null ? link.strength : 0.5;
|
|
840
|
+
const linkedTitle = linkedPath.split('/').pop().replace(/\.md$/, '').replace(/[-_]/g, ' ');
|
|
841
|
+
html += `<div class="related-entry" data-path="${esc(linkedPath)}" tabindex="0" role="button">
|
|
842
|
+
<span class="rel-type-pill" data-rel="${esc(relType)}">${esc(relType.replace(/_/g, ' '))}</span>
|
|
843
|
+
<span class="related-entry-title">${esc(linkedTitle)}</span>
|
|
844
|
+
<span class="related-entry-strength" title="Strength: ${strength.toFixed(2)}">${(strength * 100).toFixed(0)}%</span>
|
|
845
|
+
</div>`;
|
|
846
|
+
});
|
|
847
|
+
html += '</div></div>';
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
el.panelBody.innerHTML = html;
|
|
851
|
+
|
|
852
|
+
// Bind click handlers on related entries
|
|
853
|
+
el.panelBody.querySelectorAll('.related-entry').forEach((entryEl) => {
|
|
854
|
+
entryEl.addEventListener('click', () => openKnowledgePanel(entryEl.dataset.path));
|
|
855
|
+
entryEl.addEventListener('keydown', (e) => {
|
|
856
|
+
if (e.key === 'Enter') openKnowledgePanel(entryEl.dataset.path);
|
|
857
|
+
});
|
|
858
|
+
});
|
|
734
859
|
}
|
|
735
860
|
|
|
736
861
|
function renderSessionPanel(data) {
|
|
@@ -859,6 +984,13 @@
|
|
|
859
984
|
renderKnowledge();
|
|
860
985
|
});
|
|
861
986
|
|
|
987
|
+
// Knowledge search input
|
|
988
|
+
if (el.knowledgeSearchInput) {
|
|
989
|
+
el.knowledgeSearchInput.addEventListener('input', () => {
|
|
990
|
+
doKnowledgeSearch();
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
|
|
862
994
|
// Search input
|
|
863
995
|
el.searchInput.addEventListener('input', () => {
|
|
864
996
|
state.search.query = el.searchInput.value;
|
|
@@ -1006,6 +1138,145 @@
|
|
|
1006
1138
|
});
|
|
1007
1139
|
}
|
|
1008
1140
|
|
|
1141
|
+
// Theme sync from parent (agent-desk) via executeJavaScript
|
|
1142
|
+
window.addEventListener('message', (event) => {
|
|
1143
|
+
if (!event.data || event.data.type !== 'theme-sync') return;
|
|
1144
|
+
const colors = event.data.colors;
|
|
1145
|
+
if (!colors) return;
|
|
1146
|
+
|
|
1147
|
+
// Contrast enforcement: ensure text is readable against background
|
|
1148
|
+
function ensureContrast(bg, fg) {
|
|
1149
|
+
const lum = (hex) => {
|
|
1150
|
+
if (!hex || hex.charAt(0) !== '#' || hex.length < 7) return 0.5;
|
|
1151
|
+
const r = parseInt(hex.slice(1, 3), 16) / 255;
|
|
1152
|
+
const g = parseInt(hex.slice(3, 5), 16) / 255;
|
|
1153
|
+
const b = parseInt(hex.slice(5, 7), 16) / 255;
|
|
1154
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
1155
|
+
};
|
|
1156
|
+
const bgLum = lum(bg);
|
|
1157
|
+
return bgLum < 0.5 ? (lum(fg) < 0.4 ? '#e0e0e0' : fg) : lum(fg) > 0.6 ? '#333333' : fg;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
const root = document.documentElement;
|
|
1161
|
+
const bgColor = colors.bg || null;
|
|
1162
|
+
|
|
1163
|
+
// Core backgrounds
|
|
1164
|
+
if (colors.bg) root.style.setProperty('--bg', colors.bg);
|
|
1165
|
+
if (colors.bgSurface) root.style.setProperty('--bg-surface', colors.bgSurface);
|
|
1166
|
+
if (colors.bgElevated) root.style.setProperty('--bg-elevated', colors.bgElevated);
|
|
1167
|
+
if (colors.bgHover) root.style.setProperty('--bg-hover', colors.bgHover);
|
|
1168
|
+
if (colors.bgInset) root.style.setProperty('--bg-inset', colors.bgInset);
|
|
1169
|
+
|
|
1170
|
+
// Borders
|
|
1171
|
+
if (colors.border) root.style.setProperty('--border', colors.border);
|
|
1172
|
+
if (colors.borderLight) root.style.setProperty('--border-light', colors.borderLight);
|
|
1173
|
+
|
|
1174
|
+
// Text colors (with contrast enforcement)
|
|
1175
|
+
if (colors.text)
|
|
1176
|
+
root.style.setProperty(
|
|
1177
|
+
'--text',
|
|
1178
|
+
bgColor ? ensureContrast(bgColor, colors.text) : colors.text,
|
|
1179
|
+
);
|
|
1180
|
+
if (colors.textSecondary)
|
|
1181
|
+
root.style.setProperty(
|
|
1182
|
+
'--text-secondary',
|
|
1183
|
+
bgColor ? ensureContrast(bgColor, colors.textSecondary) : colors.textSecondary,
|
|
1184
|
+
);
|
|
1185
|
+
if (colors.textMuted)
|
|
1186
|
+
root.style.setProperty(
|
|
1187
|
+
'--text-muted',
|
|
1188
|
+
bgColor ? ensureContrast(bgColor, colors.textMuted) : colors.textMuted,
|
|
1189
|
+
);
|
|
1190
|
+
if (colors.textDim)
|
|
1191
|
+
root.style.setProperty(
|
|
1192
|
+
'--text-dim',
|
|
1193
|
+
bgColor ? ensureContrast(bgColor, colors.textDim) : colors.textDim,
|
|
1194
|
+
);
|
|
1195
|
+
|
|
1196
|
+
// Accent colors
|
|
1197
|
+
if (colors.accent) root.style.setProperty('--accent', colors.accent);
|
|
1198
|
+
if (colors.accentHover) root.style.setProperty('--accent-hover', colors.accentHover);
|
|
1199
|
+
if (colors.accentDim) root.style.setProperty('--accent-dim', colors.accentDim);
|
|
1200
|
+
if (colors.accentSolid) root.style.setProperty('--accent-solid', colors.accentSolid);
|
|
1201
|
+
if (colors.accentGlow) root.style.setProperty('--accent-glow', colors.accentGlow);
|
|
1202
|
+
|
|
1203
|
+
// Semantic colors
|
|
1204
|
+
if (colors.green) root.style.setProperty('--green', colors.green);
|
|
1205
|
+
if (colors.greenDim) root.style.setProperty('--green-dim', colors.greenDim);
|
|
1206
|
+
if (colors.yellow) root.style.setProperty('--yellow', colors.yellow);
|
|
1207
|
+
if (colors.yellowDim) root.style.setProperty('--yellow-dim', colors.yellowDim);
|
|
1208
|
+
if (colors.orange) root.style.setProperty('--orange', colors.orange);
|
|
1209
|
+
if (colors.orangeDim) root.style.setProperty('--orange-dim', colors.orangeDim);
|
|
1210
|
+
if (colors.red) root.style.setProperty('--red', colors.red);
|
|
1211
|
+
if (colors.redDim) root.style.setProperty('--red-dim', colors.redDim);
|
|
1212
|
+
if (colors.purple) root.style.setProperty('--purple', colors.purple);
|
|
1213
|
+
if (colors.purpleDim) root.style.setProperty('--purple-dim', colors.purpleDim);
|
|
1214
|
+
if (colors.blue) root.style.setProperty('--blue', colors.blue);
|
|
1215
|
+
if (colors.blueDim) root.style.setProperty('--blue-dim', colors.blueDim);
|
|
1216
|
+
|
|
1217
|
+
// Focus ring
|
|
1218
|
+
if (colors.focusRing) root.style.setProperty('--focus-ring', colors.focusRing);
|
|
1219
|
+
|
|
1220
|
+
// Shadows (adapt for dark/light)
|
|
1221
|
+
if (colors.isDark !== undefined) {
|
|
1222
|
+
if (colors.isDark) {
|
|
1223
|
+
root.style.setProperty(
|
|
1224
|
+
'--shadow-1',
|
|
1225
|
+
'0px 1px 2px 0px rgba(0,0,0,0.6), 0px 1px 3px 1px rgba(0,0,0,0.3)',
|
|
1226
|
+
);
|
|
1227
|
+
root.style.setProperty(
|
|
1228
|
+
'--shadow-2',
|
|
1229
|
+
'0px 1px 2px 0px rgba(0,0,0,0.6), 0px 2px 6px 2px rgba(0,0,0,0.3)',
|
|
1230
|
+
);
|
|
1231
|
+
root.style.setProperty(
|
|
1232
|
+
'--shadow-3',
|
|
1233
|
+
'0px 1px 3px 0px rgba(0,0,0,0.6), 0px 4px 8px 3px rgba(0,0,0,0.3)',
|
|
1234
|
+
);
|
|
1235
|
+
root.style.setProperty(
|
|
1236
|
+
'--shadow-hover',
|
|
1237
|
+
'0px 2px 4px 0px rgba(0,0,0,0.5), 0px 4px 12px 4px rgba(0,0,0,0.3)',
|
|
1238
|
+
);
|
|
1239
|
+
root.style.setProperty(
|
|
1240
|
+
'--shadow-panel',
|
|
1241
|
+
'-2px 0px 8px 0px rgba(0,0,0,0.6), -4px 0px 16px 2px rgba(0,0,0,0.3)',
|
|
1242
|
+
);
|
|
1243
|
+
} else {
|
|
1244
|
+
root.style.setProperty(
|
|
1245
|
+
'--shadow-1',
|
|
1246
|
+
'0px 1px 2px 0px rgba(0,0,0,0.3), 0px 1px 3px 1px rgba(0,0,0,0.15)',
|
|
1247
|
+
);
|
|
1248
|
+
root.style.setProperty(
|
|
1249
|
+
'--shadow-2',
|
|
1250
|
+
'0px 1px 2px 0px rgba(0,0,0,0.3), 0px 2px 6px 2px rgba(0,0,0,0.15)',
|
|
1251
|
+
);
|
|
1252
|
+
root.style.setProperty(
|
|
1253
|
+
'--shadow-3',
|
|
1254
|
+
'0px 1px 3px 0px rgba(0,0,0,0.3), 0px 4px 8px 3px rgba(0,0,0,0.15)',
|
|
1255
|
+
);
|
|
1256
|
+
root.style.setProperty(
|
|
1257
|
+
'--shadow-hover',
|
|
1258
|
+
'0px 2px 4px 0px rgba(0,0,0,0.25), 0px 4px 12px 4px rgba(0,0,0,0.15)',
|
|
1259
|
+
);
|
|
1260
|
+
root.style.setProperty(
|
|
1261
|
+
'--shadow-panel',
|
|
1262
|
+
'-2px 0px 8px 0px rgba(0,0,0,0.3), -4px 0px 16px 2px rgba(0,0,0,0.15)',
|
|
1263
|
+
);
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
// Apply theme attribute and hide the toggle (agent-desk controls the theme)
|
|
1268
|
+
if (colors.isDark !== undefined) {
|
|
1269
|
+
const theme = colors.isDark ? 'dark' : 'light';
|
|
1270
|
+
document.documentElement.setAttribute('data-theme', theme);
|
|
1271
|
+
localStorage.setItem('agent-knowledge-theme', theme);
|
|
1272
|
+
const icon = el.themeToggle.querySelector('.theme-icon');
|
|
1273
|
+
if (icon) icon.textContent = theme === 'dark' ? 'light_mode' : 'dark_mode';
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
// Hide the local theme toggle — agent-desk controls the theme
|
|
1277
|
+
if (el.themeToggle) el.themeToggle.style.display = 'none';
|
|
1278
|
+
});
|
|
1279
|
+
|
|
1009
1280
|
// Start
|
|
1010
1281
|
if (document.readyState === 'loading') {
|
|
1011
1282
|
document.addEventListener('DOMContentLoaded', () => {
|
package/dist/ui/index.html
CHANGED
|
@@ -140,6 +140,18 @@
|
|
|
140
140
|
<span class="material-symbols-outlined chip-icon">sticky_note_2</span>Notes
|
|
141
141
|
</button>
|
|
142
142
|
</div>
|
|
143
|
+
<div class="search-bar knowledge-search-bar">
|
|
144
|
+
<span class="material-symbols-outlined search-input-icon">search</span>
|
|
145
|
+
<input
|
|
146
|
+
type="search"
|
|
147
|
+
id="knowledge-search-input"
|
|
148
|
+
class="search-input"
|
|
149
|
+
placeholder="Search knowledge entries..."
|
|
150
|
+
autocomplete="off"
|
|
151
|
+
aria-label="Search knowledge entries"
|
|
152
|
+
/>
|
|
153
|
+
</div>
|
|
154
|
+
<div id="knowledge-search-results" class="results-list" style="display: none"></div>
|
|
143
155
|
<div id="knowledge-grid" class="card-grid"></div>
|
|
144
156
|
<div id="knowledge-empty" class="empty-state hidden">
|
|
145
157
|
<span class="material-symbols-outlined empty-icon">folder_off</span>
|
package/dist/ui/styles.css
CHANGED
|
@@ -1493,6 +1493,176 @@ h1 {
|
|
|
1493
1493
|
color: var(--text-secondary);
|
|
1494
1494
|
}
|
|
1495
1495
|
|
|
1496
|
+
/* ── Maturity Badge ───────────────────────────────────────────────────── */
|
|
1497
|
+
.maturity-badge {
|
|
1498
|
+
display: inline-flex;
|
|
1499
|
+
align-items: center;
|
|
1500
|
+
gap: 2px;
|
|
1501
|
+
font-size: 10px;
|
|
1502
|
+
font-weight: 600;
|
|
1503
|
+
padding: 2px 8px;
|
|
1504
|
+
border-radius: 10px;
|
|
1505
|
+
text-transform: uppercase;
|
|
1506
|
+
letter-spacing: 0.3px;
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
.maturity-badge[data-maturity='candidate'] {
|
|
1510
|
+
background: var(--bg-hover);
|
|
1511
|
+
color: var(--text-muted);
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
.maturity-badge[data-maturity='established'] {
|
|
1515
|
+
background: var(--blue-dim);
|
|
1516
|
+
color: var(--blue);
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
.maturity-badge[data-maturity='proven'] {
|
|
1520
|
+
background: var(--green-dim);
|
|
1521
|
+
color: var(--green);
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
.maturity-reads {
|
|
1525
|
+
font-weight: 500;
|
|
1526
|
+
font-size: 10px;
|
|
1527
|
+
opacity: 0.8;
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
.card-header-row {
|
|
1531
|
+
display: flex;
|
|
1532
|
+
align-items: center;
|
|
1533
|
+
justify-content: space-between;
|
|
1534
|
+
gap: 6px;
|
|
1535
|
+
margin-bottom: 8px;
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
/* ── Related Entries ──────────────────────────────────────────────────── */
|
|
1539
|
+
.related-section {
|
|
1540
|
+
margin-top: 20px;
|
|
1541
|
+
border-top: 1px solid var(--border-light);
|
|
1542
|
+
padding-top: 16px;
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
.related-entries {
|
|
1546
|
+
display: flex;
|
|
1547
|
+
flex-direction: column;
|
|
1548
|
+
gap: 6px;
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
.related-entry {
|
|
1552
|
+
display: flex;
|
|
1553
|
+
align-items: center;
|
|
1554
|
+
gap: 8px;
|
|
1555
|
+
padding: 8px 12px;
|
|
1556
|
+
background: var(--bg-elevated);
|
|
1557
|
+
border: 1px solid transparent;
|
|
1558
|
+
border-radius: var(--radius-sm);
|
|
1559
|
+
cursor: pointer;
|
|
1560
|
+
transition:
|
|
1561
|
+
background var(--transition-fast),
|
|
1562
|
+
border-color var(--transition-fast);
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
.related-entry:hover {
|
|
1566
|
+
background: var(--bg-hover);
|
|
1567
|
+
border-color: var(--accent);
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
.related-entry:focus-visible {
|
|
1571
|
+
outline: 2px solid var(--accent);
|
|
1572
|
+
outline-offset: 1px;
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
.rel-type-pill {
|
|
1576
|
+
display: inline-flex;
|
|
1577
|
+
align-items: center;
|
|
1578
|
+
font-size: 10px;
|
|
1579
|
+
font-weight: 600;
|
|
1580
|
+
padding: 2px 8px;
|
|
1581
|
+
border-radius: 10px;
|
|
1582
|
+
text-transform: uppercase;
|
|
1583
|
+
letter-spacing: 0.3px;
|
|
1584
|
+
white-space: nowrap;
|
|
1585
|
+
flex-shrink: 0;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
.rel-type-pill[data-rel='related_to'] {
|
|
1589
|
+
background: var(--accent-dim);
|
|
1590
|
+
color: var(--accent);
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
.rel-type-pill[data-rel='depends_on'] {
|
|
1594
|
+
background: var(--orange-dim);
|
|
1595
|
+
color: var(--orange);
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
.rel-type-pill[data-rel='supersedes'] {
|
|
1599
|
+
background: var(--red-dim);
|
|
1600
|
+
color: var(--red);
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
.rel-type-pill[data-rel='contradicts'] {
|
|
1604
|
+
background: var(--red-dim);
|
|
1605
|
+
color: var(--red);
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
.rel-type-pill[data-rel='specializes'] {
|
|
1609
|
+
background: var(--purple-dim);
|
|
1610
|
+
color: var(--purple);
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
.rel-type-pill[data-rel='part_of'] {
|
|
1614
|
+
background: var(--blue-dim);
|
|
1615
|
+
color: var(--blue);
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
.rel-type-pill[data-rel='alternative_to'] {
|
|
1619
|
+
background: var(--yellow-dim);
|
|
1620
|
+
color: var(--yellow);
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
.rel-type-pill[data-rel='builds_on'] {
|
|
1624
|
+
background: var(--green-dim);
|
|
1625
|
+
color: var(--green);
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
.related-entry-title {
|
|
1629
|
+
font-size: 13px;
|
|
1630
|
+
font-weight: 500;
|
|
1631
|
+
color: var(--text);
|
|
1632
|
+
flex: 1;
|
|
1633
|
+
overflow: hidden;
|
|
1634
|
+
text-overflow: ellipsis;
|
|
1635
|
+
white-space: nowrap;
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
.related-entry-strength {
|
|
1639
|
+
font-size: 10px;
|
|
1640
|
+
font-weight: 600;
|
|
1641
|
+
font-family: var(--font-mono);
|
|
1642
|
+
color: var(--text-dim);
|
|
1643
|
+
flex-shrink: 0;
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
/* ── Score Breakdown ──────────────────────────────────────────────────── */
|
|
1647
|
+
.score-breakdown {
|
|
1648
|
+
font-size: 11px;
|
|
1649
|
+
font-family: var(--font-mono);
|
|
1650
|
+
color: var(--text-dim);
|
|
1651
|
+
margin-top: 4px;
|
|
1652
|
+
padding: 2px 0;
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
.result-entry-title {
|
|
1656
|
+
font-size: 13px;
|
|
1657
|
+
font-weight: 600;
|
|
1658
|
+
color: var(--text);
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
/* ── Knowledge Search Bar ─────────────────────────────────────────────── */
|
|
1662
|
+
.knowledge-search-bar {
|
|
1663
|
+
margin-bottom: 16px;
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1496
1666
|
/* ── Responsive ────────────────────────────────────────────────────────── */
|
|
1497
1667
|
@media (max-width: 1024px) {
|
|
1498
1668
|
.side-panel.open {
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -40,13 +40,15 @@ graph TB
|
|
|
40
40
|
```
|
|
41
41
|
src/
|
|
42
42
|
index.ts Entry point — MCP stdio + dashboard auto-start
|
|
43
|
-
server.ts
|
|
43
|
+
server.ts 16 tool definitions, request routing, error handling
|
|
44
44
|
dashboard.ts HTTP + WebSocket server, REST API, file watcher
|
|
45
45
|
types.ts KnowledgeConfig interface, getConfig()
|
|
46
46
|
knowledge/
|
|
47
47
|
store.ts CRUD for markdown entries with YAML frontmatter
|
|
48
48
|
search.ts TF-IDF search over knowledge entries
|
|
49
49
|
git.ts git pull/push/sync with execSync + timeouts
|
|
50
|
+
graph.ts Knowledge graph — edges table, link/unlink/BFS traversal
|
|
51
|
+
scoring.ts Confidence/decay scoring — entry_scores table, auto-promotion
|
|
50
52
|
sessions/
|
|
51
53
|
parser.ts Multi-format parsing with mtime cache + adapter dispatch
|
|
52
54
|
search.ts TF-IDF ranked search with 60s global index cache
|
|
@@ -92,6 +94,69 @@ Wraps `execSync` for git operations with timeouts:
|
|
|
92
94
|
|
|
93
95
|
Builds a TF-IDF index from all knowledge entries, searches with ranking, falls back to regex for exact phrases.
|
|
94
96
|
|
|
97
|
+
## Knowledge Graph
|
|
98
|
+
|
|
99
|
+
### graph.ts
|
|
100
|
+
|
|
101
|
+
Manages typed, weighted edges between knowledge entries in a dedicated `edges` SQLite table.
|
|
102
|
+
|
|
103
|
+
**Schema**:
|
|
104
|
+
|
|
105
|
+
```sql
|
|
106
|
+
CREATE TABLE edges (
|
|
107
|
+
source TEXT NOT NULL,
|
|
108
|
+
target TEXT NOT NULL,
|
|
109
|
+
rel_type TEXT NOT NULL,
|
|
110
|
+
strength REAL DEFAULT 1.0,
|
|
111
|
+
created TEXT NOT NULL,
|
|
112
|
+
PRIMARY KEY (source, target, rel_type)
|
|
113
|
+
);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**8 relationship types**: `related_to`, `supersedes`, `depends_on`, `contradicts`, `specializes`, `part_of`, `alternative_to`, `builds_on`.
|
|
117
|
+
|
|
118
|
+
**Operations**:
|
|
119
|
+
|
|
120
|
+
- **link()** — upsert an edge (INSERT OR REPLACE), validates rel_type against allowed set
|
|
121
|
+
- **unlink()** — delete edges, optionally filtered by rel_type
|
|
122
|
+
- **links()** — list edges for a given entry or rel_type
|
|
123
|
+
- **traverse()** — BFS from a starting entry to configurable depth, returns nodes and edges visited
|
|
124
|
+
|
|
125
|
+
**Auto-linking**: On `knowledge_write`, the top-3 most similar existing entries are found via cosine similarity against the vector store. Entries with similarity > 0.7 get automatic `related_to` edges created.
|
|
126
|
+
|
|
127
|
+
## Confidence & Decay Scoring
|
|
128
|
+
|
|
129
|
+
### scoring.ts
|
|
130
|
+
|
|
131
|
+
Tracks access frequency and recency for search result ranking via an `entry_scores` SQLite table.
|
|
132
|
+
|
|
133
|
+
**Schema**:
|
|
134
|
+
|
|
135
|
+
```sql
|
|
136
|
+
CREATE TABLE entry_scores (
|
|
137
|
+
path TEXT PRIMARY KEY,
|
|
138
|
+
access_count INTEGER DEFAULT 0,
|
|
139
|
+
last_accessed TEXT NOT NULL,
|
|
140
|
+
maturity TEXT DEFAULT 'candidate'
|
|
141
|
+
);
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Scoring formula**:
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
finalScore = baseRelevance * 0.5^(daysSinceLastAccess / 90) * maturityMultiplier
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Maturity auto-promotion**:
|
|
151
|
+
|
|
152
|
+
| Stage | Accesses | Multiplier |
|
|
153
|
+
| ------------- | -------- | ---------- |
|
|
154
|
+
| `candidate` | < 5 | 0.5x |
|
|
155
|
+
| `established` | 5-19 | 1.0x |
|
|
156
|
+
| `proven` | 20+ | 1.5x |
|
|
157
|
+
|
|
158
|
+
Access count increments on `knowledge_read`. Maturity transitions happen automatically when thresholds are crossed. Search results from `knowledge_search` apply the decay formula to blend relevance with freshness and confidence.
|
|
159
|
+
|
|
95
160
|
## Session Module
|
|
96
161
|
|
|
97
162
|
### Multi-Source Architecture
|
package/docs/DASHBOARD.md
CHANGED
|
@@ -16,12 +16,15 @@ The dashboard runs at **http://localhost:3423** and auto-starts with the MCP ser
|
|
|
16
16
|
Card grid of knowledge entries. Each card shows:
|
|
17
17
|
|
|
18
18
|
- Category badge with color: projects (blue), people (purple), decisions (orange), workflows (green), notes (yellow)
|
|
19
|
+
- **Maturity badge**: candidate (gray), established (blue), proven (green) — based on access frequency
|
|
19
20
|
- Title and tag pills
|
|
20
21
|
- Last updated date
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+

|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
Category filter chips at the top: All, Projects, People, Decisions, Workflows, Notes. Search bar for filtering entries by title.
|
|
26
|
+
|
|
27
|
+
Click a card to open the side panel with rendered markdown content, score details, and related entries.
|
|
25
28
|
|
|
26
29
|
## Search Tab
|
|
27
30
|
|
|
@@ -78,6 +81,8 @@ Results use the same format as the Search tab.
|
|
|
78
81
|
- Width: 560px, resizable by dragging the left edge
|
|
79
82
|
- Close: X button or press Escape
|
|
80
83
|
- Knowledge entries: rendered as markdown via marked + DOMPurify + highlight.js
|
|
84
|
+
- **Related entries**: linked entries shown with colored relationship-type pills (related_to, depends_on, supersedes, etc.) — clickable to navigate
|
|
85
|
+
- **Score details**: maturity level, access count, decay factor, and maturity multiplier
|
|
81
86
|
- Sessions: chat bubbles (user = right/accent, assistant = left/surface)
|
|
82
87
|
|
|
83
88
|
## Theming
|
|
@@ -100,17 +105,18 @@ File watcher monitors `src/ui/` for `.html`, `.css`, `.js` changes. On change, b
|
|
|
100
105
|
|
|
101
106
|
## REST API
|
|
102
107
|
|
|
103
|
-
| Method | Endpoint | Description
|
|
104
|
-
| ------ | --------------------------------------- |
|
|
105
|
-
| GET | `/api/knowledge` | List entries
|
|
106
|
-
| GET | `/api/knowledge/search?q=` | Search knowledge
|
|
107
|
-
| GET | `/api/knowledge/:path` | Read entry
|
|
108
|
-
| GET | `/api/
|
|
109
|
-
| GET | `/api/sessions
|
|
110
|
-
| GET | `/api/sessions/
|
|
111
|
-
| GET | `/api/sessions
|
|
112
|
-
| GET | `/api/sessions/:id
|
|
113
|
-
| GET | `/
|
|
108
|
+
| Method | Endpoint | Description |
|
|
109
|
+
| ------ | --------------------------------------- | ---------------------------- |
|
|
110
|
+
| GET | `/api/knowledge` | List entries |
|
|
111
|
+
| GET | `/api/knowledge/search?q=` | Search knowledge |
|
|
112
|
+
| GET | `/api/knowledge/:path` | Read entry (with score data) |
|
|
113
|
+
| GET | `/api/knowledge/:path/links` | Graph edges for entry |
|
|
114
|
+
| GET | `/api/sessions` | List sessions |
|
|
115
|
+
| GET | `/api/sessions/search?q=&role=&ranked=` | Search sessions |
|
|
116
|
+
| GET | `/api/sessions/recall?scope=&q=` | Scoped recall |
|
|
117
|
+
| GET | `/api/sessions/:id` | Read session |
|
|
118
|
+
| GET | `/api/sessions/:id/summary` | Session summary |
|
|
119
|
+
| GET | `/health` | Health check |
|
|
114
120
|
|
|
115
121
|
## WebSocket
|
|
116
122
|
|