engram-mcp-server 1.2.8 → 1.2.9
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 +12 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +6 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/installer/ide-detector.d.ts.map +1 -1
- package/dist/installer/ide-detector.js +10 -6
- package/dist/installer/ide-detector.js.map +1 -1
- package/dist/installer/index.d.ts.map +1 -1
- package/dist/installer/index.js +79 -15
- package/dist/installer/index.js.map +1 -1
- package/package.json +6 -3
- package/dist/installer.d.ts +0 -2
- package/dist/installer.d.ts.map +0 -1
- package/dist/installer.js +0 -315
- package/dist/installer.js.map +0 -1
- package/dist/src/constants.d.ts +0 -21
- package/dist/src/constants.d.ts.map +0 -1
- package/dist/src/constants.js +0 -81
- package/dist/src/constants.js.map +0 -1
- package/dist/src/database.d.ts +0 -32
- package/dist/src/database.d.ts.map +0 -1
- package/dist/src/database.js +0 -143
- package/dist/src/database.js.map +0 -1
- package/dist/src/errors.d.ts +0 -40
- package/dist/src/errors.d.ts.map +0 -1
- package/dist/src/errors.js +0 -63
- package/dist/src/errors.js.map +0 -1
- package/dist/src/index.d.ts +0 -3
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -89
- package/dist/src/index.js.map +0 -1
- package/dist/src/installer/config-writer.d.ts +0 -25
- package/dist/src/installer/config-writer.d.ts.map +0 -1
- package/dist/src/installer/config-writer.js +0 -86
- package/dist/src/installer/config-writer.js.map +0 -1
- package/dist/src/installer/ide-configs.d.ts +0 -19
- package/dist/src/installer/ide-configs.d.ts.map +0 -1
- package/dist/src/installer/ide-configs.js +0 -131
- package/dist/src/installer/ide-configs.js.map +0 -1
- package/dist/src/installer/ide-detector.d.ts +0 -6
- package/dist/src/installer/ide-detector.d.ts.map +0 -1
- package/dist/src/installer/ide-detector.js +0 -45
- package/dist/src/installer/ide-detector.js.map +0 -1
- package/dist/src/installer/index.d.ts +0 -2
- package/dist/src/installer/index.d.ts.map +0 -1
- package/dist/src/installer/index.js +0 -229
- package/dist/src/installer/index.js.map +0 -1
- package/dist/src/logger.d.ts +0 -10
- package/dist/src/logger.d.ts.map +0 -1
- package/dist/src/logger.js +0 -51
- package/dist/src/logger.js.map +0 -1
- package/dist/src/migrations.d.ts +0 -4
- package/dist/src/migrations.d.ts.map +0 -1
- package/dist/src/migrations.js +0 -343
- package/dist/src/migrations.js.map +0 -1
- package/dist/src/repositories/changes.repo.d.ts +0 -35
- package/dist/src/repositories/changes.repo.d.ts.map +0 -1
- package/dist/src/repositories/changes.repo.js +0 -53
- package/dist/src/repositories/changes.repo.js.map +0 -1
- package/dist/src/repositories/config.repo.d.ts +0 -11
- package/dist/src/repositories/config.repo.d.ts.map +0 -1
- package/dist/src/repositories/config.repo.js +0 -38
- package/dist/src/repositories/config.repo.js.map +0 -1
- package/dist/src/repositories/conventions.repo.d.ts +0 -15
- package/dist/src/repositories/conventions.repo.d.ts.map +0 -1
- package/dist/src/repositories/conventions.repo.js +0 -39
- package/dist/src/repositories/conventions.repo.js.map +0 -1
- package/dist/src/repositories/decisions.repo.d.ts +0 -19
- package/dist/src/repositories/decisions.repo.d.ts.map +0 -1
- package/dist/src/repositories/decisions.repo.js +0 -48
- package/dist/src/repositories/decisions.repo.js.map +0 -1
- package/dist/src/repositories/events.repo.d.ts +0 -34
- package/dist/src/repositories/events.repo.d.ts.map +0 -1
- package/dist/src/repositories/events.repo.js +0 -71
- package/dist/src/repositories/events.repo.js.map +0 -1
- package/dist/src/repositories/file-notes.repo.d.ts +0 -26
- package/dist/src/repositories/file-notes.repo.d.ts.map +0 -1
- package/dist/src/repositories/file-notes.repo.js +0 -55
- package/dist/src/repositories/file-notes.repo.js.map +0 -1
- package/dist/src/repositories/index.d.ts +0 -38
- package/dist/src/repositories/index.d.ts.map +0 -1
- package/dist/src/repositories/index.js +0 -41
- package/dist/src/repositories/index.js.map +0 -1
- package/dist/src/repositories/milestones.repo.d.ts +0 -10
- package/dist/src/repositories/milestones.repo.d.ts.map +0 -1
- package/dist/src/repositories/milestones.repo.js +0 -20
- package/dist/src/repositories/milestones.repo.js.map +0 -1
- package/dist/src/repositories/sessions.repo.d.ts +0 -27
- package/dist/src/repositories/sessions.repo.d.ts.map +0 -1
- package/dist/src/repositories/sessions.repo.js +0 -61
- package/dist/src/repositories/sessions.repo.js.map +0 -1
- package/dist/src/repositories/snapshot.repo.d.ts +0 -11
- package/dist/src/repositories/snapshot.repo.d.ts.map +0 -1
- package/dist/src/repositories/snapshot.repo.js +0 -17
- package/dist/src/repositories/snapshot.repo.js.map +0 -1
- package/dist/src/repositories/tasks.repo.d.ts +0 -40
- package/dist/src/repositories/tasks.repo.d.ts.map +0 -1
- package/dist/src/repositories/tasks.repo.js +0 -90
- package/dist/src/repositories/tasks.repo.js.map +0 -1
- package/dist/src/response.d.ts +0 -28
- package/dist/src/response.d.ts.map +0 -1
- package/dist/src/response.js +0 -38
- package/dist/src/response.js.map +0 -1
- package/dist/src/scripts/install-hooks.d.ts +0 -3
- package/dist/src/scripts/install-hooks.d.ts.map +0 -1
- package/dist/src/scripts/install-hooks.js +0 -89
- package/dist/src/scripts/install-hooks.js.map +0 -1
- package/dist/src/services/compaction.service.d.ts +0 -27
- package/dist/src/services/compaction.service.d.ts.map +0 -1
- package/dist/src/services/compaction.service.js +0 -93
- package/dist/src/services/compaction.service.js.map +0 -1
- package/dist/src/services/event-trigger.service.d.ts +0 -24
- package/dist/src/services/event-trigger.service.d.ts.map +0 -1
- package/dist/src/services/event-trigger.service.js +0 -60
- package/dist/src/services/event-trigger.service.js.map +0 -1
- package/dist/src/services/git.service.d.ts +0 -20
- package/dist/src/services/git.service.d.ts.map +0 -1
- package/dist/src/services/git.service.js +0 -88
- package/dist/src/services/git.service.js.map +0 -1
- package/dist/src/services/index.d.ts +0 -5
- package/dist/src/services/index.d.ts.map +0 -1
- package/dist/src/services/index.js +0 -8
- package/dist/src/services/index.js.map +0 -1
- package/dist/src/services/project-scan.service.d.ts +0 -19
- package/dist/src/services/project-scan.service.d.ts.map +0 -1
- package/dist/src/services/project-scan.service.js +0 -66
- package/dist/src/services/project-scan.service.js.map +0 -1
- package/dist/src/tools/backup.d.ts +0 -3
- package/dist/src/tools/backup.d.ts.map +0 -1
- package/dist/src/tools/backup.js +0 -191
- package/dist/src/tools/backup.js.map +0 -1
- package/dist/src/tools/changes.d.ts +0 -3
- package/dist/src/tools/changes.d.ts.map +0 -1
- package/dist/src/tools/changes.js +0 -97
- package/dist/src/tools/changes.js.map +0 -1
- package/dist/src/tools/compaction.d.ts +0 -3
- package/dist/src/tools/compaction.d.ts.map +0 -1
- package/dist/src/tools/compaction.js +0 -151
- package/dist/src/tools/compaction.js.map +0 -1
- package/dist/src/tools/conventions.d.ts +0 -3
- package/dist/src/tools/conventions.d.ts.map +0 -1
- package/dist/src/tools/conventions.js +0 -121
- package/dist/src/tools/conventions.js.map +0 -1
- package/dist/src/tools/decisions.d.ts +0 -3
- package/dist/src/tools/decisions.d.ts.map +0 -1
- package/dist/src/tools/decisions.js +0 -136
- package/dist/src/tools/decisions.js.map +0 -1
- package/dist/src/tools/export-import.d.ts +0 -3
- package/dist/src/tools/export-import.d.ts.map +0 -1
- package/dist/src/tools/export-import.js +0 -180
- package/dist/src/tools/export-import.js.map +0 -1
- package/dist/src/tools/file-notes.d.ts +0 -3
- package/dist/src/tools/file-notes.d.ts.map +0 -1
- package/dist/src/tools/file-notes.js +0 -104
- package/dist/src/tools/file-notes.js.map +0 -1
- package/dist/src/tools/intelligence.d.ts +0 -3
- package/dist/src/tools/intelligence.d.ts.map +0 -1
- package/dist/src/tools/intelligence.js +0 -427
- package/dist/src/tools/intelligence.js.map +0 -1
- package/dist/src/tools/milestones.d.ts +0 -3
- package/dist/src/tools/milestones.d.ts.map +0 -1
- package/dist/src/tools/milestones.js +0 -71
- package/dist/src/tools/milestones.js.map +0 -1
- package/dist/src/tools/scheduler.d.ts +0 -3
- package/dist/src/tools/scheduler.d.ts.map +0 -1
- package/dist/src/tools/scheduler.js +0 -363
- package/dist/src/tools/scheduler.js.map +0 -1
- package/dist/src/tools/sessions.d.ts +0 -3
- package/dist/src/tools/sessions.d.ts.map +0 -1
- package/dist/src/tools/sessions.js +0 -356
- package/dist/src/tools/sessions.js.map +0 -1
- package/dist/src/tools/stats.d.ts +0 -3
- package/dist/src/tools/stats.d.ts.map +0 -1
- package/dist/src/tools/stats.js +0 -63
- package/dist/src/tools/stats.js.map +0 -1
- package/dist/src/tools/tasks.d.ts +0 -3
- package/dist/src/tools/tasks.d.ts.map +0 -1
- package/dist/src/tools/tasks.js +0 -206
- package/dist/src/tools/tasks.js.map +0 -1
- package/dist/src/types.d.ts +0 -170
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -5
- package/dist/src/types.js.map +0 -1
- package/dist/src/utils.d.ts +0 -58
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/utils.js +0 -190
- package/dist/src/utils.js.map +0 -1
- package/dist/tests/helpers/test-db.d.ts +0 -12
- package/dist/tests/helpers/test-db.d.ts.map +0 -1
- package/dist/tests/helpers/test-db.js +0 -149
- package/dist/tests/helpers/test-db.js.map +0 -1
- package/dist/tests/installer/installer.test.d.ts +0 -2
- package/dist/tests/installer/installer.test.d.ts.map +0 -1
- package/dist/tests/installer/installer.test.js +0 -160
- package/dist/tests/installer/installer.test.js.map +0 -1
- package/dist/tests/repositories/repos.test.d.ts +0 -2
- package/dist/tests/repositories/repos.test.d.ts.map +0 -1
- package/dist/tests/repositories/repos.test.js +0 -220
- package/dist/tests/repositories/repos.test.js.map +0 -1
- package/dist/tools/maintenance.d.ts +0 -3
- package/dist/tools/maintenance.d.ts.map +0 -1
- package/dist/tools/maintenance.js +0 -647
- package/dist/tools/maintenance.js.map +0 -1
- package/dist/tools/memory.d.ts +0 -3
- package/dist/tools/memory.d.ts.map +0 -1
- package/dist/tools/memory.js +0 -446
- package/dist/tools/memory.js.map +0 -1
package/dist/installer.js
DELETED
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import os from "os";
|
|
4
|
-
import readline from "readline";
|
|
5
|
-
const HOME = os.homedir();
|
|
6
|
-
const APPDATA = process.env.APPDATA || path.join(HOME, ".config");
|
|
7
|
-
const IDE_CONFIGS = {
|
|
8
|
-
antigravity: {
|
|
9
|
-
name: "Antigravity IDE",
|
|
10
|
-
format: "mcpServers",
|
|
11
|
-
scopes: {
|
|
12
|
-
global: [path.join(HOME, ".gemini", "antigravity", "mcp_config.json")],
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
cursor: {
|
|
16
|
-
name: "Cursor",
|
|
17
|
-
format: "mcpServers",
|
|
18
|
-
scopes: {
|
|
19
|
-
global: [
|
|
20
|
-
path.join(HOME, ".cursor", "mcp.json"),
|
|
21
|
-
path.join(APPDATA, "Cursor", "mcp.json"),
|
|
22
|
-
],
|
|
23
|
-
localDirs: [".cursor"],
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
vscode: {
|
|
27
|
-
name: "VS Code (Copilot)",
|
|
28
|
-
format: "mcpServers",
|
|
29
|
-
scopes: {
|
|
30
|
-
global: [
|
|
31
|
-
path.join(APPDATA, "Code", "User", "mcp.json"),
|
|
32
|
-
path.join(HOME, ".vscode", "mcp.json"),
|
|
33
|
-
],
|
|
34
|
-
localDirs: ["", ".vscode"], // "" means root of workspace, .vscode is fallback
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
cline: {
|
|
38
|
-
name: "Cline / Roo Code",
|
|
39
|
-
format: "mcpServers",
|
|
40
|
-
scopes: {
|
|
41
|
-
global: [
|
|
42
|
-
path.join(APPDATA, "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"),
|
|
43
|
-
path.join(HOME, ".cline", "mcp_settings.json"),
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
windsurf: {
|
|
48
|
-
name: "Windsurf",
|
|
49
|
-
format: "mcpServers",
|
|
50
|
-
scopes: {
|
|
51
|
-
global: [
|
|
52
|
-
path.join(HOME, ".codeium", "windsurf", "mcp_config.json"),
|
|
53
|
-
path.join(APPDATA, "Windsurf", "mcp.json"),
|
|
54
|
-
],
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
visualstudio: {
|
|
58
|
-
name: "Visual Studio 2022/2026",
|
|
59
|
-
format: "mcpServers",
|
|
60
|
-
scopes: {
|
|
61
|
-
global: [path.join(HOME, ".mcp.json")],
|
|
62
|
-
localDirs: ["", ".vs"], // "" means root of solution (e.g. SolutionDir/.mcp.json)
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
// ─── Engram Entry ────────────────────────────────────────────────────
|
|
67
|
-
function makeEngramEntry(format) {
|
|
68
|
-
const entry = {
|
|
69
|
-
command: "npx",
|
|
70
|
-
args: ["-y", "engram-mcp-server"],
|
|
71
|
-
};
|
|
72
|
-
if (format === "servers") {
|
|
73
|
-
// VS Code uses a slightly different shape
|
|
74
|
-
return { type: "stdio", ...entry };
|
|
75
|
-
}
|
|
76
|
-
return entry;
|
|
77
|
-
}
|
|
78
|
-
// ─── Config Manipulation ─────────────────────────────────────────────
|
|
79
|
-
function readJson(filePath) {
|
|
80
|
-
try {
|
|
81
|
-
return JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function writeJson(filePath, data) {
|
|
88
|
-
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
89
|
-
fs.writeFileSync(filePath, JSON.stringify(data, null, 2) + "\n", "utf-8");
|
|
90
|
-
}
|
|
91
|
-
function addToConfig(configPath, format) {
|
|
92
|
-
let config = readJson(configPath) || {};
|
|
93
|
-
const key = format; // "mcpServers" or "servers"
|
|
94
|
-
if (!config[key])
|
|
95
|
-
config[key] = {};
|
|
96
|
-
const newEntry = makeEngramEntry(format);
|
|
97
|
-
if (config[key].engram) {
|
|
98
|
-
// Already exists — check if it's identical
|
|
99
|
-
if (JSON.stringify(config[key].engram) === JSON.stringify(newEntry)) {
|
|
100
|
-
return "exists";
|
|
101
|
-
}
|
|
102
|
-
// Exists but different (e.g. old local path) — update to use npx
|
|
103
|
-
config[key].engram = newEntry;
|
|
104
|
-
writeJson(configPath, config);
|
|
105
|
-
return "updated";
|
|
106
|
-
}
|
|
107
|
-
config[key].engram = newEntry;
|
|
108
|
-
writeJson(configPath, config);
|
|
109
|
-
return "added";
|
|
110
|
-
}
|
|
111
|
-
// ─── Environment Detection ──────────────────────────────────────────
|
|
112
|
-
function detectCurrentIde() {
|
|
113
|
-
const env = process.env;
|
|
114
|
-
// Explicit hints usually present in extension hosts or integrated terminals
|
|
115
|
-
if (env.ANTIGRAVITY_EDITOR_APP_ROOT)
|
|
116
|
-
return "antigravity";
|
|
117
|
-
if (env.WINDSURF_PROFILE)
|
|
118
|
-
return "windsurf";
|
|
119
|
-
// VS Code forks share TERM_PROGRAM="vscode", but we can distinguish them by checking VSCODE_CWD or path
|
|
120
|
-
if (env.TERM_PROGRAM === "vscode" || env.VSCODE_IPC_HOOK || env.VSCODE_CWD) {
|
|
121
|
-
const cwdLower = (env.VSCODE_CWD || "").toLowerCase();
|
|
122
|
-
if (cwdLower.includes("antigravity"))
|
|
123
|
-
return "antigravity";
|
|
124
|
-
if (cwdLower.includes("cursor"))
|
|
125
|
-
return "cursor";
|
|
126
|
-
if (cwdLower.includes("windsurf"))
|
|
127
|
-
return "windsurf";
|
|
128
|
-
// Final fallback: check PATH but ONLY for the specific IDE execution paths, not generically
|
|
129
|
-
const pathLower = (env.PATH || "").toLowerCase();
|
|
130
|
-
if (pathLower.includes("antigravity"))
|
|
131
|
-
return "antigravity";
|
|
132
|
-
if (pathLower.includes("cursor\\cli"))
|
|
133
|
-
return "cursor"; // more specific to avoid false positives
|
|
134
|
-
if (pathLower.includes("windsurf"))
|
|
135
|
-
return "windsurf";
|
|
136
|
-
return "vscode";
|
|
137
|
-
}
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
// ─── Main ────────────────────────────────────────────────────────────
|
|
141
|
-
async function askQuestion(query) {
|
|
142
|
-
const rl = readline.createInterface({
|
|
143
|
-
input: process.stdin,
|
|
144
|
-
output: process.stdout,
|
|
145
|
-
});
|
|
146
|
-
return new Promise(resolve => rl.question(query, ans => {
|
|
147
|
-
rl.close();
|
|
148
|
-
resolve(ans);
|
|
149
|
-
}));
|
|
150
|
-
}
|
|
151
|
-
export async function runInstaller(args) {
|
|
152
|
-
if (args.includes("--list")) {
|
|
153
|
-
console.log("\nEngram can be auto-installed into these IDEs:\n");
|
|
154
|
-
for (const [id, ide] of Object.entries(IDE_CONFIGS)) {
|
|
155
|
-
let found = false;
|
|
156
|
-
if (ide.scopes.global) {
|
|
157
|
-
found = !!ide.scopes.global.find(p => fs.existsSync(p) || fs.existsSync(path.dirname(p)));
|
|
158
|
-
}
|
|
159
|
-
console.log(` ${id.padEnd(15)} ${ide.name}${ide.scopes.localDirs ? " (Global / Local)" : " (Global)"} ${found ? "✅ global path detected" : "❌ global not found"}`);
|
|
160
|
-
}
|
|
161
|
-
process.exit(0);
|
|
162
|
-
}
|
|
163
|
-
// Specific IDE requested via CLI flag?
|
|
164
|
-
const ideFlagIdx = args.indexOf("--ide");
|
|
165
|
-
if (ideFlagIdx >= 0 && args[ideFlagIdx + 1]) {
|
|
166
|
-
const targetIde = args[ideFlagIdx + 1];
|
|
167
|
-
if (!IDE_CONFIGS[targetIde]) {
|
|
168
|
-
console.error(`Unknown IDE: "${targetIde}". Options: ${Object.keys(IDE_CONFIGS).join(", ")}`);
|
|
169
|
-
process.exit(1);
|
|
170
|
-
}
|
|
171
|
-
await performInstallationInteractive({ [targetIde]: IDE_CONFIGS[targetIde] });
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
console.log("\n🧠 Engram MCP Installer\n");
|
|
175
|
-
// Auto-detect environment if it's run without specific args
|
|
176
|
-
const currentIde = detectCurrentIde();
|
|
177
|
-
if (currentIde && IDE_CONFIGS[currentIde]) {
|
|
178
|
-
console.log(`🔍 Detected environment: ${IDE_CONFIGS[currentIde].name}`);
|
|
179
|
-
const ans = await askQuestion(" Install Engram for this IDE? [Y/n]: ");
|
|
180
|
-
if (ans.trim().toLowerCase() !== 'n') {
|
|
181
|
-
await performInstallationInteractive({ [currentIde]: IDE_CONFIGS[currentIde] });
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
console.log(""); // Skip to menu
|
|
185
|
-
}
|
|
186
|
-
// Interactive Menu
|
|
187
|
-
console.log("Where would you like to configure the Engram MCP server?\n");
|
|
188
|
-
const ideKeys = Object.keys(IDE_CONFIGS);
|
|
189
|
-
ideKeys.forEach((key, index) => {
|
|
190
|
-
console.log(` ${index + 1}. ${IDE_CONFIGS[key].name}`);
|
|
191
|
-
});
|
|
192
|
-
const allOpt = ideKeys.length + 1;
|
|
193
|
-
const customOpt = ideKeys.length + 2;
|
|
194
|
-
console.log(` ${allOpt}. Install to ALL detected IDEs`);
|
|
195
|
-
console.log(` ${customOpt}. Custom IDE config path...`);
|
|
196
|
-
console.log(` 0. Cancel`);
|
|
197
|
-
const answer = await askQuestion(`\nSelect an option [0-${customOpt}]: `);
|
|
198
|
-
const choice = parseInt(answer.trim(), 10);
|
|
199
|
-
if (isNaN(choice) || choice === 0) {
|
|
200
|
-
console.log("Installation cancelled.");
|
|
201
|
-
process.exit(0);
|
|
202
|
-
}
|
|
203
|
-
let idesToProcess = {};
|
|
204
|
-
if (choice === allOpt) {
|
|
205
|
-
idesToProcess = IDE_CONFIGS; // All
|
|
206
|
-
}
|
|
207
|
-
else if (choice === customOpt) {
|
|
208
|
-
const customPath = await askQuestion("Enter the absolute path to your MCP config JSON file: ");
|
|
209
|
-
if (!customPath.trim()) {
|
|
210
|
-
console.log("No path provided. Exiting.");
|
|
211
|
-
process.exit(1);
|
|
212
|
-
}
|
|
213
|
-
idesToProcess = {
|
|
214
|
-
custom: {
|
|
215
|
-
name: "Custom Path",
|
|
216
|
-
paths: [customPath.trim()],
|
|
217
|
-
format: "mcpServers" // Safe default for unknown IDEs
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
else if (choice >= 1 && choice <= ideKeys.length) {
|
|
222
|
-
const selectedKey = ideKeys[choice - 1];
|
|
223
|
-
idesToProcess = { [selectedKey]: IDE_CONFIGS[selectedKey] };
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
console.log("\nInvalid selection. Exiting.");
|
|
227
|
-
process.exit(1);
|
|
228
|
-
}
|
|
229
|
-
await performInstallationInteractive(idesToProcess);
|
|
230
|
-
}
|
|
231
|
-
// Interactive wizard to resolve specific config paths for the selected IDEs
|
|
232
|
-
async function performInstallationInteractive(idesToProcess) {
|
|
233
|
-
let resolvedConfigs = [];
|
|
234
|
-
for (const [id, ide] of Object.entries(idesToProcess)) {
|
|
235
|
-
if (id === "custom") {
|
|
236
|
-
resolvedConfigs.push({ name: ide.name, path: ide.paths[0], format: ide.format });
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
const supportsLocal = ide.scopes?.localDirs && ide.scopes.localDirs.length > 0;
|
|
240
|
-
const supportsGlobal = ide.scopes?.global && ide.scopes.global.length > 0;
|
|
241
|
-
let targetScope = "global";
|
|
242
|
-
if (supportsLocal && supportsGlobal) {
|
|
243
|
-
console.log(`\n${ide.name} supports multiple installation scopes.`);
|
|
244
|
-
console.log(` 1. Global (Applies to all projects)`);
|
|
245
|
-
console.log(` 2. Local (Applies to a specific Solution/Workspace)`);
|
|
246
|
-
const scopeAns = await askQuestion("Select scope [1-2] (default 1): ");
|
|
247
|
-
if (scopeAns.trim() === "2") {
|
|
248
|
-
targetScope = "local";
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
else if (supportsLocal && !supportsGlobal) {
|
|
252
|
-
targetScope = "local";
|
|
253
|
-
}
|
|
254
|
-
if (targetScope === "global") {
|
|
255
|
-
const configPath = ide.scopes.global.find((p) => fs.existsSync(p)) || ide.scopes.global[0];
|
|
256
|
-
resolvedConfigs.push({ name: `${ide.name} (Global)`, path: configPath, format: ide.format });
|
|
257
|
-
}
|
|
258
|
-
else if (targetScope === "local") {
|
|
259
|
-
const solutionDir = await askQuestion(`Enter the absolute path to your ${ide.name} Solution/Workspace directory:\n> `);
|
|
260
|
-
if (!solutionDir.trim()) {
|
|
261
|
-
console.log(`Skipping ${ide.name} local installation (no path provided).`);
|
|
262
|
-
continue;
|
|
263
|
-
}
|
|
264
|
-
// For Visual studio, it's .vs/mcp.json or .mcp.json at root. We'll use the first defined localDir.
|
|
265
|
-
const localDirPrefix = ide.scopes.localDirs[0];
|
|
266
|
-
let configFileName = "mcp.json";
|
|
267
|
-
if (localDirPrefix === "") {
|
|
268
|
-
// If the config is at the absolute root of the workspace, it's virtually always hidden (.mcp.json)
|
|
269
|
-
configFileName = ".mcp.json";
|
|
270
|
-
}
|
|
271
|
-
const configPath = path.join(solutionDir.trim(), localDirPrefix, configFileName);
|
|
272
|
-
resolvedConfigs.push({ name: `${ide.name} (Local: ${path.basename(solutionDir)})`, path: configPath, format: ide.format });
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
await performInstallation(resolvedConfigs);
|
|
276
|
-
}
|
|
277
|
-
async function performInstallation(configs) {
|
|
278
|
-
let installed = 0;
|
|
279
|
-
for (const config of configs) {
|
|
280
|
-
try {
|
|
281
|
-
const result = addToConfig(config.path, config.format);
|
|
282
|
-
console.log(`\n ✅ ${config.name}`);
|
|
283
|
-
console.log(` Config: ${config.path}`);
|
|
284
|
-
let statusText = "";
|
|
285
|
-
if (result === "added")
|
|
286
|
-
statusText = "Engram added";
|
|
287
|
-
else if (result === "updated")
|
|
288
|
-
statusText = "Engram config updated to use npx";
|
|
289
|
-
else if (result === "exists")
|
|
290
|
-
statusText = "Engram is already installed and up to date";
|
|
291
|
-
console.log(` Status: ${statusText}`);
|
|
292
|
-
if (result !== "exists") {
|
|
293
|
-
installed++;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
catch (e) {
|
|
297
|
-
console.log(`\n ⚠️ ${config.name}`);
|
|
298
|
-
console.log(` Could not write to: ${config.path}`);
|
|
299
|
-
console.log(` Reason: ${e.message}`);
|
|
300
|
-
console.log(`\n For manual instructions, visit: https://github.com/keggan-std/Engram`);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
if (configs.length === 0) {
|
|
304
|
-
console.log("\n No target configurations resolved.");
|
|
305
|
-
}
|
|
306
|
-
else if (installed === 0) {
|
|
307
|
-
// Technically they could all just be "already exists"
|
|
308
|
-
console.log("\n✅ Done! No new changes were needed.");
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
console.log(`\n✅ Done! Engram configured in ${installed} IDE scope(s).`);
|
|
312
|
-
console.log(" Restart your IDE(s) to load Engram.\n");
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
//# sourceMappingURL=installer.js.map
|
package/dist/installer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"installer.js","sourceRoot":"","sources":["../src/installer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;AAC1B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AAWlE,MAAM,WAAW,GAAkC;IAC/C,WAAW,EAAE;QACT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,CAAC,YAAY,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;YACvC,OAAO,CAAC,GAAG,CAAC,6BAA6B,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;YACxD,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YAC1C,OAAO,CAAC,GAAG,CAAC,8EAA8E,CAAC,CAAC;QAChG,CAAC;IACL,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;IAC3D,CAAC;SAAM,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;QACzB,sDAAsD;QACtD,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;IACzD,CAAC;SAAM,CAAC;QACJ,OAAO,CAAC,GAAG,CAAC,kCAAkC,SAAS,gBAAgB,CAAC,CAAC;QACzE,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;IAC5D,CAAC;AACL,CAAC"}
|
package/dist/src/constants.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export declare const SERVER_NAME = "engram-mcp-server";
|
|
2
|
-
export declare const SERVER_VERSION = "1.2.5";
|
|
3
|
-
export declare const TOOL_PREFIX = "engram";
|
|
4
|
-
export declare const DB_DIR_NAME = ".engram";
|
|
5
|
-
export declare const DB_FILE_NAME = "memory.db";
|
|
6
|
-
export declare const DB_VERSION = 4;
|
|
7
|
-
export declare const MAX_FILE_TREE_DEPTH = 5;
|
|
8
|
-
export declare const MAX_FILE_TREE_ENTRIES = 500;
|
|
9
|
-
export declare const MAX_SEARCH_RESULTS = 50;
|
|
10
|
-
export declare const MAX_GIT_LOG_ENTRIES = 50;
|
|
11
|
-
export declare const MAX_RESPONSE_LENGTH = 50000;
|
|
12
|
-
export declare const DEFAULT_PAGINATION_LIMIT = 20;
|
|
13
|
-
export declare const SNAPSHOT_TTL_MINUTES = 30;
|
|
14
|
-
export declare const COMPACTION_THRESHOLD_SESSIONS = 50;
|
|
15
|
-
export declare const BACKUP_DIR_NAME = "backups";
|
|
16
|
-
export declare const DEFAULT_RETENTION_DAYS = 90;
|
|
17
|
-
export declare const MAX_BACKUP_COUNT = 10;
|
|
18
|
-
export declare const EXCLUDED_DIRS: Set<string>;
|
|
19
|
-
export declare const PROJECT_MARKERS: string[];
|
|
20
|
-
export declare const LAYER_PATTERNS: Record<string, RegExp[]>;
|
|
21
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,sBAAsB,CAAC;AAC/C,eAAO,MAAM,cAAc,UAAU,CAAC;AACtC,eAAO,MAAM,WAAW,WAAW,CAAC;AAGpC,eAAO,MAAM,WAAW,YAAY,CAAC;AACrC,eAAO,MAAM,YAAY,cAAc,CAAC;AACxC,eAAO,MAAM,UAAU,IAAI,CAAC;AAG5B,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AACzC,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAC3C,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAChD,eAAO,MAAM,eAAe,YAAY,CAAC;AACzC,eAAO,MAAM,sBAAsB,KAAK,CAAC;AACzC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAGnC,eAAO,MAAM,aAAa,aAqBxB,CAAC;AAGH,eAAO,MAAM,eAAe,UAmB3B,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAYnD,CAAC"}
|
package/dist/src/constants.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
// ============================================================================
|
|
2
|
-
// Engram MCP Server — Constants
|
|
3
|
-
// ============================================================================
|
|
4
|
-
export const SERVER_NAME = "engram-mcp-server";
|
|
5
|
-
export const SERVER_VERSION = "1.2.5";
|
|
6
|
-
export const TOOL_PREFIX = "engram";
|
|
7
|
-
// Database
|
|
8
|
-
export const DB_DIR_NAME = ".engram";
|
|
9
|
-
export const DB_FILE_NAME = "memory.db";
|
|
10
|
-
export const DB_VERSION = 4;
|
|
11
|
-
// Limits
|
|
12
|
-
export const MAX_FILE_TREE_DEPTH = 5;
|
|
13
|
-
export const MAX_FILE_TREE_ENTRIES = 500;
|
|
14
|
-
export const MAX_SEARCH_RESULTS = 50;
|
|
15
|
-
export const MAX_GIT_LOG_ENTRIES = 50;
|
|
16
|
-
export const MAX_RESPONSE_LENGTH = 50000;
|
|
17
|
-
export const DEFAULT_PAGINATION_LIMIT = 20;
|
|
18
|
-
export const SNAPSHOT_TTL_MINUTES = 30;
|
|
19
|
-
export const COMPACTION_THRESHOLD_SESSIONS = 50;
|
|
20
|
-
export const BACKUP_DIR_NAME = "backups";
|
|
21
|
-
export const DEFAULT_RETENTION_DAYS = 90;
|
|
22
|
-
export const MAX_BACKUP_COUNT = 10;
|
|
23
|
-
// File patterns to exclude from scanning
|
|
24
|
-
export const EXCLUDED_DIRS = new Set([
|
|
25
|
-
".git",
|
|
26
|
-
".gradle",
|
|
27
|
-
".idea",
|
|
28
|
-
".vs",
|
|
29
|
-
".vscode",
|
|
30
|
-
".engram",
|
|
31
|
-
".agent-memory",
|
|
32
|
-
"node_modules",
|
|
33
|
-
"build",
|
|
34
|
-
"dist",
|
|
35
|
-
"out",
|
|
36
|
-
"bin",
|
|
37
|
-
"obj",
|
|
38
|
-
"__pycache__",
|
|
39
|
-
".next",
|
|
40
|
-
".nuxt",
|
|
41
|
-
"target",
|
|
42
|
-
"Pods",
|
|
43
|
-
".dart_tool",
|
|
44
|
-
".pub-cache",
|
|
45
|
-
]);
|
|
46
|
-
// Project root markers — used to auto-detect project boundaries
|
|
47
|
-
export const PROJECT_MARKERS = [
|
|
48
|
-
".git",
|
|
49
|
-
"package.json",
|
|
50
|
-
"build.gradle",
|
|
51
|
-
"build.gradle.kts",
|
|
52
|
-
"settings.gradle",
|
|
53
|
-
"settings.gradle.kts",
|
|
54
|
-
"Cargo.toml",
|
|
55
|
-
"go.mod",
|
|
56
|
-
"pom.xml",
|
|
57
|
-
"CMakeLists.txt",
|
|
58
|
-
"Makefile",
|
|
59
|
-
"pyproject.toml",
|
|
60
|
-
"setup.py",
|
|
61
|
-
".sln",
|
|
62
|
-
".csproj",
|
|
63
|
-
"pubspec.yaml",
|
|
64
|
-
"Gemfile",
|
|
65
|
-
"composer.json",
|
|
66
|
-
];
|
|
67
|
-
// Architecture layer detection patterns
|
|
68
|
-
export const LAYER_PATTERNS = {
|
|
69
|
-
ui: [/\/(ui|views?|screens?|pages?|components?|widgets?)\//i, /\.(jsx|tsx|vue|svelte)$/],
|
|
70
|
-
viewmodel: [/\/(viewmodels?|controllers?|presenters?|blocs?)\//i],
|
|
71
|
-
domain: [/\/(domain|models?|entities|usecases?|interactors?)\//i],
|
|
72
|
-
data: [/\/(data|repositories|repos?|datasources?|providers?)\//i],
|
|
73
|
-
network: [/\/(network|api|services?|clients?|http)\//i],
|
|
74
|
-
database: [/\/(database|db|dao|migrations?|schemas?)\//i],
|
|
75
|
-
di: [/\/(di|injection|modules?|containers?)\//i],
|
|
76
|
-
util: [/\/(utils?|helpers?|extensions?|common)\//i],
|
|
77
|
-
test: [/\/(test|tests|spec|specs|__tests__)\//i, /\.(test|spec)\./i],
|
|
78
|
-
config: [/\/(config|configs?|settings?|env)\//i],
|
|
79
|
-
build: [/\/(build|gradle|cmake|scripts?)\//i, /\.(gradle|cmake)$/i],
|
|
80
|
-
};
|
|
81
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -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OAAO;IACP,OAAO;IACP,QAAQ;IACR,MAAM;IACN,YAAY;IACZ,YAAY;CACb,CAAC,CAAC;AAEH,gEAAgE;AAChE,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,MAAM;IACN,cAAc;IACd,cAAc;IACd,kBAAkB;IAClB,iBAAiB;IACjB,qBAAqB;IACrB,YAAY;IACZ,QAAQ;IACR,SAAS;IACT,gBAAgB;IAChB,UAAU;IACV,gBAAgB;IAChB,UAAU;IACV,MAAM;IACN,SAAS;IACT,cAAc;IACd,SAAS;IACT,eAAe;CAChB,CAAC;AAEF,wCAAwC;AACxC,MAAM,CAAC,MAAM,cAAc,GAA6B;IACtD,EAAE,EAAE,CAAC,uDAAuD,EAAE,yBAAyB,CAAC;IACxF,SAAS,EAAE,CAAC,oDAAoD,CAAC;IACjE,MAAM,EAAE,CAAC,uDAAuD,CAAC;IACjE,IAAI,EAAE,CAAC,yDAAyD,CAAC;IACjE,OAAO,EAAE,CAAC,4CAA4C,CAAC;IACvD,QAAQ,EAAE,CAAC,6CAA6C,CAAC;IACzD,EAAE,EAAE,CAAC,0CAA0C,CAAC;IAChD,IAAI,EAAE,CAAC,2CAA2C,CAAC;IACnD,IAAI,EAAE,CAAC,wCAAwC,EAAE,kBAAkB,CAAC;IACpE,MAAM,EAAE,CAAC,sCAAsC,CAAC;IAChD,KAAK,EAAE,CAAC,oCAAoC,EAAE,oBAAoB,CAAC;CACpE,CAAC"}
|
package/dist/src/database.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { Database as DatabaseType } from "better-sqlite3";
|
|
2
|
-
import { type Repositories } from "./repositories/index.js";
|
|
3
|
-
export declare function initDatabase(projectRoot: string): Promise<DatabaseType>;
|
|
4
|
-
export declare function getDb(): DatabaseType;
|
|
5
|
-
export declare function getRepos(): Repositories;
|
|
6
|
-
export declare function getProjectRoot(): string;
|
|
7
|
-
export declare function getDbPath(): string;
|
|
8
|
-
/**
|
|
9
|
-
* Create a backup copy of the database file.
|
|
10
|
-
* Uses SQLite's backup API for a safe, consistent copy.
|
|
11
|
-
*/
|
|
12
|
-
export declare function backupDatabase(destPath?: string): string;
|
|
13
|
-
export declare function queryAll(sql: string, params?: unknown[]): Record<string, unknown>[];
|
|
14
|
-
export declare function queryOne(sql: string, params?: unknown[]): Record<string, unknown> | null;
|
|
15
|
-
export declare function execute(sql: string, params?: unknown[]): {
|
|
16
|
-
lastId: number;
|
|
17
|
-
};
|
|
18
|
-
export declare function executeMany(statements: Array<{
|
|
19
|
-
sql: string;
|
|
20
|
-
params: unknown[];
|
|
21
|
-
}>): void;
|
|
22
|
-
export declare function now(): string;
|
|
23
|
-
export declare function getCurrentSessionId(): number | null;
|
|
24
|
-
export declare function getLastCompletedSession(): {
|
|
25
|
-
id: number;
|
|
26
|
-
ended_at: string;
|
|
27
|
-
summary: string | null;
|
|
28
|
-
agent_name: string;
|
|
29
|
-
} | null;
|
|
30
|
-
export declare function getDbSizeKb(): number;
|
|
31
|
-
export declare function forceFlush(): void;
|
|
32
|
-
//# sourceMappingURL=database.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/database.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAK/D,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAShF,wBAAsB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAuB7E;AAED,wBAAgB,KAAK,IAAI,YAAY,CAGpC;AAED,wBAAgB,QAAQ,IAAI,YAAY,CAGvC;AAED,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAID;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAmBxD;AAkBD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,EAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAIvF;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,EAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAK5F;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,EAAO,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAI/E;AAED,wBAAgB,WAAW,CAAC,UAAU,EAAE,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,EAAE,CAAA;CAAE,CAAC,GAAG,IAAI,CAQvF;AAID,wBAAgB,GAAG,IAAI,MAAM,CAE5B;AAED,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,IAAI,CAGnD;AAED,wBAAgB,uBAAuB,IAAI;IACzC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;CAC1E,GAAG,IAAI,CAWP;AAED,wBAAgB,WAAW,IAAI,MAAM,CAKpC;AAED,wBAAgB,UAAU,IAAI,IAAI,CAIjC"}
|
package/dist/src/database.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
// ============================================================================
|
|
2
|
-
// Engram MCP Server — Database Layer (better-sqlite3 — native, WAL mode)
|
|
3
|
-
// ============================================================================
|
|
4
|
-
import Database from "better-sqlite3";
|
|
5
|
-
import * as fs from "fs";
|
|
6
|
-
import * as path from "path";
|
|
7
|
-
import { DB_DIR_NAME, DB_FILE_NAME, BACKUP_DIR_NAME } from "./constants.js";
|
|
8
|
-
import { runMigrations } from "./migrations.js";
|
|
9
|
-
import { createRepositories } from "./repositories/index.js";
|
|
10
|
-
let _db = null;
|
|
11
|
-
let _repos = null;
|
|
12
|
-
let _projectRoot = process.cwd();
|
|
13
|
-
let _dbPath = "";
|
|
14
|
-
// ─── Initialization ──────────────────────────────────────────────────
|
|
15
|
-
export async function initDatabase(projectRoot) {
|
|
16
|
-
_projectRoot = projectRoot;
|
|
17
|
-
const dbDir = path.join(projectRoot, DB_DIR_NAME);
|
|
18
|
-
fs.mkdirSync(dbDir, { recursive: true });
|
|
19
|
-
ensureGitignore(projectRoot);
|
|
20
|
-
_dbPath = path.join(dbDir, DB_FILE_NAME);
|
|
21
|
-
_db = new Database(_dbPath);
|
|
22
|
-
// Performance pragmas
|
|
23
|
-
_db.pragma("journal_mode = WAL");
|
|
24
|
-
_db.pragma("foreign_keys = ON");
|
|
25
|
-
_db.pragma("synchronous = NORMAL");
|
|
26
|
-
_db.pragma("cache_size = -8000"); // 8MB cache
|
|
27
|
-
_db.pragma("busy_timeout = 5000");
|
|
28
|
-
// Run versioned migrations
|
|
29
|
-
runMigrations(_db);
|
|
30
|
-
// Initialize repositories
|
|
31
|
-
_repos = createRepositories(_db);
|
|
32
|
-
return _db;
|
|
33
|
-
}
|
|
34
|
-
export function getDb() {
|
|
35
|
-
if (!_db)
|
|
36
|
-
throw new Error("Database not initialized. Call initDatabase() first.");
|
|
37
|
-
return _db;
|
|
38
|
-
}
|
|
39
|
-
export function getRepos() {
|
|
40
|
-
if (!_repos)
|
|
41
|
-
throw new Error("Repositories not initialized. Call initDatabase() first.");
|
|
42
|
-
return _repos;
|
|
43
|
-
}
|
|
44
|
-
export function getProjectRoot() {
|
|
45
|
-
return _projectRoot;
|
|
46
|
-
}
|
|
47
|
-
export function getDbPath() {
|
|
48
|
-
return _dbPath;
|
|
49
|
-
}
|
|
50
|
-
// ─── Backup ──────────────────────────────────────────────────────────
|
|
51
|
-
/**
|
|
52
|
-
* Create a backup copy of the database file.
|
|
53
|
-
* Uses SQLite's backup API for a safe, consistent copy.
|
|
54
|
-
*/
|
|
55
|
-
export function backupDatabase(destPath) {
|
|
56
|
-
const db = getDb();
|
|
57
|
-
const projectRoot = getProjectRoot();
|
|
58
|
-
if (!destPath) {
|
|
59
|
-
const backupDir = path.join(projectRoot, DB_DIR_NAME, BACKUP_DIR_NAME);
|
|
60
|
-
fs.mkdirSync(backupDir, { recursive: true });
|
|
61
|
-
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
62
|
-
destPath = path.join(backupDir, `memory-${timestamp}.db`);
|
|
63
|
-
}
|
|
64
|
-
// Ensure destination directory exists
|
|
65
|
-
const destDir = path.dirname(destPath);
|
|
66
|
-
fs.mkdirSync(destDir, { recursive: true });
|
|
67
|
-
// Use SQLite backup API
|
|
68
|
-
db.backup(destPath);
|
|
69
|
-
return destPath;
|
|
70
|
-
}
|
|
71
|
-
// ─── Gitignore ───────────────────────────────────────────────────────
|
|
72
|
-
function ensureGitignore(projectRoot) {
|
|
73
|
-
const gitignorePath = path.join(projectRoot, ".gitignore");
|
|
74
|
-
try {
|
|
75
|
-
if (fs.existsSync(gitignorePath)) {
|
|
76
|
-
const content = fs.readFileSync(gitignorePath, "utf-8");
|
|
77
|
-
if (!content.includes(DB_DIR_NAME)) {
|
|
78
|
-
fs.appendFileSync(gitignorePath, `\n# Engram AI agent memory\n${DB_DIR_NAME}/\n`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
catch { /* skip */ }
|
|
83
|
-
}
|
|
84
|
-
// ─── Query Helpers ───────────────────────────────────────────────────
|
|
85
|
-
export function queryAll(sql, params = []) {
|
|
86
|
-
const db = getDb();
|
|
87
|
-
const stmt = db.prepare(sql);
|
|
88
|
-
return stmt.all(...params);
|
|
89
|
-
}
|
|
90
|
-
export function queryOne(sql, params = []) {
|
|
91
|
-
const db = getDb();
|
|
92
|
-
const stmt = db.prepare(sql);
|
|
93
|
-
const row = stmt.get(...params);
|
|
94
|
-
return row ?? null;
|
|
95
|
-
}
|
|
96
|
-
export function execute(sql, params = []) {
|
|
97
|
-
const db = getDb();
|
|
98
|
-
const result = db.prepare(sql).run(...params);
|
|
99
|
-
return { lastId: Number(result.lastInsertRowid) };
|
|
100
|
-
}
|
|
101
|
-
export function executeMany(statements) {
|
|
102
|
-
const db = getDb();
|
|
103
|
-
const transaction = db.transaction(() => {
|
|
104
|
-
for (const { sql, params } of statements) {
|
|
105
|
-
db.prepare(sql).run(...params);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
transaction();
|
|
109
|
-
}
|
|
110
|
-
// ─── Convenience ─────────────────────────────────────────────────────
|
|
111
|
-
export function now() {
|
|
112
|
-
return new Date().toISOString();
|
|
113
|
-
}
|
|
114
|
-
export function getCurrentSessionId() {
|
|
115
|
-
const row = queryOne("SELECT id FROM sessions WHERE ended_at IS NULL ORDER BY id DESC LIMIT 1");
|
|
116
|
-
return row ? row.id : null;
|
|
117
|
-
}
|
|
118
|
-
export function getLastCompletedSession() {
|
|
119
|
-
const row = queryOne("SELECT id, ended_at, summary, agent_name FROM sessions WHERE ended_at IS NOT NULL ORDER BY id DESC LIMIT 1");
|
|
120
|
-
if (!row)
|
|
121
|
-
return null;
|
|
122
|
-
return {
|
|
123
|
-
id: row.id,
|
|
124
|
-
ended_at: row.ended_at,
|
|
125
|
-
summary: row.summary,
|
|
126
|
-
agent_name: row.agent_name,
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
export function getDbSizeKb() {
|
|
130
|
-
try {
|
|
131
|
-
const stats = fs.statSync(_dbPath);
|
|
132
|
-
return Math.round(stats.size / 1024);
|
|
133
|
-
}
|
|
134
|
-
catch {
|
|
135
|
-
return 0;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
export function forceFlush() {
|
|
139
|
-
// With better-sqlite3 + WAL mode, we can force a WAL checkpoint
|
|
140
|
-
const db = getDb();
|
|
141
|
-
db.pragma("wal_checkpoint(TRUNCATE)");
|
|
142
|
-
}
|
|
143
|
-
//# sourceMappingURL=database.js.map
|
package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