mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-08 09:49:19 +00:00
fix(docs): locale translations for nav elements and headings
This commit is contained in:
@@ -9,7 +9,7 @@ description: OpenCode を拡張する独自のプラグインを作成します
|
||||
|
||||
---
|
||||
|
||||
## プラグインを使用する
|
||||
## プラグインの使用
|
||||
|
||||
プラグインをロードするには 2 つの方法があります。
|
||||
|
||||
@@ -17,7 +17,7 @@ description: OpenCode を拡張する独自のプラグインを作成します
|
||||
|
||||
### ローカルファイルから
|
||||
|
||||
JavaScript または TypeScript ファイルをプラグイン ディレクトリに配置します。
|
||||
JavaScript または TypeScript ファイルをプラグインディレクトリに配置します。
|
||||
|
||||
- `.opencode/plugins/` - プロジェクトレベルのプラグイン
|
||||
- `~/.config/opencode/plugins/` - グローバルプラグイン
|
||||
@@ -26,9 +26,9 @@ JavaScript または TypeScript ファイルをプラグイン ディレクト
|
||||
|
||||
---
|
||||
|
||||
### npmから
|
||||
### npm から
|
||||
|
||||
構成ファイルで npm パッケージを指定します。
|
||||
設定ファイルで npm パッケージを指定します。
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
@@ -43,11 +43,11 @@ JavaScript または TypeScript ファイルをプラグイン ディレクト
|
||||
|
||||
---
|
||||
|
||||
### プラグインのインストール方法
|
||||
### プラグインのインストール
|
||||
|
||||
**npm プラグイン** は、起動時に Bun を使用して自動的にインストールされます。パッケージとその依存関係は `~/.cache/opencode/node_modules/` にキャッシュされます。
|
||||
|
||||
**ローカル プラグイン**は、プラグイン ディレクトリから直接ロードされます。外部パッケージを使用するには、config ディレクトリ内に `package.json` を作成するか ([Dependency](#dependencies) を参照)、プラグインを npm に公開して [config](/docs/config#plugins) に追加する] 必要があります。
|
||||
**ローカルプラグイン**は、プラグインディレクトリから直接ロードされます。外部パッケージを使用するには、config ディレクトリ内に `package.json` を作成するか ([Dependency](#dependencies) を参照)、プラグインを npm に公開して [config](/docs/config#plugins) に追加する必要があります。
|
||||
|
||||
---
|
||||
|
||||
@@ -55,25 +55,25 @@ JavaScript または TypeScript ファイルをプラグイン ディレクト
|
||||
|
||||
プラグインはすべてのソースからロードされ、すべてのフックが順番に実行されます。ロード順序は次のとおりです。
|
||||
|
||||
1. グローバル構成 (`~/.config/opencode/opencode.json`)
|
||||
2. プロジェクト構成 (`opencode.json`)
|
||||
1. グローバル設定 (`~/.config/opencode/opencode.json`)
|
||||
2. プロジェクト設定 (`opencode.json`)
|
||||
3. グローバルプラグインディレクトリ (`~/.config/opencode/plugins/`)
|
||||
4. プロジェクトプラグインディレクトリ (`.opencode/plugins/`)
|
||||
|
||||
同じ名前とバージョンを持つ重複した npm パッケージは 1 回ロードされます。ただし、似た名前のローカル プラグインと npm プラグインは両方とも別々にロードされます。
|
||||
同じ名前とバージョンを持つ重複した npm パッケージは 1 回ロードされます。ただし、似た名前のローカルプラグインと npm プラグインは両方とも別々にロードされます。
|
||||
|
||||
---
|
||||
|
||||
## プラグインを作成する
|
||||
|
||||
プラグインは、1 つ以上のプラグインをエクスポートする **JavaScript/TypeScript モジュール**です
|
||||
機能。各関数はコンテキスト オブジェクトを受け取り、フック オブジェクトを返します。
|
||||
プラグインは、1 つ以上のプラグインをエクスポートする **JavaScript/TypeScript モジュール**です。
|
||||
各関数はコンテキストオブジェクトを受け取り、フックオブジェクトを返します。
|
||||
|
||||
---
|
||||
|
||||
### 依存関係
|
||||
|
||||
ローカル プラグインとカスタム ツールは外部の npm パッケージを使用できます。必要な依存関係を含む `package.json` を config ディレクトリに追加します。
|
||||
ローカルプラグインとカスタムツールは外部の npm パッケージを使用できます。必要な依存関係を含む `package.json` を config ディレクトリに追加します。
|
||||
|
||||
```json title=".opencode/package.json"
|
||||
{
|
||||
@@ -118,14 +118,14 @@ export const MyPlugin = async ({ project, client, $, directory, worktree }) => {
|
||||
- `project`: 現在のプロジェクト情報。
|
||||
- `directory`: 現在の作業ディレクトリ。
|
||||
- `worktree`: git ワークツリーのパス。
|
||||
- `client`: AI と対話するためのopencode SDK クライアント。
|
||||
- `$`: Bun の [コマンドを実行するためのshell API](https://bun.com/docs/runtime/shell)。
|
||||
- `client`: AI と対話するための OpenCode SDK クライアント。
|
||||
- `$`: Bun の [コマンドを実行するためのシェル API](https://bun.com/docs/runtime/shell)。
|
||||
|
||||
---
|
||||
|
||||
### TypeScript のサポート
|
||||
|
||||
TypeScript プラグインの場合、プラグイン パッケージから型をインポートできます。
|
||||
TypeScript プラグインの場合、プラグインパッケージから型をインポートできます。
|
||||
|
||||
```ts title="my-plugin.ts" {1}
|
||||
import type { Plugin } from "@opencode-ai/plugin"
|
||||
@@ -188,11 +188,11 @@ export const MyPlugin: Plugin = async ({ project, client, $, directory, worktree
|
||||
- `session.status`
|
||||
- `session.updated`
|
||||
|
||||
#### Todoイベント
|
||||
#### ToDo イベント
|
||||
|
||||
- `todo.updated`
|
||||
|
||||
#### shellイベント
|
||||
#### シェルイベント
|
||||
|
||||
- `shell.env`
|
||||
|
||||
@@ -211,7 +211,7 @@ export const MyPlugin: Plugin = async ({ project, client, $, directory, worktree
|
||||
|
||||
## 例
|
||||
|
||||
ここでは、opencodeを拡張するために使用できるプラグインの例をいくつか示します。
|
||||
ここでは、OpenCode を拡張するために使用できるプラグインの例をいくつか示します。
|
||||
|
||||
---
|
||||
|
||||
@@ -235,14 +235,14 @@ export const NotificationPlugin = async ({ project, client, $, directory, worktr
|
||||
macOS 上で AppleScript を実行するために `osascript` を使用しています。ここでは通知を送信するために使用しています。
|
||||
|
||||
:::note
|
||||
OpenCode デスクトップ アプリを使用している場合は、応答の準備ができたとき、またはセッション エラーが発生したときにシステム通知を自動的に送信できます。
|
||||
OpenCode デスクトップアプリを使用している場合は、応答の準備ができたとき、またはセッションエラーが発生したときにシステム通知を自動的に送信できます。
|
||||
:::
|
||||
|
||||
---
|
||||
|
||||
### .env 保護
|
||||
### .env の保護
|
||||
|
||||
opencode が `.env` ファイルを読み取らないようにします。
|
||||
OpenCode が `.env` ファイルを読み取らないようにします。
|
||||
|
||||
```javascript title=".opencode/plugins/env-protection.js"
|
||||
export const EnvProtection = async ({ project, client, $, directory, worktree }) => {
|
||||
@@ -260,7 +260,7 @@ export const EnvProtection = async ({ project, client, $, directory, worktree })
|
||||
|
||||
### 環境変数を挿入する
|
||||
|
||||
すべてのshell 実行 (AI ツールとユーザーterminal) に環境変数を挿入します。
|
||||
すべてのシェル実行 (AI ツールとユーザーターミナル) に環境変数を挿入します。
|
||||
|
||||
```javascript title=".opencode/plugins/inject-env.js"
|
||||
export const InjectEnvPlugin = async () => {
|
||||
@@ -277,7 +277,7 @@ export const InjectEnvPlugin = async () => {
|
||||
|
||||
### カスタムツール
|
||||
|
||||
プラグインはopencodeにカスタム ツールを追加することもできます。
|
||||
プラグインは OpenCode にカスタムツールを追加することもできます。
|
||||
|
||||
```ts title=".opencode/plugins/custom-tools.ts"
|
||||
import { type Plugin, tool } from "@opencode-ai/plugin"
|
||||
@@ -300,13 +300,13 @@ export const CustomToolsPlugin: Plugin = async (ctx) => {
|
||||
}
|
||||
```
|
||||
|
||||
`tool` ヘルパーは、opencode が呼び出すことができるカスタム ツールを作成します。 Zod スキーマ関数を受け取り、次のようなツール定義を返します。
|
||||
`tool` ヘルパーは、OpenCode が呼び出すことができるカスタムツールを作成します。 Zod スキーマ関数を受け取り、次のようなツール定義を返します。
|
||||
|
||||
- `description`: ツールの機能
|
||||
- `args`: ツールの引数の Zod スキーマ
|
||||
- `execute`: ツールが呼び出されたときに実行される関数
|
||||
|
||||
カスタム ツールは、組み込みツールと並行してopencodeに使用できます。
|
||||
カスタムツールは、組み込みツールと並行して OpenCode で使用できます。
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user