echoes-vault-opencode 1.0.7 → 1.0.9

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 +3 -2
  2. package/tui.ts +47 -108
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "echoes-vault-opencode",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
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",
@@ -28,7 +28,8 @@
28
28
  ],
29
29
  "license": "MIT",
30
30
  "dependencies": {
31
- "@opencode-ai/plugin": ">=1.16.0"
31
+ "@opencode-ai/plugin": ">=1.16.0",
32
+ "@opentui/solid": ">=0.3.2"
32
33
  },
33
34
  "devDependencies": {
34
35
  "@types/node": "^22.0.0",
package/tui.ts CHANGED
@@ -1,3 +1,5 @@
1
+ /** @jsxImportSource @opentui/solid */
2
+
1
3
  import type { TuiPlugin } from "@opencode-ai/plugin/tui"
2
4
 
3
5
  const tui: TuiPlugin = async (api) => {
@@ -10,124 +12,61 @@ const tui: TuiPlugin = async (api) => {
10
12
  lastSession: string | null
11
13
  }
12
14
 
13
- let vault: VaultState = api.kv.get<VaultState>(KV) ?? {
15
+ let vault: VaultState = {
14
16
  initialized: false,
15
17
  sessionActive: false,
16
18
  pagesCount: 0,
17
19
  lastSession: null,
18
20
  }
19
21
 
20
- function persist() {
21
- api.kv.set(KV, vault)
22
- }
23
-
24
- function update(partial: Partial<VaultState>) {
25
- vault = { ...vault, ...partial }
26
- persist()
27
- }
28
-
29
- api.event.on("session.created", () => {
30
- update({ sessionActive: true })
31
- })
32
-
33
- api.event.on("session.deleted", () => {
34
- update({ sessionActive: false })
35
- })
36
-
37
- api.event.on("session.idle", () => {
38
- update({ sessionActive: false })
39
- })
40
-
41
- api.keymap.registerLayer({
42
- name: "echoes-vault",
43
- commands: [
44
- { title: "EchoesVault: Init Vault", value: "echoes.init" },
45
- { title: "EchoesVault: Start Session", value: "echoes.start" },
46
- { title: "EchoesVault: End Session", value: "echoes.end" },
47
- { title: "EchoesVault: Vault Status", value: "echoes.status" },
48
- ],
49
- bindings: [
50
- { keys: "C-i", command: "echoes.init" },
51
- { keys: "C-s", command: "echoes.start" },
52
- { keys: "C-e", command: "echoes.end" },
53
- { keys: "C-v", command: "echoes.status" },
54
- ],
55
- })
56
-
57
- api.slots.register({
58
- sidebar_content: ({ session_id }) => {
59
- const sessionInfo = session_id ? api.state.session.get(session_id) : undefined
60
- const active = Boolean(sessionInfo)
61
- const sessionTitle = sessionInfo?.title ?? "Active"
62
- const pagesInfo = vault.pagesCount > 0 ? ` · ${vault.pagesCount} pages` : ""
63
-
64
- return (
65
- <Box flexDirection="column">
66
- <Box
67
- border="all"
68
- borderStyle="single"
69
- paddingX={1}
70
- paddingY={0}
71
- >
72
- <Text bold>EchoesVault</Text>
73
- </Box>
74
-
75
- <Box paddingX={1}>
76
- <Text dim>
77
- {active ? `Session: ${sessionTitle}` : vault.lastSession ? `Last: ${vault.lastSession}` : "No session"}
78
- {pagesInfo}
79
- </Text>
80
- </Box>
81
-
82
- <Box
83
- marginTop={0}
84
- marginBottom={0}
85
- paddingLeft={1}
86
- paddingRight={1}
87
- onMouseDown={() => api.ui.toast({ message: "Use /echoes-init to initialize the vault", variant: "info", duration: 2500 })}
88
- >
89
- <Box flexDirection="row" justifyContent="space-between">
90
- <Text>Init Vault</Text>
91
- <Text dim>C-i</Text>
22
+ try {
23
+ const saved = api.kv.get<VaultState>(KV)
24
+ if (saved) vault = saved
25
+
26
+ api.event.on("session.created", () => {
27
+ vault.sessionActive = true
28
+ vault.lastSession = new Date().toISOString().slice(0, 10)
29
+ try { api.kv.set(KV, vault) } catch {}
30
+ })
31
+
32
+ api.event.on("session.deleted", () => {
33
+ vault.sessionActive = false
34
+ try { api.kv.set(KV, vault) } catch {}
35
+ })
36
+
37
+ api.event.on("session.idle", () => {
38
+ vault.sessionActive = false
39
+ try { api.kv.set(KV, vault) } catch {}
40
+ })
41
+
42
+ api.slots.register({
43
+ sidebar_content: ({ session_id }: { session_id: string }) => {
44
+ const sessionInfo = session_id ? api.state.session.get(session_id) : undefined
45
+ const title = sessionInfo?.title ?? "—"
46
+ const count = vault.pagesCount
47
+
48
+ return (
49
+ <Box flexDirection="column">
50
+ <Box border="all" borderStyle="single" paddingX={1} paddingY={0}>
51
+ <Text bold>EchoesVault</Text>
92
52
  </Box>
93
- </Box>
94
-
95
- <Box
96
- paddingLeft={1}
97
- paddingRight={1}
98
- onMouseDown={() => api.ui.toast({ message: "Use /echoes-start to restore context", variant: "info", duration: 2500 })}
99
- >
100
- <Box flexDirection="row" justifyContent="space-between">
101
- <Text>Start Session</Text>
102
- <Text dim>C-s</Text>
53
+ <Box paddingX={1}>
54
+ <Text dim>
55
+ {vault.sessionActive ? `Session: ${title}` : "Idle"}
56
+ {count > 0 ? ` · ${count} pages` : ""}
57
+ </Text>
103
58
  </Box>
104
- </Box>
105
-
106
- <Box
107
- paddingLeft={1}
108
- paddingRight={1}
109
- onMouseDown={() => api.ui.toast({ message: "Use /echoes-end to save session memory", variant: "info", duration: 2500 })}
110
- >
111
- <Box flexDirection="row" justifyContent="space-between">
112
- <Text>End Session</Text>
113
- <Text dim>C-e</Text>
59
+ <Box paddingX={1} paddingY={0}>
60
+ <Text dim>/echoes-init /echoes-start /echoes-end /echoes-status</Text>
114
61
  </Box>
115
62
  </Box>
116
-
117
- <Box
118
- paddingLeft={1}
119
- paddingRight={1}
120
- onMouseDown={() => api.ui.toast({ message: "Use /echoes-status to check vault health", variant: "info", duration: 2500 })}
121
- >
122
- <Box flexDirection="row" justifyContent="space-between">
123
- <Text>Vault Status</Text>
124
- <Text dim>C-v</Text>
125
- </Box>
126
- </Box>
127
- </Box>
128
- )
129
- },
130
- })
63
+ )
64
+ },
65
+ })
66
+ } catch (error) {
67
+ console.error("[echoes-vault] TUI init failed:", error)
68
+ try { api.ui.toast({ message: "EchoesVault TUI failed to load", variant: "error" }) } catch {}
69
+ }
131
70
  }
132
71
 
133
72
  export default { tui }