@mingxy/cerebro 1.10.10 → 1.10.12

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.10",
3
+ "version": "1.10.12",
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/config.ts CHANGED
@@ -145,12 +145,12 @@ function deepMerge(base: OmemPluginConfig, overrides: Partial<OmemPluginConfig>)
145
145
  // ── Load config ──────────────────────────────────────────────────────
146
146
 
147
147
  /** File-only logger for config.ts (cannot import logger.ts due to circular dependency). */
148
- function configLog(message: string, fields?: Record<string, unknown>): void {
148
+ function configLog(message: string, fields?: Record<string, unknown>, level: string = "WARN"): void {
149
149
  try {
150
150
  const logDir = join(homedir(), ".config", "cerebro", "logs");
151
151
  const logPath = join(logDir, "plugin.log");
152
152
  const ts = new Date().toISOString().replace("T", " ").replace(/\.\d+Z$/, "");
153
- const parts = [`WARN ${ts} service=cerebro ${message}`];
153
+ const parts = [`${level.padEnd(5)} ${ts} service=cerebro ${message}`];
154
154
  if (fields) {
155
155
  for (const [k, v] of Object.entries(fields)) {
156
156
  parts.push(`${k}=${typeof v === "string" ? v : JSON.stringify(v)}`);
@@ -232,7 +232,7 @@ export function resolveAgentPolicy(
232
232
  }
233
233
  }
234
234
  if (config.defaultPolicy) return config.defaultPolicy;
235
- configLog("resolveAgentPolicy: no policy configured, defaulting to readwrite", { agentName });
235
+ configLog("resolveAgentPolicy: defaulting to readwrite", { agentName }, "DEBUG");
236
236
  return "readwrite";
237
237
  }
238
238
 
package/src/hooks.ts CHANGED
@@ -250,7 +250,7 @@ function buildClusteredContextBlock(clustered: import("./client.js").ClusteredRe
250
250
  ].join("\n");
251
251
  }
252
252
 
253
- export function autoRecallHook(client: CerebroClient, containerTags: string[], tui: any, config: Partial<OmemPluginConfig> = {}) {
253
+ export function autoRecallHook(client: CerebroClient, containerTags: string[], tui: any, config: Partial<OmemPluginConfig> = {}, getAgentName?: () => string) {
254
254
  const similarityThreshold = config.recall?.similarityThreshold ?? 0.4;
255
255
  const maxRecallResults = config.recall?.maxRecallResults ?? 10;
256
256
  const maxContentLength = Math.max(MIN_CONTENT_LENGTH, config.content?.maxContentLength ?? 500);
@@ -264,7 +264,7 @@ export function autoRecallHook(client: CerebroClient, containerTags: string[], t
264
264
  if (!input.sessionID) return;
265
265
 
266
266
  // 5a: agent memory policy check — skip recall entirely for 'none' agents
267
- const agentId = process.env.OMEM_AGENT_ID || "opencode";
267
+ const agentId = getAgentName?.() || process.env.OMEM_AGENT_ID || "opencode";
268
268
  const policy = resolveAgentPolicy(agentId, config);
269
269
  if (policy === "none") return;
270
270
 
package/src/index.ts CHANGED
@@ -119,7 +119,7 @@ const OmemPlugin: Plugin = async (input) => {
119
119
  let mainSessionLocked = false;
120
120
  let cachedAgentName: string | undefined;
121
121
 
122
- const recallHook = autoRecallHook(cerebroClient, containerTags, tui, config);
122
+ const recallHook = autoRecallHook(cerebroClient, containerTags, tui, config, () => cachedAgentName || agentId);
123
123
 
124
124
  return {
125
125
  config: async (cfg: any) => {