@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.
Files changed (42) hide show
  1. package/README.md +383 -0
  2. package/dist/agents/architect.d.ts +12 -0
  3. package/dist/agents/custom-agents.d.ts +18 -0
  4. package/dist/agents/forager.d.ts +12 -0
  5. package/dist/agents/hive.d.ts +12 -0
  6. package/dist/agents/hygienic.d.ts +12 -0
  7. package/dist/agents/index.d.ts +60 -0
  8. package/dist/agents/scout.d.ts +6 -0
  9. package/dist/agents/swarm.d.ts +12 -0
  10. package/dist/hooks/system-hook.d.ts +8 -0
  11. package/dist/hooks/variant-hook.d.ts +17 -0
  12. package/dist/index.d.ts +3 -0
  13. package/dist/index.js +24654 -0
  14. package/dist/mcp/ast-grep.d.ts +2 -0
  15. package/dist/mcp/context7.d.ts +2 -0
  16. package/dist/mcp/grep-app.d.ts +2 -0
  17. package/dist/mcp/index.d.ts +2 -0
  18. package/dist/mcp/types.d.ts +12 -0
  19. package/dist/mcp/websearch.d.ts +2 -0
  20. package/dist/skills/builtin.d.ts +38 -0
  21. package/dist/skills/file-loader.d.ts +22 -0
  22. package/dist/skills/index.d.ts +8 -0
  23. package/dist/skills/registry.generated.d.ts +14 -0
  24. package/dist/skills/types.d.ts +29 -0
  25. package/dist/utils/compaction-prompt.d.ts +1 -0
  26. package/dist/utils/format.d.ts +16 -0
  27. package/dist/utils/prompt-budgeting.d.ts +112 -0
  28. package/dist/utils/prompt-file.d.ts +58 -0
  29. package/dist/utils/prompt-observability.d.ts +93 -0
  30. package/dist/utils/worker-prompt.d.ts +43 -0
  31. package/package.json +60 -0
  32. package/skills/agents-md-mastery/SKILL.md +252 -0
  33. package/skills/brainstorming/SKILL.md +53 -0
  34. package/skills/code-reviewer/SKILL.md +208 -0
  35. package/skills/dispatching-parallel-agents/SKILL.md +200 -0
  36. package/skills/docker-mastery/SKILL.md +346 -0
  37. package/skills/executing-plans/SKILL.md +92 -0
  38. package/skills/parallel-exploration/SKILL.md +240 -0
  39. package/skills/systematic-debugging/SKILL.md +296 -0
  40. package/skills/test-driven-development/SKILL.md +371 -0
  41. package/skills/verification-before-completion/SKILL.md +139 -0
  42. package/skills/writing-plans/SKILL.md +148 -0
@@ -0,0 +1,252 @@
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
+
104
+ ## Important Patterns
105
+ # ← How to do common tasks correctly
106
+ Use `readText` from paths.ts, not fs.readFileSync
107
+
108
+ ## Gotchas & Anti-Patterns
109
+ # ← Things that break or mislead
110
+ NEVER use `ensureDirSync` — doesn't exist
111
+ ```
112
+
113
+ **Keep total under 500 lines.** Beyond that, agents lose focus and miss critical entries.
114
+
115
+ ## The Sync Workflow
116
+
117
+ After completing a feature, sync learnings to AGENTS.md:
118
+
119
+ 1. **Trigger sync:**
120
+ ```typescript
121
+ hive_agents_md({ action: 'sync', feature: 'feature-name' })
122
+ ```
123
+
124
+ 2. **Review each proposal:**
125
+ - Read the proposed change
126
+ - Ask: "Does this change agent behavior?"
127
+ - Check: Is this already obvious from code/files?
128
+
129
+ 3. **Accept signal, reject noise:**
130
+ - ❌ "TypeScript is used" → Agent detects this
131
+ - ✅ "Use `.js` extension for imports" → Prevents build failures
132
+
133
+ 4. **Apply approved changes:**
134
+ ```typescript
135
+ hive_agents_md({ action: 'apply' })
136
+ ```
137
+
138
+ **Warning:** Don't auto-approve all proposals. One bad entry pollutes all future sessions.
139
+
140
+ ## When to Prune
141
+
142
+ Remove entries when they become:
143
+
144
+ **Outdated:**
145
+ - "We use Redux" → Project migrated to Zustand
146
+ - "Node 16 compatibility required" → Now on Node 22
147
+
148
+ **Redundant:**
149
+ - "Use single quotes" + "Strings use single quotes" → Keep one
150
+ - Near-duplicates in different sections
151
+
152
+ **Too generic:**
153
+ - "Write clear code" → Applies to any project
154
+ - "Test your changes" → Universal advice
155
+
156
+ **Describing code:**
157
+ - "TaskService manages tasks" → Agent can read `TaskService` class
158
+ - "Worktrees are in `.hive/.worktrees/`" → Observable from filesystem
159
+
160
+ **Proven unnecessary:**
161
+ - Entry added 6 months ago, but agents haven't hit that issue since
162
+
163
+ ## Red Flags
164
+
165
+ | Warning Sign | Why It's Bad | Fix |
166
+ |-------------|-------------|-----|
167
+ | AGENTS.md > 800 lines | Agents lose focus, miss critical info | Prune aggressively |
168
+ | Describes what code does | Agent can read code | Remove descriptions |
169
+ | Missing build/test commands | First thing agents need | Add at top |
170
+ | No gotchas section | Agents repeat past mistakes | Document failure modes |
171
+ | Generic best practices | Doesn't change behavior | Remove or make specific |
172
+ | Outdated patterns | Misleads agents | Prune during sync |
173
+
174
+ ## Anti-Patterns
175
+
176
+ | Anti-Pattern | Better Approach |
177
+ |-------------|----------------|
178
+ | "Document everything" | Document only what changes behavior |
179
+ | "Keep for historical record" | Version control is history |
180
+ | "Might be useful someday" | Add when proven necessary |
181
+ | "Explains the system" | Agents read code for that |
182
+ | "Comprehensive reference" | AGENTS.md is a filter, not docs |
183
+
184
+ ## Good Examples
185
+
186
+ **Build Commands (High value, agents need immediately):**
187
+ ```markdown
188
+ ## Build & Test Commands
189
+ bun run build # Build all packages
190
+ bun run test # Run all tests
191
+ bun run release:check # Full CI check
192
+ ```
193
+
194
+ **Project-Specific Convention (Prevents mistakes):**
195
+ ```markdown
196
+ ## Code Style
197
+ - Imports: Use `.js` extension for local imports (ESM requirement)
198
+ - Paths: Import from `../utils/paths.js` never `./paths`
199
+ ```
200
+
201
+ **Non-Obvious Gotcha (Prevents build failure):**
202
+ ```markdown
203
+ ## Important Patterns
204
+ Use `ensureDir` from paths.ts — sync despite name
205
+ NEVER use `ensureDirSync` (doesn't exist)
206
+ ```
207
+
208
+ ## Bad Examples
209
+
210
+ **Generic advice (agent already knows):**
211
+ ```markdown
212
+ ## Best Practices
213
+ - Use meaningful variable names
214
+ - Write unit tests
215
+ - Follow DRY principle
216
+ ```
217
+
218
+ **Describes code (agent can read it):**
219
+ ```markdown
220
+ ## Architecture
221
+ The FeatureService class manages features. It has methods
222
+ for create, read, update, and delete operations.
223
+ ```
224
+
225
+ **Irrelevant metadata:**
226
+ ```markdown
227
+ ## Project History
228
+ Created in January 2024 by the platform team.
229
+ Originally built for internal use.
230
+ ```
231
+
232
+ ## Verification
233
+
234
+ Before finalizing AGENTS.md updates:
235
+
236
+ - [ ] Every entry answers: "What mistake does this prevent?"
237
+ - [ ] No generic advice that applies to all projects
238
+ - [ ] Build/test commands are first
239
+ - [ ] Gotchas section exists and is populated
240
+ - [ ] Total length under 500 lines (800 absolute max)
241
+ - [ ] No entries describing what code does
242
+ - [ ] Fresh agent session would benefit from each entry
243
+
244
+ ## Summary
245
+
246
+ AGENTS.md is **behavioral memory**, not documentation:
247
+ - Write for agents, optimize for behavior change
248
+ - Signal = prevents mistakes, Noise = describes observables
249
+ - Sync after features, prune quarterly
250
+ - Test: Would agent make a mistake without this entry?
251
+
252
+ **Quality > quantity. Every line counts.**
@@ -0,0 +1,53 @@
1
+ ---
2
+ name: brainstorming
3
+ description: "Use before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation."
4
+ ---
5
+
6
+ # Brainstorming Ideas Into Designs
7
+
8
+ ## Overview
9
+
10
+ Help turn ideas into fully formed designs and specs through natural collaborative dialogue.
11
+
12
+ Start by understanding the current project context, then ask questions one at a time to refine the idea. Once you understand what you're building, present the design in small sections (200-300 words), checking after each section whether it looks right so far.
13
+
14
+ ## The Process
15
+
16
+ **Understanding the idea:**
17
+ - Check out the current project state first (files, docs, recent commits)
18
+ - Ask questions one at a time to refine the idea
19
+ - Prefer multiple choice questions when possible, but open-ended is fine too
20
+ - Only one question per message - if a topic needs more exploration, break it into multiple questions
21
+ - Focus on understanding: purpose, constraints, success criteria
22
+
23
+ **Exploring approaches:**
24
+ - Propose 2-3 different approaches with trade-offs
25
+ - Present options conversationally with your recommendation and reasoning
26
+ - Lead with your recommended option and explain why
27
+
28
+ **Presenting the design:**
29
+ - Once you believe you understand what you're building, present the design
30
+ - Break it into sections of 200-300 words
31
+ - Ask after each section whether it looks right so far
32
+ - Cover: architecture, components, data flow, error handling, testing
33
+ - Be ready to go back and clarify if something doesn't make sense
34
+
35
+ ## After the Design
36
+
37
+ **Documentation:**
38
+ - Write the validated design to `docs/plans/YYYY-MM-DD-<topic>-design.md`
39
+ - Commit the design document to git
40
+
41
+ **Implementation (if continuing):**
42
+ - Ask: "Ready to set up for implementation?"
43
+ - Use `hive_skill:writing-plans` to create detailed implementation plan
44
+
45
+ ## Key Principles
46
+
47
+ - **One question at a time** - Don't overwhelm with multiple questions
48
+ - **Multiple choice preferred** - Easier to answer than open-ended when possible
49
+ - **YAGNI ruthlessly** - Remove unnecessary features from all designs
50
+ - **Explore alternatives** - Always propose 2-3 approaches before settling
51
+ - **Incremental validation** - Present design in sections, validate each
52
+ - **Be flexible** - Go back and clarify when something doesn't make sense
53
+ - **Challenge assumptions** - Surface fragile assumptions, ask what changes if they fail, offer lean fallback options
@@ -0,0 +1,208 @@
1
+ ---
2
+ name: code-reviewer
3
+ description: Use when reviewing implementation changes against an approved plan or task (especially before merging or between Hive tasks) to catch missing requirements, YAGNI, dead code, and risky patterns
4
+ ---
5
+
6
+ # Code Reviewer
7
+
8
+ ## Overview
9
+
10
+ This skill teaches a reviewer to evaluate implementation changes for:
11
+ - Adherence to the approved plan/task (did we build what we said?)
12
+ - Correctness (does it work, including edge cases?)
13
+ - Simplicity (YAGNI, dead code, over-abstraction)
14
+ - Risk (security, performance, maintainability)
15
+
16
+ **Core principle:** The best change is the smallest correct change that satisfies the plan.
17
+
18
+ ## Iron Laws
19
+
20
+ - Review against the task/plan first. Code quality comes second.
21
+ - Bias toward deletion and simplification. Every extra line is a liability.
22
+ - Prefer changes that leverage existing patterns and dependencies.
23
+ - Be specific: cite file paths and (when available) line numbers.
24
+ - Do not invent requirements. If the plan/task is ambiguous, mark it and request clarification.
25
+
26
+ ## What Inputs You Need
27
+
28
+ Minimum:
29
+ - The task intent (1-3 sentences)
30
+ - The plan/task requirements (or a link/path to plan section)
31
+ - The code changes (diff or list of changed files)
32
+
33
+ If available (recommended):
34
+ - Acceptance criteria / verification steps from the plan
35
+ - Test output or proof the change was verified
36
+ - Any relevant context files (design decisions, constraints)
37
+
38
+ ## Review Process (In Order)
39
+
40
+ ### 1) Identify Scope
41
+
42
+ 1. List all files changed.
43
+ 2. For each file, state why it changed (what requirement it serves).
44
+ 3. Flag any changes that do not map to the task/plan.
45
+
46
+ **Rule:** If you cannot map a change to a requirement, treat it as suspicious until justified.
47
+
48
+ ### 2) Plan/Task Adherence (Non-Negotiable)
49
+
50
+ Create a simple checklist:
51
+ - What the task says must happen
52
+ - Evidence in code/tests that it happens
53
+
54
+ Flag as issues:
55
+ - Missing requirements (implemented behavior does not match intent)
56
+ - Partial implementation with no follow-up task (TODO-driven shipping)
57
+ - Behavior changes that are not in the plan/task
58
+
59
+ ### 3) Correctness Layer
60
+
61
+ Review for:
62
+ - Edge cases and error paths
63
+ - Incorrect assumptions about inputs/types
64
+ - Inconsistent behavior across platforms/environments
65
+ - Broken invariants (e.g., state can become invalid)
66
+
67
+ Prefer "fail fast, fail loud": invalid states should become clear errors, not silent fallbacks.
68
+
69
+ ### 4) Simplicity / YAGNI Layer
70
+
71
+ Be ruthless and concrete:
72
+ - Remove dead branches, unused flags/options, unreachable code
73
+ - Remove speculative TODOs and "reserved for future" scaffolding
74
+ - Remove comments that restate the code or narrate obvious steps
75
+ - Inline one-off abstractions (helpers/classes/interfaces used once)
76
+ - Replace cleverness with obvious code
77
+ - Reduce nesting with guard clauses / early returns
78
+
79
+ Prefer clarity over brevity:
80
+ - Avoid nested ternary operators; use `if/else` or `switch` when branches matter
81
+ - Avoid dense one-liners that hide intent or make debugging harder
82
+
83
+ ### 4b) De-Slop Pass (AI Artifacts / Style Drift)
84
+
85
+ Scan the diff (not just the final code) for AI-generated slop introduced in this branch:
86
+ - Extra comments that a human would not add, or that do not match the file's tone
87
+ - Defensive checks or try/catch blocks that are abnormal for that area of the codebase
88
+ - Especially swallowed errors ("ignore and continue") and silent fallbacks
89
+ - Especially redundant validation in trusted internal codepaths
90
+ - TypeScript escape hatches used to dodge type errors (`as any`, `as unknown as X`) without necessity
91
+ - Style drift: naming, error handling patterns, logging style, and structure inconsistent with nearby code
92
+
93
+ Default stance:
94
+ - Prefer deletion over justification.
95
+ - If validation is needed, do it at boundaries; keep internals trusting parsed inputs.
96
+ - If a cast is truly unavoidable, localize it and keep the justification to a single short note.
97
+
98
+ When recommending simplifications, do not accidentally change behavior. If the current behavior is unclear, request clarification or ask for a test that pins it down.
99
+
100
+ **Default stance:** Do not add extensibility points without an explicit current requirement.
101
+
102
+ ### 5) Risk Layer (Security / Performance / Maintainability)
103
+
104
+ Only report what you are confident about.
105
+
106
+ Security checks (examples):
107
+ - No secrets in code/logs
108
+ - No injection vectors (shell/SQL/HTML) introduced
109
+ - Authz/authn checks preserved
110
+ - Sensitive data not leaked
111
+
112
+ Performance checks (examples):
113
+ - Avoid unnecessary repeated work (N+1 queries, repeated parsing, repeated filesystem hits)
114
+ - Avoid obvious hot-path allocations or large sync operations
115
+
116
+ Maintainability checks:
117
+ - Clear naming and intent
118
+ - Consistent error handling
119
+ - API boundaries not blurred
120
+ - Consistent with local file patterns (imports, export style, function style)
121
+
122
+ ### 6) Make One Primary Recommendation
123
+
124
+ Provide one clear path to reach approval.
125
+ Mention alternatives only when they have materially different trade-offs.
126
+
127
+ ### 7) Signal the Investment
128
+
129
+ Tag the required follow-up effort using:
130
+ - Quick (<1h)
131
+ - Short (1-4h)
132
+ - Medium (1-2d)
133
+ - Large (3d+)
134
+
135
+ ## Confidence Filter
136
+
137
+ Only report findings you believe are >=80% likely to be correct.
138
+ If you are unsure, explicitly label it as "Uncertain" and explain what evidence would confirm it.
139
+
140
+ ## Output Format (Use This Exactly)
141
+
142
+ ---
143
+
144
+ **Files Reviewed:** [list]
145
+
146
+ **Plan/Task Reference:** [task name + link/path to plan section if known]
147
+
148
+ **Overall Assessment:** [APPROVE | REQUEST_CHANGES | NEEDS_DISCUSSION]
149
+
150
+ **Bottom Line:** 2-3 sentences describing whether it matches the task/plan and what must change.
151
+
152
+ ### Critical Issues
153
+ - None | [file:line] - [issue] (why it blocks approval) + (recommended fix)
154
+
155
+ ### Major Issues
156
+ - None | [file:line] - [issue] + (recommended fix)
157
+
158
+ ### Minor Issues
159
+ - None | [file:line] - [issue] + (suggested fix)
160
+
161
+ ### YAGNI / Dead Code
162
+ - None | [file:line] - [what to remove/simplify] + (why it is unnecessary)
163
+
164
+ ### Positive Observations
165
+ - [at least one concrete good thing]
166
+
167
+ ### Action Plan
168
+ 1. [highest priority change]
169
+ 2. [next]
170
+ 3. [next]
171
+
172
+ ### Effort Estimate
173
+ [Quick | Short | Medium | Large]
174
+
175
+ ---
176
+
177
+ ## Common Review Smells (Fast Scan)
178
+
179
+ Task/plan adherence:
180
+ - Adds features not mentioned in the plan/task
181
+ - Leaves TODOs as the mechanism for correctness
182
+ - Introduces new configuration modes/flags "for future"
183
+
184
+ YAGNI / dead code:
185
+ - Options/config that are parsed but not used
186
+ - Branches that do the same thing on both sides
187
+ - Comments like "reserved for future" or "we might need this"
188
+
189
+ AI slop / inconsistency:
190
+ - Commentary that restates code, narrates obvious steps, or adds process noise
191
+ - try/catch that swallows errors or returns defaults without a requirement
192
+ - `as any` used to silence type errors instead of fixing types
193
+ - New helpers/abstractions with a single call site
194
+
195
+ Correctness:
196
+ - Silent fallbacks to defaults on error when the task expects a hard failure
197
+ - Unhandled error paths, missing cleanup, missing returns
198
+
199
+ Maintainability:
200
+ - Abstractions used once
201
+ - Unclear naming, "utility" grab-bags
202
+
203
+ ## When to Escalate
204
+
205
+ Use NEEDS_DISCUSSION (instead of REQUEST_CHANGES) when:
206
+ - The plan/task is ambiguous and multiple implementations could be correct
207
+ - The change implies a product/architecture decision not documented
208
+ - Fixing issues requires changing scope, dependencies, or public API