docs: document the plural forms
This commit is contained in:
@@ -17,8 +17,8 @@ Tools are defined as **TypeScript** or **JavaScript** files. However, the tool d
|
||||
|
||||
They can be defined:
|
||||
|
||||
- Locally by placing them in the `.opencode/tool/` directory of your project.
|
||||
- Or globally, by placing them in `~/.config/opencode/tool/`.
|
||||
- Locally by placing them in the `.opencode/tools/` directory of your project.
|
||||
- Or globally, by placing them in `~/.config/opencode/tools/`.
|
||||
|
||||
---
|
||||
|
||||
@@ -26,7 +26,7 @@ They can be defined:
|
||||
|
||||
The easiest way to create tools is using the `tool()` helper which provides type-safety and validation.
|
||||
|
||||
```ts title=".opencode/tool/database.ts" {1}
|
||||
```ts title=".opencode/tools/database.ts" {1}
|
||||
import { tool } from "@opencode-ai/plugin"
|
||||
|
||||
export default tool({
|
||||
@@ -49,7 +49,7 @@ The **filename** becomes the **tool name**. The above creates a `database` tool.
|
||||
|
||||
You can also export multiple tools from a single file. Each export becomes **a separate tool** with the name **`<filename>_<exportname>`**:
|
||||
|
||||
```ts title=".opencode/tool/math.ts"
|
||||
```ts title=".opencode/tools/math.ts"
|
||||
import { tool } from "@opencode-ai/plugin"
|
||||
|
||||
export const add = tool({
|
||||
@@ -112,7 +112,7 @@ export default {
|
||||
|
||||
Tools receive context about the current session:
|
||||
|
||||
```ts title=".opencode/tool/project.ts" {8}
|
||||
```ts title=".opencode/tools/project.ts" {8}
|
||||
import { tool } from "@opencode-ai/plugin"
|
||||
|
||||
export default tool({
|
||||
@@ -136,7 +136,7 @@ You can write your tools in any language you want. Here's an example that adds t
|
||||
|
||||
First, create the tool as a Python script:
|
||||
|
||||
```python title=".opencode/tool/add.py"
|
||||
```python title=".opencode/tools/add.py"
|
||||
import sys
|
||||
|
||||
a = int(sys.argv[1])
|
||||
@@ -146,7 +146,7 @@ print(a + b)
|
||||
|
||||
Then create the tool definition that invokes it:
|
||||
|
||||
```ts title=".opencode/tool/python-add.ts" {10}
|
||||
```ts title=".opencode/tools/python-add.ts" {10}
|
||||
import { tool } from "@opencode-ai/plugin"
|
||||
|
||||
export default tool({
|
||||
@@ -156,7 +156,7 @@ export default tool({
|
||||
b: tool.schema.number().describe("Second number"),
|
||||
},
|
||||
async execute(args) {
|
||||
const result = await Bun.$`python3 .opencode/tool/add.py ${args.a} ${args.b}`.text()
|
||||
const result = await Bun.$`python3 .opencode/tools/add.py ${args.a} ${args.b}`.text()
|
||||
return result.trim()
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user