Skip to content

Native TypeScript Toolsets for .opencode (code-first tools for subagents) #2237

Closed

Description

@ethan-huo

Add a native TypeScript tool extension so subagents can mount code-defined tools from the repo (e.g., .opencode/tool/*.ts). This complements MCP (generic) and plugins (hooks) with a simple, typed, code-first path.

Problem
• Plugins = lifecycle hooks; MCP = service/protocol overhead.
• No first-class, TS-native way to ship repo-scoped tools with OpenCode context.

Proposal
• Support toolset: in subagent frontmatter to dynamically import a TS module exporting a ToolSet>.
• Tools run with OpenCode context via AsyncLocalStorage (eg. opencode.use()).
• Keep authoring aligned with AI SDK tool().

Subagent config (example)

---
description: Agent desc
mode: subagent
model: vercel/google/gemini-2.5-pro
temperature: 0.1
tools:
  write: true
  edit: true
  bash: true
  read: true
  grep: true
  glob: true
toolset: ./tool/my-agent-toolset.ts
---
You are a social media operator.

Tool module (example)

// ./tool/my-agent-toolset.ts
import { tool, type ToolSet } from 'ai';

const tools: ToolSet = { midjourney:tool({...}),  twitter_post: tool({   execute() {   opencode.use().calService()  } }) };
export default tools;

Activity

  1. rekram1-node commented on Aug 25, 2025

    @rekram1-node
    Collaborator

    Not exactly sure what it will look like but user defined tools are on the roadmap

  2. rekram1-node commented on Dec 28, 2025

    @rekram1-node
    Collaborator

    [automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!

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