defineSkill(input)
根據部分輸入驗證並返回完整的 SkillManifest。
import { defineSkill } from "@hitheo/sdk";
export default defineSkill({
name: "Inventory Check",
slug: "inventory-check",
version: "1.0.0",
description: "Real-time inventory lookup and reorder alerts",
category: "automation",
author: { name: "Acme Corp" },
systemPromptExtension: `
You are an inventory management specialist. When the user asks about
stock levels, use the check_stock tool.
`,
tools: [
{
name: "check_stock",
description: "Look up current stock levels by SKU",
inputSchema: {
type: "object",
properties: {
sku: { type: "string" },
warehouse: { type: "string" },
},
},
},
],
permissions: ["read:artifacts", "external:http", "execute:tools"],
modelPreference: "theo-1-reason",
trigger: { type: "keyword", config: { keywords: ["stock", "inventory"] } },
knowledge: ["./warehouse-rules.json"],
});
驗證
defineSkill 會驗證:
- Slug 格式 — 小寫字母數字加連字符,且首尾不能有連字符
- 版本號 — 必須遵循語義化版本規範(
1.0.0) - 工具名稱 — 小寫字母數字加下劃線
Error。
SkillManifestInput 字段
| 字段 | 類型 | 是否必填 | 說明 |
|---|---|---|---|
name | string | ✅ | 人類可讀的技能名稱 |
slug | string | ✅ | 唯一標識符(小寫、連字符) |
version | string | ✅ | 語義化版本號 |
description | string | ✅ | 簡短描述 |
category | SkillCategory | ✅ | "productivity"、"domain"、"integration"、"automation"、"creative" |
author | { name, email?, url? } | ✅ | 作者信息 |
systemPromptExtension | string | ✅ | 注入到 LLM 系統提示詞中的內容 |
tools | SkillToolInput[] | — | 工具定義 |
permissions | SkillPermission[] | — | 所需權限 |
knowledge | string[] | — | 隨附的知識文件路徑 |
modelPreference | string | — | 首選模型 ID |
trigger | SkillTriggerInput | — | 激活觸發器 |
hooks | { onInstall?, onUninstall? } | — | 生命週期鈎子 |
readme | string | — | Markdown 格式的 README |
changelog | string | — | Markdown 格式的更新日誌 |
license | string | — | 許可證標識符(默認:"MIT") |
repository | string | — | 源代碼倉庫 URL |
keywords | string[] | — | 搜索關鍵詞 |
