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/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
remimem: codebase memory for coding agents.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
https://github.com/user-attachments/assets/ca02a242-60c0-4910-ae9c-9347d5a76393
|
|
6
6
|
|
|
7
7
|
It is a local-first MCP server and CLI that indexes a codebase and gives coding agents (Claude Code, Cursor, VS Code Copilot, any MCP client) the smallest set of code that answers their question, within a token budget. It also keeps project memory, decisions and conventions that persist across sessions, and ships the benchmark below so the savings can be checked.
|
|
8
8
|
|
|
@@ -145,21 +145,25 @@ Changed files are re-indexed before each tool call, so answers follow your edits
|
|
|
145
145
|
|
|
146
146
|
## Tools
|
|
147
147
|
|
|
148
|
-
| Tool | What it returns
|
|
149
|
-
| ------------------ |
|
|
150
|
-
| `get_context` | The best starting context for a task: project memory, the top code in full, and neighbor signatures. Inputs: `task`, `budget_tokens` (default 4,000), `paths`.
|
|
151
|
-
| `search_code` | Ranked code for a query, with the reason each result matched. Inputs: `query`, `k` (default 10), `budget_tokens`, `language`, `paths`.
|
|
152
|
-
| `get_symbol` | One function, class, or type with its callers and callees. Inputs: `name`, `include` (`body` or `signature`), `depth` (0 to 2).
|
|
153
|
-
| `get_file_outline` | The symbols of a file with signatures and line numbers, no bodies. Input: `path`.
|
|
154
|
-
| `find_references` | Where a symbol is called, extended, used as a type, or imported, as `path:line` grouped by file. Input: `name`.
|
|
155
|
-
| `remember` | Saves a decision, convention, gotcha, or todo, optionally linked to files and symbols. Inputs: `text`, `kind`, `paths`, `symbols`, `tags`.
|
|
156
|
-
| `recall` | Matching memories, stale ones marked. Inputs: `query`, `kind`.
|
|
157
|
-
| `forget` | Deletes a memory. Input: `id`.
|
|
158
|
-
| `index_status` | Files, chunks, last indexed commit, pending changes, embedding model.
|
|
148
|
+
| Tool | What it returns |
|
|
149
|
+
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
150
|
+
| `get_context` | The best starting context for a task: project memory, the top code in full, and neighbor signatures. Inputs: `task`, `budget_tokens` (default 4,000), `paths`. |
|
|
151
|
+
| `search_code` | Ranked code for a query, with the reason each result matched. Inputs: `query`, `k` (default 10), `budget_tokens`, `language`, `paths`. |
|
|
152
|
+
| `get_symbol` | One function, class, or type with its callers and callees. Inputs: `name`, `include` (`body` or `signature`), `depth` (0 to 2). |
|
|
153
|
+
| `get_file_outline` | The symbols of a file with signatures and line numbers, no bodies. Input: `path`. |
|
|
154
|
+
| `find_references` | Where a symbol is called, extended, used as a type, or imported, as `path:line` grouped by file. Input: `name`. |
|
|
155
|
+
| `remember` | Saves a decision, convention, gotcha, or todo, optionally linked to files and symbols; with an `id`, updates one or confirms a stale one is still true. Inputs: `text`, `kind`, `paths`, `symbols`, `tags`, `id`. |
|
|
156
|
+
| `recall` | Matching memories, stale ones marked. Inputs: `query`, `kind`. |
|
|
157
|
+
| `forget` | Deletes a memory. Input: `id`. |
|
|
158
|
+
| `index_status` | Files, chunks, last indexed commit, pending changes, embedding model. |
|
|
159
159
|
|
|
160
160
|
There is also one resource, `remimem://overview`: a directory map with the most-referenced symbols per directory.
|
|
161
161
|
|
|
162
|
-
|
|
162
|
+
## Dashboard
|
|
163
|
+
|
|
164
|
+
`remimem dashboard` opens a local page with live agent activity (each tool call as it happens, with tokens and time), the code graph (folders, files, then each symbol's callers and callees), a search playground that shows scores, reasons, and the exact packed answer, a memory manager (with Still true for stale memories), tokens saved per day, the setup checks, and a settings editor. An agent's `remimem serve` runs it too, and `index_status` gives its address. It listens on 127.0.0.1 only, and every request needs the random token in the printed address. Set `dashboard.enabled` to `false` to keep `serve` from opening a port.
|
|
165
|
+
|
|
166
|
+
The same functions are available from the command line: `remimem init`, `index [--full]`, `watch`, `serve`, `search "<query>"`, `context "<task>"`, `memory list|add|rm`, `dashboard`, `stats`, `doctor`, and `bench` (from a source checkout).
|
|
163
167
|
|
|
164
168
|
## Configuration
|
|
165
169
|
|
|
@@ -177,12 +181,13 @@ Optional, in `.remimem/config.json`. Every setting has a default; unknown keys a
|
|
|
177
181
|
| `retrieval.graphTopN`, `graphMaxNeighbors`, `edgeWeights` | 10, 20, exact 0.5 / import 0.4 / name-match 0.2 | Call graph expansion. |
|
|
178
182
|
| `retrieval.memoryLimit`, `memoryMinKeywordMatch`, `memoryMinSimilarity` | 5, 0.5, 0.4 | Which memories `get_context` attaches. |
|
|
179
183
|
| `watch.debounceMs` | 500 | How long `remimem watch` waits after the last change. |
|
|
184
|
+
| `dashboard.enabled`, `dashboard.port` | true, 0 (any free port) | Whether `remimem serve` also runs the local dashboard, and on which port of 127.0.0.1. |
|
|
180
185
|
|
|
181
186
|
Memories are mirrored to `.remimem/memory.json`, which is meant to be committed so a team shares them. The index, `.remimem/index.db`, is local and is added to `.gitignore` by `init`.
|
|
182
187
|
|
|
183
188
|
## Privacy
|
|
184
189
|
|
|
185
|
-
Everything runs on your machine. Code is parsed, embedded, and stored locally, in one SQLite file inside the project. Nothing is sent anywhere unless you set `embedding.provider` to `openai` or `voyage`, in which case the text of indexed code goes to that service to be embedded. There is no telemetry. The query log behind `remimem stats` stays in the local index. The one network request in the default setup is the first download of the embedding model from huggingface.co.
|
|
190
|
+
Everything runs on your machine. Code is parsed, embedded, and stored locally, in one SQLite file inside the project. Nothing is sent anywhere unless you set `embedding.provider` to `openai` or `voyage`, in which case the text of indexed code goes to that service to be embedded. There is no telemetry. The query log behind `remimem stats` stays in the local index. The dashboard listens on 127.0.0.1 only and needs the token in its address. The one network request in the default setup is the first download of the embedding model from huggingface.co.
|
|
186
191
|
|
|
187
192
|
## Limitations
|
|
188
193
|
|
|
@@ -196,7 +201,7 @@ Everything runs on your machine. Code is parsed, embedded, and stored locally, i
|
|
|
196
201
|
- **Memories cost a little code.** With project memory attached, the share of right files shown with a full body dropped by about 2 points in the benchmark (90% against 92%), because memory takes up to a quarter of the budget. Only a quarter of the memories attached there were relevant.
|
|
197
202
|
- **The default embedding model is not trained on code.** A code-trained alternative found no more of the right files in the benchmark and indexed five times slower, so it is an option, not the default.
|
|
198
203
|
- **Change detection trusts size and modification time.** A change that keeps both is missed until `remimem index` runs, which hashes every file.
|
|
199
|
-
- **Platform gaps.** Vector search has no prebuilt extension for Windows on ARM.
|
|
204
|
+
- **Platform gaps.** Vector search has no prebuilt extension for Windows on ARM. Go struct embedding and implicit interface satisfaction produce no graph links.
|
|
200
205
|
|
|
201
206
|
## Roadmap
|
|
202
207
|
|
package/dist/cli/commands.js
CHANGED
|
@@ -12,6 +12,7 @@ import { pack } from '../packer/index.js';
|
|
|
12
12
|
import { search } from '../retriever/index.js';
|
|
13
13
|
import { Store } from '../store/index.js';
|
|
14
14
|
import { runTool, TOOLS } from '../mcp/tools.js';
|
|
15
|
+
import { importDecisions } from '../memory/import.js';
|
|
15
16
|
import { formatStats } from '../stats/index.js';
|
|
16
17
|
const dbPath = (root) => join(root, CONFIG_DIR, 'index.db');
|
|
17
18
|
/** `remimem index`: returns the summary line. */
|
|
@@ -74,7 +75,7 @@ export async function runContext(root, task, options) {
|
|
|
74
75
|
/** `remimem memory list`, `add`, and `rm`: the memory tools from the command line. */
|
|
75
76
|
export async function runMemory(root, action, args) {
|
|
76
77
|
const config = loadConfig(root);
|
|
77
|
-
const name = { list: 'recall', add: 'remember', rm: 'forget' }[action];
|
|
78
|
+
const name = { list: 'recall', add: 'remember', rm: 'forget', confirm: 'remember' }[action];
|
|
78
79
|
const memoryTool = TOOLS.find((tool) => tool.name === name);
|
|
79
80
|
mkdirSync(join(root, CONFIG_DIR), { recursive: true });
|
|
80
81
|
const store = new Store(dbPath(root));
|
|
@@ -141,6 +142,20 @@ export async function runInit(root, options) {
|
|
|
141
142
|
const summary = await runIndex(root, options);
|
|
142
143
|
return [...steps, privacy, summary, '', clientConfigs()].join('\n');
|
|
143
144
|
}
|
|
145
|
+
/** `remimem memory import`: decisions from ADRs or a decision log, as memories. */
|
|
146
|
+
export function runMemoryImport(root, paths, options) {
|
|
147
|
+
return withStore(root, (store) => {
|
|
148
|
+
const { added, skipped } = importDecisions(root, store, paths, options);
|
|
149
|
+
const verb = options.dryRun ? 'Would import' : 'Imported';
|
|
150
|
+
const lines = [
|
|
151
|
+
`${verb} ${added.length} decision${added.length === 1 ? '' : 's'}${skipped.length ? ` (${skipped.length} already in memory)` : ''}.`,
|
|
152
|
+
...added.map((d) => ` ${d.path}: ${d.title}`),
|
|
153
|
+
];
|
|
154
|
+
if (options.dryRun && added.length)
|
|
155
|
+
lines.push('Run again without --dry-run to save them.');
|
|
156
|
+
return lines.join('\n');
|
|
157
|
+
});
|
|
158
|
+
}
|
|
144
159
|
function withStore(root, run) {
|
|
145
160
|
if (!existsSync(dbPath(root))) {
|
|
146
161
|
throw new StoreError('No index found in this directory; run `remimem index` first');
|
package/dist/cli/index.js
CHANGED
|
@@ -1,18 +1,80 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { CONFIG_DIR } from '../config/index.js';
|
|
6
|
+
import { onModelDownload } from '../embedder/index.js';
|
|
2
7
|
import { RemimemError } from '../errors.js';
|
|
3
|
-
import {
|
|
8
|
+
import { probeSqlite } from '../store/probe.js';
|
|
9
|
+
import { downloadDisplay, paint, welcome } from './ui.js';
|
|
10
|
+
const pkg = createRequire(import.meta.url)('../../package.json');
|
|
11
|
+
/**
|
|
12
|
+
* Prints any failure so a person can act on it: the message, every underlying cause, and what to
|
|
13
|
+
* do next. Errors remimem did not expect also say how to get the full trace.
|
|
14
|
+
*/
|
|
15
|
+
function report(error) {
|
|
16
|
+
const err = process.stderr;
|
|
17
|
+
const expected = error instanceof RemimemError;
|
|
18
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
19
|
+
err.write(`${paint('red', 'error:', err)} ${expected ? message : `remimem stopped unexpectedly: ${message}`}\n`);
|
|
20
|
+
let cause = error instanceof Error ? error.cause : undefined;
|
|
21
|
+
for (let depth = 0; cause !== undefined && depth < 5; depth++) {
|
|
22
|
+
err.write(` ${paint('dim', 'because:', err)} ${cause instanceof Error ? cause.message : String(cause)}\n`);
|
|
23
|
+
cause = cause instanceof Error ? cause.cause : undefined;
|
|
24
|
+
}
|
|
25
|
+
const debug = process.env['REMIMEM_LOG_LEVEL'] === 'debug';
|
|
26
|
+
if (!expected) {
|
|
27
|
+
err.write(`Run \`remimem doctor\` to check the setup${debug ? '.' : ', or set REMIMEM_LOG_LEVEL=debug for the full trace.'}\n`);
|
|
28
|
+
}
|
|
29
|
+
if (debug && error instanceof Error && error.stack)
|
|
30
|
+
err.write(`${error.stack}\n`);
|
|
31
|
+
process.exitCode = 1;
|
|
32
|
+
}
|
|
4
33
|
// Exit quietly when the reader goes away, as in `remimem search x | head`.
|
|
5
34
|
process.stdout.on('error', (error) => {
|
|
6
35
|
if (error.code !== 'EPIPE')
|
|
7
36
|
throw error;
|
|
8
37
|
process.exit(0);
|
|
9
38
|
});
|
|
39
|
+
// Failures outside a command's own flow (a watcher callback, a stray promise) are shown too.
|
|
40
|
+
process.on('uncaughtException', (error) => {
|
|
41
|
+
report(error);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
});
|
|
44
|
+
process.on('unhandledRejection', (error) => {
|
|
45
|
+
report(error);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
});
|
|
48
|
+
const args = process.argv.slice(2);
|
|
49
|
+
const command = args[0];
|
|
50
|
+
// A bare `remimem` greets the user instead of printing an error and the full help.
|
|
51
|
+
if (command === undefined) {
|
|
52
|
+
console.log(welcome(pkg.version, existsSync(join(process.cwd(), CONFIG_DIR, 'index.db'))));
|
|
53
|
+
process.exit(0);
|
|
54
|
+
}
|
|
55
|
+
// Every command but help and the version reads the index, so check SQLite first: a broken native
|
|
56
|
+
// module would otherwise crash the process with no message at all.
|
|
57
|
+
const helpOnly = args.some((a) => ['-h', '--help', '-v', '--version'].includes(a));
|
|
58
|
+
if (!helpOnly) {
|
|
59
|
+
const sqlite = probeSqlite();
|
|
60
|
+
if (!sqlite.ok) {
|
|
61
|
+
process.stderr.write(`${paint('red', 'error:', process.stderr)} ${sqlite.message}\n`);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// The MCP server talks over stdio, so it never draws anything.
|
|
66
|
+
if (command !== 'serve') {
|
|
67
|
+
let display;
|
|
68
|
+
onModelDownload((model, loaded, total) => {
|
|
69
|
+
display ??= downloadDisplay(model);
|
|
70
|
+
display.update(loaded, total);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
10
73
|
try {
|
|
74
|
+
// Loaded after the check above: these modules open SQLite.
|
|
75
|
+
const { buildProgram } = await import('./program.js');
|
|
11
76
|
await buildProgram().parseAsync();
|
|
12
77
|
}
|
|
13
78
|
catch (error) {
|
|
14
|
-
|
|
15
|
-
throw error;
|
|
16
|
-
console.error(`error: ${error.message}`);
|
|
17
|
-
process.exitCode = 1;
|
|
79
|
+
report(error);
|
|
18
80
|
}
|
package/dist/cli/program.js
CHANGED
|
@@ -1,63 +1,136 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
1
2
|
import { createRequire } from 'node:module';
|
|
2
|
-
import { statSync } from 'node:fs';
|
|
3
|
-
import { resolve } from 'node:path';
|
|
3
|
+
import { existsSync, statSync } from 'node:fs';
|
|
4
|
+
import { join, resolve } from 'node:path';
|
|
4
5
|
import { Command } from 'commander';
|
|
6
|
+
import { CONFIG_DIR, loadConfig } from '../config/index.js';
|
|
7
|
+
import { findDashboard, startDashboard } from '../dashboard/server.js';
|
|
8
|
+
import { createProvider } from '../embedder/index.js';
|
|
5
9
|
import { processFile } from '../indexer/index.js';
|
|
10
|
+
import { Store } from '../store/index.js';
|
|
6
11
|
import { RemimemError } from '../errors.js';
|
|
7
12
|
import { MEMORY_KINDS, MemoryError } from '../memory/index.js';
|
|
8
13
|
import { serve } from '../mcp/server.js';
|
|
9
|
-
import { runContext, runDoctor, runIndex, runInit, runMemory, runRefs, runSearch, runStats, runWatch, runSymbol, } from './commands.js';
|
|
14
|
+
import { runContext, runDoctor, runIndex, runInit, runMemory, runMemoryImport, runRefs, runSearch, runStats, runWatch, runSymbol, } from './commands.js';
|
|
10
15
|
import { resolveInRoot, scan } from '../scanner/index.js';
|
|
16
|
+
import { banner, clearLine, embedProgress, paint } from './ui.js';
|
|
11
17
|
const pkg = createRequire(import.meta.url)('../../package.json');
|
|
18
|
+
const HELP_ORDER = [
|
|
19
|
+
'init',
|
|
20
|
+
'search',
|
|
21
|
+
'context',
|
|
22
|
+
'memory',
|
|
23
|
+
'index',
|
|
24
|
+
'watch',
|
|
25
|
+
'dashboard',
|
|
26
|
+
'stats',
|
|
27
|
+
'doctor',
|
|
28
|
+
'serve',
|
|
29
|
+
'bench',
|
|
30
|
+
];
|
|
31
|
+
/** True when a dashboard answers at `url`; a stale discovery file can outlive its server. */
|
|
32
|
+
async function reachable(url) {
|
|
33
|
+
const { origin, searchParams } = new URL(url);
|
|
34
|
+
try {
|
|
35
|
+
const res = await fetch(`${origin}/api/overview`, {
|
|
36
|
+
headers: { 'x-remimem-token': searchParams.get('token') ?? '' },
|
|
37
|
+
signal: AbortSignal.timeout(1500),
|
|
38
|
+
});
|
|
39
|
+
return res.ok;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/** Opens a URL in the default browser; failures are ignored, the URL is printed anyway. */
|
|
46
|
+
function openBrowser(url) {
|
|
47
|
+
const [command, args] = process.platform === 'darwin'
|
|
48
|
+
? ['open', [url]]
|
|
49
|
+
: process.platform === 'win32'
|
|
50
|
+
? ['cmd', ['/c', 'start', '""', url]]
|
|
51
|
+
: ['xdg-open', [url]];
|
|
52
|
+
try {
|
|
53
|
+
spawn(command, args, { stdio: 'ignore', detached: true })
|
|
54
|
+
.on('error', () => undefined)
|
|
55
|
+
.unref();
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// No browser available (a server or container): the printed URL is enough.
|
|
59
|
+
}
|
|
60
|
+
}
|
|
12
61
|
export function buildProgram() {
|
|
13
62
|
const program = new Command('remimem')
|
|
14
|
-
.description('
|
|
15
|
-
.version(pkg.version)
|
|
63
|
+
.description('Gives coding agents only the code they need, within a token budget, and remembers your project.')
|
|
64
|
+
.version(pkg.version, '-v, --version', 'print the version')
|
|
65
|
+
.helpOption('-h, --help', 'show help for a command')
|
|
66
|
+
.helpCommand(false)
|
|
67
|
+
.showSuggestionAfterError(true)
|
|
68
|
+
// The logo above help, only when a person is reading it in a terminal.
|
|
69
|
+
.addHelpText('beforeAll', () => (process.stdout.isTTY ? banner(pkg.version) : ''))
|
|
70
|
+
.addHelpText('after', () => `
|
|
71
|
+
${paint('bold', 'Examples:')}
|
|
72
|
+
${paint('cyan', 'remimem init')} set up this project, print client configs
|
|
73
|
+
${paint('cyan', 'remimem search "how are passwords hashed"')} find code by meaning or by name
|
|
74
|
+
${paint('cyan', 'remimem context "add rate limiting to login"')} everything an agent needs for a task
|
|
75
|
+
${paint('cyan', 'remimem memory add "Money is stored in cents" --kind convention')}
|
|
76
|
+
|
|
77
|
+
Help for one command: ${paint('cyan', 'remimem <command> --help')}
|
|
78
|
+
Docs: https://github.com/JaswanthRemiel/remimem`);
|
|
16
79
|
program
|
|
17
80
|
.command('doctor')
|
|
18
|
-
.
|
|
81
|
+
.helpGroup('Check:')
|
|
82
|
+
.description('Check that everything is installed and working')
|
|
19
83
|
.action(async () => {
|
|
20
84
|
const { lines, ok } = await runDoctor(process.cwd());
|
|
21
85
|
console.log(lines.join('\n'));
|
|
22
86
|
if (!ok)
|
|
23
87
|
process.exitCode = 1;
|
|
24
88
|
});
|
|
25
|
-
const tty = process.stderr.isTTY;
|
|
26
|
-
/** A progress bar on stderr while chunks are embedded. Silent when not a terminal. */
|
|
27
|
-
const onEmbedProgress = (done, total) => {
|
|
28
|
-
if (!tty)
|
|
29
|
-
return;
|
|
30
|
-
const filled = Math.round((done / Math.max(total, 1)) * 24);
|
|
31
|
-
process.stderr.write(`\rEmbedding [${'#'.repeat(filled)}${'.'.repeat(24 - filled)}] ${done}/${total}`);
|
|
32
|
-
};
|
|
33
|
-
const clearProgress = () => {
|
|
34
|
-
if (tty)
|
|
35
|
-
process.stderr.write('\r\x1b[K');
|
|
36
|
-
};
|
|
37
89
|
program
|
|
38
90
|
.command('init')
|
|
39
|
-
.
|
|
91
|
+
.helpGroup('Get started:')
|
|
92
|
+
.description('Set up this project: index the code and print the config for your agent')
|
|
40
93
|
.action(async () => {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
94
|
+
const root = process.cwd();
|
|
95
|
+
if (process.stdout.isTTY) {
|
|
96
|
+
console.log(banner(pkg.version));
|
|
97
|
+
console.log(`Setting up remimem in ${paint('bold', root)}\n`);
|
|
98
|
+
}
|
|
99
|
+
const report = await runInit(root, { onEmbedProgress: embedProgress });
|
|
100
|
+
clearLine();
|
|
101
|
+
// The status lines come first, before the blank line that starts the client configs.
|
|
102
|
+
const split = report.indexOf('\n\n');
|
|
103
|
+
const status = split === -1 ? report : report.slice(0, split);
|
|
104
|
+
const rest = split === -1 ? '' : report.slice(split);
|
|
105
|
+
const check = paint('green', '✓');
|
|
106
|
+
console.log(process.stdout.isTTY
|
|
107
|
+
? status
|
|
108
|
+
.split('\n')
|
|
109
|
+
.map((line) => `${check} ${line}`)
|
|
110
|
+
.join('\n') + rest
|
|
111
|
+
: report);
|
|
44
112
|
});
|
|
45
113
|
program
|
|
46
114
|
.command('serve')
|
|
47
|
-
.
|
|
115
|
+
.helpGroup('For MCP clients:')
|
|
116
|
+
.description('Start the MCP server (your agent runs this, not you)')
|
|
48
117
|
.option('--root <dir>', 'project directory, default the current directory')
|
|
49
118
|
.action(async (options) => {
|
|
50
119
|
await serve(resolve(options.root ?? process.cwd()));
|
|
51
120
|
});
|
|
52
121
|
program
|
|
53
122
|
.command('context <task>')
|
|
54
|
-
.
|
|
123
|
+
.helpGroup('Find code:')
|
|
124
|
+
.description('Everything an agent needs for a task, ready to paste into any chat')
|
|
55
125
|
.option('--budget <tokens>', 'token budget for the output')
|
|
56
126
|
.action(async (task, options) => {
|
|
57
127
|
const budget = Number(options.budget);
|
|
58
128
|
console.log(await runContext(process.cwd(), task, Number.isFinite(budget) ? { budget } : {}));
|
|
59
129
|
});
|
|
60
|
-
const memory = program
|
|
130
|
+
const memory = program
|
|
131
|
+
.command('memory')
|
|
132
|
+
.helpGroup('Project memory:')
|
|
133
|
+
.description('Save, list, and delete decisions and conventions by hand');
|
|
61
134
|
const collect = (value, all) => [...all, value];
|
|
62
135
|
memory
|
|
63
136
|
.command('list')
|
|
@@ -86,6 +159,26 @@ export function buildProgram() {
|
|
|
86
159
|
tags: options.tag,
|
|
87
160
|
}));
|
|
88
161
|
});
|
|
162
|
+
memory
|
|
163
|
+
.command('confirm <id>')
|
|
164
|
+
.description('Mark a stale memory as still true, linked to the code as it is now')
|
|
165
|
+
.action(async (id) => {
|
|
166
|
+
console.log(await runMemory(process.cwd(), 'confirm', { id }));
|
|
167
|
+
});
|
|
168
|
+
memory
|
|
169
|
+
.command('import <paths...>')
|
|
170
|
+
.description('Turn ADRs or a decision log (one "##" section per decision) into memories')
|
|
171
|
+
.option('--kind <kind>', 'decision, convention, gotcha, or todo', 'decision')
|
|
172
|
+
.option('--dry-run', 'list what would be imported without saving')
|
|
173
|
+
.action((paths, options) => {
|
|
174
|
+
if (!MEMORY_KINDS.includes(options.kind)) {
|
|
175
|
+
throw new MemoryError(`Unknown kind "${options.kind}". Use one of: ${MEMORY_KINDS.join(', ')}.`);
|
|
176
|
+
}
|
|
177
|
+
console.log(runMemoryImport(process.cwd(), paths, {
|
|
178
|
+
kind: options.kind,
|
|
179
|
+
dryRun: options.dryRun,
|
|
180
|
+
}));
|
|
181
|
+
});
|
|
89
182
|
memory
|
|
90
183
|
.command('rm <id>')
|
|
91
184
|
.description('Delete a memory')
|
|
@@ -94,28 +187,69 @@ export function buildProgram() {
|
|
|
94
187
|
});
|
|
95
188
|
program
|
|
96
189
|
.command('index')
|
|
97
|
-
.
|
|
190
|
+
.helpGroup('Keep the index fresh:')
|
|
191
|
+
.description('Bring the index up to date (only changed files are re-read)')
|
|
98
192
|
.option('--full', 'reindex every file and rebuild vectors')
|
|
99
193
|
.action(async (options) => {
|
|
100
|
-
const summary = await runIndex(process.cwd(), { ...options, onEmbedProgress });
|
|
101
|
-
|
|
194
|
+
const summary = await runIndex(process.cwd(), { ...options, onEmbedProgress: embedProgress });
|
|
195
|
+
clearLine();
|
|
102
196
|
console.log(summary);
|
|
103
197
|
});
|
|
104
198
|
program
|
|
105
199
|
.command('watch')
|
|
106
|
-
.
|
|
200
|
+
.helpGroup('Keep the index fresh:')
|
|
201
|
+
.description('Re-index automatically while you edit')
|
|
107
202
|
.action(async () => {
|
|
108
203
|
const stop = await runWatch(process.cwd(), (line) => console.log(line));
|
|
109
204
|
process.once('SIGINT', () => void stop().then(() => process.exit(0)));
|
|
110
205
|
});
|
|
206
|
+
program
|
|
207
|
+
.command('dashboard')
|
|
208
|
+
.helpGroup('Check:')
|
|
209
|
+
.description('Open the local dashboard: code graph, search, memories, savings, and settings')
|
|
210
|
+
.option('--port <n>', 'port on 127.0.0.1 when starting a new dashboard (default: any free port)')
|
|
211
|
+
.option('--no-open', 'print the address without opening a browser')
|
|
212
|
+
.action(async (options) => {
|
|
213
|
+
const root = process.cwd();
|
|
214
|
+
// An agent's `remimem serve` already runs one for this project: use that.
|
|
215
|
+
const running = findDashboard(root);
|
|
216
|
+
if (running && (await reachable(running.url))) {
|
|
217
|
+
console.log(`Dashboard (served by a running remimem server): ${running.url}`);
|
|
218
|
+
if (options.open)
|
|
219
|
+
openBrowser(running.url);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if (!existsSync(join(root, CONFIG_DIR, 'index.db'))) {
|
|
223
|
+
throw new RemimemError('No index here yet. Run `remimem init` in the project first.');
|
|
224
|
+
}
|
|
225
|
+
const config = loadConfig(root);
|
|
226
|
+
const store = new Store(join(root, CONFIG_DIR, 'index.db'));
|
|
227
|
+
const ctx = { root, config, store, provider: createProvider(config.embedding) };
|
|
228
|
+
const port = options.port === undefined ? config.dashboard.port : Number(options.port);
|
|
229
|
+
const dashboard = await startDashboard(ctx, port);
|
|
230
|
+
console.log(`Dashboard: ${paint('cyan', dashboard.url)}\nPress Ctrl+C to stop.`);
|
|
231
|
+
if (options.open)
|
|
232
|
+
openBrowser(dashboard.url);
|
|
233
|
+
// Ctrl+C, or a kill: close cleanly so the discovery file goes away with the server.
|
|
234
|
+
const stop = () => {
|
|
235
|
+
void dashboard.close().then(() => {
|
|
236
|
+
store.close();
|
|
237
|
+
process.exit(0);
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
process.once('SIGINT', stop);
|
|
241
|
+
process.once('SIGTERM', stop);
|
|
242
|
+
});
|
|
111
243
|
program
|
|
112
244
|
.command('stats')
|
|
113
|
-
.
|
|
245
|
+
.helpGroup('Check:')
|
|
246
|
+
.description('Show how many tokens remimem saved your agent')
|
|
114
247
|
.action(() => {
|
|
115
248
|
console.log(runStats(process.cwd()));
|
|
116
249
|
});
|
|
117
250
|
program
|
|
118
251
|
.command('bench')
|
|
252
|
+
.helpGroup('Contributors:')
|
|
119
253
|
.description('Run the benchmark (from a source checkout of remimem)')
|
|
120
254
|
.option('--mine', 'rebuild the task files from the pinned repositories instead of running')
|
|
121
255
|
.option('--repo <name>', 'run one repository only (repeatable)', (v, all) => [...all, v], [])
|
|
@@ -138,7 +272,8 @@ export function buildProgram() {
|
|
|
138
272
|
});
|
|
139
273
|
program
|
|
140
274
|
.command('search <query>')
|
|
141
|
-
.
|
|
275
|
+
.helpGroup('Find code:')
|
|
276
|
+
.description('Find code by meaning or by name, packed into a token budget')
|
|
142
277
|
.option('-k, --limit <n>', 'number of results to consider')
|
|
143
278
|
.option('--budget <tokens>', 'token budget for the output')
|
|
144
279
|
.option('--debug', 'print every score before the results')
|
|
@@ -202,5 +337,12 @@ export function buildProgram() {
|
|
|
202
337
|
console.log(`${chunk.content}\n`);
|
|
203
338
|
}
|
|
204
339
|
});
|
|
340
|
+
// Help lists groups and commands in the order a new user needs them.
|
|
341
|
+
const rank = (c) => {
|
|
342
|
+
const i = HELP_ORDER.indexOf(c.name());
|
|
343
|
+
return i === -1 ? HELP_ORDER.length : i;
|
|
344
|
+
};
|
|
345
|
+
// `commands` is typed read-only but is the list help reads, so sorting it in place is the hook.
|
|
346
|
+
program.commands.sort((a, b) => rank(a) - rank(b));
|
|
205
347
|
return program;
|
|
206
348
|
}
|
package/dist/cli/ui.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// Presentation for people at a terminal: the banner, colors, and progress drawings.
|
|
2
|
+
// Everything here writes nothing on its own; callers decide where text goes, and the MCP
|
|
3
|
+
// server never uses this module, because its stdout belongs to the protocol.
|
|
4
|
+
import { styleText } from 'node:util';
|
|
5
|
+
/** Colors only when the stream is a terminal; honors NO_COLOR and FORCE_COLOR. */
|
|
6
|
+
export function paint(style, text, stream = process.stdout) {
|
|
7
|
+
return styleText(style, text, { validateStream: true, stream });
|
|
8
|
+
}
|
|
9
|
+
const LOGO = [
|
|
10
|
+
'██████╗ ███████╗███╗ ███╗██╗███╗ ███╗███████╗███╗ ███╗',
|
|
11
|
+
'██╔══██╗██╔════╝████╗ ████║██║████╗ ████║██╔════╝████╗ ████║',
|
|
12
|
+
'██████╔╝█████╗ ██╔████╔██║██║██╔████╔██║█████╗ ██╔████╔██║',
|
|
13
|
+
'██╔══██╗██╔══╝ ██║╚██╔╝██║██║██║╚██╔╝██║██╔══╝ ██║╚██╔╝██║',
|
|
14
|
+
'██║ ██║███████╗██║ ╚═╝ ██║██║██║ ╚═╝ ██║███████╗██║ ╚═╝ ██║',
|
|
15
|
+
'╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝',
|
|
16
|
+
];
|
|
17
|
+
/** For terminals narrower than the full logo. */
|
|
18
|
+
const LOGO_SMALL = [
|
|
19
|
+
' _ ',
|
|
20
|
+
' _ _ ___ _ __ (_)_ __ ___ _ __ ',
|
|
21
|
+
" | '_/ -_) ' \\| | ' \\/ -_) ' \\ ",
|
|
22
|
+
' |_| \\___|_|_|_|_|_|_|_\\___|_|_|_|',
|
|
23
|
+
];
|
|
24
|
+
/** The remimem logo, the tagline, and the version, sized to the terminal. */
|
|
25
|
+
export function banner(version, stream = process.stdout) {
|
|
26
|
+
const logo = (stream.columns ?? 80) >= 64 ? LOGO : LOGO_SMALL;
|
|
27
|
+
return [
|
|
28
|
+
'',
|
|
29
|
+
...logo.map((line) => paint('yellow', line, stream)),
|
|
30
|
+
'',
|
|
31
|
+
`${paint('bold', 'codebase memory for coding agents', stream)} ${paint('dim', `v${version}`, stream)}`,
|
|
32
|
+
'',
|
|
33
|
+
].join('\n');
|
|
34
|
+
}
|
|
35
|
+
/** A horizontal bar such as `██████████░░░░░░░░░░`, for a fraction from 0 to 1. */
|
|
36
|
+
export function bar(fraction, width = 24) {
|
|
37
|
+
const filled = Math.round(Math.min(1, Math.max(0, fraction)) * width);
|
|
38
|
+
return '█'.repeat(filled) + '░'.repeat(width - filled);
|
|
39
|
+
}
|
|
40
|
+
// An amphora, Mnemosyne's vessel, that fills from the bottom as the model downloads.
|
|
41
|
+
// `#` marks the cells inside it that fill up.
|
|
42
|
+
const AMPHORA = [
|
|
43
|
+
' .-"""-. ',
|
|
44
|
+
' (_______) ',
|
|
45
|
+
' )#####( ',
|
|
46
|
+
' /#######\\ ',
|
|
47
|
+
' |#########| ',
|
|
48
|
+
' |#########| ',
|
|
49
|
+
' \\#######/ ',
|
|
50
|
+
" `-----' ",
|
|
51
|
+
];
|
|
52
|
+
const AMPHORA_CELLS = AMPHORA.join('').split('#').length - 1;
|
|
53
|
+
/** The amphora filled to `fraction`, bottom row first, left to right. */
|
|
54
|
+
export function amphora(fraction) {
|
|
55
|
+
let toFill = Math.round(Math.min(1, Math.max(0, fraction)) * AMPHORA_CELLS);
|
|
56
|
+
const rows = [...AMPHORA];
|
|
57
|
+
for (let r = rows.length - 1; r >= 0; r--) {
|
|
58
|
+
rows[r] = rows[r].replace(/#/g, () => (toFill-- > 0 ? '▓' : ' '));
|
|
59
|
+
}
|
|
60
|
+
return rows;
|
|
61
|
+
}
|
|
62
|
+
const mb = (bytes) => (bytes / 1_048_576).toFixed(1);
|
|
63
|
+
const MIN_DRAW_BYTES = 2 * 1_048_576;
|
|
64
|
+
/**
|
|
65
|
+
* Draws the download of the embedding model on stderr: the amphora on the left, the model
|
|
66
|
+
* name and byte counts beside it, redrawn in place. Does nothing when stderr is not a
|
|
67
|
+
* terminal. Returns `finish`, which leaves the full drawing on screen.
|
|
68
|
+
*/
|
|
69
|
+
export function downloadDisplay(model) {
|
|
70
|
+
const out = process.stderr;
|
|
71
|
+
if (!out.isTTY) {
|
|
72
|
+
// Not a terminal (CI, piped, some IDE consoles): no drawing, but say a download is happening.
|
|
73
|
+
let started = false;
|
|
74
|
+
let done = false;
|
|
75
|
+
const update = (loaded, total) => {
|
|
76
|
+
if (total < MIN_DRAW_BYTES || done)
|
|
77
|
+
return;
|
|
78
|
+
if (!started) {
|
|
79
|
+
started = true;
|
|
80
|
+
out.write(`Downloading the embedding model ${model} (${mb(total)} MB), once...\n`);
|
|
81
|
+
}
|
|
82
|
+
if (loaded >= total) {
|
|
83
|
+
done = true;
|
|
84
|
+
out.write(`Downloaded ${model}.\n`);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
return { update, finish: () => undefined };
|
|
88
|
+
}
|
|
89
|
+
let drawn = false;
|
|
90
|
+
let lastDraw = 0;
|
|
91
|
+
let last = { loaded: 0, total: 0 };
|
|
92
|
+
const draw = (loaded, total) => {
|
|
93
|
+
const fraction = total > 0 ? loaded / total : 0;
|
|
94
|
+
const side = [
|
|
95
|
+
'',
|
|
96
|
+
'',
|
|
97
|
+
paint('bold', 'Downloading the embedding model', out),
|
|
98
|
+
paint('dim', `${model}, downloaded once, then cached`, out),
|
|
99
|
+
'',
|
|
100
|
+
`${paint('yellow', bar(fraction, 28), out)} ${Math.round(fraction * 100)}%`,
|
|
101
|
+
paint('dim', `${mb(loaded)} of ${mb(total)} MB`, out),
|
|
102
|
+
'',
|
|
103
|
+
];
|
|
104
|
+
const lines = amphora(fraction).map((row, i) => ` ${paint('yellow', row, out)} ${side[i] ?? ''}`);
|
|
105
|
+
// Move back up over the previous drawing, then redraw every line.
|
|
106
|
+
if (drawn)
|
|
107
|
+
out.write(`\x1b[${lines.length}A`);
|
|
108
|
+
out.write(`${lines.map((line) => `\r\x1b[K${line}`).join('\n')}\n`);
|
|
109
|
+
drawn = true;
|
|
110
|
+
};
|
|
111
|
+
return {
|
|
112
|
+
update(loaded, total) {
|
|
113
|
+
last = { loaded, total };
|
|
114
|
+
// Small files (tokenizer, config) come first and would read as 100% at once; the
|
|
115
|
+
// drawing starts with the model weights. Redraws are capped at about ten a second.
|
|
116
|
+
const now = Date.now();
|
|
117
|
+
if (total < MIN_DRAW_BYTES || (now - lastDraw < 100 && loaded < total))
|
|
118
|
+
return;
|
|
119
|
+
lastDraw = now;
|
|
120
|
+
draw(loaded, total);
|
|
121
|
+
},
|
|
122
|
+
finish() {
|
|
123
|
+
if (drawn)
|
|
124
|
+
draw(last.total, last.total);
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/** A one-line bar for embedding progress, redrawn in place on stderr. */
|
|
129
|
+
export function embedProgress(done, total) {
|
|
130
|
+
const out = process.stderr;
|
|
131
|
+
if (!out.isTTY)
|
|
132
|
+
return;
|
|
133
|
+
const fraction = done / Math.max(total, 1);
|
|
134
|
+
out.write(`\r\x1b[K ${paint('dim', 'Embedding', out)} ${paint('yellow', bar(fraction), out)} ${done}/${total} chunks`);
|
|
135
|
+
}
|
|
136
|
+
/** Clears the current line on stderr, after a progress bar. */
|
|
137
|
+
export function clearLine() {
|
|
138
|
+
if (process.stderr.isTTY)
|
|
139
|
+
process.stderr.write('\r\x1b[K');
|
|
140
|
+
}
|
|
141
|
+
/** What a bare `remimem` prints: the banner and the few commands that matter first. */
|
|
142
|
+
export function welcome(version, initialized) {
|
|
143
|
+
const cmd = (text) => paint('cyan', text);
|
|
144
|
+
const step = (n, text, command) => ` ${paint('dim', `${n}.`)} ${text}\n ${cmd(command)}`;
|
|
145
|
+
const lines = [banner(version)];
|
|
146
|
+
if (initialized) {
|
|
147
|
+
lines.push(`${paint('green', '✓')} This project is set up. A few things to try:`, '', ` ${cmd('remimem search "how are requests authenticated"')} find code`, ` ${cmd('remimem context "add rate limiting to login"')} context for a task`, ` ${cmd('remimem stats')} what it saved`, ` ${cmd('remimem doctor')} check the setup`);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
lines.push('Get started in this project:', '', step(1, 'Index the code and get your client configuration', 'remimem init'), '', step(2, 'Connect your agent (Claude Code shown)', 'claude mcp add remimem -- npx -y remimem serve'), '', step(3, 'Ask it something', 'remimem search "where is the config loaded"'));
|
|
151
|
+
}
|
|
152
|
+
lines.push('', `${paint('dim', 'All commands:')} ${cmd('remimem --help')} ${paint('dim', 'Docs:')} ${paint('underline', 'https://github.com/JaswanthRemiel/remimem')}`, '');
|
|
153
|
+
return lines.join('\n');
|
|
154
|
+
}
|
package/dist/config/index.js
CHANGED
|
@@ -77,6 +77,14 @@ const ConfigSchema = z.strictObject({
|
|
|
77
77
|
debounceMs: z.number().int().nonnegative().default(500),
|
|
78
78
|
})
|
|
79
79
|
.prefault({}),
|
|
80
|
+
dashboard: z
|
|
81
|
+
.strictObject({
|
|
82
|
+
/** `remimem serve` also serves the local dashboard. */
|
|
83
|
+
enabled: z.boolean().default(true),
|
|
84
|
+
/** Port on 127.0.0.1. 0 picks a free one, so several agent sessions do not collide. */
|
|
85
|
+
port: z.number().int().min(0).max(65535).default(0),
|
|
86
|
+
})
|
|
87
|
+
.prefault({}),
|
|
80
88
|
/** There is no telemetry. The field exists so that fact is visible in the config. */
|
|
81
89
|
telemetry: z.literal(false).default(false),
|
|
82
90
|
});
|