-
Notifications
You must be signed in to change notification settings - Fork 57
Java SDK implementation #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@SteveSandersonMS hey Steve, here goes the Java implementation (based on the .NET and Node implementations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements a Java SDK for GitHub Copilot, providing a complete Java interface to interact with the Copilot CLI. The implementation follows the patterns established in the .NET and Node.js SDKs.
Changes:
- Adds comprehensive Java SDK with client, session, and event handling capabilities
- Implements JSON-RPC communication layer for CLI interaction
- Adds complete test suite with E2E test infrastructure using CapiProxy for deterministic testing
Reviewed changes
Copilot reviewed 95 out of 95 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| justfile | Adds Java build targets for formatting, linting, testing, and dependency installation |
| java/src/test/java/.../ToolsTest.java | Tests for custom tools functionality including invocation, error handling, and complex types |
| java/src/test/java/.../PermissionsTest.java | Tests for permission callback functionality with various approval scenarios |
| java/src/test/java/.../McpAndAgentsTest.java | Tests for MCP server and custom agent configuration |
| java/src/test/java/.../CopilotSessionTest.java | Comprehensive session lifecycle and interaction tests |
| java/src/test/java/.../CopilotClientTest.java | Client initialization and connection tests |
| java/src/test/java/.../E2ETestContext.java | Test harness managing CapiProxy, directories, and test environment |
| java/src/test/java/.../CapiProxy.java | Proxy server manager for deterministic API response replay |
| java/src/main/java/.../json/*.java | JSON model classes for requests, responses, and configuration |
| java/src/main/java/.../events/*.java | Event classes representing all session events from the CLI |
| java/src/main/java/.../JsonRpcClient.java | JSON-RPC 2.0 client for CLI communication |
| java/src/main/java/.../SdkProtocolVersion.java | Protocol version constants |
| java/.mvn/wrapper/maven-wrapper.properties | Maven wrapper configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } catch (Exception e) { | ||
| LOG.log(Level.SEVERE, "Error handling tool call", e); | ||
| try { | ||
| rpc.sendErrorResponse(Long.parseLong(requestId), -32603, e.getMessage()); |
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential uncaught 'java.lang.NumberFormatException'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback
|
|
||
| session.handlePermissionRequest(permissionRequest).thenAccept(result -> { | ||
| try { | ||
| rpc.sendResponse(Long.parseLong(requestId), Map.of("result", result)); |
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential uncaught 'java.lang.NumberFormatException'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback
| try { | ||
| PermissionRequestResult result = new PermissionRequestResult() | ||
| .setKind("denied-no-approval-rule-and-could-not-request-from-user"); | ||
| rpc.sendResponse(Long.parseLong(requestId), Map.of("result", result)); |
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential uncaught 'java.lang.NumberFormatException'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback
| detectedPort = Integer.parseInt(matcher.group(1)); | ||
| break; |
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential uncaught 'java.lang.NumberFormatException'.
| detectedPort = Integer.parseInt(matcher.group(1)); | |
| break; | |
| try { | |
| detectedPort = Integer.parseInt(matcher.group(1)); | |
| break; | |
| } catch (NumberFormatException e) { | |
| LOG.log(Level.WARNING, "Failed to parse port from CLI output: " + line, e); | |
| } |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Thanks @brunoborges. I hope you don't mind, but we've discussed it on the team, and for now we prefer other language SDKs to be handled as external projects by their own maintainers rather than being merged into this repo. The reason is we are trying to keep evolving both the CLI and its SDK at a high rate and we have a finite maintenance budget for per-language concerns. Handling four languages is already quite a process each time a new feature or API design is added. We'll soon clarify this in the README - i.e., that for now, we're not looking for extra languages to be added here, and would love to recommend external community-mainained projects for other repos. Would you mind closing this or is it OK if I do so? Do you plan to maintain this Java SDK in an external repo? If so we'd love to link to it from our README.md as a recommended approach for anyone using that technology stack. |
|
I'll move the project to my personal account. |
This Java implementation is based on the .NET and Node implementations.