opencodekit 0.12.2 → 0.12.3

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 (32) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/template/.opencode/AGENTS.md +40 -417
  3. package/dist/template/.opencode/agent/build.md +53 -0
  4. package/dist/template/.opencode/agent/planner.md +0 -1
  5. package/dist/template/.opencode/agent/rush.md +38 -0
  6. package/dist/template/.opencode/command/accessibility-check.md +1 -1
  7. package/dist/template/.opencode/command/commit.md +1 -1
  8. package/dist/template/.opencode/command/create.md +68 -441
  9. package/dist/template/.opencode/command/finish.md +82 -252
  10. package/dist/template/.opencode/command/fix-ci.md +52 -247
  11. package/dist/template/.opencode/command/fix-types.md +32 -292
  12. package/dist/template/.opencode/command/fix-ui.md +49 -234
  13. package/dist/template/.opencode/command/fix.md +57 -194
  14. package/dist/template/.opencode/command/handoff.md +66 -243
  15. package/dist/template/.opencode/command/implement.md +67 -231
  16. package/dist/template/.opencode/command/issue.md +42 -190
  17. package/dist/template/.opencode/command/plan.md +86 -442
  18. package/dist/template/.opencode/command/pr.md +3 -1
  19. package/dist/template/.opencode/command/research-and-implement.md +69 -370
  20. package/dist/template/.opencode/command/research.md +72 -197
  21. package/dist/template/.opencode/command/resume.md +70 -438
  22. package/dist/template/.opencode/command/status.md +11 -11
  23. package/dist/template/.opencode/command/triage.md +23 -18
  24. package/dist/template/.opencode/memory/project/commands.md +139 -7
  25. package/dist/template/.opencode/memory/project/gotchas.md +85 -0
  26. package/dist/template/.opencode/plugin/beads.ts +181 -16
  27. package/dist/template/.opencode/skill/beads/SKILL.md +15 -0
  28. package/dist/template/.opencode/skill/context-engineering/SKILL.md +94 -0
  29. package/dist/template/.opencode/skill/memory-system/SKILL.md +107 -0
  30. package/dist/template/.opencode/skill/session-management/SKILL.md +111 -0
  31. package/dist/template/.opencode/skill/tool-priority/SKILL.md +115 -0
  32. package/package.json +1 -1
@@ -0,0 +1,94 @@
1
+ ---
2
+ description: Use when managing context window, deciding what to load/prune, or understanding AI adoption stages - covers constraint awareness and intent layer principles
3
+ ---
4
+
5
+ # Context Engineering Skill
6
+
7
+ ## AI Adoption Stages
8
+
9
+ OpenCode operates at **Stage 5-6**:
10
+
11
+ - **Stage 5** (Agentic Verification): Agents run tests and iterate autonomously
12
+ - **Stage 6** (Multi-Agent Orchestration): Parallel workstreams with coordination
13
+
14
+ **Current constraint**: Planning and specification quality. Implementation capacity is not the bottleneck—how well you specify requirements is.
15
+
16
+ ## Autonomous Duration
17
+
18
+ The key metric: **How long can an agent work before losing the plot?**
19
+
20
+ Extend autonomous duration by:
21
+
22
+ - Binding tighter to intent (clear specs, constraints, invariants)
23
+ - Providing systematic context (AGENTS.md hierarchy, memory files)
24
+ - Verification loops (test → iterate → verify)
25
+
26
+ ## Greenfield vs Legacy
27
+
28
+ | Type | Context | Agent Performance |
29
+ | -------------- | -------------------------- | ----------------------------- |
30
+ | **Greenfield** | Simple, fast prototypes | Works well immediately |
31
+ | **Legacy** | Complex, hidden invariants | Needs careful context loading |
32
+
33
+ Codebase complexity is a primary difficulty knob. Context is how you pay it down.
34
+
35
+ ## Three Context Constraints
36
+
37
+ 1. **Blind spots cause hallucinations** - If agent doesn't see specific context, it fills gaps with generic training priors. You only get the behavior you load.
38
+
39
+ 2. **Everything influences everything** - Noise-to-signal ratio matters. Irrelevant files degrade ALL output quality.
40
+
41
+ 3. **Window is finite** - Performance degrades BEFORE hitting hard token limits. Curate the smallest, highest-signal slice.
42
+
43
+ ## Practical Implications
44
+
45
+ | Instead of | Do This |
46
+ | ----------------------- | ----------------------------------------------------- |
47
+ | Reading entire files | Use `lsp_lsp_document_symbols` for outline |
48
+ | Loading whole documents | Read specific line ranges |
49
+ | Flat file loading | Navigate AGENTS.md hierarchy (progressive disclosure) |
50
+ | Keeping completed work | Prune context aggressively |
51
+
52
+ ## Intent Layer Principles
53
+
54
+ ### What Belongs in Each AGENTS.md
55
+
56
+ - **Purpose & Scope** - What this area does. What it explicitly DOESN'T do.
57
+ - **Entry Points & Contracts** - Main APIs, invariants, "all X goes through Y"
58
+ - **Usage Patterns** - Canonical examples: "To add a rule, follow this pattern..."
59
+ - **Anti-patterns** - Negative examples: "Never call X directly; go through Y"
60
+ - **Dependencies & Downlinks** - What it connects to, pointers to child AGENTS.md
61
+ - **Pitfalls** - Things that repeatedly confused agents/humans
62
+
63
+ ### Key Mechanics
64
+
65
+ | Principle | Meaning |
66
+ | ------------------------------- | ------------------------------------------------------------- |
67
+ | **Hierarchical loading** | When a node loads, all ancestors load too (T-shaped view) |
68
+ | **Compression, not bloat** | Good nodes compress code; 10k tokens for 20k code adds weight |
69
+ | **Least Common Ancestor (LCA)** | Place shared knowledge at shallowest node covering all paths |
70
+ | **Downlinks for discovery** | Point to related context without loading everything upfront |
71
+
72
+ ## Context Budget Guidelines
73
+
74
+ | Phase | Target Context | Action |
75
+ | ----------------- | -------------- | ----------------------------------------- |
76
+ | Starting work | <50k tokens | Load only essential AGENTS.md + task spec |
77
+ | Mid-task | 50-100k tokens | Prune completed reads, keep active files |
78
+ | Approaching limit | >100k tokens | Aggressive pruning, extract key findings |
79
+ | Near capacity | >150k tokens | Consider session restart with handoff |
80
+
81
+ ## Anti-Patterns
82
+
83
+ ❌ Loading "everything that might be relevant"
84
+ ❌ Keeping old file reads after editing complete
85
+ ❌ Reading entire files when you only need a function
86
+ ❌ Ignoring AGENTS.md hierarchy (loading leaf without ancestors)
87
+
88
+ ## Best Practices
89
+
90
+ ✅ Start with minimum viable context
91
+ ✅ Use LSP tools for targeted information
92
+ ✅ Prune after each completed sub-task
93
+ ✅ Trust AGENTS.md hierarchy for discovery
94
+ ✅ Extract findings before pruning valuable reads
@@ -0,0 +1,107 @@
1
+ ---
2
+ name: memory-system
3
+ description: Use when persisting learnings, loading previous context, or searching past decisions - covers memory file structure, tools, and when to update each file
4
+ ---
5
+
6
+ # Memory System
7
+
8
+ Persistent context that survives across sessions.
9
+
10
+ ## Directory Structure
11
+
12
+ ```
13
+ .opencode/memory/
14
+ _templates/ # Task templates (prd, observation, session-summary)
15
+ handoffs/ # Phase transitions
16
+ research/ # Research findings
17
+ observations/ # Structured observations
18
+ project/ # Persistent project knowledge
19
+ commands.md # Build, test, lint, deploy commands
20
+ conventions.md # Code patterns, commit style, PR process
21
+ gotchas.md # Footguns, edge cases, "don't forget this"
22
+ architecture.md # Key modules, directory structure
23
+ user.md # Identity, preferences, communication style
24
+ ```
25
+
26
+ ## Standard Memory Blocks
27
+
28
+ | File | Purpose | Update When |
29
+ | ------------------------- | ------------------------ | --------------------------- |
30
+ | `project/commands.md` | Build/test/lint commands | Discovering new command |
31
+ | `project/conventions.md` | Code patterns, style | Learning team pattern |
32
+ | `project/gotchas.md` | Footguns, warnings | Hitting unexpected behavior |
33
+ | `project/architecture.md` | Key modules, structure | Mapping new area |
34
+ | `user.md` | Preferences, workflow | Learning user preference |
35
+
36
+ ## Explicit Memory Updates
37
+
38
+ Don't rely on implicit learning. Explicitly persist:
39
+
40
+ - Non-obvious project behavior → `project/gotchas.md`
41
+ - User preferences discovered → `user.md`
42
+ - New build/test commands → `project/commands.md`
43
+ - Code patterns to follow → `project/conventions.md`
44
+
45
+ ## Memory Tools
46
+
47
+ ### memory-read
48
+
49
+ Load previous context or templates:
50
+
51
+ ```typescript
52
+ memory - read({ file: "project/commands" }); // Load commands
53
+ memory - read({ file: "_templates/prd" }); // Load PRD template
54
+ memory - read({ file: "handoffs/bd-abc123" }); // Load specific handoff
55
+ ```
56
+
57
+ ### memory-update
58
+
59
+ Save learnings or handoffs:
60
+
61
+ ```typescript
62
+ memory -
63
+ update({
64
+ file: "project/gotchas",
65
+ content: "### New Gotcha\n\nDescription...",
66
+ mode: "append", // or "replace"
67
+ });
68
+ ```
69
+
70
+ ### memory-search
71
+
72
+ Find past decisions, research, or handoffs:
73
+
74
+ ```typescript
75
+ memory - search({ query: "authentication" });
76
+ memory - search({ query: "bugfix", type: "observations" });
77
+ memory - search({ query: "session", type: "handoffs" });
78
+ ```
79
+
80
+ ## Observations
81
+
82
+ Record important findings with structured metadata:
83
+
84
+ ```typescript
85
+ observation({
86
+ type: "decision", // decision, bugfix, feature, pattern, discovery, learning, warning
87
+ title: "Use JWT auth",
88
+ content: "Decided to use JWT because...",
89
+ concepts: "auth, security",
90
+ files: "src/auth.ts",
91
+ bead_id: "bd-abc123",
92
+ });
93
+ ```
94
+
95
+ **When to create observations:**
96
+
97
+ - Major architectural decisions
98
+ - Bug root causes discovered
99
+ - Patterns worth reusing
100
+ - Gotchas and warnings for future
101
+
102
+ ## Best Practices
103
+
104
+ 1. **Read before work** - Check relevant memory files at session start
105
+ 2. **Update during work** - Don't wait until end; persist incrementally
106
+ 3. **Be specific** - Include file paths, function names, concrete examples
107
+ 4. **Keep it actionable** - Future agents should know what to do with the info
@@ -0,0 +1,111 @@
1
+ ---
2
+ name: session-management
3
+ description: Use when context is growing large, switching tasks, or needing previous session context - covers thresholds, session tools, and workflow patterns
4
+ ---
5
+
6
+ # Session Management
7
+
8
+ **Philosophy**: Short sessions (<150k tokens) beat long bloated ones. Agents get worse with too much context. Cost is exponential.
9
+
10
+ ## Context Thresholds
11
+
12
+ The environment monitors context usage and warns at these thresholds:
13
+
14
+ | Threshold | Action |
15
+ | --------- | ---------------------------------------------------------- |
16
+ | **70%** | Consolidate work; consider pruning irrelevant tool outputs |
17
+ | **85%** | Summarize findings and consider starting a new session |
18
+ | **95%** | Critical: prune context immediately or restart session |
19
+
20
+ ## Session Tools
21
+
22
+ ### list_sessions
23
+
24
+ Discover available sessions before reading:
25
+
26
+ ```typescript
27
+ list_sessions({ limit: 10, project: "current" }); // Current project
28
+ list_sessions({ since: "today" }); // Today's sessions
29
+ list_sessions({ project: "all", since: "yesterday" }); // Cross-project
30
+ ```
31
+
32
+ ### read_session
33
+
34
+ Pull context from previous session:
35
+
36
+ ```typescript
37
+ read_session("last"); // Most recent
38
+ read_session("2 ago", { project: "current" }); // 2nd most recent
39
+ read_session("today"); // Today's first session
40
+ read_session("ses_abc123", { focus: "file changes" }); // Specific aspect
41
+ ```
42
+
43
+ ### search_session
44
+
45
+ Full-text search across sessions:
46
+
47
+ ```typescript
48
+ search_session({ query: "auth bug" }); // Search all sessions
49
+ search_session({ query: "OAuth", session_id: "ses_abc" }); // Specific session
50
+ search_session({ query: "error", limit: 10 }); // Limit results
51
+ ```
52
+
53
+ Use to find past discussions, decisions, or work on a topic before starting new work.
54
+
55
+ ### summarize_session
56
+
57
+ Generate AI summary of a session:
58
+
59
+ ```typescript
60
+ summarize_session("ses_abc123"); // Trigger AI summarization
61
+ ```
62
+
63
+ Use before `read_session` to get a quick overview of what happened in a past session without loading full context.
64
+
65
+ ## When to Start New Session
66
+
67
+ - Completing distinct task from `bd ready`
68
+ - Token usage approaching 150k
69
+ - Switching phases (implementation → review → testing)
70
+ - After handoff (`/handoff <bead-id>`)
71
+
72
+ ## Session Workflow Pattern
73
+
74
+ ```
75
+ Session 1: Implement feature X (80k tokens)
76
+ ↓ close, update memory
77
+ Session 2: list_sessions() → read_session("last") → Refactor (60k tokens)
78
+
79
+ Session 3: read_session("previous") → Add tests (90k tokens)
80
+
81
+ Session 4: read_session refs → Final review (100k tokens)
82
+ ```
83
+
84
+ **Result**: 4 fresh contexts vs 1 degraded 330k context. Better performance, lower cost.
85
+
86
+ ## Context Transfer
87
+
88
+ Use all available sources:
89
+
90
+ 1. `read_session("last")` - Previous session work
91
+ 2. Git state - `git diff`, `git log` - Code changes
92
+ 3. Memory files - `.opencode/memory/*` - Persistent context
93
+ 4. Beads - `bd show <id>` - Task specs
94
+
95
+ **Don't**: Carry everything forward. Extract what's needed, discard the rest.
96
+
97
+ ## Pruning Strategy
98
+
99
+ When context grows large:
100
+
101
+ 1. **Discard** completed task outputs (read files you won't edit again)
102
+ 2. **Extract** key findings before discarding research
103
+ 3. **Summarize** complex investigations into memory files
104
+ 4. **Restart** session if above 85% and work is at a natural break
105
+
106
+ ## Anti-Patterns
107
+
108
+ - ❌ Running until context limit forces restart
109
+ - ❌ Carrying all previous reads forward "just in case"
110
+ - ❌ Not using memory files for cross-session persistence
111
+ - ❌ Re-reading the same files every session instead of extracting key info
@@ -0,0 +1,115 @@
1
+ ---
2
+ description: Use when choosing between search tools (LSP, ast-grep, grep, glob) or need tool reference - covers when to use each tool and detailed syntax
3
+ ---
4
+
5
+ # Tool Priority Skill
6
+
7
+ ## Priority Order
8
+
9
+ **LSP tools → AST-grep → Built-in tools**
10
+
11
+ 1. **LSP tools** - Semantic code intelligence (10 tools)
12
+ 2. `ast-grep` - Code search/replace (functions, patterns, imports, hooks)
13
+ 3. `grep` - Text search (logs, config, non-code files, simple strings)
14
+ 4. `glob` - File discovery by name pattern
15
+ 5. `read`, `edit`, `write` - File operations
16
+
17
+ **Rule**: Always `read` before `edit` to verify content.
18
+
19
+ ## Choosing the Right Tool
20
+
21
+ Ask: **"Am I looking for code structure or just text?"**
22
+
23
+ | Need | Tool | Example |
24
+ | ----------------- | ------------------------- | ------------------------------------- |
25
+ | Function calls | `ast-grep` | `pattern="fetchUser($$$)"` |
26
+ | Hook usage | `ast-grep` | `pattern="useState($$$)"` |
27
+ | Import statements | `ast-grep` | `pattern="import { $$ } from '$MOD'"` |
28
+ | Error messages | `grep` | `pattern="FATAL\|ERROR"` |
29
+ | Config values | `grep` | `pattern="API_KEY"` |
30
+ | TODO comments | `grep` | `pattern="TODO\|FIXME"` |
31
+ | Symbol type info | `lsp_lsp_hover` | Type signature at cursor |
32
+ | Definition jump | `lsp_lsp_goto_definition` | Source location |
33
+ | All usages | `lsp_lsp_find_references` | Before refactoring |
34
+ | Safe rename | `lsp_lsp_rename` | All references updated |
35
+
36
+ ## LSP Tools Reference
37
+
38
+ Semantic code intelligence via Language Server Protocol. **Uses `lsp_lsp_*` prefix** (built-in experimental).
39
+
40
+ ### Navigation & Understanding
41
+
42
+ | Tool | Purpose | When to Use |
43
+ | ---------------------------------------------------- | ------------------------------------- | --------------------------------- |
44
+ | `lsp_lsp_hover(filePath, line, character)` | Type info and docs at cursor | "What type is this variable?" |
45
+ | `lsp_lsp_goto_definition(filePath, line, character)` | Jump to where symbol is defined | "Where is this function defined?" |
46
+ | `lsp_lsp_find_references(filePath, line, character)` | Find all usages of a symbol | "What uses this function?" |
47
+ | `lsp_lsp_document_symbols(filePath)` | File outline (classes, functions) | "What's in this file?" |
48
+ | `lsp_lsp_workspace_symbols(query, filePath)` | Fuzzy search symbols across workspace | "Where is UserService defined?" |
49
+
50
+ ### Diagnostics
51
+
52
+ | Tool | Purpose | When to Use |
53
+ | ------------------------------------------ | ------------------------------------ | ------------------------ |
54
+ | `lsp_lsp_diagnostics(filePath, severity?)` | Errors/warnings from language server | "Are there type errors?" |
55
+
56
+ ### Refactoring
57
+
58
+ | Tool | Purpose | When to Use |
59
+ | ------------------------------------------------------------------------ | ----------------------------- | ---------------------------------- |
60
+ | `lsp_lsp_rename(filePath, line, character, newName)` | Rename symbol across codebase | "Rename this function safely" |
61
+ | `lsp_lsp_code_actions(filePath, startLine, startChar, endLine, endChar)` | Get available refactorings | "What refactorings are available?" |
62
+ | `lsp_lsp_code_action_apply(...)` | Apply a specific code action | Execute chosen refactoring |
63
+ | `lsp_lsp_organize_imports(filePath)` | Clean up and sort imports | "Fix imports" |
64
+
65
+ **Caveat**: LSP tools modify files directly. Re-read files before further edits.
66
+
67
+ ## AST-Grep Reference
68
+
69
+ Semantic code operations - smarter than regex.
70
+
71
+ ### Pattern Syntax
72
+
73
+ - `$NAME` - Matches any single AST node (identifier, expression, etc.)
74
+ - `$$$` - Matches zero or more nodes (for arguments, statements, etc.)
75
+
76
+ ### Search Examples
77
+
78
+ ```bash
79
+ # Find all console.log calls
80
+ ast-grep pattern="console.log($$$)"
81
+
82
+ # Find async functions
83
+ ast-grep pattern="async function $NAME($$$) { $$$ }"
84
+
85
+ # Find React hooks
86
+ ast-grep pattern="const [$S, $SET] = useState($$$)"
87
+
88
+ # Find try-catch blocks
89
+ ast-grep pattern="try { $$$ } catch ($E) { $$$ }"
90
+
91
+ # Find class definitions
92
+ ast-grep pattern="class $NAME { $$$ }"
93
+
94
+ # Find import statements
95
+ ast-grep pattern="import { $$ } from '$MOD'"
96
+ ```
97
+
98
+ ### Replace Examples
99
+
100
+ ```bash
101
+ # Rename function (dry run)
102
+ ast-grep pattern="oldFunc($$$)" rewrite="newFunc($$$)" dryRun=true
103
+
104
+ # Add await (apply)
105
+ ast-grep pattern="fetch($URL)" rewrite="await fetch($URL)" dryRun=false
106
+ ```
107
+
108
+ ## Research Tools
109
+
110
+ | Tool | Use When |
111
+ | -------------- | ------------------------------------------------------- |
112
+ | **context7** | Library docs (try first). Fast, external APIs. |
113
+ | **websearch** | Docs not in Context7, recent releases, troubleshooting. |
114
+ | **codesearch** | Real implementation patterns from GitHub. |
115
+ | **webfetch** | Specific URL user provided. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencodekit",
3
- "version": "0.12.2",
3
+ "version": "0.12.3",
4
4
  "description": "CLI tool for bootstrapping and managing OpenCodeKit projects",
5
5
  "type": "module",
6
6
  "repository": {