@prevalentware/opencode-goal-plugin 0.1.21 → 0.1.22
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/src/tui.tsx +23 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prevalentware/opencode-goal-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"description": "OpenCode goal plugin that adds Codex-style long-running goal mode, /goal commands, persistence, and TUI status for AI coding agents.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"opencode",
|
package/src/tui.tsx
CHANGED
|
@@ -82,6 +82,27 @@ type ModernTuiApi = TuiPluginApi & {
|
|
|
82
82
|
|
|
83
83
|
const goalCache = new Map<string, GoalSnapshot>()
|
|
84
84
|
|
|
85
|
+
function goalSnapshotKey(sessionID: string) {
|
|
86
|
+
return `goal-mode.snapshot.${sessionID}`
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function cachedGoal(api: TuiPluginApi, sessionID: string) {
|
|
90
|
+
const memory = goalCache.get(sessionID)
|
|
91
|
+
if (memory) return memory
|
|
92
|
+
const persisted = api.kv?.get(goalSnapshotKey(sessionID), null)
|
|
93
|
+
return isGoalSnapshot(persisted) ? persisted : null
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function cacheGoal(api: TuiPluginApi, sessionID: string, goal: GoalSnapshot | null) {
|
|
97
|
+
if (goal) {
|
|
98
|
+
goalCache.set(sessionID, goal)
|
|
99
|
+
api.kv?.set(goalSnapshotKey(sessionID), goal)
|
|
100
|
+
return
|
|
101
|
+
}
|
|
102
|
+
goalCache.delete(sessionID)
|
|
103
|
+
api.kv?.set(goalSnapshotKey(sessionID), null)
|
|
104
|
+
}
|
|
105
|
+
|
|
85
106
|
function currentSessionID(api: TuiPluginApi) {
|
|
86
107
|
const route = api.route.current
|
|
87
108
|
if (route.name !== "session") return undefined
|
|
@@ -279,13 +300,12 @@ export function goalStateFromSession(api: TuiPluginApi, sessionID: string): Goal
|
|
|
279
300
|
for (const part of parts) {
|
|
280
301
|
const goal = parseGoalToolOutput(part)
|
|
281
302
|
if (goal !== undefined) {
|
|
282
|
-
|
|
283
|
-
else goalCache.delete(sessionID)
|
|
303
|
+
cacheGoal(api, sessionID, goal)
|
|
284
304
|
return { goal, messageIndex }
|
|
285
305
|
}
|
|
286
306
|
}
|
|
287
307
|
}
|
|
288
|
-
return { goal:
|
|
308
|
+
return { goal: cachedGoal(api, sessionID), messageIndex: -1 }
|
|
289
309
|
}
|
|
290
310
|
|
|
291
311
|
function goalFromSession(api: TuiPluginApi, sessionID: string) {
|