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

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

Originally created by @ethan-huo on GitHub (Aug 25, 2025).

Originally assigned to: @thdxr on GitHub.

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;
Originally created by @ethan-huo on GitHub (Aug 25, 2025). Originally assigned to: @thdxr on GitHub. 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: <path> 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) ```mdx --- 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) ```tsx // ./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; ```
yindo closed this issue 2026-02-16 17:31:11 -05:00
Author
Owner

@rekram1-node commented on GitHub (Aug 25, 2025):

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

@rekram1-node commented on GitHub (Aug 25, 2025): Not exactly sure what it will look like but user defined tools are on the roadmap
Author
Owner

@rekram1-node commented on GitHub (Dec 27, 2025):

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

@rekram1-node commented on GitHub (Dec 27, 2025): [automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1481