Hive is an OpenCode plugin that automatically discovers project domains (frontend, backend, infra, etc.), creates per-domain AI agents at startup, and enables them to coordinate via a custom EventBus โ with fully autonomous code modification capabilities.
Startup โ Scan project โ Discover domains โ Create per-domain Agents + Queen โ EventBus coordination โ Autonomous execution
- Domain Discovery: Static project scanning + LLM enrichment + user config merge
- EventBus: Pub/sub event system for agent-to-agent communication
- Queen Coordinator: Broadcasts requirements, negotiates interfaces, dispatches parallel tasks
- Autonomous Execution: Domain agents can self-adapt to breaking changes from dependencies
In .opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": [
"./plugins/hive/index.ts"
]
}@queen Implement user authentication with JWT and role-based access controlThe Queen agent will:
- Broadcast the requirement to relevant domain agents
- Negotiate interfaces between domains (e.g., auth โ API โ frontend)
- Dispatch parallel tasks to domain agents
- Monitor progress and handle conflicts
Create .opencode/hive.json in your project root:
{
"domains": {
"frontend": {
"name": "Frontend",
"paths": ["src/ui/**", "src/components/**"],
"techStack": "React, TypeScript",
"responsibilities": "User interface, component library",
"disabled": false
},
"backend": {
"name": "Backend",
"paths": ["src/api/**", "src/services/**"],
"techStack": "Node.js, Express",
"responsibilities": "API endpoints, business logic"
}
},
"discovery": {
"model": "anthropic/claude-sonnet-4-20250514",
"autoRefresh": true
},
"coordination": {
"autonomyLevel": "full"
},
"queen": {
"model": "anthropic/claude-sonnet-4-20250514"
},
"store": {
"dataDir": ".hive"
}
}User-defined domain configurations. These override/extend auto-discovered domains.
| Field | Type | Required | Description |
|---|---|---|---|
id |
string |
Auto | Unique domain identifier (e.g., "frontend", "backend") |
name |
string |
Yes | Human-readable domain name |
description |
string |
No | Domain purpose description |
paths |
string[] |
Yes | Glob patterns matching domain source files |
techStack |
string |
No | Technology stack (e.g., "React, TypeScript") |
responsibilities |
string |
No | What this domain is responsible for |
interfaces |
string[] |
No | API contracts exposed to other domains |
dependencies |
string[] |
No | IDs of domains this domain depends on |
conventions |
string[] |
No | Coding conventions to follow |
disabled |
boolean |
No | If true, this domain won't get an agent |
Example:
{
"domains": {
"auth": {
"name": "Authentication",
"paths": ["src/auth/**", "src/middleware/auth.ts"],
"techStack": "Node.js, JWT",
"responsibilities": "User authentication, token management",
"interfaces": ["login(email, password)", "verifyToken(token)", "refreshToken(token)"],
"dependencies": ["database"],
"conventions": ["Use bcrypt for password hashing", "JWT expires in 24h"]
}
}
}Controls how domains are auto-discovered from project structure.
| Field | Type | Default | Description |
|---|---|---|---|
model |
string |
anthropic/claude-sonnet-4-20250514 |
LLM model used for analyzing project structure and enriching domain metadata |
autoRefresh |
boolean |
true |
Whether to re-discover domains when project structure changes (file watcher) |
Example:
{
"discovery": {
"model": "anthropic/claude-sonnet-4-20250514",
"autoRefresh": false
}
}model: Set to a different model if you want faster/cheaper analysis. Must be supported by your LLM provider.autoRefresh: Set tofalseif you want manual control over domain discovery. Usehive_statustool to trigger re-discovery.
Controls how domain agents coordinate and their autonomy level.
| Field | Type | Default | Description |
|---|---|---|---|
autonomyLevel |
string |
"full" |
Agent autonomy: "passive" | "propose" | "full" |
Autonomy Levels:
| Level | Behavior |
|---|---|
passive |
Agents only respond to Queen commands. Never initiate actions. |
propose |
Agents can propose changes but must get Queen approval before executing. |
full |
Agents can autonomously execute changes when notified of breaking changes or dependency updates. |
Example:
{
"coordination": {
"autonomyLevel": "propose"
}
}Controls the Queen coordinator agent.
| Field | Type | Default | Description |
|---|---|---|---|
model |
string |
anthropic/claude-sonnet-4-20250514 |
LLM model used for Queen agent reasoning |
Example:
{
"queen": {
"model": "anthropic/claude-sonnet-4-20250514"
}
}Controls persistence settings.
| Field | Type | Default | Description |
|---|---|---|---|
dataDir |
string |
.hive |
Directory for storing discovery cache, event history, and agent state |
Example:
{
"store": {
"dataDir": ".hive"
}
}Hive provides several tools for interacting with the plugin:
Emit a custom event to the EventBus.
hive_emit --type task_started --source frontend --target backend --message "Started implementing login form"
| Parameter | Required | Description |
|---|---|---|
--type |
Yes | Event type (see Event Types below) |
--source |
Yes | Source domain ID or "system" |
--target |
Yes | Target domain ID or "*" (broadcast) |
--message |
Yes | Event message |
--data |
No | Additional JSON data |
Show current Hive status (discovered domains, Queen status, recent events).
hive_status
Broadcast a requirement to all relevant domain agents.
hive_broadcast --message "Add OAuth2 login"
| Parameter | Required | Description |
|---|---|---|
--message |
Yes | Requirement description |
--target |
No | Specific domain to target (default: all) |
Initiate interface negotiation between domains.
hive_negotiate --domain1 frontend --domain2 backend --topic "auth API"
| Parameter | Required | Description |
|---|---|---|
--domain1 |
Yes | First domain ID |
--domain2 |
Yes | Second domain ID |
--topic |
Yes | Negotiation topic |
Dispatch parallel tasks to domain agents.
hive_dispatch --tasks "frontend:implement login UI" "backend:implement auth API"
| Parameter | Required | Description |
|---|---|---|
--tasks |
Yes | Array of "domainId:task" pairs |
Hive uses an EventBus for agent-to-agent communication. Supported event types:
| Event | Description |
|---|---|
requirement_broadcast |
Queen broadcasts a new requirement |
relevance_response |
Domain responds to relevance check |
interface_proposal |
Domain proposes an interface contract |
interface_accepted |
Interface proposal accepted |
interface_rejected |
Interface proposal rejected |
task_started |
Domain started a task |
task_completed |
Domain completed a task |
task_failed |
Domain task failed |
file_changed |
File change detected |
breaking_change |
Breaking change detected |
dependency_updated |
Dependency updated |
action_proposed |
Action proposed (for propose autonomy) |
action_completed |
Action completed |
help_request |
Domain requests help |
conflict_detected |
Conflict detected between domains |
info |
General info |
When autonomyLevel is set to "full", Hive can automatically respond to breaking changes:
- File watcher detects
breaking_changeordependency_updatedevent - Plugin creates a new session for affected domain agent
- Agent analyzes the change and proposes fixes
- Agent autonomously executes changes
This enables self-healing codebases where domain agents can adapt to changes in their dependencies without manual intervention.
.opencode/
โโโ opencode.json # Plugin registration
โโโ hive.json # Hive configuration (this file)
โโโ plugins/
โโโ hive/
โโโ index.ts # Plugin entry point
โโโ types.ts # Type definitions
โโโ config.ts # Config loader
โโโ store.ts # JSON persistence
โโโ discovery/ # Domain discovery
โ โโโ scanner.ts # Static project scanning
โ โโโ cache.ts # Discovery cache
โ โโโ analyzer.ts # LLM-powered analysis
โ โโโ merger.ts # User config merge
โโโ agents/ # Agent generation
โ โโโ generator.ts # Domain โ AgentConfig
โ โโโ prompts.ts # Prompt templates
โโโ eventbus/ # Event system
โ โโโ bus.ts # Pub/sub implementation
โโโ tools/ # CLI tools
โ โโโ emit.ts # hive_emit
โ โโโ status.ts # hive_status
โ โโโ broadcast.ts # hive_broadcast
โ โโโ negotiate.ts # hive_negotiate
โ โโโ dispatch.ts # hive_dispatch
โโโ hooks/ # Plugin hooks
โโโ config.ts # Dynamic registration
โโโ system-transform.ts
โโโ file-watcher.ts
โโโ autonomy.ts # Autonomous response
{
"domains": {
"frontend": {
"name": "Frontend",
"paths": ["src/**"]
}
}
}{
"domains": {
"frontend": {
"name": "Frontend Application",
"description": "Main web UI built with React",
"paths": ["src/ui/**", "src/components/**", "src/pages/**"],
"techStack": "React 18, TypeScript, TailwindCSS",
"responsibilities": "User interface, routing, state management",
"interfaces": ["useAuth()", "ApiClient"],
"dependencies": ["api", "shared"],
"conventions": ["Use functional components", "Follow atomic design"]
},
"api": {
"name": "API Server",
"description": "REST API built with Express",
"paths": ["src/api/**", "src/controllers/**", "src/middleware/**"],
"techStack": "Node.js, Express, PostgreSQL",
"responsibilities": "API endpoints, authentication, data validation",
"interfaces": ["POST /auth/login", "POST /auth/register", "GET /users/:id"],
"dependencies": ["database", "auth"],
"conventions": ["RESTful URL patterns", "Use async/await"]
},
"database": {
"name": "Database Layer",
"description": "Database models and migrations",
"paths": ["src/db/**", "src/models/**", "migrations/**"],
"techStack": "PostgreSQL, Prisma",
"responsibilities": "Data modeling, migrations, queries",
"interfaces": ["User model", "Session model"],
"conventions": ["Use Prisma ORM", "Soft deletes"]
},
"auth": {
"name": "Authentication",
"description": "Auth logic shared across layers",
"paths": ["src/auth/**", "src/middleware/auth.ts"],
"techStack": "JWT, bcrypt",
"responsibilities": "Password hashing, token generation, validation",
"interfaces": ["verifyToken(token)", "hashPassword(password)", "comparePassword(input, hash)"],
"dependencies": ["database"],
"conventions": ["bcrypt cost 12", "JWT expires 24h"]
},
"shared": {
"name": "Shared Utilities",
"description": "Shared types and utilities",
"paths": ["src/shared/**", "src/types/**"],
"techStack": "TypeScript",
"responsibilities": "Shared types, utilities, constants",
"interfaces": ["User type", "ApiResponse type", "error types"],
"conventions": [" barrel exports", "use const assertions"]
}
},
"discovery": {
"model": "anthropic/claude-sonnet-4-20250514",
"autoRefresh": true
},
"coordination": {
"autonomyLevel": "full"
},
"queen": {
"model": "anthropic/claude-sonnet-4-20250514"
},
"store": {
"dataDir": ".hive"
}
}- Check that your
pathsglobs match actual files - Ensure
discovery.autoRefreshis notfalse - Run
hive_statusto see discovered domains
- Check
queen.modelis set to a valid model - Verify autonomy level in
coordination.autonomyLevel
- Ensure target domain IDs are correct
- Check
autonomyLevelsettings