summaryrefslogtreecommitdiffhomepage
path: root/packages/plugin/src/example.ts
diff options
context:
space:
mode:
authorDax <[email protected]>2025-09-18 03:58:21 -0400
committerGitHub <[email protected]>2025-09-18 03:58:21 -0400
commit3b6c0ec0b3b4f2224311888d8f7be178ed2335da (patch)
tree33d2de1a0f3860add12f1211d23b75565eba3e9e /packages/plugin/src/example.ts
parente9d902d84471faff3daf62455d6bc97750e4dc15 (diff)
downloadopencode-3b6c0ec0b3b4f2224311888d8f7be178ed2335da.tar.gz
opencode-3b6c0ec0b3b4f2224311888d8f7be178ed2335da.zip
support custom tools (#2668)
Diffstat (limited to 'packages/plugin/src/example.ts')
-rw-r--r--packages/plugin/src/example.ts20
1 files changed, 13 insertions, 7 deletions
diff --git a/packages/plugin/src/example.ts b/packages/plugin/src/example.ts
index 04c48c918..fd6a404d9 100644
--- a/packages/plugin/src/example.ts
+++ b/packages/plugin/src/example.ts
@@ -1,14 +1,20 @@
import { Plugin } from "./index"
+import { tool } from "./tool"
-export const ExamplePlugin: Plugin = async ({
- client: _client,
- $: _shell,
- project: _project,
- directory: _directory,
- worktree: _worktree,
-}) => {
+export const ExamplePlugin: Plugin = async (ctx) => {
return {
permission: {},
+ tool: {
+ mytool: tool((zod) => ({
+ description: "This is a custom tool tool",
+ args: {
+ foo: zod.string(),
+ },
+ async execute(args, ctx) {
+ return `Hello ${args.foo}!`
+ },
+ })),
+ },
async "chat.params"(_input, output) {
output.topP = 1
},