https://github.com/copilot-community-sdk/copilot-sdk-java
Java SDK for GitHub Copilot CLI
https://github.com/copilot-community-sdk/copilot-sdk-java
copilot github java
Last synced: 7 days ago
JSON representation
Java SDK for GitHub Copilot CLI
- Host: GitHub
- URL: https://github.com/copilot-community-sdk/copilot-sdk-java
- Owner: copilot-community-sdk
- License: mit
- Created: 2026-01-21T01:53:02.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2026-03-10T16:06:06.000Z (9 days ago)
- Last Synced: 2026-03-10T21:41:04.145Z (9 days ago)
- Topics: copilot, github, java
- Language: Java
- Homepage: https://copilot-community-sdk.github.io/copilot-sdk-java/
- Size: 27.4 MB
- Stars: 55
- Watchers: 1
- Forks: 10
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
- Support: SUPPORT.md
Awesome Lists containing this project
- awesome-java - Copilot SDK Java
README
# Copilot SDK for Java
[](https://github.com/copilot-community-sdk/copilot-sdk-java/actions/workflows/build-test.yml)
[](https://github.com/copilot-community-sdk/copilot-sdk-java/actions/workflows/deploy-site.yml)
[](https://copilot-community-sdk.github.io/copilot-sdk-java/snapshot/jacoco/index.html)
[](https://copilot-community-sdk.github.io/copilot-sdk-java/)
[](https://openjdk.org/)
[](https://opensource.org/licenses/MIT)
#### Latest release
[](https://github.com/copilot-community-sdk/copilot-sdk-java/releases)
[](https://github.com/copilot-community-sdk/copilot-sdk-java/releases)
[](https://central.sonatype.com/artifact/io.github.copilot-community-sdk/copilot-sdk)
[](https://copilot-community-sdk.github.io/copilot-sdk-java/latest/)
[](https://javadoc.io/doc/io.github.copilot-community-sdk/copilot-sdk/latest/index.html)
## Background
> ⚠️ **Disclaimer:** This is an **unofficial, community-driven SDK** and is **not supported or endorsed by GitHub**. This SDK may change in breaking ways. Use at your own risk.
Java SDK for programmatic control of GitHub Copilot CLI, enabling you to build AI-powered applications and agentic workflows.
## Installation
### Requirements
- Java 17 or later
- GitHub Copilot CLI 0.0.411-1 or later installed and in PATH (or provide custom `cliPath`)
### Maven
```xml
io.github.copilot-community-sdk
copilot-sdk
1.0.11
```
### Gradle
```groovy
implementation 'io.github.copilot-community-sdk:copilot-sdk:1.0.11'
```
## Quick Start
```java
import com.github.copilot.sdk.*;
import com.github.copilot.sdk.events.*;
import com.github.copilot.sdk.json.*;
import java.util.concurrent.CompletableFuture;
public class CopilotSDK {
public static void main(String[] args) throws Exception {
// Create and start client
try (var client = new CopilotClient()) {
client.start().get();
// Create a session
var session = client.createSession(
new SessionConfig().setOnPermissionRequest(PermissionHandler.APPROVE_ALL).setModel("claude-sonnet-4.5")).get();
// Handle assistant message events
session.on(AssistantMessageEvent.class, msg -> {
System.out.println(msg.getData().getContent());
});
// Handle session usage info events
session.on(SessionUsageInfoEvent.class, usage -> {
var data = usage.getData();
System.out.println("\n--- Usage Metrics ---");
System.out.println("Current tokens: " + (int) data.getCurrentTokens());
System.out.println("Token limit: " + (int) data.getTokenLimit());
System.out.println("Messages count: " + (int) data.getMessagesLength());
});
// Send a message
var completable = session.sendAndWait(new MessageOptions().setPrompt("What is 2+2?"));
// and wait for completion
completable.get();
}
}
}
```
## Try it with JBang
You can run the SDK without setting up a full Java project, by using [JBang](https://www.jbang.dev/).
See the full source of [`jbang-example.java`](jbang-example.java) for a complete example with more features like session idle handling and usage info events.
Or run it directly from the repository:
```bash
jbang https://github.com/copilot-community-sdk/copilot-sdk-java/blob/latest/jbang-example.java
```
## Documentation
📚 **[Full Documentation](https://copilot-community-sdk.github.io/copilot-sdk-java/)** — Complete API reference, advanced usage examples, and guides.
### Quick Links
- [Getting Started](https://copilot-community-sdk.github.io/copilot-sdk-java/latest/documentation.html)
- [Javadoc API Reference](https://copilot-community-sdk.github.io/copilot-sdk-java/latest/apidocs/)
- [MCP Servers Integration](https://copilot-community-sdk.github.io/copilot-sdk-java/latest/mcp.html)
- [Cookbook](src/site/markdown/cookbook/) — Practical recipes for common use cases
## Projects Using This SDK
| Project | Description |
|---------|-------------|
| [JMeter Copilot Plugin](https://github.com/brunoborges/jmeter-copilot-plugin) | JMeter plugin for AI-assisted load testing |
> Want to add your project? Open a PR!
## CI/CD Workflows
This project uses several GitHub Actions workflows for building, testing, releasing, and syncing with the upstream SDK.
See [WORKFLOWS.md](docs/WORKFLOWS.md) for a full overview and details on each workflow.
## Contributing
Contributions are welcome! Please see the [Contributing Guide](CONTRIBUTING.md) for details.
### Agentic Upstream Merge and Sync
This SDK tracks the official [Copilot SDK](https://github.com/github/copilot-sdk) (.NET reference implementation) and ports changes to Java. The upstream merge process is automated with AI assistance:
**Weekly automated sync** — A [scheduled GitHub Actions workflow](.github/workflows/weekly-upstream-sync.yml) runs every Monday at 5 AM ET. It checks for new upstream commits since the last merge (tracked in [`.lastmerge`](.lastmerge)), and if changes are found, creates an issue labeled `upstream-sync` and assigns it to the GitHub Copilot coding agent. Any previously open `upstream-sync` issues are automatically closed.
**Reusable prompt** — The merge workflow is defined in [`agentic-merge-upstream.prompt.md`](.github/prompts/agentic-merge-upstream.prompt.md). It can be triggered manually from:
- **VS Code Copilot Chat** — type `/agentic-merge-upstream`
- **GitHub Copilot CLI** — use `copilot` CLI with the same skill reference
### Development Setup
```bash
# Clone the repository
git clone https://github.com/copilot-community-sdk/copilot-sdk-java.git
cd copilot-sdk-java
# Enable git hooks for code formatting
git config core.hooksPath .githooks
# Build and test
mvn clean verify
```
The tests require the official [copilot-sdk](https://github.com/github/copilot-sdk) test harness, which is automatically cloned during build.
## Support
See [SUPPORT.md](SUPPORT.md) for how to file issues and get help.
## Code of Conduct
This project has adopted the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md). See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for details.
## Security
See [SECURITY.md](SECURITY.md) for reporting security vulnerabilities.
## License
MIT — see [LICENSE](LICENSE) for details.
## Acknowledgement
- Initially developed with Copilot and [Bruno Borges](https://www.linkedin.com/in/brunocborges/).
## Star History
[](https://www.star-history.com/#copilot-community-sdk/copilot-sdk-java&Date)
⭐ Drop a star if you find this useful!