OpenCode plugin for Morph Fast Apply - 10x faster code editing
npm install @f97/opencode-morph-fast-applyOpenCode plugin for Morph Fast Apply - 10x faster code editing with lazy edit markers.
- 10,500+ tokens/sec code editing via Morph's Fast Apply API
- Lazy edit markers (// ... existing code ...) - no exact string matching needed
- Unified diff output with context for easy review
- Graceful fallback - suggests native edit tool on API failure
``bash`
git clone https://github.com/JRedeker/opencode-morph-fast-apply.git ~/dev/oc-plugins/morph-fast-apply
cd ~/dev/oc-plugins/morph-fast-apply
npm install
Get an API key at morphllm.com/dashboard, then add to your shell profile:
`bash`
export MORPH_API_KEY="sk-your-key-here"
Add to your global config (~/.config/opencode/opencode.json):
`json`
{
"plugin": [
"/path/to/morph-fast-apply"
],
"instructions": [
"/path/to/morph-fast-apply/MORPH_INSTRUCTIONS.md"
]
}
Or in a project-local .opencode/config.json:
`json`
{
"plugin": [
"~/dev/oc-plugins/morph-fast-apply"
],
"instructions": [
"~/dev/oc-plugins/morph-fast-apply/MORPH_INSTRUCTIONS.md"
]
}
The morph_edit tool will now be available.
The LLM can use morph_edit for efficient partial file edits:
`// ... existing code ...
morph_edit({
target_filepath: "src/auth.ts",
instructions: "Add error handling for invalid tokens",
code_edit:
function validateToken(token) {
if (!token) {
throw new Error("Token is required");
}
// ... existing code ...
}
// ... existing code ...`
})
| Situation | Tool | Reason |
|-----------|------|--------|
| Small, exact replacement | edit | Fast, no API call |morph_edit
| Large file (500+ lines) | | Handles partial snippets |morph_edit
| Multiple scattered changes | | Batch efficiently |morph_edit
| Whitespace-sensitive | | Forgiving with formatting |
| Variable | Default | Description |
|----------|---------|-------------|
| MORPH_API_KEY | (required) | Your Morph API key |MORPH_API_URL
| | https://api.morphllm.com | API endpoint |MORPH_MODEL
| | morph-v3-fast | Model (morph-v3-fast, morph-v3-large, auto) |MORPH_TIMEOUT
| | 30000 | Request timeout in ms |
1. Reads the original file content
2. Sends , , and
3. Morph intelligently merges the lazy edit markers with original code
4. Writes the merged result back to the file
5. Returns a unified diff showing what changed
Contributions welcome! This plugin could potentially be integrated into OpenCode core.