介绍
插件是用于扩展 Copilot 命令行界面(CLI) 功能的包。 可以从已向 CLI 注册的市场、Git 存储库或本地路径安装插件。
有关详细信息,请参阅“关于 GitHub Copilot 命令行界面 的插件”。
注意
可以通过在终端中输入 copilot plugin [SUBCOMMAND] --help 来查找有关使用插件的帮助。
查找插件
插件在市场中收集在一起。 市场是可从中浏览和安装的插件的注册表。 可以将市场添加到 CLI 配置,这样就可以使用 CLI 从该市场浏览和安装插件,请参阅 “添加插件市场”。 Copilot 默认注册了两个市场:copilot-plugins 和 awesome-copilot。
或者,可以在线搜索插件市场,然后直接从存储库添加插件。
若要使用 CLI 浏览其中一个已注册市场中的插件,
-
**检查当前已注册哪些市场平台。**在终端中,输入以下内容列出可用的市场:
Shell copilot plugin marketplace list
copilot plugin marketplace list或者,在交互式会话中,输入:
Copilot prompt /plugin marketplace list
/plugin marketplace list -
**浏览已注册市场中的插件。**从已注册的市场列表中,复制要浏览的市场的名称(例如,
awesome-copilot),然后输入以下命令,替换MARKETPLACE-NAME:Shell 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
例如,若要从 database-data-management 市场安装 awesome-copilot 插件,请输入:
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.json``.github/plugin目录中或存储库的根目录中包含.claude-plugin文件。
要直接从 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/PLUGIN-NAME/
添加插件市场
若要将市场添加到已注册市场列表,请在终端中输入以下命令:
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 存储库中,请使用 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选项添加到命令以删除市场,并卸载从该市场安装的所有插件。
延伸阅读
-
[AUTOTITLE](/copilot/how-tos/copilot-cli/customize-copilot/plugins-creating) -
[AUTOTITLE](/copilot/how-tos/copilot-cli/customize-copilot/plugins-marketplace)