@memrosetta/cli 0.5.1 → 0.5.3
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/dist/chunk-47SU2YUJ.js +64 -0
- package/dist/chunk-C4ANKSCI.js +151 -0
- package/dist/chunk-CEHRM6IW.js +151 -0
- package/dist/chunk-G2W4YK2T.js +56 -0
- package/dist/chunk-GGXC7TAJ.js +139 -0
- package/dist/chunk-GRNZVSAF.js +56 -0
- package/dist/chunk-GZINXXM4.js +139 -0
- package/dist/chunk-RZFCVYTK.js +71 -0
- package/dist/chunk-US6CEDMU.js +66 -0
- package/dist/chunk-VMGX5FCY.js +64 -0
- package/dist/chunk-WYHEAKPC.js +71 -0
- package/dist/clear-32Y3U2WR.js +39 -0
- package/dist/clear-AFEJPCDA.js +39 -0
- package/dist/compress-CL5D4VVJ.js +33 -0
- package/dist/compress-UUEO7WCU.js +33 -0
- package/dist/count-U2ML5ZON.js +24 -0
- package/dist/count-VVOGYSM7.js +24 -0
- package/dist/duplicates-CEJ7WSGW.js +149 -0
- package/dist/duplicates-IBUS7CJS.js +149 -0
- package/dist/enforce-T7AS4PVD.js +381 -0
- package/dist/enforce-TC5SDPEZ.js +381 -0
- package/dist/feedback-3PJTTEOD.js +51 -0
- package/dist/feedback-IB7BHIRP.js +51 -0
- package/dist/get-TQ2U7HCD.js +30 -0
- package/dist/get-WPZIHQKW.js +30 -0
- package/dist/hooks/on-prompt.js +3 -3
- package/dist/hooks/on-stop.js +3 -3
- package/dist/index.js +30 -20
- package/dist/ingest-37UXPVT5.js +97 -0
- package/dist/ingest-TPQRH34A.js +97 -0
- package/dist/init-6YQL3RCQ.js +210 -0
- package/dist/init-LHXRCCLX.js +210 -0
- package/dist/invalidate-ER2TFFWK.js +40 -0
- package/dist/invalidate-PVHUGAJ6.js +40 -0
- package/dist/maintain-NICAXFK6.js +37 -0
- package/dist/maintain-Q553GBSF.js +37 -0
- package/dist/migrate-CZL3YNQK.js +255 -0
- package/dist/migrate-FI26FSBP.js +255 -0
- package/dist/relate-5TN2WEG3.js +57 -0
- package/dist/relate-KLBMYWB3.js +57 -0
- package/dist/reset-IPOAKTJM.js +132 -0
- package/dist/search-AYZBKRXF.js +48 -0
- package/dist/search-JQ3MLRKS.js +48 -0
- package/dist/status-JF2V7ZBX.js +184 -0
- package/dist/status-UV66PWUD.js +184 -0
- package/dist/store-AAJCT3PX.js +101 -0
- package/dist/store-OVDS57U5.js +101 -0
- package/dist/sync-56KJTKE7.js +542 -0
- package/dist/sync-BCKBYRXY.js +542 -0
- package/dist/working-memory-CJARSGEK.js +53 -0
- package/dist/working-memory-Z3RUGSTQ.js +53 -0
- package/package.json +4 -4
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getConfig,
|
|
3
|
+
resolveCanonicalUserId
|
|
4
|
+
} from "./chunk-RZFCVYTK.js";
|
|
5
|
+
|
|
6
|
+
// src/sync/cli-sync.ts
|
|
7
|
+
import { createHash, randomUUID } from "crypto";
|
|
8
|
+
function deterministicOpId(kind, key) {
|
|
9
|
+
const hash = createHash("sha256").update(`${kind}:${key}`).digest("hex");
|
|
10
|
+
return `op-${hash.slice(0, 16)}`;
|
|
11
|
+
}
|
|
12
|
+
var DISABLED = {
|
|
13
|
+
enabled: false,
|
|
14
|
+
userId: "",
|
|
15
|
+
deviceId: "",
|
|
16
|
+
enqueue() {
|
|
17
|
+
},
|
|
18
|
+
close() {
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
async function openCliSyncContext(dbPath) {
|
|
22
|
+
const config = getConfig();
|
|
23
|
+
if (!config.syncEnabled || !config.syncServerUrl || !config.syncApiKey || !config.syncDeviceId) {
|
|
24
|
+
return DISABLED;
|
|
25
|
+
}
|
|
26
|
+
const userId = resolveCanonicalUserId();
|
|
27
|
+
const deviceId = config.syncDeviceId;
|
|
28
|
+
try {
|
|
29
|
+
const { default: Database } = await import("better-sqlite3");
|
|
30
|
+
const { SyncClient, ensureSyncSchema } = await import("@memrosetta/sync-client");
|
|
31
|
+
const db = new Database(dbPath);
|
|
32
|
+
ensureSyncSchema(db);
|
|
33
|
+
const client = new SyncClient(db, {
|
|
34
|
+
serverUrl: config.syncServerUrl,
|
|
35
|
+
apiKey: config.syncApiKey,
|
|
36
|
+
deviceId,
|
|
37
|
+
userId
|
|
38
|
+
});
|
|
39
|
+
const outbox = client.getOutbox();
|
|
40
|
+
return {
|
|
41
|
+
enabled: true,
|
|
42
|
+
userId,
|
|
43
|
+
deviceId,
|
|
44
|
+
enqueue(op) {
|
|
45
|
+
try {
|
|
46
|
+
outbox.addOp(op);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
process.stderr.write(
|
|
49
|
+
`[sync] enqueue failed: ${err instanceof Error ? err.message : String(err)}
|
|
50
|
+
`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
close() {
|
|
55
|
+
try {
|
|
56
|
+
db.close();
|
|
57
|
+
} catch {
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
} catch (err) {
|
|
62
|
+
process.stderr.write(
|
|
63
|
+
`[sync] disabled for this command: ${err instanceof Error ? err.message : String(err)}
|
|
64
|
+
`
|
|
65
|
+
);
|
|
66
|
+
return DISABLED;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function buildMemoryCreatedOp(ctx, memory) {
|
|
70
|
+
return {
|
|
71
|
+
opId: randomUUID(),
|
|
72
|
+
opType: "memory_created",
|
|
73
|
+
deviceId: ctx.deviceId,
|
|
74
|
+
userId: ctx.userId,
|
|
75
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
76
|
+
payload: {
|
|
77
|
+
memoryId: memory.memoryId,
|
|
78
|
+
userId: memory.userId,
|
|
79
|
+
namespace: memory.namespace,
|
|
80
|
+
memoryType: memory.memoryType,
|
|
81
|
+
content: memory.content,
|
|
82
|
+
rawText: memory.rawText,
|
|
83
|
+
documentDate: memory.documentDate,
|
|
84
|
+
sourceId: memory.sourceId,
|
|
85
|
+
confidence: memory.confidence,
|
|
86
|
+
salience: memory.salience,
|
|
87
|
+
keywords: memory.keywords,
|
|
88
|
+
eventDateStart: memory.eventDateStart,
|
|
89
|
+
eventDateEnd: memory.eventDateEnd,
|
|
90
|
+
invalidatedAt: memory.invalidatedAt,
|
|
91
|
+
learnedAt: memory.learnedAt
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function buildRelationCreatedOp(ctx, relation) {
|
|
96
|
+
return {
|
|
97
|
+
opId: randomUUID(),
|
|
98
|
+
opType: "relation_created",
|
|
99
|
+
deviceId: ctx.deviceId,
|
|
100
|
+
userId: ctx.userId,
|
|
101
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
102
|
+
payload: {
|
|
103
|
+
srcMemoryId: relation.srcMemoryId,
|
|
104
|
+
dstMemoryId: relation.dstMemoryId,
|
|
105
|
+
relationType: relation.relationType,
|
|
106
|
+
reason: relation.reason,
|
|
107
|
+
createdAt: relation.createdAt
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function buildMemoryInvalidatedOp(ctx, memoryId, invalidatedAt, reason) {
|
|
112
|
+
return {
|
|
113
|
+
opId: randomUUID(),
|
|
114
|
+
opType: "memory_invalidated",
|
|
115
|
+
deviceId: ctx.deviceId,
|
|
116
|
+
userId: ctx.userId,
|
|
117
|
+
createdAt: invalidatedAt,
|
|
118
|
+
payload: { memoryId, invalidatedAt, reason }
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function buildFeedbackGivenOp(ctx, memoryId, helpful, recordedAt) {
|
|
122
|
+
return {
|
|
123
|
+
opId: randomUUID(),
|
|
124
|
+
opType: "feedback_given",
|
|
125
|
+
deviceId: ctx.deviceId,
|
|
126
|
+
userId: ctx.userId,
|
|
127
|
+
createdAt: recordedAt,
|
|
128
|
+
payload: { memoryId, helpful, recordedAt }
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export {
|
|
133
|
+
deterministicOpId,
|
|
134
|
+
openCliSyncContext,
|
|
135
|
+
buildMemoryCreatedOp,
|
|
136
|
+
buildRelationCreatedOp,
|
|
137
|
+
buildMemoryInvalidatedOp,
|
|
138
|
+
buildFeedbackGivenOp
|
|
139
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// src/hooks/config.ts
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import { homedir, userInfo } from "os";
|
|
4
|
+
import { mkdirSync, readFileSync, writeFileSync, existsSync, chmodSync } from "fs";
|
|
5
|
+
var MEMROSETTA_DIR = join(homedir(), ".memrosetta");
|
|
6
|
+
var CONFIG_PATH = join(MEMROSETTA_DIR, "config.json");
|
|
7
|
+
var DB_PATH = join(MEMROSETTA_DIR, "memories.db");
|
|
8
|
+
var DEFAULT_CONFIG = {
|
|
9
|
+
dbPath: DB_PATH,
|
|
10
|
+
enableEmbeddings: true,
|
|
11
|
+
maxRecallResults: 5,
|
|
12
|
+
minQueryLength: 5,
|
|
13
|
+
maxContextChars: 2e3
|
|
14
|
+
};
|
|
15
|
+
function getDefaultDbPath() {
|
|
16
|
+
return DB_PATH;
|
|
17
|
+
}
|
|
18
|
+
function ensureDir() {
|
|
19
|
+
if (!existsSync(MEMROSETTA_DIR)) {
|
|
20
|
+
mkdirSync(MEMROSETTA_DIR, { recursive: true, mode: 448 });
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
chmodSync(MEMROSETTA_DIR, 448);
|
|
24
|
+
} catch {
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function getConfig() {
|
|
28
|
+
if (!existsSync(CONFIG_PATH)) {
|
|
29
|
+
return DEFAULT_CONFIG;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
const raw = readFileSync(CONFIG_PATH, "utf-8");
|
|
33
|
+
const parsed = JSON.parse(raw);
|
|
34
|
+
return {
|
|
35
|
+
...DEFAULT_CONFIG,
|
|
36
|
+
...parsed
|
|
37
|
+
};
|
|
38
|
+
} catch {
|
|
39
|
+
return DEFAULT_CONFIG;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function writeConfig(config) {
|
|
43
|
+
ensureDir();
|
|
44
|
+
writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2), "utf-8");
|
|
45
|
+
try {
|
|
46
|
+
chmodSync(CONFIG_PATH, 384);
|
|
47
|
+
} catch {
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function resolveCanonicalUserId(explicit) {
|
|
51
|
+
if (explicit && explicit.trim().length > 0) {
|
|
52
|
+
return explicit.trim();
|
|
53
|
+
}
|
|
54
|
+
const config = getConfig();
|
|
55
|
+
if (config.syncUserId && config.syncUserId.trim().length > 0) {
|
|
56
|
+
return config.syncUserId.trim();
|
|
57
|
+
}
|
|
58
|
+
return userInfo().username;
|
|
59
|
+
}
|
|
60
|
+
function getDefaultUserId() {
|
|
61
|
+
return resolveCanonicalUserId();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export {
|
|
65
|
+
getDefaultDbPath,
|
|
66
|
+
ensureDir,
|
|
67
|
+
getConfig,
|
|
68
|
+
writeConfig,
|
|
69
|
+
resolveCanonicalUserId,
|
|
70
|
+
getDefaultUserId
|
|
71
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// src/parser.ts
|
|
2
|
+
var COMMANDS = /* @__PURE__ */ new Set([
|
|
3
|
+
"store",
|
|
4
|
+
"search",
|
|
5
|
+
"ingest",
|
|
6
|
+
"get",
|
|
7
|
+
"count",
|
|
8
|
+
"clear",
|
|
9
|
+
"relate",
|
|
10
|
+
"invalidate",
|
|
11
|
+
"working-memory",
|
|
12
|
+
"maintain",
|
|
13
|
+
"compress",
|
|
14
|
+
"status",
|
|
15
|
+
"init",
|
|
16
|
+
"reset",
|
|
17
|
+
"update",
|
|
18
|
+
"feedback",
|
|
19
|
+
"sync",
|
|
20
|
+
"enforce",
|
|
21
|
+
"migrate",
|
|
22
|
+
"duplicates"
|
|
23
|
+
]);
|
|
24
|
+
function findFlag(args, flag) {
|
|
25
|
+
return args.includes(flag);
|
|
26
|
+
}
|
|
27
|
+
function findOption(args, flag) {
|
|
28
|
+
const idx = args.indexOf(flag);
|
|
29
|
+
if (idx === -1 || idx + 1 >= args.length) return void 0;
|
|
30
|
+
return args[idx + 1];
|
|
31
|
+
}
|
|
32
|
+
function parseGlobalArgs(args) {
|
|
33
|
+
const command = args.find((a) => !a.startsWith("-") && COMMANDS.has(a));
|
|
34
|
+
const db = findOption(args, "--db");
|
|
35
|
+
const formatRaw = findOption(args, "--format");
|
|
36
|
+
const format = formatRaw === "json" ? "json" : "text";
|
|
37
|
+
const noEmbeddings = findFlag(args, "--no-embeddings");
|
|
38
|
+
const help = findFlag(args, "--help") || findFlag(args, "-h");
|
|
39
|
+
const version = findFlag(args, "--version") || findFlag(args, "-v");
|
|
40
|
+
const rest = args.filter((a) => a !== command);
|
|
41
|
+
return {
|
|
42
|
+
command,
|
|
43
|
+
global: { db, format, noEmbeddings, help, version },
|
|
44
|
+
rest
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function requireOption(args, flag, name) {
|
|
48
|
+
const value = findOption(args, flag);
|
|
49
|
+
if (!value) {
|
|
50
|
+
throw new Error(`Missing required option: ${name} (${flag})`);
|
|
51
|
+
}
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
function optionalOption(args, flag) {
|
|
55
|
+
return findOption(args, flag);
|
|
56
|
+
}
|
|
57
|
+
function hasFlag(args, flag) {
|
|
58
|
+
return findFlag(args, flag);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
parseGlobalArgs,
|
|
63
|
+
requireOption,
|
|
64
|
+
optionalOption,
|
|
65
|
+
hasFlag
|
|
66
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getConfig
|
|
3
|
+
} from "./chunk-RZFCVYTK.js";
|
|
4
|
+
|
|
5
|
+
// src/engine.ts
|
|
6
|
+
import { join, dirname } from "path";
|
|
7
|
+
import { homedir } from "os";
|
|
8
|
+
import { mkdirSync, existsSync } from "fs";
|
|
9
|
+
var DEFAULT_DB = join(homedir(), ".memrosetta", "memories.db");
|
|
10
|
+
var cachedEngine = null;
|
|
11
|
+
var cachedDbPath = null;
|
|
12
|
+
async function createEngineInstance(options) {
|
|
13
|
+
const config = getConfig();
|
|
14
|
+
const dbPath = options.db ?? config.dbPath ?? DEFAULT_DB;
|
|
15
|
+
const dir = dirname(dbPath);
|
|
16
|
+
if (!existsSync(dir)) {
|
|
17
|
+
mkdirSync(dir, { recursive: true });
|
|
18
|
+
}
|
|
19
|
+
const { SqliteMemoryEngine } = await import("@memrosetta/core");
|
|
20
|
+
let embedder;
|
|
21
|
+
if (!options.noEmbeddings && config.enableEmbeddings !== false) {
|
|
22
|
+
try {
|
|
23
|
+
const { HuggingFaceEmbedder } = await import("@memrosetta/embeddings");
|
|
24
|
+
const preset = options.embeddingPreset ?? config.embeddingPreset ?? "en";
|
|
25
|
+
embedder = new HuggingFaceEmbedder({ preset });
|
|
26
|
+
await embedder.initialize();
|
|
27
|
+
} catch {
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const engine = new SqliteMemoryEngine({ dbPath, embedder });
|
|
31
|
+
await engine.initialize();
|
|
32
|
+
return engine;
|
|
33
|
+
}
|
|
34
|
+
async function getEngine(options) {
|
|
35
|
+
const config = getConfig();
|
|
36
|
+
const dbPath = options.db ?? config.dbPath ?? DEFAULT_DB;
|
|
37
|
+
if (cachedEngine && cachedDbPath === dbPath) {
|
|
38
|
+
return cachedEngine;
|
|
39
|
+
}
|
|
40
|
+
cachedEngine = await createEngineInstance(options);
|
|
41
|
+
cachedDbPath = dbPath;
|
|
42
|
+
return cachedEngine;
|
|
43
|
+
}
|
|
44
|
+
function getDefaultDbPath() {
|
|
45
|
+
return DEFAULT_DB;
|
|
46
|
+
}
|
|
47
|
+
function resolveDbPath(dbOverride) {
|
|
48
|
+
const config = getConfig();
|
|
49
|
+
return dbOverride ?? config.dbPath ?? DEFAULT_DB;
|
|
50
|
+
}
|
|
51
|
+
async function closeEngine() {
|
|
52
|
+
if (cachedEngine) {
|
|
53
|
+
await cachedEngine.close();
|
|
54
|
+
cachedEngine = null;
|
|
55
|
+
cachedDbPath = null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export {
|
|
60
|
+
getEngine,
|
|
61
|
+
getDefaultDbPath,
|
|
62
|
+
resolveDbPath,
|
|
63
|
+
closeEngine
|
|
64
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// src/hooks/config.ts
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import { homedir, userInfo } from "os";
|
|
4
|
+
import { mkdirSync, readFileSync, writeFileSync, existsSync, chmodSync } from "fs";
|
|
5
|
+
var MEMROSETTA_DIR = join(homedir(), ".memrosetta");
|
|
6
|
+
var CONFIG_PATH = join(MEMROSETTA_DIR, "config.json");
|
|
7
|
+
var DB_PATH = join(MEMROSETTA_DIR, "memories.db");
|
|
8
|
+
var DEFAULT_CONFIG = {
|
|
9
|
+
dbPath: DB_PATH,
|
|
10
|
+
enableEmbeddings: true,
|
|
11
|
+
maxRecallResults: 5,
|
|
12
|
+
minQueryLength: 5,
|
|
13
|
+
maxContextChars: 2e3
|
|
14
|
+
};
|
|
15
|
+
function getDefaultDbPath() {
|
|
16
|
+
return DB_PATH;
|
|
17
|
+
}
|
|
18
|
+
function ensureDir() {
|
|
19
|
+
if (!existsSync(MEMROSETTA_DIR)) {
|
|
20
|
+
mkdirSync(MEMROSETTA_DIR, { recursive: true, mode: 448 });
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
chmodSync(MEMROSETTA_DIR, 448);
|
|
24
|
+
} catch {
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function getConfig() {
|
|
28
|
+
if (!existsSync(CONFIG_PATH)) {
|
|
29
|
+
return DEFAULT_CONFIG;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
const raw = readFileSync(CONFIG_PATH, "utf-8");
|
|
33
|
+
const parsed = JSON.parse(raw);
|
|
34
|
+
return {
|
|
35
|
+
...DEFAULT_CONFIG,
|
|
36
|
+
...parsed
|
|
37
|
+
};
|
|
38
|
+
} catch {
|
|
39
|
+
return DEFAULT_CONFIG;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function writeConfig(config) {
|
|
43
|
+
ensureDir();
|
|
44
|
+
writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2), "utf-8");
|
|
45
|
+
try {
|
|
46
|
+
chmodSync(CONFIG_PATH, 384);
|
|
47
|
+
} catch {
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function resolveCanonicalUserId(explicit, configLoader = getConfig) {
|
|
51
|
+
if (explicit && explicit.trim().length > 0) {
|
|
52
|
+
return explicit.trim();
|
|
53
|
+
}
|
|
54
|
+
const config = configLoader();
|
|
55
|
+
if (config.syncUserId && config.syncUserId.trim().length > 0) {
|
|
56
|
+
return config.syncUserId.trim();
|
|
57
|
+
}
|
|
58
|
+
return userInfo().username;
|
|
59
|
+
}
|
|
60
|
+
function getDefaultUserId() {
|
|
61
|
+
return resolveCanonicalUserId();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export {
|
|
65
|
+
getDefaultDbPath,
|
|
66
|
+
ensureDir,
|
|
67
|
+
getConfig,
|
|
68
|
+
writeConfig,
|
|
69
|
+
resolveCanonicalUserId,
|
|
70
|
+
getDefaultUserId
|
|
71
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
hasFlag,
|
|
3
|
+
optionalOption
|
|
4
|
+
} from "./chunk-US6CEDMU.js";
|
|
5
|
+
import {
|
|
6
|
+
getEngine
|
|
7
|
+
} from "./chunk-47SU2YUJ.js";
|
|
8
|
+
import {
|
|
9
|
+
output,
|
|
10
|
+
outputError
|
|
11
|
+
} from "./chunk-ET6TNQOJ.js";
|
|
12
|
+
import {
|
|
13
|
+
getDefaultUserId
|
|
14
|
+
} from "./chunk-WYHEAKPC.js";
|
|
15
|
+
|
|
16
|
+
// src/commands/clear.ts
|
|
17
|
+
async function run(options) {
|
|
18
|
+
const { args, format, db, noEmbeddings } = options;
|
|
19
|
+
const userId = optionalOption(args, "--user") ?? getDefaultUserId();
|
|
20
|
+
const confirm = hasFlag(args, "--confirm");
|
|
21
|
+
if (!confirm) {
|
|
22
|
+
outputError(
|
|
23
|
+
"This will delete all memories for the user. Use --confirm to proceed.",
|
|
24
|
+
format
|
|
25
|
+
);
|
|
26
|
+
process.exitCode = 1;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const engine = await getEngine({ db, noEmbeddings });
|
|
30
|
+
const countBefore = await engine.count(userId);
|
|
31
|
+
await engine.clear(userId);
|
|
32
|
+
output(
|
|
33
|
+
{ userId, cleared: countBefore, message: `Cleared ${countBefore} memories` },
|
|
34
|
+
format
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
run
|
|
39
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
hasFlag,
|
|
3
|
+
optionalOption
|
|
4
|
+
} from "./chunk-US6CEDMU.js";
|
|
5
|
+
import {
|
|
6
|
+
getEngine
|
|
7
|
+
} from "./chunk-VMGX5FCY.js";
|
|
8
|
+
import {
|
|
9
|
+
output,
|
|
10
|
+
outputError
|
|
11
|
+
} from "./chunk-ET6TNQOJ.js";
|
|
12
|
+
import {
|
|
13
|
+
getDefaultUserId
|
|
14
|
+
} from "./chunk-RZFCVYTK.js";
|
|
15
|
+
|
|
16
|
+
// src/commands/clear.ts
|
|
17
|
+
async function run(options) {
|
|
18
|
+
const { args, format, db, noEmbeddings } = options;
|
|
19
|
+
const userId = optionalOption(args, "--user") ?? getDefaultUserId();
|
|
20
|
+
const confirm = hasFlag(args, "--confirm");
|
|
21
|
+
if (!confirm) {
|
|
22
|
+
outputError(
|
|
23
|
+
"This will delete all memories for the user. Use --confirm to proceed.",
|
|
24
|
+
format
|
|
25
|
+
);
|
|
26
|
+
process.exitCode = 1;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const engine = await getEngine({ db, noEmbeddings });
|
|
30
|
+
const countBefore = await engine.count(userId);
|
|
31
|
+
await engine.clear(userId);
|
|
32
|
+
output(
|
|
33
|
+
{ userId, cleared: countBefore, message: `Cleared ${countBefore} memories` },
|
|
34
|
+
format
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
run
|
|
39
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
optionalOption
|
|
3
|
+
} from "./chunk-US6CEDMU.js";
|
|
4
|
+
import {
|
|
5
|
+
getEngine
|
|
6
|
+
} from "./chunk-VMGX5FCY.js";
|
|
7
|
+
import {
|
|
8
|
+
output
|
|
9
|
+
} from "./chunk-ET6TNQOJ.js";
|
|
10
|
+
import {
|
|
11
|
+
getDefaultUserId
|
|
12
|
+
} from "./chunk-RZFCVYTK.js";
|
|
13
|
+
|
|
14
|
+
// src/commands/compress.ts
|
|
15
|
+
async function run(options) {
|
|
16
|
+
const { args, format, db, noEmbeddings } = options;
|
|
17
|
+
const userId = optionalOption(args, "--user") ?? getDefaultUserId();
|
|
18
|
+
const engine = await getEngine({ db, noEmbeddings });
|
|
19
|
+
const result = await engine.compress(userId);
|
|
20
|
+
if (format === "text") {
|
|
21
|
+
process.stdout.write(`Compression completed for user: ${userId}
|
|
22
|
+
`);
|
|
23
|
+
process.stdout.write(` Groups compressed: ${result.compressed}
|
|
24
|
+
`);
|
|
25
|
+
process.stdout.write(` Memories archived: ${result.removed}
|
|
26
|
+
`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
output({ userId, ...result }, format);
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
run
|
|
33
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
optionalOption
|
|
3
|
+
} from "./chunk-US6CEDMU.js";
|
|
4
|
+
import {
|
|
5
|
+
getEngine
|
|
6
|
+
} from "./chunk-47SU2YUJ.js";
|
|
7
|
+
import {
|
|
8
|
+
output
|
|
9
|
+
} from "./chunk-ET6TNQOJ.js";
|
|
10
|
+
import {
|
|
11
|
+
getDefaultUserId
|
|
12
|
+
} from "./chunk-WYHEAKPC.js";
|
|
13
|
+
|
|
14
|
+
// src/commands/compress.ts
|
|
15
|
+
async function run(options) {
|
|
16
|
+
const { args, format, db, noEmbeddings } = options;
|
|
17
|
+
const userId = optionalOption(args, "--user") ?? getDefaultUserId();
|
|
18
|
+
const engine = await getEngine({ db, noEmbeddings });
|
|
19
|
+
const result = await engine.compress(userId);
|
|
20
|
+
if (format === "text") {
|
|
21
|
+
process.stdout.write(`Compression completed for user: ${userId}
|
|
22
|
+
`);
|
|
23
|
+
process.stdout.write(` Groups compressed: ${result.compressed}
|
|
24
|
+
`);
|
|
25
|
+
process.stdout.write(` Memories archived: ${result.removed}
|
|
26
|
+
`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
output({ userId, ...result }, format);
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
run
|
|
33
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
optionalOption
|
|
3
|
+
} from "./chunk-US6CEDMU.js";
|
|
4
|
+
import {
|
|
5
|
+
getEngine
|
|
6
|
+
} from "./chunk-VMGX5FCY.js";
|
|
7
|
+
import {
|
|
8
|
+
output
|
|
9
|
+
} from "./chunk-ET6TNQOJ.js";
|
|
10
|
+
import {
|
|
11
|
+
getDefaultUserId
|
|
12
|
+
} from "./chunk-RZFCVYTK.js";
|
|
13
|
+
|
|
14
|
+
// src/commands/count.ts
|
|
15
|
+
async function run(options) {
|
|
16
|
+
const { args, format, db, noEmbeddings } = options;
|
|
17
|
+
const userId = optionalOption(args, "--user") ?? getDefaultUserId();
|
|
18
|
+
const engine = await getEngine({ db, noEmbeddings });
|
|
19
|
+
const count = await engine.count(userId);
|
|
20
|
+
output({ userId, count }, format);
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
run
|
|
24
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
optionalOption
|
|
3
|
+
} from "./chunk-US6CEDMU.js";
|
|
4
|
+
import {
|
|
5
|
+
getEngine
|
|
6
|
+
} from "./chunk-47SU2YUJ.js";
|
|
7
|
+
import {
|
|
8
|
+
output
|
|
9
|
+
} from "./chunk-ET6TNQOJ.js";
|
|
10
|
+
import {
|
|
11
|
+
getDefaultUserId
|
|
12
|
+
} from "./chunk-WYHEAKPC.js";
|
|
13
|
+
|
|
14
|
+
// src/commands/count.ts
|
|
15
|
+
async function run(options) {
|
|
16
|
+
const { args, format, db, noEmbeddings } = options;
|
|
17
|
+
const userId = optionalOption(args, "--user") ?? getDefaultUserId();
|
|
18
|
+
const engine = await getEngine({ db, noEmbeddings });
|
|
19
|
+
const count = await engine.count(userId);
|
|
20
|
+
output({ userId, count }, format);
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
run
|
|
24
|
+
};
|