agent-knowledge 1.8.0 → 1.9.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/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +95 -0
- package/README.md +67 -22
- package/agent-desk-plugin.json +1 -1
- package/dist/dashboard.d.ts.map +1 -1
- package/dist/dashboard.js +28 -1
- package/dist/dashboard.js.map +1 -1
- package/dist/embeddings/factory.js +1 -1
- package/dist/embeddings/factory.js.map +1 -1
- package/dist/embeddings/local.js +1 -1
- package/dist/embeddings/local.js.map +1 -1
- package/dist/embeddings/types.d.ts.map +1 -1
- package/dist/embeddings/types.js +8 -6
- package/dist/embeddings/types.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/knowledge/analyze.d.ts +18 -0
- package/dist/knowledge/analyze.d.ts.map +1 -1
- package/dist/knowledge/analyze.js +22 -0
- package/dist/knowledge/analyze.js.map +1 -1
- package/dist/knowledge/freshness.d.ts +99 -0
- package/dist/knowledge/freshness.d.ts.map +1 -0
- package/dist/knowledge/freshness.js +303 -0
- package/dist/knowledge/freshness.js.map +1 -0
- package/dist/knowledge/promote.d.ts.map +1 -1
- package/dist/knowledge/promote.js +32 -17
- package/dist/knowledge/promote.js.map +1 -1
- package/dist/knowledge/query-log.d.ts +88 -0
- package/dist/knowledge/query-log.d.ts.map +1 -0
- package/dist/knowledge/query-log.js +207 -0
- package/dist/knowledge/query-log.js.map +1 -0
- package/dist/knowledge/scoring.d.ts +16 -0
- package/dist/knowledge/scoring.d.ts.map +1 -1
- package/dist/knowledge/scoring.js +44 -0
- package/dist/knowledge/scoring.js.map +1 -1
- package/dist/knowledge/search.d.ts +24 -0
- package/dist/knowledge/search.d.ts.map +1 -1
- package/dist/knowledge/search.js +28 -0
- package/dist/knowledge/search.js.map +1 -1
- package/dist/knowledge/store.d.ts +6 -0
- package/dist/knowledge/store.d.ts.map +1 -1
- package/dist/knowledge/store.js +8 -0
- package/dist/knowledge/store.js.map +1 -1
- package/dist/server.d.ts +27 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +47 -5
- package/dist/server.js.map +1 -1
- package/dist/tool-handlers.d.ts.map +1 -1
- package/dist/tool-handlers.js +94 -4
- package/dist/tool-handlers.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +11 -9
- package/dist/types.js.map +1 -1
- package/dist/ui/app.js +271 -1
- package/dist/ui/render-knowledge.js +3 -3
- package/dist/ui/styles.css +209 -0
- package/dist/wakeup.d.ts +59 -14
- package/dist/wakeup.d.ts.map +1 -1
- package/dist/wakeup.js +406 -43
- package/dist/wakeup.js.map +1 -1
- package/docs/ARCHITECTURE.md +15 -3
- package/docs/DASHBOARD.md +6 -0
- package/docs/SETUP.md +38 -38
- package/docs/USER-MANUAL.md +79 -40
- package/docs/hooks.md +7 -7
- package/package.json +1 -1
- package/scripts/hooks/first-prompt-inject.mjs +3 -3
- package/scripts/hooks/precompact-distill.mjs +1 -1
- package/scripts/hooks/precompact-flush.mjs +1 -1
- package/scripts/hooks/sessionend-distill.mjs +1 -1
- package/scripts/setup.js +1 -1
package/dist/types.js
CHANGED
|
@@ -47,14 +47,16 @@ export function savePersistedConfig(updates) {
|
|
|
47
47
|
// ── Config resolution (env vars > persisted config > defaults) ──────────────
|
|
48
48
|
export function getConfig() {
|
|
49
49
|
const home = homedir();
|
|
50
|
-
//
|
|
51
|
-
|
|
50
|
+
// Primary host data root override — defaults to the platform config dir
|
|
51
|
+
// when unset. Most deployments leave it unset and rely on the adapter
|
|
52
|
+
// registry's multi-host auto-detection instead.
|
|
53
|
+
const dataDir = process.env.AGENT_KNOWLEDGE_DATA_DIR || getConfigDir();
|
|
52
54
|
const persisted = loadPersistedConfig();
|
|
53
|
-
const memoryDir = process.env.
|
|
55
|
+
const memoryDir = process.env.AGENT_KNOWLEDGE_MEMORY_DIR || persisted.memoryDir || join(home, 'agent-knowledge');
|
|
54
56
|
const sessionsDir = join(dataDir, 'projects');
|
|
55
57
|
// Extra session roots: from env var (comma-separated) + auto-detected editors
|
|
56
58
|
const extraSessionRoots = [];
|
|
57
|
-
const envRoots = process.env.
|
|
59
|
+
const envRoots = process.env.AGENT_KNOWLEDGE_EXTRA_SESSION_ROOTS;
|
|
58
60
|
if (envRoots) {
|
|
59
61
|
for (const r of envRoots.split(',')) {
|
|
60
62
|
const trimmed = r.trim();
|
|
@@ -77,16 +79,16 @@ export function getConfig() {
|
|
|
77
79
|
extraSessionRoots.push(root);
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
|
-
const embeddingProvider = process.env.
|
|
82
|
+
const embeddingProvider = process.env.AGENT_KNOWLEDGE_EMBEDDING_PROVIDER ||
|
|
81
83
|
persisted.embeddingProvider ||
|
|
82
84
|
'local';
|
|
83
|
-
const embeddingAlpha = parseFloat(process.env.
|
|
84
|
-
const gitUrl = process.env.
|
|
85
|
-
const autoDistillEnv = process.env.
|
|
85
|
+
const embeddingAlpha = parseFloat(process.env.AGENT_KNOWLEDGE_EMBEDDING_ALPHA || String(persisted.embeddingAlpha ?? 0.3));
|
|
86
|
+
const gitUrl = process.env.AGENT_KNOWLEDGE_GIT_URL || persisted.gitUrl || undefined;
|
|
87
|
+
const autoDistillEnv = process.env.AGENT_KNOWLEDGE_AUTO_DISTILL;
|
|
86
88
|
const autoDistill = autoDistillEnv !== undefined
|
|
87
89
|
? autoDistillEnv.toLowerCase() !== 'false'
|
|
88
90
|
: (persisted.autoDistill ?? true);
|
|
89
|
-
const indexVerbatimEnv = process.env.
|
|
91
|
+
const indexVerbatimEnv = process.env.AGENT_KNOWLEDGE_INDEX_VERBATIM;
|
|
90
92
|
const indexVerbatim = indexVerbatimEnv !== undefined
|
|
91
93
|
? indexVerbatimEnv.toLowerCase() !== 'false'
|
|
92
94
|
: (persisted.indexVerbatim ?? true);
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","s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AAK,OAAO;QAC1C,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,IAAI,IAAI,CAAC,CAAC;IAEtC,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC;IACpE,MAAM,aAAa,GACjB,gBAAgB,KAAK,SAAS;QAC5B,CAAC,CAAC,gBAAgB,CAAC,WAAW,EAAE,KAAK,OAAO;QAC5C,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,IAAI,IAAI,CAAC,CAAC;IAExC,OAAO;QACL,SAAS;QACT,OAAO;QACP,WAAW;QACX,iBAAiB;QACjB,iBAAiB;QACjB,cAAc;QACd,MAAM;QACN,WAAW;QACX,aAAa;KACd,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,eAAe,EAAE,CAAC,OAAO,CAAC;AACnC,CAAC"}
|
package/dist/ui/app.js
CHANGED
|
@@ -7,7 +7,14 @@
|
|
|
7
7
|
// ── State ──────────────────────────────────────────────────────────────────
|
|
8
8
|
const state = {
|
|
9
9
|
activeTab: 'knowledge',
|
|
10
|
-
knowledge: {
|
|
10
|
+
knowledge: {
|
|
11
|
+
entries: [],
|
|
12
|
+
activeCategory: 'all',
|
|
13
|
+
duplicateClusters: {},
|
|
14
|
+
// v1.8.1: when true, the grid is filtered to entries whose
|
|
15
|
+
// `last_accessed` is null or older than 90 days.
|
|
16
|
+
onlyUnused: false,
|
|
17
|
+
},
|
|
11
18
|
search: {
|
|
12
19
|
query: '',
|
|
13
20
|
results: [],
|
|
@@ -564,6 +571,266 @@
|
|
|
564
571
|
if (el.themeToggle) el.themeToggle.style.display = 'none';
|
|
565
572
|
});
|
|
566
573
|
|
|
574
|
+
// ── v1.8.1 Knowledge extras: unused filter, by-type chart, pin+author ─────
|
|
575
|
+
//
|
|
576
|
+
// The original renderer lives in render-knowledge.js. To avoid touching that
|
|
577
|
+
// file, we wrap K.renderKnowledge once at init time. The wrapper:
|
|
578
|
+
// 1. optionally filters the entries list by the "Unused 90d+" toggle,
|
|
579
|
+
// 2. delegates to the original renderer,
|
|
580
|
+
// 3. post-processes each rendered card to inject the pin badge
|
|
581
|
+
// (for `evergreen: true`) and the `by <author>` footer tag,
|
|
582
|
+
// 4. refreshes the "By Type" bar chart and the filter-button count.
|
|
583
|
+
|
|
584
|
+
// Per-category recency windows (days). A flat 30d default penalised
|
|
585
|
+
// long-lived categories like `people` and `projects` that are correctly
|
|
586
|
+
// consulted rarely; 30d worked for `notes` but was far too tight for
|
|
587
|
+
// identity-shaped content. Values are tuned for the typical-use shape:
|
|
588
|
+
// people change rarely, project/decision entries live long, notes are
|
|
589
|
+
// ephemeral scratch.
|
|
590
|
+
const CATEGORY_RECENT_DAYS = {
|
|
591
|
+
projects: 180,
|
|
592
|
+
people: 365,
|
|
593
|
+
decisions: 90,
|
|
594
|
+
workflows: 60,
|
|
595
|
+
notes: 30,
|
|
596
|
+
};
|
|
597
|
+
const CATEGORY_UNUSED_DAYS = {
|
|
598
|
+
projects: 365,
|
|
599
|
+
people: 730,
|
|
600
|
+
decisions: 180,
|
|
601
|
+
workflows: 120,
|
|
602
|
+
notes: 90,
|
|
603
|
+
};
|
|
604
|
+
const DEFAULT_RECENT_DAYS = 30;
|
|
605
|
+
const DEFAULT_UNUSED_DAYS = 90;
|
|
606
|
+
const CATEGORY_ORDER = ['projects', 'people', 'decisions', 'workflows', 'notes'];
|
|
607
|
+
const CATEGORY_ICONS = {
|
|
608
|
+
projects: 'code',
|
|
609
|
+
people: 'group',
|
|
610
|
+
decisions: 'gavel',
|
|
611
|
+
workflows: 'account_tree',
|
|
612
|
+
notes: 'sticky_note_2',
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
function recentDaysFor(entry) {
|
|
616
|
+
return CATEGORY_RECENT_DAYS[entry.category] ?? DEFAULT_RECENT_DAYS;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
function unusedDaysFor(entry) {
|
|
620
|
+
return CATEGORY_UNUSED_DAYS[entry.category] ?? DEFAULT_UNUSED_DAYS;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
function isOlderThan(entry, days) {
|
|
624
|
+
const la = entry.last_accessed;
|
|
625
|
+
if (!la) return true;
|
|
626
|
+
const t = new Date(la).getTime();
|
|
627
|
+
if (!Number.isFinite(t)) return true;
|
|
628
|
+
return Date.now() - t > days * 24 * 60 * 60 * 1000;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// Kept for call sites that pass an explicit day count (filter, etc.).
|
|
632
|
+
function isUnused(entry, days) {
|
|
633
|
+
return isOlderThan(entry, days ?? unusedDaysFor(entry));
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
function countUnused(entries) {
|
|
637
|
+
let n = 0;
|
|
638
|
+
for (const e of entries) if (isOlderThan(e, unusedDaysFor(e))) n++;
|
|
639
|
+
return n;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
function ensureUnusedButton() {
|
|
643
|
+
if (!el.knowledgeCategories) return null;
|
|
644
|
+
let btn = el.knowledgeCategories.querySelector('#btn-unused-filter');
|
|
645
|
+
if (btn) return btn;
|
|
646
|
+
btn = document.createElement('button');
|
|
647
|
+
btn.id = 'btn-unused-filter';
|
|
648
|
+
btn.type = 'button';
|
|
649
|
+
btn.className = 'unused-filter-btn';
|
|
650
|
+
btn.title = 'Show only entries not accessed in the last 90 days';
|
|
651
|
+
btn.innerHTML =
|
|
652
|
+
'<span class="material-symbols-outlined">schedule</span>' +
|
|
653
|
+
'<span class="unused-label">Unused (0)</span>';
|
|
654
|
+
btn.addEventListener('click', () => {
|
|
655
|
+
state.knowledge.onlyUnused = !state.knowledge.onlyUnused;
|
|
656
|
+
btn.classList.toggle('active', state.knowledge.onlyUnused);
|
|
657
|
+
K.renderKnowledge(state, el);
|
|
658
|
+
});
|
|
659
|
+
el.knowledgeCategories.appendChild(btn);
|
|
660
|
+
return btn;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
function updateUnusedButton(unusedCount) {
|
|
664
|
+
const btn = ensureUnusedButton();
|
|
665
|
+
if (!btn) return;
|
|
666
|
+
const label = btn.querySelector('.unused-label');
|
|
667
|
+
if (label) label.textContent = 'Unused (' + unusedCount + ')';
|
|
668
|
+
btn.classList.toggle('active', !!state.knowledge.onlyUnused);
|
|
669
|
+
btn.hidden = unusedCount === 0 && !state.knowledge.onlyUnused;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
function ensureBytypePanel() {
|
|
673
|
+
if (!el.knowledgeGrid || !el.knowledgeGrid.parentNode) return null;
|
|
674
|
+
let panel = K._root.getElementById('knowledge-bytype');
|
|
675
|
+
if (panel) return panel;
|
|
676
|
+
panel = document.createElement('div');
|
|
677
|
+
panel.id = 'knowledge-bytype';
|
|
678
|
+
panel.className = 'bytype-panel';
|
|
679
|
+
panel.setAttribute('aria-label', 'Access count by category');
|
|
680
|
+
panel.innerHTML =
|
|
681
|
+
'<div class="bytype-panel-header">' +
|
|
682
|
+
'<span class="bytype-title">By Type</span>' +
|
|
683
|
+
'<span class="bytype-legend">' +
|
|
684
|
+
'<span class="bytype-legend-item">' +
|
|
685
|
+
'<span class="bytype-legend-swatch recent"></span>' +
|
|
686
|
+
'Accessed 30d' +
|
|
687
|
+
'</span>' +
|
|
688
|
+
'<span class="bytype-legend-item">' +
|
|
689
|
+
'<span class="bytype-legend-swatch unused"></span>' +
|
|
690
|
+
'Unused 30d+' +
|
|
691
|
+
'</span>' +
|
|
692
|
+
'</span>' +
|
|
693
|
+
'</div>' +
|
|
694
|
+
'<div class="bytype-rows" id="knowledge-bytype-rows"></div>';
|
|
695
|
+
// Insert BEFORE the search bar so it sits in the stats area above the grid.
|
|
696
|
+
const searchBar = el.knowledgeGrid.parentNode.querySelector('.knowledge-search-bar');
|
|
697
|
+
const anchor = searchBar || el.knowledgeGrid;
|
|
698
|
+
anchor.parentNode.insertBefore(panel, anchor);
|
|
699
|
+
return panel;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
function renderBytypeChart(entries) {
|
|
703
|
+
const panel = ensureBytypePanel();
|
|
704
|
+
if (!panel) return;
|
|
705
|
+
const rowsEl = panel.querySelector('#knowledge-bytype-rows');
|
|
706
|
+
if (!rowsEl) return;
|
|
707
|
+
|
|
708
|
+
const buckets = {};
|
|
709
|
+
for (const cat of CATEGORY_ORDER) buckets[cat] = { recent: 0, unused: 0 };
|
|
710
|
+
for (const e of entries) {
|
|
711
|
+
const cat = e.category || 'notes';
|
|
712
|
+
if (!buckets[cat]) buckets[cat] = { recent: 0, unused: 0 };
|
|
713
|
+
// Per-category recency window — people/projects are consulted less
|
|
714
|
+
// often by design, so the 30d default would wrongly paint them stale.
|
|
715
|
+
if (isOlderThan(e, recentDaysFor(e))) buckets[cat].unused++;
|
|
716
|
+
else buckets[cat].recent++;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
const rows = CATEGORY_ORDER.map((cat) => {
|
|
720
|
+
const b = buckets[cat];
|
|
721
|
+
const total = b.recent + b.unused;
|
|
722
|
+
// Row-normalized: each bar sums to 100% within its row so the visual
|
|
723
|
+
// answers "how stale is this category?" without misleading gray filler.
|
|
724
|
+
// Cross-category volume stays readable via the right-side counts.
|
|
725
|
+
const denom = total || 1;
|
|
726
|
+
const recentPct = (b.recent / denom) * 100;
|
|
727
|
+
const unusedPct = (b.unused / denom) * 100;
|
|
728
|
+
const icon = CATEGORY_ICONS[cat] || 'article';
|
|
729
|
+
const bar = total
|
|
730
|
+
? '<span class="bytype-bar-recent" style="width:' +
|
|
731
|
+
recentPct.toFixed(1) +
|
|
732
|
+
'%"></span>' +
|
|
733
|
+
'<span class="bytype-bar-unused" style="width:' +
|
|
734
|
+
unusedPct.toFixed(1) +
|
|
735
|
+
'%"></span>'
|
|
736
|
+
: '<span class="bytype-bar-empty"></span>';
|
|
737
|
+
return (
|
|
738
|
+
'<div class="bytype-row-label">' +
|
|
739
|
+
'<span class="material-symbols-outlined">' +
|
|
740
|
+
icon +
|
|
741
|
+
'</span>' +
|
|
742
|
+
K.esc(cat) +
|
|
743
|
+
'</div>' +
|
|
744
|
+
'<div class="bytype-bar" role="img" aria-label="' +
|
|
745
|
+
K.esc(cat) +
|
|
746
|
+
': ' +
|
|
747
|
+
b.recent +
|
|
748
|
+
' recent, ' +
|
|
749
|
+
b.unused +
|
|
750
|
+
' unused">' +
|
|
751
|
+
bar +
|
|
752
|
+
'</div>' +
|
|
753
|
+
'<div class="bytype-row-count">' +
|
|
754
|
+
'<span class="count-recent">' +
|
|
755
|
+
b.recent +
|
|
756
|
+
'</span>' +
|
|
757
|
+
'<span class="count-sep">/</span>' +
|
|
758
|
+
'<span class="count-unused">' +
|
|
759
|
+
b.unused +
|
|
760
|
+
'</span>' +
|
|
761
|
+
'</div>'
|
|
762
|
+
);
|
|
763
|
+
}).join('');
|
|
764
|
+
K.morph(rowsEl, rows);
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
function decorateCards(entries) {
|
|
768
|
+
if (!el.knowledgeGrid) return;
|
|
769
|
+
const byPath = new Map();
|
|
770
|
+
for (const e of entries) byPath.set(e.path || e.id || '', e);
|
|
771
|
+
const cards = el.knowledgeGrid.querySelectorAll('.knowledge-card[data-path]');
|
|
772
|
+
cards.forEach((card) => {
|
|
773
|
+
const entry = byPath.get(card.getAttribute('data-path'));
|
|
774
|
+
if (!entry) return;
|
|
775
|
+
|
|
776
|
+
// Pin badge for evergreen entries — Material Symbols "push_pin".
|
|
777
|
+
const rightSlot = card.querySelector('.card-header-row > div');
|
|
778
|
+
if (rightSlot && entry.evergreen === true) {
|
|
779
|
+
if (!rightSlot.querySelector('.pin-badge')) {
|
|
780
|
+
const pin = document.createElement('span');
|
|
781
|
+
pin.className = 'pin-badge';
|
|
782
|
+
pin.title = 'Evergreen — exempt from decay';
|
|
783
|
+
pin.setAttribute('aria-label', 'Evergreen entry');
|
|
784
|
+
pin.innerHTML = '<span class="material-symbols-outlined">push_pin</span>';
|
|
785
|
+
rightSlot.insertBefore(pin, rightSlot.firstChild);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
// Author footer tag — only if frontmatter provided one.
|
|
790
|
+
if (entry.author && typeof entry.author === 'string') {
|
|
791
|
+
if (!card.querySelector('.card-author')) {
|
|
792
|
+
const tag = document.createElement('span');
|
|
793
|
+
tag.className = 'card-author';
|
|
794
|
+
tag.title = 'Author';
|
|
795
|
+
tag.textContent = entry.author;
|
|
796
|
+
card.appendChild(tag);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
function installKnowledgeEnhancements() {
|
|
803
|
+
const original = K.renderKnowledge;
|
|
804
|
+
if (!original || original.__v181wrapped) return;
|
|
805
|
+
|
|
806
|
+
const wrapped = function (s, e) {
|
|
807
|
+
const entries = s.knowledge.entries || [];
|
|
808
|
+
const unusedCount = countUnused(entries);
|
|
809
|
+
|
|
810
|
+
// Apply the "unused only" filter at the source — the inner renderer
|
|
811
|
+
// still does its own category filter on top of this.
|
|
812
|
+
const original_entries = s.knowledge.entries;
|
|
813
|
+
if (s.knowledge.onlyUnused) {
|
|
814
|
+
s.knowledge.entries = entries.filter((x) => isOlderThan(x, unusedDaysFor(x)));
|
|
815
|
+
}
|
|
816
|
+
try {
|
|
817
|
+
original(s, e);
|
|
818
|
+
} finally {
|
|
819
|
+
s.knowledge.entries = original_entries;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
renderBytypeChart(entries);
|
|
823
|
+
updateUnusedButton(unusedCount);
|
|
824
|
+
decorateCards(
|
|
825
|
+
s.knowledge.onlyUnused
|
|
826
|
+
? s.knowledge.entries.filter((x) => isOlderThan(x, unusedDaysFor(x)))
|
|
827
|
+
: entries,
|
|
828
|
+
);
|
|
829
|
+
};
|
|
830
|
+
wrapped.__v181wrapped = true;
|
|
831
|
+
K.renderKnowledge = wrapped;
|
|
832
|
+
}
|
|
833
|
+
|
|
567
834
|
// ── Init ───────────────────────────────────────────────────────────────────
|
|
568
835
|
|
|
569
836
|
async function init() {
|
|
@@ -578,6 +845,9 @@
|
|
|
578
845
|
bindEvents();
|
|
579
846
|
K.initSessionScroll(state, el);
|
|
580
847
|
if (K.setupGraphControls) K.setupGraphControls();
|
|
848
|
+
installKnowledgeEnhancements();
|
|
849
|
+
ensureUnusedButton();
|
|
850
|
+
ensureBytypePanel();
|
|
581
851
|
wsConnect();
|
|
582
852
|
|
|
583
853
|
// Restore tab from URL hash (standalone mode only)
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
el.knowledgeSearchResults.style.display = 'none';
|
|
74
74
|
el.knowledgeGrid.style.display = '';
|
|
75
75
|
el.knowledgeEmpty.classList.add('hidden');
|
|
76
|
-
renderKnowledge(state, el);
|
|
76
|
+
K.renderKnowledge(state, el);
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
79
|
try {
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
state.knowledge.entries = entries;
|
|
149
149
|
state.stats.knowledgeCount = entries.length;
|
|
150
150
|
K.updateStats(state, el);
|
|
151
|
-
renderKnowledge(state, el);
|
|
151
|
+
K.renderKnowledge(state, el);
|
|
152
152
|
} catch (err) {
|
|
153
153
|
K.toast(`Failed to load knowledge: ${err.message}`, 'error');
|
|
154
154
|
}
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
state.knowledge.duplicateClusters[entry.path] = cluster;
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
renderKnowledge(state, el);
|
|
189
|
+
K.renderKnowledge(state, el);
|
|
190
190
|
K.openPanel('consolidate', report);
|
|
191
191
|
} else {
|
|
192
192
|
K.toast('No duplicate clusters found', 'success');
|
package/dist/ui/styles.css
CHANGED
|
@@ -1586,6 +1586,215 @@ h1 {
|
|
|
1586
1586
|
margin-bottom: 8px;
|
|
1587
1587
|
}
|
|
1588
1588
|
|
|
1589
|
+
/* ── v1.8.1 Pin Badge (evergreen entries) ─────────────────────────────── */
|
|
1590
|
+
.pin-badge {
|
|
1591
|
+
display: inline-flex;
|
|
1592
|
+
align-items: center;
|
|
1593
|
+
justify-content: center;
|
|
1594
|
+
color: var(--accent);
|
|
1595
|
+
font-size: 16px;
|
|
1596
|
+
line-height: 1;
|
|
1597
|
+
cursor: help;
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
.pin-badge .material-symbols-outlined {
|
|
1601
|
+
font-size: 16px;
|
|
1602
|
+
font-variation-settings:
|
|
1603
|
+
'FILL' 1,
|
|
1604
|
+
'wght' 500,
|
|
1605
|
+
'GRAD' 0,
|
|
1606
|
+
'opsz' 20;
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
/* ── v1.8.1 Author Footer Tag ─────────────────────────────────────────── */
|
|
1610
|
+
.card-author {
|
|
1611
|
+
display: inline-flex;
|
|
1612
|
+
align-items: center;
|
|
1613
|
+
gap: 3px;
|
|
1614
|
+
font-size: 10px;
|
|
1615
|
+
font-family: var(--font-mono);
|
|
1616
|
+
font-weight: 500;
|
|
1617
|
+
color: var(--text-dim);
|
|
1618
|
+
background: var(--bg-hover);
|
|
1619
|
+
padding: 1px 6px;
|
|
1620
|
+
border-radius: 6px;
|
|
1621
|
+
margin-top: 4px;
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
.card-author::before {
|
|
1625
|
+
content: 'by';
|
|
1626
|
+
font-family: var(--font-sans);
|
|
1627
|
+
color: var(--text-muted);
|
|
1628
|
+
opacity: 0.7;
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
/* ── v1.8.1 Unused Filter Button ──────────────────────────────────────── */
|
|
1632
|
+
.unused-filter-btn {
|
|
1633
|
+
display: inline-flex;
|
|
1634
|
+
align-items: center;
|
|
1635
|
+
gap: 4px;
|
|
1636
|
+
padding: 5px 12px;
|
|
1637
|
+
font-size: 12px;
|
|
1638
|
+
font-weight: 500;
|
|
1639
|
+
color: var(--orange);
|
|
1640
|
+
background: var(--orange-dim);
|
|
1641
|
+
border: 1px solid transparent;
|
|
1642
|
+
border-radius: var(--radius-sm);
|
|
1643
|
+
cursor: pointer;
|
|
1644
|
+
transition: all var(--transition-fast);
|
|
1645
|
+
white-space: nowrap;
|
|
1646
|
+
margin-left: auto;
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
.unused-filter-btn:hover {
|
|
1650
|
+
background: var(--orange-dim);
|
|
1651
|
+
border-color: var(--orange);
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
.unused-filter-btn.active {
|
|
1655
|
+
background: var(--orange);
|
|
1656
|
+
color: #ffffff;
|
|
1657
|
+
border-color: var(--orange);
|
|
1658
|
+
font-weight: 600;
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
.unused-filter-btn .material-symbols-outlined {
|
|
1662
|
+
font-size: 14px;
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
.unused-filter-btn[hidden] {
|
|
1666
|
+
display: none;
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
/* ── v1.8.1 By-Type Access Bar Chart ──────────────────────────────────── */
|
|
1670
|
+
.bytype-panel {
|
|
1671
|
+
background: var(--bg-surface);
|
|
1672
|
+
border: 1px solid var(--border-light);
|
|
1673
|
+
border-radius: var(--radius-lg);
|
|
1674
|
+
padding: 12px 16px;
|
|
1675
|
+
margin-bottom: 16px;
|
|
1676
|
+
box-shadow: var(--shadow-1);
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
.bytype-panel-header {
|
|
1680
|
+
display: flex;
|
|
1681
|
+
align-items: center;
|
|
1682
|
+
justify-content: space-between;
|
|
1683
|
+
margin-bottom: 10px;
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
.bytype-title {
|
|
1687
|
+
font-size: 13px;
|
|
1688
|
+
font-weight: 600;
|
|
1689
|
+
text-transform: uppercase;
|
|
1690
|
+
letter-spacing: 0.5px;
|
|
1691
|
+
color: var(--text-muted);
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
.bytype-legend {
|
|
1695
|
+
display: inline-flex;
|
|
1696
|
+
align-items: center;
|
|
1697
|
+
gap: 12px;
|
|
1698
|
+
font-size: 11px;
|
|
1699
|
+
color: var(--text-dim);
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
.bytype-legend-item {
|
|
1703
|
+
display: inline-flex;
|
|
1704
|
+
align-items: center;
|
|
1705
|
+
gap: 4px;
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
.bytype-legend-swatch {
|
|
1709
|
+
width: 10px;
|
|
1710
|
+
height: 10px;
|
|
1711
|
+
border-radius: 2px;
|
|
1712
|
+
flex-shrink: 0;
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
.bytype-legend-swatch.recent {
|
|
1716
|
+
background: var(--green);
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
.bytype-legend-swatch.unused {
|
|
1720
|
+
background: var(--orange);
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
.bytype-rows {
|
|
1724
|
+
display: grid;
|
|
1725
|
+
grid-template-columns: max-content 1fr max-content;
|
|
1726
|
+
column-gap: 12px;
|
|
1727
|
+
row-gap: 6px;
|
|
1728
|
+
align-items: center;
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
.bytype-row-label {
|
|
1732
|
+
display: inline-flex;
|
|
1733
|
+
align-items: center;
|
|
1734
|
+
gap: 4px;
|
|
1735
|
+
font-size: 11px;
|
|
1736
|
+
font-weight: 500;
|
|
1737
|
+
color: var(--text-secondary);
|
|
1738
|
+
text-transform: capitalize;
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
.bytype-row-label .material-symbols-outlined {
|
|
1742
|
+
font-size: 14px;
|
|
1743
|
+
color: var(--text-dim);
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
.bytype-bar {
|
|
1747
|
+
position: relative;
|
|
1748
|
+
display: flex;
|
|
1749
|
+
height: 10px;
|
|
1750
|
+
width: 100%;
|
|
1751
|
+
background: var(--bg-inset);
|
|
1752
|
+
border-radius: 5px;
|
|
1753
|
+
overflow: hidden;
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
.bytype-bar-recent {
|
|
1757
|
+
background: var(--green);
|
|
1758
|
+
height: 100%;
|
|
1759
|
+
transition: width var(--transition-normal);
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
.bytype-bar-unused {
|
|
1763
|
+
background: var(--orange);
|
|
1764
|
+
height: 100%;
|
|
1765
|
+
transition: width var(--transition-normal);
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
.bytype-bar-empty {
|
|
1769
|
+
background: var(--bg-hover);
|
|
1770
|
+
height: 100%;
|
|
1771
|
+
width: 100%;
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
.bytype-row-count {
|
|
1775
|
+
font-family: var(--font-mono);
|
|
1776
|
+
font-size: 11px;
|
|
1777
|
+
font-weight: 500;
|
|
1778
|
+
color: var(--text-muted);
|
|
1779
|
+
white-space: nowrap;
|
|
1780
|
+
min-width: 48px;
|
|
1781
|
+
text-align: right;
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
.bytype-row-count .count-recent {
|
|
1785
|
+
color: var(--green);
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
.bytype-row-count .count-unused {
|
|
1789
|
+
color: var(--orange);
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
.bytype-row-count .count-sep {
|
|
1793
|
+
color: var(--text-dim);
|
|
1794
|
+
opacity: 0.5;
|
|
1795
|
+
margin: 0 2px;
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1589
1798
|
/* ── Related Entries ──────────────────────────────────────────────────── */
|
|
1590
1799
|
.related-section {
|
|
1591
1800
|
margin-top: 20px;
|