@mingxy/cerebro 1.6.5 → 1.6.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 +1 -1
- package/src/hooks.ts +3 -1
- package/src/index.ts +12 -4
- package/src/tui.tsx +6 -7
package/package.json
CHANGED
package/src/hooks.ts
CHANGED
|
@@ -8,7 +8,9 @@ function showToast(tui: any, title: string, message: string, variant: string = "
|
|
|
8
8
|
setTimeout(() => {
|
|
9
9
|
try {
|
|
10
10
|
tui.showToast({ body: { title, message, variant, duration: 5000 } });
|
|
11
|
-
} catch {
|
|
11
|
+
} catch (err) {
|
|
12
|
+
console.error("[cerebro] showToast failed:", err);
|
|
13
|
+
}
|
|
12
14
|
}, delayMs);
|
|
13
15
|
}
|
|
14
16
|
|
package/src/index.ts
CHANGED
|
@@ -35,18 +35,26 @@ export function setAutoStoreEnabled(sessionId: string, enabled: boolean): void {
|
|
|
35
35
|
// Bridge for TUI plugin (same process, different module graph)
|
|
36
36
|
(globalThis as any).__cerebro_autoStore = isAutoStoreEnabled;
|
|
37
37
|
|
|
38
|
-
function showToast(tui: any, title: string, message
|
|
38
|
+
function showToast(tui: any, title: string, message: string, variant: string = "info", duration: number = 5000) {
|
|
39
39
|
if (!tui) return;
|
|
40
40
|
setTimeout(() => {
|
|
41
41
|
try {
|
|
42
42
|
tui.showToast({ body: { title, message, variant, duration } });
|
|
43
|
-
} catch {
|
|
43
|
+
} catch (err) {
|
|
44
|
+
console.error("[cerebro] showToast failed:", err);
|
|
45
|
+
}
|
|
44
46
|
}, 3000);
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
const OmemPlugin: Plugin = async (input) => {
|
|
48
50
|
const { directory, client } = input;
|
|
49
|
-
|
|
51
|
+
// Proxy: dynamically resolve client.tui on each access so toast works
|
|
52
|
+
// even if client.tui isn't ready yet at plugin init time
|
|
53
|
+
const tui = new Proxy({} as any, {
|
|
54
|
+
get(_, prop) {
|
|
55
|
+
return (client as any)?.tui?.[prop];
|
|
56
|
+
},
|
|
57
|
+
});
|
|
50
58
|
|
|
51
59
|
// Load overrides from opencode.json plugin_config
|
|
52
60
|
let overrides: Record<string, unknown> = {};
|
|
@@ -63,7 +71,7 @@ const OmemPlugin: Plugin = async (input) => {
|
|
|
63
71
|
// 启动时检测连接状态
|
|
64
72
|
try {
|
|
65
73
|
await omemClient.getStats();
|
|
66
|
-
showToast(tui, `🧠 Cerebro v${pluginVersion} · Connected`,
|
|
74
|
+
showToast(tui, `🧠 Cerebro v${pluginVersion} · Connected`, `Connected to ${config.apiUrl.replace(/^https?:\/\//, "")}`, "success", 6000);
|
|
67
75
|
logInfo(`Connected to ${config.apiUrl}`);
|
|
68
76
|
} catch (err) {
|
|
69
77
|
const errMsg = err instanceof Error ? err.message : String(err);
|
package/src/tui.tsx
CHANGED
|
@@ -38,21 +38,20 @@ function SidebarContentView(props: {
|
|
|
38
38
|
for (const unsubscribe of unsubscribers) unsubscribe();
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
const enabled = autoStore();
|
|
42
|
-
const t = theme();
|
|
43
|
-
|
|
44
41
|
return (
|
|
45
42
|
<box gap={0}>
|
|
43
|
+
<text fg={theme()?.text} wrapMode="none">
|
|
44
|
+
Cerebro
|
|
45
|
+
</text>
|
|
46
46
|
<box flexDirection="row" gap={1}>
|
|
47
47
|
<text
|
|
48
48
|
flexShrink={0}
|
|
49
|
-
style={{ fg:
|
|
49
|
+
style={{ fg: autoStore() ? theme()?.success : theme()?.textMuted }}
|
|
50
50
|
>
|
|
51
51
|
•
|
|
52
52
|
</text>
|
|
53
|
-
<text fg={
|
|
54
|
-
|
|
55
|
-
{"Auto-store " + (enabled ? "ON" : "OFF")}
|
|
53
|
+
<text fg={theme()?.textMuted} wrapMode="none">
|
|
54
|
+
{"Auto-store: " + (autoStore() ? "ON" : "OFF")}
|
|
56
55
|
</text>
|
|
57
56
|
</box>
|
|
58
57
|
</box>
|