agent-knowledge 1.9.8 → 2.0.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.
Files changed (98) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +39 -41
  3. package/dist/events.d.ts +10 -0
  4. package/dist/events.d.ts.map +1 -0
  5. package/dist/events.js +23 -0
  6. package/dist/events.js.map +1 -0
  7. package/dist/index.js +19 -13
  8. package/dist/index.js.map +1 -1
  9. package/dist/knowledge/consolidate.d.ts +2 -2
  10. package/dist/knowledge/consolidate.js +2 -2
  11. package/dist/knowledge/freshness.js +1 -1
  12. package/dist/knowledge/freshness.js.map +1 -1
  13. package/dist/knowledge/git.d.ts.map +1 -1
  14. package/dist/knowledge/git.js +2 -3
  15. package/dist/knowledge/git.js.map +1 -1
  16. package/dist/knowledge/promote.js +1 -1
  17. package/dist/knowledge/promote.js.map +1 -1
  18. package/dist/knowledge/reflect.js +2 -2
  19. package/dist/knowledge/reflect.js.map +1 -1
  20. package/dist/knowledge/search.d.ts +6 -0
  21. package/dist/knowledge/search.d.ts.map +1 -1
  22. package/dist/knowledge/search.js +49 -3
  23. package/dist/knowledge/search.js.map +1 -1
  24. package/dist/knowledge/store.d.ts +3 -1
  25. package/dist/knowledge/store.d.ts.map +1 -1
  26. package/dist/knowledge/store.js +2 -5
  27. package/dist/knowledge/store.js.map +1 -1
  28. package/dist/lib.d.ts +1 -1
  29. package/dist/lib.d.ts.map +1 -1
  30. package/dist/lib.js.map +1 -1
  31. package/dist/package-meta.d.ts +4 -1
  32. package/dist/package-meta.d.ts.map +1 -1
  33. package/dist/package-meta.js +18 -9
  34. package/dist/package-meta.js.map +1 -1
  35. package/dist/rest-server.d.ts +21 -0
  36. package/dist/rest-server.d.ts.map +1 -0
  37. package/dist/rest-server.js +77 -0
  38. package/dist/rest-server.js.map +1 -0
  39. package/dist/server.d.ts +1 -5
  40. package/dist/server.d.ts.map +1 -1
  41. package/dist/server.js +1 -8
  42. package/dist/server.js.map +1 -1
  43. package/dist/sessions/indexer.d.ts +4 -0
  44. package/dist/sessions/indexer.d.ts.map +1 -1
  45. package/dist/sessions/indexer.js +6 -1
  46. package/dist/sessions/indexer.js.map +1 -1
  47. package/dist/sessions/parser.d.ts.map +1 -1
  48. package/dist/sessions/parser.js +32 -2
  49. package/dist/sessions/parser.js.map +1 -1
  50. package/dist/sessions/summary.d.ts.map +1 -1
  51. package/dist/sessions/summary.js +16 -1
  52. package/dist/sessions/summary.js.map +1 -1
  53. package/dist/transport/guard.d.ts +5 -0
  54. package/dist/transport/guard.d.ts.map +1 -0
  55. package/dist/transport/guard.js +51 -0
  56. package/dist/transport/guard.js.map +1 -0
  57. package/dist/transport/http.d.ts +17 -0
  58. package/dist/transport/http.d.ts.map +1 -0
  59. package/dist/transport/http.js +97 -0
  60. package/dist/transport/http.js.map +1 -0
  61. package/dist/transport/rest.d.ts +4 -0
  62. package/dist/transport/rest.d.ts.map +1 -0
  63. package/dist/transport/rest.js +307 -0
  64. package/dist/transport/rest.js.map +1 -0
  65. package/docs/ARCHITECTURE.md +23 -34
  66. package/docs/HOOKS.md +16 -16
  67. package/docs/INGEST.md +1 -1
  68. package/docs/SETUP.md +31 -26
  69. package/docs/USER-MANUAL.md +150 -89
  70. package/package.json +17 -14
  71. package/{skills → plugin/skills}/knowledge-ingest/SKILL.md +1 -1
  72. package/scripts/hooks/session-start.js +6 -7
  73. package/scripts/hooks/sessionend-distill.mjs +5 -5
  74. package/scripts/plugins/opencode/agent-knowledge.ts +6 -6
  75. package/scripts/setup.js +8 -7
  76. package/.claude-plugin/marketplace.json +0 -19
  77. package/.claude-plugin/plugin.json +0 -12
  78. package/.mcp.json +0 -8
  79. package/agent-desk-plugin.json +0 -20
  80. package/dist/dashboard.d.ts +0 -5
  81. package/dist/dashboard.d.ts.map +0 -1
  82. package/dist/dashboard.js +0 -666
  83. package/dist/dashboard.js.map +0 -1
  84. package/dist/ui/app.js +0 -1013
  85. package/dist/ui/index.html +0 -460
  86. package/dist/ui/morphdom.min.js +0 -1
  87. package/dist/ui/render-graph.js +0 -482
  88. package/dist/ui/render-knowledge.js +0 -288
  89. package/dist/ui/render-panel.js +0 -475
  90. package/dist/ui/render-search.js +0 -105
  91. package/dist/ui/render-sessions.js +0 -237
  92. package/dist/ui/styles.css +0 -2322
  93. package/dist/ui/template.js +0 -173
  94. package/dist/ui/ui-utils.js +0 -217
  95. package/dist/ui/vis-network.min.js +0 -34
  96. package/docs/DASHBOARD.md +0 -191
  97. package/scripts/copy-ui.js +0 -14
  98. /package/{skills → plugin/skills}/knowledge-ingest/scripts/validate.mjs +0 -0
@@ -1,288 +0,0 @@
1
- /* agent-knowledge — knowledge tab rendering */
2
- (function () {
3
- 'use strict';
4
-
5
- const K = window.Knowledge;
6
-
7
- // ── Render knowledge grid ─────────────────────────────────────────────────
8
-
9
- function renderKnowledge(state, el) {
10
- const cat = state.knowledge.activeCategory;
11
- const filtered =
12
- cat === 'all'
13
- ? state.knowledge.entries
14
- : state.knowledge.entries.filter((e) => e.category === cat);
15
-
16
- if (filtered.length === 0) {
17
- K.morph(el.knowledgeGrid, '');
18
- el.knowledgeEmpty.classList.remove('hidden');
19
- return;
20
- }
21
-
22
- el.knowledgeEmpty.classList.add('hidden');
23
- K.morph(
24
- el.knowledgeGrid,
25
- filtered
26
- .map((entry) => {
27
- const cat = entry.category || 'notes';
28
- const catIcons = {
29
- projects: 'code',
30
- people: 'group',
31
- decisions: 'gavel',
32
- workflows: 'account_tree',
33
- notes: 'sticky_note_2',
34
- };
35
- const icon = catIcons[cat] || 'article';
36
- const title = entry.title || entry.path || entry.id || 'Untitled';
37
- const tags = (entry.tags || [])
38
- .slice(0, 3)
39
- .map((t) => `<span class="card-tag">${K.esc(t)}</span>`)
40
- .join('');
41
- const time = K.relativeTime(entry.updated || entry.created);
42
-
43
- const maturity = entry.maturity || 'candidate';
44
- const accessCount = entry.access_count || 0;
45
- const hasDuplicates = !!state.knowledge.duplicateClusters[entry.path || ''];
46
-
47
- return `<div class="knowledge-card${hasDuplicates ? ' has-duplicates' : ''}" data-path="${K.esc(entry.path || entry.id || '')}" tabindex="0" role="button">
48
- <div class="card-header-row">
49
- <span class="card-category" data-cat="${K.esc(cat)}">
50
- <span class="material-symbols-outlined" style="font-size:14px">${icon}</span>
51
- ${K.esc(cat)}
52
- </span>
53
- <div style="display:flex;align-items:center;gap:4px">
54
- ${hasDuplicates ? '<span class="material-symbols-outlined duplicate-warn" title="Potential duplicate detected" style="font-size:16px;color:var(--warning)">content_copy</span>' : ''}
55
- <span class="maturity-badge" data-maturity="${K.esc(maturity)}">${K.esc(maturity)}${accessCount > 0 ? ` <span class="maturity-reads">&middot; ${accessCount} reads</span>` : ''}</span>
56
- </div>
57
- </div>
58
- ${time ? `<span class="card-date">${time}</span>` : ''}
59
- <div class="card-title">${K.esc(title)}</div>
60
- ${tags ? `<div class="card-tags">${tags}</div>` : ''}
61
- </div>`;
62
- })
63
- .join(''),
64
- );
65
- }
66
-
67
- // ── Knowledge search ──────────────────────────────────────────────────────
68
-
69
- function createKnowledgeSearch(state, el) {
70
- return K.debounce(async () => {
71
- const q = (el.knowledgeSearchInput ? el.knowledgeSearchInput.value : '').trim();
72
- if (!q) {
73
- el.knowledgeSearchResults.style.display = 'none';
74
- el.knowledgeGrid.style.display = '';
75
- el.knowledgeEmpty.classList.add('hidden');
76
- K.renderKnowledge(state, el);
77
- return;
78
- }
79
- try {
80
- const params = new URLSearchParams({ q, max_results: '20' });
81
- const cat = state.knowledge.activeCategory;
82
- if (cat !== 'all') params.set('category', cat);
83
- const results = await K.api(`/knowledge/search?${params}`);
84
- renderKnowledgeSearchResults(Array.isArray(results) ? results : [], q, el);
85
- } catch (err) {
86
- K.toast(`Knowledge search failed: ${err.message}`, 'error');
87
- }
88
- }, 300);
89
- }
90
-
91
- function renderKnowledgeSearchResults(results, query, el) {
92
- if (results.length === 0) {
93
- el.knowledgeSearchResults.style.display = 'none';
94
- el.knowledgeGrid.style.display = 'none';
95
- el.knowledgeEmpty.classList.remove('hidden');
96
- el.knowledgeEmpty.querySelector('.empty-text').textContent = 'No results found';
97
- el.knowledgeEmpty.querySelector('.empty-hint').textContent =
98
- `No knowledge entries match "${query}"`;
99
- return;
100
- }
101
-
102
- el.knowledgeEmpty.classList.add('hidden');
103
- el.knowledgeGrid.style.display = 'none';
104
- el.knowledgeSearchResults.style.display = '';
105
- K.morph(
106
- el.knowledgeSearchResults,
107
- results
108
- .map((r) => {
109
- const title = r.title || r.path || '';
110
- const excerpt = r.excerpt || '';
111
- const score = r.score;
112
- const maturity = r.maturity || 'candidate';
113
- const accessCount = r.access_count || 0;
114
- const decayF = r.decay_factor;
115
- const matMult = r.maturity_multiplier;
116
- const path = r.path || '';
117
-
118
- let scoreBreakdown = '';
119
- if (score != null) {
120
- const parts = [];
121
- parts.push(`relevance: ${score.toFixed(2)}`);
122
- if (decayF != null) parts.push(`decay: ${decayF.toFixed(2)}`);
123
- if (matMult != null) parts.push(`maturity: x${matMult.toFixed(1)}`);
124
- const finalScore = score * (decayF || 1) * (matMult || 1);
125
- scoreBreakdown = `<div class="score-breakdown">Score: ${finalScore.toFixed(2)} (${parts.join(' \u00d7 ')})</div>`;
126
- }
127
-
128
- return `<div class="result-item knowledge-result-item" data-path="${K.esc(path)}" tabindex="0" role="button">
129
- <div class="result-meta">
130
- <span class="maturity-badge" data-maturity="${K.esc(maturity)}">${K.esc(maturity)}${accessCount > 0 ? ` <span class="maturity-reads">&middot; ${accessCount} reads</span>` : ''}</span>
131
- <span class="result-entry-title">${K.esc(title)}</span>
132
- ${score != null ? `<span class="score-container">${K.formatScore(score, {})}</span>` : ''}
133
- </div>
134
- <div class="result-excerpt">${K.highlightExcerpt(excerpt, query)}</div>
135
- ${scoreBreakdown}
136
- </div>`;
137
- })
138
- .join(''),
139
- );
140
- }
141
-
142
- // ── Load knowledge from API ───────────────────────────────────────────────
143
-
144
- async function loadKnowledge(state, el) {
145
- try {
146
- const data = await K.api('/knowledge');
147
- const entries = Array.isArray(data) ? data : data.entries || [];
148
- state.knowledge.entries = entries;
149
- state.stats.knowledgeCount = entries.length;
150
- K.updateStats(state, el);
151
- K.renderKnowledge(state, el);
152
- } catch (err) {
153
- K.toast(`Failed to load knowledge: ${err.message}`, 'error');
154
- }
155
- }
156
-
157
- // ── Open knowledge entry in panel ─────────────────────────────────────────
158
-
159
- async function openKnowledgePanel(path) {
160
- if (!path) return;
161
- try {
162
- const [entryRes, linksRes] = await Promise.allSettled([
163
- K.api(`/knowledge/${encodeURIComponent(path)}`),
164
- K.api(`/knowledge/${encodeURIComponent(path)}/links`),
165
- ]);
166
- const data = entryRes.status === 'fulfilled' ? entryRes.value : {};
167
- const links = linksRes.status === 'fulfilled' ? linksRes.value : [];
168
- const title = data.title || data.path || path;
169
- const content = data.content || data.body || '';
170
- K.openPanel('knowledge', { title, content, meta: data, links, entryPath: path });
171
- } catch (err) {
172
- K.toast(`Failed to load entry: ${err.message}`, 'error');
173
- }
174
- }
175
-
176
- // ── Consolidate (duplicates) ──────────────────────────────────────────────
177
-
178
- async function loadConsolidate(state, el) {
179
- try {
180
- K.toast('Scanning for duplicates...', 'info', 2000);
181
- const report = await K.api('/knowledge/consolidate');
182
- state.knowledge.duplicateClusters = {};
183
- if (report.clusters && report.clusters.length > 0) {
184
- for (const cluster of report.clusters) {
185
- for (const entry of cluster.entries) {
186
- state.knowledge.duplicateClusters[entry.path] = cluster;
187
- }
188
- }
189
- K.renderKnowledge(state, el);
190
- K.openPanel('consolidate', report);
191
- } else {
192
- K.toast('No duplicate clusters found', 'success');
193
- }
194
- } catch (err) {
195
- K.toast(`Consolidation failed: ${err.message}`, 'error');
196
- }
197
- }
198
-
199
- // ── Reflect (unconnected entries) ─────────────────────────────────────────
200
-
201
- async function loadReflect() {
202
- try {
203
- K.toast('Finding unconnected entries...', 'info', 2000);
204
- const result = await K.api('/knowledge/reflect');
205
- if (result.unconnectedEntries && result.unconnectedEntries.length > 0) {
206
- K.openPanel('reflect', result);
207
- } else {
208
- K.toast('All entries are connected in the graph', 'success');
209
- }
210
- } catch (err) {
211
- K.toast(`Reflect failed: ${err.message}`, 'error');
212
- }
213
- }
214
-
215
- // ── God Nodes ─────────────────────────────────────────────────────────────
216
-
217
- async function loadGodNodes() {
218
- try {
219
- K.toast('Finding most connected entries...', 'info', 2000);
220
- const result = await K.api('/knowledge/god-nodes');
221
- if (Array.isArray(result) && result.length > 0) {
222
- K.openPanel('god-nodes', result);
223
- } else {
224
- K.toast('No god nodes — graph has no edges yet', 'success');
225
- }
226
- } catch (err) {
227
- K.toast(`God nodes failed: ${err.message}`, 'error');
228
- }
229
- }
230
-
231
- // ── Bridges ───────────────────────────────────────────────────────────────
232
-
233
- async function loadBridges() {
234
- try {
235
- K.toast('Finding bridge entries...', 'info', 2000);
236
- const result = await K.api('/knowledge/bridges');
237
- if (Array.isArray(result) && result.length > 0) {
238
- K.openPanel('bridges', result);
239
- } else {
240
- K.toast('No bridges found — graph has no cross-category connections', 'success');
241
- }
242
- } catch (err) {
243
- K.toast(`Bridges failed: ${err.message}`, 'error');
244
- }
245
- }
246
-
247
- // ── Gaps ──────────────────────────────────────────────────────────────────
248
-
249
- async function loadGaps() {
250
- try {
251
- K.toast('Finding knowledge gaps...', 'info', 2000);
252
- const result = await K.api('/knowledge/gaps');
253
- if (Array.isArray(result) && result.length > 0) {
254
- K.openPanel('gaps', result);
255
- } else {
256
- K.toast('No gaps — all entries are well connected', 'success');
257
- }
258
- } catch (err) {
259
- K.toast(`Gaps failed: ${err.message}`, 'error');
260
- }
261
- }
262
-
263
- // ── Brief ─────────────────────────────────────────────────────────────────
264
-
265
- async function loadBrief() {
266
- try {
267
- const result = await K.api('/knowledge/brief');
268
- K.openPanel('brief', result);
269
- } catch (err) {
270
- K.toast(`Brief failed: ${err.message}`, 'error');
271
- }
272
- }
273
-
274
- // ── Export ──────────────────────────────────────────────────────────────────
275
-
276
- Object.assign(K, {
277
- renderKnowledge,
278
- createKnowledgeSearch,
279
- loadKnowledge,
280
- openKnowledgePanel,
281
- loadConsolidate,
282
- loadReflect,
283
- loadGodNodes,
284
- loadBridges,
285
- loadGaps,
286
- loadBrief,
287
- });
288
- })();