简介
插件是扩展 Copilot CLI 功能的软件包。您可以从已在 CLI 中注册的插件市场、Git 仓库或本地路径安装插件。
欲了解更多信息,请参阅 GitHub Copilot CLI 插件概述。
注意
您可以在终端中输入 copilot plugin [SUBCOMMAND] --help 来获取使用插件的帮助。
查找插件
插件会集中在插件市场中。插件市场是插件的注册表,您可以浏览并从中安装插件。您可以将插件市场添加到 CLI 配置,这样就可以使用 CLI 浏览并安装该市场中的插件——参见 添加插件市场。Copilot 默认已注册两个插件市场:copilot-plugins 和 awesome-copilot。
或者,您也可以在线搜索插件市场,然后直接从仓库添加插件。
使用 CLI 浏览已注册插件市场中的插件
-
检查当前已注册的插件市场。
在终端中输入以下命令列出可用的插件市场:
Shell copilot plugin marketplace list
copilot plugin marketplace list或者,在交互式会话中输入:
Copilot 提示 /plugin marketplace list
/plugin marketplace list -
浏览已注册插件市场中的插件。
从已注册的插件市场列表中,复制您想要浏览的插件市场名称,例如
awesome-copilot,然后输入以下命令,替换掉MARKETPLACE-NAMEShell copilot plugin marketplace browse MARKETPLACE-NAME
copilot plugin marketplace browse MARKETPLACE-NAME
安装插件
通常,您会从已注册的插件市场安装插件。不过,您也可以直接从 Git 仓库或本地路径安装插件。
有关如何注册其他插件市场的信息,请参阅 添加与移除插件市场。
从已注册的插件市场安装
copilot plugin install PLUGIN-NAME@MARKETPLACE-NAME
copilot plugin install PLUGIN-NAME@MARKETPLACE-NAME
例如,要从 awesome-copilot 市场安装 database-data-management 插件,请输入
copilot plugin install database-data-management@awesome-copilot
copilot plugin install database-data-management@awesome-copilot
或者,在交互式会话中输入:
/plugin install PLUGIN-NAME@MARKETPLACE-NAME
/plugin install PLUGIN-NAME@MARKETPLACE-NAME
直接从在线 Git 仓库安装
您可以直接从仓库安装插件,而无需通过已注册的插件市场。
要直接从 GitHub.com 上的仓库安装插件,请输入
copilot plugin install OWNER/REPO
copilot plugin install OWNER/REPO
要从 任意在线 Git 仓库 安装插件,请输入
copilot plugin install URL-OF-GIT-REPO
copilot plugin install URL-OF-GIT-REPO
例如,copilot plugin install https://gitlab.com/OWNER/REPO.git。
重要提示
要使这些命令生效,仓库必须在 .plugin、.github/plugin、.claude-plugin 目录或仓库根目录中包含 plugin.json 文件。
要直接从 GitHub.com 上的仓库安装插件,而 plugin.json 文件位于除 .github/plugin、.claude-plugin 或仓库根目录之外的其他位置——例如,直接从插件市场仓库 anthropics/claude-code 安装插件——请输入
copilot plugin install OWNER/REPO:PATH/TO/PLUGIN
copilot plugin install OWNER/REPO:PATH/TO/PLUGIN
其中 PATH/TO/PLUGIN 为从仓库根目录到包含 plugin.json、.github/plugin/plugin.json 或 .claude-plugin/plugin.json 的目录的路径。
例如,copilot plugin install anthropics/claude-code:plugins/frontend-design
从本地路径安装
copilot plugin install ./PATH/TO/PLUGIN
copilot plugin install ./PATH/TO/PLUGIN
管理已安装的插件
copilot plugin list # View installed plugins
copilot plugin update PLUGIN-NAME # Update plugin to latest version
copilot plugin uninstall PLUGIN-NAME # Remove plugin completely
插件存放位置
从插件市场安装的插件存放于:~/.copilot/installed-plugins/MARKETPLACE/PLUGIN-NAME/。直接安装的插件(例如,从本地路径)存放于:~/.copilot/installed-plugins/_direct/SOURCE-ID/。
添加插件市场
要向已注册的插件市场列表添加一个市场,请在终端中输入以下命令
copilot plugin marketplace add OWNER/REPO
copilot plugin marketplace add OWNER/REPO
其中 OWNER/REPO 标识已在 GitHub.com 上配置为 CLI 插件市场的仓库。
例如,要添加托管在 https://github.com/anthropics/claude-code 的 claude-code-plugins 市场,请输入
copilot plugin marketplace add anthropics/claude-code
copilot plugin marketplace add anthropics/claude-code
或者,在交互式会话中输入:
/plugin marketplace add OWNER/REPO
/plugin marketplace add OWNER/REPO
如果插件市场位于本地文件系统,而非 GitHub.com,请使用插件市场目录的路径替代 OWNER/REPO。例如
copilot plugin marketplace add /PATH/TO/MARKETPLACE-DIRECTORY
copilot plugin marketplace add /PATH/TO/MARKETPLACE-DIRECTORY
如果插件市场位于非 GitHub.com 托管的 Git 仓库,请使用该仓库的 URL。例如
copilot plugin marketplace add https://gitlab.com/OWNER/REPO.git
copilot plugin marketplace add https://gitlab.com/OWNER/REPO.git
移除插件市场
要从 CLI 中移除插件市场,请输入
copilot plugin marketplace remove MARKETPLACE-NAME
copilot plugin marketplace remove MARKETPLACE-NAME
或者,在交互式会话中
/plugin marketplace remove MARKETPLACE-NAME
/plugin marketplace remove MARKETPLACE-NAME
注意
- 添加插件市场时,使用已配置为插件市场的 GitHub 仓库的 OWNER/REPO 来引用该市场。而移除插件市场时,则使用在已注册插件市场列表中显示的市场名称。
- 如果尝试移除包含已安装插件的插件市场,命令将因错误而失败,并显示当前从该市场安装的插件列表。向命令添加
--force选项即可移除该市场并卸载所有从其安装的插件。