echoes-vault-opencode 1.0.17 → 1.0.18

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 +107 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "echoes-vault-opencode",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
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,26 +1,122 @@
1
1
  /** @jsxImportSource @opentui/solid */
2
2
  import type { TuiPlugin, TuiPluginModule } from "@opencode-ai/plugin/tui"
3
3
 
4
+ type VaultState = {
5
+ initialized: boolean
6
+ sessionActive: boolean
7
+ pagesCount: number
8
+ lastSession: string | null
9
+ }
10
+
11
+ const KV = "echoes_vault"
12
+ let vault: VaultState = { initialized: false, sessionActive: false, pagesCount: 0, lastSession: null }
13
+
4
14
  const tui: TuiPlugin = async (api) => {
5
15
  try {
6
- api.slots.register({
7
- order: 10, // Определяет позицию панели (выше или ниже других)
8
- slots: {
9
- sidebar_content() {
10
- // Обязательно оборачиваем текст в тег <text>!
11
- return <text>🚀 EchoesVault loaded and ready!</text>
12
- },
13
- },
16
+ const saved = api.kv.get<VaultState>(KV)
17
+ if (saved) vault = saved
18
+
19
+ function save() {
20
+ try { api.kv.set(KV, vault) } catch {}
21
+ }
22
+
23
+ api.event.on("session.created", () => {
24
+ vault.sessionActive = true
25
+ vault.lastSession = new Date().toISOString().slice(0, 10)
26
+ save()
27
+ })
28
+
29
+ api.event.on("session.deleted", () => {
30
+ vault.sessionActive = false
31
+ save()
32
+ })
33
+
34
+ api.event.on("session.idle", () => {
35
+ vault.sessionActive = false
36
+ save()
14
37
  })
15
38
  } catch (error) {
16
- console.error("[echoes-vault] TUI init failed:", error)
39
+ console.error("[echoes-vault] event init failed:", error)
17
40
  }
41
+
42
+ try {
43
+ api.keymap.registerLayer({
44
+ name: "echoes-vault",
45
+ commands: [
46
+ { title: "EchoesVault: Init Vault", value: "echoes.init" },
47
+ { title: "EchoesVault: Start Session", value: "echoes.start" },
48
+ { title: "EchoesVault: End Session", value: "echoes.end" },
49
+ { title: "EchoesVault: Vault Status", value: "echoes.status" },
50
+ ],
51
+ bindings: [
52
+ { keys: "C-i", command: "echoes.init" },
53
+ { keys: "C-s", command: "echoes.start" },
54
+ { keys: "C-e", command: "echoes.end" },
55
+ { keys: "C-v", command: "echoes.status" },
56
+ ],
57
+ })
58
+ } catch {}
59
+
60
+ api.slots.register({
61
+ slots: {
62
+ sidebar_content({ session_id }: { session_id: string }) {
63
+ const sessionInfo = session_id ? api.state.session.get(session_id) : undefined
64
+ const title = sessionInfo?.title ?? "—"
65
+ const count = vault.pagesCount
66
+ const active = vault.sessionActive
67
+ const last = vault.lastSession
68
+
69
+ return (
70
+ <box flexDirection="column">
71
+ <box border="all" borderStyle="single" paddingX={1} paddingY={0}>
72
+ <text bold>EchoesVault</text>
73
+ </box>
74
+
75
+ <box paddingX={1} paddingY={0}>
76
+ <text color={active ? "green" : "textMuted"}>
77
+ {active ? `Session: ${title}` : last ? `Last: ${last}` : "No session"}
78
+ </text>
79
+ </box>
80
+
81
+ {count > 0 && (
82
+ <box paddingX={1} paddingY={0}>
83
+ <text color="textMuted">{count} pages indexed</text>
84
+ </box>
85
+ )}
86
+
87
+ <box paddingX={1} paddingY={0} marginTop={1}>
88
+ <text bold color="textMuted">Commands</text>
89
+ </box>
90
+
91
+ <box paddingX={1} paddingY={0}>
92
+ <text>/echoes-init</text>
93
+ <text color="textMuted"> Init vault</text>
94
+ </box>
95
+
96
+ <box paddingX={1} paddingY={0}>
97
+ <text>/echoes-start</text>
98
+ <text color="textMuted"> Start session</text>
99
+ </box>
100
+
101
+ <box paddingX={1} paddingY={0}>
102
+ <text>/echoes-end</text>
103
+ <text color="textMuted"> End session</text>
104
+ </box>
105
+
106
+ <box paddingX={1} paddingY={0}>
107
+ <text>/echoes-status</text>
108
+ <text color="textMuted"> Vault status</text>
109
+ </box>
110
+ </box>
111
+ )
112
+ },
113
+ },
114
+ })
18
115
  }
19
116
 
20
- // OpenCode любит, когда у плагина есть явный ID
21
117
  const plugin: TuiPluginModule & { id: string } = {
22
118
  id: "echoes-vault-sidebar",
23
119
  tui,
24
120
  }
25
121
 
26
- export default plugin
122
+ export default plugin