@mingxy/cerebro 1.20.1 → 1.20.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/index.ts +10 -8
- package/src/logger.ts +3 -3
- package/src/updater.ts +2 -3
- package/src/web-server.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mingxy/cerebro",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.3",
|
|
4
4
|
"description": "Cerebro persistent memory plugin for OpenCode — auto-recall, auto-capture, 9 memory tools with clustering, project-scoped memory isolation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
package/src/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { join, dirname } from "node:path";
|
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { CerebroClient } from "./client.js";
|
|
7
|
-
import { chatMessageRecallHook, autocontinueHook, compactingHook, sessionIdleHook,
|
|
7
|
+
import { chatMessageRecallHook, autocontinueHook, compactingHook, sessionIdleHook, sessionMessages, firstMessages, showToast } from "./hooks.js";
|
|
8
8
|
import { detectSaveKeyword, detectRecallKeyword, KEYWORD_NUDGE, RECALL_NUDGE } from "./keywords.js";
|
|
9
9
|
import { getUserTag, getProjectTag } from "./tags.js";
|
|
10
10
|
import { buildTools } from "./tools.js";
|
|
@@ -64,7 +64,7 @@ const OmemPlugin: Plugin = async (input) => {
|
|
|
64
64
|
} catch {}
|
|
65
65
|
|
|
66
66
|
const config = loadPluginConfig(overrides as any);
|
|
67
|
-
const
|
|
67
|
+
const STARTUP_DELAY = 2000;
|
|
68
68
|
|
|
69
69
|
setOpencodeClient(client);
|
|
70
70
|
|
|
@@ -78,18 +78,20 @@ const OmemPlugin: Plugin = async (input) => {
|
|
|
78
78
|
logError(`Connection failed: ${errMsg}`);
|
|
79
79
|
if (errMsg.includes("[cerebro]")) {
|
|
80
80
|
const cleanMsg = errMsg.replace(/^\[cerebro\]\s*/, "");
|
|
81
|
-
|
|
81
|
+
showToast(
|
|
82
82
|
tui,
|
|
83
83
|
`🧠 Cerebro v${pluginVersion} · Server Error`,
|
|
84
84
|
cleanMsg.substring(0, 150),
|
|
85
|
-
"error"
|
|
85
|
+
"error",
|
|
86
|
+
STARTUP_DELAY
|
|
86
87
|
);
|
|
87
88
|
} else {
|
|
88
|
-
|
|
89
|
+
showToast(
|
|
89
90
|
tui,
|
|
90
91
|
`🧠 Cerebro v${pluginVersion} · Connection Failed`,
|
|
91
92
|
`Unable to reach ${config.connection.apiUrl}`,
|
|
92
|
-
"error"
|
|
93
|
+
"error",
|
|
94
|
+
STARTUP_DELAY
|
|
93
95
|
);
|
|
94
96
|
}
|
|
95
97
|
}
|
|
@@ -125,9 +127,9 @@ const OmemPlugin: Plugin = async (input) => {
|
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
if (webPort) {
|
|
128
|
-
|
|
130
|
+
showToast(tui, `🧠 Cerebro Connected · v${pluginVersion}`, `🌐 Open in browser http://localhost:${webPort}`, "success", STARTUP_DELAY);
|
|
129
131
|
} else {
|
|
130
|
-
|
|
132
|
+
showToast(tui, `🧠 Cerebro Connected · v${pluginVersion}`, "No web server", "success", STARTUP_DELAY);
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
// Auto-update check (fire-and-forget, non-blocking)
|
package/src/logger.ts
CHANGED
|
@@ -138,11 +138,11 @@ function writeLog(level: string, message: string, fields?: Record<string, unknow
|
|
|
138
138
|
appendFileSync(logFile, parts.join(" ") + "\n");
|
|
139
139
|
} catch {}
|
|
140
140
|
|
|
141
|
-
// Track 2: opencode client
|
|
141
|
+
// Track 2: opencode client (async — fire-and-forget with .catch)
|
|
142
142
|
try {
|
|
143
143
|
opencodeClient?.app?.log({
|
|
144
|
-
body: { service: "cerebro", level: level.toLowerCase(), message, extra: fields },
|
|
145
|
-
});
|
|
144
|
+
body: { service: "cerebro", level: level.toLowerCase() as "debug" | "info" | "warn" | "error", message, extra: fields },
|
|
145
|
+
})?.catch?.(() => {});
|
|
146
146
|
} catch { /* opencode client not available, skip */ }
|
|
147
147
|
}
|
|
148
148
|
|
package/src/updater.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { homedir, tmpdir } from "node:os";
|
|
|
6
6
|
import { openSync, closeSync, unlinkSync, statSync, writeSync, mkdtempSync, readdirSync, rmSync } from "node:fs";
|
|
7
7
|
import { loadPluginConfig } from "./config.js";
|
|
8
8
|
import { logInfo, logDebug, logError } from "./logger.js";
|
|
9
|
+
import { showToast } from "./hooks.js";
|
|
9
10
|
|
|
10
11
|
const execFileAsync = promisify(execFile);
|
|
11
12
|
const require = createRequire(import.meta.url);
|
|
@@ -142,9 +143,7 @@ export async function checkAndUpdate(tui: any, currentVersion: string): Promise<
|
|
|
142
143
|
if (success) {
|
|
143
144
|
logInfo("updater: update completed", { from: currentVersion, to: latest });
|
|
144
145
|
try {
|
|
145
|
-
|
|
146
|
-
body: { message: `Cerebro updated to v${latest} — restart opencode to apply`, variant: "info" }
|
|
147
|
-
});
|
|
146
|
+
showToast(tui, "🧠 Cerebro Updated", `v${currentVersion} → v${latest} · restart opencode to apply`, "info", 2000);
|
|
148
147
|
} catch {}
|
|
149
148
|
} else {
|
|
150
149
|
logError("updater: update failed", { targetDir });
|
package/src/web-server.ts
CHANGED
|
@@ -119,9 +119,13 @@ export async function startWebServer(
|
|
|
119
119
|
const childJs = path.resolve(__dirname, "web-server-child.js");
|
|
120
120
|
const childPath = fs.existsSync(childTs) ? childTs : childJs;
|
|
121
121
|
|
|
122
|
+
// Use the same executor as the parent process (tsx, node, etc.)
|
|
123
|
+
// so the child can run .ts files. Also inherit execArgv (--import tsx, etc.)
|
|
122
124
|
const child = fork(childPath, [], {
|
|
123
125
|
detached: true,
|
|
124
126
|
stdio: ["pipe", "pipe", "pipe", "ipc"],
|
|
127
|
+
execPath: process.execPath,
|
|
128
|
+
execArgv: process.execArgv,
|
|
125
129
|
});
|
|
126
130
|
|
|
127
131
|
// Drain stdout/stderr to prevent pipe buffer from blocking the child
|