{"meta":{"title":"GitHub Copilot CLI 插件参考","intro":"查找 CLI 插件的命令和配置详细信息。","product":"GitHub Copilot","breadcrumbs":[{"href":"/zh/copilot","title":"GitHub Copilot"},{"href":"/zh/copilot/reference","title":"参考资料"},{"href":"/zh/copilot/reference/copilot-cli-reference","title":"\n              Copilot 命令行界面（CLI） 参考"},{"href":"/zh/copilot/reference/copilot-cli-reference/cli-plugin-reference","title":"命令行接口 (CLI) 插件参考"}],"documentType":"article"},"body":"# GitHub Copilot CLI 插件参考\n\n查找 CLI 插件的命令和配置详细信息。\n\n> \\[!NOTE]\n> 可以通过在终端中输入 `copilot plugin [SUBCOMMAND] --help` 来查找有关使用插件的帮助。\n\n## CLI 命令\n\n可以在终端中使用以下命令来管理插件 Copilot 命令行界面（CLI）。\n\n| 命令                                             | 说明                                                                          |\n| ---------------------------------------------- | --------------------------------------------------------------------------- |\n| `copilot plugin install SPECIFICATION`         | 安装插件。 请参阅下面 [`install` 命令的插件规范](#plugin-specification-for-install-command)。 |\n| `copilot plugin uninstall NAME`                | 删除插件                                                                        |\n| `copilot plugin list`                          | 列出已安装的插件                                                                    |\n| `copilot plugin update NAME`                   | 更新插件                                                                        |\n| `copilot plugin marketplace add SPECIFICATION` | 注册市场平台                                                                      |\n| `copilot plugin marketplace list`              | 列出已注册的交易平台                                                                  |\n| `copilot plugin marketplace browse NAME`       | 浏览应用市场插件                                                                    |\n| `copilot plugin marketplace remove NAME`       | 取消注册市场平台                                                                    |\n\n###\n\n```\n          `install` 命令的插件规范\n```\n\n| Format      | 示例                           | 说明            |\n| ----------- | ---------------------------- | ------------- |\n| Marketplace | `plugin@marketplace`         | 来自已注册市场的插件    |\n| GitHub      | `OWNER/REPO`                 | 存储库的根目录GitHub |\n| GitHub  子目录 | `OWNER/REPO:PATH/TO/PLUGIN`  | 存储库中的子目录      |\n| Git URL     | `https://github.com/o/r.git` | 任何 Git 网址     |\n| 本地路径        |                              |               |\n\n```\n          `./my-plugin` 或 `/abs/path`    | 本地目录 |\n```\n\n## `plugin.json`\n\n所有插件都包含一个插件目录，该目录至少包含一个位于 `plugin.json` 插件目录根目录的清单文件。 请参阅“[为 GitHub Copilot 命令行界面 (CLI) 创建插件](/zh/copilot/how-tos/copilot-cli/customize-copilot/plugins-creating)”。\n\n### 必填字段\n\n| 领域     | 类型  | 说明                                       |\n| ------ | --- | ---------------------------------------- |\n| `name` | 字符串 | kebab-case 插件名称（仅限字母、数字和连字符）。 最大 64 个字符。 |\n\n### 可选元数据字段\n\n| 领域            | 类型  | 说明                  |\n| ------------- | --- | ------------------- |\n| `description` | 字符串 | 简要说明。 最大 1024 个字符。  |\n| `version`     | 字符串 | 语义版本（例如 `1.0.0`， ）。 |\n| `author`      | 对象  |                     |\n\n```\n          `name` （必需）、 `email` （可选）、 `url` （可选）。 |\n```\n\n\\| `homepage`   | 字符串    | 插件主页 URL。 |\n\\| `repository` | 字符串    | 源存储库 URL。 |\n\\| `license`    | 字符串    | 许可证标识符（例如， `MIT`）。 |\n\\| `keywords`   | 字符串\\[]  | 搜索关键字。 |\n\\| `category`   | 字符串    | 插件类别。 |\n\\| `tags`       | 字符串\\[]  | 其他标记。 |\n\n### 组件路径字段\n\n这些命令告知 CLI 在何处查找插件的组件。 所有选项都是可选的。 如果省略，CLI 将使用默认约定。\n\n| 领域           | 类型            | 默认        | 说明                                      |\n| ------------ | ------------- | --------- | --------------------------------------- |\n| `agents`     | 字符串 \\| 字符串\\[] | `agents/` | 智能体目录的路径（`.agent.md` 文件）。               |\n| `skills`     | 字符串 \\| 字符串\\[] | `skills/` | 技能目录的路径（`SKILL.md` 文件）。                 |\n| `commands`   | 字符串 \\| 字符串\\[] | —         | 命令目录路径。                                 |\n| `hooks`      | string \\| 对象  | —         | 挂钩配置文件或内联挂钩对象的路径。                       |\n| `mcpServers` | string \\| 对象  | —         | MCP 配置文件的路径（例如 \"`.mcp.json`\"），或内联服务器定义。 |\n| `lspServers` | string \\| 对象  | —         | LSP 配置文件路径或内嵌服务器定义。                     |\n\n### 示例 `plugin.json` 文件\n\n```json copy\n{\n  \"name\": \"my-dev-tools\",\n  \"description\": \"React development utilities\",\n  \"version\": \"1.2.0\",\n  \"author\": {\n    \"name\": \"Jane Doe\",\n    \"email\": \"jane@example.com\"\n  },\n  \"license\": \"MIT\",\n  \"keywords\": [\"react\", \"frontend\"],\n  \"agents\": \"agents/\",\n  \"skills\": [\"skills/\", \"extra-skills/\"],\n  \"hooks\": \"hooks.json\",\n  \"mcpServers\": \".mcp.json\"\n}\n```\n\n## `marketplace.json`\n\n可以通过创建一个 `marketplace.json` 文件并将其保存到 `.github/plugin/` 存储库的目录来创建插件市场，供用户用来发现和安装插件。 还可以将 `marketplace.json` 文件存储在本地文件系统中。 例如，将文件保存为 `/PATH/TO/my-marketplace/.github/plugin/marketplace.json` 允许你使用以下命令将其添加到 CLI：\n\n```shell\ncopilot plugin marketplace add /PATH/TO/my-marketplace\n```\n\n> \\[!NOTE]\n> Copilot 命令行界面（CLI） 还会在 `.claude-plugin/` 目录中查找 `marketplace.json` 文件。\n\n有关详细信息，请参阅“[为 GitHub Copilot 命令行界面 (CLI) 创建插件市场](/zh/copilot/how-tos/copilot-cli/customize-copilot/plugins-marketplace)”。\n\n### 示例 `marketplace.json` 文件\n\n```json copy\n{\n  \"name\": \"my-marketplace\",\n  \"owner\": {\n    \"name\": \"Your Organization\",\n    \"email\": \"plugins@example.com\"\n  },\n  \"metadata\": {\n    \"description\": \"Curated plugins for our team\",\n    \"version\": \"1.0.0\"\n  },\n  \"plugins\": [\n    {\n      \"name\": \"frontend-design\",\n      \"description\": \"Create a professional-looking GUI ...\",\n      \"version\": \"2.1.0\",\n      \"source\": \"./plugins/frontend-design\"\n    },\n    {\n      \"name\": \"security-checks\",\n      \"description\": \"Check for potential security vulnerabilities ...\",\n      \"version\": \"1.3.0\",\n      \"source\": \"./plugins/security-checks\"\n    }\n  ]\n}\n```\n\n> \\[!NOTE]\n> 每个插件的 `source` 字段值是插件目录的路径，相对于存储库的根目录。 不需要在路径的开头使用 `./` 。 例如，`\"./plugins/plugin-name\"` 和 `\"plugins/plugin-name\"` 指向同一目录。\n\n###\n\n```\n          `marketplace.json` 字段\n```\n\n#### 顶级字段\n\n| 领域      | 类型  | 必需 | 说明                     |\n| ------- | --- | -- | ---------------------- |\n| `name`  | 字符串 | 是的 | 串式命名法的市场名称。 最大 64 个字符。 |\n| `owner` | 对象  | 是的 |                        |\n\n```\n          `{ name, email? }` — 市场所有者信息。 |\n```\n\n\\| `plugins`  | 数组    | 是的      | 插件条目列表（请参阅下表）。 |\n\\| `metadata` | 对象   | 否       | `{ description?, version?, pluginRoot? }` |\n\n#### 插件输入字段（数组中的 `plugins` 对象）\n\n| 领域            | 类型            | 必需 | 说明                                                                           |\n| ------------- | ------------- | -- | ---------------------------------------------------------------------------- |\n| `name`        | 字符串           | 是的 | kebab-case 插件名称。 最大 64 个字符。                                                  |\n| `source`      | string \\| 对象  | 是的 | 获取插件的途径（相对路径、GitHub 或 URL）。                                                  |\n| `description` | 字符串           | 否  | 插件说明。 最大 1024 个字符。                                                           |\n| `version`     | 字符串           | 否  | 插件版本。                                                                        |\n| `author`      | 对象            | 否  | `{ name, email?, url? }`                                                     |\n| `homepage`    | 字符串           | 否  | 插件主页 URL。                                                                    |\n| `repository`  | 字符串           | 否  | 源存储库 URL。                                                                    |\n| `license`     | 字符串           | 否  | 许可证标识符。                                                                      |\n| `keywords`    | 字符串\\[]        | 否  | 搜索关键字。                                                                       |\n| `category`    | 字符串           | 否  | 插件类别。                                                                        |\n| `tags`        | 字符串\\[]        | 否  | 其他标记。                                                                        |\n| `commands`    | 字符串 \\| 字符串\\[] | 否  | 命令目录路径。                                                                      |\n| `agents`      | 字符串 \\| 字符串\\[] | 否  | 代理目录路径。                                                                      |\n| `skills`      | 字符串 \\| 字符串\\[] | 否  | 技能目录路径。                                                                      |\n| `hooks`       | string \\| 对象  | 否  | 钩子配置的路径或内嵌钩子对象。                                                              |\n| `mcpServers`  | string \\| 对象  | 否  | MCP 配置或内联服务器定义的路径。                                                           |\n| `lspServers`  | string \\| 对象  | 否  | LSP 配置或内联服务器定义的路径。                                                           |\n| `strict`      | 布尔            | 否  | 当 `true`（默认值）时，插件必须符合完整的架构和验证规则。 当 `false` 时，使用宽松验证，允许更大的灵活性，特别是对于直接安装或旧版插件。 |\n\n## 文件位置\n\n| 物品     | 路径 |\n| ------ | -- |\n| 已安装的插件 |    |\n\n```\n          `~/.copilot/installed-plugins/MARKETPLACE/PLUGIN-NAME` （通过市场安装）和 `~/.copilot/installed-plugins/_direct/SOURCE-ID/` （直接安装） |\n```\n\n\\| 市场缓存    | 平台缓存目录： `~/.cache/copilot/marketplaces/` （Linux）、 `~/Library/Caches/copilot/marketplaces/` （macOS）。 可使用 `COPILOT_CACHE_HOME` 覆盖。 |\n\\| 插件清单      |\n`.plugin/plugin.json`、 `plugin.json`、 `.github/plugin/plugin.json`或 `.claude-plugin/plugin.json` （按此顺序选中） |\n\\| 市场清单 |\n`marketplace.json`、 `.plugin/marketplace.json`、 `.github/plugin/marketplace.json`或 `.claude-plugin/marketplace.json` （按此顺序选中） |\n\\| Agents               |\n`agents/`（默认值，可在清单中覆盖） |\n\\| 技能               |\n`skills/`（默认值，可在清单中覆盖） |\n\\| 挂钩配置  |\n`hooks.json` 或 `hooks/hooks.json` |\n\\| MCP 配置    |\n`.mcp.json`、`.github/mcp.json` |\n\\| LSP 配置    |\n`lsp.json` 或 `.github/lsp.json` |\n\n## 加载顺序和优先级\n\n如果安装多个插件，则某些自定义代理、技能、MCP 服务器或通过 MCP 服务器提供的工具可能具有重复的名称。 在这种情况下，CLI 会根据优先顺序确定要使用的组件。\n\n* **智能体和技能**采用“先找到者优先”的优先级。\n\n  如果项目级自定义代理或技能的名称或 ID 与所安装的插件中的名称或 ID 相同，则插件中的代理或技能将被无提示忽略。 该插件无法替代项目级或个人配置。 自定义代理使用其 ID 删除重复数据，该 ID 派生自其文件名（例如，如果文件命名 `reviewer.agent.md`，则代理 ID 为 `reviewer`）。 技能通过其在 `SKILL.md` 文件中的名称字段进行去重。\n\n* **MCP 服务器** 使用最后胜出优先权。\n\n  如果安装一个插件，该插件使用与已安装的 MCP 服务器相同的服务器名称来定义 MCP 服务器，则插件的定义优先。 可以使用 `--additional-mcp-config` 命令行选项替代使用插件安装的相同名称的 MCP 服务器配置。\n\n* **内置工具和智能体**始终存在，不能被用户定义的组件覆盖。\n\n下图说明了加载顺序和优先规则。\n\n```text\n┌──────────────────────────────────────────────────────────────────┐\n│  BUILT-IN - HARDCODED, ALWAYS PRESENT                            │\n│  • tools: bash, view, apply_patch, glob, rg, task, ...           │\n│  • agents: explore, task, code-review, general-purpose, research │\n└────────────────────────┬─────────────────────────────────────────┘\n                         │\n  ┌──────────────────────▼──────────────────────────────────────────────┐\n  │  CUSTOM AGENTS - FIRST LOADED IS USED (dedup by ID)                 │\n  │  1. ~/.copilot/agents/           (user, .github convention)         │\n  │  2. <project>/.github/agents/    (project)                          │\n  │  3. <parents>/.github/agents/    (inherited, monorepo)              │\n  │  4. <project>/.claude/agents/    (project)                          │\n  │  5. <parents>/.claude/agents/    (inherited, monorepo)              │\n  │  6. PLUGIN: agents/ dirs         (plugin, by install order)         │\n  │  7. Remote org/enterprise agents (remote, via API)                  │\n  └──────────────────────┬──────────────────────────────────────────────┘\n                         │\n  ┌──────────────────────▼──────────────────────────────────────────────┐\n  │  AGENT SKILLS - FIRST LOADED IS USED (dedup by name)                │\n  │  1. <project>/.github/skills/        (project)                      │\n  │  2. <project>/.agents/skills/        (project)                      │\n  │  3. <project>/.claude/skills/        (project)                      │\n  │  4. <parents>/.github/skills/ etc.   (inherited)                    │\n  │  5. ~/.copilot/skills/               (personal-copilot)             │\n  │  6. ~/.agents/skills/                (personal-agents)              │\n  │  7. PLUGIN: skills/ dirs             (plugin)                       │\n  │  8. COPILOT_SKILLS_DIRS env + config (custom)                       │\n  │  --- then commands (.claude/commands/), skills override commands ---│\n  └──────────────────────┬──────────────────────────────────────────────┘\n                         │\n  ┌──────────────────────▼──────────────────────────────────────────────┐\n  │  MCP SERVERS - LAST LOADED IS USED (dedup by server name)           │\n  │  1. ~/.copilot/mcp-config.json       (lowest priority)              │\n  │  2. PLUGIN: MCP configs              (plugins)                      │\n  │  3. --additional-mcp-config flag     (highest priority)             │\n  └─────────────────────────────────────────────────────────────────────┘\n```\n\n## 延伸阅读\n\n* [GitHub Copilot 命令行界面 (CLI)](/zh/copilot/how-tos/copilot-cli)\n* [GitHub Copilot CLI 命令参考](/zh/copilot/reference/copilot-cli-reference/cli-command-reference)\n* [GitHub Copilot 命令行界面编程参考](/zh/copilot/reference/copilot-cli-reference/cli-programmatic-reference)"}