opencode-lcm icon indicating copy to clipboard operation
opencode-lcm copied to clipboard

Array plugin-syntax

Open mblarsen opened this issue 8 months ago • 1 comments

What opencode version is supported I cannot load the plugin with the array syntax:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": [
    "opencode-antigravity-auth@latest",
    "oh-my-opencode-slim",
    [
      "opencode-lcm",
      {
        "scopeDefaults": {
          "grep": "session",
          "describe": "session"
        },
        "retention": {
          "staleSessionDays": 90,
          "deletedSessionDays": 30,
          "orphanBlobDays": 14
        },
        "automaticRetrieval": {
          "enabled": true,
          "scopeOrder": [
            "session",
            "root",
            "worktree"
          ],
          "scopeBudgets": {
            "session": 16,
            "root": 12,
            "worktree": 8,
            "all": 6
          },
          "stop": {
            "targetHits": 3,
            "stopOnFirstScopeWithHits": false
          },
          "maxMessageHits": 2,
          "maxSummaryHits": 1,
          "maxArtifactHits": 1
        },
        "freshTailMessages": 10,
        "minMessagesForTransform": 16,
        "summaryCharBudget": 1500,
        "systemHint": true,
        "binaryPreviewProviders": [
          "fingerprint",
          "byte-peek",
          "image-dimensions",
          "pdf-metadata"
        ],
        "previewBytePeek": 16
      }
    ]
  ]
}

Error:

Error: Configuration is invalid at $HOME/.config/opencode/opencode.json
↳ Invalid input: expected string, received array plugin.2
opencode --version
1.3.3

mblarsen avatar Apr 02 '26 05:04 mblarsen

Thanks for raising this. I looked into it and here's what's happening:

opencode-lcm itself already supports receiving options — the plugin function accepts a second rawOptions argument. The problem is that OpenCode's config schema currently only accepts plugin names as plain strings in the plugin array: { "plugin": ["opencode-lcm"] } When you try the tuple form ["opencode-lcm", { ... }], OpenCode's config validation rejects it before opencode-lcm ever runs. This is an OpenCode limitation, not a bug in this plugin. Workarounds you can use right now:

  1. Local wrapper plugin — Create a file at ~/.config/opencode/plugins/opencode-lcm-config.ts (or .opencode/plugins/ for project-level): import { GlobalOpencodeLcmPlugin } from "opencode-lcm" import type { Hooks, PluginInput } from "@opencode-ai/plugin" export const ConfiguredLcmPlugin = async (ctx: PluginInput): Promise => { return GlobalOpencodeLcmPlugin(ctx, { // your options here automaticRetrieval: { enabled: false }, retention: { deletedSessionDays: 60 }, }) } Then in your opencode.json: { "$schema": "https://opencode.ai/config.json", "plugin": ["opencode-lcm", "opencode-lcm-config"] }

  2. I can add an alternate config mechanism — opencode-lcm could read options from an environment variable (e.g. OPENCODE_LCM_OPTIONS) or a local file (e.g. .lcm/options.json). That way you wouldn't need the tuple syntax at all. If you'd like option 2, let me know which approach you prefer and I'll implement it. I can also open an issue upstream with OpenCode to request per-plugin config in opencode.json.

Plutarch01 avatar Apr 03 '26 19:04 Plutarch01