@mingxy/cerebro 1.10.1 → 1.10.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mingxy/cerebro",
3
- "version": "1.10.1",
3
+ "version": "1.10.3",
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/hooks.ts CHANGED
@@ -432,9 +432,9 @@ export function compactingHook(client: OmemClient, containerTags: string[], tui:
432
432
  if (sdkClient && input.sessionID) {
433
433
  const sessionInfo = await sdkClient.session.get({ path: { id: input.sessionID } });
434
434
  logDebug("compactingHook sessionInfo", { sessionInfo: JSON.stringify(sessionInfo) });
435
- logDebug("compactingHook project.rootPath", { rootPath: sessionInfo?.project?.rootPath });
436
- projectName = sessionInfo?.project?.rootPath
437
- ? await detectProjectName(sessionInfo.project.rootPath)
435
+ logDebug("compactingHook project.rootPath", { rootPath: sessionInfo?.data?.directory });
436
+ projectName = sessionInfo?.data?.directory
437
+ ? await detectProjectName(sessionInfo.data.directory)
438
438
  : undefined;
439
439
  logDebug("compactingHook projectName", { projectName: String(projectName) });
440
440
  }
@@ -448,7 +448,7 @@ export function compactingHook(client: OmemClient, containerTags: string[], tui:
448
448
  mode: ingestMode,
449
449
  tags: [...containerTags, "auto-capture"],
450
450
  sessionId: effectiveSessionId,
451
- parentSessionId: isSubAgent ? input.sessionID : undefined,
451
+ parentSessionId: isSubAgent ? getMainSessionId?.() : undefined,
452
452
  projectName: projectName,
453
453
  });
454
454
  logDebug("compactingHook ingestMessages result", { result: result === null ? "null(blocked)" : "ok" });
@@ -557,10 +557,10 @@ export function sessionIdleHook(
557
557
  try {
558
558
  const sessionInfo = await sdkClient.session.get({ path: { id: sessionID } });
559
559
  logDebug("sessionIdleHook sessionInfo", { sessionInfo: JSON.stringify(sessionInfo) });
560
- logDebug("sessionIdleHook project.rootPath", { rootPath: sessionInfo?.project?.rootPath });
561
- sessionTitle = sessionInfo?.title;
562
- projectName = sessionInfo?.project?.rootPath
563
- ? await detectProjectName(sessionInfo.project.rootPath)
560
+ logDebug("sessionIdleHook project.rootPath", { rootPath: sessionInfo?.data?.directory });
561
+ sessionTitle = sessionInfo?.data?.title;
562
+ projectName = sessionInfo?.data?.directory
563
+ ? await detectProjectName(sessionInfo.data.directory)
564
564
  : undefined;
565
565
  logDebug("sessionIdleHook projectName", { projectName: String(projectName) });
566
566
  } catch (e) {
package/src/logger.ts CHANGED
@@ -2,6 +2,15 @@ import { appendFileSync, mkdirSync, existsSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import { join } from "node:path";
4
4
 
5
+ const LEVEL_MAP: Record<string, number> = {
6
+ DEBUG: 0,
7
+ INFO: 1,
8
+ WARN: 2,
9
+ ERROR: 3,
10
+ };
11
+
12
+ const MIN_LEVEL = LEVEL_MAP[process.env.OMEM_LOG_LEVEL?.toUpperCase() ?? ""] ?? LEVEL_MAP.INFO;
13
+
5
14
  const LOG_DIR = join(homedir(), ".config", "ourmem");
6
15
  const LOG_FILE = join(LOG_DIR, "plugin.log");
7
16
 
@@ -16,6 +25,8 @@ function ensureLogDir(): void {
16
25
  }
17
26
 
18
27
  function writeLog(level: string, message: string, fields?: Record<string, unknown>): void {
28
+ const lvl = LEVEL_MAP[level] ?? 0;
29
+ if (lvl < MIN_LEVEL) return;
19
30
  ensureLogDir();
20
31
  const now = new Date();
21
32
  const ts = now.toISOString().replace("T", " ").replace(/\.\d+Z$/, "");