opencode-hive 1.1.0 → 1.3.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.
- package/dist/agents/architect.d.ts +1 -1
- package/dist/agents/forager.d.ts +1 -1
- package/dist/agents/hive.d.ts +1 -1
- package/dist/agents/hygienic.d.ts +1 -1
- package/dist/agents/scout.d.ts +1 -7
- package/dist/agents/swarm.d.ts +1 -1
- package/dist/hooks/system-hook.d.ts +8 -0
- package/dist/index.js +1616 -507
- package/dist/skills/registry.generated.d.ts +1 -1
- package/dist/utils/compaction-prompt.d.ts +1 -0
- package/package.json +1 -1
- package/skills/agents-md-mastery/SKILL.md +253 -0
- package/skills/docker-mastery/SKILL.md +346 -0
- package/skills/executing-plans/SKILL.md +2 -2
- package/skills/test-driven-development/SKILL.md +1 -1
- package/skills/writing-plans/SKILL.md +7 -0
- package/skills/onboarding/SKILL.md +0 -61
|
@@ -7,7 +7,7 @@ import type { SkillDefinition } from './types.js';
|
|
|
7
7
|
/**
|
|
8
8
|
* List of builtin skill names.
|
|
9
9
|
*/
|
|
10
|
-
export declare const BUILTIN_SKILL_NAMES: readonly ["brainstorming", "code-reviewer", "dispatching-parallel-agents", "
|
|
10
|
+
export declare const BUILTIN_SKILL_NAMES: readonly ["agents-md-mastery", "brainstorming", "code-reviewer", "dispatching-parallel-agents", "docker-mastery", "executing-plans", "parallel-exploration", "systematic-debugging", "test-driven-development", "verification-before-completion", "writing-plans"];
|
|
11
11
|
/**
|
|
12
12
|
* All builtin skill definitions.
|
|
13
13
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function buildCompactionPrompt(): string;
|
package/package.json
CHANGED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agents-md-mastery
|
|
3
|
+
description: "Use when bootstrapping, updating, or reviewing AGENTS.md — teaches what makes effective agent memory, how to structure sections, signal vs noise filtering, and when to prune stale entries"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AGENTS.md Mastery
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
**AGENTS.md is pseudo-memory loaded at session start.** Every line shapes agent behavior for the entire session. Quality beats quantity. Write for agents, not humans.
|
|
11
|
+
|
|
12
|
+
Unlike code comments or READMEs, AGENTS.md entries persist across all agent sessions. A bad entry misleads agents hundreds of times. A missing entry causes the same mistake repeatedly.
|
|
13
|
+
|
|
14
|
+
**Core principle:** Optimize for agent comprehension and behavioral change, not human readability.
|
|
15
|
+
|
|
16
|
+
## The Iron Law
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
EVERY ENTRY MUST CHANGE AGENT BEHAVIOR
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
If an entry doesn't:
|
|
23
|
+
- Prevent a specific mistake
|
|
24
|
+
- Enable a capability the agent would otherwise miss
|
|
25
|
+
- Override a default assumption that breaks in this codebase
|
|
26
|
+
|
|
27
|
+
...then it doesn't belong in AGENTS.md.
|
|
28
|
+
|
|
29
|
+
**Test:** Would a fresh agent session make a mistake without this entry? If no → noise.
|
|
30
|
+
|
|
31
|
+
## When to Use
|
|
32
|
+
|
|
33
|
+
| Trigger | Action |
|
|
34
|
+
|---------|--------|
|
|
35
|
+
| New project bootstrap | Write initial AGENTS.md with build/test/style basics |
|
|
36
|
+
| Feature completion | Sync new learnings via `hive_agents_md` tool |
|
|
37
|
+
| Periodic review | Audit for stale/redundant entries (quarterly) |
|
|
38
|
+
| Quality issues | Agent repeating mistakes? Check if AGENTS.md has the fix |
|
|
39
|
+
|
|
40
|
+
## What Makes Good Agent Memory
|
|
41
|
+
|
|
42
|
+
### Signal Entries (Keep)
|
|
43
|
+
|
|
44
|
+
✅ **Project-specific conventions:**
|
|
45
|
+
- "We use Zustand, not Redux — never add Redux"
|
|
46
|
+
- "Auth lives in `/lib/auth` — never create auth elsewhere"
|
|
47
|
+
- "Run `bun test` not `npm test` (we don't use npm)"
|
|
48
|
+
|
|
49
|
+
✅ **Non-obvious patterns:**
|
|
50
|
+
- "Use `.js` extension for local imports (ESM requirement)"
|
|
51
|
+
- "Worktrees don't share `node_modules` — run `bun install` in each"
|
|
52
|
+
- "SandboxConfig is in `dockerSandboxService.ts`, NOT `types.ts`"
|
|
53
|
+
|
|
54
|
+
✅ **Gotchas that break builds:**
|
|
55
|
+
- "Never use `ensureDirSync` — doesn't exist. Use `ensureDir` (sync despite name)"
|
|
56
|
+
- "Import from `../utils/paths.js` not `./paths` (ESM strict)"
|
|
57
|
+
|
|
58
|
+
### Noise Entries (Remove)
|
|
59
|
+
|
|
60
|
+
❌ **Agent already knows:**
|
|
61
|
+
- "This project uses TypeScript" (agent detects from files)
|
|
62
|
+
- "We follow semantic versioning" (universal convention)
|
|
63
|
+
- "Use descriptive variable names" (generic advice)
|
|
64
|
+
|
|
65
|
+
❌ **Irrelevant metadata:**
|
|
66
|
+
- "Created on January 2024"
|
|
67
|
+
- "Originally written by X"
|
|
68
|
+
- "License: MIT" (in LICENSE file already)
|
|
69
|
+
|
|
70
|
+
❌ **Describes what code does:**
|
|
71
|
+
- "FeatureService manages features" (agent can read code)
|
|
72
|
+
- "The system uses git worktrees" (observable from commands)
|
|
73
|
+
|
|
74
|
+
### Rule of Thumb
|
|
75
|
+
|
|
76
|
+
**Signal:** Changes how agent acts
|
|
77
|
+
**Noise:** Documents what agent observes
|
|
78
|
+
|
|
79
|
+
## Section Structure for Fast Comprehension
|
|
80
|
+
|
|
81
|
+
Agents read AGENTS.md top-to-bottom once at session start. Put high-value info first:
|
|
82
|
+
|
|
83
|
+
```markdown
|
|
84
|
+
# Project Name
|
|
85
|
+
|
|
86
|
+
## Build & Test Commands
|
|
87
|
+
# ← Agents need this IMMEDIATELY
|
|
88
|
+
bun run build
|
|
89
|
+
bun run test
|
|
90
|
+
bun run release:check
|
|
91
|
+
|
|
92
|
+
## Code Style
|
|
93
|
+
# ← Prevents syntax/import errors
|
|
94
|
+
- Semicolons: Yes
|
|
95
|
+
- Quotes: Single
|
|
96
|
+
- Imports: Use `.js` extension
|
|
97
|
+
|
|
98
|
+
## Architecture
|
|
99
|
+
# ← Key directories, where things live
|
|
100
|
+
packages/
|
|
101
|
+
├── hive-core/ # Shared logic
|
|
102
|
+
├── opencode-hive/ # Plugin
|
|
103
|
+
└── vscode-hive/ # Extension
|
|
104
|
+
|
|
105
|
+
## Important Patterns
|
|
106
|
+
# ← How to do common tasks correctly
|
|
107
|
+
Use `readText` from paths.ts, not fs.readFileSync
|
|
108
|
+
|
|
109
|
+
## Gotchas & Anti-Patterns
|
|
110
|
+
# ← Things that break or mislead
|
|
111
|
+
NEVER use `ensureDirSync` — doesn't exist
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Keep total under 500 lines.** Beyond that, agents lose focus and miss critical entries.
|
|
115
|
+
|
|
116
|
+
## The Sync Workflow
|
|
117
|
+
|
|
118
|
+
After completing a feature, sync learnings to AGENTS.md:
|
|
119
|
+
|
|
120
|
+
1. **Trigger sync:**
|
|
121
|
+
```typescript
|
|
122
|
+
hive_agents_md({ action: 'sync', feature: 'feature-name' })
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
2. **Review each proposal:**
|
|
126
|
+
- Read the proposed change
|
|
127
|
+
- Ask: "Does this change agent behavior?"
|
|
128
|
+
- Check: Is this already obvious from code/files?
|
|
129
|
+
|
|
130
|
+
3. **Accept signal, reject noise:**
|
|
131
|
+
- ❌ "TypeScript is used" → Agent detects this
|
|
132
|
+
- ✅ "Use `.js` extension for imports" → Prevents build failures
|
|
133
|
+
|
|
134
|
+
4. **Apply approved changes:**
|
|
135
|
+
```typescript
|
|
136
|
+
hive_agents_md({ action: 'apply' })
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Warning:** Don't auto-approve all proposals. One bad entry pollutes all future sessions.
|
|
140
|
+
|
|
141
|
+
## When to Prune
|
|
142
|
+
|
|
143
|
+
Remove entries when they become:
|
|
144
|
+
|
|
145
|
+
**Outdated:**
|
|
146
|
+
- "We use Redux" → Project migrated to Zustand
|
|
147
|
+
- "Node 16 compatibility required" → Now on Node 22
|
|
148
|
+
|
|
149
|
+
**Redundant:**
|
|
150
|
+
- "Use single quotes" + "Strings use single quotes" → Keep one
|
|
151
|
+
- Near-duplicates in different sections
|
|
152
|
+
|
|
153
|
+
**Too generic:**
|
|
154
|
+
- "Write clear code" → Applies to any project
|
|
155
|
+
- "Test your changes" → Universal advice
|
|
156
|
+
|
|
157
|
+
**Describing code:**
|
|
158
|
+
- "TaskService manages tasks" → Agent can read `TaskService` class
|
|
159
|
+
- "Worktrees are in `.hive/.worktrees/`" → Observable from filesystem
|
|
160
|
+
|
|
161
|
+
**Proven unnecessary:**
|
|
162
|
+
- Entry added 6 months ago, but agents haven't hit that issue since
|
|
163
|
+
|
|
164
|
+
## Red Flags
|
|
165
|
+
|
|
166
|
+
| Warning Sign | Why It's Bad | Fix |
|
|
167
|
+
|-------------|-------------|-----|
|
|
168
|
+
| AGENTS.md > 800 lines | Agents lose focus, miss critical info | Prune aggressively |
|
|
169
|
+
| Describes what code does | Agent can read code | Remove descriptions |
|
|
170
|
+
| Missing build/test commands | First thing agents need | Add at top |
|
|
171
|
+
| No gotchas section | Agents repeat past mistakes | Document failure modes |
|
|
172
|
+
| Generic best practices | Doesn't change behavior | Remove or make specific |
|
|
173
|
+
| Outdated patterns | Misleads agents | Prune during sync |
|
|
174
|
+
|
|
175
|
+
## Anti-Patterns
|
|
176
|
+
|
|
177
|
+
| Anti-Pattern | Better Approach |
|
|
178
|
+
|-------------|----------------|
|
|
179
|
+
| "Document everything" | Document only what changes behavior |
|
|
180
|
+
| "Keep for historical record" | Version control is history |
|
|
181
|
+
| "Might be useful someday" | Add when proven necessary |
|
|
182
|
+
| "Explains the system" | Agents read code for that |
|
|
183
|
+
| "Comprehensive reference" | AGENTS.md is a filter, not docs |
|
|
184
|
+
|
|
185
|
+
## Good Examples
|
|
186
|
+
|
|
187
|
+
**Build Commands (High value, agents need immediately):**
|
|
188
|
+
```markdown
|
|
189
|
+
## Build & Test Commands
|
|
190
|
+
bun run build # Build all packages
|
|
191
|
+
bun run test # Run all tests
|
|
192
|
+
bun run release:check # Full CI check
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Project-Specific Convention (Prevents mistakes):**
|
|
196
|
+
```markdown
|
|
197
|
+
## Code Style
|
|
198
|
+
- Imports: Use `.js` extension for local imports (ESM requirement)
|
|
199
|
+
- Paths: Import from `../utils/paths.js` never `./paths`
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**Non-Obvious Gotcha (Prevents build failure):**
|
|
203
|
+
```markdown
|
|
204
|
+
## Important Patterns
|
|
205
|
+
Use `ensureDir` from paths.ts — sync despite name
|
|
206
|
+
NEVER use `ensureDirSync` (doesn't exist)
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Bad Examples
|
|
210
|
+
|
|
211
|
+
**Generic advice (agent already knows):**
|
|
212
|
+
```markdown
|
|
213
|
+
## Best Practices
|
|
214
|
+
- Use meaningful variable names
|
|
215
|
+
- Write unit tests
|
|
216
|
+
- Follow DRY principle
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
**Describes code (agent can read it):**
|
|
220
|
+
```markdown
|
|
221
|
+
## Architecture
|
|
222
|
+
The FeatureService class manages features. It has methods
|
|
223
|
+
for create, read, update, and delete operations.
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
**Irrelevant metadata:**
|
|
227
|
+
```markdown
|
|
228
|
+
## Project History
|
|
229
|
+
Created in January 2024 by the platform team.
|
|
230
|
+
Originally built for internal use.
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Verification
|
|
234
|
+
|
|
235
|
+
Before finalizing AGENTS.md updates:
|
|
236
|
+
|
|
237
|
+
- [ ] Every entry answers: "What mistake does this prevent?"
|
|
238
|
+
- [ ] No generic advice that applies to all projects
|
|
239
|
+
- [ ] Build/test commands are first
|
|
240
|
+
- [ ] Gotchas section exists and is populated
|
|
241
|
+
- [ ] Total length under 500 lines (800 absolute max)
|
|
242
|
+
- [ ] No entries describing what code does
|
|
243
|
+
- [ ] Fresh agent session would benefit from each entry
|
|
244
|
+
|
|
245
|
+
## Summary
|
|
246
|
+
|
|
247
|
+
AGENTS.md is **behavioral memory**, not documentation:
|
|
248
|
+
- Write for agents, optimize for behavior change
|
|
249
|
+
- Signal = prevents mistakes, Noise = describes observables
|
|
250
|
+
- Sync after features, prune quarterly
|
|
251
|
+
- Test: Would agent make a mistake without this entry?
|
|
252
|
+
|
|
253
|
+
**Quality > quantity. Every line counts.**
|
|
@@ -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
|
|
@@ -61,8 +61,8 @@ Based on feedback:
|
|
|
61
61
|
### Step 6: Complete Development
|
|
62
62
|
|
|
63
63
|
After all tasks complete and verified:
|
|
64
|
-
- Announce: "I'm using the
|
|
65
|
-
- **REQUIRED SUB-SKILL:** Use hive_skill:
|
|
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
66
|
- Follow that skill to verify tests, present options, execute choice
|
|
67
67
|
|
|
68
68
|
## When to Stop and Ask for Help
|
|
@@ -356,7 +356,7 @@ Never fix bugs without a test.
|
|
|
356
356
|
|
|
357
357
|
## Testing Anti-Patterns
|
|
358
358
|
|
|
359
|
-
When adding mocks or test utilities,
|
|
359
|
+
When adding mocks or test utilities, avoid common pitfalls:
|
|
360
360
|
- Testing mock behavior instead of real behavior
|
|
361
361
|
- Adding test-only methods to production classes
|
|
362
362
|
- Mocking without understanding dependencies
|
|
@@ -111,6 +111,12 @@ Always include **Depends on** for each task. Use `none` to enable parallel start
|
|
|
111
111
|
**Verify**:
|
|
112
112
|
- [ ] Run: `{command}` → {expected}
|
|
113
113
|
- [ ] {Additional acceptance criteria}
|
|
114
|
+
|
|
115
|
+
All verification MUST be agent-executable (no human intervention):
|
|
116
|
+
✅ `bun test` → all pass
|
|
117
|
+
✅ `curl -X POST /api/x` → 201
|
|
118
|
+
❌ "User manually tests..."
|
|
119
|
+
❌ "Visually confirm..."
|
|
114
120
|
````
|
|
115
121
|
|
|
116
122
|
## Remember
|
|
@@ -119,6 +125,7 @@ Always include **Depends on** for each task. Use `none` to enable parallel start
|
|
|
119
125
|
- Exact commands with expected output
|
|
120
126
|
- Reference relevant skills with @ syntax
|
|
121
127
|
- DRY, YAGNI, TDD, frequent commits
|
|
128
|
+
- All acceptance criteria must be agent-executable (zero human intervention)
|
|
122
129
|
|
|
123
130
|
## Execution Handoff
|
|
124
131
|
|