feat:Add OpenCode memory plugin example#569
Conversation
|
|
yangxinxin-7
left a comment
There was a problem hiding this comment.
- Dead code: extractMessageContent is never called
extractMessageContent is defined but never used anywhere — message.part.updated reads part.text directly. Please remove
it.
- AbortSignal listener is never removed in makeRequest
options.abortSignal.addEventListener("abort", () => controller.abort())
This listener leaks when the request completes normally. Use AbortSignal.any([options.abortSignal, controller.signal])
instead.
- sessionMessageBuffer is unbounded
If session.created never fires (e.g. OpenViking is down at startup), the buffer for that session grows forever with no
size limit or TTL. Consider capping it or periodically evicting stale entries.
- flushPendingMessages is called on every streaming token
In message.part.updated, flushPendingMessages is called for every partial update. During assistant streaming, all these
calls are no-ops (role isn't set until finish=stop), but they still iterate pendingMessages on every token. Consider only
flushing from message.updated.
- autoCommit.intervalMinutes is not validated
If set to 0 or a negative value, every scheduled check triggers a commit. Add Math.max(1, intervalMinutes) as a guard.
These issues were identified via AI-assisted code review. Please verify each one before acting on it.
|
Thanks for the review. I’ve pushed updates to address the issues you pointed out. Changes included:
I also made two follow-up cleanups to reduce likely follow-up concerns:
Let me know if you’d like me to split any of these changes further. |
Summary
This PR adds an OpenCode memory plugin example for OpenViking.
The example exposes OpenViking as explicit OpenCode tools:
memsearchmemreadmembrowsememcommitIt also keeps the OpenCode conversation synchronized with an OpenViking session and uses background commit tasks for memory extraction.
Why this example
This example demonstrates a tool-based integration pattern for OpenCode.
Instead of relying on implicit prompt-time context injection, it lets the agent call OpenViking capabilities explicitly for memory search, content reading, filesystem-style browsing, and session commit.
That makes it a useful example for users who want direct memory operations and session-to-memory synchronization inside OpenCode.
Changes
examples/opencode-memory-plugin/Notes
The example is intentionally distributed as a single first-level plugin file under
~/.config/opencode/plugins, which matches OpenCode's local plugin discovery behavior.