agentcache 0.4.0 → 0.4.2

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/dist/mcp.js CHANGED
@@ -7,14 +7,17 @@ import {
7
7
  startCompile
8
8
  } from "./chunk-CUBZRYS5.js";
9
9
  import {
10
- parseTranscript
11
- } from "./chunk-IGCH7SZT.js";
10
+ computeCanonicalHash
11
+ } from "./chunk-GGAATZKM.js";
12
12
  import {
13
13
  spawnCompileAll
14
14
  } from "./chunk-JUDLOBOC.js";
15
15
  import {
16
- computeCanonicalHash
17
- } from "./chunk-GGAATZKM.js";
16
+ SqliteKnowledgeRepository
17
+ } from "./chunk-PSASDZQE.js";
18
+ import {
19
+ parseTranscript
20
+ } from "./chunk-WTXSZBQE.js";
18
21
  import {
19
22
  findProjectRoot,
20
23
  getDataDir,
@@ -22,9 +25,6 @@ import {
22
25
  getProjectId,
23
26
  isInitialized
24
27
  } from "./chunk-T4COG3XD.js";
25
- import {
26
- SqliteKnowledgeRepository
27
- } from "./chunk-ESDTP63R.js";
28
28
  import "./chunk-KFQGP6VL.js";
29
29
 
30
30
  // src/mcp.ts
@@ -92,9 +92,34 @@ function checkForUpdates() {
92
92
  }
93
93
 
94
94
  // src/mcp.ts
95
- import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
95
+ import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
96
+
97
+ // src/utils/config.ts
98
+ import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
99
+ import { join as join2 } from "path";
100
+ var DEFAULT_CONFIG = {
101
+ security: "auto"
102
+ };
103
+ function getConfigPath() {
104
+ return join2(getDataDir(), "config.json");
105
+ }
106
+ function getConfig() {
107
+ const path = getConfigPath();
108
+ if (!existsSync2(path)) return { ...DEFAULT_CONFIG };
109
+ try {
110
+ const raw = JSON.parse(readFileSync2(path, "utf-8"));
111
+ return { ...DEFAULT_CONFIG, ...raw };
112
+ } catch {
113
+ return { ...DEFAULT_CONFIG };
114
+ }
115
+ }
116
+ function saveConfig(config) {
117
+ writeFileSync2(getConfigPath(), JSON.stringify(config, null, 2), "utf-8");
118
+ }
119
+
120
+ // src/mcp.ts
96
121
  import { randomUUID } from "crypto";
97
- var PKG_VERSION = JSON.parse(readFileSync2(new URL("../package.json", import.meta.url), "utf-8")).version;
122
+ var PKG_VERSION = JSON.parse(readFileSync3(new URL("../package.json", import.meta.url), "utf-8")).version;
98
123
  function defaultScope(type) {
99
124
  return type === "rule" || type === "lesson" ? "global" : "project";
100
125
  }
@@ -117,6 +142,17 @@ function getResolvedProjectRoot() {
117
142
  function getResolvedProjectId() {
118
143
  return getProjectId(getResolvedProjectRoot());
119
144
  }
145
+ function migrateToV04() {
146
+ const config = getConfig();
147
+ if (config.migrated_v04) return;
148
+ try {
149
+ const repo = new SqliteKnowledgeRepository(getDbPath());
150
+ repo.grandfatherExistingItems();
151
+ repo.close();
152
+ saveConfig({ ...config, migrated_v04: true });
153
+ } catch {
154
+ }
155
+ }
120
156
  async function startMcpServer() {
121
157
  const server = new Server(
122
158
  { name: "agentcache", version: PKG_VERSION },
@@ -128,6 +164,7 @@ async function startMcpServer() {
128
164
  server.oninitialized = async () => {
129
165
  await resolveRoots(server);
130
166
  checkForUpdates();
167
+ migrateToV04();
131
168
  };
132
169
  server.setNotificationHandler(RootsListChangedNotificationSchema, async () => {
133
170
  await resolveRoots(server);
@@ -273,7 +310,8 @@ async function startMcpServer() {
273
310
  case "inject_context": {
274
311
  const args = request.params.arguments || {};
275
312
  const project = args.project || detectedProject;
276
- const items = repo.getKnowledgeForContext(project);
313
+ const securityMode = getConfig().security;
314
+ const items = repo.getKnowledgeForContext(project, { userOnly: securityMode === "review" });
277
315
  const rules = items.filter((i) => i.type === "rule").slice(0, 20);
278
316
  const lessons = items.filter((i) => i.type === "lesson").slice(0, 10);
279
317
  const decisions = items.filter((i) => i.type === "decision").slice(0, 10);
@@ -322,6 +360,10 @@ ${quarantined.length} observation(s) pending review \u2014 run \`agentcache revi
322
360
  return { content: [{ type: "text", text: output.trim() }] };
323
361
  }
324
362
  case "compile_submit": {
363
+ const securityMode = getConfig().security;
364
+ if (securityMode === "locked") {
365
+ return { content: [{ type: "text", text: JSON.stringify({ error: "compile_submit disabled \u2014 security mode is 'locked'. Use compile-all for batch processing." }) }], isError: true };
366
+ }
325
367
  const args = request.params.arguments;
326
368
  const project = args.project || detectedProject;
327
369
  const sessionId = `sess_${randomUUID().slice(0, 8)}`;
@@ -348,7 +390,7 @@ ${quarantined.length} observation(s) pending review \u2014 run \`agentcache revi
348
390
  if (!entry) {
349
391
  return { content: [{ type: "text", text: JSON.stringify({ message: "No pending sessions to compile." }) }] };
350
392
  }
351
- if (!existsSync2(entry.transcriptPath)) {
393
+ if (!existsSync3(entry.transcriptPath)) {
352
394
  return { content: [{ type: "text", text: JSON.stringify({ message: `Transcript not found: ${entry.transcriptPath}, skipped.` }) }] };
353
395
  }
354
396
  const events = parseTranscript(entry.transcriptPath);
@@ -2,18 +2,20 @@ import {
2
2
  spawnCompileAll
3
3
  } from "./chunk-JUDLOBOC.js";
4
4
  import {
5
- detectInstalledIdes,
6
5
  registerClaudeHooks,
7
6
  registerMcpServer
8
- } from "./chunk-JVLMZU5I.js";
7
+ } from "./chunk-SLRKWMSE.js";
8
+ import {
9
+ SqliteKnowledgeRepository
10
+ } from "./chunk-PSASDZQE.js";
11
+ import {
12
+ detectInstalledIdes
13
+ } from "./chunk-5UO7NJPQ.js";
9
14
  import {
10
15
  getDataDir,
11
16
  getDbPath,
12
17
  migrateFromLegacy
13
18
  } from "./chunk-T4COG3XD.js";
14
- import {
15
- SqliteKnowledgeRepository
16
- } from "./chunk-ESDTP63R.js";
17
19
  import "./chunk-KFQGP6VL.js";
18
20
 
19
21
  // src/postinstall.ts
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  evaluatePolicy
3
3
  } from "./chunk-T7BJPANN.js";
4
+ import {
5
+ SqliteKnowledgeRepository
6
+ } from "./chunk-PSASDZQE.js";
4
7
  import {
5
8
  findProjectRoot,
6
9
  getDbPath,
7
10
  getProjectId,
8
11
  isInitialized
9
12
  } from "./chunk-T4COG3XD.js";
10
- import {
11
- SqliteKnowledgeRepository
12
- } from "./chunk-ESDTP63R.js";
13
13
  import "./chunk-KFQGP6VL.js";
14
14
 
15
15
  // src/hooks/pre-tool-use.ts
@@ -1,17 +1,18 @@
1
+ import {
2
+ SqliteKnowledgeRepository
3
+ } from "./chunk-PSASDZQE.js";
1
4
  import {
2
5
  findAllClaudeTranscripts,
3
6
  findAllCodexTranscripts,
4
7
  findAllContinueTranscripts,
8
+ findAllCursorTranscripts,
5
9
  findAllRooCodeTranscripts
6
- } from "./chunk-IGCH7SZT.js";
10
+ } from "./chunk-WTXSZBQE.js";
7
11
  import {
8
12
  getDbPath,
9
13
  getProjectId,
10
14
  isInitialized
11
15
  } from "./chunk-T4COG3XD.js";
12
- import {
13
- SqliteKnowledgeRepository
14
- } from "./chunk-ESDTP63R.js";
15
16
  import "./chunk-KFQGP6VL.js";
16
17
 
17
18
  // src/hooks/session-start.ts
@@ -19,6 +20,14 @@ import { statSync } from "fs";
19
20
  import { basename, dirname } from "path";
20
21
  import { randomUUID } from "crypto";
21
22
  function inferProjectRootFromTranscriptPath(path) {
23
+ if (path.includes(".claude/projects/")) {
24
+ const slug2 = path.split(".claude/projects/")[1]?.split("/")[0] || "";
25
+ if (slug2.startsWith("-")) return slug2.replace(/-/g, "/");
26
+ }
27
+ if (path.includes(".cursor/projects/")) {
28
+ const slug2 = path.split(".cursor/projects/")[1]?.split("/")[0] || "";
29
+ if (slug2) return "/" + slug2.replace(/-/g, "/");
30
+ }
22
31
  const dir = dirname(path);
23
32
  const slug = basename(dir);
24
33
  if (slug.startsWith("-")) {
@@ -32,6 +41,7 @@ async function handleSessionStart() {
32
41
  const compiledPaths = new Set(repo.getAllCompiledTranscriptPaths());
33
42
  const allTranscripts = [
34
43
  ...findAllClaudeTranscripts(),
44
+ ...findAllCursorTranscripts(),
35
45
  ...findAllContinueTranscripts(),
36
46
  ...findAllCodexTranscripts(),
37
47
  ...findAllRooCodeTranscripts()
@@ -1,16 +1,18 @@
1
1
  import {
2
- detectInstalledIdes,
3
2
  registerClaudeHooks,
4
3
  registerMcpServer
5
- } from "./chunk-JVLMZU5I.js";
4
+ } from "./chunk-SLRKWMSE.js";
5
+ import {
6
+ SqliteKnowledgeRepository
7
+ } from "./chunk-PSASDZQE.js";
8
+ import {
9
+ detectInstalledIdes
10
+ } from "./chunk-5UO7NJPQ.js";
6
11
  import {
7
12
  getDataDir,
8
13
  getDbPath,
9
14
  migrateFromLegacy
10
15
  } from "./chunk-T4COG3XD.js";
11
- import {
12
- SqliteKnowledgeRepository
13
- } from "./chunk-ESDTP63R.js";
14
16
  import "./chunk-KFQGP6VL.js";
15
17
 
16
18
  // src/setup.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SqliteKnowledgeRepository
3
- } from "./chunk-ESDTP63R.js";
3
+ } from "./chunk-PSASDZQE.js";
4
4
  import "./chunk-KFQGP6VL.js";
5
5
  export {
6
6
  SqliteKnowledgeRepository
@@ -1,12 +1,12 @@
1
+ import {
2
+ SqliteKnowledgeRepository
3
+ } from "./chunk-PSASDZQE.js";
1
4
  import {
2
5
  findProjectRoot,
3
6
  getDbPath,
4
7
  getProjectId,
5
8
  isInitialized
6
9
  } from "./chunk-T4COG3XD.js";
7
- import {
8
- SqliteKnowledgeRepository
9
- } from "./chunk-ESDTP63R.js";
10
10
  import "./chunk-KFQGP6VL.js";
11
11
 
12
12
  // src/hooks/stop.ts
@@ -0,0 +1,24 @@
1
+ import {
2
+ findAllClaudeTranscripts,
3
+ findAllCodexTranscripts,
4
+ findAllContinueTranscripts,
5
+ findAllCursorTranscripts,
6
+ findAllGooseSessionIds,
7
+ findAllRooCodeTranscripts,
8
+ findLatestTranscript,
9
+ getGooseDbPath,
10
+ parseTranscript
11
+ } from "./chunk-WTXSZBQE.js";
12
+ import "./chunk-T4COG3XD.js";
13
+ import "./chunk-KFQGP6VL.js";
14
+ export {
15
+ findAllClaudeTranscripts,
16
+ findAllCodexTranscripts,
17
+ findAllContinueTranscripts,
18
+ findAllCursorTranscripts,
19
+ findAllGooseSessionIds,
20
+ findAllRooCodeTranscripts,
21
+ findLatestTranscript,
22
+ getGooseDbPath,
23
+ parseTranscript
24
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentcache",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
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",