echoes-vault-opencode 1.0.13 → 1.0.14

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.ts +63 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "echoes-vault-opencode",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
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.ts CHANGED
@@ -1,18 +1,69 @@
1
1
  import type { TuiPlugin } from "@opencode-ai/plugin/tui"
2
2
 
3
3
  const tui: TuiPlugin = async (api) => {
4
- api.slots.register({
5
- sidebar_content: () => (
6
- <Box flexDirection="column">
7
- <Box border="all" borderStyle="single" paddingX={1} paddingY={0}>
8
- <Text bold>EchoesVault</Text>
9
- </Box>
10
- <Box paddingX={1}>
11
- <Text dim>Status here</Text>
12
- </Box>
13
- </Box>
14
- ),
15
- })
4
+ const KV = "echoes_vault"
5
+
6
+ type VaultState = {
7
+ initialized: boolean
8
+ sessionActive: boolean
9
+ pagesCount: number
10
+ lastSession: string | null
11
+ }
12
+
13
+ let vault: VaultState = {
14
+ initialized: false,
15
+ sessionActive: false,
16
+ pagesCount: 0,
17
+ lastSession: null,
18
+ }
19
+
20
+ try {
21
+ const saved = api.kv.get<VaultState>(KV)
22
+ if (saved) vault = saved
23
+
24
+ api.event.on("session.created", () => {
25
+ vault.sessionActive = true
26
+ vault.lastSession = new Date().toISOString().slice(0, 10)
27
+ try { api.kv.set(KV, vault) } catch {}
28
+ })
29
+
30
+ api.event.on("session.deleted", () => {
31
+ vault.sessionActive = false
32
+ try { api.kv.set(KV, vault) } catch {}
33
+ })
34
+
35
+ api.event.on("session.idle", () => {
36
+ vault.sessionActive = false
37
+ try { api.kv.set(KV, vault) } catch {}
38
+ })
39
+
40
+ api.slots.register({
41
+ sidebar_content: ({ session_id }: { session_id: string }) => {
42
+ const sessionInfo = session_id ? api.state.session.get(session_id) : undefined
43
+ const title = sessionInfo?.title ?? "—"
44
+ const count = vault.pagesCount
45
+
46
+ return (
47
+ <box flexDirection="column">
48
+ <box border="all" borderStyle="single" paddingX={1} paddingY={0}>
49
+ <text bold>EchoesVault</text>
50
+ </box>
51
+ <box paddingX={1}>
52
+ <text dim>
53
+ {vault.sessionActive ? `Session: ${title}` : "Idle"}
54
+ {count > 0 ? ` · ${count} pages` : ""}
55
+ </text>
56
+ </box>
57
+ <box paddingX={1} paddingY={0}>
58
+ <text dim>/echoes-init /echoes-start /echoes-end /echoes-status</text>
59
+ </box>
60
+ </box>
61
+ )
62
+ },
63
+ })
64
+ } catch (error) {
65
+ console.error("[echoes-vault] TUI init failed:", error)
66
+ }
16
67
  }
17
68
 
18
69
  export default { tui }