Feat/opencode systemd integration#135
Conversation
OpenCode was still using standalone JSON storage, so its MCP traffic and automatic context hooks did not share state with the systemd agentmemory service. Route stdio MCP through the deployed REST endpoints and ship the OpenCode plugin plus installer so local deployments point both paths at the same backend.
Install script now deploys Claude Code hooks (prompt/pretool/posttool) and merges MCP + hook entries into ~/.claude/settings.json, matching the OpenCode plugin's REST-based observe/context/enrich pattern against the systemd-managed backend at 127.0.0.1:3111.
Install script now copies plugin/ (with 4 skills: remember, recall, forget, session-history) into Claude Code's plugin cache, registers it in installed_plugins.json, and enables it in settings.json. Idempotent.
OpenCode setup only enabled the plugin and MCP bridge, so explicit memory actions were not available as native skills and the generated config assumed one user's Node path. Install namespaced agentmemory skills plus an instruction file during setup, and keep the generated OpenCode config portable across local installs.
The OpenCode skill installer change should not carry docs/plans files on this feature branch. Remove the plan documents and the ignore rule that was only added to support them.
Viewer UI calls graph/build to populate knowledge graph from existing memories, but no handler existed. Adds endpoint that batches all stored memories through graph extraction to seed the graph on first load.
- messages.transform hook now falls back to cached activeSessionId since opencode doesn't pass sessionID in the hook input - Added process exit handler to call /session/end on SIGINT/SIGTERM, which triggers server-side auto-crystallization
The installer now adds a Stop hook that calls session-end.mjs, which triggers /session/end → auto-crystallization pipeline.
Avoid full dashboard redraws and use heap limits so live health stays accurate after refreshes and restarts. Limit half-open breaker probes and expire stale failures so provider errors do not inflate dashboard failure state.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (26)
📝 WalkthroughWalkthroughThis pull request introduces comprehensive AgentMemory integration infrastructure: a Bash installer ( Changes
Sequence Diagram(s)sequenceDiagram
participant OpenCode as OpenCode Client
participant Plugin as AgentMemory Plugin
participant Service as AgentMemory Service
participant KV as Session/Memory Store
Note over OpenCode,KV: Session Initialization
OpenCode->>Plugin: Chat started, system.transform hook
Plugin->>Service: POST /agentmemory/session/start<br/>{sessionId, project, cwd}
Service->>KV: Create/retrieve session
Service-->>Plugin: {context: "..."}
Plugin->>OpenCode: Inject context into system prompt
Note over OpenCode,KV: Message Processing
OpenCode->>Plugin: User sends message, messages.transform hook
Plugin->>Service: POST /agentmemory/context<br/>{sessionId, project, cwd, budget, prompt}
Service->>KV: Query relevant memories
Service-->>Plugin: {context: "..."}
Plugin->>OpenCode: Prepend context to user message
Note over OpenCode,KV: Tool Execution
OpenCode->>Plugin: Tool.execute.before: Read/Edit/Grep
Plugin->>Service: POST /agentmemory/enrich<br/>{sessionId, files, terms, toolName}
Service->>KV: Analyze file/term context
Service-->>Plugin: {enhancedContext: "..."}
OpenCode->>OpenCode: Execute tool with context
OpenCode->>Plugin: Tool.execute.after with result
Plugin->>Service: POST /agentmemory/observe<br/>{hookType, sessionId, tool_input, tool_output}
Service->>KV: Store observation, update graphs
Note over OpenCode,KV: Session Cleanup
OpenCode->>Plugin: Process exit/SIGINT/SIGTERM
Plugin->>Service: POST /agentmemory/session/end<br/>{sessionId}
Service->>KV: Finalize session, persist summaries
Estimated code review effort🎯 4 (Complex) | ⏱️ ~65 minutes Possibly related PRs
Poem
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@linuxdevel why is it closed please ? |
|
@yogeek I closed it because the PR was meant for my local fork. Sorry. My fork also has alot of other changes.. |
This pull request introduces major improvements to OpenCode and Claude integrations with agentmemory, enhances health monitoring, and adds planning documentation for upcoming dashboard and circuit breaker work. The most significant changes include new agentmemory integration plugins and hooks for OpenCode and Claude, improved health memory reporting, and detailed plans for reducing dashboard flicker and improving circuit breaker accuracy.
Agentmemory Integration for OpenCode and Claude:
integrations/opencode/plugin.js) that connects to the agentmemory backend, handling session lifecycle, context enrichment, and tool usage observation for memory-aware actions.integrations/claude-code/hooks/agentmemory-pretool.sh,agentmemory-posttool.sh,agentmemory-prompt.sh) to call agentmemory REST APIs for tool context enrichment, observation, and session context injection. [1] [2] [3]integrations/opencode/instructions-agentmemory-skills.md) describing when to use explicit agentmemory skills versus plugin-driven recall/capture.Health Monitoring Enhancements:
heapLimit) in the health snapshot and using it for more accurate memory usage thresholds. [1] [2] [3] [4]Dashboard and Circuit Breaker Planning:
Documentation and Usability:
README.mdto clarify OpenCode agentmemory installation steps and configuration merging, ensuring users understand the deployment and update process.Agentmemory Integration:
integrations/opencode/plugin.js).integrations/claude-code/hooks/agentmemory-pretool.sh,agentmemory-posttool.sh,agentmemory-prompt.sh). [1] [2] [3]integrations/opencode/instructions-agentmemory-skills.md).src/integrations/opencode-installer.js).Health Monitoring:
src/health/monitor.ts,src/health/thresholds.ts). [1] [2] [3] [4]Planning and Documentation:
docs/plans/2026-04-13-dashboard-live-updates-and-circuit-breaker-design.md,docs/plans/2026-04-13-dashboard-live-updates-and-circuit-breaker-plan.md). [1] [2]README.md.Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Documentation