agentcache 0.4.2 → 0.5.0-beta.1
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 +280 -151
- package/dist/chunk-4T3I3ACZ.js +6592 -0
- package/dist/chunk-ECMT4ANK.js +1725 -0
- package/dist/{chunk-T4COG3XD.js → chunk-R5I6WWSD.js} +31 -14
- package/dist/chunk-RXGW4Q3G.js +109 -0
- package/dist/chunk-XRJ6QW6N.js +92 -0
- package/dist/cli.js +2535 -292
- package/dist/device-id-RV7RO5RB.js +7 -0
- package/dist/ide-detector-ETGAVVXO.js +8 -0
- package/dist/mcp.d.ts +734 -2
- package/dist/mcp.js +1126 -446
- package/dist/{paths-5LZRKNYY.js → paths-NTZ2357O.js} +3 -2
- package/dist/postinstall.js +1 -65
- package/dist/setup-CXZFERQE.js +48 -0
- package/docs/compatibility.md +146 -0
- package/docs/demo-script.md +121 -0
- package/docs/launch-copy.md +127 -0
- package/docs/privacy.md +173 -0
- package/docs/troubleshooting.md +206 -0
- package/package.json +32 -14
- package/dist/3-canonicalizer-HIN2F7SZ.js +0 -11
- package/dist/chunk-5UO7NJPQ.js +0 -71
- package/dist/chunk-CUBZRYS5.js +0 -580
- package/dist/chunk-GGAATZKM.js +0 -120
- package/dist/chunk-JUDLOBOC.js +0 -77
- package/dist/chunk-KFQGP6VL.js +0 -33
- package/dist/chunk-PSASDZQE.js +0 -490
- package/dist/chunk-SLRKWMSE.js +0 -202
- package/dist/chunk-T7BJPANN.js +0 -45
- package/dist/chunk-WTXSZBQE.js +0 -388
- package/dist/compile-all-PTWTZVP5.js +0 -495
- package/dist/ide-detector-5TRCR4F5.js +0 -7
- package/dist/pre-tool-use-A4AJHZOJ.js +0 -30
- package/dist/session-start-DGMGEAJU.js +0 -78
- package/dist/setup-CVG35TUZ.js +0 -51
- package/dist/sqlite-NM2BVHUY.js +0 -7
- package/dist/stop-WGGRX6TQ.js +0 -38
- package/dist/transcript-JWSGSDSF.js +0 -24
|
@@ -5,27 +5,39 @@ import { homedir } from "os";
|
|
|
5
5
|
import { createHash } from "crypto";
|
|
6
6
|
|
|
7
7
|
// src/utils/git.ts
|
|
8
|
-
import {
|
|
9
|
-
|
|
8
|
+
import { execFileSync } from "child_process";
|
|
9
|
+
import { realpathSync } from "fs";
|
|
10
|
+
import { isAbsolute, resolve } from "path";
|
|
11
|
+
function run(args, cwd) {
|
|
10
12
|
try {
|
|
11
|
-
return
|
|
13
|
+
return execFileSync("git", args, {
|
|
14
|
+
cwd,
|
|
15
|
+
encoding: "utf-8",
|
|
16
|
+
timeout: 5e3,
|
|
17
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
18
|
+
}).trim();
|
|
12
19
|
} catch {
|
|
13
20
|
return "";
|
|
14
21
|
}
|
|
15
22
|
}
|
|
16
|
-
function getGitContext(projectRoot) {
|
|
17
|
-
const empty = { branch: "", commit: "", recentCommits: [], modifiedFiles: [] };
|
|
18
|
-
if (!run("git rev-parse --git-dir", projectRoot)) return empty;
|
|
19
|
-
const branch = run("git rev-parse --abbrev-ref HEAD", projectRoot);
|
|
20
|
-
const commit = run("git rev-parse --short HEAD", projectRoot);
|
|
21
|
-
const recentCommits = run("git log --oneline -10", projectRoot).split("\n").filter(Boolean);
|
|
22
|
-
const modifiedFiles = run("git diff --name-only HEAD~5 HEAD", projectRoot).split("\n").filter(Boolean);
|
|
23
|
-
return { branch, commit, recentCommits, modifiedFiles };
|
|
24
|
-
}
|
|
25
23
|
function getGitRoot(cwd) {
|
|
26
|
-
const root = run("
|
|
24
|
+
const root = run(["rev-parse", "--show-toplevel"], cwd);
|
|
27
25
|
return root || null;
|
|
28
26
|
}
|
|
27
|
+
function getGitRemote(cwd) {
|
|
28
|
+
const remote = run(["config", "--get", "remote.origin.url"], cwd);
|
|
29
|
+
return remote || null;
|
|
30
|
+
}
|
|
31
|
+
function getGitCommonDir(cwd) {
|
|
32
|
+
const commonDir = run(["rev-parse", "--git-common-dir"], cwd);
|
|
33
|
+
if (!commonDir) return null;
|
|
34
|
+
const absolute = isAbsolute(commonDir) ? commonDir : resolve(cwd, commonDir);
|
|
35
|
+
try {
|
|
36
|
+
return realpathSync.native(absolute);
|
|
37
|
+
} catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
29
41
|
|
|
30
42
|
// src/utils/paths.ts
|
|
31
43
|
function getDataDir() {
|
|
@@ -34,6 +46,9 @@ function getDataDir() {
|
|
|
34
46
|
function getDbPath() {
|
|
35
47
|
return join(getDataDir(), "agentcache.db");
|
|
36
48
|
}
|
|
49
|
+
function getSessionDbPath() {
|
|
50
|
+
return join(getDataDir(), "agentcache-v2.db");
|
|
51
|
+
}
|
|
37
52
|
function isInitialized() {
|
|
38
53
|
return existsSync(getDbPath());
|
|
39
54
|
}
|
|
@@ -66,10 +81,12 @@ function getContinueSessionsDir() {
|
|
|
66
81
|
}
|
|
67
82
|
|
|
68
83
|
export {
|
|
69
|
-
getGitContext,
|
|
70
84
|
getGitRoot,
|
|
85
|
+
getGitRemote,
|
|
86
|
+
getGitCommonDir,
|
|
71
87
|
getDataDir,
|
|
72
88
|
getDbPath,
|
|
89
|
+
getSessionDbPath,
|
|
73
90
|
isInitialized,
|
|
74
91
|
migrateFromLegacy,
|
|
75
92
|
findProjectRoot,
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// src/utils/ide-detector.ts
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
import { dirname, join, posix, win32 } from "path";
|
|
4
|
+
import { homedir } from "os";
|
|
5
|
+
function getRooConfigPath(home = homedir()) {
|
|
6
|
+
if (process.platform === "darwin") {
|
|
7
|
+
return join(home, "Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json");
|
|
8
|
+
}
|
|
9
|
+
if (process.platform === "win32") {
|
|
10
|
+
return join(process.env.APPDATA || join(home, "AppData/Roaming"), "Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json");
|
|
11
|
+
}
|
|
12
|
+
return join(home, ".config/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json");
|
|
13
|
+
}
|
|
14
|
+
function getWindsurfConfigPath(home = homedir()) {
|
|
15
|
+
return join(home, ".codeium", "windsurf", "mcp_config.json");
|
|
16
|
+
}
|
|
17
|
+
function getContinueConfigPath(home = homedir()) {
|
|
18
|
+
return join(home, ".continue", "mcpServers", "agentcache.json");
|
|
19
|
+
}
|
|
20
|
+
function getCodexConfigPath(home = homedir()) {
|
|
21
|
+
return join(home, ".codex", "config.toml");
|
|
22
|
+
}
|
|
23
|
+
function resolveGooseConfigPath(options = {}) {
|
|
24
|
+
const platform = options.platform ?? process.platform;
|
|
25
|
+
const env = options.env ?? process.env;
|
|
26
|
+
const home = options.home ?? homedir();
|
|
27
|
+
const path = platform === "win32" ? win32 : posix;
|
|
28
|
+
if (env.GOOSE_PATH_ROOT !== void 0) {
|
|
29
|
+
return path.join(env.GOOSE_PATH_ROOT, "config", "config.yaml");
|
|
30
|
+
}
|
|
31
|
+
if (platform !== "win32" && env.XDG_CONFIG_HOME && path.isAbsolute(env.XDG_CONFIG_HOME)) {
|
|
32
|
+
return path.join(env.XDG_CONFIG_HOME, "goose", "config.yaml");
|
|
33
|
+
}
|
|
34
|
+
if (platform === "win32") {
|
|
35
|
+
return path.join(
|
|
36
|
+
env.APPDATA || path.join(home, "AppData", "Roaming"),
|
|
37
|
+
"Block",
|
|
38
|
+
"goose",
|
|
39
|
+
"config",
|
|
40
|
+
"config.yaml"
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
return path.join(home, ".config", "goose", "config.yaml");
|
|
44
|
+
}
|
|
45
|
+
function detectInstalledIdes(homeDirectory = homedir()) {
|
|
46
|
+
const home = homeDirectory;
|
|
47
|
+
const legacyRooConfigPath = join(home, ".roo", "mcp.json");
|
|
48
|
+
const gooseConfigPath = resolveGooseConfigPath({ home });
|
|
49
|
+
return [
|
|
50
|
+
{
|
|
51
|
+
adapterId: "claude-code",
|
|
52
|
+
name: "Claude Code",
|
|
53
|
+
detected: existsSync(join(home, ".claude")),
|
|
54
|
+
mcpConfigPath: join(home, ".claude.json"),
|
|
55
|
+
mcpConfigFormat: "claude-settings"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
adapterId: "cursor",
|
|
59
|
+
name: "Cursor",
|
|
60
|
+
detected: existsSync(join(home, ".cursor")),
|
|
61
|
+
mcpConfigPath: join(home, ".cursor", "mcp.json"),
|
|
62
|
+
mcpConfigFormat: "mcp-json"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
adapterId: "roo-code",
|
|
66
|
+
name: "Roo Code",
|
|
67
|
+
detected: existsSync(getRooConfigPath(home)) || existsSync(legacyRooConfigPath),
|
|
68
|
+
mcpConfigPath: getRooConfigPath(home),
|
|
69
|
+
legacyMcpConfigPaths: [legacyRooConfigPath],
|
|
70
|
+
mcpConfigFormat: "mcp-json"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
adapterId: "windsurf",
|
|
74
|
+
name: "Windsurf",
|
|
75
|
+
detected: existsSync(join(home, ".codeium", "windsurf")) || existsSync(join(home, ".windsurf")),
|
|
76
|
+
mcpConfigPath: getWindsurfConfigPath(home),
|
|
77
|
+
legacyMcpConfigPaths: [join(home, ".windsurf", "mcp.json")],
|
|
78
|
+
mcpConfigFormat: "mcp-json"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
adapterId: "continue",
|
|
82
|
+
name: "Continue",
|
|
83
|
+
detected: existsSync(join(home, ".continue")),
|
|
84
|
+
mcpConfigPath: getContinueConfigPath(home),
|
|
85
|
+
legacyMcpConfigPaths: [join(home, ".continue", "mcp.json")],
|
|
86
|
+
mcpConfigFormat: "continue-dir"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
adapterId: "codex",
|
|
90
|
+
name: "Codex",
|
|
91
|
+
detected: existsSync(join(home, ".codex")),
|
|
92
|
+
mcpConfigPath: getCodexConfigPath(home),
|
|
93
|
+
legacyMcpConfigPaths: [join(home, ".codex", "mcp.json")],
|
|
94
|
+
mcpConfigFormat: "codex-toml"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
adapterId: "goose",
|
|
98
|
+
name: "Goose",
|
|
99
|
+
detected: existsSync(dirname(gooseConfigPath)),
|
|
100
|
+
mcpConfigPath: gooseConfigPath,
|
|
101
|
+
mcpConfigFormat: "goose-yaml"
|
|
102
|
+
}
|
|
103
|
+
];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export {
|
|
107
|
+
resolveGooseConfigPath,
|
|
108
|
+
detectInstalledIdes
|
|
109
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getDataDir
|
|
3
|
+
} from "./chunk-R5I6WWSD.js";
|
|
4
|
+
|
|
5
|
+
// src/utils/device-id.ts
|
|
6
|
+
import { randomBytes as nodeRandomBytes } from "crypto";
|
|
7
|
+
import {
|
|
8
|
+
chmodSync,
|
|
9
|
+
closeSync,
|
|
10
|
+
constants,
|
|
11
|
+
existsSync,
|
|
12
|
+
fsyncSync,
|
|
13
|
+
linkSync,
|
|
14
|
+
lstatSync,
|
|
15
|
+
mkdirSync,
|
|
16
|
+
openSync,
|
|
17
|
+
readFileSync,
|
|
18
|
+
unlinkSync,
|
|
19
|
+
writeFileSync
|
|
20
|
+
} from "fs";
|
|
21
|
+
import { join } from "path";
|
|
22
|
+
var DEVICE_ID_FILE = "device-id";
|
|
23
|
+
var DEVICE_ID_PATTERN = /^dev_[A-Za-z0-9_-]{32}$/;
|
|
24
|
+
function loadOrCreateDeviceId(options = {}) {
|
|
25
|
+
const dataDir = options.dataDir ?? getDataDir();
|
|
26
|
+
const devicePath = join(dataDir, DEVICE_ID_FILE);
|
|
27
|
+
mkdirSync(dataDir, { recursive: true, mode: 448 });
|
|
28
|
+
const directoryStat = lstatSync(dataDir);
|
|
29
|
+
if (directoryStat.isSymbolicLink()) {
|
|
30
|
+
throw new Error("AgentCache data directory must not be a symbolic link");
|
|
31
|
+
}
|
|
32
|
+
if (!directoryStat.isDirectory()) {
|
|
33
|
+
throw new Error("AgentCache data directory must be a directory");
|
|
34
|
+
}
|
|
35
|
+
chmodSync(dataDir, 448);
|
|
36
|
+
if (existsSync(devicePath)) return readStoredDeviceId(devicePath);
|
|
37
|
+
const random = options.randomBytes ?? (() => nodeRandomBytes(24));
|
|
38
|
+
const deviceId = `dev_${random().toString("base64url")}`;
|
|
39
|
+
if (!DEVICE_ID_PATTERN.test(deviceId)) {
|
|
40
|
+
throw new Error("Generated AgentCache device identity is malformed");
|
|
41
|
+
}
|
|
42
|
+
const temporaryPath = join(
|
|
43
|
+
dataDir,
|
|
44
|
+
`.device-id.${process.pid}.${nodeRandomBytes(8).toString("hex")}.tmp`
|
|
45
|
+
);
|
|
46
|
+
let descriptor;
|
|
47
|
+
try {
|
|
48
|
+
descriptor = openSync(
|
|
49
|
+
temporaryPath,
|
|
50
|
+
constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY,
|
|
51
|
+
384
|
|
52
|
+
);
|
|
53
|
+
writeFileSync(descriptor, `${deviceId}
|
|
54
|
+
`, "utf8");
|
|
55
|
+
fsyncSync(descriptor);
|
|
56
|
+
closeSync(descriptor);
|
|
57
|
+
descriptor = void 0;
|
|
58
|
+
try {
|
|
59
|
+
linkSync(temporaryPath, devicePath);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if (!isAlreadyExists(error)) throw error;
|
|
62
|
+
}
|
|
63
|
+
} finally {
|
|
64
|
+
if (descriptor !== void 0) closeSync(descriptor);
|
|
65
|
+
try {
|
|
66
|
+
unlinkSync(temporaryPath);
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return readStoredDeviceId(devicePath);
|
|
71
|
+
}
|
|
72
|
+
function readStoredDeviceId(devicePath) {
|
|
73
|
+
const stat = lstatSync(devicePath);
|
|
74
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > 256) {
|
|
75
|
+
throw new Error("Stored AgentCache device identity is malformed");
|
|
76
|
+
}
|
|
77
|
+
chmodSync(devicePath, 384);
|
|
78
|
+
const value = readFileSync(devicePath, "utf8").trim();
|
|
79
|
+
if (!DEVICE_ID_PATTERN.test(value)) {
|
|
80
|
+
throw new Error("Stored AgentCache device identity is malformed");
|
|
81
|
+
}
|
|
82
|
+
return value;
|
|
83
|
+
}
|
|
84
|
+
function isAlreadyExists(error) {
|
|
85
|
+
return Boolean(
|
|
86
|
+
error && typeof error === "object" && "code" in error && error.code === "EEXIST"
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export {
|
|
91
|
+
loadOrCreateDeviceId
|
|
92
|
+
};
|