agentcache 0.3.2 → 0.3.4
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/cli.js
CHANGED
|
@@ -46,7 +46,7 @@ program.command("enforce").description("PreToolUse hook: policy enforcement").ac
|
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
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-
|
|
49
|
+
const { runCompileAll } = await import("./compile-all-LB5S67BQ.js");
|
|
50
50
|
await runCompileAll();
|
|
51
51
|
});
|
|
52
52
|
program.command("status").description("Show AgentCache knowledge stats").action(async () => {
|
|
@@ -321,14 +321,13 @@ function processOneTranscript(repo, path, project, projectRoot, backend) {
|
|
|
321
321
|
const extractionResponse = backend.invoke(state.prompt);
|
|
322
322
|
if (!extractionResponse) return { created: 0, reinforced: 0, skipped: true };
|
|
323
323
|
const extractResult = processExtraction(repo, extractionResponse, sessionId, project, projectRoot);
|
|
324
|
+
repo.updateSessionTranscriptPath(sessionId, path);
|
|
324
325
|
if (extractResult.status === "complete") {
|
|
325
|
-
repo.updateSessionTranscriptPath(sessionId, path);
|
|
326
326
|
return { created: 0, reinforced: 0, skipped: false };
|
|
327
327
|
}
|
|
328
328
|
const clusterResponse = backend.invoke(extractResult.clusteringPrompt);
|
|
329
|
-
if (!clusterResponse) return { created: 0, reinforced: 0, skipped:
|
|
329
|
+
if (!clusterResponse) return { created: 0, reinforced: 0, skipped: false };
|
|
330
330
|
const clusterResult = processClustering(repo, clusterResponse, sessionId, project, projectRoot);
|
|
331
|
-
repo.updateSessionTranscriptPath(sessionId, path);
|
|
332
331
|
const diag = clusterResult.diagnostics;
|
|
333
332
|
const createdMatch = diag.match(/(\d+) new knowledge/);
|
|
334
333
|
const reinforcedMatch = diag.match(/(\d+) reinforced/);
|
|
@@ -361,10 +360,11 @@ function processGooseSessions(repo, backend) {
|
|
|
361
360
|
const projectRoot = session.working_dir || process.cwd();
|
|
362
361
|
const project = getProjectId(projectRoot);
|
|
363
362
|
const sessionId = `sess_${randomUUID().slice(0, 8)}`;
|
|
364
|
-
const state = startCompile(events, sessionId, project, projectRoot, repo
|
|
363
|
+
const state = startCompile(events, sessionId, project, projectRoot, repo);
|
|
365
364
|
const extractionResponse = backend.invoke(state.prompt);
|
|
366
365
|
if (!extractionResponse) continue;
|
|
367
366
|
const extractResult = processExtraction(repo, extractionResponse, sessionId, project, projectRoot);
|
|
367
|
+
repo.updateSessionTranscriptPath(sessionId, markerPath);
|
|
368
368
|
if (extractResult.status === "needs_clustering") {
|
|
369
369
|
const clusterResponse = backend.invoke(extractResult.clusteringPrompt);
|
|
370
370
|
if (clusterResponse) {
|
package/dist/mcp.js
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from "./chunk-QVQJPJGX.js";
|
|
16
16
|
import {
|
|
17
17
|
findProjectRoot,
|
|
18
|
+
getDataDir,
|
|
18
19
|
getDbPath,
|
|
19
20
|
getProjectId,
|
|
20
21
|
isInitialized
|
|
@@ -28,7 +29,68 @@ import "./chunk-KFQGP6VL.js";
|
|
|
28
29
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
29
30
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
30
31
|
import { CallToolRequestSchema, ListToolsRequestSchema, RootsListChangedNotificationSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
31
|
-
|
|
32
|
+
|
|
33
|
+
// src/utils/auto-update.ts
|
|
34
|
+
import { exec, spawn } from "child_process";
|
|
35
|
+
import { readFileSync, writeFileSync, existsSync } from "fs";
|
|
36
|
+
import { join } from "path";
|
|
37
|
+
var CHECK_INTERVAL_MS = 4 * 60 * 60 * 1e3;
|
|
38
|
+
function getLastCheckPath() {
|
|
39
|
+
return join(getDataDir(), "last-update-check.json");
|
|
40
|
+
}
|
|
41
|
+
function shouldCheck() {
|
|
42
|
+
const path = getLastCheckPath();
|
|
43
|
+
if (!existsSync(path)) return true;
|
|
44
|
+
try {
|
|
45
|
+
const data = JSON.parse(readFileSync(path, "utf-8"));
|
|
46
|
+
return Date.now() - data.checkedAt > CHECK_INTERVAL_MS;
|
|
47
|
+
} catch {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function markChecked() {
|
|
52
|
+
writeFileSync(getLastCheckPath(), JSON.stringify({ checkedAt: Date.now() }), "utf-8");
|
|
53
|
+
}
|
|
54
|
+
function getCurrentVersion() {
|
|
55
|
+
const pkgPath = new URL("../../package.json", import.meta.url);
|
|
56
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
57
|
+
return pkg.version;
|
|
58
|
+
}
|
|
59
|
+
function isNewer(latest, current) {
|
|
60
|
+
const l = latest.split(".").map(Number);
|
|
61
|
+
const c = current.split(".").map(Number);
|
|
62
|
+
for (let i = 0; i < 3; i++) {
|
|
63
|
+
if ((l[i] || 0) > (c[i] || 0)) return true;
|
|
64
|
+
if ((l[i] || 0) < (c[i] || 0)) return false;
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
function checkForUpdates() {
|
|
69
|
+
try {
|
|
70
|
+
if (!shouldCheck()) return;
|
|
71
|
+
} catch {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const current = getCurrentVersion();
|
|
75
|
+
exec("npm view agentcache version", { timeout: 1e4 }, (err, stdout) => {
|
|
76
|
+
if (err || !stdout) return;
|
|
77
|
+
const latest = stdout.trim();
|
|
78
|
+
if (!latest || !isNewer(latest, current)) {
|
|
79
|
+
markChecked();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
markChecked();
|
|
83
|
+
const child = spawn("npm", ["install", "-g", `agentcache@${latest}`], {
|
|
84
|
+
detached: true,
|
|
85
|
+
stdio: "ignore",
|
|
86
|
+
shell: true
|
|
87
|
+
});
|
|
88
|
+
child.unref();
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// src/mcp.ts
|
|
93
|
+
import { existsSync as existsSync2 } from "fs";
|
|
32
94
|
import { randomUUID } from "crypto";
|
|
33
95
|
function defaultScope(type) {
|
|
34
96
|
return type === "rule" || type === "lesson" ? "global" : "project";
|
|
@@ -62,6 +124,7 @@ async function startMcpServer() {
|
|
|
62
124
|
);
|
|
63
125
|
server.oninitialized = async () => {
|
|
64
126
|
await resolveRoots(server);
|
|
127
|
+
checkForUpdates();
|
|
65
128
|
};
|
|
66
129
|
server.setNotificationHandler(RootsListChangedNotificationSchema, async () => {
|
|
67
130
|
await resolveRoots(server);
|
|
@@ -281,7 +344,7 @@ ${pendingCount} sessions pending compilation (background compiler already runnin
|
|
|
281
344
|
if (!entry) {
|
|
282
345
|
return { content: [{ type: "text", text: JSON.stringify({ message: "No pending sessions to compile." }) }] };
|
|
283
346
|
}
|
|
284
|
-
if (!
|
|
347
|
+
if (!existsSync2(entry.transcriptPath)) {
|
|
285
348
|
return { content: [{ type: "text", text: JSON.stringify({ message: `Transcript not found: ${entry.transcriptPath}, skipped.` }) }] };
|
|
286
349
|
}
|
|
287
350
|
const events = parseTranscript(entry.transcriptPath);
|