Skip to content

Conversation

@robertpelloni
Copy link

No description provided.

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.
Copilot AI review requested due to automatic review settings December 15, 2025 18:57
Copy link
Contributor

Copilot AI left a 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-search tool 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.

Comment on lines +11 to +18

/**
* Check if the worker is healthy
*/
static async isHealthy(): Promise<boolean> {
try {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 1000); // 1s timeout
Copy link

Copilot AI Dec 15, 2025

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.

Suggested change
/**
* 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

Copilot uses AI. Check for mistakes.
import { WorkerClient } from "./worker-client";

// Simple in-memory map to store tool arguments between before/after hooks
const callArgsMap = new Map<string, any>();
Copy link

Copilot AI Dec 15, 2025

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.

Copilot uses AI. Check for mistakes.
const isHealthy = await WorkerClient.isHealthy();
if (isHealthy) {
try {
await WorkerClient.sessionInit(session.id, projectName, "SESSION_START");
Copy link

Copilot AI Dec 15, 2025

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.

Copilot uses AI. Check for mistakes.
@thedotmack thedotmack self-assigned this Dec 15, 2025
@thedotmack
Copy link
Owner

@claude review

@claude
Copy link

claude bot commented Dec 15, 2025

Claude encountered an error —— View job

Failed with exit code 128

I'll analyze this and get back to you.

@thedotmack thedotmack self-requested a review December 15, 2025 22:10
@thedotmack
Copy link
Owner

@claude review

@claude
Copy link

claude bot commented Dec 15, 2025

Claude encountered an error —— View job

Failed with exit code 128

I'll analyze this and get back to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants