Install any skill in seconds. Free to start, no credit card required.
Get Started Free →說明如何在 OpenCode 平台中取得工具定義(Tool Definitions)。AI 可透過會話初始化時自動注入的 System Prompt 取得工具定義的完整內容,包括工具名稱、參數類型與描述說明。Use when users request (1) 取得工具定義, (2) Tool definition source, (3) Tool metadata, (4) OpenCode tool definitions, (5) 工具元數據取得.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 1% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 130% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 207% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 62% | 0% |
| case-12 | ✗→✓ | ▲ Improved | 117% | 0% |
本 skill 說明如何在 OpenCode 平台中取得工具定義(Tool Definitions)。
核心要點:
This skill explains how to obtain tool definitions (Tool Definitions) in the OpenCode platform.
Core Points:
Tool Definitions 是 OpenCode 平台中每個工具的結構化元數據(Metadata),包含:
| 元數據項目 | 說明 | |-----------|------| | 工具名稱(Function Name) | 工具的唯一識別符 | | 參數定義(Parameters Schema) | 工具接受的輸入參數結構與類型 | | 描述說明(Description) | 工具功能的文字描述 |
typescripttype tool_name = (_: { // 工具描述 param1: string, // 必填參數 param2?: number, // 可選參數 }) => any;
會話初始化
│
▼
OpenCode 平台載入工具配置
│
▼
系統將 Tool Definitions 注入到 System Prompt
│
▼
AI 在上下文(Context)中取得工具定義Tool Definitions 是作為 System Prompt(系統提示) 的一部分提供給 AI。當 OpenCode 會話開始時,系統會自動將所有已配置的工具定義注入到 AI 可以讀取的上下文中。
AI 可以透過以下方式取得工具定義的內容:
typescript// 當需要輸出工具定義時,AI 可以格式化為: type webstorm_open_file_in_editor = (_: { // Opens the specified file in the JetBrains IDE editor. // Requires a filePath parameter containing the path to the file to open. // The file path can be absolute or relative to the project root. filePath: string, projectPath?: string, }) => any;
┌─────────────────────────────────────────────────────────┐
│ OpenCode 會話 │
│ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ System Prompt(系統提示) │ │
│ │ │ │
│ │ ## Tools │ │
│ │ ## Available Tools │ │
│ │ type webstorm_open_file_in_editor = ... │ │
│ │ type webstorm_read_file = ... │ │
│ │ ... │ │
│ │ │ │
│ └─────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ AI(人工智能) │ │
│ │ │ │
│ │ ✅ 可以從 System Prompt 取得工具定義 │ │
│ │ ✅ 可以直接使用這些定義來執行任務 │ │
│ │ ✅ 可以將定義格式化輸出給用戶 │ │
│ │ │ │
│ └─────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘| 行為 | 狀態 | 說明 | |------|------|------| | 從 System Prompt 取得定義 | ✅ 可行 | 定義在系統提示中,AI 可以讀取 | | AI 使用定義執行任務 | ✅ 可行 | AI 可以直接調用工具 | | AI 展示完整定義給用戶 | ✅ 可行 | AI 可以將定義格式化輸出 |
當需要使用工具時,AI 無需「取得」定義,而是直接使用:
任務:開啟檔案
│
▼
AI 從上下文中知道 webstorm_open_file_in_editor 工具
│
▼
直接調用工具:webstorm_open_file_in_editor({ filePath: "..." })當需要展示工具定義時,AI 可以格式化輸出:
typescript// AI 從上下文中取得的原始定義可能類似: /** * Opens the specified file in the JetBrains IDE editor. * Requires a filePath parameter containing the path to the file to open. * The file path can be absolute or relative to the project root. */ type webstorm_open_file_in_editor = (_: { filePath: string, projectPath?: string, }) => any;
OpenCode 平台中常見的工具前綴:
| 前綴 | 應用場景 | |------|---------| | webstorm_ / webstorm-stream_ | WebStorm IDE 整合 | | chrome-devtools_ | Chrome 開發工具 | | pencil_ | Pencil 設計工具 | | arise_ | Arise 代理框架 | | context7_ | Context7 文檔查詢 |
當其他 AI 代理詢問如何取得 Tool Definitions 時,請告知:
> Tool Definitions 是 OpenCode 平台在會話初始化時,由 System Prompt 自動注入到 AI 上下文中的。AI 可以直接從上下文中取得這些定義的完整內容,包括工具名稱、參數類型和描述說明。
❌ 錯誤理解:
「我要怎麼取得 Tool Definitions?」
→ 不需要「取得」,定義已經在上下文中
✅ 正確理解:
「Tool Definitions 已經在 System Prompt 中了,
我可以直接使用它們,也可以將它們格式化輸出給用戶」Other measured skills in the registry, with their headline benchmark lift.