echoes-vault-opencode 1.1.1 → 1.1.2
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.tsx +36 -48
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "echoes-vault-opencode",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
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,6 +1,5 @@
|
|
|
1
1
|
/** @jsxImportSource @opentui/solid */
|
|
2
2
|
import type { TuiPlugin } from "@opencode-ai/plugin/tui"
|
|
3
|
-
import { createSignal, onCleanup } from "solid-js"
|
|
4
3
|
import * as fs from "node:fs"
|
|
5
4
|
import * as path from "node:path"
|
|
6
5
|
|
|
@@ -26,11 +25,10 @@ type EchoesState = {
|
|
|
26
25
|
const CAPACITY_LIMIT = 200
|
|
27
26
|
const CAPACITY_WARNING = 170
|
|
28
27
|
|
|
29
|
-
const STATE_PATH = path.join(process.cwd(), ".opencode", "echoes-state.json")
|
|
30
|
-
|
|
31
28
|
const readState = (): EchoesState | null => {
|
|
32
29
|
try {
|
|
33
|
-
const
|
|
30
|
+
const statePath = path.join(process.cwd(), ".opencode", "echoes-state.json")
|
|
31
|
+
const raw = fs.readFileSync(statePath, "utf-8")
|
|
34
32
|
return JSON.parse(raw) as EchoesState
|
|
35
33
|
} catch {
|
|
36
34
|
return null
|
|
@@ -43,91 +41,81 @@ const tui: TuiPlugin = async (api) => {
|
|
|
43
41
|
api.slots.register({
|
|
44
42
|
slots: {
|
|
45
43
|
sidebar_content() {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
const interval = setInterval(() => setState(readState()), 3000)
|
|
49
|
-
onCleanup(() => clearInterval(interval))
|
|
44
|
+
const s = readState()
|
|
50
45
|
|
|
51
|
-
const statusColor = () => {
|
|
52
|
-
const s = state()
|
|
46
|
+
const statusColor = (() => {
|
|
53
47
|
if (!s || !s.initialized) return theme.error
|
|
54
48
|
if (s.session.saved) return theme.accent
|
|
55
49
|
if (s.session.started) return theme.success
|
|
56
50
|
return theme.warning
|
|
57
|
-
}
|
|
51
|
+
})()
|
|
58
52
|
|
|
59
|
-
const statusLabel = () => {
|
|
60
|
-
const s = state()
|
|
53
|
+
const statusLabel = (() => {
|
|
61
54
|
if (!s || !s.initialized) return "Not Activated"
|
|
62
55
|
if (s.session.saved) return "Memory Saved"
|
|
63
56
|
if (s.session.started) return "Active"
|
|
64
57
|
return "Session Not Started"
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const statusDesc = () => {
|
|
68
|
-
const s = state()
|
|
69
|
-
if (!s || !s.initialized) return null
|
|
70
|
-
if (s.session.saved) return "Vault memorized session data"
|
|
71
|
-
if (s.session.started) return null
|
|
72
|
-
return null
|
|
73
|
-
}
|
|
58
|
+
})()
|
|
74
59
|
|
|
75
|
-
const statusCmd = () => {
|
|
76
|
-
const s = state()
|
|
60
|
+
const statusCmd = (() => {
|
|
77
61
|
if (!s || !s.initialized) return "/echoes-init"
|
|
78
62
|
if (s.session.saved) return null
|
|
79
63
|
if (s.session.started) return "/echoes-end"
|
|
80
64
|
return "/echoes-start"
|
|
81
|
-
}
|
|
65
|
+
})()
|
|
82
66
|
|
|
83
|
-
const statusCmdHint = () => {
|
|
84
|
-
const s = state()
|
|
67
|
+
const statusCmdHint = (() => {
|
|
85
68
|
if (!s || !s.initialized) return "to activate vault"
|
|
86
69
|
if (s.session.saved) return null
|
|
87
70
|
if (s.session.started) return "before closing"
|
|
88
71
|
return "to load context"
|
|
89
|
-
}
|
|
72
|
+
})()
|
|
73
|
+
|
|
74
|
+
const statusDesc = (() => {
|
|
75
|
+
if (!s || !s.initialized) return null
|
|
76
|
+
if (s.session.saved) return "Vault memorized session data"
|
|
77
|
+
return null
|
|
78
|
+
})()
|
|
90
79
|
|
|
91
|
-
const pages =
|
|
80
|
+
const pages = s?.stats?.totalPages ?? 0
|
|
92
81
|
|
|
93
|
-
const capacityColor = () => {
|
|
94
|
-
|
|
95
|
-
if (
|
|
96
|
-
if (p > CAPACITY_WARNING) return theme.warning
|
|
82
|
+
const capacityColor = (() => {
|
|
83
|
+
if (pages > CAPACITY_LIMIT) return theme.error
|
|
84
|
+
if (pages > CAPACITY_WARNING) return theme.warning
|
|
97
85
|
return theme.success
|
|
98
|
-
}
|
|
86
|
+
})()
|
|
99
87
|
|
|
100
|
-
const capacityPercent =
|
|
88
|
+
const capacityPercent = Math.round((pages / CAPACITY_LIMIT) * 100)
|
|
101
89
|
|
|
102
90
|
return (
|
|
103
91
|
<box flexDirection="column">
|
|
104
92
|
<box flexDirection="row">
|
|
105
|
-
<text fg={statusColor
|
|
93
|
+
<text fg={statusColor}><b>• </b></text>
|
|
106
94
|
<text fg={theme.textMuted}><b>Echoes</b></text>
|
|
107
95
|
<text fg={theme.text}><b>Vault</b></text>
|
|
108
|
-
<text fg={theme.textMuted}> v{
|
|
96
|
+
<text fg={theme.textMuted}> v{s?.pluginVersion ?? ""}</text>
|
|
109
97
|
</box>
|
|
110
|
-
<text fg={statusColor
|
|
111
|
-
{statusDesc
|
|
112
|
-
<text fg={theme.textMuted}>{statusDesc
|
|
98
|
+
<text fg={statusColor}>{statusLabel}</text>
|
|
99
|
+
{statusDesc && (
|
|
100
|
+
<text fg={theme.textMuted}>{statusDesc}</text>
|
|
113
101
|
)}
|
|
114
|
-
{statusCmd
|
|
102
|
+
{statusCmd && (
|
|
115
103
|
<box flexDirection="row">
|
|
116
104
|
<text fg={theme.textMuted}>Run </text>
|
|
117
|
-
<text fg={theme.text}>{statusCmd
|
|
118
|
-
<text fg={theme.textMuted}> {statusCmdHint
|
|
105
|
+
<text fg={theme.text}>{statusCmd}</text>
|
|
106
|
+
<text fg={theme.textMuted}> {statusCmdHint}</text>
|
|
119
107
|
</box>
|
|
120
108
|
)}
|
|
121
|
-
{
|
|
109
|
+
{s?.initialized && (
|
|
122
110
|
<box flexDirection="column">
|
|
123
111
|
<text> </text>
|
|
124
112
|
<box flexDirection="row">
|
|
125
|
-
<text fg={capacityColor
|
|
113
|
+
<text fg={capacityColor}><b>• </b></text>
|
|
126
114
|
<text fg={theme.text}><b>Vault Capacity</b></text>
|
|
127
115
|
</box>
|
|
128
|
-
<text fg={theme.textMuted}>Pages: {pages
|
|
129
|
-
<text fg={theme.textMuted}>Usage: {capacityPercent
|
|
130
|
-
{pages
|
|
116
|
+
<text fg={theme.textMuted}>Pages: {pages}</text>
|
|
117
|
+
<text fg={theme.textMuted}>Usage: {capacityPercent}%</text>
|
|
118
|
+
{pages > CAPACITY_LIMIT && (
|
|
131
119
|
<text fg={theme.textMuted}>Consider migrating to RAG</text>
|
|
132
120
|
)}
|
|
133
121
|
</box>
|