@memrosetta/cli 0.4.0 → 0.4.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.
Files changed (39) hide show
  1. package/dist/chunk-72IW6TAV.js +59 -0
  2. package/dist/chunk-MISLIVUL.js +70 -0
  3. package/dist/chunk-NU5ZJJXP.js +63 -0
  4. package/dist/chunk-SEPYQK3J.js +60 -0
  5. package/dist/clear-47OFIDME.js +39 -0
  6. package/dist/clear-5SZVGYBX.js +39 -0
  7. package/dist/compress-SEFTKZMU.js +33 -0
  8. package/dist/compress-YNY6YNFU.js +33 -0
  9. package/dist/count-AMSEVDWR.js +24 -0
  10. package/dist/count-Z67KBEMV.js +24 -0
  11. package/dist/feedback-QDOWDWHM.js +40 -0
  12. package/dist/feedback-XGBKFQXC.js +40 -0
  13. package/dist/get-NY5H3MUA.js +30 -0
  14. package/dist/hooks/on-prompt.js +2 -2
  15. package/dist/hooks/on-stop.js +2 -2
  16. package/dist/index.js +35 -18
  17. package/dist/ingest-GSJMWDV5.js +95 -0
  18. package/dist/ingest-TZEVA25F.js +95 -0
  19. package/dist/init-GRVRJ6RO.js +205 -0
  20. package/dist/init-LK4UQISR.js +205 -0
  21. package/dist/invalidate-BY5VNFSE.js +25 -0
  22. package/dist/maintain-SGM56XKE.js +37 -0
  23. package/dist/maintain-VX2VWB2L.js +37 -0
  24. package/dist/relate-L5464WV5.js +47 -0
  25. package/dist/relate-SGZLG7JU.js +47 -0
  26. package/dist/reset-CYY4KYAB.js +129 -0
  27. package/dist/search-BJ2YV5IS.js +48 -0
  28. package/dist/search-PT4POELX.js +48 -0
  29. package/dist/status-TVY32MZD.js +218 -0
  30. package/dist/store-2USP33HQ.js +91 -0
  31. package/dist/store-XCFYGYBE.js +91 -0
  32. package/dist/sync-643GTA5X.js +319 -0
  33. package/dist/sync-7TONPJBY.js +351 -0
  34. package/dist/sync-BPVMHW34.js +319 -0
  35. package/dist/sync-OZQLBYT2.js +317 -0
  36. package/dist/sync-WURX2HJZ.js +321 -0
  37. package/dist/working-memory-UYVEJJYW.js +53 -0
  38. package/dist/working-memory-VP6L2QV6.js +53 -0
  39. package/package.json +5 -4
@@ -0,0 +1,218 @@
1
+ import {
2
+ isClaudeCodeConfigured,
3
+ isCodexConfigured,
4
+ isCursorConfigured,
5
+ isGeminiConfigured,
6
+ isGenericMCPConfigured
7
+ } from "./chunk-IS4IKWPL.js";
8
+ import {
9
+ getDefaultDbPath
10
+ } from "./chunk-72IW6TAV.js";
11
+ import {
12
+ output
13
+ } from "./chunk-ET6TNQOJ.js";
14
+ import {
15
+ getConfig
16
+ } from "./chunk-SEPYQK3J.js";
17
+
18
+ // src/commands/status.ts
19
+ import { existsSync, statSync, readFileSync } from "fs";
20
+ import { dirname, join } from "path";
21
+ import { fileURLToPath } from "url";
22
+ import { createRequire } from "module";
23
+ function getVersion() {
24
+ const strategies = [
25
+ // 1. Relative to source (dev/source checkout via tsx)
26
+ () => {
27
+ const require2 = createRequire(import.meta.url);
28
+ return require2("../../package.json").version;
29
+ },
30
+ // 2. Resolve from npm package
31
+ () => {
32
+ const require2 = createRequire(import.meta.url);
33
+ return require2("@memrosetta/cli/package.json").version;
34
+ },
35
+ // 3. Walk up to find package.json from current file location
36
+ () => {
37
+ const dir = dirname(fileURLToPath(import.meta.url));
38
+ for (let d = dir, i = 0; i < 5; i++) {
39
+ const candidate = join(d, "package.json");
40
+ if (existsSync(candidate)) {
41
+ const pkg = JSON.parse(readFileSync(candidate, "utf-8"));
42
+ if (pkg.name?.includes("memrosetta") && pkg.version) return pkg.version;
43
+ }
44
+ d = dirname(d);
45
+ }
46
+ throw new Error("not found");
47
+ }
48
+ ];
49
+ for (const strategy of strategies) {
50
+ try {
51
+ return strategy();
52
+ } catch {
53
+ }
54
+ }
55
+ return "unknown";
56
+ }
57
+ async function run(options) {
58
+ const { format, db, noEmbeddings } = options;
59
+ const config = getConfig();
60
+ const dbPath = db ?? config.dbPath ?? getDefaultDbPath();
61
+ const exists = existsSync(dbPath);
62
+ let sizeBytes = 0;
63
+ let sizeFormatted = "0B";
64
+ let memoryCount = 0;
65
+ let userList = [];
66
+ let qualityFresh = 0;
67
+ let qualityInvalidated = 0;
68
+ let qualityWithRelations = 0;
69
+ let qualityAvgActivation = 0;
70
+ const embeddingsEnabled = !noEmbeddings && config.enableEmbeddings !== false;
71
+ if (exists) {
72
+ const stat = statSync(dbPath);
73
+ sizeBytes = stat.size;
74
+ sizeFormatted = formatSize(sizeBytes);
75
+ try {
76
+ const Database = (await import("better-sqlite3")).default;
77
+ const dbConn = new Database(dbPath);
78
+ dbConn.pragma("journal_mode = WAL");
79
+ const countRow = dbConn.prepare("SELECT COUNT(*) as count FROM memories").get();
80
+ memoryCount = countRow.count;
81
+ const userRows = dbConn.prepare("SELECT DISTINCT user_id FROM memories ORDER BY user_id").all();
82
+ userList = userRows.map((r) => r.user_id);
83
+ const freshRow = dbConn.prepare(
84
+ "SELECT COUNT(*) as c FROM memories WHERE is_latest = 1 AND invalidated_at IS NULL"
85
+ ).get();
86
+ qualityFresh = freshRow.c;
87
+ const invalidatedRow = dbConn.prepare(
88
+ "SELECT COUNT(*) as c FROM memories WHERE invalidated_at IS NOT NULL"
89
+ ).get();
90
+ qualityInvalidated = invalidatedRow.c;
91
+ const relationsRow = dbConn.prepare(
92
+ "SELECT COUNT(DISTINCT src_memory_id) + COUNT(DISTINCT dst_memory_id) as c FROM memory_relations"
93
+ ).get();
94
+ qualityWithRelations = relationsRow.c;
95
+ const avgRow = dbConn.prepare(
96
+ "SELECT AVG(activation_score) as avg FROM memories WHERE is_latest = 1"
97
+ ).get();
98
+ qualityAvgActivation = avgRow.avg ?? 0;
99
+ dbConn.close();
100
+ } catch {
101
+ }
102
+ }
103
+ const claudeCodeStatus = isClaudeCodeConfigured();
104
+ const cursorStatus = isCursorConfigured();
105
+ const codexStatus = isCodexConfigured();
106
+ const geminiStatus = isGeminiConfigured();
107
+ const mcpStatus = isGenericMCPConfigured();
108
+ if (format === "text") {
109
+ process.stdout.write("MemRosetta Status\n");
110
+ process.stdout.write(`${"=".repeat(40)}
111
+
112
+ `);
113
+ process.stdout.write(
114
+ `Database: ${dbPath} (${exists ? `exists, ${sizeFormatted}` : "not found"})
115
+ `
116
+ );
117
+ process.stdout.write(`Memories: ${memoryCount}
118
+ `);
119
+ if (userList.length > 0) {
120
+ process.stdout.write(
121
+ `Users: ${userList.length} (${userList.join(", ")})
122
+ `
123
+ );
124
+ } else {
125
+ process.stdout.write("Users: 0\n");
126
+ }
127
+ const embeddingModelLabel = getEmbeddingModelLabel();
128
+ process.stdout.write(
129
+ `Embeddings: ${embeddingsEnabled ? `enabled (${embeddingModelLabel})` : "disabled"}
130
+ `
131
+ );
132
+ if (memoryCount > 0) {
133
+ process.stdout.write("\nQuality:\n");
134
+ process.stdout.write(
135
+ ` Fresh (is_latest=1): ${qualityFresh} / ${memoryCount}
136
+ `
137
+ );
138
+ process.stdout.write(` Invalidated: ${qualityInvalidated}
139
+ `);
140
+ process.stdout.write(` With relations: ${qualityWithRelations}
141
+ `);
142
+ process.stdout.write(
143
+ ` Avg activation: ${qualityAvgActivation.toFixed(2)}
144
+ `
145
+ );
146
+ }
147
+ process.stdout.write("\nIntegrations:\n");
148
+ process.stdout.write(
149
+ ` Claude Code: ${claudeCodeStatus ? "configured (hooks + MCP)" : "not configured"}
150
+ `
151
+ );
152
+ process.stdout.write(
153
+ ` Cursor: ${cursorStatus ? "configured (MCP)" : "not configured"}
154
+ `
155
+ );
156
+ process.stdout.write(
157
+ ` Codex: ${codexStatus ? "configured (MCP)" : "not configured"}
158
+ `
159
+ );
160
+ process.stdout.write(
161
+ ` Gemini: ${geminiStatus ? "configured (MCP)" : "not configured"}
162
+ `
163
+ );
164
+ process.stdout.write(
165
+ ` MCP (generic): ${mcpStatus ? "configured" : "not configured"}
166
+ `
167
+ );
168
+ return;
169
+ }
170
+ output(
171
+ {
172
+ version: getVersion(),
173
+ database: {
174
+ path: dbPath,
175
+ exists,
176
+ sizeBytes,
177
+ sizeFormatted
178
+ },
179
+ memories: memoryCount,
180
+ users: userList,
181
+ quality: {
182
+ fresh: qualityFresh,
183
+ invalidated: qualityInvalidated,
184
+ withRelations: qualityWithRelations,
185
+ avgActivation: qualityAvgActivation
186
+ },
187
+ embeddings: embeddingsEnabled,
188
+ embeddingModel: getEmbeddingModelLabel(),
189
+ embeddingPreset: getConfig().embeddingPreset ?? "en",
190
+ integrations: {
191
+ claudeCode: claudeCodeStatus,
192
+ cursor: cursorStatus,
193
+ codex: codexStatus,
194
+ gemini: geminiStatus,
195
+ mcp: mcpStatus
196
+ }
197
+ },
198
+ format
199
+ );
200
+ }
201
+ function formatSize(bytes) {
202
+ if (bytes < 1024) return `${bytes}B`;
203
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)}KB`;
204
+ return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
205
+ }
206
+ var PRESET_MODEL_LABELS = {
207
+ en: "bge-small-en-v1.5",
208
+ multilingual: "multilingual-e5-small",
209
+ ko: "ko-sroberta-multitask"
210
+ };
211
+ function getEmbeddingModelLabel() {
212
+ const config = getConfig();
213
+ const preset = config.embeddingPreset ?? "en";
214
+ return PRESET_MODEL_LABELS[preset] ?? preset;
215
+ }
216
+ export {
217
+ run
218
+ };
@@ -0,0 +1,91 @@
1
+ import {
2
+ hasFlag,
3
+ optionalOption,
4
+ requireOption
5
+ } from "./chunk-NU5ZJJXP.js";
6
+ import {
7
+ getEngine
8
+ } from "./chunk-72IW6TAV.js";
9
+ import {
10
+ output,
11
+ outputError
12
+ } from "./chunk-ET6TNQOJ.js";
13
+ import {
14
+ getDefaultUserId
15
+ } from "./chunk-SEPYQK3J.js";
16
+
17
+ // src/commands/store.ts
18
+ var VALID_TYPES = /* @__PURE__ */ new Set(["fact", "preference", "decision", "event"]);
19
+ async function readStdin() {
20
+ const chunks = [];
21
+ for await (const chunk of process.stdin) {
22
+ chunks.push(chunk);
23
+ }
24
+ return Buffer.concat(chunks).toString("utf-8").trim();
25
+ }
26
+ async function run(options) {
27
+ const { args, format, db, noEmbeddings } = options;
28
+ let input;
29
+ if (hasFlag(args, "--stdin")) {
30
+ const raw = await readStdin();
31
+ try {
32
+ const parsed = JSON.parse(raw);
33
+ if (!parsed.content || !parsed.memoryType) {
34
+ outputError(
35
+ "stdin JSON must have content and memoryType",
36
+ format
37
+ );
38
+ process.exitCode = 1;
39
+ return;
40
+ }
41
+ input = {
42
+ userId: parsed.userId ? String(parsed.userId) : getDefaultUserId(),
43
+ content: String(parsed.content),
44
+ memoryType: String(parsed.memoryType),
45
+ namespace: parsed.namespace ? String(parsed.namespace) : void 0,
46
+ keywords: Array.isArray(parsed.keywords) ? parsed.keywords : void 0,
47
+ confidence: typeof parsed.confidence === "number" ? parsed.confidence : void 0,
48
+ sourceId: parsed.sourceId ? String(parsed.sourceId) : void 0
49
+ };
50
+ } catch {
51
+ outputError("Invalid JSON from stdin", format);
52
+ process.exitCode = 1;
53
+ return;
54
+ }
55
+ } else {
56
+ const userId = optionalOption(args, "--user") ?? getDefaultUserId();
57
+ const content = requireOption(args, "--content", "content");
58
+ const memoryType = requireOption(args, "--type", "type");
59
+ if (!VALID_TYPES.has(memoryType)) {
60
+ outputError(
61
+ `Invalid type: ${memoryType}. Must be one of: fact, preference, decision, event`,
62
+ format
63
+ );
64
+ process.exitCode = 1;
65
+ return;
66
+ }
67
+ const namespace = optionalOption(args, "--namespace");
68
+ const keywordsRaw = optionalOption(args, "--keywords");
69
+ const confidenceRaw = optionalOption(args, "--confidence");
70
+ const sourceId = optionalOption(args, "--source-id");
71
+ const eventStart = optionalOption(args, "--event-start");
72
+ const eventEnd = optionalOption(args, "--event-end");
73
+ input = {
74
+ userId,
75
+ content,
76
+ memoryType,
77
+ namespace,
78
+ keywords: keywordsRaw ? keywordsRaw.split(",") : void 0,
79
+ confidence: confidenceRaw ? parseFloat(confidenceRaw) : void 0,
80
+ sourceId,
81
+ eventDateStart: eventStart,
82
+ eventDateEnd: eventEnd
83
+ };
84
+ }
85
+ const engine = await getEngine({ db, noEmbeddings });
86
+ const memory = await engine.store(input);
87
+ output(memory, format);
88
+ }
89
+ export {
90
+ run
91
+ };
@@ -0,0 +1,91 @@
1
+ import {
2
+ hasFlag,
3
+ optionalOption,
4
+ requireOption
5
+ } from "./chunk-VZQURGWB.js";
6
+ import {
7
+ getEngine
8
+ } from "./chunk-72IW6TAV.js";
9
+ import {
10
+ output,
11
+ outputError
12
+ } from "./chunk-ET6TNQOJ.js";
13
+ import {
14
+ getDefaultUserId
15
+ } from "./chunk-SEPYQK3J.js";
16
+
17
+ // src/commands/store.ts
18
+ var VALID_TYPES = /* @__PURE__ */ new Set(["fact", "preference", "decision", "event"]);
19
+ async function readStdin() {
20
+ const chunks = [];
21
+ for await (const chunk of process.stdin) {
22
+ chunks.push(chunk);
23
+ }
24
+ return Buffer.concat(chunks).toString("utf-8").trim();
25
+ }
26
+ async function run(options) {
27
+ const { args, format, db, noEmbeddings } = options;
28
+ let input;
29
+ if (hasFlag(args, "--stdin")) {
30
+ const raw = await readStdin();
31
+ try {
32
+ const parsed = JSON.parse(raw);
33
+ if (!parsed.content || !parsed.memoryType) {
34
+ outputError(
35
+ "stdin JSON must have content and memoryType",
36
+ format
37
+ );
38
+ process.exitCode = 1;
39
+ return;
40
+ }
41
+ input = {
42
+ userId: parsed.userId ? String(parsed.userId) : getDefaultUserId(),
43
+ content: String(parsed.content),
44
+ memoryType: String(parsed.memoryType),
45
+ namespace: parsed.namespace ? String(parsed.namespace) : void 0,
46
+ keywords: Array.isArray(parsed.keywords) ? parsed.keywords : void 0,
47
+ confidence: typeof parsed.confidence === "number" ? parsed.confidence : void 0,
48
+ sourceId: parsed.sourceId ? String(parsed.sourceId) : void 0
49
+ };
50
+ } catch {
51
+ outputError("Invalid JSON from stdin", format);
52
+ process.exitCode = 1;
53
+ return;
54
+ }
55
+ } else {
56
+ const userId = optionalOption(args, "--user") ?? getDefaultUserId();
57
+ const content = requireOption(args, "--content", "content");
58
+ const memoryType = requireOption(args, "--type", "type");
59
+ if (!VALID_TYPES.has(memoryType)) {
60
+ outputError(
61
+ `Invalid type: ${memoryType}. Must be one of: fact, preference, decision, event`,
62
+ format
63
+ );
64
+ process.exitCode = 1;
65
+ return;
66
+ }
67
+ const namespace = optionalOption(args, "--namespace");
68
+ const keywordsRaw = optionalOption(args, "--keywords");
69
+ const confidenceRaw = optionalOption(args, "--confidence");
70
+ const sourceId = optionalOption(args, "--source-id");
71
+ const eventStart = optionalOption(args, "--event-start");
72
+ const eventEnd = optionalOption(args, "--event-end");
73
+ input = {
74
+ userId,
75
+ content,
76
+ memoryType,
77
+ namespace,
78
+ keywords: keywordsRaw ? keywordsRaw.split(",") : void 0,
79
+ confidence: confidenceRaw ? parseFloat(confidenceRaw) : void 0,
80
+ sourceId,
81
+ eventDateStart: eventStart,
82
+ eventDateEnd: eventEnd
83
+ };
84
+ }
85
+ const engine = await getEngine({ db, noEmbeddings });
86
+ const memory = await engine.store(input);
87
+ output(memory, format);
88
+ }
89
+ export {
90
+ run
91
+ };