memorix 1.0.0 → 1.0.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.
- package/CHANGELOG.md +87 -0
- package/CLAUDE.md +10 -1
- package/README.md +14 -28
- package/README.zh-CN.md +43 -32
- package/dist/cli/index.js +40 -17
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +36 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -451,7 +451,7 @@ var init_persistence = __esm({
|
|
|
451
451
|
"use strict";
|
|
452
452
|
init_esm_shims();
|
|
453
453
|
init_file_lock();
|
|
454
|
-
DEFAULT_DATA_DIR = path3.join(os.homedir(), ".memorix", "data");
|
|
454
|
+
DEFAULT_DATA_DIR = process.env.MEMORIX_DATA_DIR || path3.join(os.homedir(), ".memorix", "data");
|
|
455
455
|
}
|
|
456
456
|
});
|
|
457
457
|
|
|
@@ -604,7 +604,7 @@ var init_fastembed_provider = __esm({
|
|
|
604
604
|
"src/embedding/fastembed-provider.ts"() {
|
|
605
605
|
"use strict";
|
|
606
606
|
init_esm_shims();
|
|
607
|
-
CACHE_DIR = join2(homedir2(), ".memorix", "data");
|
|
607
|
+
CACHE_DIR = process.env.MEMORIX_DATA_DIR || join2(homedir2(), ".memorix", "data");
|
|
608
608
|
CACHE_FILE = join2(CACHE_DIR, ".embedding-cache.json");
|
|
609
609
|
cache = /* @__PURE__ */ new Map();
|
|
610
610
|
MAX_CACHE_SIZE = 5e3;
|
|
@@ -861,7 +861,7 @@ var init_api_provider = __esm({
|
|
|
861
861
|
"src/embedding/api-provider.ts"() {
|
|
862
862
|
"use strict";
|
|
863
863
|
init_esm_shims();
|
|
864
|
-
CACHE_DIR2 = join3(homedir3(), ".memorix", "data");
|
|
864
|
+
CACHE_DIR2 = process.env.MEMORIX_DATA_DIR || join3(homedir3(), ".memorix", "data");
|
|
865
865
|
CACHE_FILE2 = join3(CACHE_DIR2, ".embedding-api-cache.json");
|
|
866
866
|
cache3 = /* @__PURE__ */ new Map();
|
|
867
867
|
MAX_CACHE_SIZE3 = 1e4;
|
|
@@ -1618,7 +1618,7 @@ var init_aliases = __esm({
|
|
|
1618
1618
|
"src/project/aliases.ts"() {
|
|
1619
1619
|
"use strict";
|
|
1620
1620
|
init_esm_shims();
|
|
1621
|
-
DEFAULT_DATA_DIR2 = path4.join(os2.homedir(), ".memorix", "data");
|
|
1621
|
+
DEFAULT_DATA_DIR2 = process.env.MEMORIX_DATA_DIR || path4.join(os2.homedir(), ".memorix", "data");
|
|
1622
1622
|
ALIAS_FILE = ".project-aliases.json";
|
|
1623
1623
|
registryCache = null;
|
|
1624
1624
|
registryDir = null;
|
|
@@ -2556,8 +2556,8 @@ async function upsertObservation(existing, input, now) {
|
|
|
2556
2556
|
status: "active"
|
|
2557
2557
|
};
|
|
2558
2558
|
try {
|
|
2559
|
-
const { removeObservation:
|
|
2560
|
-
await
|
|
2559
|
+
const { removeObservation: removeObservation3 } = await Promise.resolve().then(() => (init_orama_store(), orama_store_exports));
|
|
2560
|
+
await removeObservation3(`obs-${existing.id}`);
|
|
2561
2561
|
} catch {
|
|
2562
2562
|
}
|
|
2563
2563
|
await insertObservation(doc);
|
|
@@ -2696,6 +2696,7 @@ function suggestTopicKey(type, title) {
|
|
|
2696
2696
|
}
|
|
2697
2697
|
async function reindexObservations() {
|
|
2698
2698
|
if (observations.length === 0) return 0;
|
|
2699
|
+
await resetDb();
|
|
2699
2700
|
let embeddings = [];
|
|
2700
2701
|
if (isEmbeddingEnabled()) {
|
|
2701
2702
|
try {
|
|
@@ -2711,8 +2712,9 @@ async function reindexObservations() {
|
|
|
2711
2712
|
const obs = observations[i];
|
|
2712
2713
|
try {
|
|
2713
2714
|
const embedding = embeddings[i] ?? null;
|
|
2715
|
+
const docId = `obs-${obs.id}`;
|
|
2714
2716
|
const doc = {
|
|
2715
|
-
id:
|
|
2717
|
+
id: docId,
|
|
2716
2718
|
observationId: obs.id,
|
|
2717
2719
|
entityName: obs.entityName,
|
|
2718
2720
|
type: obs.type,
|
|
@@ -5181,10 +5183,12 @@ function generateOpenCodePlugin() {
|
|
|
5181
5183
|
* Docs: https://github.com/AVIDS2/memorix
|
|
5182
5184
|
*/
|
|
5183
5185
|
export const MemorixPlugin = async ({ project, client, $, directory, worktree }) => {
|
|
5184
|
-
|
|
5186
|
+
// Generate a stable session ID for this plugin lifetime
|
|
5187
|
+
const sessionId = \`opencode-\${Date.now().toString(36)}-\${Math.random().toString(36).slice(2, 8)}\`;
|
|
5185
5188
|
|
|
5186
5189
|
/** Pipe event JSON to memorix hook via temp file (Windows .cmd stdin workaround) */
|
|
5187
5190
|
async function runHook(payload) {
|
|
5191
|
+
payload.session_id = sessionId;
|
|
5188
5192
|
const tmpDir = Bun.env.TEMP || Bun.env.TMP || '/tmp';
|
|
5189
5193
|
const tmpPath = \`\${tmpDir}/memorix-hook-\${Date.now()}.json\`;
|
|
5190
5194
|
try {
|
|
@@ -5192,9 +5196,8 @@ export const MemorixPlugin = async ({ project, client, $, directory, worktree })
|
|
|
5192
5196
|
await Bun.write(tmpPath, data);
|
|
5193
5197
|
// cat | pipe works through .cmd wrappers; < redirect does NOT
|
|
5194
5198
|
await $\`cat \${tmpPath} | memorix hook\`.quiet().nothrow();
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
console.log('[memorix] hook error:', err?.message ?? err);
|
|
5199
|
+
} catch {
|
|
5200
|
+
// Silent \u2014 hooks must never break the agent
|
|
5198
5201
|
} finally {
|
|
5199
5202
|
try { const { unlinkSync } = await import('node:fs'); unlinkSync(tmpPath); } catch {}
|
|
5200
5203
|
}
|
|
@@ -8335,7 +8338,7 @@ async function createMemorixServer(cwd, existingServer, sharedTeam) {
|
|
|
8335
8338
|
let syncAdvisory = null;
|
|
8336
8339
|
const server = existingServer ?? new McpServer({
|
|
8337
8340
|
name: "memorix",
|
|
8338
|
-
version: "0.1.0"
|
|
8341
|
+
version: true ? "1.0.2" : "1.0.1"
|
|
8339
8342
|
});
|
|
8340
8343
|
server.registerTool(
|
|
8341
8344
|
"memorix_store",
|
|
@@ -9982,12 +9985,32 @@ ${lines.join("\n")}` }] };
|
|
|
9982
9985
|
}
|
|
9983
9986
|
if (autoInstall) {
|
|
9984
9987
|
const { getHookStatus: getHookStatus2, installHooks: installHooks2, detectInstalledAgents: detectInstalledAgents2 } = await Promise.resolve().then(() => (init_installers(), installers_exports));
|
|
9988
|
+
const { join: join17 } = await import("path");
|
|
9989
|
+
const { access: access2 } = await import("fs/promises");
|
|
9985
9990
|
const workDir = cwd ?? process.cwd();
|
|
9986
9991
|
const statuses = await getHookStatus2(workDir);
|
|
9987
9992
|
const installedAgents = new Set(statuses.filter((s) => s.installed).map((s) => s.agent));
|
|
9988
9993
|
const detectedAgents = await detectInstalledAgents2();
|
|
9994
|
+
const AGENT_MARKER_DIR = {
|
|
9995
|
+
claude: ".claude",
|
|
9996
|
+
windsurf: ".windsurf",
|
|
9997
|
+
cursor: ".cursor",
|
|
9998
|
+
copilot: ".vscode",
|
|
9999
|
+
opencode: ".opencode",
|
|
10000
|
+
kiro: ".kiro",
|
|
10001
|
+
antigravity: ".gemini",
|
|
10002
|
+
trae: ".trae"
|
|
10003
|
+
};
|
|
9989
10004
|
for (const agent of detectedAgents) {
|
|
9990
10005
|
if (installedAgents.has(agent)) continue;
|
|
10006
|
+
const markerDir = AGENT_MARKER_DIR[agent];
|
|
10007
|
+
if (markerDir) {
|
|
10008
|
+
try {
|
|
10009
|
+
await access2(join17(workDir, markerDir));
|
|
10010
|
+
} catch {
|
|
10011
|
+
continue;
|
|
10012
|
+
}
|
|
10013
|
+
}
|
|
9991
10014
|
try {
|
|
9992
10015
|
const config = await installHooks2(agent, workDir);
|
|
9993
10016
|
console.error(`[memorix] Auto-installed hooks for ${agent} \u2192 ${config.configPath}`);
|
|
@@ -10067,7 +10090,7 @@ ${lines.join("\n")}` }] };
|
|
|
10067
10090
|
try {
|
|
10068
10091
|
const older = group[i], newer = group[i + 1];
|
|
10069
10092
|
const decision = await deduplicateMemory2(
|
|
10070
|
-
{
|
|
10093
|
+
{ title: newer.title, narrative: newer.narrative, facts: newer.facts },
|
|
10071
10094
|
[{ id: older.id, title: older.title, narrative: older.narrative, facts: older.facts.join("\n") }]
|
|
10072
10095
|
);
|
|
10073
10096
|
if (decision && (decision.action === "UPDATE" || decision.action === "NONE")) {
|