opencodekit 0.16.17 → 0.16.18

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.
@@ -1,512 +1,79 @@
1
- # OpenCodeKit Template - Configuration Guide
1
+ # OpenCodeKit Template Configuration
2
2
 
3
- **Project-specific OpenCode configuration and custom extensions.**
3
+ This directory contains project-specific OpenCode configuration: agents, commands, skills, tools, plugins, and memory conventions.
4
4
 
5
- ---
5
+ ## Layout
6
6
 
7
- ## Quick Start
8
-
9
- ### 1. Environment Setup
10
-
11
- ```bash
12
- # Copy environment template
13
- cp .opencode/.env.example .opencode/.env
14
-
15
- # Add required API keys (minimum)
16
- # Edit .opencode/.env and add:
17
- CONTEXT7_API_KEY=your_context7_api_key_here
18
- EXA_API_KEY=your_exa_api_key_here
19
- ```
20
-
21
- ### 2. Verify Configuration
22
-
23
- ```bash
24
- # Start OpenCode (should load without errors)
25
- opencode
26
-
27
- # Test MCP services
28
- # In OpenCode chat: "search context7 for Next.js documentation"
29
- ```
30
-
31
- ---
32
-
33
- ## Directory Structure
34
-
35
- ```
7
+ ```text
36
8
  .opencode/
37
- ├── .env.example # Environment variables template (COPY TO .env)
38
- ├── README.md # This file
39
- ├── opencode.json # OpenCode configuration
40
- ├── dcp.jsonc # DCP plugin configuration (context pruning)
41
- ├── AGENTS.md # Global agent rules
42
-
43
- ├── agent/ # Custom agents (9 total)
44
- ├── command/ # Custom commands (14 workflows)
45
- ├── skill/ # Domain expertise (10 skills)
46
- ├── tool/ # Custom MCP tools (memory-*, observation, swarm-*)
47
- ├── plugin/ # Background plugins (memory, sessions, lsp, truncator)
48
- └── memory/ # Persistent context
49
- ```
50
-
51
- ---
52
-
53
- ## Context Management: DCP Plugin (Beta)
54
-
55
- This kit uses **Dynamic Context Pruning (DCP)** plugin for intelligent context management.
56
-
57
- ### Why DCP?
58
-
59
- - **AI-driven pruning**: `prune`, `distill`, and `compress` tools let the AI decide what to remove
60
- - **Zero-cost strategies**: Deduplication, supersede writes, and error purging run automatically
61
- - **Turn protection**: Prevents premature pruning of recent tool outputs
62
- - **File protection**: Critical config files are never auto-pruned
63
-
64
- ### Configuration
65
-
66
- DCP is configured via `.opencode/dcp.jsonc`:
67
-
68
- ```jsonc
69
- {
70
- "enabled": true,
71
- "pruneNotification": "off", // "minimal" or "detailed" for visibility
72
- "turnProtection": {
73
- "enabled": true,
74
- "turns": 4, // Protect tool outputs for 4 turns
75
- },
76
- "tools": {
77
- "prune": { "enabled": true }, // Remove noise without preservation
78
- "distill": { "enabled": true }, // Extract key findings before removing
79
- "compress": { "enabled": true }, // Collapse message ranges into summaries
80
- },
81
- "strategies": {
82
- "deduplication": { "enabled": true }, // Remove duplicate reads
83
- "supersedeWrites": { "enabled": true }, // Prune write inputs after read
84
- "purgeErrors": { "enabled": true, "turns": 4 }, // Remove error inputs
85
- },
86
- }
87
- ```
88
-
89
- ### DCP Commands
90
-
91
- - `/dcp` - Show available DCP commands
92
- - `/dcp context` - Token usage breakdown by category
93
- - `/dcp stats` - Cumulative pruning statistics
94
- - `/dcp sweep` - Prune all tools since last user message
95
- - `/dcp sweep 10` - Prune last 10 tools
96
-
97
- ### How It Works With OpenCode's Built-in Compaction
98
-
99
- OpenCode has internal compaction (not user-configurable via `opencode.json`):
100
-
101
- - **Built-in prune**: FIFO removal when context exceeds thresholds
102
- - **PRUNE_PROTECT = 40,000** tokens - Always keeps last 40K of tool outputs
103
- - **PRUNE_MINIMUM = 20,000** tokens - Only prunes if >20K tokens can be saved
104
- - **Protected tools**: `skill` outputs are never pruned
105
-
106
- **DCP complements this** by adding AI-driven, strategic pruning on top:
107
-
108
- | System | Role |
109
- | --------------------- | ---------------------------------------- |
110
- | **DCP tools** | Active management (AI decides what/when) |
111
- | **OpenCode built-in** | Passive safety net (automatic FIFO) |
112
-
113
- > **Note**: The `compaction` key is NOT in the official OpenCode config schema.
114
- > Built-in compaction behavior is controlled internally, not via user config.
115
-
116
- ### Protected Files
117
-
118
- These patterns are never auto-pruned (configured in `dcp.jsonc`):
119
-
120
- - `**/.env*` - Environment files
121
- - `**/AGENTS.md` - Agent rules
122
- - `**/.opencode/**` - OpenCode config
123
- - `**/.beads/**` - Task tracking
124
- - `**/package.json`, `**/tsconfig.json`, `**/biome.json` - Project config
125
-
126
- ### Cache Hit Trade-off
127
-
128
- DCP modifies message content before sending to LLMs, which affects prompt caching:
129
-
130
- - ~65% cache hit rate with DCP vs ~85% without
131
- - Token savings typically outweigh cache miss cost in long sessions
132
- - **Best for**: GitHub Copilot, Google Antigravity (request-based pricing)
133
-
134
- ---
135
-
136
- ## Required Environment Variables
137
-
138
- **Minimum setup (.opencode/.env):**
139
-
140
- ```bash
141
- # Required for core functionality
142
- CONTEXT7_API_KEY=your_context7_api_key_here # Library docs
143
- EXA_API_KEY=your_exa_api_key_here # Web search
9
+ ├── AGENTS.md # Global operating rules for agents
10
+ ├── opencode.json # OpenCode runtime configuration
11
+ ├── dcp.jsonc # Dynamic context pruning settings
12
+ ├── agent/ # Agent definitions (9)
13
+ ├── command/ # Slash commands (14)
14
+ ├── skill/ # Skill library used by agents/commands
15
+ ├── tool/ # Custom tools (memory, swarm, research, etc.)
16
+ ├── plugin/ # OpenCode plugins and plugin-local SDK code
17
+ ├── memory/ # Memory templates + project memory files
18
+ └── .env.example # Environment variable template
144
19
  ```
145
20
 
146
- **Optional (enable specific features):**
21
+ ## Quick Setup
147
22
 
148
23
  ```bash
149
- # Figma integration
150
- FIGMA_API_KEY=your_figma_api_key_here
151
-
152
- # Google Stitch (AI UI design)
153
- GOOGLE_CLOUD_PROJECT=your_gcp_project_id
154
- STITCH_ACCESS_TOKEN=$(gcloud auth print-access-token)
155
-
156
- # Cloud deployments (devops skill)
157
- CLOUDFLARE_API_TOKEN=your_token_here
158
- CLOUDFLARE_ACCOUNT_ID=your_account_id_here
159
- GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json
24
+ cp .opencode/.env.example .opencode/.env
160
25
  ```
161
26
 
162
- **Get API keys:**
163
-
164
- - Context7: https://context7.com
165
- - Exa: https://exa.ai
166
- - Figma: https://www.figma.com/developers/api#access-tokens
167
- - Google Cloud: https://console.cloud.google.com (for Stitch)
168
-
169
- ---
170
-
171
- ## Agent System (9 Custom Agents)
172
-
173
- **Primary Agents:**
174
-
175
- - **@build** - Main orchestrator (Kimi K2.5) - handles 70% of work
176
- - **@plan** - Architecture, multi-phase coordination
177
-
178
- **Specialist Subagents:**
179
-
180
- - **@general** - Fast subagent for small, well-defined tasks
181
- - **@explore** - Fast codebase search specialist
182
- - **@scout** - External research (library docs + GitHub patterns)
183
- - **@review** - Code review + debugging + security audit
184
- - **@vision** - UI/UX design: mockup, UI review, accessibility, aesthetics
185
- - **@looker** - Media extraction (images, PDFs, diagrams via OCR)
186
- - **@painter** - Image generation and editing (mockups, icons, assets)
187
-
188
- ---
189
-
190
- ## Custom Commands (14 workflows)
191
-
192
- **Invoke with `/` prefix:**
193
-
194
- - `/ship` - Ship code with verification
195
- - `/plan` - Create execution plan
196
- - `/start` - Start new work session
197
- - `/resume` - Resume from handoff
198
- - `/handoff` - Create session handoff
199
- - `/status` - Check project status
200
- - `/pr` - Create pull requests
201
- - `/review-codebase` - Full codebase review
202
- - `/research` - External research task
203
- - `/design` - Thoughtful design with brainstorming
204
- - `/ui-review` - UI/UX review
205
- - `/create` - Create new component/feature
206
- - `/init` - Initialize project
207
- - `/verify` - Verify changes
208
-
209
- **See:** `.opencode/command/` for all commands
27
+ Add the keys you actually need for enabled services.
210
28
 
211
- ---
29
+ ## Agent and Command Workflow
212
30
 
213
- ## Skills System (10 skills)
31
+ - Spec-first flow: `/create` -> `/start <id>` -> `/ship <id>`
32
+ - Use `/plan <id>` optionally for deeper implementation planning
33
+ - Use `/status` and `/resume` for continuity
214
34
 
215
- **Core:** beads-bridge, defense-in-depth, mockup-to-code, playwriter, resend, session-management, subagent-driven-development, vercel-deploy-claimable, verification-before-completion, writing-skills
35
+ ## Skills
216
36
 
217
- **Note:** Skills load via native `skill()` tool. Commands auto-load relevant expertise.
37
+ Skills live in `.opencode/skill/` and are loaded on demand with `skill({ name: "..." })`.
218
38
 
219
- ---
220
-
221
- ## Memory System (2-Layer Architecture)
222
-
223
- ```
224
- Memory (Permanent) → Beads (Multi-session) → Git (Audit Trail)
225
- .opencode/memory/ .beads/artifacts/ .git/
226
- ```
227
-
228
- **Memory:** Permanent knowledge, decisions, learnings (SQLite + FTS5)
229
- **Beads:** Multi-session tasks with spec/research/plan/review artifacts
230
- **Git:** Automatic execution history
231
-
232
- **See:** `AGENTS.md` for global rules and tool priority
233
-
234
- ---
39
+ - Core workflow examples: `beads`, `verification-before-completion`, `writing-plans`, `executing-plans`
40
+ - Debug/reliability examples: `systematic-debugging`, `root-cause-tracing`, `defense-in-depth`
41
+ - UI/design examples: `frontend-design`, `visual-analysis`, `accessibility-audit`
235
42
 
236
43
  ## Custom Tools
237
44
 
238
- ### Memory Tools
239
-
240
- - **memory-read** - Load previous context, templates
241
- - **memory-update** - Save learnings, handoffs
242
- - **memory-search** - FTS5 full-text search across observations
243
- - **memory-get** - Get full observation details by ID
244
- - **memory-timeline** - Chronological context around anchor
245
- - **memory-admin** - Database administration (maintenance, migration)
246
- - **observation** - Create structured observations (decision, bugfix, feature, etc.)
247
-
248
- ### Swarm Tool
249
-
250
- - **swarm** - Unified swarm coordination with operations:
251
- - `plan`: Task analysis with Kimi K2.5 PARL patterns
252
- - `delegate`: Create delegation packets for workers
253
- - `monitor`: Progress tracking for parallel tasks
254
- - `sync`: Beads ↔ OpenCode todos synchronization
255
-
256
- ### External Tools
257
-
258
- - **context7** - Library documentation lookup (resolve + query operations)
259
- - **grepsearch** - Search GitHub repos via grep.app
260
-
261
- ---
262
-
263
- ## MCP Services
264
-
265
- **Enabled by default:**
266
-
267
- 1. **context7** - Up-to-date library documentation (37.6k+ libraries)
268
- - Native tool: `context7({ operation: "resolve"|"query" })`
269
- - Step 1: Resolve library name → libraryId
270
- - Step 2: Query docs with the libraryId
271
-
272
- 2. **grepsearch** - Search 1M+ public GitHub repositories via grep.app
273
- - Native tool: `grepsearch({ query: "...", language: [...] })`
274
- - No API key needed (public service)
275
-
276
- **Skill-Embedded MCP (load on-demand):**
277
-
278
- 3. **figma** - Extract Figma layouts and design tokens
279
- - Requires: FIGMA_API_KEY
280
- - Use: `skill({ name: "figma" })` then `skill_mcp()`
45
+ Tools in `.opencode/tool/` are loaded by OpenCode and available to agents.
281
46
 
282
- 4. **playwright** - Browser automation for testing
283
- - No API key needed
284
- - Use: `skill({ name: "playwright" })` then `skill_mcp()`
47
+ - Memory: `memory-search`, `memory-get`, `memory-read`, `memory-update`, `memory-admin`, `memory-timeline`
48
+ - Observability/orchestration: `observation`, `swarm`, `action-queue`
49
+ - External research/docs: `context7`, `grepsearch`
285
50
 
286
- 5. **stitch** - Google Stitch AI-powered UI design generation
287
- - Requires: Google Cloud project with Stitch API enabled
288
- - Currently disabled in config (set `enabled: true` to activate)
51
+ ## Plugins
289
52
 
290
- ---
53
+ Current plugin source files in `.opencode/plugin/`:
291
54
 
292
- ## Stitch MCP Setup
55
+ - `memory.ts` - memory DB maintenance hooks + toast notifications
56
+ - `sessions.ts` - session browsing/search/summarization tools
57
+ - `compaction.ts` - compaction-time context injection and recovery protocol
58
+ - `swarm-enforcer.ts` - `/create` -> `/start` -> `/ship` workflow enforcement
59
+ - `skill-mcp.ts` - bridge for skill-scoped MCP servers/tools
60
+ - `copilot-auth.ts` - GitHub Copilot auth/provider integration
293
61
 
294
- Google Stitch MCP enables AI-powered UI design generation directly from OpenCode.
62
+ See `.opencode/plugin/README.md` for plugin details.
295
63
 
296
- ### Prerequisites
64
+ ## Guardrails
297
65
 
298
- 1. **Google Cloud CLI** installed: https://cloud.google.com/sdk/docs/install
299
- 2. **Google Cloud Project** with billing enabled
66
+ - Keep edits focused; avoid changing generated output under `dist/`.
67
+ - Never commit `.env` values or credentials.
68
+ - Prefer tool-based file operations over shell text manipulation in agent workflows.
69
+ - Use `br` commands to track multi-session work and keep bead state accurate.
300
70
 
301
- ### Setup Steps
302
-
303
- **Step 1: Authenticate with Google Cloud**
304
-
305
- ```bash
306
- # Login to Google Cloud
307
- gcloud auth login
308
-
309
- # Set your project
310
- gcloud config set project YOUR_PROJECT_ID
311
-
312
- # Set up Application Default Credentials
313
- gcloud auth application-default login
314
- ```
315
-
316
- **Step 2: Enable Stitch MCP**
317
-
318
- ```bash
319
- # Enable the Stitch API
320
- gcloud services enable stitch.googleapis.com --project=YOUR_PROJECT_ID
321
-
322
- # Enable Stitch for MCP access (required!)
323
- gcloud beta services mcp enable stitch.googleapis.com --project=YOUR_PROJECT_ID
324
- ```
325
-
326
- **Step 3: Set Environment Variables**
327
-
328
- Add to your `.opencode/.env` or export before starting OpenCode:
329
-
330
- ```bash
331
- # Google Cloud Project ID
332
- GOOGLE_CLOUD_PROJECT=your-project-id
333
-
334
- # Access token (refresh when expired - tokens last ~1 hour)
335
- STITCH_ACCESS_TOKEN=$(gcloud auth print-access-token)
336
- ```
337
-
338
- **Step 4: Enable in Config**
339
-
340
- Set `enabled: true` for stitch in `opencode.json`:
341
-
342
- ```jsonc
343
- "mcp": {
344
- "stitch": {
345
- "enabled": true,
346
- ...
347
- }
348
- }
349
- ```
350
-
351
- ### Available Stitch Tools
352
-
353
- | Tool | Description |
354
- | ---------------------------------- | --------------------------------- |
355
- | `stitch_list_projects` | List all your Stitch projects |
356
- | `stitch_create_project` | Create a new UI design project |
357
- | `stitch_get_project` | Get project details |
358
- | `stitch_list_screens` | List screens in a project |
359
- | `stitch_get_screen` | Get screen details with HTML code |
360
- | `stitch_generate_screen_from_text` | Generate UI from text prompt |
361
-
362
- ### Troubleshooting
363
-
364
- **"Stitch API not enabled":**
365
-
366
- ```bash
367
- gcloud beta services mcp enable stitch.googleapis.com --project=YOUR_PROJECT_ID
368
- ```
369
-
370
- **"Authentication failed":**
371
-
372
- ```bash
373
- # Refresh your access token (expires after ~1 hour)
374
- export STITCH_ACCESS_TOKEN=$(gcloud auth print-access-token)
375
- # Restart OpenCode
376
- ```
377
-
378
- ---
379
-
380
- ## Getting Started Examples
381
-
382
- ### Simple Task
383
-
384
- ```
385
- User: "Find all TypeScript files"
386
- @build: [executes directly]
387
- Result: 42 files found
388
- ```
389
-
390
- ### Research Task
391
-
392
- ```
393
- User: "Research Next.js 14 App Router"
394
- @build → @scout (docs + GitHub patterns)
395
- Result: Comprehensive research doc
396
- ```
397
-
398
- ### Complex Feature
399
-
400
- ```
401
- User: "Build auth system"
402
- @build → @plan (4 phases)
403
- @plan → @review (security audit)
404
- Result: Secure auth with tests
405
- ```
406
-
407
- ### Using Commands
408
-
409
- ```
410
- User: "/design implement dashboard"
411
- @build: [loads brainstorming skill]
412
- Result: Dashboard with shadcn/ui
413
- ```
414
-
415
- ---
416
-
417
- ## Troubleshooting
418
-
419
- **"Notifications not working" (WSL/Windows):**
420
-
421
- If running OpenCode in WSL, notifications require additional setup:
71
+ ## Verification Baseline
422
72
 
423
73
  ```bash
424
- # 1. Install dependencies
425
- sudo apt install -y libnotify-bin dunst
426
-
427
- # 2. Start dunst (run each time you open WSL terminal)
428
- dunst >/dev/null 2>&1 &
429
-
430
- # 3. Or add to ~/.bashrc for auto-start:
431
- if ! pgrep -x dunst >/dev/null; then
432
- dunst >/dev/null 2>&1 &
433
- fi
74
+ npm run typecheck
75
+ npm run lint
76
+ npm run test
434
77
  ```
435
78
 
436
- **"API key not found":**
437
-
438
- - Check .env location (.opencode/.env or ~/.config/opencode/.env)
439
- - No quotes around values (CONTEXT7_API_KEY=abc not "abc")
440
- - Restart OpenCode after changes
441
-
442
- **"MCP server failed":**
443
-
444
- - Check enabled: true in opencode.json
445
- - Verify command path (python, npx in PATH)
446
- - Check logs: ~/.config/opencode/logs/
447
-
448
- **"Skills not loading":**
449
-
450
- - Skills load via native `skill()` tool (auto-discovered)
451
- - Use /design to load brainstorming
452
- - Use /fix to load systematic-debugging
453
- - Check `.opencode/skill/` directory exists
454
-
455
- **"Context growing too fast":**
456
-
457
- - Run `/dcp context` to see token breakdown
458
- - Run `/dcp sweep` to prune recent tool outputs
459
- - Use `distill` tool to preserve key info while removing raw outputs
460
- - DCP handles active pruning; OpenCode's built-in handles passive FIFO
461
-
462
- ---
463
-
464
- ## Best Practices
465
-
466
- **Environment:**
467
-
468
- - Use .opencode/.env for project keys
469
- - Use ~/.config/opencode/.env for global keys
470
- - Never commit .env files
471
- - Rotate API keys regularly
472
-
473
- **Context Management (DCP):**
474
-
475
- - Use `/dcp context` to monitor token usage
476
- - Use `/dcp sweep` before starting new phases
477
- - Let DCP handle active pruning (turn protection prevents premature removal)
478
- - OpenCode's built-in compaction runs automatically as a safety net
479
-
480
- **Memory:**
481
-
482
- - Update memory after major phases
483
- - Document decisions in architecture notes
484
- - Log blockers in research findings
485
- - Keep research organized (YYYY-MM-DD-topic.md)
486
-
487
- **Delegation:**
488
-
489
- - Use @build for 70% of work
490
- - Delegate to @plan for 3+ phases
491
- - Use @review before deployment (code review + security)
492
- - Use @scout for library docs + GitHub patterns
493
- - Use @explore for codebase search
494
-
495
- ---
496
-
497
- ## Resources
498
-
499
- - **OpenCode Docs:** https://opencode.ai/docs
500
- - **DCP Plugin:** https://github.com/Opencode-DCP/opencode-dynamic-context-pruning
501
- - **Context7 API:** https://context7.com
502
- - **Exa API:** https://exa.ai
503
- - **Skills Documentation:** `.opencode/skill/`
504
- - **Architecture Guide:** `AGENTS.md`
505
-
506
- ---
507
-
508
- **OpenCodeKit v0.15.7**
509
- **Architecture:** Two-Layer (Memory + Beads + Git)
510
- **Context Management:** DCP Plugin (Beta) - AI-driven pruning
511
- **Package:** `npx opencodekit` to scaffold new projects
512
- **Last Updated:** February 4, 2026
79
+ For docs/config governance, run the validation scripts defined in `package.json`.