介绍
插件是用于扩展 Copilot 命令行界面(CLI) 功能的包。 请参阅“关于 GitHub Copilot 命令行界面 的插件”。
注意
可以通过在终端中输入 copilot plugin [SUBCOMMAND] --help 来查找有关使用插件的帮助。
插件结构
插件由具有特定结构的目录组成。 它必须至少在目录的根目录中包含一个plugin.json清单文件。 它还可以包含代理、技能、挂钩和 MCP 服务器配置的任意组合。
示例插件结构
my-plugin/
├── plugin.json # Required manifest
├── agents/ # Custom agents (optional)
│ └── helper.agent.md
├── skills/ # Skills (optional)
│ └── deploy/
│ └── SKILL.md
├── hooks.json # Hook configuration (optional)
└── .mcp.json # MCP server config (optional)
创建插件
-
为插件创建目录。
-
将
plugin.json清单文件添加到目录的根目录。**示例 `plugin.json` 文件**JSON { "name": "my-dev-tools", "description": "React development utilities", "version": "1.2.0", "author": { "name": "Jane Doe", "email": "[email protected]" }, "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": "[email protected]" }, "license": "MIT", "keywords": ["react", "frontend"], "agents": "agents/", "skills": ["skills/", "extra-skills/"], "hooks": "hooks.json", "mcpServers": ".mcp.json" }有关可包含在此文件中的完整字段集的详细信息,请参阅 GitHub Copilot CLI 插件参考。
-
通过为代理、技能、挂钩和 MCP 服务器配置创建适当的文件和目录,将某些组件添加到插件。
例如:
-
通过在子目录中创建
NAME.agent.md文件agents来添加代理。Markdown --- name: my-agent description: Helps with specific tasks tools: ["bash", "edit", "view"] --- You are a specialized assistant that...
--- name: my-agent description: Helps with specific tasks tools: ["bash", "edit", "view"] --- You are a specialized assistant that... -
通过在插件目录中创建一个名为
skills/NAME的子目录来添加技能,其中skills/NAME是技能的名称。 然后,在此子目录中,创建定义SKILL.md技能的文件。例如,若要创建“部署”技能,请创建
skills/deploy/SKILL.md:Markdown --- name: deploy description: Deploy the current project to... --- Instructions for the skill...
--- name: deploy description: Deploy the current project to... --- Instructions for the skill...
-
-
在本地安装插件,以便在开发插件时对其进行测试。
例如,其中
./my-plugin是您的插件目录的路径,请输入:Shell copilot plugin install ./my-plugin
copilot plugin install ./my-plugin -
查看已安装的插件列表,验证插件是否已成功加载:
Shell copilot plugin list
copilot plugin list或者,可以启动新的交互式会话并输入:
Copilot prompt /plugin list
/plugin list -
验证是否已正确加载定义的代理、技能、挂钩和 MCP 服务器配置。
例如,在交互式会话中,若要检查插件中定义的自定义代理是否已加载,请输入:
Copilot prompt /agent
/agent若要检查插件中定义的技能是否已加载,请输入:
Copilot prompt /skills list
/skills list -
使用插件组件提供的功能来验证每个组件是否按预期工作。
-
根据需要迭代您的插件开发。
重要
安装插件时,会缓存其组件,CLI 会从缓存中读取后续会话。 若要使对本地插件的更改生效,请再次安装插件。
Shell copilot plugin install ./my-plugin
copilot plugin install ./my-plugin -
测试完成后,可以通过输入以下内容卸载插件的本地版本:
Shell copilot plugin uninstall NAME
copilot plugin uninstall NAME注意
若要卸载插件,请使用插件清单文件字段中指定的
name插件plugin.json名称,而不是插件目录的路径。
分发插件
若要分发插件,可以将其添加到市场。 请参阅“为 GitHub Copilot 命令行界面 创建一个插件市场”。
延伸阅读
-
[AUTOTITLE](/copilot/how-tos/copilot-cli/customize-copilot/plugins-finding-installing) -
[AUTOTITLE](/copilot/reference/cli-plugin-reference)