Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ mvn test -Dtest=CopilotClientTest

### Package Structure

- `com.github.copilot.sdk` - Core classes (CopilotClient, CopilotSession, JsonRpcClient)
- `com.github.copilot.sdk.json` - DTOs, request/response types, handler interfaces (SessionConfig, MessageOptions, ToolDefinition, etc.)
- `com.github.copilot.sdk.generated` - Generated event types for session streaming (SessionEvent, AssistantMessageEvent, SessionIdleEvent, ToolExecutionStartEvent, etc.)
- `com.github.copilot` - Core classes (CopilotClient, CopilotSession, JsonRpcClient)
- `com.github.copilot.rpc` - DTOs, request/response types, handler interfaces (SessionConfig, MessageOptions, ToolDefinition, etc.)
- `com.github.copilot.generated` - Generated event types for session streaming (SessionEvent, AssistantMessageEvent, SessionIdleEvent, ToolExecutionStartEvent, etc.)

### Test Infrastructure

Expand Down
22 changes: 11 additions & 11 deletions .github/prompts/agentic-merge-reference-impl.prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ For each change in the reference implementation diff, determine:

| reference implementation (.NET) | Java SDK Equivalent |
|------------------------------------|--------------------------------------------------------|
| `dotnet/src/Client.cs` | `src/main/java/com/github/copilot/sdk/CopilotClient.java` |
| `dotnet/src/Session.cs` | `src/main/java/com/github/copilot/sdk/CopilotSession.java` |
| `dotnet/src/Types.cs` | `src/main/java/com/github/copilot/sdk/types/*.java` |
| `dotnet/src/Client.cs` | `src/main/java/com/github/copilot/CopilotClient.java` |
| `dotnet/src/Session.cs` | `src/main/java/com/github/copilot/CopilotSession.java` |
| `dotnet/src/Types.cs` | `src/main/java/com/github/copilot/types/*.java` |
| `dotnet/src/Generated/*.cs` | ❌ **DO NOT TOUCH** `src/generated/java/**` — see top of this file |
| `dotnet/test/*.cs` | `src/test/java/com/github/copilot/sdk/*Test.java` |
| `dotnet/test/*.cs` | `src/test/java/com/github/copilot/*Test.java` |
| `docs/getting-started.md` | `README.md` and `src/site/markdown/*.md` |
| `docs/*.md` (new files) | `src/site/markdown/*.md` + update `src/site/site.xml` |
| `sdk-protocol-version.json` | (embedded in Java code or resource file) |
Expand Down Expand Up @@ -209,7 +209,7 @@ This creates a clear history of changes that can be reviewed in the Pull Request
Follow the existing Java SDK patterns:
- Use Jackson for JSON serialization (`ObjectMapper`)
- Use Java records for DTOs where appropriate
- Follow the existing package structure under `com.github.copilot.sdk`
- Follow the existing package structure under `com.github.copilot`
- Maintain backward compatibility when possible
- **Match the style of surrounding code** - Consistency with existing code is more important than reference implementation patterns
- **Prefer existing abstractions** - If the Java SDK already solves a problem differently than .NET, keep the Java approach
Expand All @@ -230,7 +230,7 @@ git diff "$LAST_REFERENCE_IMPL_COMMIT"..origin/main --stat -- test/snapshots/

For each new or modified test file in `dotnet/test/`:

1. **Create corresponding Java test class** in `src/test/java/com/github/copilot/sdk/`
1. **Create corresponding Java test class** in `src/test/java/com/github/copilot/`
2. **Follow existing test patterns** - Look at existing tests like `PermissionsTest.java` for structure
3. **Use the E2ETestContext** infrastructure for tests that need the test harness
4. **Match snapshot directory names** - Test snapshots in `test/snapshots/` must match the directory name used in `ctx.configureForTest()`
Expand All @@ -239,10 +239,10 @@ For each new or modified test file in `dotnet/test/`:

| reference implementation Test (.NET) | Java SDK Test |
|-----------------------------|--------------------------------------------------------|
| `dotnet/test/AskUserTests.cs` | `src/test/java/com/github/copilot/sdk/AskUserTest.java` |
| `dotnet/test/HooksTests.cs` | `src/test/java/com/github/copilot/sdk/HooksTest.java` |
| `dotnet/test/ClientTests.cs` | `src/test/java/com/github/copilot/sdk/CopilotClientTest.java` |
| `dotnet/test/*Tests.cs` | `src/test/java/com/github/copilot/sdk/*Test.java` |
| `dotnet/test/AskUserTests.cs` | `src/test/java/com/github/copilot/AskUserTest.java` |
| `dotnet/test/HooksTests.cs` | `src/test/java/com/github/copilot/HooksTest.java` |
| `dotnet/test/ClientTests.cs` | `src/test/java/com/github/copilot/CopilotClientTest.java` |
| `dotnet/test/*Tests.cs` | `src/test/java/com/github/copilot/*Test.java` |

### Test Snapshot Compatibility

Expand Down Expand Up @@ -353,7 +353,7 @@ var session = client.createSession(

Explain the request/response objects and their properties.

See [FeatureHandler](apidocs/com/github/copilot/sdk/json/FeatureHandler.html) Javadoc for more details.
See [FeatureHandler](apidocs/com/github/copilot/rpc/FeatureHandler.html) Javadoc for more details.
```

### Verify Documentation Consistency
Expand Down
26 changes: 13 additions & 13 deletions .github/prompts/documentation-coverage.prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Extract all public classes, methods, and features from the SDK:

```bash
# List all public classes in core package
grep -l "public class\|public interface\|public enum" src/main/java/com/github/copilot/sdk/*.java
grep -l "public class\|public interface\|public enum" src/main/java/com/github/copilot/*.java

# List all public classes in json package (DTOs)
grep -l "public class" src/main/java/com/github/copilot/sdk/json/*.java
grep -l "public class" src/main/java/com/github/copilot/rpc/*.java

# List all event types
ls src/main/java/com/github/copilot/sdk/events/
ls src/main/java/com/github/copilot/events/
```

### Step 2: Inventory Documentation
Expand All @@ -45,7 +45,7 @@ For each major feature area, determine if it's documented:
Examine `CopilotClient.java` for public methods:

```bash
grep "public.*(" src/main/java/com/github/copilot/sdk/CopilotClient.java | grep -v "@"
grep "public.*(" src/main/java/com/github/copilot/CopilotClient.java | grep -v "@"
```

| Method | Purpose | Documented In | Status |
Expand All @@ -66,7 +66,7 @@ grep "public.*(" src/main/java/com/github/copilot/sdk/CopilotClient.java | grep
Examine `CopilotSession.java` for public methods:

```bash
grep "public.*(" src/main/java/com/github/copilot/sdk/CopilotSession.java | grep -v "@"
grep "public.*(" src/main/java/com/github/copilot/CopilotSession.java | grep -v "@"
```

| Method | Purpose | Documented In | Status |
Expand All @@ -83,7 +83,7 @@ grep "public.*(" src/main/java/com/github/copilot/sdk/CopilotSession.java | grep
Examine `SessionConfig.java` for configurable options:

```bash
grep "public.*set\|private.*;" src/main/java/com/github/copilot/sdk/json/SessionConfig.java
grep "public.*set\|private.*;" src/main/java/com/github/copilot/rpc/SessionConfig.java
```

| Option | Purpose | Documented | Example Provided |
Expand All @@ -103,7 +103,7 @@ grep "public.*set\|private.*;" src/main/java/com/github/copilot/sdk/json/Session
Check which events are documented:

```bash
grep "TYPE_MAP.put" src/main/java/com/github/copilot/sdk/events/SessionEventParser.java
grep "TYPE_MAP.put" src/main/java/com/github/copilot/events/SessionEventParser.java
```

| Event Type | Event Class | Documented | Example |
Expand All @@ -118,7 +118,7 @@ grep "TYPE_MAP.put" src/main/java/com/github/copilot/sdk/events/SessionEventPars
Check `SessionHooks.java` for hook types:

```bash
grep "private.*Handler" src/main/java/com/github/copilot/sdk/json/SessionHooks.java
grep "private.*Handler" src/main/java/com/github/copilot/rpc/SessionHooks.java
```

| Hook | Handler Interface | Documented | Example |
Expand Down Expand Up @@ -193,11 +193,11 @@ Topics that warrant dedicated documentation:
## Key Files

### Source Code
- `src/main/java/com/github/copilot/sdk/CopilotClient.java`
- `src/main/java/com/github/copilot/sdk/CopilotSession.java`
- `src/main/java/com/github/copilot/sdk/json/SessionConfig.java`
- `src/main/java/com/github/copilot/sdk/json/SessionHooks.java`
- `src/main/java/com/github/copilot/sdk/events/SessionEventParser.java`
- `src/main/java/com/github/copilot/CopilotClient.java`
- `src/main/java/com/github/copilot/CopilotSession.java`
- `src/main/java/com/github/copilot/rpc/SessionConfig.java`
- `src/main/java/com/github/copilot/rpc/SessionHooks.java`
- `src/main/java/com/github/copilot/events/SessionEventParser.java`

### Documentation
- `src/site/markdown/index.md` - Landing page
Expand Down
26 changes: 13 additions & 13 deletions .github/prompts/test-coverage-assessment.prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ First, examine the source code to identify all components that should be tested:

```bash
# List all event classes
ls src/main/java/com/github/copilot/sdk/events/
ls src/main/java/com/github/copilot/events/

# Check the event type mapping in SessionEventParser
grep -n "TYPE_MAP.put" src/main/java/com/github/copilot/sdk/events/SessionEventParser.java
grep -n "TYPE_MAP.put" src/main/java/com/github/copilot/events/SessionEventParser.java
```

Extract the list of all registered event types from `SessionEventParser.java`.
Expand All @@ -30,7 +30,7 @@ Extract the list of all registered event types from `SessionEventParser.java`.
Check `SessionHooks.java` for all available hook handlers:

```bash
grep -E "private.*Handler" src/main/java/com/github/copilot/sdk/json/SessionHooks.java
grep -E "private.*Handler" src/main/java/com/github/copilot/rpc/SessionHooks.java
```

### Step 3: Analyze Existing Tests
Expand All @@ -39,13 +39,13 @@ Examine the test files to understand current coverage:

```bash
# List all test files
ls src/test/java/com/github/copilot/sdk/
ls src/test/java/com/github/copilot/

# Check for event-related tests
grep -r "import.*events\." src/test/java/com/github/copilot/sdk/ | grep -v "\.class"
grep -r "import.*events\." src/test/java/com/github/copilot/ | grep -v "\.class"

# Check for hook tests
grep -l "SessionHooks\|Hook" src/test/java/com/github/copilot/sdk/*.java
grep -l "SessionHooks\|Hook" src/test/java/com/github/copilot/*.java
```

### Step 4: Categorize Test Coverage
Expand Down Expand Up @@ -95,13 +95,13 @@ Prioritized list of tests to add:

## Key Files to Examine

- `src/main/java/com/github/copilot/sdk/events/SessionEventParser.java` - Event type registry
- `src/main/java/com/github/copilot/sdk/json/SessionHooks.java` - Hook definitions
- `src/main/java/com/github/copilot/sdk/CopilotSession.java` - Hook handling logic
- `src/test/java/com/github/copilot/sdk/SessionEventParserTest.java` - Event parsing tests
- `src/test/java/com/github/copilot/sdk/SessionEventsE2ETest.java` - Event E2E tests
- `src/test/java/com/github/copilot/sdk/HooksTest.java` - Hook tests
- `src/test/java/com/github/copilot/sdk/SessionEventHandlingTest.java` - Event handling tests
- `src/main/java/com/github/copilot/events/SessionEventParser.java` - Event type registry
- `src/main/java/com/github/copilot/rpc/SessionHooks.java` - Hook definitions
- `src/main/java/com/github/copilot/CopilotSession.java` - Hook handling logic
- `src/test/java/com/github/copilot/SessionEventParserTest.java` - Event parsing tests
- `src/test/java/com/github/copilot/SessionEventsE2ETest.java` - Event E2E tests
- `src/test/java/com/github/copilot/HooksTest.java` - Hook tests
- `src/test/java/com/github/copilot/SessionEventHandlingTest.java` - Event handling tests

## Verification

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codegen-agentic-fix.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ For each attempt:
2. **Read the generated types** to understand what changed. Check the generated files that the handwritten code references:
```bash
# Example: check what a generated type looks like now
cat src/generated/java/com/github/copilot/sdk/generated/rpc/<TypeName>.java
cat src/generated/java/com/github/copilot/generated/rpc/<TypeName>.java
```

3. **Fix the affected source files.** You may modify files under:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/update-copilot-dependency.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
cat > /tmp/verify-codegen-prompt.txt << 'PROMPT_EOF'
You are running inside the copilot-sdk-java repository.
The code generator has just run and produced Java source files under
src/generated/java/com/github/copilot/sdk/generated/rpc/.
src/generated/java/com/github/copilot/generated/rpc/.

Your task is to spot-check the generated API classes against the source
JSON schema to verify the generator produced correct output.
Expand All @@ -74,9 +74,9 @@ jobs:
scripts/codegen/node_modules/@github/copilot/schemas/api.schema.json

2. Pick these 3 generated API classes to verify:
- src/generated/java/com/github/copilot/sdk/generated/rpc/SessionToolsApi.java
- src/generated/java/com/github/copilot/sdk/generated/rpc/SessionUiApi.java
- src/generated/java/com/github/copilot/sdk/generated/rpc/SessionPermissionsApi.java
- src/generated/java/com/github/copilot/generated/rpc/SessionToolsApi.java
- src/generated/java/com/github/copilot/generated/rpc/SessionUiApi.java
- src/generated/java/com/github/copilot/generated/rpc/SessionPermissionsApi.java

3. For each class, verify:
- Every RPC method in the schema's corresponding namespace has a
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ New types: `GetForegroundSessionResponse`, `SetForegroundSessionResponse`

- Advanced usage documentation with comprehensive examples
- Getting started guide with Maven and JBang instructions
- Package-info.java files for `com.github.copilot.sdk`, `events`, and `json` packages
- Package-info.java files for `com.github.copilot`, `events`, and `json` packages
- `@since` annotations on all public classes
- Versioned documentation with version selector on GitHub Pages
- Maven resources plugin for site markdown filtering
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ implementation 'com.github:copilot-sdk-java:1.0.0-beta-java.4'
## Quick Start

```java
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.generated.AssistantMessageEvent;
import com.github.copilot.sdk.generated.SessionUsageInfoEvent;
import com.github.copilot.sdk.json.CopilotClientOptions;
import com.github.copilot.sdk.json.MessageOptions;
import com.github.copilot.sdk.json.PermissionHandler;
import com.github.copilot.sdk.json.SessionConfig;
import com.github.copilot.CopilotClient;
import com.github.copilot.generated.AssistantMessageEvent;
import com.github.copilot.generated.SessionUsageInfoEvent;
import com.github.copilot.rpc.CopilotClientOptions;
import com.github.copilot.rpc.MessageOptions;
import com.github.copilot.rpc.PermissionHandler;
import com.github.copilot.rpc.SessionConfig;

import java.util.concurrent.Executors;

Expand Down
4 changes: 2 additions & 2 deletions config/spotbugs/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
-->
<FindBugsFilter>
<Match>
<Package name="com.github.copilot.sdk.generated"/>
<Package name="com.github.copilot.generated"/>
<Bug pattern="EI_EXPOSE_REP,EI_EXPOSE_REP2"/>
</Match>
<Match>
<Package name="com.github.copilot.sdk.json"/>
<Package name="com.github.copilot.rpc"/>
<Bug pattern="EI_EXPOSE_REP,EI_EXPOSE_REP2"/>
</Match>
</FindBugsFilter>
12 changes: 6 additions & 6 deletions jbang-example.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS com.github:copilot-sdk-java:1.0.0-beta-java.4
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.generated.AssistantMessageEvent;
import com.github.copilot.sdk.generated.SessionUsageInfoEvent;
import com.github.copilot.sdk.json.MessageOptions;
import com.github.copilot.sdk.json.PermissionHandler;
import com.github.copilot.sdk.json.SessionConfig;
import com.github.copilot.CopilotClient;
import com.github.copilot.generated.AssistantMessageEvent;
import com.github.copilot.generated.SessionUsageInfoEvent;
import com.github.copilot.rpc.MessageOptions;
import com.github.copilot.rpc.PermissionHandler;
import com.github.copilot.rpc.SessionConfig;

import static java.lang.System.out;

Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,11 @@
<propertyName>testExecutionAgentArgs</propertyName>
<!-- Focus on SDK package, exclude test harness utilities -->
<includes>
<include>com/github/copilot/sdk/**</include>
<include>com/github/copilot/**</include>
</includes>
<excludes>
<exclude>com/github/copilot/sdk/E2ETestContext*</exclude>
<exclude>com/github/copilot/sdk/CapiProxy*</exclude>
<exclude>com/github/copilot/E2ETestContext*</exclude>
<exclude>com/github/copilot/CapiProxy*</exclude>
</excludes>
</configuration>
</execution>
Expand Down
12 changes: 6 additions & 6 deletions scripts/codegen/java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ async function generateSessionEvents(schemaPath: string): Promise<void> {
pendingStandaloneTypes.clear();

const variants = extractEventVariants(schema);
const packageName = "com.github.copilot.sdk.generated";
const packageDir = `src/generated/java/com/github/copilot/sdk/generated`;
const packageName = "com.github.copilot.generated";
const packageDir = `src/generated/java/com/github/copilot/generated`;

// Generate base SessionEvent class
await generateSessionEventBaseClass(variants, packageName, packageDir);
Expand Down Expand Up @@ -940,8 +940,8 @@ async function generateRpcTypes(schemaPath: string): Promise<void> {
console.warn(`[codegen] Could not load session-events schema for cross-ref resolution: ${e}`);
}

const packageName = "com.github.copilot.sdk.generated.rpc";
const packageDir = `src/generated/java/com/github/copilot/sdk/generated/rpc`;
const packageName = "com.github.copilot.generated.rpc";
const packageDir = `src/generated/java/com/github/copilot/generated/rpc`;

// Collect all RPC methods from all sections
const sections: [string, Record<string, unknown>][] = [];
Expand Down Expand Up @@ -1562,8 +1562,8 @@ async function generateRpcWrappers(schemaPath: string): Promise<void> {
// Set module-level definitions for $ref resolution in wrapper helpers
currentDefinitions = (schema.definitions ?? {}) as Record<string, JSONSchema7>;

const packageName = "com.github.copilot.sdk.generated.rpc";
const packageDir = `src/generated/java/com/github/copilot/sdk/generated/rpc`;
const packageName = "com.github.copilot.generated.rpc";
const packageDir = `src/generated/java/com/github/copilot/generated/rpc`;

// RpcCaller interface and shared ObjectMapper holder
await generateRpcCallerInterface(packageName, packageDir);
Expand Down
Loading
Loading