remimem 0.1.0 → 0.2.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 +8 -3
- package/dist/cli/index.js +22 -1
- package/dist/cli/program.js +152 -30
- package/dist/cli/ui.js +138 -0
- package/dist/config/index.js +8 -0
- package/dist/dashboard/api.js +196 -0
- package/dist/dashboard/graph.js +58 -0
- package/dist/dashboard/server.js +164 -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/index.html +32 -0
- package/dist/embedder/index.js +32 -2
- package/dist/mcp/server.js +15 -1
- package/dist/mcp/tools.js +1 -0
- package/dist/memory/index.js +5 -2
- package/dist/store/index.js +25 -0
- package/package.json +5 -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
|
|
|
@@ -159,7 +159,11 @@ Changed files are re-indexed before each tool call, so answers follow your edits
|
|
|
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 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, 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
|
|
package/dist/cli/index.js
CHANGED
|
@@ -1,18 +1,39 @@
|
|
|
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
8
|
import { buildProgram } from './program.js';
|
|
9
|
+
import { downloadDisplay, paint, welcome } from './ui.js';
|
|
10
|
+
const pkg = createRequire(import.meta.url)('../../package.json');
|
|
4
11
|
// Exit quietly when the reader goes away, as in `remimem search x | head`.
|
|
5
12
|
process.stdout.on('error', (error) => {
|
|
6
13
|
if (error.code !== 'EPIPE')
|
|
7
14
|
throw error;
|
|
8
15
|
process.exit(0);
|
|
9
16
|
});
|
|
17
|
+
const command = process.argv[2];
|
|
18
|
+
// A bare `remimem` greets the user instead of printing an error and the full help.
|
|
19
|
+
if (command === undefined) {
|
|
20
|
+
console.log(welcome(pkg.version, existsSync(join(process.cwd(), CONFIG_DIR, 'index.db'))));
|
|
21
|
+
process.exit(0);
|
|
22
|
+
}
|
|
23
|
+
// The MCP server talks over stdio, so it never draws anything.
|
|
24
|
+
if (command !== 'serve') {
|
|
25
|
+
let display;
|
|
26
|
+
onModelDownload((model, loaded, total) => {
|
|
27
|
+
display ??= downloadDisplay(model);
|
|
28
|
+
display.update(loaded, total);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
10
31
|
try {
|
|
11
32
|
await buildProgram().parseAsync();
|
|
12
33
|
}
|
|
13
34
|
catch (error) {
|
|
14
35
|
if (!(error instanceof RemimemError))
|
|
15
36
|
throw error;
|
|
16
|
-
console.error(
|
|
37
|
+
console.error(`${paint('red', 'error:', process.stderr)} ${error.message}`);
|
|
17
38
|
process.exitCode = 1;
|
|
18
39
|
}
|
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
14
|
import { runContext, runDoctor, runIndex, runInit, runMemory, 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')
|
|
@@ -94,28 +167,69 @@ export function buildProgram() {
|
|
|
94
167
|
});
|
|
95
168
|
program
|
|
96
169
|
.command('index')
|
|
97
|
-
.
|
|
170
|
+
.helpGroup('Keep the index fresh:')
|
|
171
|
+
.description('Bring the index up to date (only changed files are re-read)')
|
|
98
172
|
.option('--full', 'reindex every file and rebuild vectors')
|
|
99
173
|
.action(async (options) => {
|
|
100
|
-
const summary = await runIndex(process.cwd(), { ...options, onEmbedProgress });
|
|
101
|
-
|
|
174
|
+
const summary = await runIndex(process.cwd(), { ...options, onEmbedProgress: embedProgress });
|
|
175
|
+
clearLine();
|
|
102
176
|
console.log(summary);
|
|
103
177
|
});
|
|
104
178
|
program
|
|
105
179
|
.command('watch')
|
|
106
|
-
.
|
|
180
|
+
.helpGroup('Keep the index fresh:')
|
|
181
|
+
.description('Re-index automatically while you edit')
|
|
107
182
|
.action(async () => {
|
|
108
183
|
const stop = await runWatch(process.cwd(), (line) => console.log(line));
|
|
109
184
|
process.once('SIGINT', () => void stop().then(() => process.exit(0)));
|
|
110
185
|
});
|
|
186
|
+
program
|
|
187
|
+
.command('dashboard')
|
|
188
|
+
.helpGroup('Check:')
|
|
189
|
+
.description('Open the local dashboard: code graph, search, memories, savings, and settings')
|
|
190
|
+
.option('--port <n>', 'port on 127.0.0.1 when starting a new dashboard (default: any free port)')
|
|
191
|
+
.option('--no-open', 'print the address without opening a browser')
|
|
192
|
+
.action(async (options) => {
|
|
193
|
+
const root = process.cwd();
|
|
194
|
+
// An agent's `remimem serve` already runs one for this project: use that.
|
|
195
|
+
const running = findDashboard(root);
|
|
196
|
+
if (running && (await reachable(running.url))) {
|
|
197
|
+
console.log(`Dashboard (served by a running remimem server): ${running.url}`);
|
|
198
|
+
if (options.open)
|
|
199
|
+
openBrowser(running.url);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (!existsSync(join(root, CONFIG_DIR, 'index.db'))) {
|
|
203
|
+
throw new RemimemError('No index here yet. Run `remimem init` in the project first.');
|
|
204
|
+
}
|
|
205
|
+
const config = loadConfig(root);
|
|
206
|
+
const store = new Store(join(root, CONFIG_DIR, 'index.db'));
|
|
207
|
+
const ctx = { root, config, store, provider: createProvider(config.embedding) };
|
|
208
|
+
const port = options.port === undefined ? config.dashboard.port : Number(options.port);
|
|
209
|
+
const dashboard = await startDashboard(ctx, port);
|
|
210
|
+
console.log(`Dashboard: ${paint('cyan', dashboard.url)}\nPress Ctrl+C to stop.`);
|
|
211
|
+
if (options.open)
|
|
212
|
+
openBrowser(dashboard.url);
|
|
213
|
+
// Ctrl+C, or a kill: close cleanly so the discovery file goes away with the server.
|
|
214
|
+
const stop = () => {
|
|
215
|
+
void dashboard.close().then(() => {
|
|
216
|
+
store.close();
|
|
217
|
+
process.exit(0);
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
process.once('SIGINT', stop);
|
|
221
|
+
process.once('SIGTERM', stop);
|
|
222
|
+
});
|
|
111
223
|
program
|
|
112
224
|
.command('stats')
|
|
113
|
-
.
|
|
225
|
+
.helpGroup('Check:')
|
|
226
|
+
.description('Show how many tokens remimem saved your agent')
|
|
114
227
|
.action(() => {
|
|
115
228
|
console.log(runStats(process.cwd()));
|
|
116
229
|
});
|
|
117
230
|
program
|
|
118
231
|
.command('bench')
|
|
232
|
+
.helpGroup('Contributors:')
|
|
119
233
|
.description('Run the benchmark (from a source checkout of remimem)')
|
|
120
234
|
.option('--mine', 'rebuild the task files from the pinned repositories instead of running')
|
|
121
235
|
.option('--repo <name>', 'run one repository only (repeatable)', (v, all) => [...all, v], [])
|
|
@@ -138,7 +252,8 @@ export function buildProgram() {
|
|
|
138
252
|
});
|
|
139
253
|
program
|
|
140
254
|
.command('search <query>')
|
|
141
|
-
.
|
|
255
|
+
.helpGroup('Find code:')
|
|
256
|
+
.description('Find code by meaning or by name, packed into a token budget')
|
|
142
257
|
.option('-k, --limit <n>', 'number of results to consider')
|
|
143
258
|
.option('--budget <tokens>', 'token budget for the output')
|
|
144
259
|
.option('--debug', 'print every score before the results')
|
|
@@ -202,5 +317,12 @@ export function buildProgram() {
|
|
|
202
317
|
console.log(`${chunk.content}\n`);
|
|
203
318
|
}
|
|
204
319
|
});
|
|
320
|
+
// Help lists groups and commands in the order a new user needs them.
|
|
321
|
+
const rank = (c) => {
|
|
322
|
+
const i = HELP_ORDER.indexOf(c.name());
|
|
323
|
+
return i === -1 ? HELP_ORDER.length : i;
|
|
324
|
+
};
|
|
325
|
+
// `commands` is typed read-only but is the list help reads, so sorting it in place is the hook.
|
|
326
|
+
program.commands.sort((a, b) => rank(a) - rank(b));
|
|
205
327
|
return program;
|
|
206
328
|
}
|
package/dist/cli/ui.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
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
|
+
return { update: () => undefined, finish: () => undefined };
|
|
73
|
+
let drawn = false;
|
|
74
|
+
let lastDraw = 0;
|
|
75
|
+
let last = { loaded: 0, total: 0 };
|
|
76
|
+
const draw = (loaded, total) => {
|
|
77
|
+
const fraction = total > 0 ? loaded / total : 0;
|
|
78
|
+
const side = [
|
|
79
|
+
'',
|
|
80
|
+
'',
|
|
81
|
+
paint('bold', 'Downloading the embedding model', out),
|
|
82
|
+
paint('dim', `${model}, downloaded once, then cached`, out),
|
|
83
|
+
'',
|
|
84
|
+
`${paint('yellow', bar(fraction, 28), out)} ${Math.round(fraction * 100)}%`,
|
|
85
|
+
paint('dim', `${mb(loaded)} of ${mb(total)} MB`, out),
|
|
86
|
+
'',
|
|
87
|
+
];
|
|
88
|
+
const lines = amphora(fraction).map((row, i) => ` ${paint('yellow', row, out)} ${side[i] ?? ''}`);
|
|
89
|
+
// Move back up over the previous drawing, then redraw every line.
|
|
90
|
+
if (drawn)
|
|
91
|
+
out.write(`\x1b[${lines.length}A`);
|
|
92
|
+
out.write(`${lines.map((line) => `\r\x1b[K${line}`).join('\n')}\n`);
|
|
93
|
+
drawn = true;
|
|
94
|
+
};
|
|
95
|
+
return {
|
|
96
|
+
update(loaded, total) {
|
|
97
|
+
last = { loaded, total };
|
|
98
|
+
// Small files (tokenizer, config) come first and would read as 100% at once; the
|
|
99
|
+
// drawing starts with the model weights. Redraws are capped at about ten a second.
|
|
100
|
+
const now = Date.now();
|
|
101
|
+
if (total < MIN_DRAW_BYTES || (now - lastDraw < 100 && loaded < total))
|
|
102
|
+
return;
|
|
103
|
+
lastDraw = now;
|
|
104
|
+
draw(loaded, total);
|
|
105
|
+
},
|
|
106
|
+
finish() {
|
|
107
|
+
if (drawn)
|
|
108
|
+
draw(last.total, last.total);
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/** A one-line bar for embedding progress, redrawn in place on stderr. */
|
|
113
|
+
export function embedProgress(done, total) {
|
|
114
|
+
const out = process.stderr;
|
|
115
|
+
if (!out.isTTY)
|
|
116
|
+
return;
|
|
117
|
+
const fraction = done / Math.max(total, 1);
|
|
118
|
+
out.write(`\r\x1b[K ${paint('dim', 'Embedding', out)} ${paint('yellow', bar(fraction), out)} ${done}/${total} chunks`);
|
|
119
|
+
}
|
|
120
|
+
/** Clears the current line on stderr, after a progress bar. */
|
|
121
|
+
export function clearLine() {
|
|
122
|
+
if (process.stderr.isTTY)
|
|
123
|
+
process.stderr.write('\r\x1b[K');
|
|
124
|
+
}
|
|
125
|
+
/** What a bare `remimem` prints: the banner and the few commands that matter first. */
|
|
126
|
+
export function welcome(version, initialized) {
|
|
127
|
+
const cmd = (text) => paint('cyan', text);
|
|
128
|
+
const step = (n, text, command) => ` ${paint('dim', `${n}.`)} ${text}\n ${cmd(command)}`;
|
|
129
|
+
const lines = [banner(version)];
|
|
130
|
+
if (initialized) {
|
|
131
|
+
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`);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
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"'));
|
|
135
|
+
}
|
|
136
|
+
lines.push('', `${paint('dim', 'All commands:')} ${cmd('remimem --help')} ${paint('dim', 'Docs:')} ${paint('underline', 'https://github.com/JaswanthRemiel/remimem')}`, '');
|
|
137
|
+
return lines.join('\n');
|
|
138
|
+
}
|
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
|
});
|