Skip to content

/dcp-compress slash command not registered on recent OpenCode versions (command snapshot timing) #609

Description

@1kUnD0G

Symptoms

  • DCP 3.1.14 installs cleanly and the debug log shows DCP initialized with no errors.
  • /dcp (TUI panel, registered via tui.json) works.
  • /dcp-compress never appears in the slash-command autocomplete list, and typing it manually sends it as a plain user message instead of triggering compression.

Root cause

Recent OpenCode versions (Effect-based refactor) build the slash-command list as a one-shot snapshot:

  1. packages/opencode/src/command/index.ts — the Command service's init() runs once on first access, expands cfg.command into a static record, and never re-reads config afterwards. There is no subscription to config changes.

  2. DCP registers the command inside its plugin config hook (index.ts):

    opencodeConfig.command["dcp-compress"] = { template: "", description: "..." }

    But that hook is invoked only after all plugins finish loading (packages/opencode/src/plugin/index.ts, "Notify plugins of current config" loop).

  3. The TUI requests the command list almost immediately at startup, so the Command snapshot is built before plugin config hooks run. The injected dcp-compress entry lands in cfg.command after the snapshot was taken and is never picked up.

The same race affects any plugin that registers commands via the config hook; DCP is just the most visible one.

Workaround

Manually declare the command in opencode.json so it exists at config-load time:

{
  "command": {
    "dcp-compress": {
      "template": "",
      "description": "Trigger DCP manual compression with: /dcp-compress [focus]"
    }
  }
}

DCP's "command.execute.before" handler matches by name (input.command === "dcp-compress"), so it intercepts the manually-declared command identically.

Proposed fix

Add a "chat.message" hook as a fallback: when a user message's text starts with /dcp-compress, run the same manual-trigger path (handleManualTriggerCommand -> state.pendingManualTrigger) and normalize the stored text to the canonical marker. This makes the command work even when the host never registered it. I have a PR ready.

Environment

  • DCP: 3.1.14 (npm)
  • OpenCode: 1.14.x (post Effect-refactor)
  • OS: Windows 11

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