agentcache 0.1.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.
- package/LICENSE +21 -0
- package/README.md +193 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/chunk-MMSMDJ4O.js +466 -0
- package/dist/chunk-PYGRUQNL.js +45 -0
- package/dist/chunk-QGG25FWV.js +173 -0
- package/dist/chunk-RUBNVM6W.js +129 -0
- package/dist/chunk-VPEEZXLK.js +68 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +73 -0
- package/dist/mcp.d.ts +3 -0
- package/dist/mcp.js +884 -0
- package/dist/paths-TWJ7GAJY.js +21 -0
- package/dist/postinstall.d.ts +2 -0
- package/dist/postinstall.js +38 -0
- package/dist/pre-tool-use-2P5P6JWE.js +30 -0
- package/dist/session-start-ILEPFZZC.js +64 -0
- package/dist/setup-QB36C2TH.js +47 -0
- package/dist/sqlite-5V565IV3.js +7 -0
- package/dist/stop-DRL3LXFQ.js +41 -0
- package/package.json +56 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
findProjectRoot,
|
|
3
|
+
getClaudeTranscriptsDir,
|
|
4
|
+
getContinueSessionsDir,
|
|
5
|
+
getDbPath,
|
|
6
|
+
getGlobalLoopDir,
|
|
7
|
+
getProjectDisplayName,
|
|
8
|
+
getProjectId,
|
|
9
|
+
isLoopInitialized
|
|
10
|
+
} from "./chunk-VPEEZXLK.js";
|
|
11
|
+
import "./chunk-MLKGABMK.js";
|
|
12
|
+
export {
|
|
13
|
+
findProjectRoot,
|
|
14
|
+
getClaudeTranscriptsDir,
|
|
15
|
+
getContinueSessionsDir,
|
|
16
|
+
getDbPath,
|
|
17
|
+
getGlobalLoopDir,
|
|
18
|
+
getProjectDisplayName,
|
|
19
|
+
getProjectId,
|
|
20
|
+
isLoopInitialized
|
|
21
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
detectInstalledIdes,
|
|
3
|
+
registerClaudeHooks,
|
|
4
|
+
registerMcpServer
|
|
5
|
+
} from "./chunk-RUBNVM6W.js";
|
|
6
|
+
import {
|
|
7
|
+
getDbPath,
|
|
8
|
+
getGlobalLoopDir
|
|
9
|
+
} from "./chunk-VPEEZXLK.js";
|
|
10
|
+
import {
|
|
11
|
+
SqliteKnowledgeRepository
|
|
12
|
+
} from "./chunk-MMSMDJ4O.js";
|
|
13
|
+
import "./chunk-MLKGABMK.js";
|
|
14
|
+
|
|
15
|
+
// src/postinstall.ts
|
|
16
|
+
import { mkdirSync } from "fs";
|
|
17
|
+
if (process.env.CI) {
|
|
18
|
+
process.exit(0);
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
mkdirSync(getGlobalLoopDir(), { recursive: true });
|
|
22
|
+
const repo = new SqliteKnowledgeRepository(getDbPath());
|
|
23
|
+
repo.close();
|
|
24
|
+
const ides = detectInstalledIdes().filter((i) => i.detected);
|
|
25
|
+
const registered = [];
|
|
26
|
+
for (const ide of ides) {
|
|
27
|
+
if (registerMcpServer(ide)) {
|
|
28
|
+
registered.push(ide.name);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
registerClaudeHooks();
|
|
32
|
+
if (registered.length > 0) {
|
|
33
|
+
console.error(`agentcache: registered with ${registered.join(", ")}`);
|
|
34
|
+
}
|
|
35
|
+
console.error("agentcache: ready. Knowledge compiles automatically across all sessions.");
|
|
36
|
+
} catch (err) {
|
|
37
|
+
console.error(`agentcache postinstall: ${err.message}. Run 'agentcache setup' manually.`);
|
|
38
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
evaluatePolicy
|
|
3
|
+
} from "./chunk-PYGRUQNL.js";
|
|
4
|
+
import {
|
|
5
|
+
findProjectRoot,
|
|
6
|
+
getDbPath,
|
|
7
|
+
getProjectId,
|
|
8
|
+
isLoopInitialized
|
|
9
|
+
} from "./chunk-VPEEZXLK.js";
|
|
10
|
+
import {
|
|
11
|
+
SqliteKnowledgeRepository
|
|
12
|
+
} from "./chunk-MMSMDJ4O.js";
|
|
13
|
+
import "./chunk-MLKGABMK.js";
|
|
14
|
+
|
|
15
|
+
// src/hooks/pre-tool-use.ts
|
|
16
|
+
function handlePreToolUse(input) {
|
|
17
|
+
if (!isLoopInitialized()) return {};
|
|
18
|
+
const projectRoot = findProjectRoot();
|
|
19
|
+
const repo = new SqliteKnowledgeRepository(getDbPath());
|
|
20
|
+
try {
|
|
21
|
+
const project = getProjectId(projectRoot);
|
|
22
|
+
const enforcedRules = repo.getEnforcedRules(project);
|
|
23
|
+
return evaluatePolicy(input, enforcedRules);
|
|
24
|
+
} finally {
|
|
25
|
+
repo.close();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
handlePreToolUse
|
|
30
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
findAllClaudeTranscripts,
|
|
3
|
+
findAllContinueTranscripts
|
|
4
|
+
} from "./chunk-QGG25FWV.js";
|
|
5
|
+
import {
|
|
6
|
+
getDbPath,
|
|
7
|
+
getProjectId,
|
|
8
|
+
isLoopInitialized
|
|
9
|
+
} from "./chunk-VPEEZXLK.js";
|
|
10
|
+
import {
|
|
11
|
+
SqliteKnowledgeRepository
|
|
12
|
+
} from "./chunk-MMSMDJ4O.js";
|
|
13
|
+
import "./chunk-MLKGABMK.js";
|
|
14
|
+
|
|
15
|
+
// src/hooks/session-start.ts
|
|
16
|
+
import { statSync } from "fs";
|
|
17
|
+
import { basename, dirname } from "path";
|
|
18
|
+
import { randomUUID } from "crypto";
|
|
19
|
+
function inferProjectRootFromTranscriptPath(path) {
|
|
20
|
+
const dir = dirname(path);
|
|
21
|
+
const slug = basename(dir);
|
|
22
|
+
if (slug.startsWith("-")) {
|
|
23
|
+
return slug.replace(/-/g, "/");
|
|
24
|
+
}
|
|
25
|
+
return dir;
|
|
26
|
+
}
|
|
27
|
+
async function handleSessionStart() {
|
|
28
|
+
if (!isLoopInitialized()) return;
|
|
29
|
+
const repo = new SqliteKnowledgeRepository(getDbPath());
|
|
30
|
+
const compiledPaths = new Set(repo.getAllCompiledTranscriptPaths());
|
|
31
|
+
const allTranscripts = [
|
|
32
|
+
...findAllClaudeTranscripts(),
|
|
33
|
+
...findAllContinueTranscripts()
|
|
34
|
+
];
|
|
35
|
+
const oneMinuteAgo = Date.now() - 6e4;
|
|
36
|
+
const uncompiled = allTranscripts.filter((path) => {
|
|
37
|
+
if (compiledPaths.has(path)) return false;
|
|
38
|
+
try {
|
|
39
|
+
return statSync(path).mtimeMs < oneMinuteAgo;
|
|
40
|
+
} catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
if (uncompiled.length === 0) {
|
|
45
|
+
repo.close();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
for (const path of uncompiled) {
|
|
49
|
+
const projectRoot = inferProjectRootFromTranscriptPath(path);
|
|
50
|
+
const project = getProjectId(projectRoot);
|
|
51
|
+
repo.queueTranscript({
|
|
52
|
+
id: `pend_${randomUUID().slice(0, 8)}`,
|
|
53
|
+
transcriptPath: path,
|
|
54
|
+
project,
|
|
55
|
+
projectRoot,
|
|
56
|
+
provider: "discovered",
|
|
57
|
+
queuedAt: Date.now()
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
repo.close();
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
handleSessionStart
|
|
64
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
detectInstalledIdes,
|
|
3
|
+
registerClaudeHooks,
|
|
4
|
+
registerMcpServer
|
|
5
|
+
} from "./chunk-RUBNVM6W.js";
|
|
6
|
+
import {
|
|
7
|
+
getDbPath,
|
|
8
|
+
getGlobalLoopDir
|
|
9
|
+
} from "./chunk-VPEEZXLK.js";
|
|
10
|
+
import {
|
|
11
|
+
SqliteKnowledgeRepository
|
|
12
|
+
} from "./chunk-MMSMDJ4O.js";
|
|
13
|
+
import "./chunk-MLKGABMK.js";
|
|
14
|
+
|
|
15
|
+
// src/setup.ts
|
|
16
|
+
import { mkdirSync } from "fs";
|
|
17
|
+
async function runSetup() {
|
|
18
|
+
mkdirSync(getGlobalLoopDir(), { recursive: true });
|
|
19
|
+
const repo = new SqliteKnowledgeRepository(getDbPath());
|
|
20
|
+
repo.close();
|
|
21
|
+
const ides = detectInstalledIdes();
|
|
22
|
+
const detected = ides.filter((i) => i.detected);
|
|
23
|
+
console.log(`
|
|
24
|
+
Loop setup complete.`);
|
|
25
|
+
console.log(` Central DB: ${getDbPath()}
|
|
26
|
+
`);
|
|
27
|
+
if (detected.length === 0) {
|
|
28
|
+
console.log(` No IDEs detected. MCP server can still be used manually: agentcache serve
|
|
29
|
+
`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
console.log(`IDEs:`);
|
|
33
|
+
for (const ide of detected) {
|
|
34
|
+
const registered = registerMcpServer(ide);
|
|
35
|
+
console.log(` ${ide.name}: ${registered ? "MCP registered" : "already registered"}`);
|
|
36
|
+
}
|
|
37
|
+
const hooksRegistered = registerClaudeHooks();
|
|
38
|
+
if (hooksRegistered) {
|
|
39
|
+
console.log(`
|
|
40
|
+
Claude Code hooks: registered (Stop, SessionStart, PreToolUse)`);
|
|
41
|
+
}
|
|
42
|
+
console.log(`
|
|
43
|
+
Done. Loop compiles knowledge across all sessions and IDEs.`);
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
runSetup
|
|
47
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
findLatestTranscript
|
|
3
|
+
} from "./chunk-QGG25FWV.js";
|
|
4
|
+
import {
|
|
5
|
+
findProjectRoot,
|
|
6
|
+
getDbPath,
|
|
7
|
+
getProjectId,
|
|
8
|
+
isLoopInitialized
|
|
9
|
+
} from "./chunk-VPEEZXLK.js";
|
|
10
|
+
import {
|
|
11
|
+
SqliteKnowledgeRepository
|
|
12
|
+
} from "./chunk-MMSMDJ4O.js";
|
|
13
|
+
import "./chunk-MLKGABMK.js";
|
|
14
|
+
|
|
15
|
+
// src/hooks/stop.ts
|
|
16
|
+
import { randomUUID } from "crypto";
|
|
17
|
+
async function handleStop(payload) {
|
|
18
|
+
if (!isLoopInitialized()) return;
|
|
19
|
+
const transcriptPath = payload?.transcript_path || findLatestTranscript();
|
|
20
|
+
if (!transcriptPath) return;
|
|
21
|
+
const repo = new SqliteKnowledgeRepository(getDbPath());
|
|
22
|
+
const projectRoot = findProjectRoot();
|
|
23
|
+
const project = getProjectId(projectRoot);
|
|
24
|
+
const compiledPaths = new Set(repo.getAllCompiledTranscriptPaths());
|
|
25
|
+
if (compiledPaths.has(transcriptPath)) {
|
|
26
|
+
repo.close();
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
repo.queueTranscript({
|
|
30
|
+
id: `pend_${randomUUID().slice(0, 8)}`,
|
|
31
|
+
transcriptPath,
|
|
32
|
+
project,
|
|
33
|
+
projectRoot,
|
|
34
|
+
provider: "claude",
|
|
35
|
+
queuedAt: Date.now()
|
|
36
|
+
});
|
|
37
|
+
repo.close();
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
handleStop
|
|
41
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agentcache",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Knowledge cache for AI agents — learns how you work, remembers across sessions, works everywhere",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "a21.ai",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/raghav-a21ai/loop-eng"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/raghav-a21ai/loop-eng#readme",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"ai",
|
|
15
|
+
"mcp",
|
|
16
|
+
"knowledge",
|
|
17
|
+
"compiler",
|
|
18
|
+
"engineering",
|
|
19
|
+
"claude",
|
|
20
|
+
"cursor",
|
|
21
|
+
"codex",
|
|
22
|
+
"ide",
|
|
23
|
+
"llm",
|
|
24
|
+
"developer-tools"
|
|
25
|
+
],
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=20.12.0"
|
|
28
|
+
},
|
|
29
|
+
"bin": {
|
|
30
|
+
"agentcache": "dist/cli.js"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsup",
|
|
37
|
+
"prepare": "tsup",
|
|
38
|
+
"postinstall": "node dist/postinstall.js",
|
|
39
|
+
"test": "vitest run",
|
|
40
|
+
"test:watch": "vitest",
|
|
41
|
+
"dev": "tsx src/cli.ts"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
45
|
+
"better-sqlite3": "^11.0.0",
|
|
46
|
+
"commander": "^12.0.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/better-sqlite3": "^7.6.0",
|
|
50
|
+
"@types/node": "^20.12.0",
|
|
51
|
+
"tsup": "^8.0.0",
|
|
52
|
+
"tsx": "^4.0.0",
|
|
53
|
+
"typescript": "^5.5.0",
|
|
54
|
+
"vitest": "^2.0.0"
|
|
55
|
+
}
|
|
56
|
+
}
|