@hung319/opencode-hive 1.3.1
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 +383 -0
- package/dist/agents/architect.d.ts +12 -0
- package/dist/agents/custom-agents.d.ts +18 -0
- package/dist/agents/forager.d.ts +12 -0
- package/dist/agents/hive.d.ts +12 -0
- package/dist/agents/hygienic.d.ts +12 -0
- package/dist/agents/index.d.ts +60 -0
- package/dist/agents/scout.d.ts +6 -0
- package/dist/agents/swarm.d.ts +12 -0
- package/dist/hooks/system-hook.d.ts +8 -0
- package/dist/hooks/variant-hook.d.ts +17 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +24654 -0
- package/dist/mcp/ast-grep.d.ts +2 -0
- package/dist/mcp/context7.d.ts +2 -0
- package/dist/mcp/grep-app.d.ts +2 -0
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/types.d.ts +12 -0
- package/dist/mcp/websearch.d.ts +2 -0
- package/dist/skills/builtin.d.ts +38 -0
- package/dist/skills/file-loader.d.ts +22 -0
- package/dist/skills/index.d.ts +8 -0
- package/dist/skills/registry.generated.d.ts +14 -0
- package/dist/skills/types.d.ts +29 -0
- package/dist/utils/compaction-prompt.d.ts +1 -0
- 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 +43 -0
- package/package.json +60 -0
- package/skills/agents-md-mastery/SKILL.md +252 -0
- package/skills/brainstorming/SKILL.md +53 -0
- package/skills/code-reviewer/SKILL.md +208 -0
- package/skills/dispatching-parallel-agents/SKILL.md +200 -0
- package/skills/docker-mastery/SKILL.md +346 -0
- package/skills/executing-plans/SKILL.md +92 -0
- package/skills/parallel-exploration/SKILL.md +240 -0
- package/skills/systematic-debugging/SKILL.md +296 -0
- package/skills/test-driven-development/SKILL.md +371 -0
- package/skills/verification-before-completion/SKILL.md +139 -0
- package/skills/writing-plans/SKILL.md +148 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dispatching-parallel-agents
|
|
3
|
+
description: Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Dispatching Parallel Agents
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
When you have multiple unrelated failures (different test files, different subsystems, different bugs), investigating them sequentially wastes time. Each investigation is independent and can happen in parallel.
|
|
11
|
+
|
|
12
|
+
**Core principle:** Dispatch one agent per independent problem domain. Let them work concurrently.
|
|
13
|
+
|
|
14
|
+
## Prerequisite: Check Runnable Tasks
|
|
15
|
+
|
|
16
|
+
Before dispatching, use `hive_status()` to get the **runnable** list — tasks whose dependencies are all satisfied.
|
|
17
|
+
|
|
18
|
+
**Only dispatch tasks that are runnable.** Never start tasks with unmet dependencies.
|
|
19
|
+
|
|
20
|
+
Only `done` satisfies dependencies (not `blocked`, `failed`, `partial`, `cancelled`).
|
|
21
|
+
|
|
22
|
+
**Ask the operator first:**
|
|
23
|
+
- Use `question()`: "These tasks are runnable and independent: [list]. Execute in parallel?"
|
|
24
|
+
- Record the decision with `hive_context_write({ name: "execution-decisions", content: "..." })`
|
|
25
|
+
- Proceed only after operator approval
|
|
26
|
+
|
|
27
|
+
## When to Use
|
|
28
|
+
|
|
29
|
+
```dot
|
|
30
|
+
digraph when_to_use {
|
|
31
|
+
"Multiple failures?" [shape=diamond];
|
|
32
|
+
"Are they independent?" [shape=diamond];
|
|
33
|
+
"Single agent investigates all" [shape=box];
|
|
34
|
+
"One agent per problem domain" [shape=box];
|
|
35
|
+
"Can they work in parallel?" [shape=diamond];
|
|
36
|
+
"Sequential agents" [shape=box];
|
|
37
|
+
"Parallel dispatch" [shape=box];
|
|
38
|
+
|
|
39
|
+
"Multiple failures?" -> "Are they independent?" [label="yes"];
|
|
40
|
+
"Are they independent?" -> "Single agent investigates all" [label="no - related"];
|
|
41
|
+
"Are they independent?" -> "Can they work in parallel?" [label="yes"];
|
|
42
|
+
"Can they work in parallel?" -> "Parallel dispatch" [label="yes"];
|
|
43
|
+
"Can they work in parallel?" -> "Sequential agents" [label="no - shared state"];
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Use when:**
|
|
48
|
+
- 3+ test files failing with different root causes
|
|
49
|
+
- Multiple subsystems broken independently
|
|
50
|
+
- Each problem can be understood without context from others
|
|
51
|
+
- No shared state between investigations
|
|
52
|
+
|
|
53
|
+
**Don't use when:**
|
|
54
|
+
- Failures are related (fix one might fix others)
|
|
55
|
+
- Need to understand full system state
|
|
56
|
+
- Agents would interfere with each other
|
|
57
|
+
|
|
58
|
+
## The Pattern
|
|
59
|
+
|
|
60
|
+
### 1. Identify Independent Domains
|
|
61
|
+
|
|
62
|
+
Group failures by what's broken:
|
|
63
|
+
- File A tests: Tool approval flow
|
|
64
|
+
- File B tests: Batch completion behavior
|
|
65
|
+
- File C tests: Abort functionality
|
|
66
|
+
|
|
67
|
+
Each domain is independent - fixing tool approval doesn't affect abort tests.
|
|
68
|
+
|
|
69
|
+
### 2. Create Focused Agent Tasks
|
|
70
|
+
|
|
71
|
+
Each agent gets:
|
|
72
|
+
- **Specific scope:** One test file or subsystem
|
|
73
|
+
- **Clear goal:** Make these tests pass
|
|
74
|
+
- **Constraints:** Don't change other code
|
|
75
|
+
- **Expected output:** Summary of what you found and fixed
|
|
76
|
+
|
|
77
|
+
### 3. Dispatch in Parallel
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
// Using Hive tools for parallel execution
|
|
81
|
+
hive_worktree_start({ task: "01-fix-abort-tests" })
|
|
82
|
+
hive_worktree_start({ task: "02-fix-batch-tests" })
|
|
83
|
+
hive_worktree_start({ task: "03-fix-race-condition-tests" })
|
|
84
|
+
// All three run concurrently in isolated worktrees
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Parallelize by issuing multiple task() calls in the same assistant message.
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
task({ subagent_type: 'scout-researcher', prompt: 'Investigate failure A' })
|
|
91
|
+
task({ subagent_type: 'scout-researcher', prompt: 'Investigate failure B' })
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 4. Review and Integrate
|
|
95
|
+
|
|
96
|
+
When agents return:
|
|
97
|
+
- Read each summary
|
|
98
|
+
- Verify fixes don't conflict
|
|
99
|
+
- Run full test suite
|
|
100
|
+
- Integrate all changes with `hive_merge`
|
|
101
|
+
|
|
102
|
+
## Agent Prompt Structure
|
|
103
|
+
|
|
104
|
+
Good agent prompts are:
|
|
105
|
+
1. **Focused** - One clear problem domain
|
|
106
|
+
2. **Self-contained** - All context needed to understand the problem
|
|
107
|
+
3. **Specific about output** - What should the agent return?
|
|
108
|
+
|
|
109
|
+
```markdown
|
|
110
|
+
Fix the 3 failing tests in src/agents/agent-tool-abort.test.ts:
|
|
111
|
+
|
|
112
|
+
1. "should abort tool with partial output capture" - expects 'interrupted at' in message
|
|
113
|
+
2. "should handle mixed completed and aborted tools" - fast tool aborted instead of completed
|
|
114
|
+
3. "should properly track pendingToolCount" - expects 3 results but gets 0
|
|
115
|
+
|
|
116
|
+
These are timing/race condition issues. Your task:
|
|
117
|
+
|
|
118
|
+
1. Read the test file and understand what each test verifies
|
|
119
|
+
2. Identify root cause - timing issues or actual bugs?
|
|
120
|
+
3. Fix by:
|
|
121
|
+
- Replacing arbitrary timeouts with event-based waiting
|
|
122
|
+
- Fixing bugs in abort implementation if found
|
|
123
|
+
- Adjusting test expectations if testing changed behavior
|
|
124
|
+
|
|
125
|
+
Do NOT just increase timeouts - find the real issue.
|
|
126
|
+
|
|
127
|
+
Return: Summary of what you found and what you fixed.
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Common Mistakes
|
|
131
|
+
|
|
132
|
+
**❌ Too broad:** "Fix all the tests" - agent gets lost
|
|
133
|
+
**✅ Specific:** "Fix agent-tool-abort.test.ts" - focused scope
|
|
134
|
+
|
|
135
|
+
**❌ No context:** "Fix the race condition" - agent doesn't know where
|
|
136
|
+
**✅ Context:** Paste the error messages and test names
|
|
137
|
+
|
|
138
|
+
**❌ No constraints:** Agent might refactor everything
|
|
139
|
+
**✅ Constraints:** "Do NOT change production code" or "Fix tests only"
|
|
140
|
+
|
|
141
|
+
**❌ Vague output:** "Fix it" - you don't know what changed
|
|
142
|
+
**✅ Specific:** "Return summary of root cause and changes"
|
|
143
|
+
|
|
144
|
+
## When NOT to Use
|
|
145
|
+
|
|
146
|
+
**Related failures:** Fixing one might fix others - investigate together first
|
|
147
|
+
**Need full context:** Understanding requires seeing entire system
|
|
148
|
+
**Exploratory debugging:** You don't know what's broken yet
|
|
149
|
+
**Shared state:** Agents would interfere (editing same files, using same resources)
|
|
150
|
+
|
|
151
|
+
## Real Example from Session
|
|
152
|
+
|
|
153
|
+
**Scenario:** 6 test failures across 3 files after major refactoring
|
|
154
|
+
|
|
155
|
+
**Failures:**
|
|
156
|
+
- agent-tool-abort.test.ts: 3 failures (timing issues)
|
|
157
|
+
- batch-completion-behavior.test.ts: 2 failures (tools not executing)
|
|
158
|
+
- tool-approval-race-conditions.test.ts: 1 failure (execution count = 0)
|
|
159
|
+
|
|
160
|
+
**Decision:** Independent domains - abort logic separate from batch completion separate from race conditions
|
|
161
|
+
|
|
162
|
+
**Dispatch:**
|
|
163
|
+
```
|
|
164
|
+
Agent 1 → Fix agent-tool-abort.test.ts
|
|
165
|
+
Agent 2 → Fix batch-completion-behavior.test.ts
|
|
166
|
+
Agent 3 → Fix tool-approval-race-conditions.test.ts
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Results:**
|
|
170
|
+
- Agent 1: Replaced timeouts with event-based waiting
|
|
171
|
+
- Agent 2: Fixed event structure bug (threadId in wrong place)
|
|
172
|
+
- Agent 3: Added wait for async tool execution to complete
|
|
173
|
+
|
|
174
|
+
**Integration:** All fixes independent, no conflicts, full suite green
|
|
175
|
+
|
|
176
|
+
**Time saved:** 3 problems solved in parallel vs sequentially
|
|
177
|
+
|
|
178
|
+
## Key Benefits
|
|
179
|
+
|
|
180
|
+
1. **Parallelization** - Multiple investigations happen simultaneously
|
|
181
|
+
2. **Focus** - Each agent has narrow scope, less context to track
|
|
182
|
+
3. **Independence** - Agents don't interfere with each other
|
|
183
|
+
4. **Speed** - 3 problems solved in time of 1
|
|
184
|
+
|
|
185
|
+
## Verification
|
|
186
|
+
|
|
187
|
+
After agents return:
|
|
188
|
+
1. **Review each summary** - Understand what changed
|
|
189
|
+
2. **Check for conflicts** - Did agents edit same code?
|
|
190
|
+
3. **Run full suite** - Verify all fixes work together
|
|
191
|
+
4. **Spot check** - Agents can make systematic errors
|
|
192
|
+
|
|
193
|
+
## Real-World Impact
|
|
194
|
+
|
|
195
|
+
From debugging session (2025-10-03):
|
|
196
|
+
- 6 failures across 3 files
|
|
197
|
+
- 3 agents dispatched in parallel
|
|
198
|
+
- All investigations completed concurrently
|
|
199
|
+
- All fixes integrated successfully
|
|
200
|
+
- Zero conflicts between agent changes
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: docker-mastery
|
|
3
|
+
description: "Use when working with Docker containers — debugging container failures, writing Dockerfiles, docker-compose for integration tests, image optimization, or deploying containerized applications"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Docker Mastery
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Docker is a **platform for building, shipping, and running applications**, not just isolation.
|
|
11
|
+
|
|
12
|
+
Agents should think in containers: reproducible environments, declarative dependencies, isolated execution.
|
|
13
|
+
|
|
14
|
+
**Core principle:** Containers are not virtual machines. They share the kernel but isolate processes, filesystems, and networks.
|
|
15
|
+
|
|
16
|
+
**Violating the letter of these guidelines is violating the spirit of containerization.**
|
|
17
|
+
|
|
18
|
+
## The Iron Law
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
UNDERSTAND THE CONTAINER BEFORE DEBUGGING INSIDE IT
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Before exec'ing into a container or adding debug commands:
|
|
25
|
+
1. Check the image (what's installed?)
|
|
26
|
+
2. Check mounts (what host files are visible?)
|
|
27
|
+
3. Check environment variables (what config is passed?)
|
|
28
|
+
4. Check the Dockerfile (how was it built?)
|
|
29
|
+
|
|
30
|
+
Random debugging inside containers wastes time. Context first, then debug.
|
|
31
|
+
|
|
32
|
+
## When to Use
|
|
33
|
+
|
|
34
|
+
Use this skill when working with:
|
|
35
|
+
- **Container build failures** - Dockerfile errors, missing dependencies
|
|
36
|
+
- **Test environment setup** - Reproducible test environments across machines
|
|
37
|
+
- **Integration test orchestration** - Multi-service setups (DB + API + tests)
|
|
38
|
+
- **Dockerfile authoring** - Writing efficient, maintainable Dockerfiles
|
|
39
|
+
- **Image size optimization** - Reducing image size, layer caching
|
|
40
|
+
- **Deployment** - Containerized application deployment
|
|
41
|
+
- **Sandbox debugging** - Issues with Hive's Docker sandbox mode
|
|
42
|
+
|
|
43
|
+
**Use this ESPECIALLY when:**
|
|
44
|
+
- Tests pass locally but fail in CI (environment mismatch)
|
|
45
|
+
- "Works on my machine" problems
|
|
46
|
+
- Need to test against specific dependency versions
|
|
47
|
+
- Multiple services must coordinate (database + API)
|
|
48
|
+
- Building for production deployment
|
|
49
|
+
|
|
50
|
+
## Core Concepts
|
|
51
|
+
|
|
52
|
+
### Images vs Containers
|
|
53
|
+
|
|
54
|
+
- **Image**: Read-only template (built from Dockerfile)
|
|
55
|
+
- **Container**: Running instance of an image (ephemeral by default)
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Build once
|
|
59
|
+
docker build -t myapp:latest .
|
|
60
|
+
|
|
61
|
+
# Run many times
|
|
62
|
+
docker run --rm myapp:latest
|
|
63
|
+
docker run --rm -e DEBUG=true myapp:latest
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Key insight:** Changes inside containers are lost unless committed or volumes are used.
|
|
67
|
+
|
|
68
|
+
### Volumes & Mounts
|
|
69
|
+
|
|
70
|
+
Mount host directories into containers for persistence and code sharing:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Mount current directory to /app in container
|
|
74
|
+
docker run -v $(pwd):/app myapp:latest
|
|
75
|
+
|
|
76
|
+
# Hive worktrees are mounted automatically
|
|
77
|
+
# Your code edits (via Read/Write/Edit tools) affect the host
|
|
78
|
+
# Container sees the same files at runtime
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**How Hive uses this:** Worktree is mounted into container, so file tools work on host, bash commands run in container.
|
|
82
|
+
|
|
83
|
+
### Multi-Stage Builds
|
|
84
|
+
|
|
85
|
+
Minimize image size by using multiple FROM statements:
|
|
86
|
+
|
|
87
|
+
```dockerfile
|
|
88
|
+
# Build stage (large, has compilers)
|
|
89
|
+
FROM node:22 AS builder
|
|
90
|
+
WORKDIR /app
|
|
91
|
+
COPY package.json bun.lockb ./
|
|
92
|
+
RUN bun install
|
|
93
|
+
COPY . .
|
|
94
|
+
RUN bun run build
|
|
95
|
+
|
|
96
|
+
# Runtime stage (small, production only)
|
|
97
|
+
FROM node:22-slim
|
|
98
|
+
WORKDIR /app
|
|
99
|
+
COPY --from=builder /app/dist ./dist
|
|
100
|
+
COPY --from=builder /app/node_modules ./node_modules
|
|
101
|
+
CMD ["node", "dist/index.js"]
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Result:** Builder tools (TypeScript, bundlers) not included in final image.
|
|
105
|
+
|
|
106
|
+
### Docker Compose for Multi-Service Setups
|
|
107
|
+
|
|
108
|
+
Define multiple services in `docker-compose.yml`:
|
|
109
|
+
|
|
110
|
+
```yaml
|
|
111
|
+
version: '3.8'
|
|
112
|
+
services:
|
|
113
|
+
db:
|
|
114
|
+
image: postgres:15
|
|
115
|
+
environment:
|
|
116
|
+
POSTGRES_PASSWORD: testpass
|
|
117
|
+
ports:
|
|
118
|
+
- "5432:5432"
|
|
119
|
+
|
|
120
|
+
api:
|
|
121
|
+
build: .
|
|
122
|
+
environment:
|
|
123
|
+
DATABASE_URL: postgres://db:5432/testdb
|
|
124
|
+
depends_on:
|
|
125
|
+
- db
|
|
126
|
+
ports:
|
|
127
|
+
- "3000:3000"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Run with: `docker-compose up -d`
|
|
131
|
+
Teardown with: `docker-compose down`
|
|
132
|
+
|
|
133
|
+
### Network Modes
|
|
134
|
+
|
|
135
|
+
- **bridge** (default): Isolated network, containers can talk to each other by name
|
|
136
|
+
- **host**: Container uses host's network directly (no isolation)
|
|
137
|
+
- **none**: No network access
|
|
138
|
+
|
|
139
|
+
**When to use host mode:** Debugging network issues, accessing host services directly.
|
|
140
|
+
|
|
141
|
+
## Common Patterns
|
|
142
|
+
|
|
143
|
+
### Debug a Failing Container
|
|
144
|
+
|
|
145
|
+
**Problem:** Container exits immediately, logs unclear.
|
|
146
|
+
|
|
147
|
+
**Pattern:**
|
|
148
|
+
1. Run interactively with shell:
|
|
149
|
+
```bash
|
|
150
|
+
docker run -it --entrypoint sh myapp:latest
|
|
151
|
+
```
|
|
152
|
+
2. Inspect filesystem, check if dependencies exist:
|
|
153
|
+
```bash
|
|
154
|
+
ls /app
|
|
155
|
+
which node
|
|
156
|
+
cat /etc/os-release
|
|
157
|
+
```
|
|
158
|
+
3. Run command manually to see full error:
|
|
159
|
+
```bash
|
|
160
|
+
node dist/index.js
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Integration Tests with Docker Compose
|
|
164
|
+
|
|
165
|
+
**Pattern:**
|
|
166
|
+
1. Define services in `docker-compose.test.yml`
|
|
167
|
+
2. Add wait logic (wait for DB to be ready)
|
|
168
|
+
3. Run tests
|
|
169
|
+
4. Teardown
|
|
170
|
+
|
|
171
|
+
```yaml
|
|
172
|
+
# docker-compose.test.yml
|
|
173
|
+
services:
|
|
174
|
+
db:
|
|
175
|
+
image: postgres:15
|
|
176
|
+
environment:
|
|
177
|
+
POSTGRES_PASSWORD: test
|
|
178
|
+
test:
|
|
179
|
+
build: .
|
|
180
|
+
command: bun run test:integration
|
|
181
|
+
depends_on:
|
|
182
|
+
- db
|
|
183
|
+
environment:
|
|
184
|
+
DATABASE_URL: postgres://postgres:test@db:5432/testdb
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
docker-compose -f docker-compose.test.yml up --abort-on-container-exit
|
|
189
|
+
docker-compose -f docker-compose.test.yml down
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Optimize Dockerfile
|
|
193
|
+
|
|
194
|
+
**Anti-pattern:**
|
|
195
|
+
```dockerfile
|
|
196
|
+
FROM node:22
|
|
197
|
+
WORKDIR /app
|
|
198
|
+
COPY . . # Copies everything (including node_modules, .git)
|
|
199
|
+
RUN bun install # Invalidates cache on any file change
|
|
200
|
+
CMD ["bun", "run", "start"]
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**Optimized:**
|
|
204
|
+
```dockerfile
|
|
205
|
+
FROM node:22-slim # Use slim variant
|
|
206
|
+
WORKDIR /app
|
|
207
|
+
|
|
208
|
+
# Copy dependency files first (cache layer)
|
|
209
|
+
COPY package.json bun.lockb ./
|
|
210
|
+
RUN bun install --production
|
|
211
|
+
|
|
212
|
+
# Copy source code (changes frequently)
|
|
213
|
+
COPY src ./src
|
|
214
|
+
COPY tsconfig.json ./
|
|
215
|
+
|
|
216
|
+
CMD ["bun", "run", "start"]
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
**Add `.dockerignore`:**
|
|
220
|
+
```
|
|
221
|
+
node_modules
|
|
222
|
+
.git
|
|
223
|
+
.env
|
|
224
|
+
*.log
|
|
225
|
+
dist
|
|
226
|
+
.DS_Store
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Handle Missing Dependencies
|
|
230
|
+
|
|
231
|
+
**Problem:** Command fails with "not found" in container.
|
|
232
|
+
|
|
233
|
+
**Pattern:**
|
|
234
|
+
1. Check if dependency is in image:
|
|
235
|
+
```bash
|
|
236
|
+
docker run -it myapp:latest which git
|
|
237
|
+
```
|
|
238
|
+
2. If missing, add to Dockerfile:
|
|
239
|
+
```dockerfile
|
|
240
|
+
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
|
|
241
|
+
```
|
|
242
|
+
3. Or use a richer base image (e.g., `node:22` instead of `node:22-slim`).
|
|
243
|
+
|
|
244
|
+
## Hive Sandbox Integration
|
|
245
|
+
|
|
246
|
+
### How Hive Wraps Commands
|
|
247
|
+
|
|
248
|
+
When sandbox mode is active (`sandbox: 'docker'` in config):
|
|
249
|
+
1. Hive hook intercepts bash commands before execution
|
|
250
|
+
2. Wraps with `docker run --rm -v <worktree>:/workspace -w /workspace <image> sh -c "<command>"`
|
|
251
|
+
3. Command runs in container, but file edits (Read/Write/Edit) still affect host
|
|
252
|
+
|
|
253
|
+
**Workers are unaware** — they issue normal bash commands, Hive handles containerization.
|
|
254
|
+
|
|
255
|
+
### When Host Access is Needed
|
|
256
|
+
|
|
257
|
+
Some operations MUST run on host:
|
|
258
|
+
- **Git operations** (commit, push, branch) — repo state is on host
|
|
259
|
+
- **Host-level tools** (Docker itself, system config)
|
|
260
|
+
- **Cross-worktree operations** (accessing main repo from worktree)
|
|
261
|
+
|
|
262
|
+
**Pattern:** Use `HOST:` prefix to escape sandbox:
|
|
263
|
+
```bash
|
|
264
|
+
HOST: git status
|
|
265
|
+
HOST: docker ps
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**If you need host access frequently:** Report as blocked and ask user if sandbox should be disabled for this task.
|
|
269
|
+
|
|
270
|
+
### Persistent vs Ephemeral Containers
|
|
271
|
+
|
|
272
|
+
**Current (v1.2.0):** Each command runs `docker run --rm` (ephemeral). State does NOT persist.
|
|
273
|
+
|
|
274
|
+
Example: `npm install lodash` in one command → not available in next command.
|
|
275
|
+
|
|
276
|
+
**Workaround:** Install dependencies in Dockerfile, not at runtime.
|
|
277
|
+
|
|
278
|
+
**Future:** `docker exec` will reuse containers, persisting state across commands.
|
|
279
|
+
|
|
280
|
+
### Auto-Detected Images
|
|
281
|
+
|
|
282
|
+
Hive detects runtime from project files:
|
|
283
|
+
- `package.json` → `node:22-slim`
|
|
284
|
+
- `requirements.txt` / `pyproject.toml` → `python:3.12-slim`
|
|
285
|
+
- `go.mod` → `golang:1.22-slim`
|
|
286
|
+
- `Cargo.toml` → `rust:1.77-slim`
|
|
287
|
+
- `Dockerfile` → Builds from project Dockerfile
|
|
288
|
+
- Fallback → `ubuntu:24.04`
|
|
289
|
+
|
|
290
|
+
**Override:** Set `dockerImage` in config (`~/.config/opencode/agent_hive.json`).
|
|
291
|
+
|
|
292
|
+
## Red Flags - STOP
|
|
293
|
+
|
|
294
|
+
If you catch yourself:
|
|
295
|
+
- Installing packages on host instead of in Dockerfile
|
|
296
|
+
- Running `docker build` without `.dockerignore` (cache invalidation)
|
|
297
|
+
- Using `latest` tag in production (non-reproducible)
|
|
298
|
+
- Ignoring container exit codes (hides failures)
|
|
299
|
+
- Assuming state persists between `docker run --rm` commands
|
|
300
|
+
- Using absolute host paths in Dockerfile (not portable)
|
|
301
|
+
- Copying secrets into image layers (leaks credentials)
|
|
302
|
+
|
|
303
|
+
**ALL of these mean: STOP. Review pattern.**
|
|
304
|
+
|
|
305
|
+
## Anti-Patterns
|
|
306
|
+
|
|
307
|
+
| Excuse | Reality |
|
|
308
|
+
|--------|---------|
|
|
309
|
+
| "I'll just run it on host" | Container mismatch bugs are worse to debug later. Build happens in container anyway. |
|
|
310
|
+
| "Works in my container, don't need CI" | CI uses different cache state. Always test in CI-like environment. |
|
|
311
|
+
| "I'll optimize the Dockerfile later" | Later never comes. Large images slow down deployments now. |
|
|
312
|
+
| "latest tag is fine for dev" | Dev should match prod. Pin versions or face surprises. |
|
|
313
|
+
| "Don't need .dockerignore, COPY is fast" | Invalidates cache on every file change. Wastes minutes per build. |
|
|
314
|
+
| "Install at runtime, not in image" | Ephemeral containers lose state. Slows down every command. |
|
|
315
|
+
| "Skip depends_on, services start fast" | Race conditions in integration tests. Use wait-for-it or health checks. |
|
|
316
|
+
|
|
317
|
+
## Verification Before Completion
|
|
318
|
+
|
|
319
|
+
Before marking Docker work complete:
|
|
320
|
+
|
|
321
|
+
- [ ] Container runs successfully: `docker run --rm <image> <command>` exits 0
|
|
322
|
+
- [ ] Tests pass inside container (not just on host)
|
|
323
|
+
- [ ] No host pollution (dependencies installed in container, not host)
|
|
324
|
+
- [ ] `.dockerignore` exists if using `COPY . .`
|
|
325
|
+
- [ ] Image tags are pinned (not `latest`) for production
|
|
326
|
+
- [ ] Multi-stage build used if applicable (separate build/runtime)
|
|
327
|
+
- [ ] Integration tests teardown properly (`docker-compose down`)
|
|
328
|
+
|
|
329
|
+
**If any fail:** Don't claim success. Fix or report blocker.
|
|
330
|
+
|
|
331
|
+
## Quick Reference
|
|
332
|
+
|
|
333
|
+
| Task | Command Pattern |
|
|
334
|
+
|------|----------------|
|
|
335
|
+
| **Debug container** | `docker run -it --entrypoint sh <image>` |
|
|
336
|
+
| **Run with mounts** | `docker run -v $(pwd):/app <image>` |
|
|
337
|
+
| **Multi-service tests** | `docker-compose up --abort-on-container-exit` |
|
|
338
|
+
| **Check image contents** | `docker run --rm <image> ls /app` |
|
|
339
|
+
| **Optimize build** | Add `.dockerignore`, use multi-stage, pin versions |
|
|
340
|
+
| **Escape Hive sandbox** | Prefix with `HOST:` (e.g., `HOST: git status`) |
|
|
341
|
+
|
|
342
|
+
## Related Skills
|
|
343
|
+
|
|
344
|
+
- **hive_skill:systematic-debugging** - When container behavior is unexpected
|
|
345
|
+
- **hive_skill:test-driven-development** - Write tests that run in containers
|
|
346
|
+
- **hive_skill:verification-before-completion** - Verify tests pass in container before claiming done
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: executing-plans
|
|
3
|
+
description: Use when you have a written implementation plan to execute in a separate session with review checkpoints
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Executing Plans
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Load plan, review critically, execute tasks in batches, report for review between batches.
|
|
11
|
+
|
|
12
|
+
**Core principle:** Batch execution with checkpoints for architect review.
|
|
13
|
+
|
|
14
|
+
**Announce at start:** "I'm using the executing-plans skill to implement this plan."
|
|
15
|
+
|
|
16
|
+
## The Process
|
|
17
|
+
|
|
18
|
+
### Step 1: Load and Review Plan
|
|
19
|
+
1. Read plan file
|
|
20
|
+
2. Review critically - identify any questions or concerns about the plan
|
|
21
|
+
3. If concerns: Raise them with your human partner before starting
|
|
22
|
+
4. If no concerns: Create TodoWrite and proceed
|
|
23
|
+
|
|
24
|
+
### Step 2: Identify Runnable Tasks
|
|
25
|
+
|
|
26
|
+
Use `hive_status()` to get the **runnable** list — tasks with all dependencies satisfied.
|
|
27
|
+
|
|
28
|
+
Only `done` satisfies dependencies (not `blocked`, `failed`, `partial`, `cancelled`).
|
|
29
|
+
|
|
30
|
+
**When 2+ tasks are runnable:**
|
|
31
|
+
- **Ask the operator** via `question()`: "Multiple tasks are runnable: [list]. Run in parallel, sequential, or a specific subset?"
|
|
32
|
+
- Record the decision with `hive_context_write({ name: "execution-decisions", content: "..." })` for future reference
|
|
33
|
+
|
|
34
|
+
**When 1 task is runnable:** Proceed directly.
|
|
35
|
+
|
|
36
|
+
### Step 3: Execute Batch
|
|
37
|
+
|
|
38
|
+
For each task in the batch:
|
|
39
|
+
1. Mark as in_progress via `hive_worktree_start()`
|
|
40
|
+
2. Follow each step exactly (plan has bite-sized steps)
|
|
41
|
+
3. Run verifications as specified
|
|
42
|
+
4. Mark as completed
|
|
43
|
+
|
|
44
|
+
### Step 4: Report
|
|
45
|
+
When batch complete:
|
|
46
|
+
- Show what was implemented
|
|
47
|
+
- Show verification output
|
|
48
|
+
- Say: "Ready for feedback."
|
|
49
|
+
|
|
50
|
+
### Step 4.5: Post-Batch Hygienic Review
|
|
51
|
+
|
|
52
|
+
After the batch report, ask the operator if they want a Hygienic code review for the batch.
|
|
53
|
+
If yes, run `task({ subagent_type: "hygienic", prompt: "Review implementation changes from the latest batch." })` and apply feedback before starting the next batch.
|
|
54
|
+
|
|
55
|
+
### Step 5: Continue
|
|
56
|
+
Based on feedback:
|
|
57
|
+
- Apply changes if needed
|
|
58
|
+
- Execute next batch
|
|
59
|
+
- Repeat until complete
|
|
60
|
+
|
|
61
|
+
### Step 6: Complete Development
|
|
62
|
+
|
|
63
|
+
After all tasks complete and verified:
|
|
64
|
+
- Announce: "I'm using the verification-before-completion skill to complete this work."
|
|
65
|
+
- **REQUIRED SUB-SKILL:** Use hive_skill:verification-before-completion
|
|
66
|
+
- Follow that skill to verify tests, present options, execute choice
|
|
67
|
+
|
|
68
|
+
## When to Stop and Ask for Help
|
|
69
|
+
|
|
70
|
+
**STOP executing immediately when:**
|
|
71
|
+
- Hit a blocker mid-batch (missing dependency, test fails, instruction unclear)
|
|
72
|
+
- Plan has critical gaps preventing starting
|
|
73
|
+
- You don't understand an instruction
|
|
74
|
+
- Verification fails repeatedly
|
|
75
|
+
|
|
76
|
+
**Ask for clarification rather than guessing.**
|
|
77
|
+
|
|
78
|
+
## When to Revisit Earlier Steps
|
|
79
|
+
|
|
80
|
+
**Return to Review (Step 1) when:**
|
|
81
|
+
- Partner updates the plan based on your feedback
|
|
82
|
+
- Fundamental approach needs rethinking
|
|
83
|
+
|
|
84
|
+
**Don't force through blockers** - stop and ask.
|
|
85
|
+
|
|
86
|
+
## Remember
|
|
87
|
+
- Review plan critically first
|
|
88
|
+
- Follow plan steps exactly
|
|
89
|
+
- Don't skip verifications
|
|
90
|
+
- Reference skills when plan says to
|
|
91
|
+
- Between batches: just report and wait
|
|
92
|
+
- Stop when blocked, don't guess
|