remimem 0.1.0 → 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 +20 -15
- package/dist/cli/commands.js +16 -1
- package/dist/cli/index.js +67 -5
- package/dist/cli/program.js +173 -31
- package/dist/cli/ui.js +154 -0
- package/dist/config/index.js +8 -0
- package/dist/dashboard/api.js +207 -0
- package/dist/dashboard/graph.js +58 -0
- package/dist/dashboard/server.js +179 -0
- package/dist/dashboard/ui/app.css +1 -0
- package/dist/dashboard/ui/app.js +324 -0
- package/dist/dashboard/ui/app.js.LEGAL.txt +18 -0
- package/dist/dashboard/ui/geist-pixel-latin-400-normal-ODEFW7VT.woff2 +0 -0
- package/dist/dashboard/ui/index.html +37 -0
- package/dist/dashboard/ui/inter-latin-400-normal-55WT6UWF.woff2 +0 -0
- package/dist/dashboard/ui/inter-latin-500-normal-W62DVTXI.woff2 +0 -0
- package/dist/dashboard/ui/inter-latin-600-normal-R6Y2SZCR.woff2 +0 -0
- package/dist/dashboard/ui/jetbrains-mono-latin-400-normal-3OOWLGQ2.woff2 +0 -0
- package/dist/dashboard/ui/jetbrains-mono-latin-500-normal-V4XIP5OW.woff2 +0 -0
- package/dist/embedder/index.js +37 -3
- package/dist/graph/index.js +30 -9
- package/dist/graph/tsconfig.js +100 -0
- package/dist/indexer/index.js +1 -1
- package/dist/mcp/server.js +15 -1
- package/dist/mcp/tools.js +42 -8
- package/dist/memory/import.js +136 -0
- package/dist/memory/index.js +31 -2
- package/dist/store/index.js +34 -0
- package/dist/store/probe.js +113 -0
- package/package.json +8 -3
package/dist/store/index.js
CHANGED
|
@@ -219,6 +219,40 @@ export class Store {
|
|
|
219
219
|
.prepare('INSERT INTO query_log (tool, query, tokens_returned, baseline_tokens_estimate, latency_ms, created_at) VALUES (?, ?, ?, ?, ?, ?)')
|
|
220
220
|
.run(entry.tool, entry.query, entry.tokensReturned, entry.baselineTokens, entry.latencyMs, new Date().toISOString());
|
|
221
221
|
}
|
|
222
|
+
/** Tool calls logged after the given id, newest first, for the dashboard's live activity. */
|
|
223
|
+
queryLogAfter(afterId, limit) {
|
|
224
|
+
return this.db
|
|
225
|
+
.prepare(`SELECT id, tool, query, tokens_returned AS tokensReturned,
|
|
226
|
+
baseline_tokens_estimate AS baselineTokens, latency_ms AS latencyMs,
|
|
227
|
+
created_at AS createdAt
|
|
228
|
+
FROM query_log WHERE id > ? ORDER BY id DESC LIMIT ?`)
|
|
229
|
+
.all(afterId, limit);
|
|
230
|
+
}
|
|
231
|
+
/** Queries and tokens per day, oldest first, for the dashboard's savings chart. */
|
|
232
|
+
queryLogDaily() {
|
|
233
|
+
return this.db
|
|
234
|
+
.prepare(`SELECT substr(created_at, 1, 10) AS day, COUNT(*) AS queries,
|
|
235
|
+
SUM(tokens_returned) AS tokensReturned, SUM(baseline_tokens_estimate) AS baselineTokens
|
|
236
|
+
FROM query_log GROUP BY day ORDER BY day`)
|
|
237
|
+
.all();
|
|
238
|
+
}
|
|
239
|
+
/** Every file with its language and number of symbols, for the dashboard's graph. */
|
|
240
|
+
fileSummaries() {
|
|
241
|
+
return this.db
|
|
242
|
+
.prepare(`SELECT f.path, f.language, COUNT(s.id) AS symbols
|
|
243
|
+
FROM files f LEFT JOIN symbols s ON s.file_id = f.id GROUP BY f.id ORDER BY f.path`)
|
|
244
|
+
.all();
|
|
245
|
+
}
|
|
246
|
+
/** Resolved symbol edges summed per pair of different files. */
|
|
247
|
+
fileEdges() {
|
|
248
|
+
return this.db
|
|
249
|
+
.prepare(`SELECT sf.path AS src, df.path AS dst, COUNT(*) AS weight
|
|
250
|
+
FROM edges e
|
|
251
|
+
JOIN symbols s ON s.id = e.src_symbol_id JOIN files sf ON sf.id = s.file_id
|
|
252
|
+
JOIN symbols d ON d.id = e.dst_symbol_id JOIN files df ON df.id = d.file_id
|
|
253
|
+
WHERE sf.id <> df.id GROUP BY sf.id, df.id`)
|
|
254
|
+
.all();
|
|
255
|
+
}
|
|
222
256
|
/** Totals per tool over the whole query log. */
|
|
223
257
|
queryLogSummary() {
|
|
224
258
|
return this.db
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// A check of the native SQLite modules, run in a child process. better-sqlite3 and sqlite-vec are
|
|
2
|
+
// compiled code: a binary built for another Node.js version, or a broken one, can kill the whole
|
|
3
|
+
// process with an access violation before any JavaScript error handling runs, so the CLI would
|
|
4
|
+
// exit with no message. A child that crashes instead lets the parent explain what happened.
|
|
5
|
+
import { spawnSync } from 'node:child_process';
|
|
6
|
+
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
8
|
+
import { homedir } from 'node:os';
|
|
9
|
+
import { dirname, join } from 'node:path';
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
const DOCS = 'https://github.com/JaswanthRemiel/remimem/blob/main/SETUP.md#troubleshooting';
|
|
12
|
+
/** Windows reports a native crash as an NTSTATUS exit code, such as 0xC0000005. */
|
|
13
|
+
function describeExit({ status, signal }) {
|
|
14
|
+
if (signal)
|
|
15
|
+
return `killed by ${signal}`;
|
|
16
|
+
if (status === null)
|
|
17
|
+
return 'no exit code';
|
|
18
|
+
if (status > 255) {
|
|
19
|
+
const hex = `0x${(status >>> 0).toString(16).toUpperCase()}`;
|
|
20
|
+
return hex === '0xC0000005' ? `exit ${hex}, access violation` : `exit ${hex}`;
|
|
21
|
+
}
|
|
22
|
+
return `exit ${status}`;
|
|
23
|
+
}
|
|
24
|
+
/** Turns what the child did into a message that says what is wrong and how to fix it. */
|
|
25
|
+
export function classifyProbe(outcome, versions) {
|
|
26
|
+
if (outcome.status === 0)
|
|
27
|
+
return { ok: true };
|
|
28
|
+
const stderr = outcome.stderr.trim();
|
|
29
|
+
// The line that names the error; Node's last line is only its version footer.
|
|
30
|
+
const lines = stderr
|
|
31
|
+
.split('\n')
|
|
32
|
+
.map((l) => l.trim())
|
|
33
|
+
.filter(Boolean);
|
|
34
|
+
const last = lines.find((l) => /error/i.test(l)) ?? lines.filter((l) => !/^Node\.js v/.test(l)).at(-1) ?? '';
|
|
35
|
+
const missing = /bindings file|NODE_MODULE_VERSION|was compiled against a different Node\.js version|Cannot find module|invalid ELF|not a valid Win32 application|image not found|dlopen|mach-o|slice is not valid/i.test(stderr);
|
|
36
|
+
const crashed = outcome.signal !== null || outcome.status === null || outcome.status > 255;
|
|
37
|
+
const steps = [
|
|
38
|
+
'Update Node.js to the latest 22.x or 24.x release, then reinstall: npm install -g remimem',
|
|
39
|
+
'Or build the SQLite module on this machine: npm rebuild -g better-sqlite3 --build-from-source (needs C++ build tools; on Windows, Visual Studio Build Tools with "Desktop development with C++")',
|
|
40
|
+
'If you run remimem through npx, clear its cache first: npx clear-npx-cache',
|
|
41
|
+
`More help: ${DOCS}`,
|
|
42
|
+
];
|
|
43
|
+
const fix = steps.map((step, i) => ` ${i + 1}. ${step}`).join('\n');
|
|
44
|
+
if (missing) {
|
|
45
|
+
return {
|
|
46
|
+
ok: false,
|
|
47
|
+
kind: 'missing',
|
|
48
|
+
message: `The SQLite module is missing or was built for a different Node.js (${versions}).\n${last}\nTo fix it:\n${fix}`,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (crashed) {
|
|
52
|
+
return {
|
|
53
|
+
ok: false,
|
|
54
|
+
kind: 'crash',
|
|
55
|
+
message: `SQLite crashed on this machine (${describeExit(outcome)}; ${versions}). remimem stores its index in SQLite, so it cannot run until this is fixed.\nTo fix it:\n${fix}`,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
ok: false,
|
|
60
|
+
kind: 'failed',
|
|
61
|
+
message: `SQLite failed to start (${describeExit(outcome)}; ${versions}).\n${last}\nTo fix it:\n${fix}`,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function versionOf(name) {
|
|
65
|
+
try {
|
|
66
|
+
return require(`${name}/package.json`).version;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return 'unknown';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Opens an in-memory database with the vector extension in a child process. A success is
|
|
74
|
+
* remembered per platform, Node.js ABI and module version, so the check runs once per setup.
|
|
75
|
+
*/
|
|
76
|
+
export function probeSqlite() {
|
|
77
|
+
const sqlite = versionOf('better-sqlite3');
|
|
78
|
+
const versions = `Node.js ${process.version}, ${process.platform}-${process.arch}, better-sqlite3 ${sqlite}`;
|
|
79
|
+
const marker = join(process.env['REMIMEM_CACHE_DIR'] ?? join(homedir(), '.cache', 'remimem'), 'checks', `sqlite-${process.platform}-${process.arch}-abi${process.versions.modules}-${sqlite}-${versionOf('sqlite-vec')}`);
|
|
80
|
+
if (existsSync(marker))
|
|
81
|
+
return { ok: true };
|
|
82
|
+
let script;
|
|
83
|
+
try {
|
|
84
|
+
script = [
|
|
85
|
+
`const Database = require(${JSON.stringify(require.resolve('better-sqlite3'))});`,
|
|
86
|
+
`const vec = require(${JSON.stringify(require.resolve('sqlite-vec'))});`,
|
|
87
|
+
`const db = new Database(':memory:');`,
|
|
88
|
+
`vec.load(db);`,
|
|
89
|
+
`db.prepare('select vec_version() as v').get();`,
|
|
90
|
+
`db.close();`,
|
|
91
|
+
].join('\n');
|
|
92
|
+
}
|
|
93
|
+
catch (cause) {
|
|
94
|
+
const outcome = { status: 1, signal: null, stderr: `Cannot find module: ${String(cause)}` };
|
|
95
|
+
return classifyProbe(outcome, versions);
|
|
96
|
+
}
|
|
97
|
+
const child = spawnSync(process.execPath, ['-e', script], { encoding: 'utf8', timeout: 30_000 });
|
|
98
|
+
const result = classifyProbe({
|
|
99
|
+
status: child.status,
|
|
100
|
+
signal: child.signal,
|
|
101
|
+
stderr: child.stderr ?? String(child.error ?? ''),
|
|
102
|
+
}, versions);
|
|
103
|
+
if (result.ok) {
|
|
104
|
+
try {
|
|
105
|
+
mkdirSync(dirname(marker), { recursive: true });
|
|
106
|
+
writeFileSync(marker, `${new Date().toISOString()}\n`);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
// Not being able to cache the result only means the check runs again next time.
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return result;
|
|
113
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "remimem",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Codebase memory for coding agents: a local-first MCP server and CLI that serves only the code context an agent needs",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Jaswanth Remiel AG",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"node": ">=22.13.0"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
|
-
"build": "tsc -p tsconfig.build.json && node -e \"require('fs').chmodSync('dist/cli/index.js', 0o755)\"",
|
|
25
|
-
"typecheck": "tsc --noEmit",
|
|
24
|
+
"build": "tsc -p tsconfig.build.json && node scripts/build-dashboard.mjs && node -e \"require('fs').chmodSync('dist/cli/index.js', 0o755)\"",
|
|
25
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p src/dashboard/ui",
|
|
26
26
|
"lint": "eslint src test scripts eslint.config.js vitest.config.js",
|
|
27
27
|
"format": "prettier --write src scripts .github grammars/README.md \"docs/**/*.md\" \"test/*.{ts,mjs}\" \"*.{js,json}\" README.md DECISIONS.md PROGRESS.md SETUP.md CONTRIBUTING.md CHANGELOG.md RELEASING.md",
|
|
28
28
|
"format:check": "prettier --check src scripts .github grammars/README.md \"docs/**/*.md\" \"test/*.{ts,mjs}\" \"*.{js,json}\" README.md DECISIONS.md PROGRESS.md SETUP.md CONTRIBUTING.md CHANGELOG.md RELEASING.md",
|
|
@@ -46,9 +46,14 @@
|
|
|
46
46
|
"zod": "^4.6.7"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
+
"@fontsource/geist-pixel": "^5.3.0",
|
|
50
|
+
"@fontsource/inter": "^5.3.0",
|
|
51
|
+
"@fontsource/jetbrains-mono": "^5.3.0",
|
|
49
52
|
"@types/better-sqlite3": "^9.6.0",
|
|
50
53
|
"@types/node": "^22.20.5",
|
|
51
54
|
"@vitest/coverage-v8": "^5.1.0",
|
|
55
|
+
"cytoscape": "^3.35.0",
|
|
56
|
+
"esbuild": "^0.28.2",
|
|
52
57
|
"eslint": "^10.14.0",
|
|
53
58
|
"prettier": "^3.10.1",
|
|
54
59
|
"typescript": "~6.0.3",
|