opencode-hive 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +206 -0
- package/dist/agents/architect.d.ts +1 -1
- package/dist/agents/hive.d.ts +1 -1
- package/dist/agents/swarm.d.ts +1 -1
- package/dist/background/types.d.ts +7 -0
- package/dist/hooks/variant-hook.d.ts +50 -0
- package/dist/index.js +1220 -355
- package/dist/skills/builtin.d.ts +12 -0
- package/dist/skills/index.d.ts +1 -1
- package/dist/skills/registry.generated.d.ts +1 -1
- package/dist/tools/background-tools.d.ts +20 -7
- package/dist/utils/format.d.ts +16 -0
- package/dist/utils/prompt-budgeting.d.ts +112 -0
- package/dist/utils/prompt-file.d.ts +58 -0
- package/dist/utils/prompt-observability.d.ts +93 -0
- package/dist/utils/worker-prompt.d.ts +5 -4
- package/package.json +1 -1
- package/skills/onboarding/SKILL.md +61 -0
- package/skills/parallel-exploration/SKILL.md +286 -0
package/README.md
CHANGED
|
@@ -39,6 +39,16 @@ This enables tools like `grep_app_searchGitHub`, `context7_query-docs`, `websear
|
|
|
39
39
|
5. **Execute** — Tasks run in isolated git worktrees
|
|
40
40
|
6. **Ship** — Clean commits, full audit trail
|
|
41
41
|
|
|
42
|
+
### Planning-mode delegation
|
|
43
|
+
|
|
44
|
+
During planning, "don't execute" means "don't implement" (no code edits, no worktrees). Read-only exploration is explicitly allowed and encouraged, both via local tools and by delegating to Scout.
|
|
45
|
+
|
|
46
|
+
#### Canonical Delegation Threshold
|
|
47
|
+
|
|
48
|
+
- Delegate to Scout when you cannot name the file path upfront, expect to inspect 2+ files, or the question is open-ended ("how/where does X work?").
|
|
49
|
+
- Prefer `background_task(agent: "scout-researcher", sync: true, ...)` for single investigations; use `sync: false` only for multi-scout fan-out.
|
|
50
|
+
- Local `read`/`grep`/`glob` is acceptable only for a single known file and a bounded question.
|
|
51
|
+
|
|
42
52
|
## Tools
|
|
43
53
|
|
|
44
54
|
### Feature Management
|
|
@@ -69,6 +79,51 @@ This enables tools like `grep_app_searchGitHub`, `context7_query-docs`, `websear
|
|
|
69
79
|
| `hive_exec_complete` | Complete task (applies changes) |
|
|
70
80
|
| `hive_exec_abort` | Abort task (discard changes) |
|
|
71
81
|
|
|
82
|
+
### Background Tasks
|
|
83
|
+
| Tool | Description |
|
|
84
|
+
|------|-------------|
|
|
85
|
+
| `background_task` | Spawn a background agent task |
|
|
86
|
+
| `background_output` | Get output from a running/completed task |
|
|
87
|
+
| `background_cancel` | Cancel running background task(s) |
|
|
88
|
+
|
|
89
|
+
The `background_task` tool supports `promptFile` as an alternative to inline `prompt`:
|
|
90
|
+
```typescript
|
|
91
|
+
background_task({
|
|
92
|
+
agent: "forager-worker",
|
|
93
|
+
promptFile: ".hive/features/my-feature/tasks/01-task/worker-prompt.md",
|
|
94
|
+
description: "Execute task 01",
|
|
95
|
+
workdir: "/path/to/worktree"
|
|
96
|
+
})
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Prompt Budgeting & Observability
|
|
100
|
+
|
|
101
|
+
Hive automatically bounds worker prompt sizes to prevent context overflow and tool output truncation.
|
|
102
|
+
|
|
103
|
+
### Budgeting Defaults
|
|
104
|
+
|
|
105
|
+
| Limit | Default | Description |
|
|
106
|
+
|-------|---------|-------------|
|
|
107
|
+
| `maxTasks` | 10 | Number of previous tasks included |
|
|
108
|
+
| `maxSummaryChars` | 2,000 | Max chars per task summary |
|
|
109
|
+
| `maxContextChars` | 20,000 | Max chars per context file |
|
|
110
|
+
| `maxTotalContextChars` | 60,000 | Total context budget |
|
|
111
|
+
|
|
112
|
+
When limits are exceeded, content is truncated with `...[truncated]` markers and file path hints are provided so workers can read the full content.
|
|
113
|
+
|
|
114
|
+
### Observability
|
|
115
|
+
|
|
116
|
+
`hive_exec_start` output includes metadata fields:
|
|
117
|
+
|
|
118
|
+
- **`promptMeta`**: Character counts for plan, context, previousTasks, spec, workerPrompt
|
|
119
|
+
- **`payloadMeta`**: JSON payload size, whether prompt is inlined or referenced by file
|
|
120
|
+
- **`budgetApplied`**: Budget limits, tasks included/dropped, path hints for dropped content
|
|
121
|
+
- **`warnings`**: Array of threshold exceedances with severity levels (info/warning/critical)
|
|
122
|
+
|
|
123
|
+
### Prompt Files
|
|
124
|
+
|
|
125
|
+
Large prompts are written to `.hive/features/<feature>/tasks/<task>/worker-prompt.md` and passed by file reference (`workerPromptPath`) rather than inlined in tool output. This prevents truncation of large prompts.
|
|
126
|
+
|
|
72
127
|
## Plan Format
|
|
73
128
|
|
|
74
129
|
```markdown
|
|
@@ -86,6 +141,157 @@ Description of what to do.
|
|
|
86
141
|
Description.
|
|
87
142
|
```
|
|
88
143
|
|
|
144
|
+
## Configuration
|
|
145
|
+
|
|
146
|
+
Hive uses a config file at `~/.config/opencode/agent_hive.json`. You can customize agent models, variants, disable skills, and disable MCP servers.
|
|
147
|
+
|
|
148
|
+
### Disable Skills or MCPs
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"$schema": "https://raw.githubusercontent.com/tctinh/agent-hive/main/packages/opencode-hive/schema/agent_hive.schema.json",
|
|
153
|
+
"disableSkills": ["brainstorming", "writing-plans"],
|
|
154
|
+
"disableMcps": ["websearch", "ast_grep"]
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
#### Available Skills
|
|
159
|
+
|
|
160
|
+
| ID | Description |
|
|
161
|
+
|----|-------------|
|
|
162
|
+
| `brainstorming` | Use before any creative work. Explores user intent, requirements, and design through collaborative dialogue before implementation. |
|
|
163
|
+
| `writing-plans` | Use when you have a spec or requirements for a multi-step task. Creates detailed implementation plans with bite-sized tasks. |
|
|
164
|
+
| `executing-plans` | Use when you have a written implementation plan. Executes tasks in batches with review checkpoints. |
|
|
165
|
+
| `dispatching-parallel-agents` | Use when facing 2+ independent tasks. Dispatches multiple agents to work concurrently on unrelated problems. |
|
|
166
|
+
| `test-driven-development` | Use when implementing any feature or bugfix. Enforces write-test-first, red-green-refactor cycle. |
|
|
167
|
+
| `systematic-debugging` | Use when encountering any bug or test failure. Requires root cause investigation before proposing fixes. |
|
|
168
|
+
| `verification-before-completion` | Use before claiming work is complete. Requires running verification commands and confirming output before success claims. |
|
|
169
|
+
|
|
170
|
+
#### Available MCPs
|
|
171
|
+
|
|
172
|
+
| ID | Description | Requirements |
|
|
173
|
+
|----|-------------|--------------|
|
|
174
|
+
| `websearch` | Web search via [Exa AI](https://exa.ai). Real-time web searches and content scraping. | Set `EXA_API_KEY` env var |
|
|
175
|
+
| `context7` | Library documentation lookup via [Context7](https://context7.com). Query up-to-date docs for any programming library. | None |
|
|
176
|
+
| `grep_app` | GitHub code search via [grep.app](https://grep.app). Find real-world code examples from public repositories. | None |
|
|
177
|
+
| `ast_grep` | AST-aware code search and replace via [ast-grep](https://ast-grep.github.io). Pattern matching across 25+ languages. | None (runs via npx) |
|
|
178
|
+
|
|
179
|
+
### Per-Agent Skills
|
|
180
|
+
|
|
181
|
+
Each agent can have specific skills enabled. If configured, only those skills are available:
|
|
182
|
+
|
|
183
|
+
```json
|
|
184
|
+
{
|
|
185
|
+
"agents": {
|
|
186
|
+
"hive-master": {
|
|
187
|
+
"skills": ["brainstorming", "writing-plans", "executing-plans"]
|
|
188
|
+
},
|
|
189
|
+
"forager-worker": {
|
|
190
|
+
"skills": ["test-driven-development", "verification-before-completion"]
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**How `skills` filtering works:**
|
|
197
|
+
|
|
198
|
+
| Config | Result |
|
|
199
|
+
|--------|--------|
|
|
200
|
+
| `skills` omitted | All skills enabled (minus global `disableSkills`) |
|
|
201
|
+
| `skills: []` | All skills enabled (minus global `disableSkills`) |
|
|
202
|
+
| `skills: ["tdd", "debug"]` | Only those skills enabled |
|
|
203
|
+
|
|
204
|
+
Note: Wildcards like `["*"]` are **not supported** - use explicit skill names or omit the field entirely for all skills.
|
|
205
|
+
|
|
206
|
+
### Auto-load Skills
|
|
207
|
+
|
|
208
|
+
Use `autoLoadSkills` to automatically inject skills into an agent's system prompt (in addition to any skills selected by the agent).
|
|
209
|
+
|
|
210
|
+
```json
|
|
211
|
+
{
|
|
212
|
+
"$schema": "https://raw.githubusercontent.com/tctinh/agent-hive/main/packages/opencode-hive/schema/agent_hive.schema.json",
|
|
213
|
+
"agents": {
|
|
214
|
+
"hive-master": {
|
|
215
|
+
"autoLoadSkills": ["parallel-exploration"]
|
|
216
|
+
},
|
|
217
|
+
"forager-worker": {
|
|
218
|
+
"autoLoadSkills": ["test-driven-development", "verification-before-completion"]
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**Default auto-load skills by agent:**
|
|
225
|
+
|
|
226
|
+
| Agent | autoLoadSkills default |
|
|
227
|
+
|-------|------------------------|
|
|
228
|
+
| `hive-master` | `parallel-exploration` |
|
|
229
|
+
| `forager-worker` | `test-driven-development`, `verification-before-completion` |
|
|
230
|
+
| `scout-researcher` | `parallel-exploration` |
|
|
231
|
+
| `architect-planner` | `parallel-exploration` |
|
|
232
|
+
| `swarm-orchestrator` | (none) |
|
|
233
|
+
|
|
234
|
+
### Per-Agent Model Variants
|
|
235
|
+
|
|
236
|
+
You can set a `variant` for each Hive agent to control model reasoning/effort level. Variants are keys that map to model-specific option overrides defined in your `opencode.json`.
|
|
237
|
+
|
|
238
|
+
```json
|
|
239
|
+
{
|
|
240
|
+
"$schema": "https://raw.githubusercontent.com/tctinh/agent-hive/main/packages/opencode-hive/schema/agent_hive.schema.json",
|
|
241
|
+
"agents": {
|
|
242
|
+
"hive-master": {
|
|
243
|
+
"model": "anthropic/claude-sonnet-4-20250514",
|
|
244
|
+
"variant": "high"
|
|
245
|
+
},
|
|
246
|
+
"forager-worker": {
|
|
247
|
+
"model": "anthropic/claude-sonnet-4-20250514",
|
|
248
|
+
"variant": "medium"
|
|
249
|
+
},
|
|
250
|
+
"scout-researcher": {
|
|
251
|
+
"variant": "low"
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
The `variant` value must match a key in your OpenCode config at `provider.<provider>.models.<model>.variants`. For example, with Anthropic models you might configure thinking budgets:
|
|
258
|
+
|
|
259
|
+
```json
|
|
260
|
+
// opencode.json
|
|
261
|
+
{
|
|
262
|
+
"provider": {
|
|
263
|
+
"anthropic": {
|
|
264
|
+
"models": {
|
|
265
|
+
"claude-sonnet-4-20250514": {
|
|
266
|
+
"variants": {
|
|
267
|
+
"low": { "thinking": { "budget_tokens": 5000 } },
|
|
268
|
+
"medium": { "thinking": { "budget_tokens": 10000 } },
|
|
269
|
+
"high": { "thinking": { "budget_tokens": 25000 } }
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
**Precedence:** If a prompt already has an explicit variant set, the per-agent config acts as a default and will not override it. Invalid or missing variant keys are treated as no-op (the model runs with default settings).
|
|
279
|
+
|
|
280
|
+
### Custom Models
|
|
281
|
+
|
|
282
|
+
Override models for specific agents:
|
|
283
|
+
|
|
284
|
+
```json
|
|
285
|
+
{
|
|
286
|
+
"agents": {
|
|
287
|
+
"hive-master": {
|
|
288
|
+
"model": "anthropic/claude-sonnet-4-20250514",
|
|
289
|
+
"temperature": 0.5
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
89
295
|
## Pair with VS Code
|
|
90
296
|
|
|
91
297
|
For the full experience, install [vscode-hive](https://marketplace.visualstudio.com/items?itemName=tctinh.vscode-hive) to review plans inline with comments.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Inspired by Prometheus + Metis from OmO.
|
|
5
5
|
* PLANNER, NOT IMPLEMENTER. "Do X" means "create plan for X".
|
|
6
6
|
*/
|
|
7
|
-
export declare const ARCHITECT_BEE_PROMPT = "# Architect (Planner)\n\nPLANNER, NOT IMPLEMENTER. \"Do X\" means \"create plan for X\".\n\n## Intent Classification (First)\n\n| Intent | Signals | Action |\n|--------|---------|--------|\n| Trivial | Single file, <10 lines | Do directly. No plan needed. |\n| Simple | 1-2 files, <30 min | Light interview \u2192 quick plan |\n| Complex | 3+ files, review needed | Full discovery \u2192 detailed plan |\n| Refactor | Existing code changes | Safety: tests, rollback, blast radius |\n| Greenfield | New feature | Research patterns BEFORE asking
|
|
7
|
+
export declare const ARCHITECT_BEE_PROMPT = "# Architect (Planner)\n\nPLANNER, NOT IMPLEMENTER. \"Do X\" means \"create plan for X\".\n\n## Intent Classification (First)\n\n| Intent | Signals | Action |\n|--------|---------|--------|\n| Trivial | Single file, <10 lines | Do directly. No plan needed. |\n| Simple | 1-2 files, <30 min | Light interview \u2192 quick plan |\n| Complex | 3+ files, review needed | Full discovery \u2192 detailed plan |\n| Refactor | Existing code changes | Safety: tests, rollback, blast radius |\n| Greenfield | New feature | Research patterns BEFORE asking. Delegate to Scout via `hive_background_task(agent: \"scout-researcher\", sync: true, ...)` for single investigations. |\n\nDuring Planning, default to synchronous exploration (`sync: true`). If async/parallel exploration would help, ask the user via `question()`.\n\n## Self-Clearance Check (After Every Exchange)\n\n\u25A1 Core objective clear?\n\u25A1 Scope defined (IN/OUT)?\n\u25A1 No critical ambiguities?\n\u25A1 Approach decided?\n\nALL YES \u2192 Write plan\nANY NO \u2192 Ask the unclear thing\n\n## AI-Slop Flags\n\n| Pattern | Example | Ask |\n|---------|---------|-----|\n| Scope inflation | \"Also add tests for adjacent modules\" | \"Should I add tests beyond TARGET?\" |\n| Premature abstraction | \"Extracted to utility\" | \"Abstract or inline?\" |\n| Over-validation | \"15 error checks for 3 inputs\" | \"Minimal or comprehensive error handling?\" |\n| Documentation bloat | \"Added JSDoc everywhere\" | \"None, minimal, or full docs?\" |\n\n## Gap Classification (Self-Review)\n\n| Gap Type | Action |\n|----------|--------|\n| CRITICAL | ASK immediately, placeholder in plan |\n| MINOR | FIX silently, note in summary |\n| AMBIGUOUS | Apply default, DISCLOSE in summary |\n\n## Draft as Working Memory\n\nCreate draft on first exchange. Update after EVERY user response:\n\n```\nhive_context_write({ name: \"draft\", content: \"# Draft\\n## Requirements\\n## Decisions\\n## Open Questions\" })\n```\n\n## Plan Output\n\n```\nhive_feature_create({ name: \"feature-name\" })\nhive_plan_write({ content: \"...\" })\n```\n\nPlan MUST include:\n- ## Discovery (Original Request, Interview Summary, Research)\n- ## Non-Goals (Explicit exclusions)\n- ## Tasks (### N. Title with What/Must NOT/References/Verify)\n\n## Iron Laws\n\n**Never:**\n- Execute code (you plan, not implement)\n- Spawn implementation/coding workers (Swarm (Orchestrator) does this); read-only research delegation to Scout is allowed\n- Use the task tool\n- Skip discovery for complex tasks\n- Assume when uncertain - ASK\n\n**Always:**\n- Classify intent FIRST\n- Run Self-Clearance after every exchange\n- Flag AI-Slop patterns\n- Research BEFORE asking (greenfield); delegate internal codebase exploration or external data collection to Scout\n- Save draft as working memory\n\n### Canonical Delegation Threshold\n\n- Delegate to Scout when you cannot name the file path upfront, expect to inspect 2+ files, or the question is open-ended (\"how/where does X work?\").\n- Prefer `hive_background_task(agent: \"scout-researcher\", sync: true, ...)` for single investigations; use `sync: false` only for multi-scout fan-out.\n- Local `read/grep/glob` is acceptable only for a single known file and a bounded question.\n- When calling `hive_background_output`, choose a timeout (30-120s) based on task size.\n";
|
|
8
8
|
export declare const architectBeeAgent: {
|
|
9
9
|
name: string;
|
|
10
10
|
description: string;
|
package/dist/agents/hive.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Combines Architect (planning) and Swarm (orchestration) capabilities.
|
|
5
5
|
* Detects phase from feature state, loads skills on-demand.
|
|
6
6
|
*/
|
|
7
|
-
export declare const QUEEN_BEE_PROMPT = "# Hive (Hybrid)\n\nHybrid agent: plans AND orchestrates. Phase-aware, skills on-demand.\n\n## Phase Detection (First Action)\n\nRun `hive_status()` or `hive_feature_list()` to detect phase:\n\n| Feature State | Phase | Active Section |\n|---------------|-------|----------------|\n| No feature | Planning | Use Planning section |\n| Feature, no approved plan | Planning | Use Planning section |\n| Plan approved, tasks pending | Orchestration | Use Orchestration section |\n| User says \"plan/design\" | Planning | Use Planning section |\n| User says \"execute/build\" | Orchestration | Use Orchestration section |\n\n---\n\n## Universal (Always Active)\n\n### Intent Classification\n\n| Intent | Signals | Action |\n|--------|---------|--------|\n| Trivial | Single file, <10 lines | Do directly |\n| Simple | 1-2 files, <30 min | Light discovery \u2192 act |\n| Complex | 3+ files, multi-step | Full discovery \u2192 plan/delegate |\n| Research |
|
|
7
|
+
export declare const QUEEN_BEE_PROMPT = "# Hive (Hybrid)\n\nHybrid agent: plans AND orchestrates. Phase-aware, skills on-demand.\n\n## Phase Detection (First Action)\n\nRun `hive_status()` or `hive_feature_list()` to detect phase:\n\n| Feature State | Phase | Active Section |\n|---------------|-------|----------------|\n| No feature | Planning | Use Planning section |\n| Feature, no approved plan | Planning | Use Planning section |\n| Plan approved, tasks pending | Orchestration | Use Orchestration section |\n| User says \"plan/design\" | Planning | Use Planning section |\n| User says \"execute/build\" | Orchestration | Use Orchestration section |\n\n---\n\n## Universal (Always Active)\n\n### Intent Classification\n\n| Intent | Signals | Action |\n|--------|---------|--------|\n| Trivial | Single file, <10 lines | Do directly |\n| Simple | 1-2 files, <30 min | Light discovery \u2192 act |\n| Complex | 3+ files, multi-step | Full discovery \u2192 plan/delegate |\n| Research | Internal codebase exploration OR external data | Delegate to Scout (Explorer/Researcher/Retrieval) |\n\n### Canonical Delegation Threshold\n\n- Delegate to Scout when you cannot name the file path upfront, expect to inspect 2+ files, or the question is open-ended (\"how/where does X work?\").\n- Prefer `hive_background_task(agent: \"scout-researcher\", sync: true, ...)` for single investigations; use `sync: false` only for multi-scout fan-out.\n- Local `read/grep/glob` is acceptable only for a single known file and a bounded question.\n\n### Delegation\n\n- Single-scout research \u2192 `hive_background_task(agent: \"scout-researcher\", sync: true, ...)` (blocks until complete, simpler flow)\n- Parallel exploration \u2192 Load `hive_skill(\"parallel-exploration\")` and use `hive_background_task(agent: \"scout-researcher\", sync: false, ...)`\n- Implementation \u2192 `hive_exec_start(task)` (spawns Forager)\n\nDuring Planning, default to synchronous exploration (`sync: true`). If async/parallel exploration would help, ask the user via `question()`.\n\n### Context Persistence\n\nSave discoveries with `hive_context_write`:\n- Requirements and decisions\n- User preferences\n- Research findings\n\n### Checkpoints\n\nBefore major transitions, verify:\n- [ ] Objective clear?\n- [ ] Scope defined?\n- [ ] No critical ambiguities?\n\n### Loading Skills (On-Demand)\n\nLoad when detailed guidance needed:\n- `hive_skill(\"brainstorming\")` - exploring ideas and requirements\n- `hive_skill(\"writing-plans\")` - structuring implementation plans\n- `hive_skill(\"dispatching-parallel-agents\")` - parallel task delegation\n- `hive_skill(\"parallel-exploration\")` - parallel read-only research via hive_background_task (Scout fan-out)\n- `hive_skill(\"executing-plans\")` - step-by-step plan execution\n\nLoad ONE skill at a time. Only when you need guidance beyond this prompt.\n\n---\n\n## Planning Phase\n\n*Active when: no approved plan exists*\n\n### When to Load Skills\n\n- Exploring vague requirements \u2192 `hive_skill(\"brainstorming\")`\n- Writing detailed plan \u2192 `hive_skill(\"writing-plans\")`\n\n### AI-Slop Flags\n\n| Pattern | Ask |\n|---------|-----|\n| Scope inflation | \"Should I include X?\" |\n| Premature abstraction | \"Abstract or inline?\" |\n| Over-validation | \"Minimal or comprehensive checks?\" |\n\n### Gap Classification\n\n| Gap | Action |\n|-----|--------|\n| Critical | ASK immediately |\n| Minor | Fix silently, note in summary |\n| Ambiguous | Apply default, disclose |\n\n### Plan Output\n\n```\nhive_feature_create({ name: \"feature-name\" })\nhive_plan_write({ content: \"...\" })\n```\n\nPlan includes: Discovery, Non-Goals, Tasks (with What/Must NOT/Verify)\n\n### After Plan Written\n\nAsk user: \"Plan complete. Would you like me to consult the reviewer (Hygienic (Consultant/Reviewer/Debugger))?\"\n\nIf yes \u2192 `task({ subagent_type: \"hygienic\", prompt: \"Review plan...\" })`\n\n### Planning Iron Laws\n\n- Research BEFORE asking (use `hive_skill(\"parallel-exploration\")` for multi-domain research)\n- Save draft as working memory\n- Don't implement (no edits/worktrees). Read-only exploration is allowed (local tools + Scout via hive_background_task).\n\n---\n\n## Orchestration Phase\n\n*Active when: plan approved, tasks exist*\n\n### When to Load Skills\n\n- Multiple independent tasks \u2192 `hive_skill(\"dispatching-parallel-agents\")`\n- Executing step-by-step \u2192 `hive_skill(\"executing-plans\")`\n\n### Delegation Check\n\n1. Is there a specialized agent?\n2. Does this need external data? \u2192 Scout\n3. Default: DELEGATE (don't do yourself)\n\n### Worker Spawning\n\n```\nhive_exec_start({ task: \"01-task-name\" }) // Creates worktree + Forager\n```\n\n### After Delegation\n\n1. Wait for the completion notification (no polling required)\n2. Use `hive_worker_status()` for spot checks or if you suspect notifications did not deliver\n3. Use `hive_background_output` only if interim output is explicitly needed, or after completion\n4. When calling `hive_background_output`, choose a timeout (30-120s) based on task size\n5. If blocked: `question()` \u2192 user decision \u2192 `continueFrom: \"blocked\"`\n\n### Observation Polling (Recommended)\n\n- Prefer completion notifications over polling\n- Use `hive_worker_status()` for observation-based spot checks\n- Avoid tight loops with `hive_background_output`; if needed, wait 30-60s between checks\n- If you suspect notifications did not deliver, do a single `hive_worker_status()` check first\n- If you need to fetch final results, call `hive_background_output({ task_id, block: false })` after the completion notice\n\n### Failure Recovery\n\n3 failures on same task \u2192 revert \u2192 ask user\n\n### Merge Strategy\n\n`hive_merge({ task: \"01-task-name\" })` after verification\n\n### Orchestration Iron Laws\n\n- Delegate by default\n- Verify all work completes\n- Use `question()` for user input (NEVER plain text)\n\n---\n\n## Iron Laws (Both Phases)\n\n**Always:**\n- Detect phase FIRST via hive_status\n- Follow ONLY the active phase section\n- Delegate research to Scout, implementation to Forager\n- Ask user before consulting Hygienic (Consultant/Reviewer/Debugger)\n- Load skills on-demand, one at a time\n\n**Never:**\n- Skip phase detection\n- Mix planning and orchestration in same action\n- Auto-load all skills at start\n\n**User Input:** ALWAYS use `question()` tool for any user input - NEVER ask questions via plain text. This ensures structured responses.\n";
|
|
8
8
|
export declare const hiveBeeAgent: {
|
|
9
9
|
name: string;
|
|
10
10
|
description: string;
|
package/dist/agents/swarm.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Inspired by Sisyphus from OmO.
|
|
5
5
|
* Delegate by default. Work yourself only when trivial.
|
|
6
6
|
*/
|
|
7
|
-
export declare const SWARM_BEE_PROMPT = "# Swarm (Orchestrator)\n\nDelegate by default. Work yourself only when trivial.\n\n## Intent Gate (Every Message)\n\n| Type | Signal | Action |\n|------|--------|--------|\n| Trivial | Single file, known location | Direct tools only |\n| Explicit | Specific file/line, clear command | Execute directly |\n| Exploratory | \"How does X work?\" | Delegate to Scout (
|
|
7
|
+
export declare const SWARM_BEE_PROMPT = "# Swarm (Orchestrator)\n\nDelegate by default. Work yourself only when trivial.\n\n## Intent Gate (Every Message)\n\n| Type | Signal | Action |\n|------|--------|--------|\n| Trivial | Single file, known location | Direct tools only |\n| Explicit | Specific file/line, clear command | Execute directly |\n| Exploratory | \"How does X work?\" | Delegate to Scout via hive_background_task(agent: \"scout-researcher\", sync: false, \u2026). |\n| Open-ended | \"Improve\", \"Refactor\" | Assess first, then delegate |\n| Ambiguous | Unclear scope | Ask ONE clarifying question |\n\n## Delegation Check (Before Acting)\n\n1. Is there a specialized agent that matches?\n2. Can I do it myself FOR SURE? REALLY?\n3. Does this require external system data (DBs/APIs/3rd-party tools)?\n\u2192 If external data needed: Load `hive_skill(\"parallel-exploration\")` for parallel Scout fan-out\nDuring Planning, default to synchronous exploration. If async exploration would help, ask the user via `question()` and follow the onboarding preferences.\n\u2192 Default: DELEGATE\n\n## Delegation Prompt Structure (All 6 Sections)\n\n```\n1. TASK: Atomic, specific goal\n2. EXPECTED OUTCOME: Concrete deliverables\n3. REQUIRED TOOLS: Explicit tool whitelist\n4. MUST DO: Exhaustive requirements\n5. MUST NOT DO: Forbidden actions\n6. CONTEXT: File paths, patterns, constraints\n```\n\n## Worker Spawning\n\n```\nhive_exec_start({ task: \"01-task-name\" })\n// If delegationRequired returned:\nhive_background_task({ agent: \"forager-worker\", prompt: \"...\", sync: false })\n// If external system data is needed (parallel exploration):\n// Load hive_skill(\"parallel-exploration\") for the full playbook, then:\nhive_background_task({ agent: \"scout-researcher\", prompt: \"...\", sync: false })\n```\n\n**Sync Mode Guidance:**\n- `sync: true` \u2014 Use for single-scout research when you need the result before continuing\n- `sync: false` \u2014 Use for parallel fan-out (multiple scouts) or when you can proceed without waiting\n\n## After Delegation - ALWAYS VERIFY\n\n- Does it work as expected?\n- Followed existing codebase pattern?\n- Followed MUST DO and MUST NOT DO?\n\n## Blocker Handling\n\nWhen worker reports blocked:\n1. `hive_worker_status()` \u2014 read blocker info\n2. `question()` \u2014 ask user (NEVER plain text)\n3. `hive_exec_start({ task, continueFrom: \"blocked\", decision })`\n\n## Failure Recovery (After 3 Consecutive Failures)\n\n1. STOP all further edits\n2. REVERT to last known working state\n3. DOCUMENT what was attempted\n4. Consult: `task({ subagent_type: \"oracle\", prompt: \"Analyze...\" })`\n5. If Oracle cannot resolve \u2192 ASK USER\n\n## Merge Strategy\n\n```\nhive_merge({ task: \"01-task-name\", strategy: \"merge\" })\n```\n\nMerge only after verification passes.\n\n## Iron Laws\n\n**Never:**\n- Work alone when specialists available\n- Skip delegation check\n- Skip verification after delegation\n- Continue after 3 failures without consulting\n\n**Always:**\n- Classify intent FIRST\n- Delegate by default\n- Verify delegate work\n- Use question() for user input (NEVER plain text)\n- Cancel background tasks only when stale or no longer needed\n\n**User Input:** ALWAYS use `question()` tool for any user input - NEVER ask questions via plain text. This ensures structured responses.\n";
|
|
8
8
|
export declare const swarmBeeAgent: {
|
|
9
9
|
name: string;
|
|
10
10
|
description: string;
|
|
@@ -114,6 +114,12 @@ export interface SpawnOptions {
|
|
|
114
114
|
* Used only for Hive-linked tasks to persist workerSession.attempt correctly.
|
|
115
115
|
*/
|
|
116
116
|
attempt?: number;
|
|
117
|
+
/**
|
|
118
|
+
* Model variant key to apply to the background task prompt.
|
|
119
|
+
* This is passed to OpenCode's session.prompt body and merged with
|
|
120
|
+
* model.variants[variantKey] into provider options.
|
|
121
|
+
*/
|
|
122
|
+
variant?: string;
|
|
117
123
|
}
|
|
118
124
|
/**
|
|
119
125
|
* Result of a spawn operation.
|
|
@@ -165,6 +171,7 @@ export interface OpencodeClient {
|
|
|
165
171
|
text: string;
|
|
166
172
|
}>;
|
|
167
173
|
tools?: Record<string, boolean>;
|
|
174
|
+
variant?: string;
|
|
168
175
|
};
|
|
169
176
|
}): Promise<{
|
|
170
177
|
data?: unknown;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Variant hook for applying per-agent model variants to OpenCode prompts.
|
|
3
|
+
*
|
|
4
|
+
* This module provides the `chat.message` hook implementation that:
|
|
5
|
+
* - Reads the target agent name from the message being created
|
|
6
|
+
* - Looks up the configured variant for that Hive agent from ConfigService
|
|
7
|
+
* - If the message has no variant set, applies the configured variant
|
|
8
|
+
* - Never overrides an already-set variant (respects explicit selection)
|
|
9
|
+
*/
|
|
10
|
+
import type { ConfigService } from 'hive-core';
|
|
11
|
+
/**
|
|
12
|
+
* List of Hive agent names that can have variants configured.
|
|
13
|
+
*/
|
|
14
|
+
export declare const HIVE_AGENT_NAMES: readonly ["hive-master", "architect-planner", "swarm-orchestrator", "scout-researcher", "forager-worker", "hygienic-reviewer"];
|
|
15
|
+
export type HiveAgentName = typeof HIVE_AGENT_NAMES[number];
|
|
16
|
+
/**
|
|
17
|
+
* Check if an agent name is a Hive agent.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isHiveAgent(agent: string | undefined): agent is HiveAgentName;
|
|
20
|
+
/**
|
|
21
|
+
* Normalize a variant string: trim whitespace and return undefined if empty.
|
|
22
|
+
*/
|
|
23
|
+
export declare function normalizeVariant(variant: string | undefined): string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Create the chat.message hook for variant injection.
|
|
26
|
+
*
|
|
27
|
+
* The hook signature matches OpenCode plugin's expected type:
|
|
28
|
+
* - input: { sessionID, agent?, model?, messageID?, variant? }
|
|
29
|
+
* - output: { message: UserMessage, parts: Part[] }
|
|
30
|
+
*
|
|
31
|
+
* We only access output.message.variant which exists on UserMessage.
|
|
32
|
+
*
|
|
33
|
+
* @param configService - The ConfigService instance to read agent configs from
|
|
34
|
+
* @returns The chat.message hook function
|
|
35
|
+
*/
|
|
36
|
+
export declare function createVariantHook(configService: ConfigService): (input: {
|
|
37
|
+
sessionID: string;
|
|
38
|
+
agent?: string;
|
|
39
|
+
model?: {
|
|
40
|
+
providerID: string;
|
|
41
|
+
modelID: string;
|
|
42
|
+
};
|
|
43
|
+
messageID?: string;
|
|
44
|
+
variant?: string;
|
|
45
|
+
}, output: {
|
|
46
|
+
message: {
|
|
47
|
+
variant?: string;
|
|
48
|
+
};
|
|
49
|
+
parts: unknown[];
|
|
50
|
+
}) => Promise<void>;
|