echoes-vault-opencode 1.0.15 → 1.0.16
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.
- package/package.json +1 -1
- package/tui.ts +1 -83
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "echoes-vault-opencode",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
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,91 +1,9 @@
|
|
|
1
|
-
import { createElement, spread } from "@opentui/solid"
|
|
2
1
|
import type { TuiPlugin } from "@opencode-ai/plugin/tui"
|
|
3
2
|
|
|
4
|
-
function h(tag: string, props: Record<string, any> = {}, children: any[] = []) {
|
|
5
|
-
const el = createElement(tag)
|
|
6
|
-
spread(el, props)
|
|
7
|
-
for (const child of children) {
|
|
8
|
-
if (child != null && child !== false) el.add(child)
|
|
9
|
-
}
|
|
10
|
-
return el
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function t(content: string, props: Record<string, any> = {}) {
|
|
14
|
-
const el = createElement("text")
|
|
15
|
-
el.content = content
|
|
16
|
-
spread(el, props)
|
|
17
|
-
return el
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function box(props: Record<string, any> = {}, ...children: any[]) {
|
|
21
|
-
return h("box", props, children.flat())
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function text(content: string, props: Record<string, any> = {}) {
|
|
25
|
-
return t(content, props)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
3
|
const tui: TuiPlugin = async (api) => {
|
|
29
|
-
const KV = "echoes_vault"
|
|
30
|
-
|
|
31
|
-
type VaultState = {
|
|
32
|
-
initialized: boolean
|
|
33
|
-
sessionActive: boolean
|
|
34
|
-
pagesCount: number
|
|
35
|
-
lastSession: string | null
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
let vault: VaultState = {
|
|
39
|
-
initialized: false,
|
|
40
|
-
sessionActive: false,
|
|
41
|
-
pagesCount: 0,
|
|
42
|
-
lastSession: null,
|
|
43
|
-
}
|
|
44
|
-
|
|
45
4
|
try {
|
|
46
|
-
const saved = api.kv.get<VaultState>(KV)
|
|
47
|
-
if (saved) vault = saved
|
|
48
|
-
|
|
49
|
-
api.event.on("session.created", () => {
|
|
50
|
-
vault.sessionActive = true
|
|
51
|
-
vault.lastSession = new Date().toISOString().slice(0, 10)
|
|
52
|
-
try { api.kv.set(KV, vault) } catch {}
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
api.event.on("session.deleted", () => {
|
|
56
|
-
vault.sessionActive = false
|
|
57
|
-
try { api.kv.set(KV, vault) } catch {}
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
api.event.on("session.idle", () => {
|
|
61
|
-
vault.sessionActive = false
|
|
62
|
-
try { api.kv.set(KV, vault) } catch {}
|
|
63
|
-
})
|
|
64
|
-
|
|
65
5
|
api.slots.register({
|
|
66
|
-
sidebar_content: (
|
|
67
|
-
const sessionInfo = session_id ? api.state.session.get(session_id) : undefined
|
|
68
|
-
const title = sessionInfo?.title ?? "—"
|
|
69
|
-
const count = vault.pagesCount
|
|
70
|
-
const statusLine = vault.sessionActive ? `Session: ${title}` : "Idle"
|
|
71
|
-
const pagesLine = count > 0 ? ` · ${count} pages` : ""
|
|
72
|
-
|
|
73
|
-
return box(
|
|
74
|
-
{ flexDirection: "column" },
|
|
75
|
-
box(
|
|
76
|
-
{ border: "all" as any, borderStyle: "single" as any, paddingX: 1, paddingY: 0 },
|
|
77
|
-
text("EchoesVault"),
|
|
78
|
-
),
|
|
79
|
-
box(
|
|
80
|
-
{ paddingX: 1 },
|
|
81
|
-
text(`${statusLine}${pagesLine}`, { dim: true }),
|
|
82
|
-
),
|
|
83
|
-
box(
|
|
84
|
-
{ paddingX: 1, paddingY: 0 },
|
|
85
|
-
text("/echoes-init /echoes-start /echoes-end /echoes-status", { dim: true }),
|
|
86
|
-
),
|
|
87
|
-
)
|
|
88
|
-
},
|
|
6
|
+
sidebar_content: () => "EchoesVault loaded",
|
|
89
7
|
})
|
|
90
8
|
} catch (error) {
|
|
91
9
|
console.error("[echoes-vault] TUI init failed:", error)
|