@hiai-gg/hiai-opencode 0.1.3 → 0.1.5
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 -18
- package/AGENTS.md +77 -23
- package/ARCHITECTURE.md +15 -17
- package/LICENSE.md +1 -0
- package/README.md +189 -94
- package/assets/cli/hiai-opencode.mjs +276 -0
- package/assets/mcp/playwright.mjs +7 -0
- package/config/hiai-opencode.schema.json +85 -50
- package/dist/config/defaults.d.ts +1 -3
- package/dist/config/index.d.ts +0 -1
- package/dist/config/platform-schema.d.ts +343 -4
- package/dist/config/schema/agent-overrides.d.ts +256 -0
- package/dist/config/schema/categories.d.ts +1 -1
- package/dist/config/schema/commands.d.ts +1 -0
- package/dist/config/schema/index.d.ts +2 -0
- package/dist/config/schema/oh-my-opencode-config.d.ts +267 -0
- package/dist/config/schema/skill-discovery.d.ts +11 -0
- package/dist/config/types.d.ts +33 -3
- package/dist/create-tools.d.ts +2 -0
- package/dist/features/builtin-commands/templates/mcp-status.d.ts +1 -0
- package/dist/features/builtin-commands/types.d.ts +1 -1
- package/dist/features/opencode-skill-loader/loader.d.ts +2 -0
- package/dist/index.js +744 -358
- package/dist/internals/plugins/websearch-cited/index.d.ts +7 -1
- package/dist/mcp/types.d.ts +1 -1
- package/dist/plugin/skill-discovery-config.d.ts +4 -0
- package/dist/plugin/tool-registry.d.ts +2 -0
- package/dist/shared/startup-diagnostics.d.ts +6 -0
- package/dist/tools/skill-mcp/tools.d.ts +2 -0
- package/hiai-opencode.json +55 -33
- package/package.json +4 -1
- package/src/agents/AGENTS.md +3 -4
- package/src/config/defaults.ts +186 -77
- package/src/config/index.ts +0 -1
- package/src/config/loader.test.ts +16 -1
- package/src/config/loader.ts +4 -2
- package/src/config/platform-schema.ts +53 -4
- package/src/config/schema/agent-overrides.ts +2 -0
- package/src/config/schema/commands.ts +1 -0
- package/src/config/schema/fast-apply.ts +4 -4
- package/src/config/schema/index.ts +2 -0
- package/src/config/schema/oh-my-opencode-config.ts +3 -0
- package/src/config/schema/skill-discovery.ts +25 -0
- package/src/config/types.ts +49 -2
- package/src/create-tools.ts +4 -1
- package/src/features/builtin-commands/commands.ts +7 -0
- package/src/features/builtin-commands/templates/mcp-status.ts +36 -0
- package/src/features/builtin-commands/types.ts +1 -1
- package/src/features/builtin-skills/skills/playwright.ts +24 -2
- package/src/features/opencode-skill-loader/loader.ts +11 -0
- package/src/index.ts +53 -14
- package/src/internals/plugins/websearch-cited/index.ts +10 -5
- package/src/lsp/index.ts +1 -0
- package/src/mcp/registry.ts +6 -1
- package/src/plugin/hooks/create-tool-guard-hooks.ts +1 -1
- package/src/plugin/skill-context.ts +31 -13
- package/src/plugin/skill-discovery-config.ts +32 -0
- package/src/plugin/tool-registry.ts +4 -0
- package/src/plugin-handlers/agent-config-handler.ts +20 -13
- package/src/plugin-handlers/command-config-handler.ts +22 -12
- package/src/shared/migration/agent-names.ts +5 -5
- package/src/shared/startup-diagnostics.ts +77 -0
- package/src/tools/skill-mcp/tools.ts +45 -7
- package/src/config/models.ts +0 -32
package/.env.example
CHANGED
|
@@ -2,29 +2,22 @@
|
|
|
2
2
|
# Copy this file to .env and fill in your values.
|
|
3
3
|
# All keys are optional unless noted.
|
|
4
4
|
|
|
5
|
-
#
|
|
6
|
-
|
|
7
|
-
#
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
#
|
|
11
|
-
|
|
12
|
-
#
|
|
5
|
+
# Model Provider Credentials
|
|
6
|
+
#
|
|
7
|
+
# Configure model provider credentials with OpenCode Connect.
|
|
8
|
+
# hiai-opencode only stores model IDs such as:
|
|
9
|
+
# - openrouter/anthropic/claude-3.5-sonnet
|
|
10
|
+
# - openai/gpt-4.1
|
|
11
|
+
# - anthropic/claude-3-5-sonnet-latest
|
|
12
|
+
#
|
|
13
|
+
# Do not put model provider keys here for normal OpenCode usage.
|
|
14
|
+
# Optional fallback only for headless/non-Connect workflows:
|
|
15
|
+
# OPENROUTER_API_KEY=your_openrouter_api_key_here
|
|
13
16
|
# OPENAI_API_KEY=your_openai_api_key_here
|
|
14
|
-
|
|
15
|
-
# Optional - needed only if using Anthropic models directly (not via OpenRouter)
|
|
16
17
|
# ANTHROPIC_API_KEY=your_anthropic_api_key_here
|
|
17
|
-
|
|
18
|
-
# Optional - DeepSeek models
|
|
19
18
|
# DEEPSEEK_API_KEY=your_deepseek_api_key_here
|
|
20
|
-
|
|
21
|
-
# Optional - GLM models via OpenRouter
|
|
22
19
|
# GLM_API_KEY=your_glm_api_key_here
|
|
23
|
-
|
|
24
|
-
# Optional - MiniMax models via OpenRouter
|
|
25
20
|
# MINIMAX_API_KEY=your_minimax_api_key_here
|
|
26
|
-
|
|
27
|
-
# Optional - Qwen models via OpenRouter
|
|
28
21
|
# QWEN_API_KEY=your_qwen_api_key_here
|
|
29
22
|
|
|
30
23
|
# MCP Service Keys
|
|
@@ -62,6 +55,9 @@ OPENROUTER_API_KEY=your_openrouter_api_key_here
|
|
|
62
55
|
# Optional - set to 1, true, or yes to install Chromium during launcher startup
|
|
63
56
|
# HIAI_PLAYWRIGHT_INSTALL_BROWSERS=0
|
|
64
57
|
|
|
58
|
+
# Optional - if Linux system browser deps cannot be installed, edit hiai-opencode.json
|
|
59
|
+
# and add Playwright MCP args such as "--browser", "chrome" to use an existing browser.
|
|
60
|
+
|
|
65
61
|
# RAG MCP
|
|
66
62
|
|
|
67
63
|
# Optional - RAG search tool endpoint
|
package/AGENTS.md
CHANGED
|
@@ -81,6 +81,8 @@ When a user asks OpenCode or another agent to finish installing this plugin, fol
|
|
|
81
81
|
- Do not add MCP server npm packages to the OpenCode `plugin` array.
|
|
82
82
|
- Use `hiai-opencode.json` as the project-level service switchboard.
|
|
83
83
|
- Use `src/mcp/registry.ts` as the source of truth for default MCP launch wiring.
|
|
84
|
+
- Keep skill discovery deterministic by default: packaged plugin skills, generated builtin skills, explicit config sources, and project `.opencode/skills`.
|
|
85
|
+
- Do not enable global OpenCode, Claude, or Agents skill folders unless the user explicitly asks.
|
|
84
86
|
- Use `.env.example` as the key template, but never print, invent, commit, or hardcode secret values.
|
|
85
87
|
- Prefer user-level or project-local installs. Do not use sudo/admin rights unless the user explicitly asks.
|
|
86
88
|
|
|
@@ -96,16 +98,24 @@ When a user asks OpenCode or another agent to finish installing this plugin, fol
|
|
|
96
98
|
2. Check plugin registration with `opencode debug config`.
|
|
97
99
|
3. Find or create `hiai-opencode.json` in the project root or `.opencode/`.
|
|
98
100
|
4. Configure the `mcp` object there. Disable services that cannot run on the host.
|
|
99
|
-
5.
|
|
100
|
-
- `
|
|
101
|
+
5. Keep `skill_discovery` clean unless the user opts into external folders:
|
|
102
|
+
- `config_sources: true`
|
|
103
|
+
- `project_opencode: true`
|
|
104
|
+
- `global_opencode: false`
|
|
105
|
+
- `project_claude: false`
|
|
106
|
+
- `global_claude: false`
|
|
107
|
+
- `project_agents: false`
|
|
108
|
+
- `global_agents: false`
|
|
109
|
+
6. Check environment variables without printing values:
|
|
101
110
|
- `FIRECRAWL_API_KEY`
|
|
102
111
|
- `STITCH_AI_API_KEY`
|
|
103
112
|
- `CONTEXT7_API_KEY`
|
|
113
|
+
- `GOOGLE_SEARCH_API_KEY`
|
|
104
114
|
- `MEMPALACE_PYTHON`
|
|
105
115
|
- `OPENCODE_RAG_URL`
|
|
106
116
|
- `HIAI_PLAYWRIGHT_INSTALL_BROWSERS`
|
|
107
117
|
- `HIAI_MCP_AUTO_INSTALL`
|
|
108
|
-
|
|
118
|
+
7. Verify with:
|
|
109
119
|
- `opencode debug config`
|
|
110
120
|
- `opencode mcp list --print-logs --log-level INFO`
|
|
111
121
|
|
|
@@ -121,6 +131,13 @@ When a user asks OpenCode or another agent to finish installing this plugin, fol
|
|
|
121
131
|
| `stitch` | `STITCH_AI_API_KEY` is set | Remote MCP endpoint |
|
|
122
132
|
| `context7` | User wants Context7 docs/search | Remote MCP endpoint; use `CONTEXT7_API_KEY` if available |
|
|
123
133
|
|
|
134
|
+
Playwright troubleshooting rules:
|
|
135
|
+
|
|
136
|
+
- If `skill_mcp` says `MCP server "playwright" not found`, first load the `playwright` skill and check `hiai-opencode mcp-status`; do not report this as a browser dependency failure.
|
|
137
|
+
- If Chromium reports missing Linux libraries (`libnspr4`, `libnss3`, `libatk-bridge`, `libgtk-3`, etc.), explain that MCP is present but the host lacks browser system dependencies.
|
|
138
|
+
- Without sudo, try a system browser override in `hiai-opencode.json`, such as `--browser chrome` or `--browser msedge`.
|
|
139
|
+
- If no browser path works, use `curl` only as degraded HTTP verification and explicitly say it is not a replacement for browser testing.
|
|
140
|
+
|
|
124
141
|
### Prompt For OpenCode Users
|
|
125
142
|
|
|
126
143
|
Users can paste this into OpenCode after installing the plugin:
|
|
@@ -188,18 +205,17 @@ If runtime output differs from that set, inspect:
|
|
|
188
205
|
|
|
189
206
|
## Model Configuration
|
|
190
207
|
|
|
191
|
-
There
|
|
208
|
+
There is one source of truth for model IDs:
|
|
192
209
|
|
|
193
|
-
|
|
194
|
-
- [src/config/models.ts](src/config/models.ts)
|
|
195
|
-
2. actual runtime defaults:
|
|
196
|
-
- [src/config/defaults.ts](src/config/defaults.ts)
|
|
210
|
+
- [hiai-opencode.json](hiai-opencode.json)
|
|
197
211
|
|
|
198
|
-
The
|
|
212
|
+
The runtime loader is:
|
|
199
213
|
|
|
200
|
-
- [
|
|
214
|
+
- [src/config/defaults.ts](src/config/defaults.ts)
|
|
201
215
|
|
|
202
|
-
|
|
216
|
+
Users configure only the 10 primary agent model slots under `models`: `bob`, `coder`, `strategist`, `guard`, `critic`, `designer`, `researcher`, `manager`, `brainstormer`, and `vision`.
|
|
217
|
+
Hidden agents and task categories are derived internally in `src/config/defaults.ts`.
|
|
218
|
+
Use fully qualified model IDs. Do not introduce local aliases like `hiai-fast`, `sonnet`, `fast`, or `high`.
|
|
203
219
|
|
|
204
220
|
## Change Map
|
|
205
221
|
|
|
@@ -207,10 +223,9 @@ Use this table when you need to change something and want the right file immedia
|
|
|
207
223
|
|
|
208
224
|
| Goal | Edit this first | Why |
|
|
209
225
|
|---|---|---|
|
|
210
|
-
| Change
|
|
211
|
-
| Change
|
|
212
|
-
| Change
|
|
213
|
-
| Change provider/model guidance shown to maintainers | [src/config/models.ts](src/config/models.ts) | That file holds provider rules and role guidance |
|
|
226
|
+
| Change a user-facing default model slot | [hiai-opencode.json](hiai-opencode.json) | This is the canonical model source |
|
|
227
|
+
| Change how categories inherit the 10 model slots | [src/config/defaults.ts](src/config/defaults.ts) | Category routing is internal |
|
|
228
|
+
| Change MCP/LSP user-facing switches | [hiai-opencode.json](hiai-opencode.json) | Users only toggle enabled state there |
|
|
214
229
|
| Change Bob behavior or prompt text | [src/agents/bob.ts](src/agents/bob.ts), `src/agents/bob/*` | Bob prompt authoring lives there |
|
|
215
230
|
| Change Coder behavior or prompt text | `src/agents/coder/*` | Coder prompt authoring lives there |
|
|
216
231
|
| Change Strategist behavior or prompt text | `src/agents/strategist/*` | Strategist prompt authoring lives there |
|
|
@@ -228,6 +243,8 @@ Use this table when you need to change something and want the right file immedia
|
|
|
228
243
|
| Change closure protocol appended to prompts | [src/shared/closure-protocol.ts](src/shared/closure-protocol.ts) | It is injected after prompt construction |
|
|
229
244
|
| Change prompt override / prompt_append behavior | `src/agents/builtin-agents/agent-overrides.ts` | Override merge logic lives there |
|
|
230
245
|
| Change environment context appended to prompts | `src/agents/builtin-agents/environment-context.ts` | Runtime environment prompt injection lives there |
|
|
246
|
+
| Change skill discovery source defaults | [src/config/schema/skill-discovery.ts](src/config/schema/skill-discovery.ts), [src/plugin/skill-discovery-config.ts](src/plugin/skill-discovery-config.ts) | Controls opt-in external skill folders |
|
|
247
|
+
| Change skill source loading behavior | [src/plugin/skill-context.ts](src/plugin/skill-context.ts), [src/plugin-handlers/command-config-handler.ts](src/plugin-handlers/command-config-handler.ts) | Skills and skill-backed commands must stay aligned |
|
|
231
248
|
| Change MCP defaults | [src/mcp/registry.ts](src/mcp/registry.ts) | Default MCP wiring lives there |
|
|
232
249
|
| Change OpenCode MCP assembly | [src/mcp/index.ts](src/mcp/index.ts) | Final MCP config assembly lives there |
|
|
233
250
|
| Change local MCP helper launcher logic | `assets/mcp/*` | Runtime launcher scripts live there |
|
|
@@ -328,22 +345,59 @@ Current MCP set:
|
|
|
328
345
|
- `websearch`
|
|
329
346
|
- `grep_app`
|
|
330
347
|
|
|
348
|
+
## Skill Discovery Rules
|
|
349
|
+
|
|
350
|
+
Default behavior is intentionally deterministic.
|
|
351
|
+
|
|
352
|
+
Enabled by default:
|
|
353
|
+
|
|
354
|
+
- packaged `hiai-opencode` skill definitions mirrored into OpenCode's skill view
|
|
355
|
+
- generated builtin helper skills
|
|
356
|
+
- explicit `skills.sources` entries
|
|
357
|
+
- project-local `.opencode/skills` and `.opencode/skill`
|
|
358
|
+
|
|
359
|
+
Disabled by default:
|
|
360
|
+
|
|
361
|
+
- global OpenCode skills
|
|
362
|
+
- project and global Claude skills
|
|
363
|
+
- project and global Agents skills
|
|
364
|
+
|
|
365
|
+
Opt-in example:
|
|
366
|
+
|
|
367
|
+
```json
|
|
368
|
+
{
|
|
369
|
+
"skill_discovery": {
|
|
370
|
+
"global_opencode": true,
|
|
371
|
+
"project_claude": true,
|
|
372
|
+
"global_claude": false,
|
|
373
|
+
"project_agents": false,
|
|
374
|
+
"global_agents": false
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
Use `skills.disable` for noisy individual skills:
|
|
380
|
+
|
|
381
|
+
```json
|
|
382
|
+
{
|
|
383
|
+
"skills": {
|
|
384
|
+
"disable": ["claude-md-management"]
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
```
|
|
388
|
+
|
|
331
389
|
## Environment Variables
|
|
332
390
|
|
|
333
391
|
Use [.env.example](.env.example) as the canonical key template for local setup and release checks.
|
|
334
392
|
|
|
335
|
-
|
|
393
|
+
Model provider credentials are configured through OpenCode Connect. Do not ask users to put `OPENROUTER_API_KEY`, `OPENAI_API_KEY`, or `ANTHROPIC_API_KEY` into `hiai-opencode.json` for normal model usage. The plugin stores model IDs only.
|
|
394
|
+
|
|
395
|
+
Common service keys:
|
|
336
396
|
|
|
337
|
-
- `OPENROUTER_API_KEY`
|
|
338
|
-
- `OPENAI_API_KEY`
|
|
339
|
-
- `ANTHROPIC_API_KEY`
|
|
340
|
-
- `DEEPSEEK_API_KEY`
|
|
341
|
-
- `GLM_API_KEY`
|
|
342
|
-
- `MINIMAX_API_KEY`
|
|
343
|
-
- `QWEN_API_KEY`
|
|
344
397
|
- `STITCH_AI_API_KEY`
|
|
345
398
|
- `FIRECRAWL_API_KEY`
|
|
346
399
|
- `CONTEXT7_API_KEY`
|
|
400
|
+
- `GOOGLE_SEARCH_API_KEY`
|
|
347
401
|
- `OLLAMA_BASE_URL`
|
|
348
402
|
- `OLLAMA_MODEL`
|
|
349
403
|
- `MEMPALACE_PYTHON`
|
package/ARCHITECTURE.md
CHANGED
|
@@ -14,7 +14,7 @@ The plugin has five main layers:
|
|
|
14
14
|
|
|
15
15
|
## Repository Layout
|
|
16
16
|
|
|
17
|
-
- [src/config](src/config): schemas, types,
|
|
17
|
+
- [src/config](src/config): schemas, types, and bundled config loading
|
|
18
18
|
- [src/agents](src/agents): agent factories, prompts, and prompt helpers
|
|
19
19
|
- [src/plugin-handlers](src/plugin-handlers): runtime config assembly into OpenCode shape
|
|
20
20
|
- [src/features](src/features): loaders, materializers, bridges, and supporting runtime features
|
|
@@ -62,26 +62,20 @@ Runtime naming, visibility, and compatibility are normalized through:
|
|
|
62
62
|
|
|
63
63
|
### Presets
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
User-facing model IDs live in one place:
|
|
66
66
|
|
|
67
|
-
- [
|
|
68
|
-
|
|
69
|
-
This file defines:
|
|
70
|
-
|
|
71
|
-
- `MODEL_PRESETS`
|
|
72
|
-
- `MODEL_ROLE_GUIDE`
|
|
73
|
-
- `PROVIDER_MODEL_RULES`
|
|
67
|
+
- [hiai-opencode.json](hiai-opencode.json)
|
|
74
68
|
|
|
75
69
|
### Runtime Defaults
|
|
76
70
|
|
|
77
|
-
|
|
71
|
+
The TypeScript defaults loader derives hidden agents and categories from the 10 user-facing model slots:
|
|
78
72
|
|
|
79
73
|
- [src/config/defaults.ts](src/config/defaults.ts)
|
|
80
74
|
|
|
81
|
-
This is the
|
|
75
|
+
This is the internal routing source for:
|
|
82
76
|
|
|
83
|
-
- agent
|
|
84
|
-
- category
|
|
77
|
+
- hidden agent model inheritance
|
|
78
|
+
- category model inheritance
|
|
85
79
|
- MCP defaults
|
|
86
80
|
- LSP defaults
|
|
87
81
|
- permissions
|
|
@@ -164,8 +158,8 @@ If a prompt change looks correct in source but does not show up correctly in Ope
|
|
|
164
158
|
|
|
165
159
|
Use these rules when editing the prompt layer:
|
|
166
160
|
|
|
167
|
-
- change `
|
|
168
|
-
- change `src/config/defaults.ts` when
|
|
161
|
+
- change `hiai-opencode.json` when any primary agent model slot should change
|
|
162
|
+
- change `src/config/defaults.ts` when internal category-to-agent-slot routing should change
|
|
169
163
|
- change `src/agents/*` when the prompt content or behavior should change
|
|
170
164
|
- change shared prompt/injection files when the prompt is being appended or normalized after agent construction
|
|
171
165
|
- change `src/plugin-handlers/agent-config-handler.ts` when runtime name, visibility, mode, or final description should change
|
|
@@ -196,6 +190,10 @@ Relevant files:
|
|
|
196
190
|
|
|
197
191
|
- [src/features/builtin-skills/materialize.ts](src/features/builtin-skills/materialize.ts)
|
|
198
192
|
- [src/features/opencode-skill-loader](src/features/opencode-skill-loader)
|
|
193
|
+
- [src/config/schema/skill-discovery.ts](src/config/schema/skill-discovery.ts)
|
|
194
|
+
- [src/plugin/skill-discovery-config.ts](src/plugin/skill-discovery-config.ts)
|
|
195
|
+
|
|
196
|
+
Default discovery is deterministic: packaged plugin skills, generated builtin skills, explicit config sources, and project `.opencode/skills`. Global OpenCode, Claude, and Agents skill folders are opt-in.
|
|
199
197
|
|
|
200
198
|
## MCP
|
|
201
199
|
|
|
@@ -273,8 +271,8 @@ Avoid adding more root docs unless they serve a genuinely new role.
|
|
|
273
271
|
|
|
274
272
|
When changing the plugin, keep these invariants:
|
|
275
273
|
|
|
276
|
-
- `
|
|
277
|
-
- `src/config/
|
|
274
|
+
- `hiai-opencode.json` is the source of truth for user-facing runtime defaults and model IDs
|
|
275
|
+
- `src/config/defaults.ts` must remain a loader, not a second model map
|
|
278
276
|
- root docs should use canonical runtime names, not stale internal aliases
|
|
279
277
|
- user-facing docs should describe visible agents first and hidden/system agents second
|
|
280
278
|
- third-party MCPs should follow upstream install/launch conventions whenever possible
|
package/LICENSE.md
CHANGED
|
@@ -20,6 +20,7 @@ Some are:
|
|
|
20
20
|
|
|
21
21
|
| Component | Upstream | Notes |
|
|
22
22
|
|---|---|---|
|
|
23
|
+
| OpenCode host/runtime | [anomalyco/opencode](https://github.com/anomalyco/opencode) | plugin host and runtime target |
|
|
23
24
|
| Core orchestration influences | [code-yeongyu/oh-my-openagent](https://github.com/code-yeongyu/oh-my-openagent) | important architectural influence |
|
|
24
25
|
| Planning / workflow influences | [obra/superpowers](https://github.com/obra/superpowers) | planning, review, and debugging ideas |
|
|
25
26
|
| Specialist / platform influences | [vtemian/micode](https://github.com/vtemian/micode) | platform-style specialist behavior |
|