agentcache 0.2.0 → 0.2.3
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 +11 -11
- package/dist/{chunk-LDQPTAZ7.js → chunk-H3S3HDHK.js} +18 -27
- package/dist/cli.js +1 -1
- package/dist/mcp.js +22 -22
- package/dist/postinstall.js +1 -1
- package/dist/{setup-YCFTG2KT.js → setup-TVSEXURZ.js} +1 -1
- package/package.json +1 -1
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 `
|
|
62
|
-
2. **During session** — agent calls `
|
|
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
|
-
| `
|
|
83
|
-
| `
|
|
84
|
-
| `
|
|
85
|
-
| `
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
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
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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-
|
|
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
|
|
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: "
|
|
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: "
|
|
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: "
|
|
623
|
-
description: "Submit clustering decisions when
|
|
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
|
|
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: "
|
|
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
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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 "
|
|
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);
|
|
@@ -743,14 +743,14 @@ async function startMcpServer() {
|
|
|
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
745
|
if (pendingCount > 0) {
|
|
746
|
-
output = `<!-- ${pendingCount} previous session(s) pending compilation. Call
|
|
746
|
+
output = `<!-- ${pendingCount} previous session(s) pending compilation. Call compile_extract to process. -->
|
|
747
747
|
|
|
748
748
|
` + output;
|
|
749
749
|
}
|
|
750
|
-
output += "\n---\nIMPORTANT: Submit observations incrementally as they happen during this session.\nWhen you learn something (rule, lesson, decision, context), call
|
|
750
|
+
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
751
|
return { content: [{ type: "text", text: output.trim() }] };
|
|
752
752
|
}
|
|
753
|
-
case "
|
|
753
|
+
case "compile_submit": {
|
|
754
754
|
const args = request.params.arguments;
|
|
755
755
|
const project = args.project || detectedProject;
|
|
756
756
|
const sessionId = `sess_${randomUUID4().slice(0, 8)}`;
|
|
@@ -768,14 +768,14 @@ async function startMcpServer() {
|
|
|
768
768
|
content: [{ type: "text", text: JSON.stringify({ status: "needs_clustering", sessionId: result.sessionId, clusteringContext: result.clusteringPrompt }) }]
|
|
769
769
|
};
|
|
770
770
|
}
|
|
771
|
-
case "
|
|
771
|
+
case "compile_cluster": {
|
|
772
772
|
const args = request.params.arguments;
|
|
773
773
|
const project = args.project || detectedProject;
|
|
774
774
|
const responseText = JSON.stringify({ clusters: args.clusters });
|
|
775
775
|
const result = processClustering(repo, responseText, args.sessionId, project, projectRoot);
|
|
776
776
|
return { content: [{ type: "text", text: JSON.stringify({ status: "complete", diagnostics: result.diagnostics }) }] };
|
|
777
777
|
}
|
|
778
|
-
case "
|
|
778
|
+
case "compile_extract": {
|
|
779
779
|
const args = request.params.arguments || {};
|
|
780
780
|
const entry = repo.popPendingTranscript();
|
|
781
781
|
if (!entry) {
|
|
@@ -793,14 +793,14 @@ async function startMcpServer() {
|
|
|
793
793
|
const state = startCompile(events, sessionId, project, entry.projectRoot || projectRoot, repo, entry.transcriptPath);
|
|
794
794
|
return { content: [{ type: "text", text: JSON.stringify({ sessionId: state.sessionId, prompt: state.prompt }) }] };
|
|
795
795
|
}
|
|
796
|
-
case "
|
|
796
|
+
case "enforce": {
|
|
797
797
|
const args = request.params.arguments;
|
|
798
798
|
const project = args.project || detectedProject;
|
|
799
799
|
const input = { tool_name: args.tool_name, tool_input: args.tool_input || {} };
|
|
800
800
|
const result = evaluatePolicy(input, repo.getEnforcedRules(project));
|
|
801
801
|
return { content: [{ type: "text", text: JSON.stringify(result) }] };
|
|
802
802
|
}
|
|
803
|
-
case "
|
|
803
|
+
case "save_observation": {
|
|
804
804
|
const args = request.params.arguments;
|
|
805
805
|
const project = args.project || detectedProject;
|
|
806
806
|
const scope = args.scope || defaultScope(args.type);
|
|
@@ -849,7 +849,7 @@ async function startMcpServer() {
|
|
|
849
849
|
});
|
|
850
850
|
return { content: [{ type: "text", text: JSON.stringify({ saved: true, scope }) }] };
|
|
851
851
|
}
|
|
852
|
-
case "
|
|
852
|
+
case "get_knowledge": {
|
|
853
853
|
const args = request.params.arguments || {};
|
|
854
854
|
const project = args.project || detectedProject;
|
|
855
855
|
const items = repo.getKnowledgeItems(project, {
|
|
@@ -860,7 +860,7 @@ async function startMcpServer() {
|
|
|
860
860
|
const summary = filtered.map((i) => `[${i.id}] [${i.scope}/${i.confidence}] (${i.type}) ${i.content}`).join("\n");
|
|
861
861
|
return { content: [{ type: "text", text: summary || "No knowledge items found." }] };
|
|
862
862
|
}
|
|
863
|
-
case "
|
|
863
|
+
case "deprecate_knowledge": {
|
|
864
864
|
const args = request.params.arguments;
|
|
865
865
|
const item = repo.getKnowledgeItem(args.id);
|
|
866
866
|
if (!item) {
|
package/dist/postinstall.js
CHANGED