echoes-vault-opencode 1.0.5 → 1.0.7

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 +7 -2
  2. package/tui.ts +133 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "echoes-vault-opencode",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
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",
@@ -8,10 +8,15 @@
8
8
  "./server": {
9
9
  "import": "./index.ts",
10
10
  "types": "./index.ts"
11
+ },
12
+ "./tui": {
13
+ "import": "./tui.ts",
14
+ "types": "./tui.ts"
11
15
  }
12
16
  },
13
17
  "files": [
14
- "index.ts"
18
+ "index.ts",
19
+ "tui.ts"
15
20
  ],
16
21
  "keywords": [
17
22
  "opencode",
package/tui.ts ADDED
@@ -0,0 +1,133 @@
1
+ import type { TuiPlugin } from "@opencode-ai/plugin/tui"
2
+
3
+ const tui: TuiPlugin = async (api) => {
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 = api.kv.get<VaultState>(KV) ?? {
14
+ initialized: false,
15
+ sessionActive: false,
16
+ pagesCount: 0,
17
+ lastSession: null,
18
+ }
19
+
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>
92
+ </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>
103
+ </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>
114
+ </Box>
115
+ </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
+ })
131
+ }
132
+
133
+ export default { tui }