summaryrefslogtreecommitdiffhomepage
path: root/packages/web/src
diff options
context:
space:
mode:
authoradamelmore <[email protected]>2026-01-27 06:29:14 -0600
committeradamelmore <[email protected]>2026-01-27 06:29:20 -0600
commitb4e0cdbe8e41583345a290f90ccd17bd9dd927e7 (patch)
treead642439a6528e2e03855959776be3b3eda3bdf7 /packages/web/src
parent095328faf439fbdc62506f3653875fbfec5c60ab (diff)
downloadopencode-b4e0cdbe8e41583345a290f90ccd17bd9dd927e7.tar.gz
opencode-b4e0cdbe8e41583345a290f90ccd17bd9dd927e7.zip
docs(core): plugin tool context updates
Diffstat (limited to 'packages/web/src')
-rw-r--r--packages/web/src/content/docs/custom-tools.mdx9
-rw-r--r--packages/web/src/content/docs/plugins.mdx5
2 files changed, 9 insertions, 5 deletions
diff --git a/packages/web/src/content/docs/custom-tools.mdx b/packages/web/src/content/docs/custom-tools.mdx
index ef93a64e2..80a192369 100644
--- a/packages/web/src/content/docs/custom-tools.mdx
+++ b/packages/web/src/content/docs/custom-tools.mdx
@@ -120,12 +120,15 @@ export default tool({
args: {},
async execute(args, context) {
// Access context information
- const { agent, sessionID, messageID, directory } = context
- return `Agent: ${agent}, Session: ${sessionID}, Message: ${messageID}, Directory: ${directory}`
+ const { agent, sessionID, messageID, directory, worktree } = context
+ return `Agent: ${agent}, Session: ${sessionID}, Message: ${messageID}, Directory: ${directory}, Worktree: ${worktree}`
},
})
```
+Use `context.directory` for the session working directory.
+Use `context.worktree` for the git worktree root.
+
---
## Examples
@@ -157,7 +160,7 @@ export default tool({
b: tool.schema.number().describe("Second number"),
},
async execute(args, context) {
- const script = path.join(context.directory, ".opencode/tools/add.py")
+ const script = path.join(context.worktree, ".opencode/tools/add.py")
const result = await Bun.$`python3 ${script} ${args.a} ${args.b}`.text()
return result.trim()
},
diff --git a/packages/web/src/content/docs/plugins.mdx b/packages/web/src/content/docs/plugins.mdx
index 2033a9d90..ba530a6d9 100644
--- a/packages/web/src/content/docs/plugins.mdx
+++ b/packages/web/src/content/docs/plugins.mdx
@@ -269,8 +269,9 @@ export const CustomToolsPlugin: Plugin = async (ctx) => {
args: {
foo: tool.schema.string(),
},
- async execute(args, ctx) {
- return `Hello ${args.foo}!`
+ async execute(args, context) {
+ const { directory, worktree } = context
+ return `Hello ${args.foo} from ${directory} (worktree: ${worktree})`
},
}),
},