mor 0.0.2 → 0.1.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 +160 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +587 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.js +56 -0
- package/dist/config.js.map +1 -0
- package/dist/db.d.ts +37 -0
- package/dist/db.js +134 -0
- package/dist/db.js.map +1 -0
- package/dist/embeddings/none.d.ts +6 -0
- package/dist/embeddings/none.js +8 -0
- package/dist/embeddings/none.js.map +1 -0
- package/dist/embeddings/ollama.d.ts +9 -0
- package/dist/embeddings/ollama.js +28 -0
- package/dist/embeddings/ollama.js.map +1 -0
- package/dist/embeddings/openai.d.ts +10 -0
- package/dist/embeddings/openai.js +33 -0
- package/dist/embeddings/openai.js.map +1 -0
- package/dist/embeddings/provider.d.ts +7 -0
- package/dist/embeddings/provider.js +15 -0
- package/dist/embeddings/provider.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +160 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp.d.ts +1 -0
- package/dist/mcp.js +188 -0
- package/dist/mcp.js.map +1 -0
- package/dist/memory.d.ts +20 -0
- package/dist/memory.js +124 -0
- package/dist/memory.js.map +1 -0
- package/dist/operations.d.ts +61 -0
- package/dist/operations.js +122 -0
- package/dist/operations.js.map +1 -0
- package/dist/query.d.ts +3 -0
- package/dist/query.js +44 -0
- package/dist/query.js.map +1 -0
- package/dist/remote.d.ts +35 -0
- package/dist/remote.js +77 -0
- package/dist/remote.js.map +1 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.js +241 -0
- package/dist/server.js.map +1 -0
- package/dist/types.d.ts +50 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/package.json +35 -17
- package/.dir-locals.el +0 -6
- package/.editorconfig +0 -15
- package/.eslintrc +0 -26
- package/.npmignore +0 -32
- package/LICENSE +0 -21
- package/alg/dfs.js +0 -36
- package/alg/revDfs.js +0 -36
- package/cli.js +0 -106
- package/mor-core.js +0 -60
- package/mor-link.js +0 -23
- package/mor-outdated.js +0 -26
package/dist/remote.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
class HttpError extends Error {
|
|
2
|
+
status;
|
|
3
|
+
constructor(status, message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.status = status;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export class RemoteOperations {
|
|
9
|
+
baseUrl;
|
|
10
|
+
token;
|
|
11
|
+
constructor(config) {
|
|
12
|
+
if (!config.server?.url)
|
|
13
|
+
throw new Error('No server URL configured');
|
|
14
|
+
this.baseUrl = config.server.url.replace(/\/+$/, '');
|
|
15
|
+
this.token = config.server.token;
|
|
16
|
+
}
|
|
17
|
+
headers() {
|
|
18
|
+
const h = { 'Content-Type': 'application/json' };
|
|
19
|
+
if (this.token)
|
|
20
|
+
h['Authorization'] = `Bearer ${this.token}`;
|
|
21
|
+
return h;
|
|
22
|
+
}
|
|
23
|
+
async request(method, path, body) {
|
|
24
|
+
const url = `${this.baseUrl}${path}`;
|
|
25
|
+
const res = await fetch(url, {
|
|
26
|
+
method,
|
|
27
|
+
headers: this.headers(),
|
|
28
|
+
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
|
29
|
+
});
|
|
30
|
+
const json = (await res.json());
|
|
31
|
+
if (!res.ok) {
|
|
32
|
+
throw new HttpError(res.status, json.error ?? `HTTP ${res.status}`);
|
|
33
|
+
}
|
|
34
|
+
return json.data;
|
|
35
|
+
}
|
|
36
|
+
async search(query, limit = 20) {
|
|
37
|
+
const params = new URLSearchParams({ q: query, limit: String(limit) });
|
|
38
|
+
return this.request('GET', `/memories/search?${params}`);
|
|
39
|
+
}
|
|
40
|
+
async read(query) {
|
|
41
|
+
try {
|
|
42
|
+
return await this.request('GET', `/memories/${encodeURIComponent(query)}`);
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
if (e instanceof HttpError && e.status === 404)
|
|
46
|
+
return undefined;
|
|
47
|
+
throw e;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async add(opts) {
|
|
51
|
+
return this.request('POST', '/memories', opts);
|
|
52
|
+
}
|
|
53
|
+
async update(query, updates) {
|
|
54
|
+
return this.request('PUT', `/memories/${encodeURIComponent(query)}`, updates);
|
|
55
|
+
}
|
|
56
|
+
async remove(query) {
|
|
57
|
+
return this.request('DELETE', `/memories/${encodeURIComponent(query)}`);
|
|
58
|
+
}
|
|
59
|
+
async grep(pattern, limit = 20, ignoreCase = false) {
|
|
60
|
+
const params = new URLSearchParams({
|
|
61
|
+
q: pattern,
|
|
62
|
+
limit: String(limit),
|
|
63
|
+
...(ignoreCase ? { ignoreCase: '1' } : {}),
|
|
64
|
+
});
|
|
65
|
+
return this.request('GET', `/memories/grep?${params}`);
|
|
66
|
+
}
|
|
67
|
+
async list() {
|
|
68
|
+
return this.request('GET', '/memories');
|
|
69
|
+
}
|
|
70
|
+
async push() {
|
|
71
|
+
return this.request('POST', '/push');
|
|
72
|
+
}
|
|
73
|
+
close() {
|
|
74
|
+
// no-op for remote
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=remote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.js","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AAGA,MAAM,SAAU,SAAQ,KAAK;IAElB;IADT,YACS,MAAc,EACrB,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,WAAM,GAAN,MAAM,CAAQ;IAIvB,CAAC;CACF;AAED,MAAM,OAAO,gBAAgB;IACnB,OAAO,CAAS;IAChB,KAAK,CAAU;IAEvB,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QACrE,IAAI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CAAC,OAAO,CAAW,KAAK,EAAE,kBAAkB,MAAM,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,OAAO,CAAW,KAAK,EAAE,WAAW,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,OAAO,CAAuC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7E,CAAC;IAED,KAAK;QACH,mBAAmB;IACrB,CAAC;CACF"}
|
package/dist/server.d.ts
ADDED
package/dist/server.js
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import http from 'node:http';
|
|
3
|
+
import { LocalOperations } from './operations.js';
|
|
4
|
+
function log(msg) {
|
|
5
|
+
process.stderr.write(`[mor] ${msg}\n`);
|
|
6
|
+
}
|
|
7
|
+
async function readBody(req, maxBytes = 10 * 1024 * 1024) {
|
|
8
|
+
const chunks = [];
|
|
9
|
+
let total = 0;
|
|
10
|
+
for await (const chunk of req) {
|
|
11
|
+
total += chunk.byteLength;
|
|
12
|
+
if (total > maxBytes)
|
|
13
|
+
throw new Error('Request body too large');
|
|
14
|
+
chunks.push(chunk);
|
|
15
|
+
}
|
|
16
|
+
return Buffer.concat(chunks).toString('utf-8');
|
|
17
|
+
}
|
|
18
|
+
function json(res, status, data) {
|
|
19
|
+
if (res.headersSent)
|
|
20
|
+
return;
|
|
21
|
+
const body = JSON.stringify(data);
|
|
22
|
+
res.writeHead(status, { 'Content-Type': 'application/json' });
|
|
23
|
+
res.end(body);
|
|
24
|
+
}
|
|
25
|
+
function router(routes) {
|
|
26
|
+
const compiled = routes.map(([method, pattern, handler]) => {
|
|
27
|
+
const keys = [];
|
|
28
|
+
const re = new RegExp('^' +
|
|
29
|
+
pattern.replace(/:(\w+)/g, (_, k) => {
|
|
30
|
+
keys.push(k);
|
|
31
|
+
return '([^/]+)';
|
|
32
|
+
}) +
|
|
33
|
+
'$');
|
|
34
|
+
return { method, re, keys, handler };
|
|
35
|
+
});
|
|
36
|
+
return async (req, res) => {
|
|
37
|
+
const url = new URL(req.url ?? '/', `http://${req.headers.host ?? 'localhost'}`);
|
|
38
|
+
const method = req.method ?? 'GET';
|
|
39
|
+
for (const route of compiled) {
|
|
40
|
+
if (route.method !== method)
|
|
41
|
+
continue;
|
|
42
|
+
const match = url.pathname.match(route.re);
|
|
43
|
+
if (!match)
|
|
44
|
+
continue;
|
|
45
|
+
const params = {};
|
|
46
|
+
route.keys.forEach((k, i) => {
|
|
47
|
+
params[k] = decodeURIComponent(match[i + 1]);
|
|
48
|
+
});
|
|
49
|
+
await route.handler({ url, params, req, res });
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
json(res, 404, { error: 'Not found' });
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export function startServer(config, opts) {
|
|
56
|
+
const ops = new LocalOperations(config);
|
|
57
|
+
const { token } = opts;
|
|
58
|
+
const handle = router([
|
|
59
|
+
[
|
|
60
|
+
'GET',
|
|
61
|
+
'/health',
|
|
62
|
+
async ({ res }) => {
|
|
63
|
+
json(res, 200, { ok: true });
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
[
|
|
67
|
+
'GET',
|
|
68
|
+
'/memories/search',
|
|
69
|
+
async ({ url, res }) => {
|
|
70
|
+
const q = url.searchParams.get('q');
|
|
71
|
+
if (!q) {
|
|
72
|
+
json(res, 400, { error: 'Missing query parameter: q' });
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const limitRaw = parseInt(url.searchParams.get('limit') ?? '20', 10);
|
|
76
|
+
const limit = Number.isNaN(limitRaw) || limitRaw < 1 ? 20 : limitRaw;
|
|
77
|
+
json(res, 200, { data: await ops.search(q, limit) });
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
[
|
|
81
|
+
'GET',
|
|
82
|
+
'/memories',
|
|
83
|
+
async ({ res }) => {
|
|
84
|
+
json(res, 200, { data: await ops.list() });
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
[
|
|
88
|
+
'POST',
|
|
89
|
+
'/memories',
|
|
90
|
+
async ({ req, res }) => {
|
|
91
|
+
let body;
|
|
92
|
+
try {
|
|
93
|
+
body = JSON.parse(await readBody(req));
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
json(res, 400, { error: 'Invalid JSON' });
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (!body.title || !body.content) {
|
|
100
|
+
json(res, 400, { error: 'Missing required fields: title, content' });
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const { title, content, tags, type, repository } = body;
|
|
104
|
+
json(res, 201, {
|
|
105
|
+
data: await ops.add({ title, content, tags, type, repository }),
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
[
|
|
110
|
+
'GET',
|
|
111
|
+
'/memories/grep',
|
|
112
|
+
async ({ url, res }) => {
|
|
113
|
+
const q = url.searchParams.get('q');
|
|
114
|
+
if (!q) {
|
|
115
|
+
json(res, 400, { error: 'Missing query parameter: q' });
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const limitRaw = parseInt(url.searchParams.get('limit') ?? '20', 10);
|
|
119
|
+
const limit = Number.isNaN(limitRaw) || limitRaw < 1 ? 20 : limitRaw;
|
|
120
|
+
const ignoreCase = url.searchParams.get('ignoreCase') === '1';
|
|
121
|
+
json(res, 200, { data: await ops.grep(q, limit, ignoreCase) });
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
[
|
|
125
|
+
'GET',
|
|
126
|
+
'/memories/:query',
|
|
127
|
+
async ({ params, res }) => {
|
|
128
|
+
const mem = await ops.read(params.query);
|
|
129
|
+
if (!mem) {
|
|
130
|
+
json(res, 404, { error: `Memory not found: ${params.query}` });
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
json(res, 200, { data: mem });
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
[
|
|
137
|
+
'PUT',
|
|
138
|
+
'/memories/:query',
|
|
139
|
+
async ({ params, req, res }) => {
|
|
140
|
+
let body;
|
|
141
|
+
try {
|
|
142
|
+
body = JSON.parse(await readBody(req));
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
json(res, 400, { error: 'Invalid JSON' });
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
const { title, content, tags, type } = body;
|
|
150
|
+
json(res, 200, {
|
|
151
|
+
data: await ops.update(params.query, {
|
|
152
|
+
title,
|
|
153
|
+
content,
|
|
154
|
+
tags,
|
|
155
|
+
type,
|
|
156
|
+
}),
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
catch (e) {
|
|
160
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
161
|
+
json(res, msg.includes('Memory not found') ? 404 : 500, {
|
|
162
|
+
error: msg,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
[
|
|
168
|
+
'POST',
|
|
169
|
+
'/push',
|
|
170
|
+
async ({ res }) => {
|
|
171
|
+
try {
|
|
172
|
+
json(res, 200, { data: await ops.push() });
|
|
173
|
+
}
|
|
174
|
+
catch (e) {
|
|
175
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
176
|
+
json(res, 500, { error: msg });
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
[
|
|
181
|
+
'DELETE',
|
|
182
|
+
'/memories/:query',
|
|
183
|
+
async ({ params, res }) => {
|
|
184
|
+
try {
|
|
185
|
+
json(res, 200, { data: await ops.remove(params.query) });
|
|
186
|
+
}
|
|
187
|
+
catch (e) {
|
|
188
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
189
|
+
json(res, msg.includes('Memory not found') ? 404 : 500, {
|
|
190
|
+
error: msg,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
]);
|
|
196
|
+
const server = http.createServer(async (req, res) => {
|
|
197
|
+
const start = Date.now();
|
|
198
|
+
try {
|
|
199
|
+
if (token) {
|
|
200
|
+
const expectedBuf = Buffer.from(`Bearer ${token}`);
|
|
201
|
+
const providedBuf = Buffer.from(req.headers.authorization ?? '');
|
|
202
|
+
if (expectedBuf.byteLength !== providedBuf.byteLength ||
|
|
203
|
+
!crypto.timingSafeEqual(providedBuf, expectedBuf)) {
|
|
204
|
+
json(res, 401, { error: 'Unauthorized' });
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
await handle(req, res);
|
|
209
|
+
}
|
|
210
|
+
catch (e) {
|
|
211
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
212
|
+
log(`Error: ${msg}`);
|
|
213
|
+
json(res, 500, { error: msg });
|
|
214
|
+
}
|
|
215
|
+
finally {
|
|
216
|
+
log(`${req.method} ${req.url} ${res.statusCode} ${Date.now() - start}ms`);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
const shutdown = () => {
|
|
220
|
+
log('Shutting down...');
|
|
221
|
+
ops.close();
|
|
222
|
+
server.close();
|
|
223
|
+
};
|
|
224
|
+
process.on('SIGINT', () => {
|
|
225
|
+
shutdown();
|
|
226
|
+
process.exit(0);
|
|
227
|
+
});
|
|
228
|
+
process.on('SIGTERM', () => {
|
|
229
|
+
shutdown();
|
|
230
|
+
process.exit(0);
|
|
231
|
+
});
|
|
232
|
+
server.on('close', () => {
|
|
233
|
+
process.removeAllListeners('SIGINT');
|
|
234
|
+
process.removeAllListeners('SIGTERM');
|
|
235
|
+
});
|
|
236
|
+
server.listen(opts.port, opts.host, () => {
|
|
237
|
+
log(`Listening on http://${opts.host}:${opts.port}`);
|
|
238
|
+
});
|
|
239
|
+
return server;
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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,CAAC,OAAO,EAAE,GAAG,EAAE;QACtB,OAAO,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QACrC,OAAO,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE;QACvC,GAAG,CAAC,uBAAuB,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface ServerConfig {
|
|
2
|
+
url: string;
|
|
3
|
+
token?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ServeConfig {
|
|
6
|
+
port?: number;
|
|
7
|
+
host?: string;
|
|
8
|
+
token?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface Config {
|
|
11
|
+
memoryDir: string;
|
|
12
|
+
dbPath: string;
|
|
13
|
+
embedding: EmbeddingConfig;
|
|
14
|
+
server?: ServerConfig;
|
|
15
|
+
serve?: ServeConfig;
|
|
16
|
+
}
|
|
17
|
+
export interface EmbeddingConfig {
|
|
18
|
+
provider: 'none' | 'openai' | 'ollama';
|
|
19
|
+
model: string;
|
|
20
|
+
baseUrl: string;
|
|
21
|
+
dimensions: number;
|
|
22
|
+
apiKey?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare const MEMORY_TYPES: readonly ["user", "feedback", "project", "reference", "knowledge", "snippet", "file"];
|
|
25
|
+
export type MemoryType = (typeof MEMORY_TYPES)[number];
|
|
26
|
+
export interface FrontMatter {
|
|
27
|
+
id: string;
|
|
28
|
+
title: string;
|
|
29
|
+
tags: string[];
|
|
30
|
+
type: MemoryType;
|
|
31
|
+
repository?: string;
|
|
32
|
+
created: string;
|
|
33
|
+
updated: string;
|
|
34
|
+
}
|
|
35
|
+
export interface Memory {
|
|
36
|
+
id: string;
|
|
37
|
+
title: string;
|
|
38
|
+
tags: string[];
|
|
39
|
+
type: MemoryType;
|
|
40
|
+
repository?: string;
|
|
41
|
+
created: string;
|
|
42
|
+
updated: string;
|
|
43
|
+
content: string;
|
|
44
|
+
filePath: string;
|
|
45
|
+
}
|
|
46
|
+
export interface SearchResult {
|
|
47
|
+
memory: Memory;
|
|
48
|
+
score: number;
|
|
49
|
+
matchType: 'uuid' | 'filename' | 'fts' | 'vector';
|
|
50
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA2BA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,MAAM;IACN,UAAU;IACV,SAAS;IACT,WAAW;IACX,WAAW;IACX,SAAS;IACT,MAAM;CACE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,26 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mor",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A user-controlled memory bank for AI assistants",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"mor": "dist/cli.js"
|
|
8
8
|
},
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
"author": {
|
|
12
|
-
"name": "Sigurd Fosseng",
|
|
13
|
-
"emali": "sigurd@fosseng.net"
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=20"
|
|
14
11
|
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
17
|
+
"@modelcontextprotocol/sdk": "^1.28.0",
|
|
18
|
+
"better-sqlite3": "^12.8.0",
|
|
19
|
+
"commander": "^14.0.3",
|
|
20
|
+
"gray-matter": "^4.0.3",
|
|
21
|
+
"zod": "^4.3.6"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"eslint": "^
|
|
24
|
+
"@eslint/js": "^10.0.1",
|
|
25
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
26
|
+
"@types/node": "^25.5.0",
|
|
27
|
+
"eslint": "^10.1.0",
|
|
28
|
+
"eslint-config-prettier": "^10.1.8",
|
|
29
|
+
"prettier": "^3.8.1",
|
|
30
|
+
"tsx": "^4.21.0",
|
|
31
|
+
"typescript": "^6.0.2",
|
|
32
|
+
"typescript-eslint": "^8.57.2",
|
|
33
|
+
"vitest": "^4.1.2"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc",
|
|
37
|
+
"dev": "tsx src/cli.ts",
|
|
38
|
+
"test": "vitest run",
|
|
39
|
+
"test:watch": "vitest",
|
|
40
|
+
"lint": "eslint src/",
|
|
41
|
+
"format": "prettier --write src/",
|
|
42
|
+
"format:check": "prettier --check src/"
|
|
25
43
|
}
|
|
26
|
-
}
|
|
44
|
+
}
|
package/.dir-locals.el
DELETED
package/.editorconfig
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
root = true
|
|
2
|
-
|
|
3
|
-
[*]
|
|
4
|
-
indent_style = tab
|
|
5
|
-
end_of_line = lf
|
|
6
|
-
charset = utf-8
|
|
7
|
-
trim_trailing_whitespace = true
|
|
8
|
-
insert_final_newline = true
|
|
9
|
-
|
|
10
|
-
[{package.json,*.yml}]
|
|
11
|
-
indent_style = space
|
|
12
|
-
indent_size = 2
|
|
13
|
-
|
|
14
|
-
[*.md]
|
|
15
|
-
trim_trailing_whitespace = false
|
package/.eslintrc
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"rules": {
|
|
3
|
-
"indent": [
|
|
4
|
-
2,
|
|
5
|
-
"tab"
|
|
6
|
-
],
|
|
7
|
-
"quotes": [
|
|
8
|
-
2,
|
|
9
|
-
"single"
|
|
10
|
-
],
|
|
11
|
-
"linebreak-style": [
|
|
12
|
-
2,
|
|
13
|
-
"unix"
|
|
14
|
-
],
|
|
15
|
-
"semi": [
|
|
16
|
-
2,
|
|
17
|
-
"always"
|
|
18
|
-
],
|
|
19
|
-
"no-console": 0
|
|
20
|
-
},
|
|
21
|
-
"env": {
|
|
22
|
-
"es6": true,
|
|
23
|
-
"node": true
|
|
24
|
-
},
|
|
25
|
-
"extends": "eslint:recommended"
|
|
26
|
-
}
|
package/.npmignore
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# Created by https://www.gitignore.io/api/node
|
|
2
|
-
|
|
3
|
-
### Node ###
|
|
4
|
-
# Logs
|
|
5
|
-
logs
|
|
6
|
-
*.log
|
|
7
|
-
npm-debug.log*
|
|
8
|
-
|
|
9
|
-
# Runtime data
|
|
10
|
-
pids
|
|
11
|
-
*.pid
|
|
12
|
-
*.seed
|
|
13
|
-
|
|
14
|
-
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
15
|
-
lib-cov
|
|
16
|
-
|
|
17
|
-
# Coverage directory used by tools like istanbul
|
|
18
|
-
coverage
|
|
19
|
-
|
|
20
|
-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
|
21
|
-
.grunt
|
|
22
|
-
|
|
23
|
-
# node-waf configuration
|
|
24
|
-
.lock-wscript
|
|
25
|
-
|
|
26
|
-
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
|
27
|
-
build/Release
|
|
28
|
-
|
|
29
|
-
# Dependency directory
|
|
30
|
-
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
|
|
31
|
-
node_modules
|
|
32
|
-
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2015 Sigurd Fosseng <sigurd@fosseng.net>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
package/alg/dfs.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
var _ = require('lodash');
|
|
2
|
-
|
|
3
|
-
module.exports = dfs;
|
|
4
|
-
|
|
5
|
-
function dfs(g, vs, order) {
|
|
6
|
-
if (!_.isArray(vs)) {
|
|
7
|
-
vs = [vs];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
var acc = [];
|
|
11
|
-
var visited = {};
|
|
12
|
-
_.each(vs, function (v) {
|
|
13
|
-
if (!g.hasNode(v)) {
|
|
14
|
-
throw new Error('Graph does not have node: ' + v);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
doDfs(g, v, order === 'post', visited, acc);
|
|
18
|
-
});
|
|
19
|
-
return acc;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function doDfs(g, v, postorder, visited, acc) {
|
|
23
|
-
if (!_.has(visited, v)) {
|
|
24
|
-
visited[v] = true;
|
|
25
|
-
|
|
26
|
-
if (!postorder) {
|
|
27
|
-
acc.push(v);
|
|
28
|
-
}
|
|
29
|
-
_.each(g.successors(v), function (w) {
|
|
30
|
-
doDfs(g, w, postorder, visited, acc);
|
|
31
|
-
});
|
|
32
|
-
if (postorder) {
|
|
33
|
-
acc.push(v);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
package/alg/revDfs.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
var _ = require('lodash');
|
|
2
|
-
|
|
3
|
-
module.exports = dfs;
|
|
4
|
-
|
|
5
|
-
function dfs(g, vs, order) {
|
|
6
|
-
if (!_.isArray(vs)) {
|
|
7
|
-
vs = [vs];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
var acc = [];
|
|
11
|
-
var visited = {};
|
|
12
|
-
_.each(vs, function (v) {
|
|
13
|
-
if (!g.hasNode(v)) {
|
|
14
|
-
throw new Error('Graph does not have node: ' + v);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
doDfs(g, v, order === 'post', visited, acc);
|
|
18
|
-
});
|
|
19
|
-
return acc;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function doDfs(g, v, postorder, visited, acc) {
|
|
23
|
-
if (!_.has(visited, v)) {
|
|
24
|
-
visited[v] = true;
|
|
25
|
-
|
|
26
|
-
if (!postorder) {
|
|
27
|
-
acc.push(v);
|
|
28
|
-
}
|
|
29
|
-
_.each(g.predecessors(v), function (w) {
|
|
30
|
-
doDfs(g, w, postorder, visited, acc);
|
|
31
|
-
});
|
|
32
|
-
if (postorder) {
|
|
33
|
-
acc.push(v);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|