apsolut-cortex 0.1.0 → 0.1.2
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 +62 -43
- package/dist/cli.js +16 -794
- package/dist/hooks/post-tool-use.js +3 -5344
- package/dist/hooks/session-end.js +280 -37949
- package/dist/hooks/session-start.js +2 -786
- package/dist/hooks/stop.js +2 -786
- package/dist/mcp/server.js +203 -47737
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1,22 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
5
2
|
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __toESM = (mod, isNodeMode, target) => {
|
|
9
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
10
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
11
|
-
for (let key of __getOwnPropNames(mod))
|
|
12
|
-
if (!__hasOwnProp.call(to, key))
|
|
13
|
-
__defProp(to, key, {
|
|
14
|
-
get: () => mod[key],
|
|
15
|
-
enumerable: true
|
|
16
|
-
});
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
20
3
|
var __export = (target, all) => {
|
|
21
4
|
for (var name in all)
|
|
22
5
|
__defProp(target, name, {
|
|
@@ -27,772 +10,6 @@ var __export = (target, all) => {
|
|
|
27
10
|
});
|
|
28
11
|
};
|
|
29
12
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
30
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
31
|
-
|
|
32
|
-
// node_modules/better-sqlite3/lib/util.js
|
|
33
|
-
var require_util = __commonJS((exports) => {
|
|
34
|
-
exports.getBooleanOption = (options, key) => {
|
|
35
|
-
let value = false;
|
|
36
|
-
if (key in options && typeof (value = options[key]) !== "boolean") {
|
|
37
|
-
throw new TypeError(`Expected the "${key}" option to be a boolean`);
|
|
38
|
-
}
|
|
39
|
-
return value;
|
|
40
|
-
};
|
|
41
|
-
exports.cppdb = Symbol();
|
|
42
|
-
exports.inspect = Symbol.for("nodejs.util.inspect.custom");
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// node_modules/better-sqlite3/lib/sqlite-error.js
|
|
46
|
-
var require_sqlite_error = __commonJS((exports, module) => {
|
|
47
|
-
var descriptor = { value: "SqliteError", writable: true, enumerable: false, configurable: true };
|
|
48
|
-
function SqliteError(message, code) {
|
|
49
|
-
if (new.target !== SqliteError) {
|
|
50
|
-
return new SqliteError(message, code);
|
|
51
|
-
}
|
|
52
|
-
if (typeof code !== "string") {
|
|
53
|
-
throw new TypeError("Expected second argument to be a string");
|
|
54
|
-
}
|
|
55
|
-
Error.call(this, message);
|
|
56
|
-
descriptor.value = "" + message;
|
|
57
|
-
Object.defineProperty(this, "message", descriptor);
|
|
58
|
-
Error.captureStackTrace(this, SqliteError);
|
|
59
|
-
this.code = code;
|
|
60
|
-
}
|
|
61
|
-
Object.setPrototypeOf(SqliteError, Error);
|
|
62
|
-
Object.setPrototypeOf(SqliteError.prototype, Error.prototype);
|
|
63
|
-
Object.defineProperty(SqliteError.prototype, "name", descriptor);
|
|
64
|
-
module.exports = SqliteError;
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// node_modules/file-uri-to-path/index.js
|
|
68
|
-
var require_file_uri_to_path = __commonJS((exports, module) => {
|
|
69
|
-
var sep = __require("path").sep || "/";
|
|
70
|
-
module.exports = fileUriToPath;
|
|
71
|
-
function fileUriToPath(uri) {
|
|
72
|
-
if (typeof uri != "string" || uri.length <= 7 || uri.substring(0, 7) != "file://") {
|
|
73
|
-
throw new TypeError("must pass in a file:// URI to convert to a file path");
|
|
74
|
-
}
|
|
75
|
-
var rest = decodeURI(uri.substring(7));
|
|
76
|
-
var firstSlash = rest.indexOf("/");
|
|
77
|
-
var host = rest.substring(0, firstSlash);
|
|
78
|
-
var path = rest.substring(firstSlash + 1);
|
|
79
|
-
if (host == "localhost")
|
|
80
|
-
host = "";
|
|
81
|
-
if (host) {
|
|
82
|
-
host = sep + sep + host;
|
|
83
|
-
}
|
|
84
|
-
path = path.replace(/^(.+)\|/, "$1:");
|
|
85
|
-
if (sep == "\\") {
|
|
86
|
-
path = path.replace(/\//g, "\\");
|
|
87
|
-
}
|
|
88
|
-
if (/^.+\:/.test(path)) {} else {
|
|
89
|
-
path = sep + path;
|
|
90
|
-
}
|
|
91
|
-
return host + path;
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// node_modules/bindings/bindings.js
|
|
96
|
-
var require_bindings = __commonJS((exports, module) => {
|
|
97
|
-
var __filename = "D:\\sites\\git\\apsolut-cortex\\node_modules\\bindings\\bindings.js";
|
|
98
|
-
var fs = __require("fs");
|
|
99
|
-
var path = __require("path");
|
|
100
|
-
var fileURLToPath = require_file_uri_to_path();
|
|
101
|
-
var join = path.join;
|
|
102
|
-
var dirname = path.dirname;
|
|
103
|
-
var exists = fs.accessSync && function(path2) {
|
|
104
|
-
try {
|
|
105
|
-
fs.accessSync(path2);
|
|
106
|
-
} catch (e) {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
return true;
|
|
110
|
-
} || fs.existsSync || path.existsSync;
|
|
111
|
-
var defaults = {
|
|
112
|
-
arrow: process.env.NODE_BINDINGS_ARROW || " → ",
|
|
113
|
-
compiled: process.env.NODE_BINDINGS_COMPILED_DIR || "compiled",
|
|
114
|
-
platform: process.platform,
|
|
115
|
-
arch: process.arch,
|
|
116
|
-
nodePreGyp: "node-v" + process.versions.modules + "-" + process.platform + "-" + process.arch,
|
|
117
|
-
version: process.versions.node,
|
|
118
|
-
bindings: "bindings.node",
|
|
119
|
-
try: [
|
|
120
|
-
["module_root", "build", "bindings"],
|
|
121
|
-
["module_root", "build", "Debug", "bindings"],
|
|
122
|
-
["module_root", "build", "Release", "bindings"],
|
|
123
|
-
["module_root", "out", "Debug", "bindings"],
|
|
124
|
-
["module_root", "Debug", "bindings"],
|
|
125
|
-
["module_root", "out", "Release", "bindings"],
|
|
126
|
-
["module_root", "Release", "bindings"],
|
|
127
|
-
["module_root", "build", "default", "bindings"],
|
|
128
|
-
["module_root", "compiled", "version", "platform", "arch", "bindings"],
|
|
129
|
-
["module_root", "addon-build", "release", "install-root", "bindings"],
|
|
130
|
-
["module_root", "addon-build", "debug", "install-root", "bindings"],
|
|
131
|
-
["module_root", "addon-build", "default", "install-root", "bindings"],
|
|
132
|
-
["module_root", "lib", "binding", "nodePreGyp", "bindings"]
|
|
133
|
-
]
|
|
134
|
-
};
|
|
135
|
-
function bindings(opts) {
|
|
136
|
-
if (typeof opts == "string") {
|
|
137
|
-
opts = { bindings: opts };
|
|
138
|
-
} else if (!opts) {
|
|
139
|
-
opts = {};
|
|
140
|
-
}
|
|
141
|
-
Object.keys(defaults).map(function(i2) {
|
|
142
|
-
if (!(i2 in opts))
|
|
143
|
-
opts[i2] = defaults[i2];
|
|
144
|
-
});
|
|
145
|
-
if (!opts.module_root) {
|
|
146
|
-
opts.module_root = exports.getRoot(exports.getFileName());
|
|
147
|
-
}
|
|
148
|
-
if (path.extname(opts.bindings) != ".node") {
|
|
149
|
-
opts.bindings += ".node";
|
|
150
|
-
}
|
|
151
|
-
var requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
|
|
152
|
-
var tries = [], i = 0, l = opts.try.length, n, b, err;
|
|
153
|
-
for (;i < l; i++) {
|
|
154
|
-
n = join.apply(null, opts.try[i].map(function(p) {
|
|
155
|
-
return opts[p] || p;
|
|
156
|
-
}));
|
|
157
|
-
tries.push(n);
|
|
158
|
-
try {
|
|
159
|
-
b = opts.path ? requireFunc.resolve(n) : requireFunc(n);
|
|
160
|
-
if (!opts.path) {
|
|
161
|
-
b.path = n;
|
|
162
|
-
}
|
|
163
|
-
return b;
|
|
164
|
-
} catch (e) {
|
|
165
|
-
if (e.code !== "MODULE_NOT_FOUND" && e.code !== "QUALIFIED_PATH_RESOLUTION_FAILED" && !/not find/i.test(e.message)) {
|
|
166
|
-
throw e;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
err = new Error(`Could not locate the bindings file. Tried:
|
|
171
|
-
` + tries.map(function(a) {
|
|
172
|
-
return opts.arrow + a;
|
|
173
|
-
}).join(`
|
|
174
|
-
`));
|
|
175
|
-
err.tries = tries;
|
|
176
|
-
throw err;
|
|
177
|
-
}
|
|
178
|
-
module.exports = exports = bindings;
|
|
179
|
-
exports.getFileName = function getFileName(calling_file) {
|
|
180
|
-
var { prepareStackTrace: origPST, stackTraceLimit: origSTL } = Error, dummy = {}, fileName;
|
|
181
|
-
Error.stackTraceLimit = 10;
|
|
182
|
-
Error.prepareStackTrace = function(e, st) {
|
|
183
|
-
for (var i = 0, l = st.length;i < l; i++) {
|
|
184
|
-
fileName = st[i].getFileName();
|
|
185
|
-
if (fileName !== __filename) {
|
|
186
|
-
if (calling_file) {
|
|
187
|
-
if (fileName !== calling_file) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
} else {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
Error.captureStackTrace(dummy);
|
|
197
|
-
dummy.stack;
|
|
198
|
-
Error.prepareStackTrace = origPST;
|
|
199
|
-
Error.stackTraceLimit = origSTL;
|
|
200
|
-
var fileSchema = "file://";
|
|
201
|
-
if (fileName.indexOf(fileSchema) === 0) {
|
|
202
|
-
fileName = fileURLToPath(fileName);
|
|
203
|
-
}
|
|
204
|
-
return fileName;
|
|
205
|
-
};
|
|
206
|
-
exports.getRoot = function getRoot(file) {
|
|
207
|
-
var dir = dirname(file), prev;
|
|
208
|
-
while (true) {
|
|
209
|
-
if (dir === ".") {
|
|
210
|
-
dir = process.cwd();
|
|
211
|
-
}
|
|
212
|
-
if (exists(join(dir, "package.json")) || exists(join(dir, "node_modules"))) {
|
|
213
|
-
return dir;
|
|
214
|
-
}
|
|
215
|
-
if (prev === dir) {
|
|
216
|
-
throw new Error('Could not find module root given file: "' + file + '". Do you have a `package.json` file? ');
|
|
217
|
-
}
|
|
218
|
-
prev = dir;
|
|
219
|
-
dir = join(dir, "..");
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
// node_modules/better-sqlite3/lib/methods/wrappers.js
|
|
225
|
-
var require_wrappers = __commonJS((exports) => {
|
|
226
|
-
var { cppdb } = require_util();
|
|
227
|
-
exports.prepare = function prepare(sql) {
|
|
228
|
-
return this[cppdb].prepare(sql, this, false);
|
|
229
|
-
};
|
|
230
|
-
exports.exec = function exec(sql) {
|
|
231
|
-
this[cppdb].exec(sql);
|
|
232
|
-
return this;
|
|
233
|
-
};
|
|
234
|
-
exports.close = function close() {
|
|
235
|
-
this[cppdb].close();
|
|
236
|
-
return this;
|
|
237
|
-
};
|
|
238
|
-
exports.loadExtension = function loadExtension(...args) {
|
|
239
|
-
this[cppdb].loadExtension(...args);
|
|
240
|
-
return this;
|
|
241
|
-
};
|
|
242
|
-
exports.defaultSafeIntegers = function defaultSafeIntegers(...args) {
|
|
243
|
-
this[cppdb].defaultSafeIntegers(...args);
|
|
244
|
-
return this;
|
|
245
|
-
};
|
|
246
|
-
exports.unsafeMode = function unsafeMode(...args) {
|
|
247
|
-
this[cppdb].unsafeMode(...args);
|
|
248
|
-
return this;
|
|
249
|
-
};
|
|
250
|
-
exports.getters = {
|
|
251
|
-
name: {
|
|
252
|
-
get: function name() {
|
|
253
|
-
return this[cppdb].name;
|
|
254
|
-
},
|
|
255
|
-
enumerable: true
|
|
256
|
-
},
|
|
257
|
-
open: {
|
|
258
|
-
get: function open() {
|
|
259
|
-
return this[cppdb].open;
|
|
260
|
-
},
|
|
261
|
-
enumerable: true
|
|
262
|
-
},
|
|
263
|
-
inTransaction: {
|
|
264
|
-
get: function inTransaction() {
|
|
265
|
-
return this[cppdb].inTransaction;
|
|
266
|
-
},
|
|
267
|
-
enumerable: true
|
|
268
|
-
},
|
|
269
|
-
readonly: {
|
|
270
|
-
get: function readonly() {
|
|
271
|
-
return this[cppdb].readonly;
|
|
272
|
-
},
|
|
273
|
-
enumerable: true
|
|
274
|
-
},
|
|
275
|
-
memory: {
|
|
276
|
-
get: function memory() {
|
|
277
|
-
return this[cppdb].memory;
|
|
278
|
-
},
|
|
279
|
-
enumerable: true
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
// node_modules/better-sqlite3/lib/methods/transaction.js
|
|
285
|
-
var require_transaction = __commonJS((exports, module) => {
|
|
286
|
-
var { cppdb } = require_util();
|
|
287
|
-
var controllers = new WeakMap;
|
|
288
|
-
module.exports = function transaction(fn) {
|
|
289
|
-
if (typeof fn !== "function")
|
|
290
|
-
throw new TypeError("Expected first argument to be a function");
|
|
291
|
-
const db = this[cppdb];
|
|
292
|
-
const controller = getController(db, this);
|
|
293
|
-
const { apply } = Function.prototype;
|
|
294
|
-
const properties = {
|
|
295
|
-
default: { value: wrapTransaction(apply, fn, db, controller.default) },
|
|
296
|
-
deferred: { value: wrapTransaction(apply, fn, db, controller.deferred) },
|
|
297
|
-
immediate: { value: wrapTransaction(apply, fn, db, controller.immediate) },
|
|
298
|
-
exclusive: { value: wrapTransaction(apply, fn, db, controller.exclusive) },
|
|
299
|
-
database: { value: this, enumerable: true }
|
|
300
|
-
};
|
|
301
|
-
Object.defineProperties(properties.default.value, properties);
|
|
302
|
-
Object.defineProperties(properties.deferred.value, properties);
|
|
303
|
-
Object.defineProperties(properties.immediate.value, properties);
|
|
304
|
-
Object.defineProperties(properties.exclusive.value, properties);
|
|
305
|
-
return properties.default.value;
|
|
306
|
-
};
|
|
307
|
-
var getController = (db, self) => {
|
|
308
|
-
let controller = controllers.get(db);
|
|
309
|
-
if (!controller) {
|
|
310
|
-
const shared = {
|
|
311
|
-
commit: db.prepare("COMMIT", self, false),
|
|
312
|
-
rollback: db.prepare("ROLLBACK", self, false),
|
|
313
|
-
savepoint: db.prepare("SAVEPOINT `\t_bs3.\t`", self, false),
|
|
314
|
-
release: db.prepare("RELEASE `\t_bs3.\t`", self, false),
|
|
315
|
-
rollbackTo: db.prepare("ROLLBACK TO `\t_bs3.\t`", self, false)
|
|
316
|
-
};
|
|
317
|
-
controllers.set(db, controller = {
|
|
318
|
-
default: Object.assign({ begin: db.prepare("BEGIN", self, false) }, shared),
|
|
319
|
-
deferred: Object.assign({ begin: db.prepare("BEGIN DEFERRED", self, false) }, shared),
|
|
320
|
-
immediate: Object.assign({ begin: db.prepare("BEGIN IMMEDIATE", self, false) }, shared),
|
|
321
|
-
exclusive: Object.assign({ begin: db.prepare("BEGIN EXCLUSIVE", self, false) }, shared)
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
return controller;
|
|
325
|
-
};
|
|
326
|
-
var wrapTransaction = (apply, fn, db, { begin, commit, rollback, savepoint, release, rollbackTo }) => function sqliteTransaction() {
|
|
327
|
-
let before, after, undo;
|
|
328
|
-
if (db.inTransaction) {
|
|
329
|
-
before = savepoint;
|
|
330
|
-
after = release;
|
|
331
|
-
undo = rollbackTo;
|
|
332
|
-
} else {
|
|
333
|
-
before = begin;
|
|
334
|
-
after = commit;
|
|
335
|
-
undo = rollback;
|
|
336
|
-
}
|
|
337
|
-
before.run();
|
|
338
|
-
try {
|
|
339
|
-
const result = apply.call(fn, this, arguments);
|
|
340
|
-
if (result && typeof result.then === "function") {
|
|
341
|
-
throw new TypeError("Transaction function cannot return a promise");
|
|
342
|
-
}
|
|
343
|
-
after.run();
|
|
344
|
-
return result;
|
|
345
|
-
} catch (ex) {
|
|
346
|
-
if (db.inTransaction) {
|
|
347
|
-
undo.run();
|
|
348
|
-
if (undo !== rollback)
|
|
349
|
-
after.run();
|
|
350
|
-
}
|
|
351
|
-
throw ex;
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
// node_modules/better-sqlite3/lib/methods/pragma.js
|
|
357
|
-
var require_pragma = __commonJS((exports, module) => {
|
|
358
|
-
var { getBooleanOption, cppdb } = require_util();
|
|
359
|
-
module.exports = function pragma(source, options) {
|
|
360
|
-
if (options == null)
|
|
361
|
-
options = {};
|
|
362
|
-
if (typeof source !== "string")
|
|
363
|
-
throw new TypeError("Expected first argument to be a string");
|
|
364
|
-
if (typeof options !== "object")
|
|
365
|
-
throw new TypeError("Expected second argument to be an options object");
|
|
366
|
-
const simple = getBooleanOption(options, "simple");
|
|
367
|
-
const stmt = this[cppdb].prepare(`PRAGMA ${source}`, this, true);
|
|
368
|
-
return simple ? stmt.pluck().get() : stmt.all();
|
|
369
|
-
};
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
// node_modules/better-sqlite3/lib/methods/backup.js
|
|
373
|
-
var require_backup = __commonJS((exports, module) => {
|
|
374
|
-
var fs = __require("fs");
|
|
375
|
-
var path = __require("path");
|
|
376
|
-
var { promisify } = __require("util");
|
|
377
|
-
var { cppdb } = require_util();
|
|
378
|
-
var fsAccess = promisify(fs.access);
|
|
379
|
-
module.exports = async function backup(filename, options) {
|
|
380
|
-
if (options == null)
|
|
381
|
-
options = {};
|
|
382
|
-
if (typeof filename !== "string")
|
|
383
|
-
throw new TypeError("Expected first argument to be a string");
|
|
384
|
-
if (typeof options !== "object")
|
|
385
|
-
throw new TypeError("Expected second argument to be an options object");
|
|
386
|
-
filename = filename.trim();
|
|
387
|
-
const attachedName = "attached" in options ? options.attached : "main";
|
|
388
|
-
const handler = "progress" in options ? options.progress : null;
|
|
389
|
-
if (!filename)
|
|
390
|
-
throw new TypeError("Backup filename cannot be an empty string");
|
|
391
|
-
if (filename === ":memory:")
|
|
392
|
-
throw new TypeError('Invalid backup filename ":memory:"');
|
|
393
|
-
if (typeof attachedName !== "string")
|
|
394
|
-
throw new TypeError('Expected the "attached" option to be a string');
|
|
395
|
-
if (!attachedName)
|
|
396
|
-
throw new TypeError('The "attached" option cannot be an empty string');
|
|
397
|
-
if (handler != null && typeof handler !== "function")
|
|
398
|
-
throw new TypeError('Expected the "progress" option to be a function');
|
|
399
|
-
await fsAccess(path.dirname(filename)).catch(() => {
|
|
400
|
-
throw new TypeError("Cannot save backup because the directory does not exist");
|
|
401
|
-
});
|
|
402
|
-
const isNewFile = await fsAccess(filename).then(() => false, () => true);
|
|
403
|
-
return runBackup(this[cppdb].backup(this, attachedName, filename, isNewFile), handler || null);
|
|
404
|
-
};
|
|
405
|
-
var runBackup = (backup, handler) => {
|
|
406
|
-
let rate = 0;
|
|
407
|
-
let useDefault = true;
|
|
408
|
-
return new Promise((resolve, reject) => {
|
|
409
|
-
setImmediate(function step() {
|
|
410
|
-
try {
|
|
411
|
-
const progress = backup.transfer(rate);
|
|
412
|
-
if (!progress.remainingPages) {
|
|
413
|
-
backup.close();
|
|
414
|
-
resolve(progress);
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
if (useDefault) {
|
|
418
|
-
useDefault = false;
|
|
419
|
-
rate = 100;
|
|
420
|
-
}
|
|
421
|
-
if (handler) {
|
|
422
|
-
const ret = handler(progress);
|
|
423
|
-
if (ret !== undefined) {
|
|
424
|
-
if (typeof ret === "number" && ret === ret)
|
|
425
|
-
rate = Math.max(0, Math.min(2147483647, Math.round(ret)));
|
|
426
|
-
else
|
|
427
|
-
throw new TypeError("Expected progress callback to return a number or undefined");
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
setImmediate(step);
|
|
431
|
-
} catch (err) {
|
|
432
|
-
backup.close();
|
|
433
|
-
reject(err);
|
|
434
|
-
}
|
|
435
|
-
});
|
|
436
|
-
});
|
|
437
|
-
};
|
|
438
|
-
});
|
|
439
|
-
|
|
440
|
-
// node_modules/better-sqlite3/lib/methods/serialize.js
|
|
441
|
-
var require_serialize = __commonJS((exports, module) => {
|
|
442
|
-
var { cppdb } = require_util();
|
|
443
|
-
module.exports = function serialize(options) {
|
|
444
|
-
if (options == null)
|
|
445
|
-
options = {};
|
|
446
|
-
if (typeof options !== "object")
|
|
447
|
-
throw new TypeError("Expected first argument to be an options object");
|
|
448
|
-
const attachedName = "attached" in options ? options.attached : "main";
|
|
449
|
-
if (typeof attachedName !== "string")
|
|
450
|
-
throw new TypeError('Expected the "attached" option to be a string');
|
|
451
|
-
if (!attachedName)
|
|
452
|
-
throw new TypeError('The "attached" option cannot be an empty string');
|
|
453
|
-
return this[cppdb].serialize(attachedName);
|
|
454
|
-
};
|
|
455
|
-
});
|
|
456
|
-
|
|
457
|
-
// node_modules/better-sqlite3/lib/methods/function.js
|
|
458
|
-
var require_function = __commonJS((exports, module) => {
|
|
459
|
-
var { getBooleanOption, cppdb } = require_util();
|
|
460
|
-
module.exports = function defineFunction(name, options, fn) {
|
|
461
|
-
if (options == null)
|
|
462
|
-
options = {};
|
|
463
|
-
if (typeof options === "function") {
|
|
464
|
-
fn = options;
|
|
465
|
-
options = {};
|
|
466
|
-
}
|
|
467
|
-
if (typeof name !== "string")
|
|
468
|
-
throw new TypeError("Expected first argument to be a string");
|
|
469
|
-
if (typeof fn !== "function")
|
|
470
|
-
throw new TypeError("Expected last argument to be a function");
|
|
471
|
-
if (typeof options !== "object")
|
|
472
|
-
throw new TypeError("Expected second argument to be an options object");
|
|
473
|
-
if (!name)
|
|
474
|
-
throw new TypeError("User-defined function name cannot be an empty string");
|
|
475
|
-
const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
|
|
476
|
-
const deterministic = getBooleanOption(options, "deterministic");
|
|
477
|
-
const directOnly = getBooleanOption(options, "directOnly");
|
|
478
|
-
const varargs = getBooleanOption(options, "varargs");
|
|
479
|
-
let argCount = -1;
|
|
480
|
-
if (!varargs) {
|
|
481
|
-
argCount = fn.length;
|
|
482
|
-
if (!Number.isInteger(argCount) || argCount < 0)
|
|
483
|
-
throw new TypeError("Expected function.length to be a positive integer");
|
|
484
|
-
if (argCount > 100)
|
|
485
|
-
throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
486
|
-
}
|
|
487
|
-
this[cppdb].function(fn, name, argCount, safeIntegers, deterministic, directOnly);
|
|
488
|
-
return this;
|
|
489
|
-
};
|
|
490
|
-
});
|
|
491
|
-
|
|
492
|
-
// node_modules/better-sqlite3/lib/methods/aggregate.js
|
|
493
|
-
var require_aggregate = __commonJS((exports, module) => {
|
|
494
|
-
var { getBooleanOption, cppdb } = require_util();
|
|
495
|
-
module.exports = function defineAggregate(name, options) {
|
|
496
|
-
if (typeof name !== "string")
|
|
497
|
-
throw new TypeError("Expected first argument to be a string");
|
|
498
|
-
if (typeof options !== "object" || options === null)
|
|
499
|
-
throw new TypeError("Expected second argument to be an options object");
|
|
500
|
-
if (!name)
|
|
501
|
-
throw new TypeError("User-defined function name cannot be an empty string");
|
|
502
|
-
const start = "start" in options ? options.start : null;
|
|
503
|
-
const step = getFunctionOption(options, "step", true);
|
|
504
|
-
const inverse = getFunctionOption(options, "inverse", false);
|
|
505
|
-
const result = getFunctionOption(options, "result", false);
|
|
506
|
-
const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
|
|
507
|
-
const deterministic = getBooleanOption(options, "deterministic");
|
|
508
|
-
const directOnly = getBooleanOption(options, "directOnly");
|
|
509
|
-
const varargs = getBooleanOption(options, "varargs");
|
|
510
|
-
let argCount = -1;
|
|
511
|
-
if (!varargs) {
|
|
512
|
-
argCount = Math.max(getLength(step), inverse ? getLength(inverse) : 0);
|
|
513
|
-
if (argCount > 0)
|
|
514
|
-
argCount -= 1;
|
|
515
|
-
if (argCount > 100)
|
|
516
|
-
throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
517
|
-
}
|
|
518
|
-
this[cppdb].aggregate(start, step, inverse, result, name, argCount, safeIntegers, deterministic, directOnly);
|
|
519
|
-
return this;
|
|
520
|
-
};
|
|
521
|
-
var getFunctionOption = (options, key, required) => {
|
|
522
|
-
const value = key in options ? options[key] : null;
|
|
523
|
-
if (typeof value === "function")
|
|
524
|
-
return value;
|
|
525
|
-
if (value != null)
|
|
526
|
-
throw new TypeError(`Expected the "${key}" option to be a function`);
|
|
527
|
-
if (required)
|
|
528
|
-
throw new TypeError(`Missing required option "${key}"`);
|
|
529
|
-
return null;
|
|
530
|
-
};
|
|
531
|
-
var getLength = ({ length }) => {
|
|
532
|
-
if (Number.isInteger(length) && length >= 0)
|
|
533
|
-
return length;
|
|
534
|
-
throw new TypeError("Expected function.length to be a positive integer");
|
|
535
|
-
};
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
// node_modules/better-sqlite3/lib/methods/table.js
|
|
539
|
-
var require_table = __commonJS((exports, module) => {
|
|
540
|
-
var { cppdb } = require_util();
|
|
541
|
-
module.exports = function defineTable(name, factory) {
|
|
542
|
-
if (typeof name !== "string")
|
|
543
|
-
throw new TypeError("Expected first argument to be a string");
|
|
544
|
-
if (!name)
|
|
545
|
-
throw new TypeError("Virtual table module name cannot be an empty string");
|
|
546
|
-
let eponymous = false;
|
|
547
|
-
if (typeof factory === "object" && factory !== null) {
|
|
548
|
-
eponymous = true;
|
|
549
|
-
factory = defer(parseTableDefinition(factory, "used", name));
|
|
550
|
-
} else {
|
|
551
|
-
if (typeof factory !== "function")
|
|
552
|
-
throw new TypeError("Expected second argument to be a function or a table definition object");
|
|
553
|
-
factory = wrapFactory(factory);
|
|
554
|
-
}
|
|
555
|
-
this[cppdb].table(factory, name, eponymous);
|
|
556
|
-
return this;
|
|
557
|
-
};
|
|
558
|
-
function wrapFactory(factory) {
|
|
559
|
-
return function virtualTableFactory(moduleName, databaseName, tableName, ...args) {
|
|
560
|
-
const thisObject = {
|
|
561
|
-
module: moduleName,
|
|
562
|
-
database: databaseName,
|
|
563
|
-
table: tableName
|
|
564
|
-
};
|
|
565
|
-
const def = apply.call(factory, thisObject, args);
|
|
566
|
-
if (typeof def !== "object" || def === null) {
|
|
567
|
-
throw new TypeError(`Virtual table module "${moduleName}" did not return a table definition object`);
|
|
568
|
-
}
|
|
569
|
-
return parseTableDefinition(def, "returned", moduleName);
|
|
570
|
-
};
|
|
571
|
-
}
|
|
572
|
-
function parseTableDefinition(def, verb, moduleName) {
|
|
573
|
-
if (!hasOwnProperty.call(def, "rows")) {
|
|
574
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "rows" property`);
|
|
575
|
-
}
|
|
576
|
-
if (!hasOwnProperty.call(def, "columns")) {
|
|
577
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "columns" property`);
|
|
578
|
-
}
|
|
579
|
-
const rows = def.rows;
|
|
580
|
-
if (typeof rows !== "function" || Object.getPrototypeOf(rows) !== GeneratorFunctionPrototype) {
|
|
581
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "rows" property (should be a generator function)`);
|
|
582
|
-
}
|
|
583
|
-
let columns = def.columns;
|
|
584
|
-
if (!Array.isArray(columns) || !(columns = [...columns]).every((x) => typeof x === "string")) {
|
|
585
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "columns" property (should be an array of strings)`);
|
|
586
|
-
}
|
|
587
|
-
if (columns.length !== new Set(columns).size) {
|
|
588
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate column names`);
|
|
589
|
-
}
|
|
590
|
-
if (!columns.length) {
|
|
591
|
-
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with zero columns`);
|
|
592
|
-
}
|
|
593
|
-
let parameters;
|
|
594
|
-
if (hasOwnProperty.call(def, "parameters")) {
|
|
595
|
-
parameters = def.parameters;
|
|
596
|
-
if (!Array.isArray(parameters) || !(parameters = [...parameters]).every((x) => typeof x === "string")) {
|
|
597
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "parameters" property (should be an array of strings)`);
|
|
598
|
-
}
|
|
599
|
-
} else {
|
|
600
|
-
parameters = inferParameters(rows);
|
|
601
|
-
}
|
|
602
|
-
if (parameters.length !== new Set(parameters).size) {
|
|
603
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate parameter names`);
|
|
604
|
-
}
|
|
605
|
-
if (parameters.length > 32) {
|
|
606
|
-
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with more than the maximum number of 32 parameters`);
|
|
607
|
-
}
|
|
608
|
-
for (const parameter of parameters) {
|
|
609
|
-
if (columns.includes(parameter)) {
|
|
610
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with column "${parameter}" which was ambiguously defined as both a column and parameter`);
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
let safeIntegers = 2;
|
|
614
|
-
if (hasOwnProperty.call(def, "safeIntegers")) {
|
|
615
|
-
const bool = def.safeIntegers;
|
|
616
|
-
if (typeof bool !== "boolean") {
|
|
617
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "safeIntegers" property (should be a boolean)`);
|
|
618
|
-
}
|
|
619
|
-
safeIntegers = +bool;
|
|
620
|
-
}
|
|
621
|
-
let directOnly = false;
|
|
622
|
-
if (hasOwnProperty.call(def, "directOnly")) {
|
|
623
|
-
directOnly = def.directOnly;
|
|
624
|
-
if (typeof directOnly !== "boolean") {
|
|
625
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "directOnly" property (should be a boolean)`);
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
const columnDefinitions = [
|
|
629
|
-
...parameters.map(identifier).map((str) => `${str} HIDDEN`),
|
|
630
|
-
...columns.map(identifier)
|
|
631
|
-
];
|
|
632
|
-
return [
|
|
633
|
-
`CREATE TABLE x(${columnDefinitions.join(", ")});`,
|
|
634
|
-
wrapGenerator(rows, new Map(columns.map((x, i) => [x, parameters.length + i])), moduleName),
|
|
635
|
-
parameters,
|
|
636
|
-
safeIntegers,
|
|
637
|
-
directOnly
|
|
638
|
-
];
|
|
639
|
-
}
|
|
640
|
-
function wrapGenerator(generator, columnMap, moduleName) {
|
|
641
|
-
return function* virtualTable(...args) {
|
|
642
|
-
const output = args.map((x) => Buffer.isBuffer(x) ? Buffer.from(x) : x);
|
|
643
|
-
for (let i = 0;i < columnMap.size; ++i) {
|
|
644
|
-
output.push(null);
|
|
645
|
-
}
|
|
646
|
-
for (const row of generator(...args)) {
|
|
647
|
-
if (Array.isArray(row)) {
|
|
648
|
-
extractRowArray(row, output, columnMap.size, moduleName);
|
|
649
|
-
yield output;
|
|
650
|
-
} else if (typeof row === "object" && row !== null) {
|
|
651
|
-
extractRowObject(row, output, columnMap, moduleName);
|
|
652
|
-
yield output;
|
|
653
|
-
} else {
|
|
654
|
-
throw new TypeError(`Virtual table module "${moduleName}" yielded something that isn't a valid row object`);
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
};
|
|
658
|
-
}
|
|
659
|
-
function extractRowArray(row, output, columnCount, moduleName) {
|
|
660
|
-
if (row.length !== columnCount) {
|
|
661
|
-
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an incorrect number of columns`);
|
|
662
|
-
}
|
|
663
|
-
const offset = output.length - columnCount;
|
|
664
|
-
for (let i = 0;i < columnCount; ++i) {
|
|
665
|
-
output[i + offset] = row[i];
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
function extractRowObject(row, output, columnMap, moduleName) {
|
|
669
|
-
let count = 0;
|
|
670
|
-
for (const key of Object.keys(row)) {
|
|
671
|
-
const index = columnMap.get(key);
|
|
672
|
-
if (index === undefined) {
|
|
673
|
-
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an undeclared column "${key}"`);
|
|
674
|
-
}
|
|
675
|
-
output[index] = row[key];
|
|
676
|
-
count += 1;
|
|
677
|
-
}
|
|
678
|
-
if (count !== columnMap.size) {
|
|
679
|
-
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with missing columns`);
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
function inferParameters({ length }) {
|
|
683
|
-
if (!Number.isInteger(length) || length < 0) {
|
|
684
|
-
throw new TypeError("Expected function.length to be a positive integer");
|
|
685
|
-
}
|
|
686
|
-
const params = [];
|
|
687
|
-
for (let i = 0;i < length; ++i) {
|
|
688
|
-
params.push(`$${i + 1}`);
|
|
689
|
-
}
|
|
690
|
-
return params;
|
|
691
|
-
}
|
|
692
|
-
var { hasOwnProperty } = Object.prototype;
|
|
693
|
-
var { apply } = Function.prototype;
|
|
694
|
-
var GeneratorFunctionPrototype = Object.getPrototypeOf(function* () {});
|
|
695
|
-
var identifier = (str) => `"${str.replace(/"/g, '""')}"`;
|
|
696
|
-
var defer = (x) => () => x;
|
|
697
|
-
});
|
|
698
|
-
|
|
699
|
-
// node_modules/better-sqlite3/lib/methods/inspect.js
|
|
700
|
-
var require_inspect = __commonJS((exports, module) => {
|
|
701
|
-
var DatabaseInspection = function Database() {};
|
|
702
|
-
module.exports = function inspect(depth, opts) {
|
|
703
|
-
return Object.assign(new DatabaseInspection, this);
|
|
704
|
-
};
|
|
705
|
-
});
|
|
706
|
-
|
|
707
|
-
// node_modules/better-sqlite3/lib/database.js
|
|
708
|
-
var require_database = __commonJS((exports, module) => {
|
|
709
|
-
var fs = __require("fs");
|
|
710
|
-
var path = __require("path");
|
|
711
|
-
var util = require_util();
|
|
712
|
-
var SqliteError = require_sqlite_error();
|
|
713
|
-
var DEFAULT_ADDON;
|
|
714
|
-
function Database(filenameGiven, options) {
|
|
715
|
-
if (new.target == null) {
|
|
716
|
-
return new Database(filenameGiven, options);
|
|
717
|
-
}
|
|
718
|
-
let buffer;
|
|
719
|
-
if (Buffer.isBuffer(filenameGiven)) {
|
|
720
|
-
buffer = filenameGiven;
|
|
721
|
-
filenameGiven = ":memory:";
|
|
722
|
-
}
|
|
723
|
-
if (filenameGiven == null)
|
|
724
|
-
filenameGiven = "";
|
|
725
|
-
if (options == null)
|
|
726
|
-
options = {};
|
|
727
|
-
if (typeof filenameGiven !== "string")
|
|
728
|
-
throw new TypeError("Expected first argument to be a string");
|
|
729
|
-
if (typeof options !== "object")
|
|
730
|
-
throw new TypeError("Expected second argument to be an options object");
|
|
731
|
-
if ("readOnly" in options)
|
|
732
|
-
throw new TypeError('Misspelled option "readOnly" should be "readonly"');
|
|
733
|
-
if ("memory" in options)
|
|
734
|
-
throw new TypeError('Option "memory" was removed in v7.0.0 (use ":memory:" filename instead)');
|
|
735
|
-
const filename = filenameGiven.trim();
|
|
736
|
-
const anonymous = filename === "" || filename === ":memory:";
|
|
737
|
-
const readonly = util.getBooleanOption(options, "readonly");
|
|
738
|
-
const fileMustExist = util.getBooleanOption(options, "fileMustExist");
|
|
739
|
-
const timeout = "timeout" in options ? options.timeout : 5000;
|
|
740
|
-
const verbose = "verbose" in options ? options.verbose : null;
|
|
741
|
-
const nativeBinding = "nativeBinding" in options ? options.nativeBinding : null;
|
|
742
|
-
if (readonly && anonymous && !buffer)
|
|
743
|
-
throw new TypeError("In-memory/temporary databases cannot be readonly");
|
|
744
|
-
if (!Number.isInteger(timeout) || timeout < 0)
|
|
745
|
-
throw new TypeError('Expected the "timeout" option to be a positive integer');
|
|
746
|
-
if (timeout > 2147483647)
|
|
747
|
-
throw new RangeError('Option "timeout" cannot be greater than 2147483647');
|
|
748
|
-
if (verbose != null && typeof verbose !== "function")
|
|
749
|
-
throw new TypeError('Expected the "verbose" option to be a function');
|
|
750
|
-
if (nativeBinding != null && typeof nativeBinding !== "string" && typeof nativeBinding !== "object")
|
|
751
|
-
throw new TypeError('Expected the "nativeBinding" option to be a string or addon object');
|
|
752
|
-
let addon;
|
|
753
|
-
if (nativeBinding == null) {
|
|
754
|
-
addon = DEFAULT_ADDON || (DEFAULT_ADDON = require_bindings()("better_sqlite3.node"));
|
|
755
|
-
} else if (typeof nativeBinding === "string") {
|
|
756
|
-
const requireFunc = typeof __non_webpack_require__ === "function" ? __non_webpack_require__ : __require;
|
|
757
|
-
addon = requireFunc(path.resolve(nativeBinding).replace(/(\.node)?$/, ".node"));
|
|
758
|
-
} else {
|
|
759
|
-
addon = nativeBinding;
|
|
760
|
-
}
|
|
761
|
-
if (!addon.isInitialized) {
|
|
762
|
-
addon.setErrorConstructor(SqliteError);
|
|
763
|
-
addon.isInitialized = true;
|
|
764
|
-
}
|
|
765
|
-
if (!anonymous && !fs.existsSync(path.dirname(filename))) {
|
|
766
|
-
throw new TypeError("Cannot open database because the directory does not exist");
|
|
767
|
-
}
|
|
768
|
-
Object.defineProperties(this, {
|
|
769
|
-
[util.cppdb]: { value: new addon.Database(filename, filenameGiven, anonymous, readonly, fileMustExist, timeout, verbose || null, buffer || null) },
|
|
770
|
-
...wrappers.getters
|
|
771
|
-
});
|
|
772
|
-
}
|
|
773
|
-
var wrappers = require_wrappers();
|
|
774
|
-
Database.prototype.prepare = wrappers.prepare;
|
|
775
|
-
Database.prototype.transaction = require_transaction();
|
|
776
|
-
Database.prototype.pragma = require_pragma();
|
|
777
|
-
Database.prototype.backup = require_backup();
|
|
778
|
-
Database.prototype.serialize = require_serialize();
|
|
779
|
-
Database.prototype.function = require_function();
|
|
780
|
-
Database.prototype.aggregate = require_aggregate();
|
|
781
|
-
Database.prototype.table = require_table();
|
|
782
|
-
Database.prototype.loadExtension = wrappers.loadExtension;
|
|
783
|
-
Database.prototype.exec = wrappers.exec;
|
|
784
|
-
Database.prototype.close = wrappers.close;
|
|
785
|
-
Database.prototype.defaultSafeIntegers = wrappers.defaultSafeIntegers;
|
|
786
|
-
Database.prototype.unsafeMode = wrappers.unsafeMode;
|
|
787
|
-
Database.prototype[util.inspect] = require_inspect();
|
|
788
|
-
module.exports = Database;
|
|
789
|
-
});
|
|
790
|
-
|
|
791
|
-
// node_modules/better-sqlite3/lib/index.js
|
|
792
|
-
var require_lib = __commonJS((exports, module) => {
|
|
793
|
-
module.exports = require_database();
|
|
794
|
-
module.exports.SqliteError = require_sqlite_error();
|
|
795
|
-
});
|
|
796
13
|
|
|
797
14
|
// src/db.ts
|
|
798
15
|
var exports_db = {};
|
|
@@ -817,6 +34,7 @@ __export(exports_db, {
|
|
|
817
34
|
DB_PATH: () => DB_PATH,
|
|
818
35
|
CORTEX_DIR: () => CORTEX_DIR
|
|
819
36
|
});
|
|
37
|
+
import Database from "better-sqlite3";
|
|
820
38
|
import { existsSync, mkdirSync } from "fs";
|
|
821
39
|
import { homedir } from "os";
|
|
822
40
|
import { join } from "path";
|
|
@@ -827,7 +45,7 @@ function getDb() {
|
|
|
827
45
|
mkdirSync(CORTEX_DIR, { recursive: true });
|
|
828
46
|
if (!existsSync(MODELS_DIR))
|
|
829
47
|
mkdirSync(MODELS_DIR, { recursive: true });
|
|
830
|
-
_db = new
|
|
48
|
+
_db = new Database(DB_PATH);
|
|
831
49
|
_db.pragma("journal_mode = WAL");
|
|
832
50
|
_db.pragma("synchronous = NORMAL");
|
|
833
51
|
_db.pragma("foreign_keys = ON");
|
|
@@ -1087,9 +305,8 @@ function decayAndPrune(db, projectId) {
|
|
|
1087
305
|
`).run(projectId).changes;
|
|
1088
306
|
return { decayed, pruned };
|
|
1089
307
|
}
|
|
1090
|
-
var
|
|
308
|
+
var CORTEX_DIR, DB_PATH, REGISTRY_PATH, MODELS_DIR, _db = null;
|
|
1091
309
|
var init_db = __esm(() => {
|
|
1092
|
-
import_better_sqlite3 = __toESM(require_lib(), 1);
|
|
1093
310
|
CORTEX_DIR = join(homedir(), ".apsolut");
|
|
1094
311
|
DB_PATH = join(CORTEX_DIR, "memory.db");
|
|
1095
312
|
REGISTRY_PATH = join(CORTEX_DIR, "registry.json");
|
|
@@ -1099,17 +316,18 @@ var init_db = __esm(() => {
|
|
|
1099
316
|
// src/cli.ts
|
|
1100
317
|
import {
|
|
1101
318
|
existsSync as existsSync3,
|
|
1102
|
-
mkdirSync as
|
|
319
|
+
mkdirSync as mkdirSync3,
|
|
1103
320
|
readFileSync as readFileSync2,
|
|
1104
321
|
writeFileSync as writeFileSync2
|
|
1105
322
|
} from "fs";
|
|
1106
|
-
import { join as join2, resolve, dirname } from "path";
|
|
323
|
+
import { join as join2, resolve, dirname as dirname2 } from "path";
|
|
1107
324
|
import { homedir as homedir2 } from "os";
|
|
1108
325
|
import { fileURLToPath } from "url";
|
|
1109
326
|
|
|
1110
327
|
// src/registry.ts
|
|
1111
328
|
init_db();
|
|
1112
|
-
import { existsSync as existsSync2, readFileSync, writeFileSync } from "fs";
|
|
329
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync, writeFileSync } from "fs";
|
|
330
|
+
import { dirname } from "path";
|
|
1113
331
|
function readRegistry() {
|
|
1114
332
|
if (!existsSync2(REGISTRY_PATH))
|
|
1115
333
|
return { projects: {} };
|
|
@@ -1120,6 +338,9 @@ function readRegistry() {
|
|
|
1120
338
|
}
|
|
1121
339
|
}
|
|
1122
340
|
function writeRegistry(reg) {
|
|
341
|
+
const dir = dirname(REGISTRY_PATH);
|
|
342
|
+
if (!existsSync2(dir))
|
|
343
|
+
mkdirSync2(dir, { recursive: true });
|
|
1123
344
|
writeFileSync(REGISTRY_PATH, JSON.stringify(reg, null, 2));
|
|
1124
345
|
}
|
|
1125
346
|
function registerProject(id, name, path) {
|
|
@@ -1130,9 +351,10 @@ function registerProject(id, name, path) {
|
|
|
1130
351
|
|
|
1131
352
|
// src/cli.ts
|
|
1132
353
|
var __filename2 = fileURLToPath(import.meta.url);
|
|
1133
|
-
var __dirname2 =
|
|
354
|
+
var __dirname2 = dirname2(__filename2);
|
|
1134
355
|
var PACKAGE_ROOT = resolve(__dirname2, "..");
|
|
1135
356
|
var IS_DIST = __dirname2.endsWith("dist") || __dirname2.includes(`${process.sep}dist${process.sep}`);
|
|
357
|
+
var PKG_VERSION = JSON.parse(readFileSync2(join2(PACKAGE_ROOT, "package.json"), "utf-8")).version;
|
|
1136
358
|
var PROJECT_ROOT = process.cwd();
|
|
1137
359
|
var CLAUDE_SETTINGS = join2(homedir2(), ".claude", "settings.json");
|
|
1138
360
|
var MCP_JSON = join2(PROJECT_ROOT, ".mcp.json");
|
|
@@ -1163,7 +385,7 @@ switch (cmd) {
|
|
|
1163
385
|
break;
|
|
1164
386
|
default:
|
|
1165
387
|
console.log(`
|
|
1166
|
-
apsolut-cortex
|
|
388
|
+
apsolut-cortex v${PKG_VERSION}
|
|
1167
389
|
|
|
1168
390
|
Commands:
|
|
1169
391
|
init Set up memory for this Claude Code project
|
|
@@ -1188,7 +410,7 @@ async function init() {
|
|
|
1188
410
|
apsolut-cortex init
|
|
1189
411
|
`);
|
|
1190
412
|
if (!existsSync3(PROJECT_APSOLUT)) {
|
|
1191
|
-
|
|
413
|
+
mkdirSync3(PROJECT_APSOLUT, { recursive: true });
|
|
1192
414
|
}
|
|
1193
415
|
let projectId;
|
|
1194
416
|
let projectName;
|
|
@@ -1237,9 +459,9 @@ apsolut-cortex init
|
|
|
1237
459
|
SessionEnd: [{ command: `${hookCmd} hook:session-end` }]
|
|
1238
460
|
};
|
|
1239
461
|
let settings = {};
|
|
1240
|
-
const settingsDir =
|
|
462
|
+
const settingsDir = dirname2(CLAUDE_SETTINGS);
|
|
1241
463
|
if (!existsSync3(settingsDir))
|
|
1242
|
-
|
|
464
|
+
mkdirSync3(settingsDir, { recursive: true });
|
|
1243
465
|
if (existsSync3(CLAUDE_SETTINGS)) {
|
|
1244
466
|
try {
|
|
1245
467
|
settings = JSON.parse(readFileSync2(CLAUDE_SETTINGS, "utf-8"));
|