@mingxy/cerebro 1.7.5 → 1.7.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mingxy/cerebro",
3
- "version": "1.7.5",
3
+ "version": "1.7.6",
4
4
  "description": "Cerebro persistent memory plugin for OpenCode — auto-recall, auto-capture, 9 memory tools with clustering",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/index.ts CHANGED
@@ -23,7 +23,10 @@ try {
23
23
 
24
24
  // Per-session auto-store toggle: sessionId → enabled (default: true = auto-store on)
25
25
  const autoStoreSessions = new Map<string, boolean>();
26
- const STATE_FILE = join(tmpdir(), "cerebro_autostore.json");
26
+
27
+ function getStateFilePath(sessionId: string): string {
28
+ return join(tmpdir(), `cerebro_autostore_${sessionId}.json`);
29
+ }
27
30
 
28
31
  export function isAutoStoreEnabled(sessionId: string | undefined): boolean {
29
32
  if (!sessionId) return true;
@@ -33,9 +36,7 @@ export function isAutoStoreEnabled(sessionId: string | undefined): boolean {
33
36
  export function setAutoStoreEnabled(sessionId: string, enabled: boolean): void {
34
37
  autoStoreSessions.set(sessionId, enabled);
35
38
  try {
36
- const obj: Record<string, boolean> = {};
37
- for (const [k, v] of autoStoreSessions) obj[k] = v;
38
- writeFileSync(STATE_FILE, JSON.stringify(obj));
39
+ writeFileSync(getStateFilePath(sessionId), JSON.stringify({ enabled }));
39
40
  } catch {}
40
41
  }
41
42
 
package/src/tui.tsx CHANGED
@@ -6,15 +6,15 @@ import { readFileSync } from "node:fs";
6
6
  import { join } from "node:path";
7
7
  import { tmpdir } from "node:os";
8
8
 
9
- const STATE_FILE = join(tmpdir(), "cerebro_autostore.json");
10
9
  const id = "@mingxy/cerebro";
11
10
  const SIDEBAR_ORDER = 160;
12
11
 
13
12
  function readAutoStoreFromFile(sessionId: string | undefined): boolean {
14
13
  if (!sessionId) return true;
15
14
  try {
16
- const data = JSON.parse(readFileSync(STATE_FILE, "utf-8"));
17
- return data[sessionId] ?? true;
15
+ const filePath = join(tmpdir(), `cerebro_autostore_${sessionId}.json`);
16
+ const data = JSON.parse(readFileSync(filePath, "utf-8"));
17
+ return data.enabled ?? true;
18
18
  } catch {
19
19
  return true;
20
20
  }