@memrosetta/cli 0.4.2 → 0.4.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-YXK6FDB6.js +42 -0
- package/dist/index.js +2 -2
- package/dist/status-HLKL32NP.js +184 -0
- package/dist/update-4F3YY2HU.js +79 -0
- package/package.json +1 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/version.ts
|
|
2
|
+
import { existsSync, readFileSync } from "fs";
|
|
3
|
+
import { dirname, join } from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import { createRequire } from "module";
|
|
6
|
+
function resolveCliVersion() {
|
|
7
|
+
const strategies = [
|
|
8
|
+
() => {
|
|
9
|
+
const require2 = createRequire(import.meta.url);
|
|
10
|
+
return require2("../../package.json").version;
|
|
11
|
+
},
|
|
12
|
+
() => {
|
|
13
|
+
const require2 = createRequire(import.meta.url);
|
|
14
|
+
return require2("@memrosetta/cli/package.json").version;
|
|
15
|
+
},
|
|
16
|
+
() => {
|
|
17
|
+
const dir = dirname(fileURLToPath(import.meta.url));
|
|
18
|
+
for (let d = dir, i = 0; i < 5; i++) {
|
|
19
|
+
const candidate = join(d, "package.json");
|
|
20
|
+
if (existsSync(candidate)) {
|
|
21
|
+
const pkg = JSON.parse(readFileSync(candidate, "utf-8"));
|
|
22
|
+
if (pkg.name?.includes("memrosetta") && pkg.version) {
|
|
23
|
+
return pkg.version;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
d = dirname(d);
|
|
27
|
+
}
|
|
28
|
+
throw new Error("not found");
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
for (const strategy of strategies) {
|
|
32
|
+
try {
|
|
33
|
+
return strategy();
|
|
34
|
+
} catch {
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return "unknown";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
resolveCliVersion
|
|
42
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -165,7 +165,7 @@ async function main() {
|
|
|
165
165
|
break;
|
|
166
166
|
}
|
|
167
167
|
case "status": {
|
|
168
|
-
const mod = await import("./status-
|
|
168
|
+
const mod = await import("./status-HLKL32NP.js");
|
|
169
169
|
await mod.run(commandOptions);
|
|
170
170
|
break;
|
|
171
171
|
}
|
|
@@ -180,7 +180,7 @@ async function main() {
|
|
|
180
180
|
break;
|
|
181
181
|
}
|
|
182
182
|
case "update": {
|
|
183
|
-
const mod = await import("./update-
|
|
183
|
+
const mod = await import("./update-4F3YY2HU.js");
|
|
184
184
|
await mod.run();
|
|
185
185
|
break;
|
|
186
186
|
}
|
|
@@ -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-72IW6TAV.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,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveCliVersion
|
|
3
|
+
} from "./chunk-YXK6FDB6.js";
|
|
4
|
+
|
|
5
|
+
// src/commands/update.ts
|
|
6
|
+
import { execSync } from "child_process";
|
|
7
|
+
function parseNpmList(raw) {
|
|
8
|
+
const start = raw.indexOf("{");
|
|
9
|
+
if (start === -1) return {};
|
|
10
|
+
try {
|
|
11
|
+
return JSON.parse(raw.slice(start));
|
|
12
|
+
} catch {
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function getInstalledVersion(packageName) {
|
|
17
|
+
try {
|
|
18
|
+
const raw = execSync(`npm list -g ${packageName} --depth=0 --json`, {
|
|
19
|
+
encoding: "utf-8",
|
|
20
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
21
|
+
});
|
|
22
|
+
const parsed = parseNpmList(raw);
|
|
23
|
+
const deps = parsed.dependencies ?? {};
|
|
24
|
+
return deps[packageName]?.version ?? null;
|
|
25
|
+
} catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async function run() {
|
|
30
|
+
const runningVersion = resolveCliVersion();
|
|
31
|
+
const wrapperInstalled = getInstalledVersion("memrosetta");
|
|
32
|
+
const cliInstalled = getInstalledVersion("@memrosetta/cli");
|
|
33
|
+
let packageName;
|
|
34
|
+
let currentVersion;
|
|
35
|
+
if (wrapperInstalled) {
|
|
36
|
+
packageName = "memrosetta";
|
|
37
|
+
currentVersion = wrapperInstalled;
|
|
38
|
+
} else if (cliInstalled) {
|
|
39
|
+
packageName = "@memrosetta/cli";
|
|
40
|
+
currentVersion = cliInstalled;
|
|
41
|
+
} else {
|
|
42
|
+
packageName = "memrosetta";
|
|
43
|
+
currentVersion = runningVersion;
|
|
44
|
+
}
|
|
45
|
+
process.stdout.write(`Current version: ${currentVersion} (${packageName})
|
|
46
|
+
`);
|
|
47
|
+
if (currentVersion !== runningVersion && runningVersion !== "unknown") {
|
|
48
|
+
process.stdout.write(`Running binary: ${runningVersion}
|
|
49
|
+
`);
|
|
50
|
+
}
|
|
51
|
+
process.stdout.write("Checking for updates...\n");
|
|
52
|
+
try {
|
|
53
|
+
const latest = execSync(`npm view ${packageName} version`, {
|
|
54
|
+
encoding: "utf-8"
|
|
55
|
+
}).trim();
|
|
56
|
+
if (latest === currentVersion) {
|
|
57
|
+
process.stdout.write(`Already up to date (${currentVersion}).
|
|
58
|
+
`);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
process.stdout.write(`New version available: ${latest}
|
|
62
|
+
`);
|
|
63
|
+
process.stdout.write("Updating...\n");
|
|
64
|
+
execSync(`npm install -g ${packageName}@latest --force`, {
|
|
65
|
+
stdio: "inherit"
|
|
66
|
+
});
|
|
67
|
+
process.stdout.write(`
|
|
68
|
+
Updated: ${currentVersion} -> ${latest}
|
|
69
|
+
`);
|
|
70
|
+
} catch (err) {
|
|
71
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
72
|
+
process.stderr.write(`Update failed: ${message}
|
|
73
|
+
`);
|
|
74
|
+
process.exitCode = 1;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
run
|
|
79
|
+
};
|