The new custom tool ToolContext doesn't expose project, directory, and worktree as the docs example #1760

Closed
opened 2026-02-16 17:32:31 -05:00 by yindo · 0 comments
Owner

Originally created by @armedi on GitHub (Sep 18, 2025).

Originally assigned to: @rekram1-node on GitHub.

The custom tool docs page gives this example

import { tool } from "@opencode-ai/plugin"

export default tool({
  description: "Get project information",
  args: {},
  async execute(args, context) {
    // Access context information
    const { project, directory, worktree } = context
    return `Project: ${project.name}, Directory: ${directory}`
  },
})

where as in the source code at packages/plugin/src/tool.ts the context is only

export type ToolContext = {
  sessionID: string
  messageID: string
  agent: string
  abort: AbortSignal
}

I am writing a tool that need the information of the directory where opencode is running. How can I get this info?

UPDATE:

I figured I can just use process.cwd()

Originally created by @armedi on GitHub (Sep 18, 2025). Originally assigned to: @rekram1-node on GitHub. The custom tool docs page gives this example ```js import { tool } from "@opencode-ai/plugin" export default tool({ description: "Get project information", args: {}, async execute(args, context) { // Access context information const { project, directory, worktree } = context return `Project: ${project.name}, Directory: ${directory}` }, }) ``` where as in the source code at [packages/plugin/src/tool.ts](https://github.com/sst/opencode/blob/ffa5689885d0bc943c1bcd91cf1bf3706a52c3c5/packages/plugin/src/tool.ts#L3-L8) the context is only ```ts export type ToolContext = { sessionID: string messageID: string agent: string abort: AbortSignal } ``` I am writing a tool that need the information of the directory where opencode is running. How can I get this info? UPDATE: I figured I can just use `process.cwd()`
yindo closed this issue 2026-02-16 17:32:31 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1760