跳至主要内容

GitHub Copilot CLI 插件参考

查找 CLI 插件的命令和配置细节。

注意

您可以在终端中输入 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来自已注册市场的插件
GitHubOWNER/REPOGitHub 仓库根目录
GitHub 子目录OWNER/REPO:PATH/TO/PLUGIN仓库中的子目录
Git URLhttps://github.com/o/r.git任意 Git URL
本地路径./my-plugin or /abs/path本地目录

plugin.json

所有插件都由一个插件目录组成,至少包含一个位于插件目录根部的清单文件 plugin.json。请参阅 创建 GitHub Copilot CLI 插件

必填字段

字段类型描述
namestring使用 kebab-case 的插件名称(仅限字母、数字和连字符)。最长 64 个字符。

可选元数据字段

字段类型描述
descriptionstring简要描述。最长 1024 个字符。
versionstring语义化版本(例如 1.0.0)。
authorobjectname(必填),email(可选),url(可选)。
homepagestring插件首页 URL。
repositorystring源码仓库 URL。
licensestring许可证标识符(例如 MIT)。
keywordsstring[]搜索关键词。
category (类别)string插件类别。
tagsstring[]附加标签。

组件路径字段

这些字段告诉 CLI 在哪里可以找到插件的组件。全部为可选项。如果省略,CLI 将使用默认约定。

字段类型默认值描述
agentsstring | string[]agents/指向代理目录(.agent.md 文件)的路径。
skillsstring | string[]skills/指向技能目录(SKILL.md 文件)的路径。
commandsstring | string[]指向命令目录的路径。
hooksstring | object指向 hooks 配置文件的路径,或内联 hooks 对象。
mcpServersstring | object指向 MCP 配置文件的路径(例如 .mcp.json),或内联服务器定义。
lspServersstring | object指向 LSP 配置文件的路径,或内联服务器定义。

示例 plugin.json 文件

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 文件

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"
    }
  ]
}

注意

source 字段的值为相对于仓库根目录的插件目录路径。无需在路径开头使用 ./。例如,"./plugins/plugin-name""plugins/plugin-name" 解析为相同的目录。

marketplace.json 字段

顶层字段

字段类型是否必填描述
namestring使用 kebab-case 的市场名称。最长 64 个字符。
ownerobject{ name, email? } — 市场所有者信息。
plugins数组 (array)插件条目列表(见下表)。
metadataobject{ description?, version?, pluginRoot? }

插件条目字段(plugins 数组中的对象)

字段类型是否必填描述
namestring使用 kebab-case 的插件名称。最长 64 个字符。
来源string | object插件获取位置(相对路径、GitHub 或 URL)。
descriptionstring插件描述。最长 1024 个字符。
versionstring插件版本。
authorobject{ name, email?, url? }
homepagestring插件首页 URL。
repositorystring源码仓库 URL。
licensestring许可证标识符。
keywordsstring[]搜索关键词。
category (类别)string插件类别。
tagsstring[]附加标签。
commandsstring | string[]指向命令目录的路径。
agentsstring | string[]指向代理目录的路径。
skillsstring | string[]指向技能目录的路径。
hooksstring | object指向 hooks 配置或内联 hooks 对象的路径。
mcpServersstring | object指向 MCP 配置或内联服务器定义的路径。
lspServersstring | object指向 LSP 配置或内联服务器定义的路径。
strictbooleantrue(默认值)时,插件必须符合完整的模式和验证规则。 当 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.jsonplugin.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)             │
  └─────────────────────────────────────────────────────────────────────┘

延伸阅读

© . This site is unofficial and not affiliated with GitHub, Inc.