Skip to content

plugin for opencode #279

Description

@tan-wei-xin-alez

I like using plugins that are automatically loaded every session in opencode so I created the following one based on https://github.com/ayghri/i-have-adhd/blob/main/.opencode/plugins/i-have-adhd.mjs, might be useful to some people who don't want to have to manually keep calling this skill

➜  ~ cat opencode/humanizer/.opencode/plugins/humanizer.mjs
// Humanizer OpenCode plugin.
// Injects the shared Humanizer rules into every chat system prompt.

import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const skillPath = path.resolve(__dirname, '../../SKILL.md');

function rulesetBody() {
  return fs
    .readFileSync(skillPath, 'utf8')
    .replace(/^---[^\S\r\n]*\r?\n[\s\S]*?\r?\n---[^\S\r\n]*(?:\r?\n|$)/, '')
    .replace(/(?:\r?\n)+$/, '');
}

export default async () => ({
  'experimental.chat.system.transform': async (_input, output) => {
    let body;
    try {
      body = rulesetBody();
    } catch (_error) {
      return;
    }

    output.system.push(
      'HUMANIZER MODE ACTIVE. Apply these rules to assistant prose while preserving code, commands, paths, structured data, URLs, quoted text, and exact-output requests.\n\n' +
        body,
    );
  },
});

Testing

  ┃
  ┃  are ponytail, i-have-adhd and humanizer plugins called automatically every opencode session?
  ┃

     Thought · 5ms

     Yes, in this session:

     - ponytail: active automatically at full level.
     - i-have-adhd: active automatically and marked always-on.
     - humanizer: active automatically.

     They are not being invoked as tool calls each session. Their instructions were injected into the session
     context by the OpenCode configuration or session setup.

     The separate skill tool is only needed when loading a skill listed under available_skills; these three are
     already active before any tool call.

     ▣  Plan · GPT-5.6 Luna · 7.7s

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions