About building Copilot 扩展
Copilot 扩展 are integrations that expand the functionality of Copilot 对话助手, allowing developers to bring external tools, services, and custom behaviors into the Chat experience. You can use Copilot 扩展 to extend the capabilities of Copilot 对话助手 in a variety of ways, including:
- Querying documentation: A Copilot 扩展 can allow Copilot 对话助手 to query a third-party documentation service to find information about a specific topic.
- AI-assisted coding: A Copilot 扩展 can use a third-party AI model to provide code suggestions.
- Data retrieval: A Copilot 扩展 can allow Copilot 对话助手 to query a third-party data service to retrieve information about a specific topic.
- Action execution: A Copilot 扩展 can allow Copilot 对话助手 to execute a specific action, such as posting to a message board or updating a tracking item in an external system.
GitHub Copilot 扩展 are built with GitHub Apps. They are best suited for developers who want cross-platform compatibility and app management and support from GitHub.
About skillsets and agents
技能集和代理是通过 Copilot 扩展性平台 扩展 Copilot 的功能和上下文的两种方式。 它们支持将外部服务和 API 集成到 Copilot 对话助手 中,但每一种都适用于不同的用例,并提供不同程度的控制和复杂度:
- 技能集轻巧且精简,是为那些需要使用 Copilot 执行特定任务(例如,数据检索或简单操作)且希望以最少的设置来完成的开发人员而设计的。**** 它们会自动处理路由、提示构建、函数评估以及响应生成,这使得它们非常适合进行快速且直接的集成。 For more information about skillsets, see 关于 Copilot 扩展的技能组.
- 代理适用于那些需要完全控制请求处理方式以及响应生成方式的复杂集成****。 它们支持实现自定义逻辑,与其他 LLM 和/或 Copilot API 集成,管理对话上下文,并处理用户交互的各个方面。 虽然代理需要更多的工程和维护工作,但它们为复杂的工作流提供了最大的灵活性。 有关代理的详细信息,请参阅“关于 Copilot 扩展的代理”。
About context passing
You can allow your Copilot 扩展 to receive context from the editor, such as the currently opened file, by enabling the Read-only access level for the "Copilot Editor Context" permission in your GitHub App settings. See step 10 of Configuring your GitHub App.
The GitHub Copilot 扩展性平台 automatically handles messaging when implicit and explicit context is unavailable or unauthorized. To enable context passing, you are required to request permissions from users. To enable context passing, you are required to:
- Update your APIs to handle new reference types.
- Request permissions from users. When requesting permissions, follow these best practices:
- Clearly communicate what context you need and what you need it for.
- Implement appropriate error handling for unavailable context that your own application logic and API calls.
- If context is unavailable, provide value where possible without this data.
- Request only the minimum required permissions for your extension.
Context passing respects content exclusions, which refers to any files listed in your context exclusion settings, including files that begin with .
.
For more information about context passing, see 代理的上下文传递.
Using APIs in GitHub Copilot 扩展
Building GitHub Copilot 扩展 requires using the GitHub API. Optionally, the Copilot API can be used for additional capabilities. For details on request and response formatting, see the OpenAI API documentation.
注意
The Copilot API is available for Copilot 扩展 builders, but only GitHub Apps and VS Code Chat extensions can be used to access these endpoints.
Resources for building GitHub Copilot 扩展
GitHub provides a comprehensive toolkit for extension builders, with code samples, a CLI debugging tool, quickstart SDKs, and a user feedback repository. For more information, see the copilot-extensions organization on GitHub.
Before creating your own GitHub Copilot 扩展 from scratch, you may want to explore an existing Copilot 代理, then integrate it with a GitHub App to see how it works. GitHub provides a few example Copilot 代理 that you can clone and use as the basis for your own GitHub Copilot 扩展:
-
Blackbeard: A simple Copilot 代理 that responds to requests like a pirate, using Copilot's LLM API and special system prompts. It is a good starting point for learning how to build a GitHub Copilot 扩展. For more information, see the Blackbeard Copilot 扩展.
-
GitHub Models: A more complex Copilot 代理 that lets you ask about and interact with various LLMs listed on the GitHub Marketplace from within Copilot 对话助手. For more information, see the GitHub Models Copilot 扩展.
注意
GitHub Models are in 公共预览版 and subject to change.
-
Function calling: an example agent written in Go that demonstrates function calling and confirmation dialogues. For more information, see the Function calling extension.
-
RAG extension: an example agent written in Go that demonstrates a simple implementation of retrieval augmented generation. For more information, see the RAG extension.
-
Preview SDK: An SDK that simplifies the process of building GitHub Copilot 扩展 by handling request verification, response formatting, and API interactions. It allows builders to focus on their extension's core functionality rather than boilerplate, by streamlining the integration of tools, APIs, and data sources into Copilot 对话助手. For more information, see the Preview SDK.
About building 支持 Copilot 的 VS Code 聊天参与者
注意
The GitHub documentation focuses on building GitHub Copilot 扩展, not 支持 Copilot 的 VS Code 聊天参与者.
You can build a Copilot 扩展 that is exclusive and native to Visual Studio Code, called a 支持 Copilot 的 VS Code 聊天参与者.
GitHub Copilot 扩展 and 支持 Copilot 的 VS Code 聊天参与者 use the same backend platform to route requests to extensions. Both provide similar end-user experiences, integrate with Copilot 对话助手, and can leverage the Copilot API or other LLMs.
While they share similarities, below are several key differences:
- GitHub Copilot 扩展 can be used in any editor where extensions are supported, while 支持 Copilot 的 VS Code 聊天参与者 are only available in Visual Studio Code.
- GitHub Copilot 扩展 are server-side extensions, requiring server infrastructure to build. These extensions provide a built-in connection to your GitHub workspaces, as set by your organization administrator.
- 支持 Copilot 的 VS Code 聊天参与者 are client-side extensions that have more access to VS Code's features and APIs, allowing more editor-specific interactions like accessing local workspace data, manipulating Visual Studio Code's interface, and read/write access to local files. They do not require server infrastructure.
- Because 支持 Copilot 的 VS Code 聊天参与者 are local to the user's machine, they cannot be controlled by the Copilot policies of an organization or enterprise on GitHub.com.
- 支持 Copilot 的 VS Code 聊天参与者 are published to the VS Code Marketplace, not the GitHub Marketplace.
支持 Copilot 的 VS Code 聊天参与者 are best suited for developers who want to build extensions that use VS Code-specific APIs and functionality, or extend existing VS Code extensions.
For more information on 支持 Copilot 的 VS Code 聊天参与者, see Chat extensions in the Visual Studio Code documentation.
Indemnity for Copilot 扩展
Copilot 扩展 are not covered by GitHub Copilot’s indemnity policy. However, this exclusion applies only to issues that arise within extension chat threads.
Installing and using extensions does not affect indemnity coverage for any issues that occur while using other Copilot features such as code completion and chat.