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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. 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.4",
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, Show } from "solid-js"
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: VaultStats
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
- return JSON.parse(raw) as EchoesState
32
- } catch {
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
- api.slots.register({
41
- slots: {
42
- sidebar_content() {
43
- const [state, setState] = createSignal<EchoesState | null>(readState())
44
-
45
- const interval = setInterval(() => setState(readState()), 3000)
46
- onCleanup(() => clearInterval(interval))
47
-
48
- const statusColor = () => {
49
- const s = state()
50
- if (!s || !s.initialized) return theme.error
51
- if (s.session.saved) return theme.accent
52
- if (s.session.started) return theme.success
53
- return theme.warning
54
- }
55
-
56
- const statusLabel = () => {
57
- const s = state()
58
- if (!s || !s.initialized) return "Not Activated"
59
- if (s.session.saved) return "Memory Saved"
60
- if (s.session.started) return "Active"
61
- return "Session Not Started"
62
- }
63
-
64
- const vaultHealthColor = () => {
65
- const pages = state()?.stats?.totalPages ?? 0
66
- if (pages > 200) return theme.error
67
- if (pages >= 170) return theme.warning
68
- return theme.success
69
- }
70
-
71
- const vaultUsagePercent = () => {
72
- const pages = state()?.stats?.totalPages ?? 0
73
- return Math.round((pages / 200) * 100)
74
- }
75
-
76
- const statusDesc = () => {
77
- const s = state()
78
- if (!s || !s.initialized) return null
79
- if (s.session.saved) return "Vault memorized session data"
80
- if (s.session.started) return null
81
- return null
82
- }
83
-
84
- const statusCmd = () => {
85
- const s = state()
86
- if (!s || !s.initialized) return "/echoes-init"
87
- if (s.session.saved) return null
88
- if (s.session.started) return "/echoes-end"
89
- return "/echoes-start"
90
- }
91
-
92
- const statusCmdHint = () => {
93
- const s = state()
94
- if (!s || !s.initialized) return "to activate vault"
95
- if (s.session.saved) return null
96
- if (s.session.started) return "before closing"
97
- return "to load context"
98
- }
99
-
100
- return (
101
- <box flexDirection="column">
102
- <box flexDirection="row">
103
- <text fg={statusColor()}><b>• </b></text>
104
- <text fg={theme.textMuted}><b>Echoes</b></text>
105
- <text fg={theme.text}><b>Vault</b></text>
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={theme.textMuted}>Run </text>
115
- <text fg={theme.text}>{statusCmd()}</text>
116
- <text fg={theme.textMuted}> {statusCmdHint()}</text>
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
- </Show>
119
- <Show when={state()?.initialized}>
120
- <box flexDirection="column">
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={vaultHealthColor()}>• </text>
123
- <text fg={theme.text}><b>Vault Health</b></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
- <text fg={theme.textMuted}> Pages: {state()?.stats?.totalPages ?? 0}</text>
126
- <text fg={theme.textMuted}> Usage: {vaultUsagePercent()}%</text>
127
- <Show when={(state()?.stats?.totalPages ?? 0) > 200}>
128
- <text fg={theme.textMuted}> Consider migrating to RAG</text>
129
- </Show>
130
- </box>
131
- </Show>
132
- </box>
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 }