@hiai-gg/hiai-opencode 0.1.3 → 0.1.4

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.
Files changed (51) hide show
  1. package/.env.example +14 -18
  2. package/AGENTS.md +75 -23
  3. package/ARCHITECTURE.md +11 -14
  4. package/LICENSE.md +1 -0
  5. package/README.md +177 -94
  6. package/assets/cli/hiai-opencode.mjs +276 -0
  7. package/assets/mcp/playwright.mjs +7 -0
  8. package/config/hiai-opencode.schema.json +113 -1
  9. package/dist/config/defaults.d.ts +0 -3
  10. package/dist/config/index.d.ts +0 -1
  11. package/dist/config/platform-schema.d.ts +70 -0
  12. package/dist/config/schema/agent-overrides.d.ts +256 -0
  13. package/dist/config/schema/categories.d.ts +2 -2
  14. package/dist/config/schema/commands.d.ts +1 -0
  15. package/dist/config/schema/index.d.ts +2 -0
  16. package/dist/config/schema/oh-my-opencode-config.d.ts +267 -0
  17. package/dist/config/schema/skill-discovery.d.ts +11 -0
  18. package/dist/config/types.d.ts +12 -1
  19. package/dist/features/builtin-commands/templates/mcp-status.d.ts +1 -0
  20. package/dist/features/builtin-commands/types.d.ts +1 -1
  21. package/dist/features/opencode-skill-loader/loader.d.ts +2 -0
  22. package/dist/index.js +692 -541
  23. package/dist/plugin/skill-discovery-config.d.ts +4 -0
  24. package/dist/shared/startup-diagnostics.d.ts +6 -0
  25. package/hiai-opencode.json +191 -35
  26. package/package.json +4 -1
  27. package/src/agents/AGENTS.md +3 -4
  28. package/src/config/defaults.ts +60 -81
  29. package/src/config/index.ts +0 -1
  30. package/src/config/platform-schema.ts +17 -2
  31. package/src/config/schema/agent-overrides.ts +2 -0
  32. package/src/config/schema/commands.ts +1 -0
  33. package/src/config/schema/fast-apply.ts +4 -4
  34. package/src/config/schema/index.ts +2 -0
  35. package/src/config/schema/oh-my-opencode-config.ts +3 -0
  36. package/src/config/schema/skill-discovery.ts +25 -0
  37. package/src/config/types.ts +16 -0
  38. package/src/features/builtin-commands/commands.ts +7 -0
  39. package/src/features/builtin-commands/templates/mcp-status.ts +36 -0
  40. package/src/features/builtin-commands/types.ts +1 -1
  41. package/src/features/builtin-skills/skills/playwright.ts +24 -2
  42. package/src/features/opencode-skill-loader/loader.ts +11 -0
  43. package/src/index.ts +14 -13
  44. package/src/plugin/hooks/create-tool-guard-hooks.ts +1 -1
  45. package/src/plugin/skill-context.ts +31 -13
  46. package/src/plugin/skill-discovery-config.ts +32 -0
  47. package/src/plugin-handlers/agent-config-handler.ts +20 -13
  48. package/src/plugin-handlers/command-config-handler.ts +22 -12
  49. package/src/shared/migration/agent-names.ts +5 -5
  50. package/src/shared/startup-diagnostics.ts +77 -0
  51. 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
- # Core Model Provider (REQUIRED for default presets)
6
-
7
- # Required if using OpenRouter (the default provider for most agents)
8
- OPENROUTER_API_KEY=your_openrouter_api_key_here
9
-
10
- # Alternative Direct Provider Keys
11
-
12
- # Optional - needed only if using OpenAI models directly (not via OpenRouter)
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. Check environment variables without printing values:
100
- - `OPENROUTER_API_KEY`
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
- 6. Verify with:
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,15 @@ If runtime output differs from that set, inspect:
188
205
 
189
206
  ## Model Configuration
190
207
 
191
- There are two sources of truth:
208
+ There is one source of truth for model IDs:
192
209
 
193
- 1. shared presets and guidance:
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 example override file is:
212
+ The runtime loader is:
199
213
 
200
- - [hiai-opencode.json](hiai-opencode.json)
214
+ - [src/config/defaults.ts](src/config/defaults.ts)
201
215
 
202
- Use fully qualified model IDs. Do not introduce local aliases like `hiai-fast` or `sonnet`.
216
+ Use fully qualified model IDs. Do not introduce local aliases like `hiai-fast`, `sonnet`, `fast`, or `high`.
203
217
 
204
218
  ## Change Map
205
219
 
@@ -207,10 +221,9 @@ Use this table when you need to change something and want the right file immedia
207
221
 
208
222
  | Goal | Edit this first | Why |
209
223
  |---|---|---|
210
- | Change shared preset values like `fast`, `mid`, `high`, `vision`, `reasoning` | [src/config/models.ts](src/config/models.ts) | This is the shared preset map |
211
- | Change which default model an agent uses | [src/config/defaults.ts](src/config/defaults.ts) | This is the runtime default assignment layer |
212
- | Change which default model a category uses | [src/config/defaults.ts](src/config/defaults.ts) | Categories are assigned there |
213
- | Change provider/model guidance shown to maintainers | [src/config/models.ts](src/config/models.ts) | That file holds provider rules and role guidance |
224
+ | Change which default model an agent uses | [hiai-opencode.json](hiai-opencode.json) | This is the canonical model source |
225
+ | Change which default model a category uses | [hiai-opencode.json](hiai-opencode.json) | Categories are assigned there |
226
+ | Change MCP/LSP/user-facing defaults | [hiai-opencode.json](hiai-opencode.json) | The runtime loader reads this file |
214
227
  | Change Bob behavior or prompt text | [src/agents/bob.ts](src/agents/bob.ts), `src/agents/bob/*` | Bob prompt authoring lives there |
215
228
  | Change Coder behavior or prompt text | `src/agents/coder/*` | Coder prompt authoring lives there |
216
229
  | Change Strategist behavior or prompt text | `src/agents/strategist/*` | Strategist prompt authoring lives there |
@@ -228,6 +241,8 @@ Use this table when you need to change something and want the right file immedia
228
241
  | Change closure protocol appended to prompts | [src/shared/closure-protocol.ts](src/shared/closure-protocol.ts) | It is injected after prompt construction |
229
242
  | Change prompt override / prompt_append behavior | `src/agents/builtin-agents/agent-overrides.ts` | Override merge logic lives there |
230
243
  | Change environment context appended to prompts | `src/agents/builtin-agents/environment-context.ts` | Runtime environment prompt injection lives there |
244
+ | 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 |
245
+ | 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
246
  | Change MCP defaults | [src/mcp/registry.ts](src/mcp/registry.ts) | Default MCP wiring lives there |
232
247
  | Change OpenCode MCP assembly | [src/mcp/index.ts](src/mcp/index.ts) | Final MCP config assembly lives there |
233
248
  | Change local MCP helper launcher logic | `assets/mcp/*` | Runtime launcher scripts live there |
@@ -328,22 +343,59 @@ Current MCP set:
328
343
  - `websearch`
329
344
  - `grep_app`
330
345
 
346
+ ## Skill Discovery Rules
347
+
348
+ Default behavior is intentionally deterministic.
349
+
350
+ Enabled by default:
351
+
352
+ - packaged `hiai-opencode` skill definitions mirrored into OpenCode's skill view
353
+ - generated builtin helper skills
354
+ - explicit `skills.sources` entries
355
+ - project-local `.opencode/skills` and `.opencode/skill`
356
+
357
+ Disabled by default:
358
+
359
+ - global OpenCode skills
360
+ - project and global Claude skills
361
+ - project and global Agents skills
362
+
363
+ Opt-in example:
364
+
365
+ ```json
366
+ {
367
+ "skill_discovery": {
368
+ "global_opencode": true,
369
+ "project_claude": true,
370
+ "global_claude": false,
371
+ "project_agents": false,
372
+ "global_agents": false
373
+ }
374
+ }
375
+ ```
376
+
377
+ Use `skills.disable` for noisy individual skills:
378
+
379
+ ```json
380
+ {
381
+ "skills": {
382
+ "disable": ["claude-md-management"]
383
+ }
384
+ }
385
+ ```
386
+
331
387
  ## Environment Variables
332
388
 
333
389
  Use [.env.example](.env.example) as the canonical key template for local setup and release checks.
334
390
 
335
- Common keys:
391
+ 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.
392
+
393
+ Common service keys:
336
394
 
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
395
  - `STITCH_AI_API_KEY`
345
396
  - `FIRECRAWL_API_KEY`
346
397
  - `CONTEXT7_API_KEY`
398
+ - `GOOGLE_SEARCH_API_KEY`
347
399
  - `OLLAMA_BASE_URL`
348
400
  - `OLLAMA_MODEL`
349
401
  - `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, model presets, default wiring
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,19 +62,13 @@ Runtime naming, visibility, and compatibility are normalized through:
62
62
 
63
63
  ### Presets
64
64
 
65
- Shared presets and provider guidance live in:
65
+ Agent and category model IDs live in one place:
66
66
 
67
- - [src/config/models.ts](src/config/models.ts)
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
- Actual default agent/category assignments live in:
71
+ The TypeScript defaults loader only reads the bundled canonical config:
78
72
 
79
73
  - [src/config/defaults.ts](src/config/defaults.ts)
80
74
 
@@ -164,8 +158,7 @@ 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 `src/config/models.ts` when the preset map itself should change
168
- - change `src/config/defaults.ts` when default model assignment should change
161
+ - change `hiai-opencode.json` when any default model assignment should change
169
162
  - change `src/agents/*` when the prompt content or behavior should change
170
163
  - change shared prompt/injection files when the prompt is being appended or normalized after agent construction
171
164
  - change `src/plugin-handlers/agent-config-handler.ts` when runtime name, visibility, mode, or final description should change
@@ -196,6 +189,10 @@ Relevant files:
196
189
 
197
190
  - [src/features/builtin-skills/materialize.ts](src/features/builtin-skills/materialize.ts)
198
191
  - [src/features/opencode-skill-loader](src/features/opencode-skill-loader)
192
+ - [src/config/schema/skill-discovery.ts](src/config/schema/skill-discovery.ts)
193
+ - [src/plugin/skill-discovery-config.ts](src/plugin/skill-discovery-config.ts)
194
+
195
+ 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
196
 
200
197
  ## MCP
201
198
 
@@ -273,8 +270,8 @@ Avoid adding more root docs unless they serve a genuinely new role.
273
270
 
274
271
  When changing the plugin, keep these invariants:
275
272
 
276
- - `src/config/defaults.ts` is the runtime source of truth for defaults
277
- - `src/config/models.ts` is the source of truth for shared model presets and provider guidance
273
+ - `hiai-opencode.json` is the source of truth for user-facing runtime defaults and model IDs
274
+ - `src/config/defaults.ts` must remain a loader, not a second model map
278
275
  - root docs should use canonical runtime names, not stale internal aliases
279
276
  - user-facing docs should describe visible agents first and hidden/system agents second
280
277
  - 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 |