Skip to content

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

Closed

Description

@armedi

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions