@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,184 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isClaudeCodeConfigured,
|
|
3
|
+
isCodexConfigured,
|
|
4
|
+
isCursorConfigured,
|
|
5
|
+
isGeminiConfigured,
|
|
6
|
+
isGenericMCPConfigured
|
|
7
|
+
} from "./chunk-4LNXT25H.js";
|
|
8
|
+
import {
|
|
9
|
+
resolveCliVersion
|
|
10
|
+
} from "./chunk-YXK6FDB6.js";
|
|
11
|
+
import {
|
|
12
|
+
getDefaultDbPath
|
|
13
|
+
} from "./chunk-47SU2YUJ.js";
|
|
14
|
+
import {
|
|
15
|
+
output
|
|
16
|
+
} from "./chunk-ET6TNQOJ.js";
|
|
17
|
+
import {
|
|
18
|
+
getConfig
|
|
19
|
+
} from "./chunk-WYHEAKPC.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,184 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isClaudeCodeConfigured,
|
|
3
|
+
isCodexConfigured,
|
|
4
|
+
isCursorConfigured,
|
|
5
|
+
isGeminiConfigured,
|
|
6
|
+
isGenericMCPConfigured
|
|
7
|
+
} from "./chunk-4LNXT25H.js";
|
|
8
|
+
import {
|
|
9
|
+
resolveCliVersion
|
|
10
|
+
} from "./chunk-YXK6FDB6.js";
|
|
11
|
+
import {
|
|
12
|
+
getDefaultDbPath
|
|
13
|
+
} from "./chunk-VMGX5FCY.js";
|
|
14
|
+
import {
|
|
15
|
+
output
|
|
16
|
+
} from "./chunk-ET6TNQOJ.js";
|
|
17
|
+
import {
|
|
18
|
+
getConfig
|
|
19
|
+
} from "./chunk-RZFCVYTK.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-GZINXXM4.js";
|
|
5
|
+
import {
|
|
6
|
+
hasFlag,
|
|
7
|
+
optionalOption,
|
|
8
|
+
requireOption
|
|
9
|
+
} from "./chunk-US6CEDMU.js";
|
|
10
|
+
import {
|
|
11
|
+
getEngine,
|
|
12
|
+
resolveDbPath
|
|
13
|
+
} from "./chunk-VMGX5FCY.js";
|
|
14
|
+
import {
|
|
15
|
+
output,
|
|
16
|
+
outputError
|
|
17
|
+
} from "./chunk-ET6TNQOJ.js";
|
|
18
|
+
import {
|
|
19
|
+
getDefaultUserId
|
|
20
|
+
} from "./chunk-RZFCVYTK.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
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildMemoryCreatedOp,
|
|
3
|
+
openCliSyncContext
|
|
4
|
+
} from "./chunk-GGXC7TAJ.js";
|
|
5
|
+
import {
|
|
6
|
+
hasFlag,
|
|
7
|
+
optionalOption,
|
|
8
|
+
requireOption
|
|
9
|
+
} from "./chunk-US6CEDMU.js";
|
|
10
|
+
import {
|
|
11
|
+
getEngine,
|
|
12
|
+
resolveDbPath
|
|
13
|
+
} from "./chunk-47SU2YUJ.js";
|
|
14
|
+
import {
|
|
15
|
+
output,
|
|
16
|
+
outputError
|
|
17
|
+
} from "./chunk-ET6TNQOJ.js";
|
|
18
|
+
import {
|
|
19
|
+
getDefaultUserId
|
|
20
|
+
} from "./chunk-WYHEAKPC.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
|
+
};
|