@memrosetta/cli 0.4.5 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,205 @@
1
+ import {
2
+ getAgentsMdPath,
3
+ getCodexConfigFilePath,
4
+ getCursorMcpConfigPath,
5
+ getCursorRulesPath,
6
+ getGeminiMdPath,
7
+ getGeminiSettingsFilePath,
8
+ getGenericMCPPath,
9
+ isClaudeCodeInstalled,
10
+ registerClaudeCodeHooks,
11
+ registerCodexMCP,
12
+ registerCursorMCP,
13
+ registerGeminiMCP,
14
+ registerGenericMCP,
15
+ updateClaudeMd
16
+ } from "./chunk-IS4IKWPL.js";
17
+ import {
18
+ hasFlag,
19
+ optionalOption
20
+ } from "./chunk-NU5ZJJXP.js";
21
+ import {
22
+ getDefaultDbPath,
23
+ getEngine
24
+ } from "./chunk-VAVUPQZA.js";
25
+ import {
26
+ output
27
+ } from "./chunk-ET6TNQOJ.js";
28
+ import {
29
+ getConfig,
30
+ writeConfig
31
+ } from "./chunk-SEPYQK3J.js";
32
+
33
+ // src/commands/init.ts
34
+ import { existsSync } from "fs";
35
+ var LANG_FLAG_TO_PRESET = {
36
+ en: "en",
37
+ multi: "multilingual",
38
+ ko: "ko"
39
+ };
40
+ async function run(options) {
41
+ const { args, format, db, noEmbeddings } = options;
42
+ const wantClaudeCode = hasFlag(args, "--claude-code");
43
+ const wantCursor = hasFlag(args, "--cursor");
44
+ const wantCodex = hasFlag(args, "--codex");
45
+ const wantGemini = hasFlag(args, "--gemini");
46
+ const langFlag = optionalOption(args, "--lang");
47
+ const embeddingPreset = langFlag ? LANG_FLAG_TO_PRESET[langFlag] : void 0;
48
+ if (langFlag && !LANG_FLAG_TO_PRESET[langFlag]) {
49
+ process.stderr.write(
50
+ `Unknown --lang value: "${langFlag}". Supported: en, multi, ko
51
+ `
52
+ );
53
+ process.exitCode = 1;
54
+ return;
55
+ }
56
+ {
57
+ const config2 = getConfig();
58
+ const updates = {};
59
+ if (db) {
60
+ updates.dbPath = db;
61
+ }
62
+ if (noEmbeddings) {
63
+ updates.enableEmbeddings = false;
64
+ }
65
+ if (embeddingPreset) {
66
+ updates.embeddingPreset = embeddingPreset;
67
+ }
68
+ if (Object.keys(updates).length > 0) {
69
+ writeConfig({ ...config2, ...updates });
70
+ }
71
+ }
72
+ const config = getConfig();
73
+ const dbPath = db ?? config.dbPath ?? getDefaultDbPath();
74
+ const existed = existsSync(dbPath);
75
+ const engine = await getEngine({ db: dbPath, noEmbeddings });
76
+ await engine.close();
77
+ const result = {
78
+ database: {
79
+ path: dbPath,
80
+ created: !existed
81
+ },
82
+ integrations: {}
83
+ };
84
+ registerGenericMCP();
85
+ result.integrations.mcp = {
86
+ registered: true,
87
+ path: getGenericMCPPath()
88
+ };
89
+ if (wantClaudeCode) {
90
+ const hooksOk = registerClaudeCodeHooks();
91
+ const claudeMdOk = updateClaudeMd();
92
+ result.integrations.claudeCode = {
93
+ hooks: hooksOk,
94
+ mcp: true,
95
+ claudeMd: claudeMdOk
96
+ };
97
+ }
98
+ if (wantCursor) {
99
+ const cursorRulesUpdated = registerCursorMCP();
100
+ result.integrations.cursor = {
101
+ mcp: true,
102
+ path: getCursorMcpConfigPath(),
103
+ cursorRules: cursorRulesUpdated,
104
+ cursorRulesPath: getCursorRulesPath()
105
+ };
106
+ }
107
+ if (wantCodex) {
108
+ const agentsMdUpdated = registerCodexMCP();
109
+ result.integrations.codex = {
110
+ mcp: true,
111
+ path: getCodexConfigFilePath(),
112
+ agentsMd: agentsMdUpdated,
113
+ agentsMdPath: getAgentsMdPath()
114
+ };
115
+ }
116
+ if (wantGemini) {
117
+ const geminiMdUpdated = registerGeminiMCP();
118
+ result.integrations.gemini = {
119
+ mcp: true,
120
+ path: getGeminiSettingsFilePath(),
121
+ geminiMd: geminiMdUpdated,
122
+ geminiMdPath: getGeminiMdPath()
123
+ };
124
+ }
125
+ if (format === "text") {
126
+ printTextOutput(result, wantClaudeCode, wantCursor, wantCodex, wantGemini);
127
+ return;
128
+ }
129
+ output(result, format);
130
+ }
131
+ function printTextOutput(result, claudeCode, cursor, codex = false, gemini = false) {
132
+ const w = (s) => process.stdout.write(s);
133
+ w("\nMemRosetta initialized successfully.\n\n");
134
+ w(" What was set up:\n");
135
+ w(" ----------------------------------------\n");
136
+ w(` Database: ${result.database.path}`);
137
+ w(result.database.created ? " (created)\n" : " (already exists)\n");
138
+ w(` MCP Server: ${result.integrations.mcp.path} (always included)
139
+ `);
140
+ const currentConfig = getConfig();
141
+ if (currentConfig.embeddingPreset && currentConfig.embeddingPreset !== "en") {
142
+ const presetLabels = {
143
+ multilingual: "multilingual (multilingual-e5-small)",
144
+ ko: "Korean (ko-sroberta-multitask)"
145
+ };
146
+ w(` Embeddings: ${presetLabels[currentConfig.embeddingPreset] ?? currentConfig.embeddingPreset}
147
+ `);
148
+ }
149
+ if (claudeCode) {
150
+ const cc = result.integrations.claudeCode;
151
+ if (cc.hooks) {
152
+ w(" Stop Hook: ~/.claude/settings.json (auto-save on session end)\n");
153
+ } else if (!isClaudeCodeInstalled()) {
154
+ w(" Stop Hook: SKIPPED (Claude Code not found at ~/.claude)\n");
155
+ w(' Install Claude Code first, then run "memrosetta init --claude-code" again.\n');
156
+ }
157
+ if (cc.claudeMd) {
158
+ w(" CLAUDE.md: ~/.claude/CLAUDE.md (memory instructions added)\n");
159
+ } else {
160
+ w(" CLAUDE.md: already configured\n");
161
+ }
162
+ }
163
+ if (cursor) {
164
+ w(` Cursor MCP: ${result.integrations.cursor.path}
165
+ `);
166
+ if (result.integrations.cursor.cursorRules) {
167
+ w(` .cursorrules: ${result.integrations.cursor.cursorRulesPath} (memory instructions added)
168
+ `);
169
+ } else {
170
+ w(" .cursorrules: already configured\n");
171
+ }
172
+ }
173
+ if (codex) {
174
+ w(` Codex MCP: ${result.integrations.codex.path}
175
+ `);
176
+ if (result.integrations.codex.agentsMd) {
177
+ w(` AGENTS.md: ${result.integrations.codex.agentsMdPath} (memory instructions added)
178
+ `);
179
+ } else {
180
+ w(" AGENTS.md: already configured\n");
181
+ }
182
+ }
183
+ if (gemini) {
184
+ w(` Gemini MCP: ${result.integrations.gemini.path}
185
+ `);
186
+ if (result.integrations.gemini.geminiMd) {
187
+ w(` GEMINI.md: ${result.integrations.gemini.geminiMdPath} (memory instructions added)
188
+ `);
189
+ } else {
190
+ w(" GEMINI.md: already configured\n");
191
+ }
192
+ }
193
+ w("\n");
194
+ if (!claudeCode && !cursor && !codex && !gemini) {
195
+ w(" MCP is ready. Add --claude-code, --cursor, --codex, or --gemini for tool-specific setup.\n");
196
+ w(" Example: memrosetta init --claude-code\n");
197
+ w("\n");
198
+ }
199
+ if (claudeCode) {
200
+ w(" Restart Claude Code to activate.\n\n");
201
+ }
202
+ }
203
+ export {
204
+ run
205
+ };
@@ -0,0 +1,40 @@
1
+ import {
2
+ buildMemoryInvalidatedOp,
3
+ openCliSyncContext
4
+ } from "./chunk-KPASMEV7.js";
5
+ import {
6
+ optionalOption
7
+ } from "./chunk-NU5ZJJXP.js";
8
+ import {
9
+ getEngine,
10
+ resolveDbPath
11
+ } from "./chunk-VAVUPQZA.js";
12
+ import {
13
+ output,
14
+ outputError
15
+ } from "./chunk-ET6TNQOJ.js";
16
+ import "./chunk-SEPYQK3J.js";
17
+
18
+ // src/commands/invalidate.ts
19
+ async function run(options) {
20
+ const { args, format, db, noEmbeddings } = options;
21
+ const memoryId = args.find((a) => !a.startsWith("-"));
22
+ if (!memoryId) {
23
+ outputError("Usage: memrosetta invalidate <memoryId>", format);
24
+ process.exitCode = 1;
25
+ return;
26
+ }
27
+ const reason = optionalOption(args, "--reason");
28
+ const engine = await getEngine({ db, noEmbeddings });
29
+ const now = (/* @__PURE__ */ new Date()).toISOString();
30
+ await engine.invalidate(memoryId, reason);
31
+ const sync = await openCliSyncContext(resolveDbPath(db));
32
+ if (sync.enabled) {
33
+ sync.enqueue(buildMemoryInvalidatedOp(sync, memoryId, now, reason));
34
+ sync.close();
35
+ }
36
+ output({ memoryId, invalidated: true }, format);
37
+ }
38
+ export {
39
+ run
40
+ };
@@ -0,0 +1,37 @@
1
+ import {
2
+ optionalOption
3
+ } from "./chunk-NU5ZJJXP.js";
4
+ import {
5
+ getEngine
6
+ } from "./chunk-VAVUPQZA.js";
7
+ import {
8
+ output
9
+ } from "./chunk-ET6TNQOJ.js";
10
+ import {
11
+ getDefaultUserId
12
+ } from "./chunk-SEPYQK3J.js";
13
+
14
+ // src/commands/maintain.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.maintain(userId);
20
+ if (format === "text") {
21
+ process.stdout.write(`Maintenance completed for user: ${userId}
22
+ `);
23
+ process.stdout.write(` Activation scores updated: ${result.activationUpdated}
24
+ `);
25
+ process.stdout.write(` Tiers updated: ${result.tiersUpdated}
26
+ `);
27
+ process.stdout.write(` Groups compressed: ${result.compressed}
28
+ `);
29
+ process.stdout.write(` Memories archived: ${result.removed}
30
+ `);
31
+ return;
32
+ }
33
+ output({ userId, ...result }, format);
34
+ }
35
+ export {
36
+ run
37
+ };
@@ -0,0 +1,57 @@
1
+ import {
2
+ buildRelationCreatedOp,
3
+ openCliSyncContext
4
+ } from "./chunk-KPASMEV7.js";
5
+ import {
6
+ optionalOption,
7
+ requireOption
8
+ } from "./chunk-NU5ZJJXP.js";
9
+ import {
10
+ getEngine,
11
+ resolveDbPath
12
+ } from "./chunk-VAVUPQZA.js";
13
+ import {
14
+ output,
15
+ outputError
16
+ } from "./chunk-ET6TNQOJ.js";
17
+ import "./chunk-SEPYQK3J.js";
18
+
19
+ // src/commands/relate.ts
20
+ var VALID_RELATION_TYPES = /* @__PURE__ */ new Set([
21
+ "updates",
22
+ "extends",
23
+ "derives",
24
+ "contradicts",
25
+ "supports"
26
+ ]);
27
+ async function run(options) {
28
+ const { args, format, db, noEmbeddings } = options;
29
+ const src = requireOption(args, "--src", "source memory ID");
30
+ const dst = requireOption(args, "--dst", "destination memory ID");
31
+ const relationType = requireOption(args, "--type", "relation type");
32
+ const reason = optionalOption(args, "--reason");
33
+ if (!VALID_RELATION_TYPES.has(relationType)) {
34
+ outputError(
35
+ `Invalid relation type: ${relationType}. Must be one of: updates, extends, derives, contradicts, supports`,
36
+ format
37
+ );
38
+ process.exitCode = 1;
39
+ return;
40
+ }
41
+ const engine = await getEngine({ db, noEmbeddings });
42
+ const relation = await engine.relate(
43
+ src,
44
+ dst,
45
+ relationType,
46
+ reason
47
+ );
48
+ const sync = await openCliSyncContext(resolveDbPath(db));
49
+ if (sync.enabled) {
50
+ sync.enqueue(buildRelationCreatedOp(sync, relation));
51
+ sync.close();
52
+ }
53
+ output(relation, format);
54
+ }
55
+ export {
56
+ run
57
+ };
@@ -0,0 +1,48 @@
1
+ import {
2
+ optionalOption,
3
+ requireOption
4
+ } from "./chunk-NU5ZJJXP.js";
5
+ import {
6
+ getEngine
7
+ } from "./chunk-VAVUPQZA.js";
8
+ import {
9
+ output,
10
+ outputError
11
+ } from "./chunk-ET6TNQOJ.js";
12
+ import {
13
+ getDefaultUserId
14
+ } from "./chunk-SEPYQK3J.js";
15
+
16
+ // src/commands/search.ts
17
+ async function run(options) {
18
+ const { args, format, db, noEmbeddings } = options;
19
+ const userId = optionalOption(args, "--user") ?? getDefaultUserId();
20
+ const query = requireOption(args, "--query", "query");
21
+ const limitRaw = optionalOption(args, "--limit");
22
+ const namespace = optionalOption(args, "--namespace");
23
+ const typesRaw = optionalOption(args, "--types");
24
+ const minConfidenceRaw = optionalOption(args, "--min-confidence");
25
+ const limit = limitRaw ? parseInt(limitRaw, 10) : 5;
26
+ if (isNaN(limit) || limit < 1) {
27
+ outputError("Invalid limit value", format);
28
+ process.exitCode = 1;
29
+ return;
30
+ }
31
+ const memoryTypes = typesRaw ? typesRaw.split(",") : void 0;
32
+ const minConfidence = minConfidenceRaw ? parseFloat(minConfidenceRaw) : void 0;
33
+ const engine = await getEngine({ db, noEmbeddings });
34
+ const response = await engine.search({
35
+ userId,
36
+ query,
37
+ namespace,
38
+ limit,
39
+ filters: {
40
+ memoryTypes,
41
+ minConfidence
42
+ }
43
+ });
44
+ output(response, format);
45
+ }
46
+ export {
47
+ run
48
+ };
@@ -0,0 +1,184 @@
1
+ import {
2
+ isClaudeCodeConfigured,
3
+ isCodexConfigured,
4
+ isCursorConfigured,
5
+ isGeminiConfigured,
6
+ isGenericMCPConfigured
7
+ } from "./chunk-IS4IKWPL.js";
8
+ import {
9
+ resolveCliVersion
10
+ } from "./chunk-YXK6FDB6.js";
11
+ import {
12
+ getDefaultDbPath
13
+ } from "./chunk-VAVUPQZA.js";
14
+ import {
15
+ output
16
+ } from "./chunk-ET6TNQOJ.js";
17
+ import {
18
+ getConfig
19
+ } from "./chunk-SEPYQK3J.js";
20
+
21
+ // src/commands/status.ts
22
+ import { existsSync, statSync } from "fs";
23
+ async function run(options) {
24
+ const { format, db, noEmbeddings } = options;
25
+ const config = getConfig();
26
+ const dbPath = db ?? config.dbPath ?? getDefaultDbPath();
27
+ const exists = existsSync(dbPath);
28
+ let sizeBytes = 0;
29
+ let sizeFormatted = "0B";
30
+ let memoryCount = 0;
31
+ let userList = [];
32
+ let qualityFresh = 0;
33
+ let qualityInvalidated = 0;
34
+ let qualityWithRelations = 0;
35
+ let qualityAvgActivation = 0;
36
+ const embeddingsEnabled = !noEmbeddings && config.enableEmbeddings !== false;
37
+ if (exists) {
38
+ const stat = statSync(dbPath);
39
+ sizeBytes = stat.size;
40
+ sizeFormatted = formatSize(sizeBytes);
41
+ try {
42
+ const Database = (await import("better-sqlite3")).default;
43
+ const dbConn = new Database(dbPath);
44
+ dbConn.pragma("journal_mode = WAL");
45
+ const countRow = dbConn.prepare("SELECT COUNT(*) as count FROM memories").get();
46
+ memoryCount = countRow.count;
47
+ const userRows = dbConn.prepare("SELECT DISTINCT user_id FROM memories ORDER BY user_id").all();
48
+ userList = userRows.map((r) => r.user_id);
49
+ const freshRow = dbConn.prepare(
50
+ "SELECT COUNT(*) as c FROM memories WHERE is_latest = 1 AND invalidated_at IS NULL"
51
+ ).get();
52
+ qualityFresh = freshRow.c;
53
+ const invalidatedRow = dbConn.prepare(
54
+ "SELECT COUNT(*) as c FROM memories WHERE invalidated_at IS NOT NULL"
55
+ ).get();
56
+ qualityInvalidated = invalidatedRow.c;
57
+ const relationsRow = dbConn.prepare(
58
+ "SELECT COUNT(DISTINCT src_memory_id) + COUNT(DISTINCT dst_memory_id) as c FROM memory_relations"
59
+ ).get();
60
+ qualityWithRelations = relationsRow.c;
61
+ const avgRow = dbConn.prepare(
62
+ "SELECT AVG(activation_score) as avg FROM memories WHERE is_latest = 1"
63
+ ).get();
64
+ qualityAvgActivation = avgRow.avg ?? 0;
65
+ dbConn.close();
66
+ } catch {
67
+ }
68
+ }
69
+ const claudeCodeStatus = isClaudeCodeConfigured();
70
+ const cursorStatus = isCursorConfigured();
71
+ const codexStatus = isCodexConfigured();
72
+ const geminiStatus = isGeminiConfigured();
73
+ const mcpStatus = isGenericMCPConfigured();
74
+ if (format === "text") {
75
+ process.stdout.write("MemRosetta Status\n");
76
+ process.stdout.write(`${"=".repeat(40)}
77
+
78
+ `);
79
+ process.stdout.write(
80
+ `Database: ${dbPath} (${exists ? `exists, ${sizeFormatted}` : "not found"})
81
+ `
82
+ );
83
+ process.stdout.write(`Memories: ${memoryCount}
84
+ `);
85
+ if (userList.length > 0) {
86
+ process.stdout.write(
87
+ `Users: ${userList.length} (${userList.join(", ")})
88
+ `
89
+ );
90
+ } else {
91
+ process.stdout.write("Users: 0\n");
92
+ }
93
+ const embeddingModelLabel = getEmbeddingModelLabel();
94
+ process.stdout.write(
95
+ `Embeddings: ${embeddingsEnabled ? `enabled (${embeddingModelLabel})` : "disabled"}
96
+ `
97
+ );
98
+ if (memoryCount > 0) {
99
+ process.stdout.write("\nQuality:\n");
100
+ process.stdout.write(
101
+ ` Fresh (is_latest=1): ${qualityFresh} / ${memoryCount}
102
+ `
103
+ );
104
+ process.stdout.write(` Invalidated: ${qualityInvalidated}
105
+ `);
106
+ process.stdout.write(` With relations: ${qualityWithRelations}
107
+ `);
108
+ process.stdout.write(
109
+ ` Avg activation: ${qualityAvgActivation.toFixed(2)}
110
+ `
111
+ );
112
+ }
113
+ process.stdout.write("\nIntegrations:\n");
114
+ process.stdout.write(
115
+ ` Claude Code: ${claudeCodeStatus ? "configured (hooks + MCP)" : "not configured"}
116
+ `
117
+ );
118
+ process.stdout.write(
119
+ ` Cursor: ${cursorStatus ? "configured (MCP)" : "not configured"}
120
+ `
121
+ );
122
+ process.stdout.write(
123
+ ` Codex: ${codexStatus ? "configured (MCP)" : "not configured"}
124
+ `
125
+ );
126
+ process.stdout.write(
127
+ ` Gemini: ${geminiStatus ? "configured (MCP)" : "not configured"}
128
+ `
129
+ );
130
+ process.stdout.write(
131
+ ` MCP (generic): ${mcpStatus ? "configured" : "not configured"}
132
+ `
133
+ );
134
+ return;
135
+ }
136
+ output(
137
+ {
138
+ version: resolveCliVersion(),
139
+ database: {
140
+ path: dbPath,
141
+ exists,
142
+ sizeBytes,
143
+ sizeFormatted
144
+ },
145
+ memories: memoryCount,
146
+ users: userList,
147
+ quality: {
148
+ fresh: qualityFresh,
149
+ invalidated: qualityInvalidated,
150
+ withRelations: qualityWithRelations,
151
+ avgActivation: qualityAvgActivation
152
+ },
153
+ embeddings: embeddingsEnabled,
154
+ embeddingModel: getEmbeddingModelLabel(),
155
+ embeddingPreset: getConfig().embeddingPreset ?? "en",
156
+ integrations: {
157
+ claudeCode: claudeCodeStatus,
158
+ cursor: cursorStatus,
159
+ codex: codexStatus,
160
+ gemini: geminiStatus,
161
+ mcp: mcpStatus
162
+ }
163
+ },
164
+ format
165
+ );
166
+ }
167
+ function formatSize(bytes) {
168
+ if (bytes < 1024) return `${bytes}B`;
169
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)}KB`;
170
+ return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
171
+ }
172
+ var PRESET_MODEL_LABELS = {
173
+ en: "bge-small-en-v1.5",
174
+ multilingual: "multilingual-e5-small",
175
+ ko: "ko-sroberta-multitask"
176
+ };
177
+ function getEmbeddingModelLabel() {
178
+ const config = getConfig();
179
+ const preset = config.embeddingPreset ?? "en";
180
+ return PRESET_MODEL_LABELS[preset] ?? preset;
181
+ }
182
+ export {
183
+ run
184
+ };
@@ -0,0 +1,101 @@
1
+ import {
2
+ buildMemoryCreatedOp,
3
+ openCliSyncContext
4
+ } from "./chunk-KPASMEV7.js";
5
+ import {
6
+ hasFlag,
7
+ optionalOption,
8
+ requireOption
9
+ } from "./chunk-NU5ZJJXP.js";
10
+ import {
11
+ getEngine,
12
+ resolveDbPath
13
+ } from "./chunk-VAVUPQZA.js";
14
+ import {
15
+ output,
16
+ outputError
17
+ } from "./chunk-ET6TNQOJ.js";
18
+ import {
19
+ getDefaultUserId
20
+ } from "./chunk-SEPYQK3J.js";
21
+
22
+ // src/commands/store.ts
23
+ var VALID_TYPES = /* @__PURE__ */ new Set(["fact", "preference", "decision", "event"]);
24
+ async function readStdin() {
25
+ const chunks = [];
26
+ for await (const chunk of process.stdin) {
27
+ chunks.push(chunk);
28
+ }
29
+ return Buffer.concat(chunks).toString("utf-8").trim();
30
+ }
31
+ async function run(options) {
32
+ const { args, format, db, noEmbeddings } = options;
33
+ let input;
34
+ if (hasFlag(args, "--stdin")) {
35
+ const raw = await readStdin();
36
+ try {
37
+ const parsed = JSON.parse(raw);
38
+ if (!parsed.content || !parsed.memoryType) {
39
+ outputError(
40
+ "stdin JSON must have content and memoryType",
41
+ format
42
+ );
43
+ process.exitCode = 1;
44
+ return;
45
+ }
46
+ input = {
47
+ userId: parsed.userId ? String(parsed.userId) : getDefaultUserId(),
48
+ content: String(parsed.content),
49
+ memoryType: String(parsed.memoryType),
50
+ namespace: parsed.namespace ? String(parsed.namespace) : void 0,
51
+ keywords: Array.isArray(parsed.keywords) ? parsed.keywords : void 0,
52
+ confidence: typeof parsed.confidence === "number" ? parsed.confidence : void 0,
53
+ sourceId: parsed.sourceId ? String(parsed.sourceId) : void 0
54
+ };
55
+ } catch {
56
+ outputError("Invalid JSON from stdin", format);
57
+ process.exitCode = 1;
58
+ return;
59
+ }
60
+ } else {
61
+ const userId = optionalOption(args, "--user") ?? getDefaultUserId();
62
+ const content = requireOption(args, "--content", "content");
63
+ const memoryType = requireOption(args, "--type", "type");
64
+ if (!VALID_TYPES.has(memoryType)) {
65
+ outputError(
66
+ `Invalid type: ${memoryType}. Must be one of: fact, preference, decision, event`,
67
+ format
68
+ );
69
+ process.exitCode = 1;
70
+ return;
71
+ }
72
+ const namespace = optionalOption(args, "--namespace");
73
+ const keywordsRaw = optionalOption(args, "--keywords");
74
+ const confidenceRaw = optionalOption(args, "--confidence");
75
+ const sourceId = optionalOption(args, "--source-id");
76
+ const eventStart = optionalOption(args, "--event-start");
77
+ const eventEnd = optionalOption(args, "--event-end");
78
+ input = {
79
+ userId,
80
+ content,
81
+ memoryType,
82
+ namespace,
83
+ keywords: keywordsRaw ? keywordsRaw.split(",") : void 0,
84
+ confidence: confidenceRaw ? parseFloat(confidenceRaw) : void 0,
85
+ sourceId,
86
+ eventDateStart: eventStart,
87
+ eventDateEnd: eventEnd
88
+ };
89
+ }
90
+ const engine = await getEngine({ db, noEmbeddings });
91
+ const memory = await engine.store(input);
92
+ const sync = await openCliSyncContext(resolveDbPath(db));
93
+ if (sync.enabled) {
94
+ sync.enqueue(buildMemoryCreatedOp(sync, memory));
95
+ sync.close();
96
+ }
97
+ output(memory, format);
98
+ }
99
+ export {
100
+ run
101
+ };