GeezerVison is showing github.com — support wildcard matching tool names in config · mmacia/opencode@1ec71e4
File treeExpand file treeCollapse file tree Open diff view settings web/src/content/docs/docs
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: opencode.json +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | { | 2 | 2 | "$schema": "https://opencode.ai/config.json", | | 3 | + "agent": { | | 4 | + "build": {} | | 5 | + }, | 3 | 6 | "mcp": { | 4 | 7 | "context7": { | 5 | 8 | "type": "remote", | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/session/index.ts +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -42,6 +42,7 @@ import { ToolRegistry } from "../tool/registry" | 42 | 42 | import { Plugin } from "../plugin" | 43 | 43 | import { Agent } from "../agent/agent" | 44 | 44 | import { Permission } from "../permission" | | 45 | +import { Wildcard } from "../util/wildcard" | 45 | 46 |
| 46 | 47 | export namespace Session { | 47 | 48 | const log = Log.create({ service: "session" }) | @@ -768,7 +769,7 @@ export namespace Session { | 768 | 769 | mergeDeep(input.tools ?? {}), | 769 | 770 | ) | 770 | 771 | for (const item of await ToolRegistry.tools(input.providerID, input.modelID)) { | 771 | | - if (enabledTools[item.id] === false) continue | | 772 | + if (Wildcard.all(item.id, enabledTools) === false) continue | 772 | 773 | tools[item.id] = tool({ | 773 | 774 | id: item.id as any, | 774 | 775 | description: item.description, | @@ -829,7 +830,7 @@ export namespace Session { | 829 | 830 | } | 830 | 831 |
| 831 | 832 | for (const [key, item] of Object.entries(await MCP.tools())) { | 832 | | - if (enabledTools[key] === false) continue | | 833 | + if (Wildcard.all(key, enabledTools) === false) continue | 833 | 834 | const execute = item.execute | 834 | 835 | if (!execute) continue | 835 | 836 | item.execute = async (args, opts) => { | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/util/wildcard.ts +14Lines changed: 14 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import { sortBy, pipe } from "remeda" | | 2 | + | 1 | 3 | export namespace Wildcard { | 2 | 4 | export function match(str: string, pattern: string) { | 3 | 5 | const regex = new RegExp( | @@ -11,4 +13,16 @@ export namespace Wildcard { | 11 | 13 | ) | 12 | 14 | return regex.test(str) | 13 | 15 | } | | 16 | + | | 17 | + export function all(input: string, patterns: Record<string, any>) { | | 18 | + const sorted = pipe(patterns, Object.entries, sortBy([([key]) => key.length, "asc"], [([key]) => key, "asc"])) | | 19 | + let result = undefined | | 20 | + for (const [pattern, value] of sorted) { | | 21 | + if (match(input, pattern)) { | | 22 | + result = value | | 23 | + continue | | 24 | + } | | 25 | + } | | 26 | + return result | | 27 | + } | 14 | 28 | } |
Collapse file Copy file name to clipboardExpand all lines: packages/web/src/content/docs/docs/agents.mdx +17-1Lines changed: 17 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -318,6 +318,22 @@ Control which tools are available in this agent with the `tools` config. You can | 318 | 318 | } | 319 | 319 | ``` | 320 | 320 |
| | 321 | +You can also use wildcards to control multiple tools at once. For example, to disable all tools from an MCP server: | | 322 | + | | 323 | +```json title="opencode.json" | | 324 | +{ | | 325 | + "agent": { | | 326 | + "readonly": { | | 327 | + "tools": { | | 328 | + "mymcp_*": false, | | 329 | + "write": false, | | 330 | + "edit": false | | 331 | + } | | 332 | + } | | 333 | + } | | 334 | +} | | 335 | +``` | | 336 | + | 321 | 337 | If no tools are specified, all tools are enabled by default. | 322 | 338 |
| 323 | 339 | --- | @@ -371,7 +387,7 @@ For example, with OpenAI's reasoning models, you can control the reasoning effor | 371 | 387 | "agent": { | 372 | 388 | "deep-thinker": { | 373 | 389 | "description": "Agent that uses high reasoning effort for complex problems", | 374 | | - "model": "openai/gpt-5-turbo", | | 390 | + "model": "openai/gpt-5-turbo", | 375 | 391 | "reasoningEffort": "high", | 376 | 392 | "textVerbosity": "low" | 377 | 393 | } | |
|