agentcache 0.2.0 → 0.2.4

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/README.md CHANGED
@@ -58,8 +58,8 @@ No `init`. No `setup`. No config. No second command. The install itself:
58
58
 
59
59
  ### The Cycle
60
60
 
61
- 1. **Session starts** — agent calls `agentcache_inject_context` → gets compiled rules, lessons, decisions
62
- 2. **During session** — agent calls `agentcache_compile_submit` incrementally as it learns things
61
+ 1. **Session starts** — agent calls `inject_context` → gets compiled rules, lessons, decisions
62
+ 2. **During session** — agent calls `compile_submit` incrementally as it learns things
63
63
  3. **Session ends** — knowledge is already saved. If agent didn't submit (abrupt exit), transcript recovery handles it next session.
64
64
 
65
65
  ### Knowledge Types
@@ -75,18 +75,18 @@ Rules and lessons are **global** — they apply to all your projects. Decisions
75
75
 
76
76
  ## MCP Tools
77
77
 
78
- AgentCache exposes 8 tools via the Model Context Protocol:
78
+ AgentCache exposes 8 tools via the Model Context Protocol (prefixed as `mcp--agentcache--<tool>` in IDEs):
79
79
 
80
80
  | Tool | Purpose |
81
81
  |------|---------|
82
- | `agentcache_inject_context` | Load compiled knowledge at session start |
83
- | `agentcache_compile_submit` | Submit observations incrementally during session |
84
- | `agentcache_compile_cluster` | Resolve clustering when observations overlap existing knowledge |
85
- | `agentcache_compile_extract` | Process queued transcripts from previous sessions |
86
- | `agentcache_enforce` | Check tool calls against enforced policy rules |
87
- | `agentcache_save_observation` | Save a permanent observation (USER authority, never auto-deprecated) |
88
- | `agentcache_get_knowledge` | Query the knowledge database |
89
- | `agentcache_deprecate_knowledge` | Mark knowledge as deprecated when it's no longer valid |
82
+ | `inject_context` | Load compiled knowledge at session start |
83
+ | `compile_submit` | Submit observations incrementally during session |
84
+ | `compile_cluster` | Resolve clustering when observations overlap existing knowledge |
85
+ | `compile_extract` | Process queued transcripts from previous sessions |
86
+ | `enforce` | Check tool calls against enforced policy rules |
87
+ | `save_observation` | Save a permanent observation (USER authority, never auto-deprecated) |
88
+ | `get_knowledge` | Query the knowledge database |
89
+ | `deprecate_knowledge` | Mark knowledge as deprecated when it's no longer valid |
90
90
 
91
91
  ## CLI Commands
92
92
 
@@ -90,14 +90,14 @@ function isVscodeExtensionIde(ide) {
90
90
  return ide.name === "Roo Code" || ide.name === "Continue";
91
91
  }
92
92
  var ALL_TOOLS = [
93
- "agentcache_inject_context",
94
- "agentcache_compile_submit",
95
- "agentcache_compile_cluster",
96
- "agentcache_compile_extract",
97
- "agentcache_enforce",
98
- "agentcache_save_observation",
99
- "agentcache_get_knowledge",
100
- "agentcache_deprecate_knowledge"
93
+ "inject_context",
94
+ "compile_submit",
95
+ "compile_cluster",
96
+ "compile_extract",
97
+ "enforce",
98
+ "save_observation",
99
+ "get_knowledge",
100
+ "deprecate_knowledge"
101
101
  ];
102
102
  function registerMcpServer(ide) {
103
103
  if (!ide.detected) return false;
@@ -149,18 +149,16 @@ function registerClaudeCode() {
149
149
  }
150
150
  if (!settings.permissions) settings.permissions = {};
151
151
  if (!settings.permissions.allow) settings.permissions.allow = [];
152
- const allowList = settings.permissions.allow;
152
+ let allowList = settings.permissions.allow;
153
+ allowList = allowList.filter((p) => !p.startsWith("mcp__agentcache__loop_") && !p.startsWith("mcp__agentcache__agentcache_"));
154
+ settings.permissions.allow = allowList;
153
155
  const mcpPerms = ALL_TOOLS.map((t) => `mcp__agentcache__${t}`);
154
- let permsUpdated = false;
155
156
  for (const perm of mcpPerms) {
156
157
  if (!allowList.includes(perm)) {
157
158
  allowList.push(perm);
158
- permsUpdated = true;
159
159
  }
160
160
  }
161
- if (permsUpdated) {
162
- writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
163
- }
161
+ writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
164
162
  }
165
163
  return serverRegistered;
166
164
  }
@@ -184,35 +182,28 @@ function registerMcpJson(ide) {
184
182
  alwaysAllow: ALL_TOOLS,
185
183
  disabled: false
186
184
  };
187
- } else if (!existing) {
185
+ } else {
188
186
  const agentcacheBin = findAgentcacheScript();
189
187
  config.mcpServers.agentcache = {
190
188
  command: agentcacheBin,
191
- args: ["serve"]
189
+ args: ["serve"],
190
+ alwaysAllow: ALL_TOOLS
192
191
  };
193
- } else {
194
- return false;
195
192
  }
196
193
  mkdirSync(dirname(ide.mcpConfigPath), { recursive: true });
197
194
  writeFileSync(ide.mcpConfigPath, JSON.stringify(config, null, 2));
198
- return !existing;
195
+ return true;
199
196
  }
200
197
  function registerContinue(ide) {
201
198
  const configPath = ide.mcpConfigPath;
202
- if (existsSync2(configPath)) {
203
- try {
204
- const existing = JSON.parse(readFileSync(configPath, "utf-8"));
205
- if (existing.mcpServers?.agentcache) return false;
206
- } catch {
207
- }
208
- }
209
199
  const nodeBin = findNodeBinary();
210
200
  const script = findAgentcacheScript();
211
201
  const config = {
212
202
  mcpServers: {
213
203
  agentcache: {
214
204
  command: nodeBin,
215
- args: [script, "serve"]
205
+ args: [script, "serve"],
206
+ alwaysAllow: ALL_TOOLS
216
207
  }
217
208
  }
218
209
  };
package/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ import { Command } from "commander";
5
5
  var program = new Command();
6
6
  program.name("agentcache").description("Engineering Knowledge Compiler \u2014 universal, zero-config").version("0.3.0");
7
7
  program.command("setup").description("Detect IDEs and register AgentCache (runs automatically on install)").action(async () => {
8
- const { runSetup } = await import("./setup-YCFTG2KT.js");
8
+ const { runSetup } = await import("./setup-TVSEXURZ.js");
9
9
  await runSetup();
10
10
  });
11
11
  program.command("serve").description("Start AgentCache MCP server (spawned by IDEs automatically)").action(async () => {
package/dist/mcp.js CHANGED
@@ -570,7 +570,7 @@ async function startMcpServer() {
570
570
  { name: "agentcache", version: "0.1.0" },
571
571
  {
572
572
  capabilities: { tools: {} },
573
- instructions: "AgentCache is your knowledge cache. At the START of every session, call agentcache_inject_context to load compiled rules, lessons, decisions, and context. Submit observations INCREMENTALLY via agentcache_compile_submit as you learn them \u2014 do not wait until session end."
573
+ instructions: "AgentCache is your knowledge cache. At the START of every session, call inject_context to load compiled rules, lessons, decisions, and context. Submit observations INCREMENTALLY via compile_submit as you learn them \u2014 do not wait until session end."
574
574
  }
575
575
  );
576
576
  server.oninitialized = async () => {
@@ -582,7 +582,7 @@ async function startMcpServer() {
582
582
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
583
583
  tools: [
584
584
  {
585
- name: "agentcache_inject_context",
585
+ name: "inject_context",
586
586
  description: "Get compiled engineering knowledge for this project. Returns global rules/lessons (apply everywhere) + project-specific decisions/context. Call this at the START of every session.",
587
587
  inputSchema: {
588
588
  type: "object",
@@ -593,7 +593,7 @@ async function startMcpServer() {
593
593
  }
594
594
  },
595
595
  {
596
- name: "agentcache_compile_submit",
596
+ name: "compile_submit",
597
597
  description: "Submit observations extracted from your session. Call this INCREMENTALLY \u2014 each time you learn a rule, lesson, decision, or context item. Do NOT batch until end of session; sessions can terminate without warning.",
598
598
  inputSchema: {
599
599
  type: "object",
@@ -619,12 +619,12 @@ async function startMcpServer() {
619
619
  }
620
620
  },
621
621
  {
622
- name: "agentcache_compile_cluster",
623
- description: "Submit clustering decisions when agentcache_compile_submit returns needs_clustering. Determines whether observations create new knowledge or relate to existing items.",
622
+ name: "compile_cluster",
623
+ description: "Submit clustering decisions when compile_submit returns needs_clustering. Determines whether observations create new knowledge or relate to existing items.",
624
624
  inputSchema: {
625
625
  type: "object",
626
626
  properties: {
627
- sessionId: { type: "string", description: "Session ID from agentcache_compile_submit response" },
627
+ sessionId: { type: "string", description: "Session ID from compile_submit response" },
628
628
  clusters: {
629
629
  type: "array",
630
630
  items: {
@@ -644,8 +644,8 @@ async function startMcpServer() {
644
644
  }
645
645
  },
646
646
  {
647
- name: "agentcache_compile_extract",
648
- description: "For PREVIOUS sessions stored as transcript files. Reads a queued transcript and returns an extraction prompt for you to process. After processing, call agentcache_compile_submit with the results.",
647
+ name: "compile_extract",
648
+ description: "For PREVIOUS sessions stored as transcript files. Reads a queued transcript and returns an extraction prompt for you to process. After processing, call compile_submit with the results.",
649
649
  inputSchema: {
650
650
  type: "object",
651
651
  properties: {
@@ -655,7 +655,7 @@ async function startMcpServer() {
655
655
  }
656
656
  },
657
657
  {
658
- name: "agentcache_enforce",
658
+ name: "enforce",
659
659
  description: "Check if a tool call is allowed by AgentCache policy rules. Call this BEFORE executing risky operations (file deletions, force pushes, etc). Returns allow or block with reason.",
660
660
  inputSchema: {
661
661
  type: "object",
@@ -668,7 +668,7 @@ async function startMcpServer() {
668
668
  }
669
669
  },
670
670
  {
671
- name: "agentcache_save_observation",
671
+ name: "save_observation",
672
672
  description: "Save a single observation immediately with USER authority (never overwritten by compiler). Use for important rules or decisions that should persist permanently.",
673
673
  inputSchema: {
674
674
  type: "object",
@@ -683,7 +683,7 @@ async function startMcpServer() {
683
683
  }
684
684
  },
685
685
  {
686
- name: "agentcache_get_knowledge",
686
+ name: "get_knowledge",
687
687
  description: "Query knowledge items from AgentCache knowledge database.",
688
688
  inputSchema: {
689
689
  type: "object",
@@ -697,7 +697,7 @@ async function startMcpServer() {
697
697
  }
698
698
  },
699
699
  {
700
- name: "agentcache_deprecate_knowledge",
700
+ name: "deprecate_knowledge",
701
701
  description: "Mark a knowledge item as deprecated. Use when a rule, lesson, or decision is no longer valid. Works on both auto-compiled and user-saved items.",
702
702
  inputSchema: {
703
703
  type: "object",
@@ -719,7 +719,7 @@ async function startMcpServer() {
719
719
  const detectedProject = getResolvedProjectId();
720
720
  try {
721
721
  switch (request.params.name) {
722
- case "agentcache_inject_context": {
722
+ case "inject_context": {
723
723
  const args = request.params.arguments || {};
724
724
  const project = args.project || detectedProject;
725
725
  const items = repo.getKnowledgeForContext(project);
@@ -742,15 +742,20 @@ async function startMcpServer() {
742
742
  }
743
743
  if (!output) output = "No compiled knowledge yet. This will populate as you use AgentCache across sessions.\n";
744
744
  const pendingCount = repo.getPendingCount();
745
- if (pendingCount > 0) {
746
- output = `<!-- ${pendingCount} previous session(s) pending compilation. Call agentcache_compile_extract to process. -->
747
-
748
- ` + output;
745
+ if (pendingCount > 20) {
746
+ output += `
747
+ ---
748
+ KNOWLEDGE COMPILATION AVAILABLE: You have ${pendingCount} past sessions that haven't been compiled into knowledge yet. Ask the user: "I can compile knowledge from your past ${pendingCount} sessions (~60s). Process now or later?" If they agree, call compile_extract up to 5 times, submitting results with compile_submit after each. If they decline, move on.
749
+ `;
750
+ } else if (pendingCount > 0) {
751
+ output += `
752
+ <!-- ${pendingCount} session(s) pending compilation (below threshold, will process when backlog grows). -->
753
+ `;
749
754
  }
750
- output += "\n---\nIMPORTANT: Submit observations incrementally as they happen during this session.\nWhen you learn something (rule, lesson, decision, context), call agentcache_compile_submit immediately.\nDo NOT wait until the end \u2014 sessions can terminate without warning.\n";
755
+ output += "\n---\nIMPORTANT: Submit observations incrementally as they happen during this session.\nWhen you learn something (rule, lesson, decision, context), call compile_submit immediately.\nDo NOT wait until the end \u2014 sessions can terminate without warning.\n";
751
756
  return { content: [{ type: "text", text: output.trim() }] };
752
757
  }
753
- case "agentcache_compile_submit": {
758
+ case "compile_submit": {
754
759
  const args = request.params.arguments;
755
760
  const project = args.project || detectedProject;
756
761
  const sessionId = `sess_${randomUUID4().slice(0, 8)}`;
@@ -768,14 +773,14 @@ async function startMcpServer() {
768
773
  content: [{ type: "text", text: JSON.stringify({ status: "needs_clustering", sessionId: result.sessionId, clusteringContext: result.clusteringPrompt }) }]
769
774
  };
770
775
  }
771
- case "agentcache_compile_cluster": {
776
+ case "compile_cluster": {
772
777
  const args = request.params.arguments;
773
778
  const project = args.project || detectedProject;
774
779
  const responseText = JSON.stringify({ clusters: args.clusters });
775
780
  const result = processClustering(repo, responseText, args.sessionId, project, projectRoot);
776
781
  return { content: [{ type: "text", text: JSON.stringify({ status: "complete", diagnostics: result.diagnostics }) }] };
777
782
  }
778
- case "agentcache_compile_extract": {
783
+ case "compile_extract": {
779
784
  const args = request.params.arguments || {};
780
785
  const entry = repo.popPendingTranscript();
781
786
  if (!entry) {
@@ -793,14 +798,14 @@ async function startMcpServer() {
793
798
  const state = startCompile(events, sessionId, project, entry.projectRoot || projectRoot, repo, entry.transcriptPath);
794
799
  return { content: [{ type: "text", text: JSON.stringify({ sessionId: state.sessionId, prompt: state.prompt }) }] };
795
800
  }
796
- case "agentcache_enforce": {
801
+ case "enforce": {
797
802
  const args = request.params.arguments;
798
803
  const project = args.project || detectedProject;
799
804
  const input = { tool_name: args.tool_name, tool_input: args.tool_input || {} };
800
805
  const result = evaluatePolicy(input, repo.getEnforcedRules(project));
801
806
  return { content: [{ type: "text", text: JSON.stringify(result) }] };
802
807
  }
803
- case "agentcache_save_observation": {
808
+ case "save_observation": {
804
809
  const args = request.params.arguments;
805
810
  const project = args.project || detectedProject;
806
811
  const scope = args.scope || defaultScope(args.type);
@@ -849,7 +854,7 @@ async function startMcpServer() {
849
854
  });
850
855
  return { content: [{ type: "text", text: JSON.stringify({ saved: true, scope }) }] };
851
856
  }
852
- case "agentcache_get_knowledge": {
857
+ case "get_knowledge": {
853
858
  const args = request.params.arguments || {};
854
859
  const project = args.project || detectedProject;
855
860
  const items = repo.getKnowledgeItems(project, {
@@ -860,7 +865,7 @@ async function startMcpServer() {
860
865
  const summary = filtered.map((i) => `[${i.id}] [${i.scope}/${i.confidence}] (${i.type}) ${i.content}`).join("\n");
861
866
  return { content: [{ type: "text", text: summary || "No knowledge items found." }] };
862
867
  }
863
- case "agentcache_deprecate_knowledge": {
868
+ case "deprecate_knowledge": {
864
869
  const args = request.params.arguments;
865
870
  const item = repo.getKnowledgeItem(args.id);
866
871
  if (!item) {
@@ -2,7 +2,7 @@ import {
2
2
  detectInstalledIdes,
3
3
  registerClaudeHooks,
4
4
  registerMcpServer
5
- } from "./chunk-LDQPTAZ7.js";
5
+ } from "./chunk-H3S3HDHK.js";
6
6
  import {
7
7
  getDataDir,
8
8
  getDbPath,
@@ -2,7 +2,7 @@ import {
2
2
  detectInstalledIdes,
3
3
  registerClaudeHooks,
4
4
  registerMcpServer
5
- } from "./chunk-LDQPTAZ7.js";
5
+ } from "./chunk-H3S3HDHK.js";
6
6
  import {
7
7
  getDataDir,
8
8
  getDbPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentcache",
3
- "version": "0.2.0",
3
+ "version": "0.2.4",
4
4
  "description": "Knowledge cache for AI agents — learns how you work, remembers across sessions, works everywhere",
5
5
  "type": "module",
6
6
  "license": "MIT",