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.
@@ -0,0 +1,196 @@
1
+ // The dashboard's JSON API. Every handler works on the same ToolContext as the MCP tools, so
2
+ // the page shows exactly what the agent sees, and changes take effect for the agent at once.
3
+ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
4
+ import { createRequire } from 'node:module';
5
+ import { join } from 'node:path';
6
+ import { runDoctor } from '../cli/commands.js';
7
+ import { CONFIG_DIR, parseConfig } from '../config/index.js';
8
+ import { createProvider } from '../embedder/index.js';
9
+ import { RemimemError } from '../errors.js';
10
+ import { indexRepo, pendingChanges } from '../indexer/index.js';
11
+ import { forget, MEMORY_KINDS, MemoryError, remember } from '../memory/index.js';
12
+ import { pack } from '../packer/index.js';
13
+ import { search } from '../retriever/index.js';
14
+ import { refreshIndex } from '../mcp/tools.js';
15
+ import { folderView } from './graph.js';
16
+ const pkg = createRequire(import.meta.url)('../../package.json');
17
+ export class NotFoundError extends RemimemError {
18
+ }
19
+ const object = (body) => typeof body === 'object' && body !== null && !Array.isArray(body)
20
+ ? body
21
+ : {};
22
+ const strings = (value) => Array.isArray(value)
23
+ ? value.filter((v) => typeof v === 'string' && v.trim() !== '')
24
+ : [];
25
+ function memoryInput(body) {
26
+ const b = object(body);
27
+ const kind = typeof b['kind'] === 'string' ? b['kind'] : 'decision';
28
+ if (!MEMORY_KINDS.includes(kind)) {
29
+ throw new MemoryError(`Unknown kind "${kind}". Use one of: ${MEMORY_KINDS.join(', ')}.`);
30
+ }
31
+ return {
32
+ text: typeof b['text'] === 'string' ? b['text'] : '',
33
+ kind: kind,
34
+ paths: strings(b['paths']),
35
+ symbols: strings(b['symbols']),
36
+ tags: strings(b['tags']),
37
+ };
38
+ }
39
+ /** Re-indexes now, after any refresh already running, and lets tool calls wait for it. */
40
+ async function reindex(ctx, full) {
41
+ if (ctx.refreshing)
42
+ await ctx.refreshing;
43
+ const run = indexRepo(ctx.root, ctx.store, ctx.config, { provider: ctx.provider, full });
44
+ ctx.refreshing = run.catch(() => undefined).finally(() => (ctx.refreshing = undefined));
45
+ return await run;
46
+ }
47
+ function configPath(root) {
48
+ return join(root, CONFIG_DIR, 'config.json');
49
+ }
50
+ function readRawConfig(root) {
51
+ try {
52
+ return JSON.parse(readFileSync(configPath(root), 'utf8'));
53
+ }
54
+ catch {
55
+ return {};
56
+ }
57
+ }
58
+ export async function handleApi(ctx, req) {
59
+ const { store } = ctx;
60
+ const route = `${req.method} ${req.path}`;
61
+ const memoryId = /^\/api\/memories\/([\w-]+)$/.exec(req.path)?.[1];
62
+ switch (route) {
63
+ case 'GET /api/overview': {
64
+ const counts = store.counts();
65
+ const files = store.fileSummaries();
66
+ const languages = new Map();
67
+ for (const f of files)
68
+ languages.set(f.language ?? 'text', (languages.get(f.language ?? 'text') ?? 0) + 1);
69
+ const memories = store.listMemories();
70
+ return {
71
+ root: ctx.root,
72
+ version: pkg.version,
73
+ counts: { ...counts, edges: store.edgeCount(), vectors: store.vectorCount() },
74
+ embeddingModel: store.embeddingModel() ?? null,
75
+ lastIndexedAt: store.getMeta('last_indexed_at') ?? null,
76
+ lastIndexedCommit: store.getMeta('last_indexed_commit') ?? null,
77
+ languages: [...languages]
78
+ .map(([language, count]) => ({ language, files: count }))
79
+ .sort((a, b) => b.files - a.files),
80
+ memories: { total: memories.length, stale: memories.filter((m) => m.stale).length },
81
+ pending: counts.files > 0 ? await pendingChanges(ctx.root, store, ctx.config) : null,
82
+ indexing: ctx.refreshing !== undefined,
83
+ };
84
+ }
85
+ case 'GET /api/graph':
86
+ return folderView(store.fileSummaries(), store.fileEdges(), req.query.get('dir') ?? '');
87
+ case 'GET /api/file': {
88
+ const path = req.query.get('path') ?? '';
89
+ const language = store.fileLanguage(path);
90
+ if (language === undefined)
91
+ throw new NotFoundError(`No file "${path}" in the index.`);
92
+ const symbols = store.symbolsInFile(path);
93
+ const neighbors = store.neighbors(symbols.map((s) => s.id));
94
+ return {
95
+ path,
96
+ language,
97
+ symbols: symbols.map((s) => ({
98
+ ...s,
99
+ // The parent and children are shown by nesting, so only cross-symbol edges are listed.
100
+ neighbors: neighbors
101
+ .filter((n) => n.of === s.id && n.relation !== 'inside' && n.relation !== 'contains')
102
+ .map((n) => ({
103
+ id: n.id,
104
+ path: n.path,
105
+ name: n.qualifiedName,
106
+ kind: n.kind,
107
+ line: n.startLine,
108
+ relation: n.relation,
109
+ confidence: n.confidence,
110
+ })),
111
+ })),
112
+ memories: store.listMemories().filter((m) => m.links.some((l) => l.path === path)),
113
+ };
114
+ }
115
+ case 'GET /api/symbol': {
116
+ const chunks = store.chunksOfSymbol(Number(req.query.get('id')));
117
+ if (chunks.length === 0)
118
+ throw new NotFoundError('No code for that symbol in the index.');
119
+ const first = chunks[0];
120
+ return {
121
+ path: first.path,
122
+ startLine: first.startLine,
123
+ code: chunks.map((c) => c.content).join('\n'),
124
+ };
125
+ }
126
+ case 'POST /api/search': {
127
+ const b = object(req.body);
128
+ const text = typeof b['query'] === 'string' ? b['query'].trim() : '';
129
+ if (!text)
130
+ throw new RemimemError('Type something to search for.');
131
+ const retrieval = ctx.config.retrieval;
132
+ const budget = Number.isFinite(b['budget'])
133
+ ? Number(b['budget'])
134
+ : retrieval.defaultBudgetTokens;
135
+ const k = Number.isFinite(b['k']) ? Number(b['k']) : retrieval.defaultK;
136
+ await refreshIndex(ctx);
137
+ const started = performance.now();
138
+ // Not logged: trying queries here should not count toward the savings in `remimem stats`.
139
+ const results = await search(store, text, retrieval, ctx.provider, k);
140
+ const packed = pack(results, budget, '', retrieval.neighborBudgetShare);
141
+ const shown = new Set(packed.included.map((item) => item.chunk.id));
142
+ return {
143
+ ms: Math.round(performance.now() - started),
144
+ tokens: packed.tokens,
145
+ budget,
146
+ text: packed.text,
147
+ results: results.map((r) => ({
148
+ path: r.chunk.path,
149
+ startLine: r.chunk.startLine,
150
+ endLine: r.chunk.endLine,
151
+ symbol: r.chunk.symbol,
152
+ kind: r.chunk.kind,
153
+ score: r.score,
154
+ reasons: r.reasons,
155
+ ranks: r.ranks,
156
+ detail: r.detail,
157
+ tokens: r.chunk.tokenCount,
158
+ included: shown.has(r.chunk.id),
159
+ })),
160
+ };
161
+ }
162
+ case 'GET /api/memories':
163
+ return { kinds: MEMORY_KINDS, memories: store.listMemories() };
164
+ case 'POST /api/memories':
165
+ return remember(ctx.root, store, memoryInput(req.body));
166
+ case 'GET /api/stats':
167
+ return { byTool: store.queryLogSummary(), daily: store.queryLogDaily() };
168
+ case 'GET /api/doctor':
169
+ return await runDoctor(ctx.root);
170
+ case 'POST /api/index':
171
+ return { stats: await reindex(ctx, object(req.body)['full'] === true) };
172
+ case 'GET /api/config':
173
+ return { raw: readRawConfig(ctx.root), effective: ctx.config };
174
+ case 'PUT /api/config': {
175
+ const raw = object(req.body)['config'];
176
+ // Throws a ConfigError with the schema's message when the edit is not valid.
177
+ const config = parseConfig(raw);
178
+ mkdirSync(join(ctx.root, CONFIG_DIR), { recursive: true });
179
+ writeFileSync(configPath(ctx.root), `${JSON.stringify(raw, null, 2)}\n`);
180
+ const embeddingChanged = JSON.stringify(config.embedding) !== JSON.stringify(ctx.config.embedding);
181
+ ctx.config = config;
182
+ if (embeddingChanged)
183
+ ctx.provider = createProvider(config.embedding);
184
+ return { effective: config, needsFullIndex: embeddingChanged };
185
+ }
186
+ }
187
+ if (memoryId !== undefined && req.method === 'PUT') {
188
+ return remember(ctx.root, store, { ...memoryInput(req.body), id: memoryId });
189
+ }
190
+ if (memoryId !== undefined && req.method === 'DELETE') {
191
+ if (!forget(ctx.root, store, memoryId))
192
+ throw new NotFoundError(`No memory with id ${memoryId}.`);
193
+ return { deleted: memoryId };
194
+ }
195
+ throw new NotFoundError(`No such API route: ${route}`);
196
+ }
@@ -0,0 +1,58 @@
1
+ // The dashboard's code graph, one folder at a time: each child folder or file of the current
2
+ // folder is a node, and resolved symbol edges between files are summed onto those nodes.
3
+ /** The graph of the children of `dir` ('' is the project root). */
4
+ export function folderView(files, fileEdges, dir) {
5
+ const prefix = dir === '' ? '' : `${dir.replace(/\/+$/, '')}/`;
6
+ // The child of `dir` a file belongs to, or undefined when it is outside `dir`.
7
+ const childOf = (path) => {
8
+ if (!path.startsWith(prefix))
9
+ return undefined;
10
+ const rest = path.slice(prefix.length);
11
+ const slash = rest.indexOf('/');
12
+ return slash === -1 ? path : prefix + rest.slice(0, slash);
13
+ };
14
+ const nodes = new Map();
15
+ for (const file of files) {
16
+ const id = childOf(file.path);
17
+ if (id === undefined)
18
+ continue;
19
+ const node = nodes.get(id) ?? {
20
+ id,
21
+ label: id.slice(prefix.length),
22
+ type: id === file.path ? 'file' : 'folder',
23
+ files: 0,
24
+ symbols: 0,
25
+ language: null,
26
+ languages: new Map(),
27
+ };
28
+ node.files += 1;
29
+ node.symbols += file.symbols;
30
+ if (file.language)
31
+ node.languages.set(file.language, (node.languages.get(file.language) ?? 0) + 1);
32
+ nodes.set(id, node);
33
+ }
34
+ const edges = new Map();
35
+ for (const edge of fileEdges) {
36
+ const source = childOf(edge.src);
37
+ const target = childOf(edge.dst);
38
+ if (source === undefined || target === undefined || source === target)
39
+ continue;
40
+ const key = `${source}\n${target}`;
41
+ const existing = edges.get(key);
42
+ if (existing)
43
+ existing.weight += edge.weight;
44
+ else
45
+ edges.set(key, { source, target, weight: edge.weight });
46
+ }
47
+ return {
48
+ dir: prefix.replace(/\/$/, ''),
49
+ nodes: [...nodes.values()]
50
+ .map(({ languages, ...node }) => ({
51
+ ...node,
52
+ language: [...languages].sort((a, b) => b[1] - a[1])[0]?.[0] ?? null,
53
+ }))
54
+ // Folders first, then files, each by name.
55
+ .sort((a, b) => a.type === b.type ? a.id.localeCompare(b.id) : a.type === 'folder' ? -1 : 1),
56
+ edges: [...edges.values()],
57
+ };
58
+ }
@@ -0,0 +1,164 @@
1
+ // The local dashboard: a small HTTP server on 127.0.0.1 that serves the page and its JSON API.
2
+ // The page can change memories, the index, and the config, so every request is checked:
3
+ // the Host header must name this server (against DNS rebinding), every API call must carry the
4
+ // token from the printed URL, and changes must be JSON from this origin (against cross-site
5
+ // forms). Nothing here writes to stdout: under `remimem serve` it belongs to the MCP protocol.
6
+ import { createHash, randomBytes, timingSafeEqual } from 'node:crypto';
7
+ import { readFileSync, rmSync, writeFileSync } from 'node:fs';
8
+ import { createServer } from 'node:http';
9
+ import { tmpdir } from 'node:os';
10
+ import { dirname, join } from 'node:path';
11
+ import { fileURLToPath } from 'node:url';
12
+ import { RemimemError } from '../errors.js';
13
+ import { log } from '../log.js';
14
+ import { handleApi, NotFoundError } from './api.js';
15
+ /** Where the built page lives: next to this file, in `ui/`. */
16
+ const UI_DIR = join(dirname(fileURLToPath(import.meta.url)), 'ui');
17
+ const STATIC = {
18
+ '/': ['index.html', 'text/html; charset=utf-8'],
19
+ '/app.js': ['app.js', 'text/javascript; charset=utf-8'],
20
+ '/app.css': ['app.css', 'text/css; charset=utf-8'],
21
+ };
22
+ const MAX_BODY_BYTES = 1_048_576;
23
+ /** The file that tells `remimem dashboard` where a running server for `root` is. */
24
+ export function discoveryFile(root) {
25
+ const id = createHash('sha256').update(root).digest('hex').slice(0, 16);
26
+ return join(tmpdir(), `remimem-dashboard-${id}.json`);
27
+ }
28
+ /** The running dashboard for `root`, if its server process is still alive. */
29
+ export function findDashboard(root) {
30
+ try {
31
+ const found = JSON.parse(readFileSync(discoveryFile(root), 'utf8'));
32
+ process.kill(found.pid, 0); // throws when the process is gone
33
+ return found;
34
+ }
35
+ catch {
36
+ return undefined;
37
+ }
38
+ }
39
+ function sameToken(given, token) {
40
+ if (given === undefined || given.length !== token.length)
41
+ return false;
42
+ return timingSafeEqual(Buffer.from(given), Buffer.from(token));
43
+ }
44
+ function send(res, status, body, type) {
45
+ res.writeHead(status, {
46
+ 'content-type': type,
47
+ 'cache-control': 'no-store',
48
+ // The token is in the page's URL: never leak it in a Referer, never allow framing.
49
+ 'referrer-policy': 'no-referrer',
50
+ 'x-frame-options': 'DENY',
51
+ 'x-content-type-options': 'nosniff',
52
+ 'content-security-policy': "default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; frame-ancestors 'none'",
53
+ });
54
+ res.end(body);
55
+ }
56
+ const json = (res, status, value) => send(res, status, JSON.stringify(value), 'application/json; charset=utf-8');
57
+ async function readBody(req) {
58
+ let size = 0;
59
+ const parts = [];
60
+ for await (const part of req) {
61
+ size += part.length;
62
+ if (size > MAX_BODY_BYTES)
63
+ throw new RemimemError('Request body too large.');
64
+ parts.push(part);
65
+ }
66
+ const text = Buffer.concat(parts).toString('utf8');
67
+ if (!text)
68
+ return undefined;
69
+ try {
70
+ return JSON.parse(text);
71
+ }
72
+ catch {
73
+ throw new RemimemError('Request body is not valid JSON.');
74
+ }
75
+ }
76
+ /**
77
+ * Starts the dashboard for an open project. `port` 0 picks a free port. The URL is written to
78
+ * the discovery file, which is removed again by `close`.
79
+ */
80
+ export async function startDashboard(ctx, port = 0) {
81
+ const token = randomBytes(24).toString('base64url');
82
+ let origins = new Set();
83
+ let hosts = new Set();
84
+ const server = createServer((req, res) => {
85
+ void (async () => {
86
+ const host = req.headers.host ?? '';
87
+ if (!hosts.has(host))
88
+ return send(res, 421, 'Unknown host', 'text/plain');
89
+ const url = new URL(req.url ?? '/', `http://${host}`);
90
+ const method = req.method ?? 'GET';
91
+ if (!url.pathname.startsWith('/api/')) {
92
+ const asset = method === 'GET' ? STATIC[url.pathname] : undefined;
93
+ if (!asset)
94
+ return send(res, 404, 'Not found', 'text/plain');
95
+ try {
96
+ return send(res, 200, readFileSync(join(UI_DIR, asset[0]), 'utf8'), asset[1]);
97
+ }
98
+ catch {
99
+ return send(res, 500, 'The dashboard page is missing. Run `npm run build`.', 'text/plain');
100
+ }
101
+ }
102
+ const given = req.headers['x-remimem-token'];
103
+ if (!sameToken(typeof given === 'string' ? given : undefined, token)) {
104
+ return json(res, 401, {
105
+ error: 'Missing or wrong token. Open the URL that remimem printed.',
106
+ });
107
+ }
108
+ if (method !== 'GET') {
109
+ const origin = req.headers.origin;
110
+ const type = req.headers['content-type'] ?? '';
111
+ if ((origin !== undefined && !origins.has(origin)) ||
112
+ !type.startsWith('application/json')) {
113
+ return json(res, 403, {
114
+ error: 'Changes must be JSON requests from the dashboard page.',
115
+ });
116
+ }
117
+ }
118
+ try {
119
+ const body = method === 'GET' ? undefined : await readBody(req);
120
+ json(res, 200, await handleApi(ctx, { method, path: url.pathname, query: url.searchParams, body }));
121
+ }
122
+ catch (error) {
123
+ if (error instanceof RemimemError) {
124
+ return json(res, error instanceof NotFoundError ? 404 : 400, { error: error.message });
125
+ }
126
+ log.error(`dashboard: ${method} ${url.pathname} failed: ${String(error)}`);
127
+ json(res, 500, { error: 'Internal error; see the remimem log.' });
128
+ }
129
+ })();
130
+ });
131
+ await new Promise((resolve, reject) => {
132
+ server.once('error', reject);
133
+ server.listen(port, '127.0.0.1', () => resolve());
134
+ });
135
+ const actual = server.address().port;
136
+ hosts = new Set([`127.0.0.1:${actual}`, `localhost:${actual}`]);
137
+ origins = new Set([...hosts].map((h) => `http://${h}`));
138
+ const url = `http://127.0.0.1:${actual}/?token=${token}`;
139
+ const file = discoveryFile(ctx.root);
140
+ try {
141
+ writeFileSync(file, JSON.stringify({ url, pid: process.pid }), { mode: 0o600 });
142
+ }
143
+ catch (error) {
144
+ log.warn(`could not write ${file}: ${String(error)}`);
145
+ }
146
+ log.info(`dashboard at ${url}`);
147
+ // Only remove the discovery file if it still points at this server.
148
+ const cleanup = () => {
149
+ if (findDashboard(ctx.root)?.url === url)
150
+ rmSync(file, { force: true });
151
+ };
152
+ process.once('exit', cleanup);
153
+ return {
154
+ url,
155
+ port: actual,
156
+ unref: () => server.unref(),
157
+ close: async () => {
158
+ process.off('exit', cleanup);
159
+ cleanup();
160
+ server.closeAllConnections();
161
+ await new Promise((resolve) => server.close(() => resolve()));
162
+ },
163
+ };
164
+ }
@@ -0,0 +1 @@
1
+ :root{--bg: #f2ede1;--fg: #26251e;--card: #f7f3ea;--muted: #e8e1d0;--muted-fg: #6b6656;--border: #dcd3be;--primary: #9a6b1f;--primary-fg: #fbf8f1;--danger: #a4502f;--ok: #4f7a3a;--warn: #9a6b1f;--serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;--sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;--mono: ui-monospace, Menlo, Consolas, monospace;color-scheme:light}@media(prefers-color-scheme:dark){:root{--bg: #14130f;--fg: #ece6d6;--card: #1b1a15;--muted: #24221c;--muted-fg: #a39c88;--border: #2e2b23;--primary: #d9a94b;--primary-fg: #14130f;--danger: #e07a55;--ok: #8fbf7a;--warn: #d9a94b;color-scheme:dark}}*{box-sizing:border-box}html,body{margin:0;height:100%}body{background:var(--bg);color:var(--fg);font:14px/1.5 var(--sans)}a{color:inherit}button,input,select,textarea{font:inherit;color:inherit}.shell{display:grid;grid-template-columns:220px minmax(0,1fr);min-height:100%}.side{position:sticky;top:0;height:100vh;display:flex;flex-direction:column;gap:4px;padding:20px 14px;border-right:1px solid var(--border);background:var(--card)}.brand{display:flex;align-items:center;gap:10px;font:600 20px var(--serif)}.mark{display:grid;place-items:center;width:26px;height:26px;border:1px solid var(--primary);border-radius:999px;color:var(--primary);font-size:15px}.root{margin:6px 0 14px;font:12px var(--mono);color:var(--muted-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;direction:rtl;text-align:left}.tabs{display:flex;flex-direction:column;gap:2px}.tabs a{padding:7px 10px;border-radius:6px;text-decoration:none;color:var(--muted-fg)}.tabs a:hover{background:var(--muted);color:var(--fg)}.tabs a[aria-current=page]{background:var(--muted);color:var(--fg);box-shadow:inset 2px 0 0 var(--primary)}.version{margin-top:auto;font:12px var(--mono);color:var(--muted-fg)}main{padding:28px 32px 64px;outline:none;min-width:0}h1{margin:0 0 4px;font:600 30px/1.15 var(--serif)}h2{margin:28px 0 10px;font:600 19px var(--serif)}.lede{margin:0 0 20px;color:var(--muted-fg)}.grid{display:grid;gap:12px;grid-template-columns:repeat(auto-fill,minmax(160px,1fr))}.card{border:1px solid var(--border);border-radius:8px;background:var(--card);padding:14px 16px;min-width:0}.stat .value{font:600 26px var(--serif)}.stat .label{color:var(--muted-fg);font-size:12px}.row{display:flex;flex-wrap:wrap;align-items:center;gap:8px}.spacer{flex:1}.btn{display:inline-flex;align-items:center;gap:6px;padding:7px 12px;border:1px solid var(--border);border-radius:6px;background:var(--card);cursor:pointer}.btn:hover{border-color:var(--primary)}.btn.primary{background:var(--fg);border-color:var(--fg);color:var(--bg)}.btn.danger{color:var(--danger)}.btn:disabled{opacity:.55;cursor:progress}input[type=text],input[type=search],input[type=number],select,textarea{padding:7px 10px;border:1px solid var(--border);border-radius:6px;background:var(--bg);min-width:0}input:focus-visible,select:focus-visible,textarea:focus-visible,.btn:focus-visible,.tabs a:focus-visible{outline:2px solid var(--primary);outline-offset:1px}textarea{width:100%;font:13px/1.5 var(--mono)}.mono{font-family:var(--mono);font-size:12.5px}.muted{color:var(--muted-fg)}.chip{display:inline-block;padding:1px 8px;border:1px solid var(--border);border-radius:999px;font-size:11.5px;color:var(--muted-fg);white-space:nowrap}.chip.exact,.chip.ok{color:var(--ok);border-color:color-mix(in oklab,var(--ok) 40%,transparent)}.chip.import{color:var(--primary);border-color:color-mix(in oklab,var(--primary) 40%,transparent)}.chip.name-match,.chip.stale,.chip.bad{color:var(--danger);border-color:color-mix(in oklab,var(--danger) 40%,transparent)}.bar{height:8px;border-radius:999px;background:var(--muted);overflow:hidden}.bar>span{display:block;height:100%;background:var(--primary)}table{width:100%;border-collapse:collapse}th,td{padding:7px 8px;border-bottom:1px solid var(--border);text-align:left;vertical-align:top}th{font-weight:500;color:var(--muted-fg);font-size:12px}.table-wrap{overflow-x:auto}pre.code{margin:0;padding:12px 14px;border:1px solid var(--border);border-radius:8px;background:var(--card);overflow:auto;max-height:460px;font:12.5px/1.5 var(--mono)}.chart{width:100%;height:160px;display:block}.graph-layout{display:grid;grid-template-columns:minmax(0,1fr) 360px;gap:14px}.crumbs{display:flex;flex-wrap:wrap;gap:4px;align-items:center;margin-bottom:10px;font:13px var(--mono)}.crumbs button{border:0;background:none;padding:2px 4px;color:var(--primary);cursor:pointer}#cy{height:min(68vh,640px);border:1px solid var(--border);border-radius:8px;background:var(--card)}.panel{max-height:min(68vh,640px);overflow:auto}.symbol{padding:6px 0;border-bottom:1px solid var(--border)}.symbol>button{border:0;background:none;padding:0;cursor:pointer;text-align:left}.neighbors{margin:4px 0 0;padding:0;list-style:none;font-size:12.5px}.neighbors li{display:flex;gap:6px;align-items:baseline;padding:1px 0}.neighbors button{border:0;background:none;padding:0;color:var(--primary);cursor:pointer;font:12px var(--mono);text-align:left;overflow-wrap:anywhere}.legend{display:flex;flex-wrap:wrap;gap:10px;margin-top:8px;font-size:12px;color:var(--muted-fg)}.legend i{display:inline-block;width:10px;height:10px;border-radius:999px;margin-right:4px;vertical-align:-1px}.memory{display:grid;gap:8px}.memory p{margin:0;white-space:pre-wrap;overflow-wrap:anywhere}.form{display:grid;gap:10px}.form label{display:grid;gap:4px;font-size:12.5px;color:var(--muted-fg)}.error{color:var(--danger);white-space:pre-wrap}.toast{position:fixed;right:16px;bottom:16px;max-width:min(420px,calc(100vw - 32px));padding:10px 14px;border:1px solid var(--border);border-radius:8px;background:var(--fg);color:var(--bg);opacity:0;transform:translateY(8px);transition:opacity .2s,transform .2s;pointer-events:none}.toast.show{opacity:1;transform:none}@media(max-width:860px){.shell{grid-template-columns:minmax(0,1fr)}.side{position:sticky;z-index:5;height:auto;flex-direction:row;align-items:center;gap:12px;padding:10px 14px;border-right:0;border-bottom:1px solid var(--border)}.root,.version,.brand .name{display:none}.tabs{flex-direction:row;overflow-x:auto;scrollbar-width:none}.tabs a{white-space:nowrap}.tabs a[aria-current=page]{box-shadow:inset 0 -2px 0 var(--primary)}main{padding:20px 16px 48px}h1{font-size:25px}.graph-layout{grid-template-columns:minmax(0,1fr)}#cy{height:56vh}.panel{max-height:none}}@media(prefers-reduced-motion:reduce){.toast{transition:none}}