agentcache 0.2.4 → 0.3.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/README.md +38 -9
- package/dist/chunk-IER56P6A.js +589 -0
- package/dist/chunk-KFQGP6VL.js +33 -0
- package/dist/chunk-RXBTPJVW.js +74 -0
- package/dist/{chunk-OSFK44XC.js → chunk-TE6DBLJ5.js} +137 -3
- package/dist/cli.js +10 -6
- package/dist/compile-all-RWCAU7MO.js +461 -0
- package/dist/mcp.js +27 -532
- package/dist/{paths-LEZQCRKI.js → paths-LOLEIMI5.js} +1 -1
- package/dist/postinstall.js +8 -1
- package/dist/{pre-tool-use-TPCPTJXS.js → pre-tool-use-OWWS54XG.js} +1 -1
- package/dist/{session-start-BIY7CBXU.js → session-start-YSRUGD5N.js} +8 -4
- package/dist/{setup-TVSEXURZ.js → setup-5APZETPV.js} +1 -1
- package/dist/{sqlite-5V565IV3.js → sqlite-AUND6HGQ.js} +1 -1
- package/dist/{stop-6MKD743B.js → stop-6SROS34Q.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-MLKGABMK.js +0 -9
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getDataDir
|
|
3
|
+
} from "./chunk-WHP4Z32Z.js";
|
|
4
|
+
|
|
5
|
+
// src/utils/background-compile.ts
|
|
6
|
+
import { spawn } from "child_process";
|
|
7
|
+
import { existsSync, writeFileSync, readFileSync, unlinkSync } from "fs";
|
|
8
|
+
import { join } from "path";
|
|
9
|
+
var LOCK_FILE = "compile-all.lock";
|
|
10
|
+
var STALE_THRESHOLD_MS = 4 * 60 * 60 * 1e3;
|
|
11
|
+
function getLockPath() {
|
|
12
|
+
return join(getDataDir(), LOCK_FILE);
|
|
13
|
+
}
|
|
14
|
+
function isLocked() {
|
|
15
|
+
const lockPath = getLockPath();
|
|
16
|
+
if (!existsSync(lockPath)) return false;
|
|
17
|
+
try {
|
|
18
|
+
const content = readFileSync(lockPath, "utf-8");
|
|
19
|
+
const { pid, startedAt } = JSON.parse(content);
|
|
20
|
+
if (Date.now() - startedAt > STALE_THRESHOLD_MS) {
|
|
21
|
+
unlinkSync(lockPath);
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
process.kill(pid, 0);
|
|
26
|
+
return true;
|
|
27
|
+
} catch {
|
|
28
|
+
unlinkSync(lockPath);
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
} catch {
|
|
32
|
+
unlinkSync(lockPath);
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function spawnCompileAll() {
|
|
37
|
+
if (isLocked()) return false;
|
|
38
|
+
const agentcacheBin = process.argv[1]?.replace(/\/dist\/.*/, "/dist/cli.js") || "agentcache";
|
|
39
|
+
const isLinkedBinary = agentcacheBin.includes("dist/cli.js");
|
|
40
|
+
const cmd = isLinkedBinary ? process.execPath : "agentcache";
|
|
41
|
+
const args = isLinkedBinary ? [agentcacheBin, "compile-all"] : ["compile-all"];
|
|
42
|
+
const child = spawn(cmd, args, {
|
|
43
|
+
detached: true,
|
|
44
|
+
stdio: "ignore",
|
|
45
|
+
env: { ...process.env, AGENTCACHE_BACKGROUND: "1" }
|
|
46
|
+
});
|
|
47
|
+
child.unref();
|
|
48
|
+
try {
|
|
49
|
+
writeFileSync(getLockPath(), JSON.stringify({ pid: child.pid, startedAt: Date.now() }));
|
|
50
|
+
} catch {
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
function acquireLock() {
|
|
55
|
+
if (isLocked()) return false;
|
|
56
|
+
try {
|
|
57
|
+
writeFileSync(getLockPath(), JSON.stringify({ pid: process.pid, startedAt: Date.now() }));
|
|
58
|
+
return true;
|
|
59
|
+
} catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function releaseLock() {
|
|
64
|
+
try {
|
|
65
|
+
unlinkSync(getLockPath());
|
|
66
|
+
} catch {
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
spawnCompileAll,
|
|
72
|
+
acquireLock,
|
|
73
|
+
releaseLock
|
|
74
|
+
};
|
|
@@ -4,11 +4,12 @@ import {
|
|
|
4
4
|
} from "./chunk-WHP4Z32Z.js";
|
|
5
5
|
import {
|
|
6
6
|
__export
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-KFQGP6VL.js";
|
|
8
8
|
|
|
9
9
|
// src/utils/transcript.ts
|
|
10
10
|
import { readdirSync, statSync, existsSync } from "fs";
|
|
11
11
|
import { join } from "path";
|
|
12
|
+
import { homedir } from "os";
|
|
12
13
|
|
|
13
14
|
// src/utils/transcript-parsers/claude-jsonl.ts
|
|
14
15
|
var claude_jsonl_exports = {};
|
|
@@ -94,8 +95,94 @@ function parse2(path) {
|
|
|
94
95
|
return events;
|
|
95
96
|
}
|
|
96
97
|
|
|
98
|
+
// src/utils/transcript-parsers/codex-jsonl.ts
|
|
99
|
+
var codex_jsonl_exports = {};
|
|
100
|
+
__export(codex_jsonl_exports, {
|
|
101
|
+
canParse: () => canParse3,
|
|
102
|
+
parse: () => parse3
|
|
103
|
+
});
|
|
104
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
105
|
+
function canParse3(path) {
|
|
106
|
+
if (!path.endsWith(".jsonl")) return false;
|
|
107
|
+
return path.includes(".codex/sessions/");
|
|
108
|
+
}
|
|
109
|
+
function parse3(path) {
|
|
110
|
+
const content = readFileSync3(path, "utf-8");
|
|
111
|
+
const events = [];
|
|
112
|
+
for (const line of content.split("\n")) {
|
|
113
|
+
if (!line.trim()) continue;
|
|
114
|
+
try {
|
|
115
|
+
const obj = JSON.parse(line);
|
|
116
|
+
if (obj.type === "response_item" && obj.payload) {
|
|
117
|
+
const p = obj.payload;
|
|
118
|
+
if (p.role === "developer" && Array.isArray(p.content)) {
|
|
119
|
+
const text = p.content.filter((c) => c.type === "input_text").map((c) => c.text).join("\n");
|
|
120
|
+
if (text) events.push({ type: "message", role: "user", content: text });
|
|
121
|
+
} else if (p.role === "assistant" && Array.isArray(p.content)) {
|
|
122
|
+
for (const block of p.content) {
|
|
123
|
+
if (block.type === "output_text" && block.text) {
|
|
124
|
+
events.push({ type: "message", role: "assistant", content: block.text });
|
|
125
|
+
} else if (block.type === "function_call") {
|
|
126
|
+
events.push({
|
|
127
|
+
type: "tool_use",
|
|
128
|
+
tool_name: block.name,
|
|
129
|
+
tool_input: { arguments: block.arguments }
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
} catch {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return events;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// src/utils/transcript-parsers/roo-code-json.ts
|
|
143
|
+
var roo_code_json_exports = {};
|
|
144
|
+
__export(roo_code_json_exports, {
|
|
145
|
+
canParse: () => canParse4,
|
|
146
|
+
parse: () => parse4
|
|
147
|
+
});
|
|
148
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
149
|
+
function canParse4(path) {
|
|
150
|
+
return path.includes("roo-cline/tasks/") && path.endsWith("api_conversation_history.json");
|
|
151
|
+
}
|
|
152
|
+
function parse4(path) {
|
|
153
|
+
const content = readFileSync4(path, "utf-8");
|
|
154
|
+
const events = [];
|
|
155
|
+
try {
|
|
156
|
+
const messages = JSON.parse(content);
|
|
157
|
+
if (!Array.isArray(messages)) return [];
|
|
158
|
+
for (const msg of messages) {
|
|
159
|
+
if (msg.role === "user" && Array.isArray(msg.content)) {
|
|
160
|
+
const text = msg.content.filter((c) => c.type === "text").map((c) => c.text).join("\n");
|
|
161
|
+
if (text) events.push({ type: "message", role: "user", content: text });
|
|
162
|
+
} else if (msg.role === "assistant" && typeof msg.content === "string") {
|
|
163
|
+
events.push({ type: "message", role: "assistant", content: msg.content });
|
|
164
|
+
} else if (msg.role === "assistant" && Array.isArray(msg.content)) {
|
|
165
|
+
for (const block of msg.content) {
|
|
166
|
+
if (block.type === "text" && block.text) {
|
|
167
|
+
events.push({ type: "message", role: "assistant", content: block.text });
|
|
168
|
+
} else if (block.type === "tool_use") {
|
|
169
|
+
events.push({
|
|
170
|
+
type: "tool_use",
|
|
171
|
+
tool_name: block.name,
|
|
172
|
+
tool_input: block.input
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
} catch {
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
return events;
|
|
182
|
+
}
|
|
183
|
+
|
|
97
184
|
// src/utils/transcript-parsers/index.ts
|
|
98
|
-
var parsers = [claude_jsonl_exports, continue_json_exports];
|
|
185
|
+
var parsers = [codex_jsonl_exports, roo_code_json_exports, claude_jsonl_exports, continue_json_exports];
|
|
99
186
|
function parseTranscriptAuto(path) {
|
|
100
187
|
for (const parser of parsers) {
|
|
101
188
|
if (parser.canParse(path)) return parser.parse(path);
|
|
@@ -164,10 +251,57 @@ function findAllContinueTranscripts() {
|
|
|
164
251
|
return [];
|
|
165
252
|
}
|
|
166
253
|
}
|
|
254
|
+
function findAllCodexTranscripts() {
|
|
255
|
+
const baseDir = join(homedir(), ".codex", "sessions");
|
|
256
|
+
if (!existsSync(baseDir)) return [];
|
|
257
|
+
const transcripts = [];
|
|
258
|
+
function walkDir(dir) {
|
|
259
|
+
try {
|
|
260
|
+
for (const entry of readdirSync(dir)) {
|
|
261
|
+
const full = join(dir, entry);
|
|
262
|
+
const stat = statSync(full);
|
|
263
|
+
if (stat.isDirectory()) {
|
|
264
|
+
walkDir(full);
|
|
265
|
+
} else if (entry.endsWith(".jsonl") && stat.size > 100) {
|
|
266
|
+
transcripts.push(full);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
} catch {
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
walkDir(baseDir);
|
|
273
|
+
return transcripts;
|
|
274
|
+
}
|
|
275
|
+
function findAllRooCodeTranscripts() {
|
|
276
|
+
const possibleDirs = [
|
|
277
|
+
join(homedir(), "Library", "Application Support", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "tasks"),
|
|
278
|
+
join(homedir(), ".config", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "tasks")
|
|
279
|
+
];
|
|
280
|
+
const transcripts = [];
|
|
281
|
+
for (const baseDir of possibleDirs) {
|
|
282
|
+
if (!existsSync(baseDir)) continue;
|
|
283
|
+
try {
|
|
284
|
+
for (const taskDir of readdirSync(baseDir)) {
|
|
285
|
+
const historyPath = join(baseDir, taskDir, "api_conversation_history.json");
|
|
286
|
+
if (existsSync(historyPath) && statSync(historyPath).size > 100) {
|
|
287
|
+
transcripts.push(historyPath);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
} catch {
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return transcripts;
|
|
294
|
+
}
|
|
295
|
+
function getGooseDbPath() {
|
|
296
|
+
return join(homedir(), ".local", "share", "goose", "sessions", "sessions.db");
|
|
297
|
+
}
|
|
167
298
|
|
|
168
299
|
export {
|
|
169
300
|
parseTranscript,
|
|
170
301
|
findLatestTranscript,
|
|
171
302
|
findAllClaudeTranscripts,
|
|
172
|
-
findAllContinueTranscripts
|
|
303
|
+
findAllContinueTranscripts,
|
|
304
|
+
findAllCodexTranscripts,
|
|
305
|
+
findAllRooCodeTranscripts,
|
|
306
|
+
getGooseDbPath
|
|
173
307
|
};
|
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-5APZETPV.js");
|
|
9
9
|
await runSetup();
|
|
10
10
|
});
|
|
11
11
|
program.command("serve").description("Start AgentCache MCP server (spawned by IDEs automatically)").action(async () => {
|
|
@@ -13,7 +13,7 @@ program.command("serve").description("Start AgentCache MCP server (spawned by ID
|
|
|
13
13
|
await startMcpServer();
|
|
14
14
|
});
|
|
15
15
|
program.command("compile-session").description("Stop hook: queue transcript for compilation").action(async () => {
|
|
16
|
-
const { handleStop } = await import("./stop-
|
|
16
|
+
const { handleStop } = await import("./stop-6SROS34Q.js");
|
|
17
17
|
let payload;
|
|
18
18
|
try {
|
|
19
19
|
let data = "";
|
|
@@ -28,11 +28,11 @@ program.command("compile-session").description("Stop hook: queue transcript for
|
|
|
28
28
|
await handleStop(payload);
|
|
29
29
|
});
|
|
30
30
|
program.command("discover").description("SessionStart hook: discover uncompiled transcripts").action(async () => {
|
|
31
|
-
const { handleSessionStart } = await import("./session-start-
|
|
31
|
+
const { handleSessionStart } = await import("./session-start-YSRUGD5N.js");
|
|
32
32
|
await handleSessionStart();
|
|
33
33
|
});
|
|
34
34
|
program.command("enforce").description("PreToolUse hook: policy enforcement").action(async () => {
|
|
35
|
-
const { handlePreToolUse } = await import("./pre-tool-use-
|
|
35
|
+
const { handlePreToolUse } = await import("./pre-tool-use-OWWS54XG.js");
|
|
36
36
|
let data = "";
|
|
37
37
|
for await (const chunk of process.stdin) {
|
|
38
38
|
data += chunk;
|
|
@@ -45,13 +45,17 @@ program.command("enforce").description("PreToolUse hook: policy enforcement").ac
|
|
|
45
45
|
process.stdout.write("{}");
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
+
program.command("compile-all").description("Batch-compile all unprocessed transcripts using an available LLM CLI").action(async () => {
|
|
49
|
+
const { runCompileAll } = await import("./compile-all-RWCAU7MO.js");
|
|
50
|
+
await runCompileAll();
|
|
51
|
+
});
|
|
48
52
|
program.command("status").description("Show AgentCache knowledge stats").action(async () => {
|
|
49
|
-
const { getDbPath, isInitialized, findProjectRoot, getProjectId, getProjectDisplayName } = await import("./paths-
|
|
53
|
+
const { getDbPath, isInitialized, findProjectRoot, getProjectId, getProjectDisplayName } = await import("./paths-LOLEIMI5.js");
|
|
50
54
|
if (!isInitialized()) {
|
|
51
55
|
console.log("AgentCache not initialized. Run: agentcache setup");
|
|
52
56
|
return;
|
|
53
57
|
}
|
|
54
|
-
const { SqliteKnowledgeRepository } = await import("./sqlite-
|
|
58
|
+
const { SqliteKnowledgeRepository } = await import("./sqlite-AUND6HGQ.js");
|
|
55
59
|
const repo = new SqliteKnowledgeRepository(getDbPath());
|
|
56
60
|
const projectRoot = findProjectRoot();
|
|
57
61
|
const project = getProjectId(projectRoot);
|