-
-
Notifications
You must be signed in to change notification settings - Fork 397
Port opencode plugin 226549446602792139 #334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Port opencode plugin 226549446602792139 #334
Conversation
This commit introduces a new plugin for OpenCode that connects to the claude-mem worker service. It implements: - `session.created` hook to inject memory context. - `tool.execute.after` hook to capture observations. - `mem-search` tool for memory retrieval. - `session.idle` hook for summarization. The plugin resides in `opencode-plugin/` and includes its own build and test configuration.
This commit adds a Gemini CLI extension that proxies memory capabilities to the claude-mem worker. It includes: - An MCP server implementation using `@modelcontextprotocol/sdk`. - `mem-search` tool exposed to Gemini. - Manifest and context files (`gemini-extension.json`, `GEMINI.md`). - Build configuration for ESM compatibility. The extension connects to the local worker on port 37777.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR ports the Claude-Mem plugin (ID: 226549446602792139) to OpenCode, enabling persistent memory and context management across sessions. The plugin acts as a client to the Claude-Mem worker service, capturing tool executions and providing memory search capabilities.
Key changes:
- Implements a WorkerClient to communicate with the Claude-Mem service on port 37777
- Adds OpenCode plugin lifecycle hooks for session management and tool execution tracking
- Provides a custom
mem-searchtool for querying historical context
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| opencode-plugin/tsconfig.json | TypeScript configuration for ESNext with Bun runtime support |
| opencode-plugin/test/plugin.test.ts | Test suite covering plugin hooks and WorkerClient integration |
| opencode-plugin/src/worker-client.ts | HTTP client for Claude-Mem worker service API |
| opencode-plugin/src/index.ts | Main plugin implementation with lifecycle hooks and memory search tool |
| opencode-plugin/package.json | Package manifest with dependencies and build scripts |
| opencode-plugin/README.md | Documentation for installation, usage, and architecture |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| /** | ||
| * Check if the worker is healthy | ||
| */ | ||
| static async isHealthy(): Promise<boolean> { | ||
| try { | ||
| const controller = new AbortController(); | ||
| const timeoutId = setTimeout(() => controller.abort(), 1000); // 1s timeout |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The timeout duration of 1000ms is hardcoded. Consider extracting this as a class constant (e.g., HEALTH_CHECK_TIMEOUT_MS) to improve maintainability and make it easier to adjust if needed.
| /** | |
| * Check if the worker is healthy | |
| */ | |
| static async isHealthy(): Promise<boolean> { | |
| try { | |
| const controller = new AbortController(); | |
| const timeoutId = setTimeout(() => controller.abort(), 1000); // 1s timeout | |
| private static readonly HEALTH_CHECK_TIMEOUT_MS = 1000; | |
| * Check if the worker is healthy | |
| */ | |
| static async isHealthy(): Promise<boolean> { | |
| try { | |
| const controller = new AbortController(); | |
| const timeoutId = setTimeout(() => controller.abort(), this.HEALTH_CHECK_TIMEOUT_MS); // 1s timeout |
| import { WorkerClient } from "./worker-client"; | ||
|
|
||
| // Simple in-memory map to store tool arguments between before/after hooks | ||
| const callArgsMap = new Map<string, any>(); |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The module-level Map callArgsMap could grow unbounded if call IDs are not properly cleaned up. Consider implementing a size limit or TTL mechanism to prevent potential memory leaks in long-running processes.
| const isHealthy = await WorkerClient.isHealthy(); | ||
| if (isHealthy) { | ||
| try { | ||
| await WorkerClient.sessionInit(session.id, projectName, "SESSION_START"); |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded string 'SESSION_START' should be extracted as a constant (e.g., SESSION_START_PROMPT) for better maintainability and to avoid magic strings.
|
@claude review |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
@claude review |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
No description provided.