Skip to content

Commit b40a6f2

Browse files
edburnsCopilot
andauthored
Move java to monorepo. Phase 05: Cross-Cutting Updates (#1441)
* Preserve 80-java-monorepo-add-01-remove-before-merge directory * Complete Phase 03 * Start iterating Phase 05 * WIP: Phase 05 * WIP Phase 05: #1423 * Add Java scenarios: Phase 1 (size S, #1-#16) Add 16 Java scenario implementations covering: - modes: default, minimal - prompts: system-message, reasoning-effort - sessions: streaming, infinite-sessions - tools: no-tools, tool-filtering - transport: stdio, tcp - callbacks: user-input - auth: byok-openai, byok-azure, byok-anthropic - bundling: fully-bundled, app-direct-server All scenarios compile successfully with mvn compile. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add Java scenarios: Phase 2 (size M, #17-#26) Add 10 Java scenario implementations covering: - callbacks: hooks (pre/post tool use, session start/end), permissions - prompts: attachments - sessions: concurrent-sessions, session-resume - tools: custom-agents, tool-overrides, mcp-servers, skills - auth: gh-app (OAuth device flow) All scenarios compile successfully with mvn compile. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update Phase 05 * Ready to have agent do docs-validation.yml * Use correct day * Phase 05 Update docs-validation.yml to include Java code snippets. * Prepare for phase 05 review * Prepare for phase 05 review: remove prompts. * Fix Java scenarios: update imports after package rename (com.github.copilot.sdk -> com.github.copilot) * Abide by @patniko #1448 and remove scenario-builds.yml. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address review feedback: idempotent Java validation, path filter, README links - Copy .java files instead of moving them so validation is idempotent - Add java/pom.xml to docs-validation.yml path trigger - Update README Java install links to ./java/README.md anchors Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Change Java distribution from 'temurin' to 'microsoft' --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c5d9b82 commit b40a6f2

28 files changed

Lines changed: 509 additions & 144 deletions

.github/workflows/codegen-check.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ on:
1414
- 'go/generated_*.go'
1515
- 'go/rpc/**'
1616
- 'rust/src/generated/**'
17+
- 'sdk-protocol-version.json'
18+
- 'java/src/main/java/com/github/copilot/SdkProtocolVersion.java'
1719
- '.github/workflows/codegen-check.yml'
1820
workflow_dispatch:
1921

@@ -78,4 +80,13 @@ jobs:
7880
git diff
7981
exit 1
8082
fi
83+
84+
- name: Verify Java protocol version matches
85+
run: |
86+
EXPECTED=$(jq -r '.version' sdk-protocol-version.json)
87+
ACTUAL=$(grep -oP 'LATEST\(\K[0-9]+' java/src/main/java/com/github/copilot/SdkProtocolVersion.java)
88+
if [ "$EXPECTED" != "$ACTUAL" ]; then
89+
echo "::error::Java SDK protocol version ($ACTUAL) does not match sdk-protocol-version.json ($EXPECTED). Java manages its own SdkProtocolVersion.java via java/scripts/codegen/. Update it to match."
90+
exit 1
91+
fi
8192
echo "✅ Generated files are up-to-date"

.github/workflows/docs-validation.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
- 'python/copilot/**'
1010
- 'go/**/*.go'
1111
- 'dotnet/src/**'
12+
- 'java/src/**'
13+
- 'java/pom.xml'
1214
- 'scripts/docs-validation/**'
1315
- '.github/workflows/docs-validation.yml'
1416
workflow_dispatch:
@@ -126,3 +128,32 @@ jobs:
126128
- name: Extract and validate C#
127129
working-directory: scripts/docs-validation
128130
run: npm run extract && npm run validate:cs
131+
132+
validate-java:
133+
name: "Validate Java"
134+
if: github.event.repository.fork == false
135+
runs-on: ubuntu-latest
136+
steps:
137+
- uses: actions/checkout@v6
138+
139+
- uses: actions/setup-node@v6
140+
with:
141+
node-version: 22
142+
143+
- uses: actions/setup-java@v4
144+
with:
145+
distribution: 'microsoft'
146+
java-version: '17'
147+
cache: 'maven'
148+
149+
- name: Install SDK to local repo
150+
working-directory: java
151+
run: mvn install -DskipTests -q
152+
153+
- name: Install validation dependencies
154+
working-directory: scripts/docs-validation
155+
run: npm ci
156+
157+
- name: Extract and validate Java
158+
working-directory: scripts/docs-validation
159+
run: npm run extract && npm run validate:java

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
},
2020
"[go]": {
2121
"editor.defaultFormatter": "golang.go"
22-
}
22+
},
23+
"java.configuration.updateBuildConfiguration": "automatic"
2324
}

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The GitHub Copilot SDK exposes the same engine behind Copilot CLI: a production-
2424
| **Go** | [`go/`](./go/) | [Cookbook](https://github.com/github/awesome-copilot/blob/main/cookbook/copilot-sdk/go/README.md) | `go get github.com/github/copilot-sdk/go` |
2525
| **.NET** | [`dotnet/`](./dotnet/) | [Cookbook](https://github.com/github/awesome-copilot/blob/main/cookbook/copilot-sdk/dotnet/README.md) | `dotnet add package GitHub.Copilot.SDK` |
2626
| **Rust** | [`rust/`](./rust/) || `cargo add github-copilot-sdk` |
27-
| **Java** | [`github/copilot-sdk-java`](https://github.com/github/copilot-sdk-java) | [Cookbook](https://github.com/github/awesome-copilot/blob/main/cookbook/copilot-sdk/java/README.md) | Maven coordinates<br>`com.github:copilot-sdk-java`<br>See instructions for [Maven](https://github.com/github/copilot-sdk-java?tab=readme-ov-file#maven) and [Gradle](https://github.com/github/copilot-sdk-java?tab=readme-ov-file#gradle) |
27+
| **Java** | [`java/`](./java/) | [Cookbook](https://github.com/github/awesome-copilot/blob/main/cookbook/copilot-sdk/java/README.md) | Maven coordinates<br>`com.github:copilot-sdk-java`<br>See instructions for [Maven](./java/README.md#maven) and [Gradle](./java/README.md#gradle) |
2828

2929
See the individual SDK READMEs for installation, usage examples, and API reference.
3030

@@ -37,7 +37,7 @@ Quick steps:
3737
1. **(Optional) Install the Copilot CLI**
3838

3939
For Node.js, Python, and .NET SDKs, the Copilot CLI is bundled automatically and no separate installation is required.
40-
For the Go and Rust SDKs, [install the CLI manually](https://github.com/features/copilot/cli) or ensure `copilot` is available in your PATH unless you opt into their application-level CLI bundling features.
40+
For the Go, Java and Rust SDKs, [install the CLI manually](https://github.com/features/copilot/cli) or ensure `copilot` is available in your PATH unless you opt into their application-level CLI bundling features.
4141

4242
2. **Install your preferred SDK** using the commands above.
4343

@@ -88,7 +88,7 @@ See the **[Authentication documentation](./docs/auth/index.md)** for details on
8888

8989
No — for Node.js, Python, and .NET SDKs, the Copilot CLI is bundled automatically as a dependency. You do not need to install it separately.
9090

91-
For Go and Rust SDKs, the CLI is not bundled by default. Install the CLI manually, ensure `copilot` is available in your PATH, or opt into their application-level CLI bundling features.
91+
For Go, Java and Rust SDKs, the CLI is **not** bundled by default. Install the CLI manually, ensure `copilot` is available in your PATH, or opt into their application-level CLI bundling features.
9292

9393
Advanced: You can override the CLI binary or connect to an external server. See the individual SDK README for language-specific options.
9494

@@ -109,7 +109,7 @@ Yes, check out the custom instructions and SDK-specific guidance:
109109
- **[.NET](https://github.com/github/awesome-copilot/blob/main/instructions/copilot-sdk-csharp.instructions.md)**
110110
- **[Go](https://github.com/github/awesome-copilot/blob/main/instructions/copilot-sdk-go.instructions.md)**
111111
- **[Rust](./rust/README.md)** (SDK guidance; custom instructions not yet published)
112-
- **[Java](https://github.com/github/copilot-sdk-java/blob/main/instructions/copilot-sdk-java.instructions.md)**
112+
- **[Java](https://github.com/github/awesome-copilot/blob/main/instructions/copilot-sdk-java.instructions.md)**
113113

114114
### What models are supported?
115115

docs/auth/authenticate.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ await using var client = new CopilotClient();
8989
<summary><strong>Java</strong></summary>
9090

9191
```java
92-
import com.github.copilot.sdk.CopilotClient;
92+
import com.github.copilot.CopilotClient;
9393

9494
// Default: uses logged-in user credentials
9595
var client = new CopilotClient();
@@ -205,9 +205,10 @@ await using var client = new CopilotClient(new CopilotClientOptions
205205
<details>
206206
<summary><strong>Java</strong></summary>
207207

208+
<!-- docs-validate: skip -->
208209
```java
209-
import com.github.copilot.sdk.CopilotClient;
210-
import com.github.copilot.sdk.json.*;
210+
import com.github.copilot.CopilotClient;
211+
import com.github.copilot.rpc.*;
211212

212213
var client = new CopilotClient(new CopilotClientOptions()
213214
.setGitHubToken(userAccessToken) // Token from OAuth flow
@@ -384,8 +385,8 @@ await using var client = new CopilotClient(new CopilotClientOptions
384385
<summary><strong>Java</strong></summary>
385386

386387
```java
387-
import com.github.copilot.sdk.CopilotClient;
388-
import com.github.copilot.sdk.json.*;
388+
import com.github.copilot.CopilotClient;
389+
import com.github.copilot.rpc.*;
389390

390391
var client = new CopilotClient(new CopilotClientOptions()
391392
.setUseLoggedInUser(false) // Only use explicit tokens

docs/auth/byok.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,8 @@ Console.WriteLine(response?.Data.Content);
170170
<summary><strong>Java</strong></summary>
171171

172172
```java
173-
import com.github.copilot.sdk.CopilotClient;
174-
import com.github.copilot.sdk.events.*;
175-
import com.github.copilot.sdk.json.*;
173+
import com.github.copilot.CopilotClient;
174+
import com.github.copilot.rpc.*;
176175

177176
var client = new CopilotClient();
178177
client.start().get();
@@ -450,8 +449,8 @@ var client = new CopilotClient(new CopilotClientOptions
450449
<summary><strong>Java</strong></summary>
451450

452451
```java
453-
import com.github.copilot.sdk.CopilotClient;
454-
import com.github.copilot.sdk.json.*;
452+
import com.github.copilot.CopilotClient;
453+
import com.github.copilot.rpc.*;
455454
import java.util.List;
456455
import java.util.concurrent.CompletableFuture;
457456

docs/features/custom-agents.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,8 @@ await using var session = await client.CreateSessionAsync(new SessionConfig
210210
<summary><strong>Java</strong></summary>
211211

212212
```java
213-
import com.github.copilot.sdk.CopilotClient;
214-
import com.github.copilot.sdk.events.*;
215-
import com.github.copilot.sdk.json.*;
213+
import com.github.copilot.CopilotClient;
214+
import com.github.copilot.rpc.*;
216215
import java.util.List;
217216

218217
try (var client = new CopilotClient()) {
@@ -387,7 +386,7 @@ var session = await client.CreateSessionAsync(new SessionConfig
387386

388387
<!-- docs-validate: skip -->
389388
```java
390-
import com.github.copilot.sdk.json.*;
389+
import com.github.copilot.rpc.*;
391390
import java.util.List;
392391

393392
var session = client.createSession(
@@ -656,6 +655,7 @@ await session.SendAndWaitAsync(new MessageOptions
656655
<details>
657656
<summary><strong>Java</strong></summary>
658657

658+
<!-- docs-validate: skip -->
659659
```java
660660
session.on(event -> {
661661
if (event instanceof SubagentStartedEvent e) {
@@ -980,4 +980,4 @@ session.on((event) => {
980980
// Show error in UI, retry, or fall back to parent agent
981981
}
982982
});
983-
```
983+
```

docs/features/hooks.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,8 @@ var session = await client.CreateSessionAsync(new SessionConfig
212212
<summary><strong>Java</strong></summary>
213213

214214
```java
215-
import com.github.copilot.sdk.CopilotClient;
216-
import com.github.copilot.sdk.events.*;
217-
import com.github.copilot.sdk.json.*;
215+
import com.github.copilot.CopilotClient;
216+
import com.github.copilot.rpc.*;
218217
import java.util.concurrent.CompletableFuture;
219218

220219
try (var client = new CopilotClient()) {
@@ -430,14 +429,15 @@ var session = await client.CreateSessionAsync(new SessionConfig
430429
<details>
431430
<summary><strong>Java</strong></summary>
432431

432+
<!-- docs-validate: skip -->
433433
```java
434434
import java.util.Set;
435435
import java.util.concurrent.CompletableFuture;
436436

437-
import com.github.copilot.sdk.PermissionHandler;
438-
import com.github.copilot.sdk.SessionConfig;
439-
import com.github.copilot.sdk.SessionHooks;
440-
import com.github.copilot.sdk.json.PreToolUseHookOutput;
437+
import com.github.copilot.rpc.PermissionHandler;
438+
import com.github.copilot.rpc.SessionConfig;
439+
import com.github.copilot.rpc.SessionHooks;
440+
import com.github.copilot.rpc.PreToolUseHookOutput;
441441
var readOnlyTools = Set.of("read_file", "glob", "grep", "view");
442442

443443
var hooks = new SessionHooks()
@@ -1063,4 +1063,4 @@ For full type definitions, input/output field tables, and additional examples fo
10631063
- [Getting Started](../getting-started.md)
10641064
- [Custom Agents & Sub-Agent Orchestration](./custom-agents.md)
10651065
- [Streaming Session Events](./streaming-events.md)
1066-
- [Debugging Guide](../troubleshooting/debugging.md)
1066+
- [Debugging Guide](../troubleshooting/debugging.md)

docs/features/image-input.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,8 @@ await session.SendAsync(new MessageOptions
225225
<summary><strong>Java</strong></summary>
226226

227227
```java
228-
import com.github.copilot.sdk.CopilotClient;
229-
import com.github.copilot.sdk.events.*;
230-
import com.github.copilot.sdk.json.*;
228+
import com.github.copilot.CopilotClient;
229+
import com.github.copilot.rpc.*;
231230
import java.util.List;
232231

233232
try (var client = new CopilotClient()) {
@@ -434,9 +433,8 @@ await session.SendAsync(new MessageOptions
434433
<summary><strong>Java</strong></summary>
435434

436435
```java
437-
import com.github.copilot.sdk.CopilotClient;
438-
import com.github.copilot.sdk.events.*;
439-
import com.github.copilot.sdk.json.*;
436+
import com.github.copilot.CopilotClient;
437+
import com.github.copilot.rpc.*;
440438
import java.util.List;
441439

442440
try (var client = new CopilotClient()) {

docs/features/skills.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,8 @@ await session.SendAndWaitAsync(new MessageOptions
145145
<summary><strong>Java</strong></summary>
146146

147147
```java
148-
import com.github.copilot.sdk.CopilotClient;
149-
import com.github.copilot.sdk.events.*;
150-
import com.github.copilot.sdk.json.*;
148+
import com.github.copilot.CopilotClient;
149+
import com.github.copilot.rpc.*;
151150
import java.util.List;
152151

153152
try (var client = new CopilotClient()) {
@@ -280,8 +279,9 @@ var session = await client.CreateSessionAsync(new SessionConfig
280279
<details>
281280
<summary><strong>Java</strong></summary>
282281

282+
<!-- docs-validate: skip -->
283283
```java
284-
import com.github.copilot.sdk.json.*;
284+
import com.github.copilot.rpc.*;
285285
import java.util.List;
286286

287287
var session = client.createSession(
@@ -422,4 +422,4 @@ If multiple skills provide conflicting instructions:
422422

423423
* [Custom Agents](../getting-started.md#create-custom-agents) - Define specialized AI personas
424424
* [Custom Tools](../getting-started.md#step-4-add-a-custom-tool) - Build your own tools
425-
* [MCP Servers](./mcp.md) - Connect external tool providers
425+
* [MCP Servers](./mcp.md) - Connect external tool providers

0 commit comments

Comments
 (0)