echoes-vault-opencode 1.1.4 → 1.1.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/tui.tsx +112 -96
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "echoes-vault-opencode",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"description": "EchoesVault — persistent memory plugin for OpenCode. Obsidian-style knowledge base with daily logs, encyclopedia pages, and session resumption.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.ts",
|
package/tui.tsx
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/** @jsxImportSource @opentui/solid */
|
|
2
2
|
import type { TuiPlugin } from "@opencode-ai/plugin/tui"
|
|
3
|
-
import { createSignal, onCleanup
|
|
3
|
+
import { createSignal, onCleanup } from "solid-js"
|
|
4
4
|
import * as fs from "node:fs"
|
|
5
5
|
import * as path from "node:path"
|
|
6
6
|
|
|
7
|
+
console.log("[EchoesVault TUI] Module loaded")
|
|
8
|
+
|
|
7
9
|
type VaultStats = {
|
|
8
10
|
totalPages: number
|
|
9
11
|
totalDailyLogs: number
|
|
@@ -20,120 +22,134 @@ type EchoesState = {
|
|
|
20
22
|
lastStart: string | null
|
|
21
23
|
lastSave: string | null
|
|
22
24
|
}
|
|
23
|
-
stats
|
|
25
|
+
stats?: VaultStats
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
const STATE_PATH = path.join(process.cwd(), ".opencode", "echoes-state.json")
|
|
29
|
+
console.log("[EchoesVault TUI] STATE_PATH:", STATE_PATH)
|
|
27
30
|
|
|
28
31
|
const readState = (): EchoesState | null => {
|
|
29
32
|
try {
|
|
30
33
|
const raw = fs.readFileSync(STATE_PATH, "utf-8")
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
const parsed = JSON.parse(raw) as EchoesState
|
|
35
|
+
console.log("[EchoesVault TUI] State read OK, initialized:", parsed.initialized, "stats:", JSON.stringify(parsed.stats))
|
|
36
|
+
return parsed
|
|
37
|
+
} catch (e) {
|
|
38
|
+
console.log("[EchoesVault TUI] State read failed:", e)
|
|
33
39
|
return null
|
|
34
40
|
}
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
const tui: TuiPlugin = async (api) => {
|
|
44
|
+
console.log("[EchoesVault TUI] tui() called, api.theme available:", !!api.theme)
|
|
38
45
|
const theme = api.theme.current
|
|
46
|
+
console.log("[EchoesVault TUI] theme.current loaded")
|
|
39
47
|
|
|
40
|
-
|
|
41
|
-
slots
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
<text fg={theme.textMuted}> v{state()?.pluginVersion ?? ""}</text>
|
|
107
|
-
</box>
|
|
108
|
-
<text fg={statusColor()}>{statusLabel()}</text>
|
|
109
|
-
<Show when={statusDesc()}>
|
|
110
|
-
<text fg={theme.textMuted}>{statusDesc()}</text>
|
|
111
|
-
</Show>
|
|
112
|
-
<Show when={statusCmd()}>
|
|
48
|
+
try {
|
|
49
|
+
api.slots.register({
|
|
50
|
+
slots: {
|
|
51
|
+
sidebar_content() {
|
|
52
|
+
console.log("[EchoesVault TUI] sidebar_content() rendering")
|
|
53
|
+
const [state, setState] = createSignal<EchoesState | null>(readState())
|
|
54
|
+
|
|
55
|
+
const interval = setInterval(() => setState(readState()), 3000)
|
|
56
|
+
onCleanup(() => clearInterval(interval))
|
|
57
|
+
|
|
58
|
+
const statusColor = () => {
|
|
59
|
+
const s = state()
|
|
60
|
+
if (!s || !s.initialized) return theme.error
|
|
61
|
+
if (s.session.saved) return theme.accent
|
|
62
|
+
if (s.session.started) return theme.success
|
|
63
|
+
return theme.warning
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const statusLabel = () => {
|
|
67
|
+
const s = state()
|
|
68
|
+
if (!s || !s.initialized) return "Not Activated"
|
|
69
|
+
if (s.session.saved) return "Memory Saved"
|
|
70
|
+
if (s.session.started) return "Active"
|
|
71
|
+
return "Session Not Started"
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const vaultHealthColor = () => {
|
|
75
|
+
const pages = state()?.stats?.totalPages ?? 0
|
|
76
|
+
if (pages > 200) return theme.error
|
|
77
|
+
if (pages >= 170) return theme.warning
|
|
78
|
+
return theme.success
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const vaultUsagePercent = () => {
|
|
82
|
+
const pages = state()?.stats?.totalPages ?? 0
|
|
83
|
+
return Math.round((pages / 200) * 100)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const statusDesc = () => {
|
|
87
|
+
const s = state()
|
|
88
|
+
if (!s || !s.initialized) return null
|
|
89
|
+
if (s.session.saved) return "Vault memorized session data"
|
|
90
|
+
if (s.session.started) return null
|
|
91
|
+
return null
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const statusCmd = () => {
|
|
95
|
+
const s = state()
|
|
96
|
+
if (!s || !s.initialized) return "/echoes-init"
|
|
97
|
+
if (s.session.saved) return null
|
|
98
|
+
if (s.session.started) return "/echoes-end"
|
|
99
|
+
return "/echoes-start"
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const statusCmdHint = () => {
|
|
103
|
+
const s = state()
|
|
104
|
+
if (!s || !s.initialized) return "to activate vault"
|
|
105
|
+
if (s.session.saved) return null
|
|
106
|
+
if (s.session.started) return "before closing"
|
|
107
|
+
return "to load context"
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
console.log("[EchoesVault TUI] About to return JSX")
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<box flexDirection="column">
|
|
113
114
|
<box flexDirection="row">
|
|
114
|
-
<text fg={
|
|
115
|
-
<text fg={theme.
|
|
116
|
-
<text fg={theme.
|
|
115
|
+
<text fg={statusColor()}><b>• </b></text>
|
|
116
|
+
<text fg={theme.textMuted}><b>Echoes</b></text>
|
|
117
|
+
<text fg={theme.text}><b>Vault</b></text>
|
|
118
|
+
<text fg={theme.textMuted}> v{state()?.pluginVersion ?? ""}</text>
|
|
117
119
|
</box>
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
<text fg={statusColor()}>{statusLabel()}</text>
|
|
121
|
+
{statusDesc() && (
|
|
122
|
+
<text fg={theme.textMuted}>{statusDesc()}</text>
|
|
123
|
+
)}
|
|
124
|
+
{statusCmd() && (
|
|
121
125
|
<box flexDirection="row">
|
|
122
|
-
<text fg={
|
|
123
|
-
<text fg={theme.text}
|
|
126
|
+
<text fg={theme.textMuted}>Run </text>
|
|
127
|
+
<text fg={theme.text}>{statusCmd()}</text>
|
|
128
|
+
<text fg={theme.textMuted}> {statusCmdHint()}</text>
|
|
124
129
|
</box>
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
<
|
|
128
|
-
<
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
)}
|
|
131
|
+
{state()?.initialized ? (
|
|
132
|
+
<box flexDirection="column">
|
|
133
|
+
<box flexDirection="row">
|
|
134
|
+
<text fg={vaultHealthColor()}>{"• "}</text>
|
|
135
|
+
<text fg={theme.text}><b>Vault Health</b></text>
|
|
136
|
+
</box>
|
|
137
|
+
<text fg={theme.textMuted}>{" Pages: "}{state()?.stats?.totalPages ?? 0}</text>
|
|
138
|
+
<text fg={theme.textMuted}>{" Usage: "}{vaultUsagePercent()}{"%"}</text>
|
|
139
|
+
{(state()?.stats?.totalPages ?? 0) > 200 ? (
|
|
140
|
+
<text fg={theme.textMuted}>{" Consider migrating to RAG"}</text>
|
|
141
|
+
) : null}
|
|
142
|
+
</box>
|
|
143
|
+
) : null}
|
|
144
|
+
</box>
|
|
145
|
+
)
|
|
146
|
+
},
|
|
134
147
|
},
|
|
135
|
-
}
|
|
136
|
-
|
|
148
|
+
})
|
|
149
|
+
console.log("[EchoesVault TUI] slots.register() OK")
|
|
150
|
+
} catch (e) {
|
|
151
|
+
console.error("[EchoesVault TUI] slots.register() FAILED:", e)
|
|
152
|
+
}
|
|
137
153
|
}
|
|
138
154
|
|
|
139
155
|
export default { id: "echoes-vault-ui", tui }
|