opencode-morphllm 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,62 +4,189 @@
4
4
  [![npm](https://img.shields.io/npm/v/opencode-morphllm?style=flat-square)](https://www.npmjs.com/package/opencode-morphllm)
5
5
  [![downloads](https://img.shields.io/npm/dt/opencode-morphllm?style=flat-square)](https://www.npmjs.com/package/opencode-morphllm)
6
6
 
7
- This is an OpenCode Plugin for [MorphLLM](https://morphllm.com/). This plugin just adds in `edit_file` and `warpgrep_codebase_search` from MorphLLM to your agent configs as well as the intelligent model router for choosing different models based on the difficulty of the prompt.
7
+ An [OpenCode](https://opencode.ai/) plugin that integrates [MorphLLM](https://morphllm.com/)'s intelligent model routing and powerful MCP tools into your AI coding workflow.
8
8
 
9
- Github: https://github.com/VitoLin/opencode-morphllm
9
+ - **GitHub**: https://github.com/VitoLin/opencode-morphllm
10
+ - **NPM**: https://www.npmjs.com/package/opencode-morphllm
10
11
 
11
- NPM: https://www.npmjs.com/package/opencode-morphllm
12
+ ## Features
13
+
14
+ ### Intelligent Model Router
15
+
16
+ Automatically classifies your prompts by complexity (easy/medium/hard) and routes them to the most cost-effective and appropriate model. Save money on simple tasks while using powerful models only when needed.
17
+
18
+ ### MCP Tools
19
+
20
+ Adds MorphLLM's specialized MCP tools to OpenCode:
21
+
22
+ - **`edit_file`** - Fast, precise file editing tool optimized for code modifications
23
+ - **`warpgrep_codebase_search`** - Advanced codebase search with contextual understanding
24
+
25
+ ### Prompt Caching Optimization
26
+
27
+ Optional mode that maintains model consistency within a session, reducing costs through prompt caching.
12
28
 
13
29
  ## Installation
14
30
 
15
- In `~/.config/opencode/opencode.json`, add the following config:
31
+ ### 1. Install the Plugin
16
32
 
17
- ```
18
- "plugin": [
19
- "opencode-morphllm"
20
- ]
33
+ Add the plugin to your OpenCode configuration at `~/.config/opencode/opencode.json`:
34
+
35
+ ```json
36
+ {
37
+ "plugins": ["opencode-morphllm"]
38
+ }
21
39
  ```
22
40
 
23
- You can also set the `opencode-morphllm` config variables by creating a `json` file at `~/.config/opencode/morph.json`. You can find the provider and model ids from https://models.dev
41
+ ### 2. Configure MorphLLM
24
42
 
25
- Example configs:
43
+ Create a configuration file at `~/.config/opencode/morph.json`:
26
44
 
27
45
  ```json
28
46
  {
29
- "MORPH_API_KEY": "YOUR_API_KEY_HERE",
47
+ "MORPH_API_KEY": "your_morph_api_key_here",
30
48
  "MORPH_ROUTER_CONFIGS": {
31
49
  "MORPH_MODEL_EASY": "github-copilot/gpt-5-mini",
32
50
  "MORPH_MODEL_MEDIUM": "opencode/minimax-m2.1-free",
33
51
  "MORPH_MODEL_HARD": "github-copilot/gemini-2.5-pro",
34
52
  "MORPH_ROUTER_ENABLED": true,
35
- "MORPH_ROUTER_PROMPT_CACHING_AWARE": true
53
+ "MORPH_ROUTER_PROMPT_CACHING_AWARE": false
36
54
  }
37
55
  }
38
56
  ```
39
57
 
40
- Legacy format (still supported):
58
+ Find available models at [models.dev](https://models.dev).
59
+
60
+ ## Configuration Reference
61
+
62
+ ### Core Settings
63
+
64
+ | Option | Description | Required |
65
+ | --------------- | --------------------- | -------- |
66
+ | `MORPH_API_KEY` | Your MorphLLM API key | Yes |
67
+
68
+ ### Router Settings (inside `MORPH_ROUTER_CONFIGS`)
69
+
70
+ | Option | Description | Default |
71
+ | ----------------------------------- | --------------------------------------------------------- | -------------------- |
72
+ | `MORPH_ROUTER_ENABLED` | Enable/disable the intelligent router | `true` |
73
+ | `MORPH_MODEL_EASY` | Model for easy prompts (simple questions, formatting) | - |
74
+ | `MORPH_MODEL_MEDIUM` | Model for medium prompts (standard coding tasks) | - |
75
+ | `MORPH_MODEL_HARD` | Model for hard prompts (complex architecture, debugging) | - |
76
+ | `MORPH_MODEL_DEFAULT` | Fallback model when classification fails | `MORPH_MODEL_MEDIUM` |
77
+ | `MORPH_ROUTER_PROMPT_CACHING_AWARE` | Stick to first model per session for caching optimization | `false` |
78
+
79
+ ### Model Format
80
+
81
+ Models are specified as `provider/model-id`. Examples:
82
+
83
+ - `github-copilot/gpt-5-mini`
84
+ - `github-copilot/gemini-2.5-pro`
85
+ - `opencode/minimax-m2.1-free`
86
+
87
+ ### Legacy Format
88
+
89
+ For backward compatibility, you can also use flat configuration:
41
90
 
42
91
  ```json
43
92
  {
44
- "MORPH_API_KEY": "YOUR_API_KEY_HERE",
93
+ "MORPH_API_KEY": "your_key",
45
94
  "MORPH_MODEL_EASY": "github-copilot/gpt-5-mini",
46
95
  "MORPH_MODEL_MEDIUM": "opencode/minimax-m2.1-free",
47
96
  "MORPH_MODEL_HARD": "github-copilot/gemini-2.5-pro",
48
- "MORPH_ROUTER_ENABLED": true,
49
- "MORPH_ROUTER_PROMPT_CACHING_AWARE": true
97
+ "MORPH_ROUTER_ENABLED": true
50
98
  }
51
99
  ```
52
100
 
101
+ ### Project-Level Configuration
102
+
103
+ You can also configure per-project settings by creating `.opencode/morph.json` in your project root. Project settings override user settings.
104
+
105
+ ```
106
+ my-project/
107
+ ├── .opencode/
108
+ │ └── morph.json # Project-specific Morph config
109
+ └── src/
110
+ ```
111
+
112
+ Both `.json` and `.jsonc` (with comments) formats are supported.
113
+
114
+ ## How It Works
115
+
116
+ ### Intelligent Routing
117
+
118
+ When you send a prompt, the plugin:
119
+
120
+ 1. **Classifies** the prompt complexity using MorphLLM's classification engine
121
+ 2. **Selects** the appropriate model based on your configuration
122
+ 3. **Routes** the request to the chosen model
123
+
124
+ Example routing:
125
+
126
+ - "Format this JSON" → Easy → `MORPH_MODEL_EASY` (cheaper, faster)
127
+ - "Add a React component" → Medium → `MORPH_MODEL_MEDIUM`
128
+ - "Debug this race condition" → Hard → `MORPH_MODEL_HARD` (powerful)
129
+
130
+ ### Prompt Caching Mode
131
+
132
+ When `MORPH_ROUTER_PROMPT_CACHING_AWARE` is enabled:
133
+
134
+ - The first prompt in a session determines the model for all subsequent prompts
135
+ - Reduces costs through prompt caching with compatible providers
136
+ - Best for long conversations on similar topics
137
+
53
138
  ## Development
54
139
 
55
- After pulling down the package, set the OpenCode config path to the local repo
140
+ To work on the plugin locally:
56
141
 
57
- `~/.config/opencode/opencode.json`
142
+ 1. Clone the repository
143
+ 2. Point OpenCode to your local copy in `~/.config/opencode/opencode.json`:
58
144
 
59
145
  ```json
60
- "plugin": [
61
- "/path/to/morph-opencode-plugin/"
62
- ]
146
+ {
147
+ "plugins": ["/path/to/morph-opencode-plugin/"]
148
+ }
149
+ ```
150
+
151
+ 3. Changes are immediately reflected when you run OpenCode
152
+
153
+ ### Scripts
154
+
155
+ ```bash
156
+ # Build
157
+ bun run build
158
+
159
+ # Test
160
+ bun test
161
+
162
+ # Format
163
+ bun run format
63
164
  ```
64
165
 
65
- Now your changes will be reflected when you run OpenCode.
166
+ ## Troubleshooting
167
+
168
+ ### Plugin not loading
169
+
170
+ Ensure the plugin is properly listed in your OpenCode config:
171
+
172
+ ```json
173
+ {
174
+ "plugins": ["opencode-morphllm"]
175
+ }
176
+ ```
177
+
178
+ ### Router not working
179
+
180
+ Check that:
181
+
182
+ 1. `MORPH_API_KEY` is set correctly
183
+ 2. `MORPH_ROUTER_ENABLED` is not set to `false`
184
+ 3. At least one model is configured
185
+
186
+ ### Where to find models
187
+
188
+ Visit [models.dev](https://models.dev) to browse available models and their IDs.
189
+
190
+ ## License
191
+
192
+ [MIT](LICENSE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-morphllm",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "author": "Vito Lin",
5
5
  "main": "dist/index.js",
6
6
  "description": "OpenCode plugin for MorphLLM",
@@ -1,39 +0,0 @@
1
- name: Coverage
2
-
3
- on:
4
- push:
5
- branches: [main]
6
- pull_request:
7
- branches: [main]
8
-
9
- permissions:
10
- contents: write
11
-
12
- jobs:
13
- build:
14
- runs-on: ubuntu-latest
15
-
16
- steps:
17
- - uses: actions/checkout@v4
18
-
19
- - name: Install Bun
20
- run: |
21
- curl -fsSL https://bun.sh/install | bash
22
-
23
- - name: Install dependencies
24
- run: $HOME/.bun/bin/bun install
25
-
26
- - name: Run coverage
27
- run: $HOME/.bun/bin/bun test
28
-
29
- - name: Generate coverage badge
30
- run: |
31
- npx lcov-badge2 coverage/lcov.info -o coverage/coverage.svg
32
-
33
- - name: Commit coverage badge
34
- run: |
35
- git config --local user.email "action@github.com"
36
- git config --local user.name "GitHub Action"
37
- git add coverage/*.svg 2>/dev/null || echo "No badge files to add"
38
- git commit -m "Update coverage badge" || echo "No changes to commit"
39
- git push
package/.gitleaks.toml DELETED
@@ -1,6 +0,0 @@
1
- title = "Gitleaks Config"
2
-
3
- [[rules]]
4
- id = "morph-key"
5
- description = "Morph API Key"
6
- regex = "sk-[A-Za-z0-9_-]{48}"
package/.husky/pre-commit DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env sh
2
- . "$(dirname -- "$0")/_/husky.sh"
3
-
4
- bunx lint-staged
5
-
6
- gitleaks protect --staged --config .gitleaks.toml --verbose || true
package/.prettierignore DELETED
@@ -1 +0,0 @@
1
- dist/
package/.prettierrc DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "semi": true,
3
- "trailingComma": "es5",
4
- "singleQuote": true,
5
- "printWidth": 80,
6
- "tabWidth": 2,
7
- "useTabs": false
8
- }