Files
opencode-primer/.opencode/plugins/README.md
Wesam AbousaidandClaude Opus 4.8 29a69a35b0 docs: refresh for OpenCode v1.16.2 and fix correctness bugs
Update the guide to the current release (v1.16.2, 2026-06-05), verified
against opencode.ai/docs and github.com/anomalyco/opencode.

Correctness fixes:
- Plugins: tool.execute.before/after and shell.env are top-level hooks
  with an (input, output) signature, not event.type values. Rewrite both
  shipped example plugins plus the docs/migration examples so they fire.
- Permissions: bash glob maps resolve last-matching-rule-wins (catch-all
  "*" first), not most-specific-wins. Fix prose, reorder examples, and fix
  the shipped opencode.json (rm -rf* deny was shadowed by a later rm *).
- Drop non-existent permission keys repo_clone/repo_overview (15 keys, not
  17); fix steps (integer), deprecate maxSteps/tools, move reasoningEffort
  into model options; fix the `mise` install command.

Currency updates:
- v1.15.4 -> v1.16.2; add v1.16 highlights and a changelog section.
- Refresh OpenCode Zen lineup/pricing (Claude Opus 4.8, gpt-5.4,
  gemini-3.5-flash, qwen3.7, grok-build-0.1; correct free-tier IDs).
- Add `opencode mcp add`, run --replay, extra skill paths, shift+tab, and
  native GitHub commands; correct the specialist-prompt count; bump dates.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-08 19:00:39 +02:00

46 lines
1.4 KiB
Markdown

# `.opencode/plugins/`
Working examples of OpenCode plugins. Drop-in to any project — pure JS, no npm dependencies.
| Plugin | What it does |
|---|---|
| [`protect-secrets.js`](protect-secrets.js) | Blocks any tool call (read/write/bash) touching `.env*`, `secrets/`, `credentials*`, SSH keys, `.npmrc`, `.pypirc`. |
| [`audit-log.js`](audit-log.js) | Appends a one-line JSON record of every completed tool call to `.opencode/audit.jsonl`. |
## How they load
OpenCode auto-loads every `.js` / `.ts` file in `.opencode/plugins/` at session start. No registration step.
```bash
opencode # loads both plugins automatically
opencode --pure # skip all plugins for one run
```
## Audit how this plugin folder fires
```bash
tail -f .opencode/audit.jsonl # watch tool calls live
```
Sample line:
```json
{"ts":"2026-06-08T19:30:12.451Z","tool":"edit","arg_keys":["filePath","oldString","newString"],"title":"src/api/auth.ts"}
```
## Disabling temporarily
Three options:
1. Move the plugin file out of `.opencode/plugins/`.
2. Comment out the `export default` line.
3. Gate the body of the plugin on an env var:
```js
if (process.env.OPENCODE_DISABLE_AUDIT_LOG) return {};
```
## Writing your own
See [`docs/plugins.md`](../../docs/plugins.md) for the full API, event list, and more patterns (auto-format on save, idle notifications, etc.).