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
@@ -3,7 +3,7 @@
3
3
  // =============================================================================
4
4
  // agent-knowledge SessionStart hook
5
5
  //
6
- // 1. Announces the knowledge dashboard URL.
6
+ // 1. Says where the person browses the knowledge base (the /knowledge pane).
7
7
  // 2. Auto-loads the L0 identity section into the host's additionalContext so
8
8
  // the agent starts each session with "who the user is" already in the
9
9
  // prompt — query-agnostic facts that apply regardless of the first question.
@@ -33,14 +33,13 @@ import { homedir } from 'os';
33
33
  const __filename = fileURLToPath(import.meta.url);
34
34
  const __dirname = dirname(__filename);
35
35
 
36
- const knowledgePort = process.env.AGENT_KNOWLEDGE_PORT || '3423';
37
36
  const autoWakeEnabled =
38
37
  (process.env.AGENT_KNOWLEDGE_AUTOWAKE ?? '1').trim().toLowerCase() !== '0' &&
39
38
  (process.env.AGENT_KNOWLEDGE_AUTOWAKE ?? '1').trim().toLowerCase() !== 'false';
40
39
  const wakeupBudget = Number.parseInt(process.env.AGENT_KNOWLEDGE_WAKEUP_BUDGET ?? '200', 10) || 200;
41
40
 
42
41
  function emit(additionalContext, statusSuffix) {
43
- const base = `agent-knowledge: http://localhost:${knowledgePort}`;
42
+ const base = 'agent-knowledge: /knowledge';
44
43
  const systemMessage = statusSuffix ? `${base} | ${statusSuffix}` : base;
45
44
  const msg = {
46
45
  systemMessage,
@@ -166,11 +165,11 @@ async function main() {
166
165
  // run would skip the very next user prompt.
167
166
  const markerCleared = clearFirstPromptMarker(sessionId);
168
167
 
169
- const dashboardLine = `Knowledge: http://localhost:${knowledgePort}`;
168
+ const paneLine = 'Knowledge: the person browses the knowledge base in the /knowledge pane.';
170
169
 
171
170
  const autowakeOffSuffix = markerCleared ? `${source} · inject rearmed` : source;
172
171
  if (!autoWakeEnabled) {
173
- return emit(dashboardLine, `autowake off · ${autowakeOffSuffix}`);
172
+ return emit(paneLine, `autowake off · ${autowakeOffSuffix}`);
174
173
  }
175
174
 
176
175
  const { rendered, hasIdentity, bodyChars } = await loadIdentitySection();
@@ -192,11 +191,11 @@ async function main() {
192
191
  const onboardingBlock = onboarding === 'pending' ? ONBOARDING_INSTRUCTION : '';
193
192
 
194
193
  if (!rendered) {
195
- return emit(`${dashboardLine}${onboardingBlock}`, suffix);
194
+ return emit(`${paneLine}${onboardingBlock}`, suffix);
196
195
  }
197
196
 
198
197
  const base = [
199
- dashboardLine,
198
+ paneLine,
200
199
  '',
201
200
  '--- Knowledge wakeup (identity only; call `knowledge action=wakeup` for L1 facts) ---',
202
201
  rendered,
@@ -47,12 +47,12 @@ function appendBreadcrumb(line) {
47
47
  }
48
48
  }
49
49
 
50
- // Best-effort POST to the agent-knowledge dashboard so a live toast appears
51
- // in the UI when the session ends. Silently drops on any failure (dashboard
50
+ // Best-effort POST to the agent-knowledge REST server so the /knowledge pane
51
+ // shows the receipt when the session ends. Silently drops on any failure (server
52
52
  // not running, network error, timeout) — the disk receipts are authoritative.
53
- function postDashboardEvent(kind, message) {
53
+ function postEvent(kind, message) {
54
54
  return new Promise((resolve) => {
55
- if (process.env.AGENT_KNOWLEDGE_DASHBOARD_EVENTS === '0') {
55
+ if (process.env.AGENT_KNOWLEDGE_EVENTS === '0') {
56
56
  resolve();
57
57
  return;
58
58
  }
@@ -185,7 +185,7 @@ ${userMsgs
185
185
  if (wrote) {
186
186
  appendBreadcrumb(`- SessionEnd ${endedAt} ${sessionId} → ${file}`);
187
187
  const receipt = `${userTurns}u/${assistantTurns}a turns, ${toolUses} tool uses → ${file}`;
188
- await postDashboardEvent('session-end', receipt);
188
+ await postEvent('session-end', receipt);
189
189
  emit(`knowledge: SessionEnd — ${receipt}`);
190
190
  } else {
191
191
  emit(`knowledge: SessionEnd — write failed for ${file}`);
@@ -6,7 +6,7 @@
6
6
  // opencode's plugin API (@opencode-ai/plugin).
7
7
  //
8
8
  // Coverage vs. the Claude hook set:
9
- // - session.created → session-start.js (dashboard announce)
9
+ // - session.created → session-start.js (announce)
10
10
  // - chat.message → first-prompt-inject.mjs (first-prompt KB inject)
11
11
  // - experimental.session.compacting → precompact-flush.mjs (save-context nudge)
12
12
  // - session.deleted → sessionend-distill.mjs (session summary file)
@@ -24,7 +24,7 @@
24
24
  // Env vars (same as the Claude hooks):
25
25
  // AGENT_KNOWLEDGE_MEMORY_DIR — knowledge base root (default ~/agent-knowledge)
26
26
  // AGENT_KNOWLEDGE_DATA_DIR — marker/cache dir (default <memory>/.data)
27
- // AGENT_KNOWLEDGE_PORT — dashboard port for search (default 3423)
27
+ // AGENT_KNOWLEDGE_PORT — REST port for search (default 3423)
28
28
  // AGENT_KNOWLEDGE_FIRSTPROMPT_INJECT — "0" / "false" / "off" to disable inject
29
29
  // AGENT_KNOWLEDGE_FIRSTPROMPT_BUDGET — max inject tokens (chars/4, clamped [100,8000])
30
30
  // AGENT_KNOWLEDGE_FIRSTPROMPT_MAX_HITS — max rendered hits (clamped [1,20])
@@ -51,7 +51,7 @@ function markerDir(): string {
51
51
  return join(dataDir(), '.first-prompt-seen');
52
52
  }
53
53
 
54
- function dashboardUrl(): string {
54
+ function restUrl(): string {
55
55
  const port = process.env.AGENT_KNOWLEDGE_PORT || '3423';
56
56
  return `http://localhost:${port}`;
57
57
  }
@@ -109,7 +109,7 @@ function shouldInject(text: string): boolean {
109
109
  return first !== '/' && first !== '!';
110
110
  }
111
111
 
112
- // ── Knowledge search via dashboard HTTP ─────────────────────────────────────
112
+ // ── Knowledge search via the REST server ─────────────────────────────────────
113
113
 
114
114
  type Hit = {
115
115
  entry?: { path?: string; category?: string; title?: string };
@@ -122,7 +122,7 @@ type Hit = {
122
122
 
123
123
  async function searchKnowledge(query: string): Promise<Hit[]> {
124
124
  try {
125
- const url = new URL(`${dashboardUrl()}/api/knowledge/search`);
125
+ const url = new URL(`${restUrl()}/api/knowledge/search`);
126
126
  url.searchParams.set('q', query);
127
127
  url.searchParams.set('max_results', String(maxHits()));
128
128
  const resp = await fetch(url, { signal: AbortSignal.timeout(3000) });
@@ -259,7 +259,7 @@ export const AgentKnowledgePlugin: Plugin = async ({ client }) => {
259
259
  await typedClient.tui?.showToast?.({
260
260
  body: {
261
261
  title: 'agent-knowledge',
262
- message: `dashboard: ${dashboardUrl()}`,
262
+ message: `knowledge base: ${memoryDir()}`,
263
263
  variant: 'info',
264
264
  duration: 3000,
265
265
  },
package/scripts/setup.js CHANGED
@@ -179,9 +179,8 @@ if (!IS_CLAUDE) {
179
179
  console.log(`
180
180
  Setup complete!
181
181
 
182
- Start the dashboard: node dist/server.js
183
182
  MCP server (stdio): node dist/index.js
184
- Dashboard URL: http://localhost:3423
183
+ REST API: http://localhost:3423 (served by the first MCP process)
185
184
  ${
186
185
  IS_OPENCODE
187
186
  ? 'OpenCode: the plugin loads automatically on next session start. See docs/SETUP.md#opencode-plugins for env-var tuning.\n'
@@ -227,7 +226,7 @@ function addUnmatchedHook(eventName, marker, command, timeout = 10) {
227
226
  console.log(` ${eventName}: added ${marker} hook`);
228
227
  }
229
228
 
230
- // SessionStart: dashboard banner
229
+ // SessionStart: /knowledge banner + L0 identity
231
230
  addUnmatchedHook(
232
231
  'SessionStart',
233
232
  'session-start.js',
@@ -282,7 +281,7 @@ console.log(' Saved settings.json');
282
281
 
283
282
  console.log('Installing knowledge-ingest skill...');
284
283
 
285
- const skillSrc = join(PROJECT_DIR, 'skills', 'knowledge-ingest', 'SKILL.md');
284
+ const skillSrc = join(PROJECT_DIR, 'plugin', 'skills', 'knowledge-ingest', 'SKILL.md');
286
285
 
287
286
  const skillDests = [
288
287
  join(HOME, '.claude', 'skills', 'knowledge-ingest', 'SKILL.md'),
@@ -307,21 +306,23 @@ if (existsSync(skillSrc)) {
307
306
  }
308
307
  }
309
308
  } else {
310
- console.log(' Warning: skills/knowledge-ingest/SKILL.md not found in repo');
309
+ console.log(' Warning: plugin/skills/knowledge-ingest/SKILL.md not found in repo');
311
310
  }
312
311
 
313
312
  console.log(`
314
313
  Setup complete!
315
314
 
316
315
  Restart Claude Code to load the new MCP server. Every session will now:
317
- - Show the knowledge dashboard URL + L0/L1 wakeup payload on start (session-start.js)
316
+ - Name the /knowledge pane and load the L0 identity on start (session-start.js)
318
317
  - Report ingest freshness on start (session-start-ingest.mjs)
319
318
  - Inject query-targeted knowledge hits on the first real user prompt (first-prompt-inject.mjs)
320
319
  - Flush a rich session summary before compaction (precompact-flush.mjs)
321
320
  - Snapshot recent user prompts before compaction (precompact-distill.mjs)
322
321
  - Dump a final session summary on exit (sessionend-distill.mjs)
323
322
 
324
- Dashboard: http://localhost:3423 (auto-starts on first MCP connection)
323
+ Browse it: /knowledge in Claude Code, with the plugin installed:
324
+ claude plugin marketplace add keshrath/agent-knowledge
325
+ claude plugin install agent-knowledge@agent-knowledge
325
326
  Knowledge base: ~/agent-knowledge/ (configurable via AGENT_KNOWLEDGE_MEMORY_DIR)
326
327
 
327
328
  See docs/HOOKS.md for details and docs/SETUP.md for manual configuration.
@@ -1,19 +0,0 @@
1
- {
2
- "name": "agent-knowledge",
3
- "owner": {
4
- "name": "keshrath"
5
- },
6
- "metadata": {
7
- "description": "Cross-session memory for AI coding agents.",
8
- "version": "1.0.0"
9
- },
10
- "plugins": [
11
- {
12
- "name": "agent-knowledge",
13
- "source": "./",
14
- "description": "Cross-session memory for AI coding agents. Git-synced Markdown knowledge base with hybrid semantic + TF-IDF search, typed knowledge graph, confidence/decay scoring, and session auto-distillation with secrets scrubbing. Reads sessions from Claude Code, Cursor, and OpenCode. Dashboard on :3423.",
15
- "category": "workflow",
16
- "tags": ["mcp", "memory", "knowledge-graph", "semantic-search"]
17
- }
18
- ]
19
- }
@@ -1,12 +0,0 @@
1
- {
2
- "name": "agent-knowledge",
3
- "description": "Cross-session memory for AI coding agents. Git-synced Markdown knowledge base with hybrid semantic + TF-IDF search, typed knowledge graph, and session auto-distillation with secrets scrubbing.",
4
- "version": "1.9.8",
5
- "author": {
6
- "name": "keshrath"
7
- },
8
- "homepage": "https://github.com/keshrath/agent-knowledge",
9
- "repository": "https://github.com/keshrath/agent-knowledge",
10
- "license": "MIT",
11
- "keywords": ["mcp", "memory", "knowledge-graph", "semantic-search", "claude-code"]
12
- }
package/.mcp.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "mcpServers": {
3
- "agent-knowledge": {
4
- "command": "npx",
5
- "args": ["-y", "agent-knowledge@^1.8.0"]
6
- }
7
- }
8
- }
@@ -1,20 +0,0 @@
1
- {
2
- "id": "agent-knowledge",
3
- "name": "Knowledge",
4
- "icon": "psychology",
5
- "version": "1.9.8",
6
- "description": "Knowledge base — entries, sessions, search, graph relationships",
7
- "ui": "./dist/ui/app.js",
8
- "css": "./dist/ui/styles.css",
9
- "uiFiles": [
10
- "ui-utils.js",
11
- "render-knowledge.js",
12
- "render-search.js",
13
- "render-sessions.js",
14
- "render-graph.js",
15
- "render-panel.js",
16
- "template.js",
17
- "app.js"
18
- ],
19
- "position": 3
20
- }
@@ -1,5 +0,0 @@
1
- import http from 'http';
2
- import { serveStatic } from 'agent-common';
3
- export declare function startDashboard(port?: number): Promise<http.Server>;
4
- export { serveStatic };
5
- //# sourceMappingURL=dashboard.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../src/dashboard.ts"],"names":[],"mappings":"AASA,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAIL,WAAW,EAIZ,MAAM,cAAc,CAAC;AAkqBtB,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAqFlE;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}