@memrosetta/cli 0.3.2 → 0.4.1
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-356QK7TK.js +533 -0
- package/dist/chunk-3LSITXZ4.js +69 -0
- package/dist/chunk-6IOTBMUB.js +570 -0
- package/dist/chunk-72IW6TAV.js +59 -0
- package/dist/chunk-BGXZ3MDD.js +341 -0
- package/dist/chunk-EZVP3OY7.js +52 -0
- package/dist/chunk-FCHV2JMZ.js +347 -0
- package/dist/{chunk-F7ZMZ6HN.js → chunk-HXZ7MAT6.js} +2 -1
- package/dist/chunk-IM6H35RB.js +341 -0
- package/dist/chunk-JGE6RXXH.js +48 -0
- package/dist/chunk-JPBSMZ26.js +343 -0
- package/dist/chunk-KSKRPUZZ.js +43 -0
- package/dist/chunk-L6S3TXHR.js +326 -0
- package/dist/chunk-MISLIVUL.js +70 -0
- package/dist/chunk-NU5ZJJXP.js +63 -0
- package/dist/{chunk-326TFH4F.js → chunk-OCCU5YEG.js} +11 -42
- package/dist/chunk-PW52BB6L.js +61 -0
- package/dist/chunk-RABFL4EN.js +528 -0
- package/dist/chunk-RDUU53MG.js +343 -0
- package/dist/chunk-RYPYJJ2K.js +70 -0
- package/dist/chunk-SEPYQK3J.js +60 -0
- package/dist/{chunk-CATBN3ZT.js → chunk-TQOH7ZXN.js} +6 -18
- package/dist/chunk-Y6NH6K27.js +209 -0
- package/dist/{clear-MTL4CQM3.js → clear-47OFIDME.js} +10 -5
- package/dist/clear-4RQW6SYW.js +39 -0
- package/dist/clear-5SZVGYBX.js +39 -0
- package/dist/clear-BYRCL5ZN.js +39 -0
- package/dist/clear-ETQ7XFMV.js +39 -0
- package/dist/clear-P6H55OKZ.js +39 -0
- package/dist/clear-T3TWJQKL.js +39 -0
- package/dist/{compress-Z46R4N4M.js → compress-HDNYPXZ3.js} +10 -5
- package/dist/compress-S6MS4QW7.js +33 -0
- package/dist/compress-SEFTKZMU.js +33 -0
- package/dist/compress-TVWXLW3L.js +33 -0
- package/dist/compress-VLYNZ5BQ.js +33 -0
- package/dist/compress-YNY6YNFU.js +33 -0
- package/dist/compress-ZXWRRGHT.js +33 -0
- package/dist/{count-4TZ3C524.js → count-26AGY5XL.js} +10 -5
- package/dist/count-AMSEVDWR.js +24 -0
- package/dist/count-AVG5ZIRW.js +24 -0
- package/dist/count-CJIYYJKN.js +24 -0
- package/dist/count-KFFD4ML7.js +24 -0
- package/dist/count-UUAD3GEJ.js +24 -0
- package/dist/count-Z67KBEMV.js +24 -0
- package/dist/feedback-QDOWDWHM.js +40 -0
- package/dist/feedback-XGBKFQXC.js +40 -0
- package/dist/{get-B6AL75EW.js → get-75MGS4LN.js} +4 -2
- package/dist/get-NY5H3MUA.js +30 -0
- package/dist/hooks/on-prompt.js +2 -2
- package/dist/hooks/on-stop.js +2 -2
- package/dist/index.js +35 -18
- package/dist/ingest-A3BAI2C4.js +95 -0
- package/dist/ingest-E7QDD5NY.js +95 -0
- package/dist/ingest-GSJMWDV5.js +95 -0
- package/dist/ingest-IGI7RXR4.js +95 -0
- package/dist/ingest-JPIHSH7W.js +95 -0
- package/dist/ingest-QGXA4Y6C.js +95 -0
- package/dist/ingest-TZEVA25F.js +95 -0
- package/dist/init-2PRW64KV.js +146 -0
- package/dist/init-C3CONL23.js +146 -0
- package/dist/init-DAKOWQSW.js +169 -0
- package/dist/init-FYPMJDRN.js +146 -0
- package/dist/{init-C335O4TX.js → init-GCT4XEI6.js} +2 -2
- package/dist/init-GRVRJ6RO.js +205 -0
- package/dist/init-HBEIXY3N.js +146 -0
- package/dist/init-LK4UQISR.js +205 -0
- package/dist/init-MISGIVCC.js +146 -0
- package/dist/init-MNM4TXXJ.js +146 -0
- package/dist/{init-YAGOXYWG.js → init-OQW3KXTR.js} +2 -2
- package/dist/init-SIEKAILM.js +113 -0
- package/dist/init-TM7GTHTJ.js +146 -0
- package/dist/init-VYWOSISP.js +146 -0
- package/dist/init-WCL7FZOJ.js +182 -0
- package/dist/init-ZLUDTJAP.js +182 -0
- package/dist/invalidate-BY5VNFSE.js +25 -0
- package/dist/{invalidate-C54IVIGL.js → invalidate-D2O4VWZU.js} +4 -2
- package/dist/{maintain-ZPHG47YY.js → maintain-B65WIMGJ.js} +10 -5
- package/dist/maintain-EWOU3DGT.js +37 -0
- package/dist/maintain-FELKLG7O.js +37 -0
- package/dist/maintain-SGM56XKE.js +37 -0
- package/dist/maintain-VX2VWB2L.js +37 -0
- package/dist/maintain-WRRDXEG3.js +37 -0
- package/dist/maintain-XTCSOQBU.js +37 -0
- package/dist/{relate-R6DQUJCQ.js → relate-2QMG5H2I.js} +5 -3
- package/dist/relate-C22YYJZT.js +46 -0
- package/dist/relate-L5464WV5.js +47 -0
- package/dist/relate-SGZLG7JU.js +47 -0
- package/dist/relate-V5RYMJJ5.js +47 -0
- package/dist/relate-W4BXPFJA.js +46 -0
- package/dist/reset-45EUG44R.js +95 -0
- package/dist/reset-5NDHFUC3.js +95 -0
- package/dist/reset-C7I3LA5M.js +95 -0
- package/dist/reset-CYY4KYAB.js +129 -0
- package/dist/reset-F6F2R6BR.js +95 -0
- package/dist/reset-K3K4K5CT.js +95 -0
- package/dist/reset-K4WZJ4WU.js +95 -0
- package/dist/{reset-P63V46RN.js → reset-NNQQJN6L.js} +2 -2
- package/dist/{reset-GPV46GSD.js → reset-P5FXLI4E.js} +2 -2
- package/dist/reset-SORHIEKY.js +112 -0
- package/dist/reset-SVJMWYAK.js +95 -0
- package/dist/reset-W22RJGYZ.js +112 -0
- package/dist/reset-W3QVA632.js +95 -0
- package/dist/reset-WYEU6XJQ.js +112 -0
- package/dist/{search-YEYKOEXC.js → search-2SU5WQYK.js} +9 -4
- package/dist/search-5EE3XB2R.js +48 -0
- package/dist/search-BJ2YV5IS.js +48 -0
- package/dist/search-L6P3XY47.js +48 -0
- package/dist/search-PT4POELX.js +48 -0
- package/dist/search-UA7Y55LQ.js +48 -0
- package/dist/search-ZKLRJXFT.js +48 -0
- package/dist/status-3XVXJF7M.js +170 -0
- package/dist/status-4THJLSJL.js +131 -0
- package/dist/status-4UYY7TOE.js +131 -0
- package/dist/status-7G3RMR6A.js +139 -0
- package/dist/status-7M4TJVDH.js +170 -0
- package/dist/status-7MEEKEC2.js +131 -0
- package/dist/status-BQL4VJ6Y.js +149 -0
- package/dist/status-BTEVCZ5K.js +125 -0
- package/dist/status-F3NZGGPH.js +131 -0
- package/dist/status-GQMXOMRN.js +131 -0
- package/dist/status-HJGTMHTD.js +131 -0
- package/dist/{status-AMMF6QGI.js → status-IEKR6SSH.js} +35 -6
- package/dist/status-JJGVWESB.js +139 -0
- package/dist/status-LDVRVYZH.js +131 -0
- package/dist/{status-XNQRRFWF.js → status-TATIX3R6.js} +1 -1
- package/dist/{status-PYD6U7U7.js → status-TVY32MZD.js} +10 -3
- package/dist/{store-ZMERYHI6.js → store-2USP33HQ.js} +12 -7
- package/dist/store-6D5OJ2DX.js +91 -0
- package/dist/store-I4JNJWAZ.js +91 -0
- package/dist/store-R4LXYE57.js +91 -0
- package/dist/store-UMR2NOT7.js +91 -0
- package/dist/store-XCFYGYBE.js +91 -0
- package/dist/store-ZDI5AH4M.js +91 -0
- package/dist/sync-643GTA5X.js +319 -0
- package/dist/sync-BPVMHW34.js +319 -0
- package/dist/sync-OZQLBYT2.js +317 -0
- package/dist/sync-WURX2HJZ.js +321 -0
- package/dist/update-XJLMXCDZ.js +36 -0
- package/dist/{working-memory-2RRQFX4Q.js → working-memory-2U33JHJB.js} +10 -6
- package/dist/working-memory-35TMFU3P.js +53 -0
- package/dist/working-memory-IBWGIXLW.js +53 -0
- package/dist/working-memory-RZE3GYQZ.js +53 -0
- package/dist/working-memory-UYVEJJYW.js +53 -0
- package/dist/working-memory-VP6L2QV6.js +53 -0
- package/dist/working-memory-WGB5DZ3B.js +53 -0
- package/package.json +5 -4
- package/dist/chunk-MWLPPS7U.js +0 -133
- package/dist/ingest-ZOR3XSAE.js +0 -152
- package/dist/init-7VFBCA4O.js +0 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memrosetta/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"better-sqlite3": "^11.0.0",
|
|
18
|
-
"@memrosetta/core": "0.
|
|
18
|
+
"@memrosetta/core": "0.4.0",
|
|
19
19
|
"@memrosetta/embeddings": "0.3.0",
|
|
20
|
-
"@memrosetta/
|
|
20
|
+
"@memrosetta/sync-client": "0.1.1",
|
|
21
|
+
"@memrosetta/types": "0.4.0"
|
|
21
22
|
},
|
|
22
23
|
"optionalDependencies": {
|
|
23
24
|
"@memrosetta/llm": "0.3.0"
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
"vitest": "^2.0.0"
|
|
30
31
|
},
|
|
31
32
|
"scripts": {
|
|
32
|
-
"build": "tsup src/index.ts src/hooks/on-stop.ts src/hooks/on-prompt.ts --format esm --external better-sqlite3 --external @memrosetta/core --external @memrosetta/embeddings --external @memrosetta/types --external @memrosetta/llm --external @huggingface/transformers --external sqlite-vec --external onnxruntime-node",
|
|
33
|
+
"build": "tsup src/index.ts src/hooks/on-stop.ts src/hooks/on-prompt.ts --format esm --external better-sqlite3 --external @memrosetta/core --external @memrosetta/embeddings --external @memrosetta/sync-client --external @memrosetta/types --external @memrosetta/llm --external @huggingface/transformers --external sqlite-vec --external onnxruntime-node",
|
|
33
34
|
"start": "node dist/index.js",
|
|
34
35
|
"test": "vitest run",
|
|
35
36
|
"test:watch": "vitest",
|
package/dist/chunk-MWLPPS7U.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
// src/output.ts
|
|
2
|
-
function output(data, format) {
|
|
3
|
-
if (format === "json") {
|
|
4
|
-
process.stdout.write(JSON.stringify(data) + "\n");
|
|
5
|
-
} else {
|
|
6
|
-
formatText(data);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
function outputError(message, format) {
|
|
10
|
-
if (format === "json") {
|
|
11
|
-
process.stdout.write(JSON.stringify({ error: message }) + "\n");
|
|
12
|
-
} else {
|
|
13
|
-
process.stderr.write(`Error: ${message}
|
|
14
|
-
`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
function isSearchResponse(data) {
|
|
18
|
-
return typeof data === "object" && data !== null && "results" in data && "totalCount" in data && "queryTimeMs" in data;
|
|
19
|
-
}
|
|
20
|
-
function isMemory(data) {
|
|
21
|
-
return typeof data === "object" && data !== null && "memoryId" in data && "content" in data && "memoryType" in data;
|
|
22
|
-
}
|
|
23
|
-
function formatDate(iso) {
|
|
24
|
-
return iso.slice(0, 10);
|
|
25
|
-
}
|
|
26
|
-
function formatText(data) {
|
|
27
|
-
if (isSearchResponse(data)) {
|
|
28
|
-
if (data.results.length === 0) {
|
|
29
|
-
process.stdout.write("No results found.\n");
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
for (const result of data.results) {
|
|
33
|
-
const score = result.score.toFixed(2);
|
|
34
|
-
const date = formatDate(result.memory.learnedAt);
|
|
35
|
-
const type = result.memory.memoryType;
|
|
36
|
-
process.stdout.write(
|
|
37
|
-
`[${score}] ${result.memory.content} (${type}, ${date})
|
|
38
|
-
`
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
process.stdout.write(
|
|
42
|
-
`
|
|
43
|
-
${data.totalCount} result(s) in ${data.queryTimeMs.toFixed(1)}ms
|
|
44
|
-
`
|
|
45
|
-
);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (isMemory(data)) {
|
|
49
|
-
process.stdout.write(`ID: ${data.memoryId}
|
|
50
|
-
`);
|
|
51
|
-
process.stdout.write(`Content: ${data.content}
|
|
52
|
-
`);
|
|
53
|
-
process.stdout.write(`Type: ${data.memoryType}
|
|
54
|
-
`);
|
|
55
|
-
process.stdout.write(`Date: ${formatDate(data.learnedAt)}
|
|
56
|
-
`);
|
|
57
|
-
if (data.namespace) {
|
|
58
|
-
process.stdout.write(`Namespace: ${data.namespace}
|
|
59
|
-
`);
|
|
60
|
-
}
|
|
61
|
-
if (data.keywords && data.keywords.length > 0) {
|
|
62
|
-
process.stdout.write(`Keywords: ${data.keywords.join(", ")}
|
|
63
|
-
`);
|
|
64
|
-
}
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
if (typeof data === "object" && data !== null && "count" in data) {
|
|
68
|
-
const countData = data;
|
|
69
|
-
process.stdout.write(`Count: ${countData.count}
|
|
70
|
-
`);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
if (typeof data === "string") {
|
|
74
|
-
process.stdout.write(data + "\n");
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
process.stdout.write(JSON.stringify(data, null, 2) + "\n");
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// src/engine.ts
|
|
81
|
-
import { join, dirname } from "path";
|
|
82
|
-
import { homedir } from "os";
|
|
83
|
-
import { mkdirSync, existsSync } from "fs";
|
|
84
|
-
var DEFAULT_DB = join(homedir(), ".memrosetta", "memories.db");
|
|
85
|
-
var cachedEngine = null;
|
|
86
|
-
var cachedDbPath = null;
|
|
87
|
-
async function createEngineInstance(options) {
|
|
88
|
-
const dbPath = options.db ?? DEFAULT_DB;
|
|
89
|
-
const dir = dirname(dbPath);
|
|
90
|
-
if (!existsSync(dir)) {
|
|
91
|
-
mkdirSync(dir, { recursive: true });
|
|
92
|
-
}
|
|
93
|
-
const { SqliteMemoryEngine } = await import("@memrosetta/core");
|
|
94
|
-
let embedder;
|
|
95
|
-
if (!options.noEmbeddings) {
|
|
96
|
-
try {
|
|
97
|
-
const { HuggingFaceEmbedder } = await import("@memrosetta/embeddings");
|
|
98
|
-
embedder = new HuggingFaceEmbedder();
|
|
99
|
-
await embedder.initialize();
|
|
100
|
-
} catch {
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
const engine = new SqliteMemoryEngine({ dbPath, embedder });
|
|
104
|
-
await engine.initialize();
|
|
105
|
-
return engine;
|
|
106
|
-
}
|
|
107
|
-
async function getEngine(options) {
|
|
108
|
-
const dbPath = options.db ?? DEFAULT_DB;
|
|
109
|
-
if (cachedEngine && cachedDbPath === dbPath) {
|
|
110
|
-
return cachedEngine;
|
|
111
|
-
}
|
|
112
|
-
cachedEngine = await createEngineInstance(options);
|
|
113
|
-
cachedDbPath = dbPath;
|
|
114
|
-
return cachedEngine;
|
|
115
|
-
}
|
|
116
|
-
function getDefaultDbPath() {
|
|
117
|
-
return DEFAULT_DB;
|
|
118
|
-
}
|
|
119
|
-
async function closeEngine() {
|
|
120
|
-
if (cachedEngine) {
|
|
121
|
-
await cachedEngine.close();
|
|
122
|
-
cachedEngine = null;
|
|
123
|
-
cachedDbPath = null;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export {
|
|
128
|
-
output,
|
|
129
|
-
outputError,
|
|
130
|
-
getEngine,
|
|
131
|
-
getDefaultDbPath,
|
|
132
|
-
closeEngine
|
|
133
|
-
};
|
package/dist/ingest-ZOR3XSAE.js
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
optionalOption,
|
|
3
|
-
requireOption
|
|
4
|
-
} from "./chunk-F7ZMZ6HN.js";
|
|
5
|
-
import {
|
|
6
|
-
getEngine,
|
|
7
|
-
output,
|
|
8
|
-
outputError
|
|
9
|
-
} from "./chunk-MWLPPS7U.js";
|
|
10
|
-
|
|
11
|
-
// src/commands/ingest.ts
|
|
12
|
-
import { readFileSync } from "fs";
|
|
13
|
-
function stripSystemReminders(text) {
|
|
14
|
-
let result = text;
|
|
15
|
-
while (result.includes("<system-reminder>") && result.includes("</system-reminder>")) {
|
|
16
|
-
const start = result.indexOf("<system-reminder>");
|
|
17
|
-
const end = result.indexOf("</system-reminder>") + "</system-reminder>".length;
|
|
18
|
-
result = result.slice(0, start) + result.slice(end);
|
|
19
|
-
}
|
|
20
|
-
return result.trim();
|
|
21
|
-
}
|
|
22
|
-
function extractAssistantText(content) {
|
|
23
|
-
if (typeof content === "string") {
|
|
24
|
-
return content.trim();
|
|
25
|
-
}
|
|
26
|
-
if (Array.isArray(content)) {
|
|
27
|
-
return content.filter(
|
|
28
|
-
(block) => block !== null && typeof block === "object" && block.type === "text" && typeof block.text === "string"
|
|
29
|
-
).map((block) => block.text).join("\n").trim();
|
|
30
|
-
}
|
|
31
|
-
return "";
|
|
32
|
-
}
|
|
33
|
-
function classifyTurn(turn) {
|
|
34
|
-
const lower = turn.content.toLowerCase();
|
|
35
|
-
if (turn.role === "user") {
|
|
36
|
-
if (lower.includes("decide") || lower.includes("go with") || lower.includes("let's do") || lower.includes("proceed") || lower.includes("approved")) {
|
|
37
|
-
return "decision";
|
|
38
|
-
}
|
|
39
|
-
if (lower.includes("prefer") || lower.includes("i like") || lower.includes("i want") || lower.includes("i need")) {
|
|
40
|
-
return "preference";
|
|
41
|
-
}
|
|
42
|
-
return "event";
|
|
43
|
-
}
|
|
44
|
-
return "fact";
|
|
45
|
-
}
|
|
46
|
-
function parseTranscriptContent(content) {
|
|
47
|
-
const lines = content.split("\n").filter((l) => l.trim());
|
|
48
|
-
let sessionId = "";
|
|
49
|
-
const turns = [];
|
|
50
|
-
for (const line of lines) {
|
|
51
|
-
let entry;
|
|
52
|
-
try {
|
|
53
|
-
entry = JSON.parse(line);
|
|
54
|
-
} catch {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
if (!sessionId && entry.sessionId) {
|
|
58
|
-
sessionId = entry.sessionId;
|
|
59
|
-
}
|
|
60
|
-
const msg = entry.message;
|
|
61
|
-
if (!msg || !msg.role) continue;
|
|
62
|
-
if (msg.role === "user" && typeof msg.content === "string") {
|
|
63
|
-
const clean = stripSystemReminders(msg.content);
|
|
64
|
-
if (clean && clean.length > 5) {
|
|
65
|
-
turns.push({ role: "user", content: clean });
|
|
66
|
-
}
|
|
67
|
-
} else if (msg.role === "assistant" && msg.content !== void 0) {
|
|
68
|
-
const text = extractAssistantText(
|
|
69
|
-
msg.content
|
|
70
|
-
);
|
|
71
|
-
if (text && text.length > 10) {
|
|
72
|
-
turns.push({ role: "assistant", content: text });
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return { turns, sessionId };
|
|
77
|
-
}
|
|
78
|
-
function turnsToMemories(turns, userId, namespace, sessionShort) {
|
|
79
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
80
|
-
const memories = [];
|
|
81
|
-
for (let i = 0; i < turns.length; i++) {
|
|
82
|
-
const turn = turns[i];
|
|
83
|
-
if (turn.content.length < 20) continue;
|
|
84
|
-
const content = turn.content.length > 500 ? turn.content.slice(0, 497) + "..." : turn.content;
|
|
85
|
-
memories.push({
|
|
86
|
-
userId,
|
|
87
|
-
namespace: namespace ?? `session-${sessionShort}`,
|
|
88
|
-
memoryType: classifyTurn(turn),
|
|
89
|
-
content,
|
|
90
|
-
documentDate: now,
|
|
91
|
-
sourceId: `cc-${sessionShort}-${i}`,
|
|
92
|
-
confidence: turn.role === "user" ? 0.9 : 0.8
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
return memories;
|
|
96
|
-
}
|
|
97
|
-
async function readStdin() {
|
|
98
|
-
const chunks = [];
|
|
99
|
-
for await (const chunk of process.stdin) {
|
|
100
|
-
chunks.push(chunk);
|
|
101
|
-
}
|
|
102
|
-
return Buffer.concat(chunks).toString("utf-8").trim();
|
|
103
|
-
}
|
|
104
|
-
async function run(options) {
|
|
105
|
-
const { args, format, db, noEmbeddings } = options;
|
|
106
|
-
const userId = requireOption(args, "--user", "user");
|
|
107
|
-
const file = optionalOption(args, "--file");
|
|
108
|
-
const namespace = optionalOption(args, "--namespace");
|
|
109
|
-
let content;
|
|
110
|
-
if (file) {
|
|
111
|
-
try {
|
|
112
|
-
content = readFileSync(file, "utf-8");
|
|
113
|
-
} catch (err) {
|
|
114
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
115
|
-
outputError(`Failed to read file: ${msg}`, format);
|
|
116
|
-
process.exitCode = 1;
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
} else {
|
|
120
|
-
content = await readStdin();
|
|
121
|
-
}
|
|
122
|
-
if (!content) {
|
|
123
|
-
outputError("No transcript content provided", format);
|
|
124
|
-
process.exitCode = 1;
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
const parsed = parseTranscriptContent(content);
|
|
128
|
-
const sessionShort = parsed.sessionId ? parsed.sessionId.slice(0, 8) : "unknown";
|
|
129
|
-
const memories = turnsToMemories(
|
|
130
|
-
parsed.turns,
|
|
131
|
-
userId,
|
|
132
|
-
namespace,
|
|
133
|
-
sessionShort
|
|
134
|
-
);
|
|
135
|
-
if (memories.length === 0) {
|
|
136
|
-
output({ stored: 0, message: "No memories extracted from transcript" }, format);
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
const engine = await getEngine({ db, noEmbeddings });
|
|
140
|
-
const stored = await engine.storeBatch(memories);
|
|
141
|
-
output(
|
|
142
|
-
{
|
|
143
|
-
stored: stored.length,
|
|
144
|
-
sessionId: parsed.sessionId || void 0,
|
|
145
|
-
namespace: namespace ?? `session-${sessionShort}`
|
|
146
|
-
},
|
|
147
|
-
format
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
export {
|
|
151
|
-
run
|
|
152
|
-
};
|
package/dist/init-7VFBCA4O.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getDefaultDbPath,
|
|
3
|
-
getEngine,
|
|
4
|
-
output
|
|
5
|
-
} from "./chunk-MWLPPS7U.js";
|
|
6
|
-
|
|
7
|
-
// src/commands/init.ts
|
|
8
|
-
import { existsSync } from "fs";
|
|
9
|
-
async function run(options) {
|
|
10
|
-
const { format, db, noEmbeddings } = options;
|
|
11
|
-
const dbPath = db ?? getDefaultDbPath();
|
|
12
|
-
const existed = existsSync(dbPath);
|
|
13
|
-
const engine = await getEngine({ db: dbPath, noEmbeddings });
|
|
14
|
-
await engine.close();
|
|
15
|
-
output(
|
|
16
|
-
{
|
|
17
|
-
path: dbPath,
|
|
18
|
-
created: !existed,
|
|
19
|
-
message: existed ? `Database already exists at ${dbPath}` : `Database initialized at ${dbPath}`
|
|
20
|
-
},
|
|
21
|
-
format
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
export {
|
|
25
|
-
run
|
|
26
|
-
};
|