agent-knowledge 1.7.3 → 1.8.1
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/.mcp.json +1 -1
- package/CHANGELOG.md +101 -0
- package/README.md +43 -18
- 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/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 +145 -0
- package/dist/knowledge/promote.d.ts.map +1 -0
- package/dist/knowledge/promote.js +532 -0
- package/dist/knowledge/promote.js.map +1 -0
- 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 +22 -2
- package/dist/knowledge/scoring.d.ts.map +1 -1
- package/dist/knowledge/scoring.js +51 -3
- package/dist/knowledge/scoring.js.map +1 -1
- package/dist/knowledge/search.d.ts +56 -5
- package/dist/knowledge/search.d.ts.map +1 -1
- package/dist/knowledge/search.js +88 -10
- package/dist/knowledge/search.js.map +1 -1
- package/dist/knowledge/store.d.ts +12 -0
- package/dist/knowledge/store.d.ts.map +1 -1
- package/dist/knowledge/store.js +18 -0
- package/dist/knowledge/store.js.map +1 -1
- package/dist/search/mmr.d.ts +54 -0
- package/dist/search/mmr.d.ts.map +1 -0
- package/dist/search/mmr.js +138 -0
- package/dist/search/mmr.js.map +1 -0
- package/dist/server.d.ts +334 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +378 -301
- package/dist/server.js.map +1 -1
- package/dist/sessions/indexer.d.ts.map +1 -1
- package/dist/sessions/indexer.js +13 -11
- package/dist/sessions/indexer.js.map +1 -1
- package/dist/tool-handlers.d.ts +10 -3
- package/dist/tool-handlers.d.ts.map +1 -1
- package/dist/tool-handlers.js +150 -21
- package/dist/tool-handlers.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 +31 -6
- package/docs/SETUP.md +20 -8
- package/docs/USER-MANUAL.md +205 -59
- package/docs/hooks.md +81 -21
- package/package.json +4 -1
- package/scripts/hooks/first-prompt-inject.mjs +230 -0
- package/scripts/hooks/precompact-flush.mjs +89 -60
- package/scripts/hooks/session-start.js +73 -9
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;
|
package/dist/wakeup.d.ts
CHANGED
|
@@ -1,37 +1,82 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* wakeup — return a
|
|
2
|
+
* wakeup — return a token-budgeted context blob at session start.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* v1.8.1: evolved from a flat top-K renderer into a section-priority
|
|
5
|
+
* context packer. `buildContextBundle` assembles a multi-section blob
|
|
6
|
+
* (identity, active_tasks, recent_decisions, known_gotchas,
|
|
7
|
+
* last_session_summary, top_weighted, semantic_fallback) where each
|
|
8
|
+
* section gets its own per-section budget and the packer greedily fills
|
|
9
|
+
* top-to-bottom until the global token budget is hit.
|
|
5
10
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
11
|
+
* `wakeup()` is retained as a thin backwards-compatibility wrapper: when
|
|
12
|
+
* called with only `tokenBudget` + `scope` (no `sections`), it routes to
|
|
13
|
+
* the `top_weighted` section alone, producing output shape-compatible
|
|
14
|
+
* with v1.8.0.
|
|
9
15
|
*
|
|
10
|
-
*
|
|
11
|
-
* to be called once at session start so the agent has a small but well-chosen
|
|
12
|
-
* window into the user's world before it ever issues a real search.
|
|
16
|
+
* Exposed via the MCP `knowledge` tool as `action: "wakeup"`.
|
|
13
17
|
*/
|
|
14
|
-
export
|
|
15
|
-
|
|
18
|
+
export type SectionName = 'identity' | 'active_tasks' | 'recent_decisions' | 'known_gotchas' | 'last_session_summary' | 'top_weighted' | 'semantic_fallback';
|
|
19
|
+
export declare const DEFAULT_SECTIONS: SectionName[];
|
|
20
|
+
export interface ContextBundleOptions {
|
|
21
|
+
/** Max total tokens (chars/4 estimate) for the rendered blob. Default 800. */
|
|
16
22
|
tokenBudget?: number;
|
|
17
|
-
/** Optional category filter
|
|
23
|
+
/** Optional category filter applied to the top_weighted section. */
|
|
18
24
|
scope?: string;
|
|
25
|
+
/** Ordered list of sections to emit. Defaults to DEFAULT_SECTIONS. */
|
|
26
|
+
sections?: SectionName[];
|
|
27
|
+
/**
|
|
28
|
+
* Per-section token-budget overrides. Unspecified sections share the
|
|
29
|
+
* remainder evenly. If omitted, all sections get an equal slice.
|
|
30
|
+
*/
|
|
31
|
+
sectionBudgets?: Partial<Record<SectionName, number>>;
|
|
19
32
|
}
|
|
20
|
-
export interface
|
|
33
|
+
export interface RenderedSection {
|
|
34
|
+
name: SectionName;
|
|
35
|
+
/** Rendered markdown for this section (already includes its heading). */
|
|
36
|
+
content: string;
|
|
37
|
+
/** Budget this section was given (in tokens). */
|
|
38
|
+
budget: number;
|
|
39
|
+
/** Tokens actually consumed. */
|
|
40
|
+
used: number;
|
|
41
|
+
/** True when the section was cut short to fit. */
|
|
42
|
+
truncated: boolean;
|
|
43
|
+
/** True when this section had no content to render. */
|
|
44
|
+
empty: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface ContextBundleResult {
|
|
21
47
|
identity: string;
|
|
48
|
+
/** v1.8.0-compatible entries view — the `top_weighted` section's picks. */
|
|
22
49
|
entries: Array<{
|
|
23
50
|
path: string;
|
|
24
51
|
title: string;
|
|
25
52
|
weight: number;
|
|
26
53
|
excerpt: string;
|
|
27
54
|
}>;
|
|
55
|
+
sections: RenderedSection[];
|
|
28
56
|
rendered: string;
|
|
29
57
|
token_estimate: number;
|
|
30
58
|
truncated: boolean;
|
|
31
59
|
}
|
|
60
|
+
export type WakeupOptions = Pick<ContextBundleOptions, 'tokenBudget' | 'scope'>;
|
|
61
|
+
export type WakeupResult = ContextBundleResult;
|
|
62
|
+
/**
|
|
63
|
+
* Build the section-priority context bundle.
|
|
64
|
+
*
|
|
65
|
+
* Greedy-fill algorithm:
|
|
66
|
+
* 1. Allocate per-section char budget (defaults to an even split).
|
|
67
|
+
* 2. For each section in priority order, render up to its budget.
|
|
68
|
+
* 3. If a section under-uses its budget, redistribute the remainder
|
|
69
|
+
* to subsequent sections.
|
|
70
|
+
* 4. Stop once total rendered chars ≥ global budget.
|
|
71
|
+
* 5. Mark `truncated: true` if any emitted section was cut.
|
|
72
|
+
*/
|
|
73
|
+
export declare function buildContextBundle(options?: ContextBundleOptions): ContextBundleResult;
|
|
32
74
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
75
|
+
* v1.8.0-compatible entry point.
|
|
76
|
+
*
|
|
77
|
+
* When invoked with only `tokenBudget` + `scope`, routes to the
|
|
78
|
+
* `top_weighted` section alone so the `rendered` output stays shape-
|
|
79
|
+
* compatible with pre-v1.8.1 callers (identity heading + L1 facts list).
|
|
35
80
|
*/
|
|
36
81
|
export declare function wakeup(options?: WakeupOptions): WakeupResult;
|
|
37
82
|
//# sourceMappingURL=wakeup.d.ts.map
|
package/dist/wakeup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wakeup.d.ts","sourceRoot":"","sources":["../src/wakeup.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"wakeup.d.ts","sourceRoot":"","sources":["../src/wakeup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAWH,MAAM,MAAM,WAAW,GACnB,UAAU,GACV,cAAc,GACd,kBAAkB,GAClB,eAAe,GACf,sBAAsB,GACtB,cAAc,GACd,mBAAmB,CAAC;AAExB,eAAO,MAAM,gBAAgB,EAAE,WAAW,EAQzC,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACnC,8EAA8E;IAC9E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IACzB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;CACvD;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,WAAW,CAAC;IAClB,yEAAyE;IACzE,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,SAAS,EAAE,OAAO,CAAC;IACnB,uDAAuD;IACvD,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjF,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;CACpB;AAGD,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,oBAAoB,EAAE,aAAa,GAAG,OAAO,CAAC,CAAC;AAChF,MAAM,MAAM,YAAY,GAAG,mBAAmB,CAAC;AA0X/C;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,oBAAyB,GAAG,mBAAmB,CA6H1F;AAID;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,YAAY,CAMhE"}
|