Skip to content

[FEATURE]: add opencode support #1

@MaksimSkorobogatov

Description

@MaksimSkorobogatov

Summary

Add OpenCode (terminal-based AI coding agent) to the list of supported agents in agentMemory.

Why

OpenCode is a popular open-source AI coding agent (Go-based TUI, ~140K GitHub stars) that already supports MCP servers natively via its opencode.json config. It would be a natural fit for agentMemory's persistent memory system.

MCP Server Config Format for OpenCode

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "agentmemory": {
      "type": "local",
      "command": ["node", "/path/to/mcp-server/server.js", "project-id", "/path/to/workspace"],
      "enabled": true
    }
  }
}

Note: OpenCode uses "type": "local" and "command" as an array (not "command" + "args" separately).

Proposed Changes

  1. src/config.ts — Add OpenCode detection (check for opencode.json in workspace or opencode in PATH) and write MCP config to opencode.json instead of VS Code settings.

  2. src/interceptor.ts — Add injectOpenCodeRules() method that:

    • Creates/updates AGENTS.md with agentMemory instructions at the project root
    • Creates .opencode/commands/memory-search.md custom command
    • Creates .opencode/commands/memory-write.md custom command
  3. src/mcp-server/memory-bank-sync.ts — Add OpenCode agent config:

    {
      name: 'opencode',
      memoryBankPath: '.opencode/memory-bank',
      fileMapping: {
        'architecture.md': { type: 'architecture', tags: ['design', 'system'] },
        'patterns.md': { type: 'pattern', tags: ['patterns', 'design'] },
        'decisions.md': { type: 'decision', tags: ['decisions', 'tech'] },
        'features.md': { type: 'feature', tags: ['features', 'product'] }
      }
    }

    Also add sync to AGENTS.md since that's what OpenCode reads at session start.

  4. Extension activation — OpenCode doesn't use VS Code extensions, so the integration would work via:

    • Manual MCP server configuration in opencode.json
    • Or a helper script that auto-configures opencode.json

OpenCode-Specific Notes

  • OpenCode MCP tools are prefixed with the server name: agentmemory_memory_search, agentmemory_memory_write, etc.
  • OpenCode supports both local (stdio) and remote (SSE) MCP servers
  • OpenCode reads AGENTS.md at session start for project context — this is the equivalent of KiloCode's memory bank files
  • Custom commands in .opencode/commands/ support $ARGUMENTS placeholder and frontmatter for description, agent, model

References


This issue is suitable as a task for a coding agent.

I can open a PR if it's welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions