Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@morphllm/opencode-morph-plugin

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@morphllm/opencode-morph-plugin

OpenCode plugin for Morph SDK - fast apply, WarpGrep codebase search

Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
396
-53.63%
Maintainers
2
Weekly downloads
 
Created
Source

opencode-morph-plugin

OpenCode plugin for Morph. Three tools:

  • Fast Apply — 10,500+ tok/s code editing with lazy markers
  • WarpGrep — fast agentic codebase search, +4% on SWE-Bench Pro, -15% cost
  • Compaction — 25,000+ tok/s context compression in sub-2s, +0.6% on SWE-Bench Pro

WarpGrep SWE-bench Pro Benchmarks

On production repos and SWE-Bench Pro, enabling WarpGrep and compaction improves task accuracy by 6%, reduces cost, and is net 28% faster.

Setup

1. Get an API key

Sign up at morphllm.com/dashboard and add it to your environment:

export MORPH_API_KEY="sk-..."

2. Install the plugin

Add to ~/.config/opencode/plugin/:

ln -s /path/to/opencode-morph-plugin/index.ts ~/.config/opencode/plugin/morph.ts

Add the SDK dependency to ~/.config/opencode/package.json:

{
  "dependencies": {
    "@morphllm/morphsdk": "^0.2.134"
  }
}

OpenCode runs bun install at startup to install it.

When published as an npm package: { "plugin": ["@morphllm/opencode-morph-plugin"] }

Copy the packaged routing policy so the LLM picks the right tool:

cp instructions/morph-tools.md ~/.config/opencode/instructions/

Then reference it in your opencode.json:

{
  "instructions": ["~/.config/opencode/instructions/morph-tools.md"]
}

Fast Apply (morph_edit)

10,500+ tok/s code merging. The LLM writes partial snippets with lazy markers, Morph merges them into the full file.

  LLM generates partial edit         Morph merges into full file
  with lazy markers                  at 10,500+ tok/s

  // ... existing code ...           function validateToken(token) {
  function validateToken(token) {      const decoded = jwt.verify(token);
    if (!token) {             ──>      if (!token) {
      throw new Error("...");            throw new Error("...");
    }                                  }
    // ... existing code ...           return decoded;
  }                                  }
  // ... existing code ...           export default validateToken;

  ┌──────────┐    ┌───────────┐    ┌──────────┐    ┌──────────┐
  │ code_edit │───>│ Morph API │───>│ safety   │───>│ write to │
  │ + file   │    │ merge     │    │ guards   │    │ disk     │
  └──────────┘    └───────────┘    └──────────┘    └──────────┘
                                    marker leak?
                                    truncation?

Safety guards block writes when: no markers on files >10 lines, markers leak into merged output, or merged output loses >60% chars / >50% lines.

Fast agentic codebase search. +4% accuracy on SWE-Bench Pro, -15% cost, sub-6s per query.

  Query                               Fast agentic search

  "How does auth                     Turn 1: ripgrep "auth" "token" "jwt"
   middleware work?"                 Turn 2: read src/middleware/auth.ts
           │                         Turn 3: ripgrep "verifyToken"
           v                         Turn 4: read src/utils/jwt.ts
  ┌──────────────┐                            │
  │ WarpGrep     │    ┌─────────┐             v
  │ Agent        │───>│ ripgrep │    ┌──────────────────┐
  │ (multi-turn) │    │ read    │    │ 5 file contexts  │
  │              │───>│ ls      │───>│ with line ranges │
  └──────────────┘    └─────────┘    └──────────────────┘
    4 turns, sub-6s                   src/middleware/auth.ts:15-42
                                      src/utils/jwt.ts:1-28
                                      ...

Use for exploratory queries ("how does X work?", "where is Y handled?"). For exact keyword lookup, use grep directly.

State-of-the-Art Compaction

25,000+ tok/s context compression in under 2 seconds. +0.6% on SWE-Bench Pro, where summarization-based compaction methods all hurt performance. Fires at 140k chars (~35k tokens), before OpenCode's built-in auto-compact (95% context window). Results cached per message set.

  Every LLM call                      Only fires when context is large

  ┌───────────────────────────────────────────────────┐
  │              Message History (20 msgs)             │
  │  msg1  msg2  msg3  ...  msg14 │ msg15 ... msg20   │
  │  ──────── older ─────────────   ── recent (6) ──  │
  └───────────────────────────────────────────────────┘
                    │                       │
        total > 140k chars?                  │
                    │                       │
                    v                       │
          ┌─────────────────┐               │
          │ Morph Compact   │               │
          │ API (~2s)       │               │
          │ 30% kept        │               │
          └────────┬────────┘               │
                   │                        │
                   v                        v
  ┌───────────────────────────────────────────────────┐
  │  [compacted summary]   │ msg15  msg16 ... msg20   │
  │  ────── 1 msg ───────    ──── recent (6) ──────   │
  └───────────────────────────────────────────────────┘
              7 messages sent to LLM
              (cached for subsequent calls)

Tool selection guide

TaskToolWhy
Large file (300+ lines)morph_editPartial snippets, no exact matching
Multiple scattered changesmorph_editBatch edits efficiently
Small exact replacementeditFaster, no API call
New file creationwritemorph_edit only edits existing files
Codebase search/explorationwarpgrep_codebase_searchFast agentic search
Exact keyword lookupgrepDirect ripgrep, no API call

Configuration

VariableDefaultDescription
MORPH_API_KEYrequiredYour Morph API key
MORPH_EDITtrueSet false to disable Fast Apply
MORPH_WARPGREPtrueSet false to disable WarpGrep
MORPH_COMPACTtrueSet false to disable compaction
MORPH_COMPACT_CHAR_THRESHOLD140000Char count before compaction triggers
MORPH_COMPACT_RATIO0.3Compression ratio (0.05-1.0, lower = more aggressive)

Development

bun install
bun test          # 57 tests
bun run typecheck # tsc --noEmit

License

MIT

Keywords

opencode

FAQs

Package last updated on 09 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts