Skip to content

ryanrhughes/opencode-plugin-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

opencode-plugin-test

A test plugin demonstrating OpenCode's native bundled extensions support for commands, skills, agents, and MCP servers.

Features

Agents

Agent Description
reviewer Expert code reviewer for analyzing code quality and issues
documenter Documentation specialist for writing clear docs

Commands

Command Description
/analyze Analyze code for issues and improvements
/explain Explain code or concepts in detail
/test-gen Generate tests for code or functionality

Skills

Skill Description
git-workflow Git workflow best practices
debugging Systematic debugging techniques

MCP Servers

Server Description
context7 Library documentation via Context7

Installation

From Source (Development)

  1. Clone and build:
cd ~/Work/opencode-plugin
npm install
npm run build
  1. Add to your .opencode/config.json:
{
  "plugin": ["file:///home/ryan/Work/opencode-plugin/dist/index.js"]
}

From npm (After Publishing)

{
  "plugin": ["opencode-plugin-test@latest"]
}

Project Structure

src/
  agents/         # Agent definitions
    reviewer.ts
    documenter.ts
    index.ts
  commands/       # Command definitions
    analyze.ts
    explain.ts
    test-gen.ts
    index.ts
  skills/         # Skill definitions
    git-workflow.ts
    debugging.ts
    index.ts
  mcp/            # MCP server configs
    index.ts
  index.ts        # Main plugin entry

How It Works

This plugin uses OpenCode's native extension bundling:

import type { Plugin } from "@opencode-ai/plugin";
import { reviewer, documenter } from "./agents";
import { analyze, explain, testGen } from "./commands";
import { gitWorkflow, debugging } from "./skills";
import { builtinMcps } from "./mcp";

export const TestPlugin: Plugin = async (ctx) => {
  return {
    // Native agent registration
    agent: {
      reviewer,
      documenter,
    },

    // Native command registration
    command: {
      analyze,
      explain,
      "test-gen": testGen,
    },

    // Native skill registration
    skill: {
      "git-workflow": gitWorkflow,
      debugging,
    },

    // MCP via config hook
    config: async (config) => {
      config.mcp = config.mcp || {};
      for (const [name, mcp] of Object.entries(builtinMcps)) {
        if (!config.mcp[name]) {
          config.mcp[name] = mcp;
        }
      }
    },
  };
};

Precedence

Extensions are loaded in order (later wins):

  1. Built-in
  2. Plugin-provided (this plugin)
  3. Config-based (~/.config/opencode/)
  4. File-based (.opencode/command/*.md, etc.)

Users can override any plugin-provided extension by creating a file-based version.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published