@hiai-gg/hiai-opencode 0.1.2 → 0.1.3
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/.env.example +14 -3
- package/AGENTS.md +111 -8
- package/ARCHITECTURE.md +6 -6
- package/README.md +145 -25
- package/assets/mcp/mempalace.mjs +47 -4
- package/assets/mcp/playwright.mjs +76 -0
- package/dist/config/defaults.d.ts +3 -0
- package/dist/config/platform-schema.d.ts +2 -0
- package/dist/index.js +220 -175
- package/dist/mcp/registry.d.ts +14 -0
- package/dist/mcp/types.d.ts +6 -0
- package/hiai-opencode.json +2 -2
- package/package.json +1 -1
- package/src/config/defaults.ts +5 -62
- package/src/config/loader.ts +4 -1
- package/src/config/platform-schema.ts +1 -0
- package/src/index.ts +1 -0
- package/src/mcp/index.ts +0 -33
- package/src/mcp/omo-mcp-index.ts +0 -5
- package/src/mcp/registry.ts +132 -0
- package/src/mcp/types.ts +11 -1
package/.env.example
CHANGED
|
@@ -32,7 +32,7 @@ OPENROUTER_API_KEY=your_openrouter_api_key_here
|
|
|
32
32
|
# Optional - Stitch AI remote MCP service
|
|
33
33
|
# STITCH_AI_API_KEY=your_stitch_api_key_here
|
|
34
34
|
|
|
35
|
-
# Optional - Firecrawl web scraping MCP
|
|
35
|
+
# Optional - Firecrawl web scraping MCP
|
|
36
36
|
# FIRECRAWL_API_KEY=your_firecrawl_api_key_here
|
|
37
37
|
|
|
38
38
|
# Optional - Context7 code search MCP
|
|
@@ -51,7 +51,18 @@ OPENROUTER_API_KEY=your_openrouter_api_key_here
|
|
|
51
51
|
# Optional - Python command for MemPalace MCP (python3, python, or full path)
|
|
52
52
|
# MEMPALACE_PYTHON=python3
|
|
53
53
|
|
|
54
|
+
# Optional - custom MemPalace data directory
|
|
55
|
+
# MEMPALACE_PALACE_PATH=./.opencode/palace
|
|
56
|
+
|
|
57
|
+
# Optional - set to 0, false, or no to prevent first-run Python package install
|
|
58
|
+
# HIAI_MCP_AUTO_INSTALL=1
|
|
59
|
+
|
|
60
|
+
# Playwright MCP
|
|
61
|
+
|
|
62
|
+
# Optional - set to 1, true, or yes to install Chromium during launcher startup
|
|
63
|
+
# HIAI_PLAYWRIGHT_INSTALL_BROWSERS=0
|
|
64
|
+
|
|
54
65
|
# RAG MCP
|
|
55
66
|
|
|
56
|
-
# Optional - RAG
|
|
57
|
-
#
|
|
67
|
+
# Optional - RAG search tool endpoint
|
|
68
|
+
# OPENCODE_RAG_URL=http://localhost:9002/tools/search
|
package/AGENTS.md
CHANGED
|
@@ -4,7 +4,9 @@ This file is for autonomous agents or tooling that need to install, configure, v
|
|
|
4
4
|
|
|
5
5
|
## Purpose
|
|
6
6
|
|
|
7
|
-
`hiai-opencode` is an OpenCode plugin repository published as `@hiai-gg/hiai-opencode`. It is not a standalone app.
|
|
7
|
+
`hiai-opencode` is an OpenCode plugin repository published as `@hiai-gg/hiai-opencode`. It is not a standalone app. It wires OpenCode agents, prompts, skills, MCP server launch commands, LSP defaults, and compatibility behavior around external upstream tools. Do not describe MCP servers, skills, model providers, or auxiliary OpenCode plugins as owned by this repository.
|
|
8
|
+
|
|
9
|
+
The normal workflow is:
|
|
8
10
|
|
|
9
11
|
1. install it through OpenCode or build it locally
|
|
10
12
|
2. register `@hiai-gg/hiai-opencode` in OpenCode
|
|
@@ -15,7 +17,19 @@ This file is for autonomous agents or tooling that need to install, configure, v
|
|
|
15
17
|
|
|
16
18
|
### Native OpenCode Install
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
Use the OpenCode plugin CLI:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
opencode plugin @hiai-gg/hiai-opencode@latest --global
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Optional Dynamic Context Pruning plugin:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
opencode plugin @tarquinen/opencode-dcp@latest --global
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Manual alternative:
|
|
19
33
|
|
|
20
34
|
```json
|
|
21
35
|
{
|
|
@@ -33,7 +47,13 @@ bun run build
|
|
|
33
47
|
|
|
34
48
|
### Register In OpenCode
|
|
35
49
|
|
|
36
|
-
|
|
50
|
+
Use the plugin CLI:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
opencode plugin @hiai-gg/hiai-opencode@latest --global
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Manual alternative:
|
|
37
57
|
|
|
38
58
|
```json
|
|
39
59
|
{
|
|
@@ -49,6 +69,85 @@ opencode debug config
|
|
|
49
69
|
opencode mcp list --print-logs --log-level INFO
|
|
50
70
|
```
|
|
51
71
|
|
|
72
|
+
## Post-Install Bootstrap Instructions
|
|
73
|
+
|
|
74
|
+
When a user asks OpenCode or another agent to finish installing this plugin, follow this procedure.
|
|
75
|
+
|
|
76
|
+
### Operating Rules
|
|
77
|
+
|
|
78
|
+
- Keep OpenCode plugins separate from MCP servers.
|
|
79
|
+
- Register `@hiai-gg/hiai-opencode` as an OpenCode plugin.
|
|
80
|
+
- Register `@tarquinen/opencode-dcp` only when the user wants Dynamic Context Pruning; it is a separate OpenCode plugin.
|
|
81
|
+
- Do not add MCP server npm packages to the OpenCode `plugin` array.
|
|
82
|
+
- Use `hiai-opencode.json` as the project-level service switchboard.
|
|
83
|
+
- Use `src/mcp/registry.ts` as the source of truth for default MCP launch wiring.
|
|
84
|
+
- Use `.env.example` as the key template, but never print, invent, commit, or hardcode secret values.
|
|
85
|
+
- Prefer user-level or project-local installs. Do not use sudo/admin rights unless the user explicitly asks.
|
|
86
|
+
|
|
87
|
+
### Bootstrap Checklist
|
|
88
|
+
|
|
89
|
+
1. Check tool availability:
|
|
90
|
+
- `opencode --version`
|
|
91
|
+
- `node --version`
|
|
92
|
+
- `npx --version`
|
|
93
|
+
- `bun --version`
|
|
94
|
+
- `python --version` or `python3 --version`
|
|
95
|
+
- `uv --version` when available
|
|
96
|
+
2. Check plugin registration with `opencode debug config`.
|
|
97
|
+
3. Find or create `hiai-opencode.json` in the project root or `.opencode/`.
|
|
98
|
+
4. Configure the `mcp` object there. Disable services that cannot run on the host.
|
|
99
|
+
5. Check environment variables without printing values:
|
|
100
|
+
- `OPENROUTER_API_KEY`
|
|
101
|
+
- `FIRECRAWL_API_KEY`
|
|
102
|
+
- `STITCH_AI_API_KEY`
|
|
103
|
+
- `CONTEXT7_API_KEY`
|
|
104
|
+
- `MEMPALACE_PYTHON`
|
|
105
|
+
- `OPENCODE_RAG_URL`
|
|
106
|
+
- `HIAI_PLAYWRIGHT_INSTALL_BROWSERS`
|
|
107
|
+
- `HIAI_MCP_AUTO_INSTALL`
|
|
108
|
+
6. Verify with:
|
|
109
|
+
- `opencode debug config`
|
|
110
|
+
- `opencode mcp list --print-logs --log-level INFO`
|
|
111
|
+
|
|
112
|
+
### MCP Setup Matrix
|
|
113
|
+
|
|
114
|
+
| Service | Enable when | Dependency behavior |
|
|
115
|
+
|---|---|---|
|
|
116
|
+
| `playwright` | Node and npx are available | Helper launcher runs `@playwright/mcp@latest`; set `HIAI_PLAYWRIGHT_INSTALL_BROWSERS=1` to install Chromium on first start |
|
|
117
|
+
| `sequential-thinking` | Node and npx are available | Helper launcher runs `@modelcontextprotocol/server-sequential-thinking` |
|
|
118
|
+
| `firecrawl` | `FIRECRAWL_API_KEY` is set | Helper launcher runs `firecrawl-mcp` |
|
|
119
|
+
| `mempalace` | `uv` is available, or Python 3.9+ with pip is available | Launcher prefers `uv`; otherwise uses Python and can run `python -m pip install --user mempalace` when `HIAI_MCP_AUTO_INSTALL` is not disabled |
|
|
120
|
+
| `rag` | User has a local or remote RAG endpoint | Uses `OPENCODE_RAG_URL`, defaulting to `http://localhost:9002/tools/search` |
|
|
121
|
+
| `stitch` | `STITCH_AI_API_KEY` is set | Remote MCP endpoint |
|
|
122
|
+
| `context7` | User wants Context7 docs/search | Remote MCP endpoint; use `CONTEXT7_API_KEY` if available |
|
|
123
|
+
|
|
124
|
+
### Prompt For OpenCode Users
|
|
125
|
+
|
|
126
|
+
Users can paste this into OpenCode after installing the plugin:
|
|
127
|
+
|
|
128
|
+
```text
|
|
129
|
+
Finish hiai-opencode setup in this workspace.
|
|
130
|
+
|
|
131
|
+
Keep OpenCode plugins separate from MCP servers. Do not add MCP server packages to the OpenCode plugin list.
|
|
132
|
+
|
|
133
|
+
Verify @hiai-gg/hiai-opencode is registered. If I ask for Dynamic Context Pruning, install @tarquinen/opencode-dcp as a separate OpenCode plugin.
|
|
134
|
+
|
|
135
|
+
Find or create hiai-opencode.json in the project root or .opencode/. Use its mcp object as the only switchboard for MCP enable/disable.
|
|
136
|
+
|
|
137
|
+
Check which services can run here:
|
|
138
|
+
- playwright: node/npx; optionally HIAI_PLAYWRIGHT_INSTALL_BROWSERS=1.
|
|
139
|
+
- sequential-thinking: node/npx.
|
|
140
|
+
- firecrawl: FIRECRAWL_API_KEY.
|
|
141
|
+
- mempalace: uv or Python 3.9+ with pip; MEMPALACE_PYTHON if needed; HIAI_MCP_AUTO_INSTALL controls first-run pip install.
|
|
142
|
+
- rag: OPENCODE_RAG_URL or http://localhost:9002/tools/search.
|
|
143
|
+
- stitch: STITCH_AI_API_KEY.
|
|
144
|
+
- context7: optional CONTEXT7_API_KEY.
|
|
145
|
+
|
|
146
|
+
Report missing keys without printing secret values. Never invent or hardcode API keys.
|
|
147
|
+
|
|
148
|
+
Run opencode debug config and opencode mcp list --print-logs --log-level INFO if available. If something is missing, propose or run only user-level/project-local install commands.
|
|
149
|
+
```
|
|
150
|
+
|
|
52
151
|
## Expected Agent State
|
|
53
152
|
|
|
54
153
|
Visible primary agents:
|
|
@@ -129,8 +228,8 @@ Use this table when you need to change something and want the right file immedia
|
|
|
129
228
|
| Change closure protocol appended to prompts | [src/shared/closure-protocol.ts](src/shared/closure-protocol.ts) | It is injected after prompt construction |
|
|
130
229
|
| Change prompt override / prompt_append behavior | `src/agents/builtin-agents/agent-overrides.ts` | Override merge logic lives there |
|
|
131
230
|
| Change environment context appended to prompts | `src/agents/builtin-agents/environment-context.ts` | Runtime environment prompt injection lives there |
|
|
132
|
-
| Change MCP defaults | [src/
|
|
133
|
-
| Change
|
|
231
|
+
| Change MCP defaults | [src/mcp/registry.ts](src/mcp/registry.ts) | Default MCP wiring lives there |
|
|
232
|
+
| Change OpenCode MCP assembly | [src/mcp/index.ts](src/mcp/index.ts) | Final MCP config assembly lives there |
|
|
134
233
|
| Change local MCP helper launcher logic | `assets/mcp/*` | Runtime launcher scripts live there |
|
|
135
234
|
| Change npm bootstrap behavior for MCP/LSP tools | [assets/runtime/npm-package-runner.mjs](assets/runtime/npm-package-runner.mjs) | Shared npm bootstrap logic lives there |
|
|
136
235
|
| Change LSP defaults | [src/config/defaults.ts](src/config/defaults.ts) | LSP defaults live there |
|
|
@@ -204,11 +303,11 @@ So:
|
|
|
204
303
|
|
|
205
304
|
## MCP Rules
|
|
206
305
|
|
|
207
|
-
Default MCP
|
|
306
|
+
Default MCP wiring lives in:
|
|
208
307
|
|
|
209
|
-
- [src/
|
|
308
|
+
- [src/mcp/registry.ts](src/mcp/registry.ts)
|
|
210
309
|
|
|
211
|
-
|
|
310
|
+
OpenCode MCP config assembly lives in:
|
|
212
311
|
|
|
213
312
|
- [src/mcp/index.ts](src/mcp/index.ts)
|
|
214
313
|
|
|
@@ -248,6 +347,10 @@ Common keys:
|
|
|
248
347
|
- `OLLAMA_BASE_URL`
|
|
249
348
|
- `OLLAMA_MODEL`
|
|
250
349
|
- `MEMPALACE_PYTHON`
|
|
350
|
+
- `MEMPALACE_PALACE_PATH`
|
|
351
|
+
- `OPENCODE_RAG_URL`
|
|
352
|
+
- `HIAI_PLAYWRIGHT_INSTALL_BROWSERS`
|
|
353
|
+
- `HIAI_MCP_AUTO_INSTALL`
|
|
251
354
|
|
|
252
355
|
## Known Runtime Caveats
|
|
253
356
|
|
package/ARCHITECTURE.md
CHANGED
|
@@ -187,10 +187,10 @@ The final runtime prompt can also be affected by:
|
|
|
187
187
|
|
|
188
188
|
## Skills
|
|
189
189
|
|
|
190
|
-
Two skill sources are
|
|
190
|
+
Two skill sources are wired into OpenCode:
|
|
191
191
|
|
|
192
|
-
- project
|
|
193
|
-
-
|
|
192
|
+
- project skill definitions in [skills](skills)
|
|
193
|
+
- skill materialization into the OpenCode-visible skill tree
|
|
194
194
|
|
|
195
195
|
Relevant files:
|
|
196
196
|
|
|
@@ -201,11 +201,11 @@ Relevant files:
|
|
|
201
201
|
|
|
202
202
|
### Definitions
|
|
203
203
|
|
|
204
|
-
Default MCP
|
|
204
|
+
Default MCP wiring is in:
|
|
205
205
|
|
|
206
|
-
- [src/
|
|
206
|
+
- [src/mcp/registry.ts](src/mcp/registry.ts)
|
|
207
207
|
|
|
208
|
-
|
|
208
|
+
OpenCode MCP config assembly is in:
|
|
209
209
|
|
|
210
210
|
- [src/mcp/index.ts](src/mcp/index.ts)
|
|
211
211
|
|
package/README.md
CHANGED
|
@@ -1,14 +1,40 @@
|
|
|
1
1
|
# hiai-opencode
|
|
2
2
|
|
|
3
|
-
`hiai-opencode` is an OpenCode plugin that
|
|
3
|
+
`hiai-opencode` is an OpenCode plugin that wires together:
|
|
4
4
|
|
|
5
5
|
- a curated multi-agent runtime
|
|
6
|
-
- project and
|
|
6
|
+
- project and OpenCode skills
|
|
7
7
|
- MCP integrations
|
|
8
8
|
- LSP defaults
|
|
9
9
|
- migration and compatibility wiring
|
|
10
10
|
|
|
11
11
|
This repository is intended to be usable by someone who clones it from GitHub without any internal context.
|
|
12
|
+
The external MCP servers, skills, model providers, and auxiliary OpenCode plugins remain their own upstream projects; this plugin only provides OpenCode wiring, defaults, prompts, launchers, and documentation around them.
|
|
13
|
+
|
|
14
|
+
## Why This Exists
|
|
15
|
+
|
|
16
|
+
I wanted the "one install, give me the whole cockpit" setup. More agents, more MCP servers, more skills, better defaults, fewer tiny config islands. 🚀
|
|
17
|
+
|
|
18
|
+
The problem: all those great tools do not magically become friends just because you installed them. Some are npm packages, some are Python tools, some need API keys, some need a local service, and some only wake up after the first run. Meanwhile your main agent can waste half the context window just reading everything you bolted on. Not chill. 😅
|
|
19
|
+
|
|
20
|
+
So `hiai-opencode` is my attempt to wire the best pieces I use into one OpenCode-friendly shape: agents, prompts, skills, MCP launchers, LSP defaults, and a clean config surface. It does not claim ownership of the upstream tools. It just tries to make them cooperate.
|
|
21
|
+
|
|
22
|
+
After the first install, a few MCP services may still need local dependencies or keys. You have two options:
|
|
23
|
+
|
|
24
|
+
- Follow the setup sections below: [Install](#install), [Environment](#environment), and [MCP Service Notes](#mcp-service-notes).
|
|
25
|
+
- Or ask OpenCode to do the boring part for you. Paste this after installing:
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
Read AGENTS.md and finish hiai-opencode setup for this workspace.
|
|
29
|
+
|
|
30
|
+
Keep OpenCode plugins separate from MCP servers. Do not add MCP server packages to the OpenCode plugin list.
|
|
31
|
+
|
|
32
|
+
Check which MCP services can run on this machine, update hiai-opencode.json, install only missing user-level or project-local dependencies, and report missing API keys without printing secret values.
|
|
33
|
+
|
|
34
|
+
Then run opencode debug config and opencode mcp list --print-logs --log-level INFO if available.
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
For the full operator playbook, see [AGENTS.md](AGENTS.md). 🤖
|
|
12
38
|
|
|
13
39
|
## What You Get
|
|
14
40
|
|
|
@@ -20,7 +46,7 @@ This repository is intended to be usable by someone who clones it from GitHub wi
|
|
|
20
46
|
- `deep`, `ultrabrain`, `visual-engineering`, `artistry`, and `unspecified-high` are the deep Coder contour
|
|
21
47
|
- `Critic` and `Researcher` are selected explicitly
|
|
22
48
|
- `Designer`, `Brainstormer`, `Manager`, and `Vision` are direct callable specialists
|
|
23
|
-
-
|
|
49
|
+
- Skill materialization into OpenCode's `skills/` view
|
|
24
50
|
- MCP wiring for `playwright`, `stitch`, `sequential-thinking`, `firecrawl`, `rag`, `mempalace`, `context7`, plus remote `websearch` and `grep_app`
|
|
25
51
|
- LSP wiring for TypeScript, Svelte, Python, Bash, and ESLint
|
|
26
52
|
|
|
@@ -47,9 +73,19 @@ Optional, depending on which services you want:
|
|
|
47
73
|
|
|
48
74
|
## Install
|
|
49
75
|
|
|
50
|
-
Recommended native OpenCode install
|
|
76
|
+
Recommended native OpenCode install:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
opencode plugin @hiai-gg/hiai-opencode@latest --global
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Optional DCP plugin:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
opencode plugin @tarquinen/opencode-dcp@latest --global
|
|
86
|
+
```
|
|
51
87
|
|
|
52
|
-
|
|
88
|
+
Manual config alternative:
|
|
53
89
|
|
|
54
90
|
```json
|
|
55
91
|
{
|
|
@@ -81,7 +117,19 @@ bun run build
|
|
|
81
117
|
|
|
82
118
|
## Register The Plugin In OpenCode
|
|
83
119
|
|
|
84
|
-
|
|
120
|
+
Use the OpenCode plugin CLI:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
opencode plugin @hiai-gg/hiai-opencode@latest --global
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
If you also want Dynamic Context Pruning, install its separate plugin next:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
opencode plugin @tarquinen/opencode-dcp@latest --global
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
If you prefer manual config, add the plugin package to your OpenCode config. OpenCode installs npm plugins automatically at startup.
|
|
85
133
|
|
|
86
134
|
```json
|
|
87
135
|
{
|
|
@@ -94,6 +142,8 @@ The packaged minimal example lives in [config/opencode.json](config/opencode.jso
|
|
|
94
142
|
|
|
95
143
|
The richer example config lives in [hiai-opencode.json](hiai-opencode.json).
|
|
96
144
|
|
|
145
|
+
Do not put MCP server packages such as `firecrawl-mcp`, `@playwright/mcp`, or `@modelcontextprotocol/server-sequential-thinking` into the OpenCode `plugin` array. They are MCP servers, not OpenCode plugins. `hiai-opencode` only provides the OpenCode-side launch wiring for them through its `mcp` config and helper launchers.
|
|
146
|
+
|
|
97
147
|
## Quick Start
|
|
98
148
|
|
|
99
149
|
```bash
|
|
@@ -105,6 +155,18 @@ bun run build
|
|
|
105
155
|
|
|
106
156
|
Register the plugin in OpenCode:
|
|
107
157
|
|
|
158
|
+
```bash
|
|
159
|
+
opencode plugin @hiai-gg/hiai-opencode@latest --global
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Optional:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
opencode plugin @tarquinen/opencode-dcp@latest --global
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Manual equivalent:
|
|
169
|
+
|
|
108
170
|
```json
|
|
109
171
|
{
|
|
110
172
|
"$schema": "https://opencode.ai/config.json",
|
|
@@ -112,6 +174,22 @@ Register the plugin in OpenCode:
|
|
|
112
174
|
}
|
|
113
175
|
```
|
|
114
176
|
|
|
177
|
+
Project-level service config goes in `hiai-opencode.json` at the project root or under `.opencode/`:
|
|
178
|
+
|
|
179
|
+
```json
|
|
180
|
+
{
|
|
181
|
+
"mcp": {
|
|
182
|
+
"playwright": { "enabled": true },
|
|
183
|
+
"sequential-thinking": { "enabled": true },
|
|
184
|
+
"firecrawl": { "enabled": true },
|
|
185
|
+
"mempalace": { "enabled": true },
|
|
186
|
+
"rag": { "enabled": false },
|
|
187
|
+
"stitch": { "enabled": false },
|
|
188
|
+
"context7": { "enabled": true }
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
115
193
|
Then verify:
|
|
116
194
|
|
|
117
195
|
```bash
|
|
@@ -119,6 +197,37 @@ opencode debug config
|
|
|
119
197
|
opencode mcp list --print-logs --log-level INFO
|
|
120
198
|
```
|
|
121
199
|
|
|
200
|
+
## Post-Install Bootstrap Prompt
|
|
201
|
+
|
|
202
|
+
After installing the plugin, you can ask OpenCode to finish local setup with this prompt:
|
|
203
|
+
|
|
204
|
+
```text
|
|
205
|
+
Inspect this OpenCode workspace and finish hiai-opencode setup.
|
|
206
|
+
|
|
207
|
+
Do not add MCP server packages to the OpenCode plugin list. Keep OpenCode plugins separate from MCP servers.
|
|
208
|
+
|
|
209
|
+
Check that @hiai-gg/hiai-opencode is registered. If Dynamic Context Pruning is requested, install @tarquinen/opencode-dcp as a separate OpenCode plugin.
|
|
210
|
+
|
|
211
|
+
Find or create hiai-opencode.json in the project root or .opencode/. Use its mcp object as the single switchboard for enabling or disabling MCP services.
|
|
212
|
+
|
|
213
|
+
Enable only services that can run on this machine:
|
|
214
|
+
- playwright: requires node/npx; optionally set HIAI_PLAYWRIGHT_INSTALL_BROWSERS=1 before first run if browser binaries are needed.
|
|
215
|
+
- sequential-thinking: requires node/npx.
|
|
216
|
+
- firecrawl: requires FIRECRAWL_API_KEY.
|
|
217
|
+
- mempalace: requires uv or Python 3.9+ with pip; set MEMPALACE_PYTHON if needed. Leave HIAI_MCP_AUTO_INSTALL enabled unless the user forbids package installation.
|
|
218
|
+
- rag: requires OPENCODE_RAG_URL or a running local endpoint at http://localhost:9002/tools/search.
|
|
219
|
+
- stitch: requires STITCH_AI_API_KEY.
|
|
220
|
+
- context7: works without a key but use CONTEXT7_API_KEY if available.
|
|
221
|
+
|
|
222
|
+
Check .env.example, report missing keys without printing secret values, and never invent or hardcode API keys.
|
|
223
|
+
|
|
224
|
+
Run verification commands where available:
|
|
225
|
+
- opencode debug config
|
|
226
|
+
- opencode mcp list --print-logs --log-level INFO
|
|
227
|
+
|
|
228
|
+
If a dependency is missing, install only user-level or project-local dependencies, explain every command before running it, and do not use sudo/admin rights unless the user explicitly asks.
|
|
229
|
+
```
|
|
230
|
+
|
|
122
231
|
## Where To Change Things
|
|
123
232
|
|
|
124
233
|
### Models
|
|
@@ -164,21 +273,21 @@ Name mapping and visibility:
|
|
|
164
273
|
|
|
165
274
|
### Skills
|
|
166
275
|
|
|
167
|
-
|
|
276
|
+
Project skill definitions live under:
|
|
168
277
|
|
|
169
278
|
- [skills](skills)
|
|
170
279
|
|
|
171
|
-
|
|
280
|
+
Skill materialization logic:
|
|
172
281
|
|
|
173
282
|
- [src/features/builtin-skills/materialize.ts](src/features/builtin-skills/materialize.ts)
|
|
174
283
|
|
|
175
284
|
### MCP
|
|
176
285
|
|
|
177
|
-
Default MCP
|
|
286
|
+
Default MCP registry:
|
|
178
287
|
|
|
179
|
-
- [src/
|
|
288
|
+
- [src/mcp/registry.ts](src/mcp/registry.ts)
|
|
180
289
|
|
|
181
|
-
|
|
290
|
+
OpenCode MCP config assembly:
|
|
182
291
|
|
|
183
292
|
- [src/mcp/index.ts](src/mcp/index.ts)
|
|
184
293
|
|
|
@@ -215,6 +324,19 @@ Use [.env.example](.env.example) as the reference template. Create a local `.env
|
|
|
215
324
|
|
|
216
325
|
## MCP Service Notes
|
|
217
326
|
|
|
327
|
+
The user-facing MCP switchboard is the `mcp` object in `hiai-opencode.json`:
|
|
328
|
+
|
|
329
|
+
```json
|
|
330
|
+
{
|
|
331
|
+
"mcp": {
|
|
332
|
+
"playwright": { "enabled": true },
|
|
333
|
+
"mempalace": { "enabled": false }
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
The source of truth for default MCP wiring is `src/mcp/registry.ts`. Change that file when adding a new MCP integration or changing its launch command, required env vars, or install strategy.
|
|
339
|
+
|
|
218
340
|
### Works well as remote MCP
|
|
219
341
|
|
|
220
342
|
- `stitch`
|
|
@@ -224,14 +346,22 @@ Use [.env.example](.env.example) as the reference template. Create a local `.env
|
|
|
224
346
|
|
|
225
347
|
### Works with local helper bootstrap
|
|
226
348
|
|
|
227
|
-
- `playwright`
|
|
349
|
+
- `playwright`: launches `@playwright/mcp@latest` through the helper npm runner. Set `HIAI_PLAYWRIGHT_INSTALL_BROWSERS=1` if you want the launcher to install Chromium on first start.
|
|
350
|
+
- `sequential-thinking`: launches `@modelcontextprotocol/server-sequential-thinking` through the helper npm runner.
|
|
351
|
+
- `firecrawl`: launches `firecrawl-mcp` through the helper npm runner and requires `FIRECRAWL_API_KEY`.
|
|
228
352
|
|
|
229
353
|
### Needs upstream runtime or extra setup
|
|
230
354
|
|
|
231
|
-
- `mempalace`:
|
|
232
|
-
- `firecrawl`: requires `FIRECRAWL_API_KEY`
|
|
355
|
+
- `mempalace`: prefers `uv`; otherwise uses Python. If `HIAI_MCP_AUTO_INSTALL` is not `0`, `false`, or `no`, the launcher can run `python -m pip install --user mempalace` on first start.
|
|
233
356
|
- `rag`: requires your own running endpoint
|
|
234
|
-
|
|
357
|
+
|
|
358
|
+
### Additional OpenCode Plugin
|
|
359
|
+
|
|
360
|
+
`opencode-dcp` is a separate OpenCode plugin, not an MCP server:
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
opencode plugin @tarquinen/opencode-dcp@latest --global
|
|
364
|
+
```
|
|
235
365
|
|
|
236
366
|
### Important Windows note
|
|
237
367
|
|
|
@@ -242,16 +372,6 @@ On some Windows/OpenCode environments, local MCP process spawning can fail with
|
|
|
242
372
|
|
|
243
373
|
This most often affects `sequential-thinking` and `mempalace`, and sometimes local `npx`-backed tools.
|
|
244
374
|
|
|
245
|
-
## Optional External Plugin
|
|
246
|
-
|
|
247
|
-
`opencode-dcp` is intentionally not bundled.
|
|
248
|
-
|
|
249
|
-
Install it separately if you want it:
|
|
250
|
-
|
|
251
|
-
```bash
|
|
252
|
-
opencode plugin @tarquinen/opencode-dcp@latest --global
|
|
253
|
-
```
|
|
254
|
-
|
|
255
375
|
## Build And Publish
|
|
256
376
|
|
|
257
377
|
Build:
|
package/assets/mcp/mempalace.mjs
CHANGED
|
@@ -74,6 +74,37 @@ function resolvePythonForMempalace() {
|
|
|
74
74
|
return null;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
function resolvePythonForPip() {
|
|
78
|
+
for (const candidate of pythonCandidates()) {
|
|
79
|
+
const probe = spawnSync(
|
|
80
|
+
candidate.command,
|
|
81
|
+
[...candidate.args, "-m", "pip", "--version"],
|
|
82
|
+
{ stdio: "ignore", timeout: 10000 },
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
if (probe.status === 0) {
|
|
86
|
+
return candidate;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function shouldAutoInstall() {
|
|
94
|
+
const value = process.env.HIAI_MCP_AUTO_INSTALL?.trim().toLowerCase();
|
|
95
|
+
return value !== "0" && value !== "false" && value !== "no";
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function installMempalaceWithPip(candidate) {
|
|
99
|
+
const result = spawnSync(
|
|
100
|
+
candidate.command,
|
|
101
|
+
[...candidate.args, "-m", "pip", "install", "--user", "mempalace"],
|
|
102
|
+
{ stdio: "inherit", timeout: 300000 },
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
return result.status === 0 && canRunModule(candidate, "mempalace.mcp_server");
|
|
106
|
+
}
|
|
107
|
+
|
|
77
108
|
function resolveUvCacheRoot() {
|
|
78
109
|
return process.env.UV_CACHE_DIR
|
|
79
110
|
|| join(resolveCacheRoot(), "hiai-opencode", "uv");
|
|
@@ -128,16 +159,28 @@ function main() {
|
|
|
128
159
|
}
|
|
129
160
|
|
|
130
161
|
const python = resolvePythonForMempalace();
|
|
131
|
-
|
|
162
|
+
const fallbackPython =
|
|
163
|
+
python
|
|
164
|
+
|| (shouldAutoInstall()
|
|
165
|
+
? (() => {
|
|
166
|
+
const pipPython = resolvePythonForPip();
|
|
167
|
+
if (pipPython && installMempalaceWithPip(pipPython)) {
|
|
168
|
+
return pipPython;
|
|
169
|
+
}
|
|
170
|
+
return null;
|
|
171
|
+
})()
|
|
172
|
+
: null);
|
|
173
|
+
|
|
174
|
+
if (!fallbackPython) {
|
|
132
175
|
console.error(
|
|
133
|
-
"[hiai-opencode] mempalace skipped: install uv or Python 3.9+ with `pip install mempalace`",
|
|
176
|
+
"[hiai-opencode] mempalace skipped: install uv or Python 3.9+ with `pip install --user mempalace`",
|
|
134
177
|
);
|
|
135
178
|
process.exit(0);
|
|
136
179
|
}
|
|
137
180
|
|
|
138
181
|
const child = spawn(
|
|
139
|
-
|
|
140
|
-
[...
|
|
182
|
+
fallbackPython.command,
|
|
183
|
+
[...fallbackPython.args, "-m", "mempalace.mcp_server", "--palace", palacePath],
|
|
141
184
|
{
|
|
142
185
|
stdio: "inherit",
|
|
143
186
|
env: {
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { mkdirSync } from "node:fs"
|
|
4
|
+
import { dirname, join } from "node:path"
|
|
5
|
+
import { fileURLToPath } from "node:url"
|
|
6
|
+
import { spawn, spawnSync } from "node:child_process"
|
|
7
|
+
|
|
8
|
+
function resolveCacheRoot() {
|
|
9
|
+
const xdgCache = process.env.XDG_CACHE_HOME?.trim()
|
|
10
|
+
if (xdgCache) return xdgCache
|
|
11
|
+
|
|
12
|
+
const scriptDir = dirname(fileURLToPath(import.meta.url))
|
|
13
|
+
const pluginRoot = join(scriptDir, "..", "..")
|
|
14
|
+
return join(pluginRoot, ".runtime-cache")
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function runNpx(args, stdio = "inherit") {
|
|
18
|
+
const cacheRoot = join(resolveCacheRoot(), "hiai-opencode", "npm")
|
|
19
|
+
const tempRoot = join(cacheRoot, "tmp")
|
|
20
|
+
mkdirSync(tempRoot, { recursive: true })
|
|
21
|
+
|
|
22
|
+
const npxCommand = process.platform === "win32" ? "npx.cmd" : "npx"
|
|
23
|
+
return spawnSync(npxCommand, args, {
|
|
24
|
+
stdio,
|
|
25
|
+
shell: process.platform === "win32",
|
|
26
|
+
env: {
|
|
27
|
+
...process.env,
|
|
28
|
+
npm_config_cache: cacheRoot,
|
|
29
|
+
NPM_CONFIG_CACHE: cacheRoot,
|
|
30
|
+
TEMP: tempRoot,
|
|
31
|
+
TMP: tempRoot,
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function shouldInstallBrowsers() {
|
|
37
|
+
const value = process.env.HIAI_PLAYWRIGHT_INSTALL_BROWSERS?.trim().toLowerCase()
|
|
38
|
+
return value === "1" || value === "true" || value === "yes"
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (shouldInstallBrowsers()) {
|
|
42
|
+
const result = runNpx(["-y", "playwright@latest", "install", "chromium"])
|
|
43
|
+
if (result.status !== 0) {
|
|
44
|
+
console.error("[hiai-opencode] playwright browser install failed")
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const cacheRoot = join(resolveCacheRoot(), "hiai-opencode", "npm")
|
|
49
|
+
const tempRoot = join(cacheRoot, "tmp")
|
|
50
|
+
mkdirSync(tempRoot, { recursive: true })
|
|
51
|
+
|
|
52
|
+
const npxCommand = process.platform === "win32" ? "npx.cmd" : "npx"
|
|
53
|
+
const child = spawn(npxCommand, ["-y", "@playwright/mcp@latest", ...process.argv.slice(2)], {
|
|
54
|
+
stdio: "inherit",
|
|
55
|
+
shell: process.platform === "win32",
|
|
56
|
+
env: {
|
|
57
|
+
...process.env,
|
|
58
|
+
npm_config_cache: cacheRoot,
|
|
59
|
+
NPM_CONFIG_CACHE: cacheRoot,
|
|
60
|
+
TEMP: tempRoot,
|
|
61
|
+
TMP: tempRoot,
|
|
62
|
+
},
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
child.on("exit", (code, signal) => {
|
|
66
|
+
if (signal) {
|
|
67
|
+
process.kill(process.pid, signal)
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
process.exit(code ?? 0)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
child.on("error", (error) => {
|
|
74
|
+
console.error("[hiai-opencode] playwright launcher failed:", error)
|
|
75
|
+
process.exit(1)
|
|
76
|
+
})
|
|
@@ -72,6 +72,7 @@ export declare const McpServerConfigSchema: z.ZodObject<{
|
|
|
72
72
|
local: "local";
|
|
73
73
|
}>>;
|
|
74
74
|
url: z.ZodOptional<z.ZodString>;
|
|
75
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
75
76
|
command: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
76
77
|
timeout: z.ZodOptional<z.ZodNumber>;
|
|
77
78
|
environment: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
@@ -971,6 +972,7 @@ export declare const HiaiOpencodeConfigSchema: z.ZodObject<{
|
|
|
971
972
|
local: "local";
|
|
972
973
|
}>>;
|
|
973
974
|
url: z.ZodOptional<z.ZodString>;
|
|
975
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
974
976
|
command: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
975
977
|
timeout: z.ZodOptional<z.ZodNumber>;
|
|
976
978
|
environment: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|