注意
您可以在终端中输入 copilot plugin [SUBCOMMAND] --help 来获取使用插件的帮助。
CLI 命令
您可以在终端中使用以下命令来管理 Copilot CLI 的插件。
| 命令 | 描述 |
|---|---|
copilot plugin install SPECIFICATION | 安装插件。请参阅下面的 用于 install 命令的插件规范。 |
copilot plugin uninstall NAME | 卸载插件 |
copilot plugin list | 列出已安装的插件 |
copilot plugin update NAME | 更新插件 |
copilot plugin marketplace add SPECIFICATION | 注册一个市场 |
copilot plugin marketplace list | 列出已注册的市场 |
copilot plugin marketplace browse NAME | 浏览市场插件 |
copilot plugin marketplace remove NAME | 注销市场 |
用于 install 命令的插件规范
| 格式 | 示例 | 描述 |
|---|---|---|
| 市场 | plugin@marketplace | 来自已注册市场的插件 |
| GitHub | OWNER/REPO | GitHub 仓库根目录 |
| GitHub 子目录 | OWNER/REPO:PATH/TO/PLUGIN | 仓库中的子目录 |
| Git URL | https://github.com/o/r.git | 任意 Git URL |
| 本地路径 | ./my-plugin or /abs/path | 本地目录 |
plugin.json
所有插件都由一个插件目录组成,至少包含一个位于插件目录根部的清单文件 plugin.json。请参阅 创建 GitHub Copilot CLI 插件。
必填字段
| 字段 | 类型 | 描述 |
|---|---|---|
name | string | 使用 kebab-case 的插件名称(仅限字母、数字和连字符)。最长 64 个字符。 |
可选元数据字段
| 字段 | 类型 | 描述 |
|---|---|---|
description | string | 简要描述。最长 1024 个字符。 |
version | string | 语义化版本(例如 1.0.0)。 |
author | object | name(必填),email(可选),url(可选)。 |
homepage | string | 插件首页 URL。 |
repository | string | 源码仓库 URL。 |
license | string | 许可证标识符(例如 MIT)。 |
keywords | string[] | 搜索关键词。 |
category (类别) | string | 插件类别。 |
tags | string[] | 附加标签。 |
组件路径字段
这些字段告诉 CLI 在哪里可以找到插件的组件。全部为可选项。如果省略,CLI 将使用默认约定。
| 字段 | 类型 | 默认值 | 描述 |
|---|---|---|---|
agents | string | string[] | agents/ | 指向代理目录(.agent.md 文件)的路径。 |
skills | string | string[] | skills/ | 指向技能目录(SKILL.md 文件)的路径。 |
commands | string | string[] | — | 指向命令目录的路径。 |
hooks | string | object | — | 指向 hooks 配置文件的路径,或内联 hooks 对象。 |
mcpServers | string | object | — | 指向 MCP 配置文件的路径(例如 .mcp.json),或内联服务器定义。 |
lspServers | string | object | — | 指向 LSP 配置文件的路径,或内联服务器定义。 |
示例 plugin.json 文件
{
"name": "my-dev-tools",
"description": "React development utilities",
"version": "1.2.0",
"author": {
"name": "Jane Doe",
"email": "jane@example.com"
},
"license": "MIT",
"keywords": ["react", "frontend"],
"agents": "agents/",
"skills": ["skills/", "extra-skills/"],
"hooks": "hooks.json",
"mcpServers": ".mcp.json"
}
{
"name": "my-dev-tools",
"description": "React development utilities",
"version": "1.2.0",
"author": {
"name": "Jane Doe",
"email": "jane@example.com"
},
"license": "MIT",
"keywords": ["react", "frontend"],
"agents": "agents/",
"skills": ["skills/", "extra-skills/"],
"hooks": "hooks.json",
"mcpServers": ".mcp.json"
}
marketplace.json
您可以通过创建 marketplace.json 文件并将其保存到仓库的 .github/plugin/ 目录来创建插件市场——人们可以用它来发现并安装您的插件。您也可以将 marketplace.json 文件存放在本地文件系统中。例如,将文件保存为 /PATH/TO/my-marketplace/.github/plugin/marketplace.json 可使您能够使用以下命令将其添加到 CLI。
copilot plugin marketplace add /PATH/TO/my-marketplace
注意
Copilot CLI 还会在 .claude-plugin/ 目录中查找 marketplace.json 文件。
欲了解更多信息,请参阅 为 GitHub Copilot CLI 创建插件市场。
示例 marketplace.json 文件
{
"name": "my-marketplace",
"owner": {
"name": "Your Organization",
"email": "plugins@example.com"
},
"metadata": {
"description": "Curated plugins for our team",
"version": "1.0.0"
},
"plugins": [
{
"name": "frontend-design",
"description": "Create a professional-looking GUI ...",
"version": "2.1.0",
"source": "./plugins/frontend-design"
},
{
"name": "security-checks",
"description": "Check for potential security vulnerabilities ...",
"version": "1.3.0",
"source": "./plugins/security-checks"
}
]
}
{
"name": "my-marketplace",
"owner": {
"name": "Your Organization",
"email": "plugins@example.com"
},
"metadata": {
"description": "Curated plugins for our team",
"version": "1.0.0"
},
"plugins": [
{
"name": "frontend-design",
"description": "Create a professional-looking GUI ...",
"version": "2.1.0",
"source": "./plugins/frontend-design"
},
{
"name": "security-checks",
"description": "Check for potential security vulnerabilities ...",
"version": "1.3.0",
"source": "./plugins/security-checks"
}
]
}
注意
source 字段的值为相对于仓库根目录的插件目录路径。无需在路径开头使用 ./。例如,"./plugins/plugin-name" 和 "plugins/plugin-name" 解析为相同的目录。
marketplace.json 字段
顶层字段
| 字段 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
name | string | 是 | 使用 kebab-case 的市场名称。最长 64 个字符。 |
owner | object | 是 | { name, email? } — 市场所有者信息。 |
plugins | 数组 (array) | 是 | 插件条目列表(见下表)。 |
metadata | object | 否 | { description?, version?, pluginRoot? } |
插件条目字段(plugins 数组中的对象)
| 字段 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
name | string | 是 | 使用 kebab-case 的插件名称。最长 64 个字符。 |
来源 | string | object | 是 | 插件获取位置(相对路径、GitHub 或 URL)。 |
description | string | 否 | 插件描述。最长 1024 个字符。 |
version | string | 否 | 插件版本。 |
author | object | 否 | { name, email?, url? } |
homepage | string | 否 | 插件首页 URL。 |
repository | string | 否 | 源码仓库 URL。 |
license | string | 否 | 许可证标识符。 |
keywords | string[] | 否 | 搜索关键词。 |
category (类别) | string | 否 | 插件类别。 |
tags | string[] | 否 | 附加标签。 |
commands | string | string[] | 否 | 指向命令目录的路径。 |
agents | string | string[] | 否 | 指向代理目录的路径。 |
skills | string | string[] | 否 | 指向技能目录的路径。 |
hooks | string | object | 否 | 指向 hooks 配置或内联 hooks 对象的路径。 |
mcpServers | string | object | 否 | 指向 MCP 配置或内联服务器定义的路径。 |
lspServers | string | object | 否 | 指向 LSP 配置或内联服务器定义的路径。 |
strict | boolean | 否 | 当 true(默认值)时,插件必须符合完整的模式和验证规则。 当 false 时,使用宽松的验证,提供更大的灵活性——尤其适用于直接安装或旧版插件。 |
文件位置
| 项目 | 路径 |
|---|---|
| 已安装的插件 | ~/.copilot/installed-plugins/MARKETPLACE/PLUGIN-NAME(通过市场安装)以及 ~/.copilot/installed-plugins/_direct/SOURCE-ID/(直接安装) |
| 市场缓存 | 平台缓存目录:~/.cache/copilot/marketplaces/(Linux),~/Library/Caches/copilot/marketplaces/(macOS)。可通过 COPILOT_CACHE_HOME 覆盖。 |
| 插件清单 | .plugin/plugin.json、plugin.json、.github/plugin/plugin.json 或 .claude-plugin/plugin.json(按此顺序检查) |
| 市场清单 | marketplace.json、.plugin/marketplace.json、.github/plugin/marketplace.json 或 .claude-plugin/marketplace.json(按此顺序检查) |
| 代理 | agents/(默认,可在清单中覆盖) |
| 技能 | skills/(默认,可在清单中覆盖) |
| 钩子配置 | hooks.json or hooks/hooks.json |
| MCP 配置 | .mcp.json, .github/mcp.json |
| LSP 配置 | lsp.json or .github/lsp.json |
加载顺序和优先级
如果您安装了多个插件,可能会出现自定义代理、技能、MCP 服务器或通过 MCP 服务器提供的工具名称重复的情况。在此情形下,CLI 会依据优先级顺序决定使用哪个组件。
-
代理和技能 使用先到先得的优先级。
如果您在项目级别拥有与已安装插件中相同名称或 ID 的自定义代理或技能,则插件中的该代理或技能会被静默忽略。插件无法覆盖项目级或个人配置。自定义代理会根据其 ID 去重,ID 来自文件名(例如文件名为
reviewer.agent.md时,代理 ID 为reviewer)。技能则通过其SKILL.md文件中的 name 字段去重。 -
MCP 服务器 使用后到先得的优先级。
如果您安装的插件定义了与已安装的 MCP 服务器同名的服务器,则插件的定义优先。您可以使用
--additional-mcp-config命令行选项来覆盖使用插件安装的同名 MCP 服务器配置。 -
内置工具和代理始终存在,且不能被用户定义的组件覆盖。
下图展示了加载顺序和优先级规则。
┌──────────────────────────────────────────────────────────────────┐
│ BUILT-IN - HARDCODED, ALWAYS PRESENT │
│ • tools: bash, view, apply_patch, glob, rg, task, ... │
│ • agents: explore, task, code-review, general-purpose, research │
└────────────────────────┬─────────────────────────────────────────┘
│
┌──────────────────────▼──────────────────────────────────────────────┐
│ CUSTOM AGENTS - FIRST LOADED IS USED (dedup by ID) │
│ 1. ~/.copilot/agents/ (user, .github convention) │
│ 2. <project>/.github/agents/ (project) │
│ 3. <parents>/.github/agents/ (inherited, monorepo) │
│ 4. ~/.claude/agents/ (user, .claude convention) │
│ 5. <project>/.claude/agents/ (project) │
│ 6. <parents>/.claude/agents/ (inherited, monorepo) │
│ 7. PLUGIN: agents/ dirs (plugin, by install order) │
│ 8. Remote org/enterprise agents (remote, via API) │
└──────────────────────┬──────────────────────────────────────────────┘
│
┌──────────────────────▼──────────────────────────────────────────────┐
│ AGENT SKILLS - FIRST LOADED IS USED (dedup by name) │
│ 1. <project>/.github/skills/ (project) │
│ 2. <project>/.agents/skills/ (project) │
│ 3. <project>/.claude/skills/ (project) │
│ 4. <parents>/.github/skills/ etc. (inherited) │
│ 5. ~/.copilot/skills/ (personal-copilot) │
│ 6. ~/.agents/skills/ (personal-agents) │
│ 7. ~/.claude/skills/ (personal-claude) │
│ 8. PLUGIN: skills/ dirs (plugin) │
│ 9. COPILOT_SKILLS_DIRS env + config (custom) │
│ --- then commands (.claude/commands/), skills override commands ---│
└──────────────────────┬──────────────────────────────────────────────┘
│
┌──────────────────────▼──────────────────────────────────────────────┐
│ MCP SERVERS - LAST LOADED IS USED (dedup by server name) │
│ 1. ~/.copilot/mcp-config.json (lowest priority) │
│ 2. PLUGIN: MCP configs (plugins) │
│ 3. --additional-mcp-config flag (highest priority) │
└─────────────────────────────────────────────────────────────────────┘