docs: document the plural forms
This commit is contained in:
@@ -19,8 +19,8 @@ There are two ways to load plugins.
|
||||
|
||||
Place JavaScript or TypeScript files in the plugin directory.
|
||||
|
||||
- `.opencode/plugin/` - Project-level plugins
|
||||
- `~/.config/opencode/plugin/` - Global plugins
|
||||
- `.opencode/plugins/` - Project-level plugins
|
||||
- `~/.config/opencode/plugins/` - Global plugins
|
||||
|
||||
Files in these directories are automatically loaded at startup.
|
||||
|
||||
@@ -57,8 +57,8 @@ Plugins are loaded from all sources and all hooks run in sequence. The load orde
|
||||
|
||||
1. Global config (`~/.config/opencode/opencode.json`)
|
||||
2. Project config (`opencode.json`)
|
||||
3. Global plugin directory (`~/.config/opencode/plugin/`)
|
||||
4. Project plugin directory (`.opencode/plugin/`)
|
||||
3. Global plugin directory (`~/.config/opencode/plugins/`)
|
||||
4. Project plugin directory (`.opencode/plugins/`)
|
||||
|
||||
Duplicate npm packages with the same name and version are loaded once. However, a local plugin and an npm plugin with similar names are both loaded separately.
|
||||
|
||||
@@ -85,7 +85,7 @@ Local plugins and custom tools can use external npm packages. Add a `package.jso
|
||||
|
||||
OpenCode runs `bun install` at startup to install these. Your plugins and tools can then import them.
|
||||
|
||||
```ts title=".opencode/plugin/my-plugin.ts"
|
||||
```ts title=".opencode/plugins/my-plugin.ts"
|
||||
import { escape } from "shescape"
|
||||
|
||||
export const MyPlugin = async (ctx) => {
|
||||
@@ -103,7 +103,7 @@ export const MyPlugin = async (ctx) => {
|
||||
|
||||
### Basic structure
|
||||
|
||||
```js title=".opencode/plugin/example.js"
|
||||
```js title=".opencode/plugins/example.js"
|
||||
export const MyPlugin = async ({ project, client, $, directory, worktree }) => {
|
||||
console.log("Plugin initialized!")
|
||||
|
||||
@@ -215,7 +215,7 @@ Here are some examples of plugins you can use to extend opencode.
|
||||
|
||||
Send notifications when certain events occur:
|
||||
|
||||
```js title=".opencode/plugin/notification.js"
|
||||
```js title=".opencode/plugins/notification.js"
|
||||
export const NotificationPlugin = async ({ project, client, $, directory, worktree }) => {
|
||||
return {
|
||||
event: async ({ event }) => {
|
||||
@@ -240,7 +240,7 @@ If you’re using the OpenCode desktop app, it can send system notifications aut
|
||||
|
||||
Prevent opencode from reading `.env` files:
|
||||
|
||||
```javascript title=".opencode/plugin/env-protection.js"
|
||||
```javascript title=".opencode/plugins/env-protection.js"
|
||||
export const EnvProtection = async ({ project, client, $, directory, worktree }) => {
|
||||
return {
|
||||
"tool.execute.before": async (input, output) => {
|
||||
@@ -258,7 +258,7 @@ export const EnvProtection = async ({ project, client, $, directory, worktree })
|
||||
|
||||
Plugins can also add custom tools to opencode:
|
||||
|
||||
```ts title=".opencode/plugin/custom-tools.ts"
|
||||
```ts title=".opencode/plugins/custom-tools.ts"
|
||||
import { type Plugin, tool } from "@opencode-ai/plugin"
|
||||
|
||||
export const CustomToolsPlugin: Plugin = async (ctx) => {
|
||||
@@ -292,7 +292,7 @@ Your custom tools will be available to opencode alongside built-in tools.
|
||||
|
||||
Use `client.app.log()` instead of `console.log` for structured logging:
|
||||
|
||||
```ts title=".opencode/plugin/my-plugin.ts"
|
||||
```ts title=".opencode/plugins/my-plugin.ts"
|
||||
export const MyPlugin = async ({ client }) => {
|
||||
await client.app.log({
|
||||
service: "my-plugin",
|
||||
@@ -311,7 +311,7 @@ Levels: `debug`, `info`, `warn`, `error`. See [SDK documentation](https://openco
|
||||
|
||||
Customize the context included when a session is compacted:
|
||||
|
||||
```ts title=".opencode/plugin/compaction.ts"
|
||||
```ts title=".opencode/plugins/compaction.ts"
|
||||
import type { Plugin } from "@opencode-ai/plugin"
|
||||
|
||||
export const CompactionPlugin: Plugin = async (ctx) => {
|
||||
@@ -335,7 +335,7 @@ The `experimental.session.compacting` hook fires before the LLM generates a cont
|
||||
|
||||
You can also replace the compaction prompt entirely by setting `output.prompt`:
|
||||
|
||||
```ts title=".opencode/plugin/custom-compaction.ts"
|
||||
```ts title=".opencode/plugins/custom-compaction.ts"
|
||||
import type { Plugin } from "@opencode-ai/plugin"
|
||||
|
||||
export const CustomCompactionPlugin: Plugin = async (ctx) => {
|
||||
|
||||
Reference in New Issue
Block a user