MyNixOS website logo

Custom tools for opencode.

This option can either be:

  • An attribute set defining tools
  • A path to a directory containing multiple tool files

If an attribute set is used, the attribute name becomes the tool filename, and the value is either:

  • Inline content as a string (creates opencode/tool/<name>.ts)
  • A path to a file (creates opencode/tool/<name>.ts or opencode/tool/<name>.js)

If a path is used, it is expected to contain tool files. The directory is symlinked to $XDG_CONFIG_HOME/opencode/tool/.

See https://opencode.ai/docs/tools/ for the documentation.

Declarations
Type
(attribute set of (strings concatenated with "\n" or absolute path)) or absolute path
Default
{ }
Example
{
  database-query = ''
    import { tool } from "@opencode-ai/plugin"

    export default tool({
      description: "Query the project database",
      args: {
        query: tool.schema.string().describe("SQL query to execute"),
      },
      async execute(args) {
        // Your database logic here
        return `Executed query: ${args.query}`
      },
    })
  '';

  # Or reference an existing file
  api-client = ./tools/api-client.ts;
}