agentcache 0.4.2 → 0.5.0-beta.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.
Files changed (38) hide show
  1. package/README.md +282 -151
  2. package/dist/{chunk-T4COG3XD.js → chunk-R5I6WWSD.js} +31 -14
  3. package/dist/chunk-RXGW4Q3G.js +109 -0
  4. package/dist/chunk-XRJ6QW6N.js +92 -0
  5. package/dist/chunk-YKG6CDGT.js +1818 -0
  6. package/dist/chunk-YY7QXBG5.js +6610 -0
  7. package/dist/cli.js +2535 -292
  8. package/dist/device-id-RV7RO5RB.js +7 -0
  9. package/dist/ide-detector-ETGAVVXO.js +8 -0
  10. package/dist/mcp.d.ts +734 -2
  11. package/dist/mcp.js +1126 -446
  12. package/dist/{paths-5LZRKNYY.js → paths-NTZ2357O.js} +3 -2
  13. package/dist/postinstall.js +1 -65
  14. package/dist/setup-7JJPW3VG.js +48 -0
  15. package/docs/compatibility.md +152 -0
  16. package/docs/demo-script.md +121 -0
  17. package/docs/launch-copy.md +125 -0
  18. package/docs/privacy.md +173 -0
  19. package/docs/troubleshooting.md +209 -0
  20. package/package.json +32 -14
  21. package/dist/3-canonicalizer-HIN2F7SZ.js +0 -11
  22. package/dist/chunk-5UO7NJPQ.js +0 -71
  23. package/dist/chunk-CUBZRYS5.js +0 -580
  24. package/dist/chunk-GGAATZKM.js +0 -120
  25. package/dist/chunk-JUDLOBOC.js +0 -77
  26. package/dist/chunk-KFQGP6VL.js +0 -33
  27. package/dist/chunk-PSASDZQE.js +0 -490
  28. package/dist/chunk-SLRKWMSE.js +0 -202
  29. package/dist/chunk-T7BJPANN.js +0 -45
  30. package/dist/chunk-WTXSZBQE.js +0 -388
  31. package/dist/compile-all-PTWTZVP5.js +0 -495
  32. package/dist/ide-detector-5TRCR4F5.js +0 -7
  33. package/dist/pre-tool-use-A4AJHZOJ.js +0 -30
  34. package/dist/session-start-DGMGEAJU.js +0 -78
  35. package/dist/setup-CVG35TUZ.js +0 -51
  36. package/dist/sqlite-NM2BVHUY.js +0 -7
  37. package/dist/stop-WGGRX6TQ.js +0 -38
  38. package/dist/transcript-JWSGSDSF.js +0 -24
@@ -1,495 +0,0 @@
1
- import {
2
- processClustering,
3
- processExtraction,
4
- startCompile
5
- } from "./chunk-CUBZRYS5.js";
6
- import "./chunk-GGAATZKM.js";
7
- import {
8
- acquireLock,
9
- releaseLock
10
- } from "./chunk-JUDLOBOC.js";
11
- import {
12
- SqliteKnowledgeRepository
13
- } from "./chunk-PSASDZQE.js";
14
- import {
15
- findAllClaudeTranscripts,
16
- findAllCodexTranscripts,
17
- findAllContinueTranscripts,
18
- findAllCursorTranscripts,
19
- findAllRooCodeTranscripts,
20
- getGooseDbPath,
21
- parseTranscript
22
- } from "./chunk-WTXSZBQE.js";
23
- import {
24
- getDbPath,
25
- getGitRoot,
26
- getProjectId,
27
- isInitialized
28
- } from "./chunk-T4COG3XD.js";
29
- import {
30
- __esm,
31
- __export,
32
- __require,
33
- __toCommonJS
34
- } from "./chunk-KFQGP6VL.js";
35
-
36
- // src/utils/transcript-parsers/goose-sqlite.ts
37
- var goose_sqlite_exports = {};
38
- __export(goose_sqlite_exports, {
39
- canParse: () => canParse,
40
- getGooseDbPath: () => getGooseDbPath2,
41
- hasGooseSessions: () => hasGooseSessions,
42
- parse: () => parse,
43
- parseSession: () => parseSession
44
- });
45
- import { existsSync } from "fs";
46
- import { join } from "path";
47
- import { homedir } from "os";
48
- function canParse(path) {
49
- return path.endsWith("goose-sessions.db") || path.includes("goose/sessions/sessions.db");
50
- }
51
- function getGooseDbPath2() {
52
- return join(homedir(), ".local", "share", "goose", "sessions", "sessions.db");
53
- }
54
- function hasGooseSessions() {
55
- return existsSync(getGooseDbPath2());
56
- }
57
- function parseSession(db, sessionId) {
58
- const events = [];
59
- const rows = db.prepare("SELECT role, content_json FROM messages WHERE session_id = ? ORDER BY created_timestamp ASC").all(sessionId);
60
- for (const row of rows) {
61
- try {
62
- const content = JSON.parse(row.content_json);
63
- if (!Array.isArray(content)) continue;
64
- for (const block of content) {
65
- if (row.role === "user" && block.type === "text" && block.text) {
66
- events.push({ type: "message", role: "user", content: block.text });
67
- } else if (row.role === "assistant" && block.type === "text" && block.text) {
68
- events.push({ type: "message", role: "assistant", content: block.text });
69
- } else if (row.role === "assistant" && block.type === "toolRequest") {
70
- events.push({
71
- type: "tool_use",
72
- tool_name: block.toolCall?.value?.name || "unknown",
73
- tool_input: block.toolCall?.value?.arguments ? { arguments: block.toolCall.value.arguments } : {}
74
- });
75
- }
76
- }
77
- } catch {
78
- continue;
79
- }
80
- }
81
- return events;
82
- }
83
- function parse(_path) {
84
- return [];
85
- }
86
- var init_goose_sqlite = __esm({
87
- "src/utils/transcript-parsers/goose-sqlite.ts"() {
88
- "use strict";
89
- }
90
- });
91
-
92
- // src/compile-all.ts
93
- import { spawnSync } from "child_process";
94
- import { existsSync as existsSync2, writeFileSync, unlinkSync } from "fs";
95
- import { tmpdir } from "os";
96
- import { join as join2, dirname } from "path";
97
- import { randomUUID } from "crypto";
98
- function detectBackend() {
99
- const backends = [
100
- {
101
- cmd: "claude",
102
- name: "Claude Code",
103
- buildInvoke: () => (prompt) => {
104
- const result = spawnSync("claude", ["-p", "-", "--output-format", "text"], {
105
- input: prompt,
106
- encoding: "utf-8",
107
- timeout: 12e4,
108
- maxBuffer: 10 * 1024 * 1024
109
- });
110
- return result.status === 0 ? result.stdout : null;
111
- }
112
- },
113
- {
114
- cmd: "codex",
115
- name: "Codex",
116
- buildInvoke: () => (prompt) => {
117
- const tmpFile = join2(tmpdir(), `agentcache-prompt-${Date.now()}.txt`);
118
- writeFileSync(tmpFile, prompt);
119
- const result = spawnSync("codex", ["exec", "-", "--skip-git-repo-check"], {
120
- input: prompt,
121
- encoding: "utf-8",
122
- timeout: 12e4,
123
- maxBuffer: 10 * 1024 * 1024
124
- });
125
- try {
126
- unlinkSync(tmpFile);
127
- } catch {
128
- }
129
- return result.status === 0 ? result.stdout : null;
130
- }
131
- },
132
- {
133
- cmd: "gemini",
134
- name: "Gemini CLI",
135
- buildInvoke: () => (prompt) => {
136
- const result = spawnSync("gemini", ["-p", "-"], {
137
- input: prompt,
138
- encoding: "utf-8",
139
- timeout: 12e4,
140
- maxBuffer: 10 * 1024 * 1024
141
- });
142
- return result.status === 0 ? result.stdout : null;
143
- }
144
- },
145
- {
146
- cmd: "copilot",
147
- name: "Copilot CLI",
148
- buildInvoke: () => (prompt) => {
149
- const result = spawnSync("copilot", ["-p", "-"], {
150
- input: prompt,
151
- encoding: "utf-8",
152
- timeout: 12e4,
153
- maxBuffer: 10 * 1024 * 1024
154
- });
155
- return result.status === 0 ? result.stdout : null;
156
- }
157
- },
158
- {
159
- cmd: "aider",
160
- name: "Aider",
161
- buildInvoke: () => (prompt) => {
162
- const tmpFile = join2(tmpdir(), `agentcache-prompt-${Date.now()}.txt`);
163
- writeFileSync(tmpFile, prompt);
164
- const result = spawnSync("aider", ["--message-file", tmpFile, "--yes", "--no-stream", "--no-git"], {
165
- encoding: "utf-8",
166
- timeout: 12e4,
167
- maxBuffer: 10 * 1024 * 1024
168
- });
169
- try {
170
- unlinkSync(tmpFile);
171
- } catch {
172
- }
173
- return result.status === 0 ? result.stdout : null;
174
- }
175
- },
176
- {
177
- cmd: "goose",
178
- name: "Goose",
179
- buildInvoke: () => (prompt) => {
180
- const tmpFile = join2(tmpdir(), `agentcache-prompt-${Date.now()}.txt`);
181
- writeFileSync(tmpFile, prompt);
182
- const result = spawnSync("goose", ["run", "--instructions", tmpFile], {
183
- encoding: "utf-8",
184
- timeout: 12e4,
185
- maxBuffer: 10 * 1024 * 1024
186
- });
187
- try {
188
- unlinkSync(tmpFile);
189
- } catch {
190
- }
191
- return result.status === 0 ? result.stdout : null;
192
- }
193
- }
194
- ];
195
- for (const b of backends) {
196
- try {
197
- const which = spawnSync("which", [b.cmd], { encoding: "utf-8" });
198
- if (which.status === 0 && which.stdout.trim()) {
199
- return { name: b.name, invoke: b.buildInvoke() };
200
- }
201
- } catch {
202
- }
203
- }
204
- try {
205
- const ollamaCheck = spawnSync("curl", ["-s", "http://localhost:11434/api/tags"], {
206
- encoding: "utf-8",
207
- timeout: 3e3
208
- });
209
- if (ollamaCheck.status === 0 && ollamaCheck.stdout.includes("models")) {
210
- const models = JSON.parse(ollamaCheck.stdout)?.models || [];
211
- const model = models.find((m) => /qwen|llama|mistral|gemma/i.test(m.name))?.name || models[0]?.name;
212
- if (model) {
213
- return {
214
- name: `Ollama (${model})`,
215
- invoke: (prompt) => {
216
- const result = spawnSync("curl", [
217
- "-s",
218
- "http://localhost:11434/api/generate",
219
- "-d",
220
- JSON.stringify({ model, prompt, stream: false })
221
- ], { encoding: "utf-8", timeout: 12e4, maxBuffer: 10 * 1024 * 1024 });
222
- if (result.status !== 0) return null;
223
- try {
224
- return JSON.parse(result.stdout)?.response || null;
225
- } catch {
226
- return null;
227
- }
228
- }
229
- };
230
- }
231
- }
232
- } catch {
233
- }
234
- const anthropicKey = process.env.ANTHROPIC_API_KEY;
235
- if (anthropicKey) {
236
- return {
237
- name: "Anthropic API (env)",
238
- invoke: (prompt) => {
239
- const result = spawnSync("curl", [
240
- "-s",
241
- "https://api.anthropic.com/v1/messages",
242
- "-H",
243
- "content-type: application/json",
244
- "-H",
245
- `x-api-key: ${anthropicKey}`,
246
- "-H",
247
- "anthropic-version: 2023-06-01",
248
- "-d",
249
- JSON.stringify({
250
- model: "claude-sonnet-4-20250514",
251
- max_tokens: 4096,
252
- messages: [{ role: "user", content: prompt }]
253
- })
254
- ], { encoding: "utf-8", timeout: 12e4, maxBuffer: 10 * 1024 * 1024 });
255
- if (result.status !== 0) return null;
256
- try {
257
- return JSON.parse(result.stdout)?.content?.[0]?.text || null;
258
- } catch {
259
- return null;
260
- }
261
- }
262
- };
263
- }
264
- const openaiKey = process.env.OPENAI_API_KEY;
265
- if (openaiKey) {
266
- return {
267
- name: "OpenAI API (env)",
268
- invoke: (prompt) => {
269
- const result = spawnSync("curl", [
270
- "-s",
271
- "https://api.openai.com/v1/chat/completions",
272
- "-H",
273
- "content-type: application/json",
274
- "-H",
275
- `Authorization: Bearer ${openaiKey}`,
276
- "-d",
277
- JSON.stringify({
278
- model: "gpt-4o-mini",
279
- messages: [{ role: "user", content: prompt }]
280
- })
281
- ], { encoding: "utf-8", timeout: 12e4, maxBuffer: 10 * 1024 * 1024 });
282
- if (result.status !== 0) return null;
283
- try {
284
- return JSON.parse(result.stdout)?.choices?.[0]?.message?.content || null;
285
- } catch {
286
- return null;
287
- }
288
- }
289
- };
290
- }
291
- return null;
292
- }
293
- function discoverAllTranscripts(repo) {
294
- const compiledPaths = new Set(repo.getAllCompiledTranscriptPaths());
295
- const results = [];
296
- const allPaths = [
297
- ...findAllClaudeTranscripts(),
298
- ...findAllCursorTranscripts(),
299
- ...findAllContinueTranscripts(),
300
- ...findAllCodexTranscripts(),
301
- ...findAllRooCodeTranscripts()
302
- ];
303
- for (const path of allPaths) {
304
- if (compiledPaths.has(path)) continue;
305
- const projectRoot = inferProjectRoot(path);
306
- const project = getProjectId(projectRoot);
307
- results.push({ path, project, projectRoot });
308
- }
309
- return results;
310
- }
311
- function inferProjectRoot(transcriptPath) {
312
- if (transcriptPath.includes(".claude/projects/")) {
313
- const slug = transcriptPath.split(".claude/projects/")[1]?.split("/")[0] || "";
314
- if (slug.startsWith("-")) return slug.replace(/-/g, "/");
315
- }
316
- if (transcriptPath.includes(".cursor/projects/")) {
317
- const slug = transcriptPath.split(".cursor/projects/")[1]?.split("/")[0] || "";
318
- if (slug) {
319
- const asPath = "/" + slug.replace(/-/g, "/");
320
- const root = getGitRoot(asPath);
321
- if (root) return root;
322
- }
323
- }
324
- try {
325
- const events = parseTranscript(transcriptPath);
326
- for (const event of events) {
327
- const filePath = extractFilePath(event);
328
- if (filePath) {
329
- const root = getGitRoot(dirname(filePath));
330
- if (root) return root;
331
- return dirname(filePath);
332
- }
333
- }
334
- } catch {
335
- }
336
- return process.cwd();
337
- }
338
- function extractFilePath(event) {
339
- if (event.tool_input) {
340
- for (const val of Object.values(event.tool_input)) {
341
- if (typeof val === "string" && val.startsWith("/") && val.includes("/") && !val.includes(" ")) {
342
- return val;
343
- }
344
- }
345
- }
346
- return null;
347
- }
348
- function processOneTranscript(repo, path, project, projectRoot, backend) {
349
- const events = parseTranscript(path);
350
- if (events.length < 3) return { created: 0, reinforced: 0, skipped: true };
351
- const sessionId = `sess_${randomUUID().slice(0, 8)}`;
352
- const state = startCompile(events, sessionId, project, projectRoot, repo);
353
- const extractionResponse = backend.invoke(state.prompt);
354
- if (!extractionResponse) return { created: 0, reinforced: 0, skipped: true };
355
- const extractResult = processExtraction(repo, extractionResponse, sessionId, project, projectRoot);
356
- repo.updateSessionTranscriptPath(sessionId, path);
357
- if (extractResult.status === "complete") {
358
- return { created: 0, reinforced: 0, skipped: false };
359
- }
360
- const clusterResponse = backend.invoke(extractResult.clusteringPrompt);
361
- if (!clusterResponse) return { created: 0, reinforced: 0, skipped: false };
362
- const clusterResult = processClustering(repo, clusterResponse, sessionId, project, projectRoot);
363
- const diag = clusterResult.diagnostics;
364
- const createdMatch = diag.match(/(\d+) new knowledge/);
365
- const reinforcedMatch = diag.match(/(\d+) reinforced/);
366
- return {
367
- created: createdMatch ? parseInt(createdMatch[1]) : 0,
368
- reinforced: reinforcedMatch ? parseInt(reinforcedMatch[1]) : 0,
369
- skipped: false
370
- };
371
- }
372
- function processGooseSessions(repo, backend) {
373
- const dbPath = getGooseDbPath();
374
- if (!existsSync2(dbPath)) return { processed: 0, created: 0 };
375
- let Database;
376
- try {
377
- Database = __require("better-sqlite3");
378
- } catch {
379
- return { processed: 0, created: 0 };
380
- }
381
- const gooseDb = new Database(dbPath, { readonly: true });
382
- const compiledPaths = new Set(repo.getAllCompiledTranscriptPaths());
383
- const sessions = gooseDb.prepare("SELECT id, working_dir FROM sessions").all();
384
- let processed = 0;
385
- let totalCreated = 0;
386
- for (const session of sessions) {
387
- const markerPath = `goose:${session.id}`;
388
- if (compiledPaths.has(markerPath)) continue;
389
- const { parseSession: parseSession2 } = (init_goose_sqlite(), __toCommonJS(goose_sqlite_exports));
390
- const events = parseSession2(gooseDb, session.id);
391
- if (events.length < 3) continue;
392
- const projectRoot = session.working_dir || process.cwd();
393
- const project = getProjectId(projectRoot);
394
- const sessionId = `sess_${randomUUID().slice(0, 8)}`;
395
- const state = startCompile(events, sessionId, project, projectRoot, repo);
396
- const extractionResponse = backend.invoke(state.prompt);
397
- if (!extractionResponse) continue;
398
- const extractResult = processExtraction(repo, extractionResponse, sessionId, project, projectRoot);
399
- repo.updateSessionTranscriptPath(sessionId, markerPath);
400
- if (extractResult.status === "needs_clustering") {
401
- const clusterResponse = backend.invoke(extractResult.clusteringPrompt);
402
- if (clusterResponse) {
403
- processClustering(repo, clusterResponse, sessionId, project, projectRoot);
404
- }
405
- }
406
- processed++;
407
- totalCreated++;
408
- }
409
- gooseDb.close();
410
- return { processed, created: totalCreated };
411
- }
412
- async function runCompileAll() {
413
- if (!isInitialized()) {
414
- console.error("AgentCache not initialized. Run: npm install -g agentcache");
415
- process.exit(1);
416
- }
417
- if (!acquireLock()) {
418
- console.error("Another compile-all process is already running. Exiting.");
419
- process.exit(0);
420
- }
421
- process.on("exit", releaseLock);
422
- process.on("SIGINT", () => {
423
- releaseLock();
424
- process.exit(130);
425
- });
426
- process.on("SIGTERM", () => {
427
- releaseLock();
428
- process.exit(143);
429
- });
430
- const backend = detectBackend();
431
- if (!backend) {
432
- releaseLock();
433
- console.error("No LLM backend found. Install one of: claude, codex, gemini, copilot, aider, goose");
434
- process.exit(1);
435
- }
436
- console.log(`AgentCache compile-all`);
437
- console.log(`LLM backend: ${backend.name}`);
438
- console.log("");
439
- const repo = new SqliteKnowledgeRepository(getDbPath());
440
- const transcripts = discoverAllTranscripts(repo);
441
- const gooseAvailable = existsSync2(getGooseDbPath());
442
- const total = transcripts.length + (gooseAvailable ? 1 : 0);
443
- if (total === 0 && !gooseAvailable) {
444
- console.log("No uncompiled transcripts found. Knowledge is up to date.");
445
- repo.close();
446
- return;
447
- }
448
- const estimatedMinutes = Math.ceil(transcripts.length * 0.7);
449
- console.log(`Found ${transcripts.length} transcripts to process`);
450
- if (gooseAvailable) console.log(`+ Goose sessions available`);
451
- console.log(`Estimated time: ~${estimatedMinutes} minutes`);
452
- console.log(`Started: ${(/* @__PURE__ */ new Date()).toLocaleTimeString()}`);
453
- console.log("\u2500".repeat(50));
454
- let processed = 0;
455
- let totalCreated = 0;
456
- let totalReinforced = 0;
457
- let errors = 0;
458
- for (const t of transcripts) {
459
- processed++;
460
- const label = t.path.split("/").slice(-2).join("/");
461
- process.stdout.write(`[${processed}/${transcripts.length}] ${label.slice(0, 40)}... `);
462
- try {
463
- const result = processOneTranscript(repo, t.path, t.project, t.projectRoot, backend);
464
- if (result.skipped) {
465
- console.log("skipped");
466
- } else {
467
- totalCreated += result.created;
468
- totalReinforced += result.reinforced;
469
- console.log(`+${result.created} new, ${result.reinforced} reinforced`);
470
- }
471
- } catch (err) {
472
- errors++;
473
- console.log(`error: ${err.message?.slice(0, 50)}`);
474
- }
475
- }
476
- if (gooseAvailable) {
477
- process.stdout.write("Processing Goose sessions... ");
478
- try {
479
- const gooseResult = processGooseSessions(repo, backend);
480
- console.log(`${gooseResult.processed} sessions processed`);
481
- } catch (err) {
482
- console.log(`error: ${err.message?.slice(0, 50)}`);
483
- }
484
- }
485
- repo.close();
486
- console.log("\u2500".repeat(50));
487
- console.log(`Done: ${(/* @__PURE__ */ new Date()).toLocaleTimeString()}`);
488
- console.log(` ${processed} transcripts processed`);
489
- console.log(` ${totalCreated} knowledge items created`);
490
- console.log(` ${totalReinforced} reinforced`);
491
- if (errors > 0) console.log(` ${errors} errors`);
492
- }
493
- export {
494
- runCompileAll
495
- };
@@ -1,7 +0,0 @@
1
- import {
2
- detectInstalledIdes
3
- } from "./chunk-5UO7NJPQ.js";
4
- import "./chunk-KFQGP6VL.js";
5
- export {
6
- detectInstalledIdes
7
- };
@@ -1,30 +0,0 @@
1
- import {
2
- evaluatePolicy
3
- } from "./chunk-T7BJPANN.js";
4
- import {
5
- SqliteKnowledgeRepository
6
- } from "./chunk-PSASDZQE.js";
7
- import {
8
- findProjectRoot,
9
- getDbPath,
10
- getProjectId,
11
- isInitialized
12
- } from "./chunk-T4COG3XD.js";
13
- import "./chunk-KFQGP6VL.js";
14
-
15
- // src/hooks/pre-tool-use.ts
16
- function handlePreToolUse(input) {
17
- if (!isInitialized()) 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
- };
@@ -1,78 +0,0 @@
1
- import {
2
- SqliteKnowledgeRepository
3
- } from "./chunk-PSASDZQE.js";
4
- import {
5
- findAllClaudeTranscripts,
6
- findAllCodexTranscripts,
7
- findAllContinueTranscripts,
8
- findAllCursorTranscripts,
9
- findAllRooCodeTranscripts
10
- } from "./chunk-WTXSZBQE.js";
11
- import {
12
- getDbPath,
13
- getProjectId,
14
- isInitialized
15
- } from "./chunk-T4COG3XD.js";
16
- import "./chunk-KFQGP6VL.js";
17
-
18
- // src/hooks/session-start.ts
19
- import { statSync } from "fs";
20
- import { basename, dirname } from "path";
21
- import { randomUUID } from "crypto";
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
- }
31
- const dir = dirname(path);
32
- const slug = basename(dir);
33
- if (slug.startsWith("-")) {
34
- return slug.replace(/-/g, "/");
35
- }
36
- return dir;
37
- }
38
- async function handleSessionStart() {
39
- if (!isInitialized()) return;
40
- const repo = new SqliteKnowledgeRepository(getDbPath());
41
- const compiledPaths = new Set(repo.getAllCompiledTranscriptPaths());
42
- const allTranscripts = [
43
- ...findAllClaudeTranscripts(),
44
- ...findAllCursorTranscripts(),
45
- ...findAllContinueTranscripts(),
46
- ...findAllCodexTranscripts(),
47
- ...findAllRooCodeTranscripts()
48
- ];
49
- const oneMinuteAgo = Date.now() - 6e4;
50
- const uncompiled = allTranscripts.filter((path) => {
51
- if (compiledPaths.has(path)) return false;
52
- try {
53
- return statSync(path).mtimeMs < oneMinuteAgo;
54
- } catch {
55
- return false;
56
- }
57
- });
58
- if (uncompiled.length === 0) {
59
- repo.close();
60
- return;
61
- }
62
- for (const path of uncompiled) {
63
- const projectRoot = inferProjectRootFromTranscriptPath(path);
64
- const project = getProjectId(projectRoot);
65
- repo.queueTranscript({
66
- id: `pend_${randomUUID().slice(0, 8)}`,
67
- transcriptPath: path,
68
- project,
69
- projectRoot,
70
- provider: "discovered",
71
- queuedAt: Date.now()
72
- });
73
- }
74
- repo.close();
75
- }
76
- export {
77
- handleSessionStart
78
- };
@@ -1,51 +0,0 @@
1
- import {
2
- registerClaudeHooks,
3
- registerMcpServer
4
- } from "./chunk-SLRKWMSE.js";
5
- import {
6
- SqliteKnowledgeRepository
7
- } from "./chunk-PSASDZQE.js";
8
- import {
9
- detectInstalledIdes
10
- } from "./chunk-5UO7NJPQ.js";
11
- import {
12
- getDataDir,
13
- getDbPath,
14
- migrateFromLegacy
15
- } from "./chunk-T4COG3XD.js";
16
- import "./chunk-KFQGP6VL.js";
17
-
18
- // src/setup.ts
19
- import { mkdirSync } from "fs";
20
- async function runSetup() {
21
- migrateFromLegacy();
22
- mkdirSync(getDataDir(), { recursive: true });
23
- const repo = new SqliteKnowledgeRepository(getDbPath());
24
- repo.close();
25
- const ides = detectInstalledIdes();
26
- const detected = ides.filter((i) => i.detected);
27
- console.log(`
28
- AgentCache setup complete.`);
29
- console.log(` Central DB: ${getDbPath()}
30
- `);
31
- if (detected.length === 0) {
32
- console.log(` No IDEs detected. MCP server can still be used manually: agentcache serve
33
- `);
34
- return;
35
- }
36
- console.log(`IDEs:`);
37
- for (const ide of detected) {
38
- const registered = registerMcpServer(ide);
39
- console.log(` ${ide.name}: ${registered ? "MCP registered" : "already registered"}`);
40
- }
41
- const hooksRegistered = registerClaudeHooks();
42
- if (hooksRegistered) {
43
- console.log(`
44
- Claude Code hooks: registered (Stop, SessionStart, PreToolUse)`);
45
- }
46
- console.log(`
47
- Done. AgentCache compiles knowledge across all sessions and IDEs.`);
48
- }
49
- export {
50
- runSetup
51
- };
@@ -1,7 +0,0 @@
1
- import {
2
- SqliteKnowledgeRepository
3
- } from "./chunk-PSASDZQE.js";
4
- import "./chunk-KFQGP6VL.js";
5
- export {
6
- SqliteKnowledgeRepository
7
- };