@hiai-gg/hiai-opencode 0.1.9 → 0.2.0

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 (134) hide show
  1. package/.env.example +0 -19
  2. package/AGENTS.md +214 -54
  3. package/ARCHITECTURE.md +9 -11
  4. package/LICENSE.md +4 -3
  5. package/README.md +68 -135
  6. package/assets/cli/hiai-opencode.mjs +137 -86
  7. package/config/.logs/subtask2.log +2 -0
  8. package/config/.mcp.json +45 -0
  9. package/config/.opencode/palace/knowledge_graph.sqlite3 +0 -0
  10. package/config/.opencode/palace/knowledge_graph.sqlite3-shm +0 -0
  11. package/config/.opencode/palace/knowledge_graph.sqlite3-wal +0 -0
  12. package/config/hiai-opencode.schema.json +176 -62
  13. package/dist/agents/builtin-agents/{guard-agent.d.ts → manager-agent.d.ts} +1 -1
  14. package/dist/agents/dynamic-agent-policy-sections.d.ts +2 -0
  15. package/dist/agents/{guard → manager}/agent.d.ts +7 -7
  16. package/dist/agents/manager/default-prompt-sections.d.ts +5 -0
  17. package/dist/agents/manager/default.d.ts +2 -0
  18. package/dist/agents/manager/index.d.ts +2 -0
  19. package/dist/agents/{guard → manager}/prompt-section-builder.d.ts +1 -1
  20. package/dist/agents/{guard → manager}/shared-prompt.d.ts +2 -2
  21. package/dist/agents/prompt-library/index.d.ts +0 -1
  22. package/dist/agents/strategist/behavioral-summary.d.ts +1 -1
  23. package/dist/agents/strategist/high-accuracy-mode.d.ts +1 -1
  24. package/dist/agents/strategist/identity-constraints.d.ts +1 -1
  25. package/dist/agents/strategist/index.d.ts +1 -1
  26. package/dist/agents/strategist/interview-mode.d.ts +1 -1
  27. package/dist/agents/strategist/plan-generation.d.ts +1 -1
  28. package/dist/agents/strategist/plan-template.d.ts +1 -1
  29. package/dist/agents/strategist/system-prompt.d.ts +3 -3
  30. package/dist/agents/types.d.ts +2 -2
  31. package/dist/agents/writer.d.ts +7 -0
  32. package/dist/config/index.d.ts +4 -6
  33. package/dist/config/platform-schema.d.ts +64 -56
  34. package/dist/config/schema/agent-names.d.ts +9 -10
  35. package/dist/config/schema/agent-overrides.d.ts +2 -258
  36. package/dist/config/schema/browser-automation.d.ts +0 -4
  37. package/dist/config/schema/{oh-my-opencode-config.d.ts → hiai-opencode-config.d.ts} +2 -261
  38. package/dist/config/schema/hooks.d.ts +1 -1
  39. package/dist/config/schema/index.d.ts +2 -2
  40. package/dist/config/types.d.ts +7 -5
  41. package/dist/create-hooks.d.ts +3 -0
  42. package/dist/features/boulder-state/constants.d.ts +1 -1
  43. package/dist/features/boulder-state/types.d.ts +1 -1
  44. package/dist/features/builtin-commands/templates/refactor.d.ts +1 -1
  45. package/dist/features/builtin-skills/skills/{playwright.d.ts → agent-browser.d.ts} +0 -1
  46. package/dist/features/builtin-skills/skills/index.d.ts +1 -2
  47. package/dist/hooks/critic-plans-only/agent-matcher.d.ts +1 -0
  48. package/dist/hooks/critic-plans-only/constants.d.ts +6 -0
  49. package/dist/hooks/critic-plans-only/hook.d.ts +11 -0
  50. package/dist/hooks/critic-plans-only/index.d.ts +3 -0
  51. package/dist/hooks/critic-plans-only/path-policy.d.ts +1 -0
  52. package/dist/hooks/index.d.ts +2 -1
  53. package/dist/hooks/json-error-recovery/hook.d.ts +1 -1
  54. package/dist/hooks/manager/hook-name.d.ts +1 -0
  55. package/dist/hooks/{guard → manager}/system-reminder-templates.d.ts +2 -2
  56. package/dist/hooks/mempalace-auto-save/constants.d.ts +1 -0
  57. package/dist/hooks/mempalace-auto-save/handler.d.ts +13 -0
  58. package/dist/hooks/mempalace-auto-save/index.d.ts +15 -0
  59. package/dist/hooks/mempalace-auto-save/types.d.ts +16 -0
  60. package/dist/hooks/strategist-md-only/constants.d.ts +2 -2
  61. package/dist/index.js +1266 -1920
  62. package/dist/internals/plugins/pty/pty/tools/list.d.ts +2 -5
  63. package/dist/mcp/registry.d.ts +1 -1
  64. package/dist/mcp/types.d.ts +0 -4
  65. package/dist/plugin/hooks/create-continuation-hooks.d.ts +4 -0
  66. package/dist/plugin/tool-registry.d.ts +4 -2
  67. package/dist/plugin-handlers/agent-priority-order.d.ts +2 -2
  68. package/dist/shared/agent-display-names.d.ts +2 -2
  69. package/dist/shared/system-directive.d.ts +2 -2
  70. package/dist/tools/agent-browser/constants.d.ts +16 -0
  71. package/dist/tools/agent-browser/index.d.ts +4 -0
  72. package/dist/tools/agent-browser/integration.d.ts +2 -0
  73. package/dist/tools/agent-browser/tools.d.ts +2 -0
  74. package/dist/tools/agent-browser/types.d.ts +80 -0
  75. package/dist/tools/call-hiai-agent/background-agent-executor.d.ts +5 -0
  76. package/dist/tools/{call-omo-agent → call-hiai-agent}/background-executor.d.ts +2 -2
  77. package/dist/tools/call-hiai-agent/constants.d.ts +3 -0
  78. package/dist/tools/{call-omo-agent → call-hiai-agent}/index.d.ts +1 -1
  79. package/dist/tools/{call-omo-agent → call-hiai-agent}/session-creator.d.ts +2 -2
  80. package/dist/tools/{call-omo-agent → call-hiai-agent}/subagent-session-creator.d.ts +2 -2
  81. package/dist/tools/{call-omo-agent → call-hiai-agent}/sync-executor.d.ts +2 -2
  82. package/dist/tools/{call-omo-agent → call-hiai-agent}/tools.d.ts +1 -1
  83. package/dist/tools/{call-omo-agent → call-hiai-agent}/types.d.ts +2 -2
  84. package/dist/tools/delegate-task/constants.d.ts +1 -1
  85. package/dist/tools/delegate-task/sub-agent.d.ts +1 -1
  86. package/dist/tools/index.d.ts +2 -1
  87. package/dist/tools/task/todo-sync.d.ts +1 -1
  88. package/docs/HOOKS.md +126 -0
  89. package/docs/HOOK_TIMINGS.md +58 -0
  90. package/docs/PERMISSIONS.md +84 -0
  91. package/docs/quickstart.md +60 -0
  92. package/hiai-opencode.json +10 -22
  93. package/package.json +13 -11
  94. package/skills/firecrawl-cli/SKILL.md +314 -0
  95. package/skills/firecrawl-cli/rules/install.md +98 -0
  96. package/assets/mcp/playwright.mjs +0 -83
  97. package/assets/mcp/rag.mjs +0 -236
  98. package/dist/agents/brainstormer.d.ts +0 -7
  99. package/dist/agents/guard/default-prompt-sections.d.ts +0 -6
  100. package/dist/agents/guard/default.d.ts +0 -2
  101. package/dist/agents/guard/index.d.ts +0 -2
  102. package/dist/agents/platform-manager.d.ts +0 -7
  103. package/dist/agents/prompt-library/platform.d.ts +0 -1
  104. package/dist/features/builtin-skills/skills/playwright-cli.d.ts +0 -10
  105. package/dist/hooks/guard/hook-name.d.ts +0 -1
  106. package/dist/tools/call-omo-agent/background-agent-executor.d.ts +0 -5
  107. package/dist/tools/call-omo-agent/constants.d.ts +0 -3
  108. /package/dist/hooks/{guard → manager}/background-launch-session-tracking.d.ts +0 -0
  109. /package/dist/hooks/{guard → manager}/bob-path.d.ts +0 -0
  110. /package/dist/hooks/{guard → manager}/boulder-continuation-injector.d.ts +0 -0
  111. /package/dist/hooks/{guard → manager}/boulder-session-lineage.d.ts +0 -0
  112. /package/dist/hooks/{guard → manager}/event-handler.d.ts +0 -0
  113. /package/dist/hooks/{guard → manager}/final-wave-approval-gate.d.ts +0 -0
  114. /package/dist/hooks/{guard → manager}/final-wave-plan-state.d.ts +0 -0
  115. /package/dist/hooks/{guard → manager}/guard-hook.d.ts +0 -0
  116. /package/dist/hooks/{guard → manager}/idle-event.d.ts +0 -0
  117. /package/dist/hooks/{guard → manager}/index.d.ts +0 -0
  118. /package/dist/hooks/{guard → manager}/is-abort-error.d.ts +0 -0
  119. /package/dist/hooks/{guard → manager}/recent-model-resolver.d.ts +0 -0
  120. /package/dist/hooks/{guard → manager}/resolve-active-boulder-session.d.ts +0 -0
  121. /package/dist/hooks/{guard → manager}/session-last-agent.d.ts +0 -0
  122. /package/dist/hooks/{guard → manager}/subagent-session-id.d.ts +0 -0
  123. /package/dist/hooks/{guard → manager}/task-context.d.ts +0 -0
  124. /package/dist/hooks/{guard → manager}/tool-execute-after.d.ts +0 -0
  125. /package/dist/hooks/{guard → manager}/tool-execute-before.d.ts +0 -0
  126. /package/dist/hooks/{guard → manager}/types.d.ts +0 -0
  127. /package/dist/hooks/{guard → manager}/verification-reminders.d.ts +0 -0
  128. /package/dist/hooks/{guard → manager}/write-edit-tool-policy.d.ts +0 -0
  129. /package/dist/tools/{call-omo-agent → call-hiai-agent}/agent-resolver.d.ts +0 -0
  130. /package/dist/tools/{call-omo-agent → call-hiai-agent}/completion-poller.d.ts +0 -0
  131. /package/dist/tools/{call-omo-agent → call-hiai-agent}/message-dir.d.ts +0 -0
  132. /package/dist/tools/{call-omo-agent → call-hiai-agent}/message-processor.d.ts +0 -0
  133. /package/dist/tools/{call-omo-agent → call-hiai-agent}/message-storage-directory.d.ts +0 -0
  134. /package/dist/tools/{call-omo-agent → call-hiai-agent}/tool-context-with-metadata.d.ts +0 -0
package/.env.example CHANGED
@@ -22,14 +22,6 @@
22
22
  # FIRECRAWL_API_KEY=your_firecrawl_api_key_here
23
23
 
24
24
  # Optional - Context7 code search MCP
25
- # CONTEXT7_API_KEY=your_context7_api_key_here
26
-
27
- # Optional - Exa remote websearch MCP. Recommended for higher limits.
28
- # EXA_API_KEY=your_exa_api_key_here
29
-
30
- # Optional - Tavily remote websearch MCP.
31
- # Required only when hiai-opencode.json uses provider "tavily".
32
- # TAVILY_API_KEY=your_tavily_api_key_here
33
25
 
34
26
  # Local Model Helpers
35
27
 
@@ -50,14 +42,6 @@
50
42
  # Optional - set to 0, false, or no to prevent first-run Python package install
51
43
  # HIAI_MCP_AUTO_INSTALL=1
52
44
 
53
- # Playwright MCP
54
-
55
- # Optional - set to 1, true, or yes to install Chromium during launcher startup
56
- # HIAI_PLAYWRIGHT_INSTALL_BROWSERS=0
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
-
61
45
  # Static MCP export
62
46
 
63
47
  # Optional - controls automatic .mcp.json export when the plugin loads.
@@ -71,7 +55,4 @@
71
55
  # Values: safe (default), force
72
56
  # HIAI_OPENCODE_EXPORT_MCP_MODE=safe
73
57
 
74
- # RAG MCP
75
58
 
76
- # Optional - RAG search tool endpoint
77
- # OPENCODE_RAG_URL=http://localhost:9002/tools/search
package/AGENTS.md CHANGED
@@ -115,11 +115,8 @@ When a user asks OpenCode or another agent to finish installing this plugin, fol
115
115
  - `FIRECRAWL_API_KEY`
116
116
  - `STITCH_AI_API_KEY`
117
117
  - `CONTEXT7_API_KEY`
118
- - `EXA_API_KEY`
119
- - `TAVILY_API_KEY`
120
118
  - `MEMPALACE_PYTHON`
121
- - `OPENCODE_RAG_URL`
122
- - `HIAI_PLAYWRIGHT_INSTALL_BROWSERS`
119
+
123
120
  - `HIAI_MCP_AUTO_INSTALL`
124
121
  7. Verify with:
125
122
  - `opencode debug config`
@@ -132,24 +129,13 @@ When a user asks OpenCode or another agent to finish installing this plugin, fol
132
129
 
133
130
  | Service | Enable when | Dependency behavior |
134
131
  |---|---|---|
135
- | `playwright` | Node and npx are available | Helper launcher runs `@playwright/mcp@latest`; set `HIAI_PLAYWRIGHT_INSTALL_BROWSERS=1` to install Chromium on first start |
136
132
  | `sequential-thinking` | Node and npx are available | Helper launcher runs `@modelcontextprotocol/server-sequential-thinking` |
137
- | `firecrawl` | `FIRECRAWL_API_KEY` is set | Helper launcher runs `firecrawl-mcp` |
133
+
138
134
  | `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. Interpreter can be pinned via `mcp.mempalace.pythonPath` or `MEMPALACE_PYTHON` |
139
- | `rag` | User has a local or remote RAG endpoint | Uses `OPENCODE_RAG_URL`, defaulting to `http://localhost:9002/tools/search` |
140
135
  | `stitch` | `STITCH_AI_API_KEY` is set | Remote MCP endpoint |
141
136
  | `context7` | User wants Context7 docs/search | Remote MCP endpoint; use `CONTEXT7_API_KEY` if available |
142
- | `websearch` | User wants remote web search | Defaults to Exa; `EXA_API_KEY` optional for Exa, `TAVILY_API_KEY` required for Tavily |
143
137
  | `grep_app` | User wants GitHub/code search | Remote MCP endpoint; no key required |
144
138
 
145
- Playwright troubleshooting rules:
146
-
147
- - `skill_mcp` can call enabled hiai-opencode builtin MCPs and skill-embedded MCPs. If it reports a builtin MCP such as `firecrawl` as missing, check that the installed plugin version includes builtin fallback support and that `hiai-opencode.json` has that MCP enabled.
148
- - If `skill_mcp` says `MCP server "playwright" not found`, first check `hiai-opencode mcp-status`; do not report this as a browser dependency failure.
149
- - 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.
150
- - Without sudo, try a system browser override in `hiai-opencode.json`, such as `--browser chrome` or `--browser msedge`.
151
- - If no browser path works, use `curl` only as degraded HTTP verification and explicitly say it is not a replacement for browser testing.
152
-
153
139
  ### Prompt For OpenCode Users
154
140
 
155
141
  Users can paste this into OpenCode after installing the plugin:
@@ -164,14 +150,10 @@ Verify @hiai-gg/hiai-opencode is registered. If I ask for Dynamic Context Prunin
164
150
  Find or create hiai-opencode.json in the project root or .opencode/. Use its mcp object as the only switchboard for MCP enable/disable.
165
151
 
166
152
  Check which services can run here:
167
- - playwright: node/npx; optionally HIAI_PLAYWRIGHT_INSTALL_BROWSERS=1.
168
153
  - sequential-thinking: node/npx.
169
- - firecrawl: FIRECRAWL_API_KEY.
170
154
  - mempalace: uv or Python 3.9+ with pip; set `mcp.mempalace.pythonPath` (or `MEMPALACE_PYTHON`) if needed; `HIAI_MCP_AUTO_INSTALL` controls first-run pip install.
171
- - rag: OPENCODE_RAG_URL or http://localhost:9002/tools/search.
172
155
  - stitch: STITCH_AI_API_KEY.
173
156
  - context7: optional CONTEXT7_API_KEY.
174
- - websearch: optional EXA_API_KEY for Exa, or TAVILY_API_KEY when provider is tavily.
175
157
  - grep_app: no key required.
176
158
 
177
159
  Report missing keys without printing secret values. Never invent or hardcode API keys.
@@ -186,12 +168,11 @@ Visible primary agents:
186
168
  - `Bob`
187
169
  - `Coder`
188
170
  - `Strategist`
189
- - `Guard`
171
+ - `Manager`
190
172
  - `Critic`
191
173
  - `Designer`
192
174
  - `Researcher`
193
- - `Manager`
194
- - `Brainstormer`
175
+ - `Writer`
195
176
  - `Vision`
196
177
 
197
178
  Hidden/system or compatibility agents:
@@ -200,6 +181,7 @@ Hidden/system or compatibility agents:
200
181
  - `Sub`
201
182
  - `build`
202
183
  - `plan`
184
+ - `quality-guardian`
203
185
 
204
186
  Automatic task distribution:
205
187
 
@@ -208,8 +190,8 @@ Automatic task distribution:
208
190
  - `deep`, `ultrabrain`, `visual-engineering`, `artistry`, and `unspecified-high` use Coder's deep contour
209
191
  - `Critic` is selected explicitly for review and verification passes
210
192
  - `Researcher` is selected explicitly for codebase and documentation discovery
211
- - `Designer`, `Brainstormer`, `Manager`, and `Vision` are direct callable specialists, not category executors
212
- - `Bob` and `Guard` are orchestration agents, not normal subagent routing targets
193
+ - `Designer`, `Writer`, `Manager`, and `Vision` are direct callable specialists, not category executors
194
+ - `Bob` and `Manager` are orchestration agents, not normal subagent routing targets
213
195
 
214
196
  If runtime output differs from that set, inspect:
215
197
 
@@ -227,7 +209,7 @@ The runtime loader is:
227
209
 
228
210
  - [src/config/defaults.ts](src/config/defaults.ts)
229
211
 
230
- Users configure only the 10 primary agent model slots under `models`: `bob`, `coder`, `strategist`, `guard`, `critic`, `designer`, `researcher`, `manager`, `brainstormer`, and `vision`.
212
+ Users configure only the 10 primary agent model slots under `models`: `bob`, `coder`, `strategist`, `manager`, `critic`, `designer`, `researcher`, `writer`, `vision`, and `sub`.
231
213
  Hidden agents and task categories are derived internally in `src/config/defaults.ts`.
232
214
  Use fully qualified model IDs. Do not introduce local aliases like `hiai-fast`, `sonnet`, `fast`, or `high`.
233
215
  When helping a user choose model IDs, tell them to connect providers in OpenCode, run `opencode models`, and copy the exact `provider/model-id` strings into `hiai-opencode.json`. Do not invent provider prefixes.
@@ -244,7 +226,7 @@ Use this table when you need to change something and want the right file immedia
244
226
  | Change Bob behavior or prompt text | [src/agents/bob.ts](src/agents/bob.ts), `src/agents/bob/*` | Bob prompt authoring lives there |
245
227
  | Change Coder behavior or prompt text | `src/agents/coder/*` | Coder prompt authoring lives there |
246
228
  | Change Strategist behavior or prompt text | `src/agents/strategist/*` | Strategist prompt authoring lives there |
247
- | Change Guard behavior or prompt text | `src/agents/guard/*` | Guard prompt authoring lives there |
229
+ | Change Manager behavior or prompt text | `src/agents/manager/*` | Manager prompt authoring lives there |
248
230
  | Change Critic prompt text | `src/agents/critic/*` | Critic prompt authoring lives there |
249
231
  | Change Vision prompt text | [src/agents/ui.ts](src/agents/ui.ts) | Vision lives there |
250
232
  | Change Manager prompt text | [src/agents/platform-manager.ts](src/agents/platform-manager.ts) | Manager lives there |
@@ -277,7 +259,7 @@ These decide the high-level config object for each agent:
277
259
  - Bob: [src/agents/bob.ts](src/agents/bob.ts)
278
260
  - Coder: `src/agents/coder/*`
279
261
  - Strategist: `src/agents/strategist/*`
280
- - Guard: `src/agents/guard/*`
262
+ - Manager: `src/agents/manager/*`
281
263
  - Critic: `src/agents/critic/*`
282
264
  - Vision: [src/agents/ui.ts](src/agents/ui.ts)
283
265
  - Manager: [src/agents/platform-manager.ts](src/agents/platform-manager.ts)
@@ -287,10 +269,10 @@ These decide the high-level config object for each agent:
287
269
 
288
270
  Examples:
289
271
 
290
- - Bob: `src/agents/bob/gpt-pro.ts`, `src/agents/bob/gemini.ts`
291
- - Coder: `src/agents/coder/gpt.ts`, `src/agents/coder/gpt-codex.ts`, `src/agents/coder/gpt-pro.ts`
292
- - Strategist: `src/agents/strategist/gpt.ts`, `src/agents/strategist/gemini.ts`
293
- - Guard: `src/agents/guard/gpt.ts`, `src/agents/guard/gemini.ts`
272
+ - Bob: `src/agents/bob.ts` (single file — variants are merged via factory logic)
273
+ - Coder: `src/agents/coder/agent.ts`, `src/agents/coder/gpt.ts` (model routing via index.ts)
274
+ - Strategist: `src/agents/strategist/index.ts` (mode variants via sub-directory files)
275
+ - Manager: `src/agents/manager/agent.ts`, `src/agents/manager/default.ts`, `src/agents/manager/default-prompt-sections.ts`
294
276
 
295
277
  ### Layer 3: Shared Prompt Sections
296
278
 
@@ -350,20 +332,16 @@ Runtime helper assets live in:
350
332
 
351
333
  Current MCP set:
352
334
 
353
- - `playwright`
354
- - `stitch`
355
335
  - `sequential-thinking`
356
- - `firecrawl`
357
- - `rag`
358
336
  - `mempalace`
337
+ - `stitch`
359
338
  - `context7`
360
- - `websearch`
361
339
  - `grep_app`
362
340
 
363
341
  ## Writing And Website Copy
364
342
 
365
- Public-facing website/product copy is owned by `brainstormer`.
366
- `writer`, `copywriter`, `content-writer`, and `website-writer` are aliases for `brainstormer`.
343
+ Public-facing website/product copy is owned by `writer`.
344
+ `writer`, `copywriter`, `content-writer`, and `website-writer` are aliases for `writer`.
367
345
 
368
346
  Use the `website-copywriting` skill for:
369
347
 
@@ -377,10 +355,10 @@ Use the `website-copywriting` skill for:
377
355
  Preferred invocation:
378
356
 
379
357
  ```text
380
- task(subagent_type="brainstormer", load_skills=["website-copywriting"], run_in_background=false, description="Write landing page copy", prompt="...")
358
+ task(subagent_type="writer", load_skills=["website-copywriting"], run_in_background=false, description="Write landing page copy", prompt="...")
381
359
  ```
382
360
 
383
- Use `designer` or `visual-engineering` for visual direction. Use `brainstormer` for words.
361
+ Use `designer` or `visual-engineering` for visual direction. Use `writer` for words.
384
362
 
385
363
  ## Manager Memory Stewardship
386
364
 
@@ -389,7 +367,7 @@ Use `platform-manager` / `manager` when durable project memory or handoff state
389
367
  Manager owns:
390
368
 
391
369
  - MemPalace decision hygiene: search first, deduplicate, write only durable decisions and important preferences.
392
- - Architecture memory updates: when architecture changes, update MemPalace and sync to RAG only if the configured RAG endpoint exposes write/upsert capability.
370
+ - Architecture memory updates: when architecture changes, update MemPalace.
393
371
  - TODO hygiene: mark completed items complete, preserve unfinished tasks with blocker and next action, remove duplicate stale TODOs.
394
372
  - Session continuity: write concise handoff ledgers, not raw transcripts.
395
373
 
@@ -447,14 +425,11 @@ Common service keys:
447
425
  - `STITCH_AI_API_KEY`
448
426
  - `FIRECRAWL_API_KEY`
449
427
  - `CONTEXT7_API_KEY`
450
- - `EXA_API_KEY`
451
- - `TAVILY_API_KEY`
452
428
  - `OLLAMA_BASE_URL`
453
429
  - `OLLAMA_MODEL`
454
430
  - `MEMPALACE_PYTHON`
455
431
  - `MEMPALACE_PALACE_PATH`
456
- - `OPENCODE_RAG_URL`
457
- - `HIAI_PLAYWRIGHT_INSTALL_BROWSERS`
432
+
458
433
  - `HIAI_MCP_AUTO_INSTALL`
459
434
  - `HIAI_OPENCODE_AUTO_EXPORT_MCP`
460
435
  - `HIAI_OPENCODE_MCP_EXPORT_PATH`
@@ -471,24 +446,21 @@ AGENTS:
471
446
  sub — implementation (cheap, bounded)
472
447
  strategist — planning (read-only, no code)
473
448
  critic — review gate (APPROVED/REJECTED)
474
- researcher — discovery: local grep + Context7/Firecrawl/grep_app/websearch/RAG/MemPalace
449
+ researcher — discovery: local grep + Context7/Firecrawl/grep_app/MemPalace
475
450
  designer — UI via Stitch MCP
476
- brainstormer — copy/positioning/SEO (write to copy files only)
451
+ writer — copy/positioning/SEO (write to copy files only)
477
452
  vision — PDF/image extraction
478
- manager — MemPalace/RAG memory steward
453
+ manager — MemPalace memory steward
479
454
  quality-guardian — post-impl review + bug investigation
480
- guard sandboxed bash executor
455
+ agent-skills skill registry, discovery
481
456
 
482
457
  MCP INTEGRATIONS (who uses what):
483
458
  Stitch -> designer (UI generation)
484
- Firecrawl -> researcher (web scrape/search/extract)
459
+ Firecrawl -> researcher (CLI skill)
485
460
  Context7 -> researcher, coder (lib docs)
486
461
  grep_app -> researcher (OSS code patterns)
487
- websearch -> researcher (general web)
488
- RAG -> researcher, brainstormer, manager (project knowledge)
489
462
  MemPalace -> manager (primary), all agents (search before answer)
490
463
  Sequential-Thinking -> strategist, critic (deep reasoning)
491
- Playwright -> coder (only for tests/automation)
492
464
 
493
465
  LSP:
494
466
  typescript, svelte, eslint, bash, pyright
@@ -508,6 +480,194 @@ This most often affects:
508
480
  - `mempalace`
509
481
  - local `npx`-backed MCP processes
510
482
 
483
+ ## Closure Protocol
484
+
485
+ All agents MUST wrap their final response in a structured `<CLOSURE>` block. This is injected into every agent prompt via `buildAgentIdentitySection()` in [src/agents/prompt-library/identity.ts](src/agents/prompt-library/identity.ts).
486
+
487
+ ### Schema
488
+
489
+ ```xml
490
+ <CLOSURE>
491
+ {
492
+ "reasoning": "Concise summary of what was achieved and why it satisfies the request.",
493
+ "evidence": ["Link to test results", "File path to changes", "Log snippets", "LSP diagnostics clean"],
494
+ "readiness": "done" | "accept" | "reject"
495
+ }
496
+ </CLOSURE>
497
+ ```
498
+
499
+ ### Readiness Values
500
+
501
+ | Value | Meaning |
502
+ |-------|---------|
503
+ | `done` | Task completed successfully |
504
+ | `accept` | Reviewer approved the proposed changes |
505
+ | `reject` | Reviewer denied the changes with feedback |
506
+
507
+ **WARNING**: Responses without a valid `<CLOSURE>` block will be automatically REJECTED by the system.
508
+
509
+ ### Relationship to `<promise>DONE</promise>`
510
+
511
+ The ralph-loop continuation system uses `<promise>DONE</promise>` as its signal to stop iterating. This is separate from `<CLOSURE>`:
512
+
513
+ - `<CLOSURE>` — task completion marker, required on every agent response
514
+ - `<promise>DONE</promise>` — ralph-loop continuation signal, stops the loop when emitted
515
+
516
+ Both can appear together; they do not conflict. The closure validator lives in [src/shared/closure-protocol.ts](src/shared/closure-protocol.ts).
517
+
518
+ ### When to Inspect Closure Injection
519
+
520
+ If an agent response is missing `<CLOSURE>` at runtime but the source prompts look correct, check in order:
521
+
522
+ 1. Does the agent factory call `buildAgentIdentitySection()`? (located in [src/agents/prompt-library/identity.ts](src/agents/prompt-library/identity.ts))
523
+ 2. Does `src/shared/closure-protocol.ts` export the correct `CLOSURE_SCHEMA_PROMPT`?
524
+ 3. Does `src/agents/builtin-agents/agent-overrides.ts` or [src/plugin-handlers/agent-config-handler.ts](src/plugin-handlers/agent-config-handler.ts) strip or override the closure injection?
525
+
526
+ ## Troubleshooting
527
+
528
+ ### `hiai-opencode doctor` reports schema errors
529
+
530
+ 1. Run `hiai-opencode doctor` and look for the specific missing or unknown key
531
+ 2. Check your `hiai-opencode.json` against the schema in [config/hiai-opencode.schema.json](config/hiai-opencode.schema.json)
532
+ 3. Verify all keys in `models`, `mcp`, and `skill_discovery` match documented shapes
533
+ 4. Run `opencode debug config` to confirm the plugin is registered
534
+
535
+ ### `hiai-opencode mcp-status` shows all services as ⚠️ missing
536
+
537
+ - The plugin is likely registered but cannot find its bundled `hiai-opencode.json`
538
+ - Run `bun run build` in the plugin repository to ensure `dist/` is populated
539
+ - If running from npm, reinstall: `opencode plugin @hiai-gg/hiai-opencode@latest --global`
540
+
541
+ ### `opencode mcp list` does not show hiai-opencode MCP servers
542
+
543
+ - `opencode mcp list` reads static `.mcp.json` files, not runtime plugin MCP
544
+ - Run `hiai-opencode export-mcp .mcp.json` to write a static export
545
+ - The plugin auto-exports on startup when `HIAI_OPENCODE_AUTO_EXPORT_MCP` is not disabled
546
+
547
+ ### Firecrawl tools return "FIRECRAWL_API_KEY missing" despite having the key set
548
+
549
+ The `skill_mcp` env scrubber strips secret-shaped env vars before launching stdio MCP servers. If your key only lives in `process.env`, move it into the explicit `environment` block in `hiai-opencode.json`:
550
+
551
+ ```json
552
+ {
553
+ "mcp": {
554
+ "firecrawl-cli": {
555
+ "enabled": true,
556
+ "environment": { "FIRECRAWL_API_KEY": "fc-..." }
557
+ }
558
+ }
559
+ }
560
+ ```
561
+
562
+ This bypasses the filter because explicit `environment` entries are an allowlist.
563
+
564
+ ### Browser Automation (agent-browser)
565
+
566
+ For browser automation, use the `/agent-browser` skill instead of MCP. The CLI-based approach uses native Chrome via CDP, snapshot-based @eN refs, and doesn't require MCP server startup — no Playwright.
567
+
568
+ **Install** (Bun):
569
+ ```bash
570
+ bun add -g agent-browser && agent-browser install
571
+ ```
572
+
573
+ Or via npm:
574
+ ```bash
575
+ npm i -g agent-browser && agent-browser install
576
+ ```
577
+
578
+ Repo: https://github.com/vercel-labs/agent-browser
579
+
580
+ Key environment variables (`AGENT_BROWSER_*`):
581
+ - `AGENT_BROWSER_HEADED=1` — show browser window
582
+ - `AGENT_BROWSER_SESSION=name` — isolated session
583
+ - `AGENT_BROWSER_PROFILE=path` — persistent profile
584
+ - `AGENT_BROWSER_PROVIDER=name` — cloud provider (browserbase, browseruse, kernel)
585
+ - `AGENT_BROWSER_AUTO_CONNECT=1` — auto-discover running Chrome
586
+ - `AGENT_BROWSER_EXECUTABLE_PATH` — custom browser binary
587
+
588
+ Key pattern: `snapshot -i --json` → @eN refs → `click @e2` / `fill @e3 "text"`
589
+
590
+ Use `/agent-browser` skill in OpenCode for browser tasks — navigation, snapshots, screenshots, form filling, console/network inspection.
591
+
592
+ ### MemPalace MCP fails with "python not found"
593
+
594
+ The launcher prefers `uv`. If `uv` is not available, it falls back to `python`. Set `mcp.mempalace.pythonPath` or `MEMPALACE_PYTHON` to the correct interpreter:
595
+
596
+ ```json
597
+ {
598
+ "mcp": {
599
+ "mempalace": {
600
+ "enabled": true,
601
+ "pythonPath": "/usr/bin/python3"
602
+ }
603
+ }
604
+ }
605
+ ```
606
+
607
+ If `HIAI_MCP_AUTO_INSTALL` is not disabled, the launcher will attempt `python -m pip install --user mempalace` on first start.
608
+
609
+ ### Agent prompt looks correct in source but wrong at runtime
610
+
611
+ The final runtime prompt is assembled from multiple layers beyond `src/agents/`:
612
+
613
+ 1. Source prompt in `src/agents/<agent>/*.ts`
614
+ 2. Model-specific variant in `src/agents/<agent>/<model>.ts`
615
+ 3. Shared prompt-library blocks in `src/agents/prompt-library/*`
616
+ 4. Runtime injection from `src/agents/builtin-agents/agent-overrides.ts` and `src/agents/builtin-agents/environment-context.ts`
617
+ 5. Closure protocol from `src/shared/closure-protocol.ts`
618
+ 6. Plugin handler normalization in [src/plugin-handlers/agent-config-handler.ts](src/plugin-handlers/agent-config-handler.ts)
619
+
620
+ Inspect layer 6 first when runtime output diverges from source.
621
+
622
+ ## Common Pitfalls
623
+
624
+ ### Installing MCP server packages as OpenCode plugins
625
+
626
+ MCP servers (`firecrawl-mcp`, `@modelcontextprotocol/server-sequential-thinking`) are NOT OpenCode plugins. Adding them to the `plugin` array in `opencode.json` will not work.
627
+
628
+ Register only `@hiai-gg/hiai-opencode` as a plugin. MCP wiring is handled through the `mcp` object in `hiai-opencode.json`.
629
+
630
+ ### Inventing model ID prefixes
631
+
632
+ When users ask which model to choose, tell them to run `opencode models` and copy the exact `provider/model-id` strings from that output into `hiai-opencode.json`. Do not invent prefixes like `openrouter/minimax/` — the provider prefix must match what OpenCode Connect has authorized.
633
+
634
+ ### Hardcoding API keys in config files
635
+
636
+ Never put actual API key values in `hiai-opencode.json`. Use `{env:VARIABLE_NAME}` placeholder format:
637
+
638
+ ```json
639
+ {
640
+ "mcp": {
641
+ "firecrawl-cli": {
642
+ "enabled": true,
643
+ "environment": { "FIRECRAWL_API_KEY": "{env:FIRECRAWL_API_KEY}" }
644
+ }
645
+ }
646
+ }
647
+ ```
648
+
649
+ Check with: `grep -E '(AQ\.|fc-|ctx7sk-|sk-|key-)' hiai-opencode.json` — should return 0 matches.
650
+
651
+ ### Enabling all skill sources
652
+
653
+ Global OpenCode, Claude, and Agents skill folders are disabled by default for a reason: they can pollute the skill tree with low-quality or irrelevant skills. Only enable them if the user explicitly asks.
654
+
655
+ ### Writing code in Bob or Manager
656
+
657
+ Bob is an orchestrator — it MUST delegate, not implement. Manager is a memory steward — it should not write code files. Assign implementation to `Coder` or `Sub`, not to these orchestration agents.
658
+
659
+ ### Confusing `<CLOSURE>` with `<promise>DONE</promise>`
660
+
661
+ `<CLOSURE>` is a mandatory task-completion marker that Manager checks on every response. `<promise>DONE</promise>` is a ralph-loop signal that stops the iteration loop. They serve different purposes and both can coexist. See the Closure Protocol section for details.
662
+
663
+ ### Treating `src/agents/` as the only prompt source
664
+
665
+ Prompt assembly has 6 layers. Changing a file in `src/agents/` is necessary but not sufficient if layers 4–6 are overriding the result. See "Prompting Truth Model" for the full picture.
666
+
667
+ ### Skipping `lsp_diagnostics` after edits
668
+
669
+ Coder MUST run `lsp_diagnostics` after every file edit. LSP errors will not surface automatically — agents must proactively call the diagnostic tool to catch TypeScript/Svelte/Bash/Python errors.
670
+
511
671
  ## Prompt Ownership
512
672
 
513
673
  For contributor-level detail on how prompts are assembled from source through runtime injection, see [src/agents/AGENTS.md](src/agents/AGENTS.md).
package/ARCHITECTURE.md CHANGED
@@ -31,7 +31,7 @@ User input
31
31
  │ category routes to: │
32
32
  │ deep/ultrabrain → coder (implementation) │
33
33
  │ quick/bounded → sub (cheap bounded) │
34
- │ writing → brainstormer (copy) │
34
+ │ writing → writer (copy) │
35
35
  │ visual-engineering → designer (Stitch MCP) │
36
36
  │ artistry → designer (creative) │
37
37
  │ │
@@ -72,12 +72,11 @@ These are the agents meant to be visible in the normal UI:
72
72
  - `Bob`
73
73
  - `Coder`
74
74
  - `Strategist`
75
- - `Guard`
75
+ - `Manager`
76
76
  - `Critic`
77
77
  - `Designer`
78
78
  - `Researcher`
79
- - `Manager`
80
- - `Brainstormer`
79
+ - `Writer`
81
80
  - `Vision`
82
81
 
83
82
  ### Hidden/System Agents
@@ -88,6 +87,7 @@ These exist for compatibility or system behavior and are not intended as user-fa
88
87
  - `Sub`
89
88
  - `build`
90
89
  - `plan`
90
+ - `Quality Guardian`
91
91
 
92
92
  ### Canonical Source Files
93
93
 
@@ -130,13 +130,12 @@ These files create the top-level agent config objects:
130
130
  - Bob: [src/agents/bob.ts](src/agents/bob.ts)
131
131
  - Coder: [src/agents/coder/agent.ts](src/agents/coder/agent.ts)
132
132
  - Strategist: `src/agents/strategist/*`
133
- - Guard: [src/agents/guard/agent.ts](src/agents/guard/agent.ts)
133
+ - Manager: [src/agents/manager/agent.ts](src/agents/manager/agent.ts)
134
134
  - Critic: [src/agents/critic/agent.ts](src/agents/critic/agent.ts)
135
135
  - Designer: [src/agents/designer.ts](src/agents/designer.ts)
136
- - Brainstormer: [src/agents/brainstormer.ts](src/agents/brainstormer.ts)
136
+ - Writer: [src/agents/writer.ts](src/agents/writer.ts)
137
137
  - Agent Skills: [src/agents/agent-skills.ts](src/agents/agent-skills.ts)
138
138
  - Vision: [src/agents/ui.ts](src/agents/ui.ts)
139
- - Manager: [src/agents/platform-manager.ts](src/agents/platform-manager.ts)
140
139
  - Researcher: [src/agents/researcher.ts](src/agents/researcher.ts)
141
140
 
142
141
  ### Layer 2: Model-Specific Prompt Variants
@@ -146,7 +145,7 @@ Examples:
146
145
  - Bob: `src/agents/bob/gpt-pro.ts`, `src/agents/bob/gemini.ts`
147
146
  - Coder: `src/agents/coder/gpt.ts`, `src/agents/coder/gpt-codex.ts`, `src/agents/coder/gpt-pro.ts`
148
147
  - Strategist: `src/agents/strategist/gpt.ts`, `src/agents/strategist/gemini.ts`
149
- - Guard: `src/agents/guard/gpt.ts`, `src/agents/guard/gemini.ts`
148
+ - Manager: `src/agents/manager/gpt.ts`, `src/agents/manager/gemini.ts`
150
149
 
151
150
  This is where provider- or model-family-specific behavior usually lives.
152
151
 
@@ -258,15 +257,14 @@ Helper launchers live in:
258
257
 
259
258
  Current MCP set:
260
259
 
261
- - `playwright`
262
260
  - `stitch`
263
261
  - `sequential-thinking`
264
- - `firecrawl`
265
- - `rag`
262
+ - `firecrawl` (CLI skill, not MCP)
266
263
  - `mempalace`
267
264
  - `context7`
268
265
  - `websearch`
269
266
  - `grep_app`
267
+ - `agent-browser` (CLI skill, not MCP)
270
268
 
271
269
  ## LSP
272
270
 
package/LICENSE.md CHANGED
@@ -25,12 +25,13 @@ Some are:
25
25
  | Planning / workflow influences | [obra/superpowers](https://github.com/obra/superpowers) | planning, review, and debugging ideas |
26
26
  | Specialist / platform influences | [vtemian/micode](https://github.com/vtemian/micode) | platform-style specialist behavior |
27
27
  | Agent skill ecosystem | [addyosmani/agent-skills](https://github.com/addyosmani/agent-skills) | tactical workflow skill ideas |
28
+ | Supabase Postgres skill | [supabase/agent-skills](https://github.com/supabase/agent-skills/blob/main/skills/supabase-postgres-best-practices/SKILL.md) | Postgres best practices skill |
29
+ | Browser automation | [vercel-labs/agent-browser](https://github.com/vercel-labs/agent-browser) | CLI-based browser automation via CDP |
28
30
  | Optional external plugin | [Opencode-DCP/opencode-dynamic-context-pruning](https://github.com/Opencode-DCP/opencode-dynamic-context-pruning) | not bundled |
29
31
  | MemPalace | [MemPalace/mempalace](https://github.com/MemPalace/mempalace) | external upstream MCP/runtime |
30
- | Playwright MCP | [microsoft/playwright-mcp](https://github.com/microsoft/playwright-mcp) | external MCP |
31
32
  | Sequential Thinking | [modelcontextprotocol/servers](https://github.com/modelcontextprotocol/servers) | external MCP |
32
- | Firecrawl MCP | [firecrawl-ai/firecrawl-mcp-server](https://github.com/firecrawl-ai/firecrawl-mcp-server) | external MCP |
33
- | Context7 MCP | [upstash/context7-mcp](https://github.com/upstash/context7-mcp) | external MCP |
33
+ | Firecrawl CLI skill | [firecrawl/firecrawl](https://github.com/firecrawl/firecrawl) | CLI-based web scraping, crawl, extract, search |
34
+ | Context7 MCP | [upstash/context7](https://github.com/upstash/context7) | external MCP |
34
35
  | bun-pty / PTY ecosystem | [shekohex/opencode-pty](https://github.com/shekohex/opencode-pty) | PTY/runtime integration influence |
35
36
 
36
37
  ## What Is Bundled vs External