@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 +1 -1
- package/src/hooks.ts +8 -8
- package/src/logger.ts +11 -0
package/package.json
CHANGED
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?.
|
|
436
|
-
projectName = sessionInfo?.
|
|
437
|
-
? await detectProjectName(sessionInfo.
|
|
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 ?
|
|
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?.
|
|
561
|
-
sessionTitle = sessionInfo?.title;
|
|
562
|
-
projectName = sessionInfo?.
|
|
563
|
-
? await detectProjectName(sessionInfo.
|
|
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$/, "");
|