Skip to content
Closed
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
6561490
Initial plan
Copilot Apr 12, 2026
3ef1b22
Add Java code generation from JSON schemas
Copilot Apr 12, 2026
6e3c50c
Add comment explaining npm install before npm ci in update workflow
Copilot Apr 13, 2026
75e5dba
Improve Java code generator: sealed hierarchy, records, Long for inte…
Copilot Apr 13, 2026
e9c0bf7
Add @JsonInclude(NON_NULL) to all generated event classes and warn on…
edburns Apr 14, 2026
da9ec9c
Migrate events package to auto-generated SessionEvent types
Copilot Apr 14, 2026
7e7b283
Fix residual old-package references and rename SessionEventParserTest
edburns Apr 15, 2026
6d35942
Generate typed RPC wrapper classes (ServerRpc, SessionRpc) from api.s…
Copilot Apr 15, 2026
e4dc6e5
Fix race condition in SessionEventsE2ETest: wait for own listener to …
Copilot Apr 16, 2026
a2712a7
Chunk 3: Wire generated RPC wrappers into CopilotClient and CopilotSe…
Copilot Apr 16, 2026
f21a5ae
Merge remote-tracking branch 'upstream/main' into copilot/copilot-pr-70
edburns Apr 16, 2026
cc3e09a
Chunk 3 improvements: lazy getRpc() init, full internal RPC migration…
Copilot Apr 17, 2026
5ba95f6
Fix Windows CLI path resolution and extract shared TestUtil
edburns Apr 17, 2026
265eec4
Apply Spotless formatting fixes to TestUtil.java
edburns Apr 17, 2026
cf7d988
Merge branch 'main' into copilot/copilot-pr-70
edburns Apr 17, 2026
ed1b1e3
Forbid agentic sync from modifying src/generated/java/ files
Copilot Apr 17, 2026
9ec2478
Remove duplicate Javadoc block on sendExpandedToolResult()
edburns Apr 17, 2026
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
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.github/workflows/*.lock.yml linguist-generated=true merge=ours
.github/workflows/*.lock.yml linguist-generated=true merge=ours
src/generated/java/** eol=lf linguist-generated=true
2 changes: 1 addition & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ mvn test -Dtest=CopilotClientTest

- `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.events` - Event types for session streaming (AssistantMessageEvent, SessionIdleEvent, ToolExecutionStartEvent, etc.)
- `com.github.copilot.sdk.generated` - Generated event types for session streaming (SessionEvent, AssistantMessageEvent, SessionIdleEvent, ToolExecutionStartEvent, etc.)

### Test Infrastructure

Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/codegen-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: "Codegen Check"

on:
push:
branches:
- main
pull_request:
paths:
- 'scripts/codegen/**'
- 'src/generated/java/**'
- '.github/workflows/codegen-check.yml'
workflow_dispatch:

permissions:
contents: read

jobs:
check:
name: "Verify generated files are up-to-date"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: 22

- name: Install codegen dependencies
working-directory: ./scripts/codegen
run: npm ci

- name: Run codegen
working-directory: ./scripts/codegen
run: npm run generate

- name: Check for uncommitted changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "::error::Generated files are out of date. Run 'cd scripts/codegen && npm run generate' and commit the changes."
git diff --stat
git diff
exit 1
fi
echo "✅ Generated files are up-to-date"
97 changes: 97 additions & 0 deletions .github/workflows/update-copilot-dependency.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: "Update @github/copilot Dependency"

on:
workflow_dispatch:
inputs:
version:
description: 'Target version of @github/copilot (e.g. 1.0.24)'
required: true
type: string

permissions:
contents: write
pull-requests: write

jobs:
update:
name: "Update @github/copilot to ${{ inputs.version }}"
runs-on: ubuntu-latest
steps:
- name: Validate version input
env:
VERSION: ${{ inputs.version }}
run: |
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9._-]+)?$ ]]; then
echo "::error::Invalid version format '$VERSION'. Expected semver (e.g. 1.0.24)."
exit 1
fi

- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: 22

- name: Update @github/copilot in scripts/codegen
env:
VERSION: ${{ inputs.version }}
working-directory: ./scripts/codegen
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot add a comment explaining the necessity of the unusual step of running npm install before npm ci

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment in 6e3c50c explaining the two-step approach: npm install updates package.json and package-lock.json to pin the new version, then npm ci does a clean reproducible install from the updated lock file. Running npm ci alone would fail because it cannot change a pinned version, and npm install alone leaves behind stale packages.

# npm install updates package.json and package-lock.json to the new
# version; npm ci (below) then does a clean, reproducible install from
# the updated lock file. Both steps are required: npm install alone
# leaves leftover packages, while npm ci alone cannot change the pinned
# version in the lock file.
run: npm install "@github/copilot@$VERSION"

- name: Install codegen dependencies
working-directory: ./scripts/codegen
run: npm ci

- name: Run codegen
working-directory: ./scripts/codegen
run: npm run generate

- name: Create pull request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ inputs.version }}
run: |
BRANCH="update-copilot-$VERSION"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

if git rev-parse --verify "origin/$BRANCH" >/dev/null 2>&1; then
git checkout "$BRANCH"
git reset --hard HEAD
else
git checkout -b "$BRANCH"
fi

git add -A

if git diff --cached --quiet; then
echo "No changes detected; skipping commit and PR creation."
exit 0
fi

git commit -m "Update @github/copilot to $VERSION

- Updated @github/copilot in scripts/codegen
- Re-ran Java code generator"
git push origin "$BRANCH" --force-with-lease

if gh pr view "$BRANCH" >/dev/null 2>&1; then
echo "Pull request for branch '$BRANCH' already exists; updated branch only."
else
gh pr create \
--title "Update @github/copilot to $VERSION" \
--body "Automated update of \`@github/copilot\` to version \`$VERSION\`.

### Changes
- Updated \`@github/copilot\` in \`scripts/codegen/package.json\`
- Re-ran Java code generator (\`scripts/codegen\`)

> Created by the **Update @github/copilot Dependency** workflow." \
--base main \
--head "$BRANCH"
fi
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ examples-test/
blog-copilotsdk/
.claude/worktrees
smoke-test
*job-logs.txt
*job-logs.txt*
temporary-prompts/
changebundle.txt*
.classpath
.project
.settings
scripts/codegen/node_modules/
*~
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ implementation 'com.github:copilot-sdk-java:0.2.2-java.1'

```java
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.events.AssistantMessageEvent;
import com.github.copilot.sdk.events.SessionUsageInfoEvent;
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;
Expand Down
4 changes: 2 additions & 2 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<property name="charset" value="UTF-8"/>
<property name="severity" value="error"/>

<!-- Exclude json package and events package (self-documenting DTOs) -->
<!-- Exclude json package, events package, and generated package (self-documenting DTOs) -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value=".*[\\/](json|events)[\\/].*\.java$"/>
<property name="fileNamePattern" value=".*[\\/](json|events|generated|rpc)[\\/].*\.java$"/>
</module>

<module name="TreeWalker">
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 @@ -2,15 +2,15 @@
<!--
SpotBugs exclusion filter for the Copilot SDK.

The 'events' and 'json' packages contain Jackson-deserialized DTOs where
The 'generated' and 'json' packages contain Jackson-deserialized DTOs where
returning mutable internal representations (EI_EXPOSE_REP) and storing
references to mutable objects (EI_EXPOSE_REP2) is intentional and expected.
Making defensive copies would add overhead without meaningful security
benefit for these read-only data transfer objects.
-->
<FindBugsFilter>
<Match>
<Package name="com.github.copilot.sdk.events"/>
<Package name="com.github.copilot.sdk.generated"/>
<Bug pattern="EI_EXPOSE_REP,EI_EXPOSE_REP2"/>
</Match>
<Match>
Expand Down
38 changes: 38 additions & 0 deletions docs/WORKFLOWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
| Workflow | Description | Triggers | Schedule |
|----------|-------------|----------|----------|
| [Build & Test](workflows/build-test.yml) | Builds, lints, and tests the Java SDK | `push` (main), `pull_request`, `merge_group`, `workflow_dispatch` | Sundays at 00:00 UTC |
| [Codegen Check](workflows/codegen-check.yml) | Verifies that generated Java files are up-to-date with the JSON schemas | `push` (main), `pull_request`, `workflow_dispatch` | — |
| [Update @github/copilot Dependency](workflows/update-copilot-dependency.yml) | Updates the `@github/copilot` npm package, re-runs code generation, and opens a PR | `workflow_dispatch` | — |
| [Deploy Documentation](workflows/deploy-site.yml) | Generates and deploys versioned docs to GitHub Pages | `workflow_run` (after Build & Test), `release`, `workflow_dispatch` | — |
| [Publish to Maven Central](workflows/publish-maven.yml) | Releases the SDK to Maven Central and creates a GitHub Release | `workflow_dispatch` | — |
| [Weekly Reference Implementation Sync](workflows/weekly-reference-impl-sync.yml) | Checks for new reference implementation commits and creates an issue for Copilot to merge | `workflow_dispatch` | Mondays at 10:00 UTC |
Expand Down Expand Up @@ -87,6 +89,42 @@ Auto-generated compiled workflow produced by `gh aw compile` from the correspond

---

## Codegen Check

**File:** [`codegen-check.yml`](workflows/codegen-check.yml)

Verifies that the generated Java source files in `src/generated/java/` are up-to-date with the JSON schemas distributed in the `@github/copilot` npm package.

Steps:
1. Installs the codegen dependencies from `scripts/codegen/`
2. Runs the Java code generator (`npm run generate`)
3. Fails with a diff if any generated file differs from what is committed

Run this locally with:
```bash
cd scripts/codegen && npm ci && npm run generate
```

If changes appear, commit the updated generated files.

---

## Update @github/copilot Dependency

**File:** [`update-copilot-dependency.yml`](workflows/update-copilot-dependency.yml)

Manual workflow triggered when a new version of the `@github/copilot` npm package is published. Accepts a `version` input (e.g. `1.0.25`).

Steps:
1. Updates `@github/copilot` in `scripts/codegen/package.json`
2. Re-runs the Java code generator
3. Commits the updated `package.json`, `package-lock.json`, and all regenerated Java files
4. Opens (or updates) a pull request for review

The resulting PR will be automatically validated by the **Codegen Check** workflow.

---

## Copilot Setup Steps

**File:** [`copilot-setup-steps.yml`](workflows/copilot-setup-steps.yml)
Expand Down
4 changes: 2 additions & 2 deletions jbang-example.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
!
//DEPS com.github:copilot-sdk-java:0.2.2-java.1
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.events.AssistantMessageEvent;
import com.github.copilot.sdk.events.SessionUsageInfoEvent;
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;
Expand Down
23 changes: 23 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,35 @@
</systemPropertyVariables>
</configuration>
</plugin>
<!-- Add src/generated/java as an additional source root -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.6.1</version>
<executions>
<execution>
<id>add-generated-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.basedir}/src/generated/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.44.5</version>
<configuration>
<java>
<excludes>
<exclude>src/generated/java/**/*.java</exclude>
</excludes>
<eclipse>
<version>4.33</version>
</eclipse>
Expand Down
1 change: 1 addition & 0 deletions scripts/codegen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
Loading
Loading