Skip to content

Commit 62c9eaa

Browse files
committed
feat: update README.md for clarity, add index.md for documentation, and adjust site.xml for proper configuration
1 parent 280e81a commit 62c9eaa

5 files changed

Lines changed: 155 additions & 98 deletions

File tree

README.md

Lines changed: 29 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,13 @@
11
# Copilot SDK for Java
22

3-
[![Build](https://github.com/copilot-community-sdk/copilot-sdk-java/actions/workflows/build-test.yml/badge.svg)](https://github.com/copilot-community-sdk/copilot-sdk-java/actions/workflows/build-test.yml)
3+
[![Build & Test](https://github.com/copilot-community-sdk/copilot-sdk-java/actions/workflows/build-test.yml/badge.svg)](https://github.com/copilot-community-sdk/copilot-sdk-java/actions/workflows/build-test.yml)
44
[![Maven Central](https://img.shields.io/maven-central/v/io.github.copilot-community-sdk/copilot-sdk)](https://central.sonatype.com/artifact/io.github.copilot-community-sdk/copilot-sdk)
55
[![Java 17+](https://img.shields.io/badge/Java-17%2B-blue)](https://openjdk.org/)
66
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
77

8-
> ⚠️ **Disclaimer:** This is an **unofficial, community-driven, and agentic-developed SDK** and is **not supported or endorsed by GitHub**. This SDK may change in breaking ways. This SDK may change in breaking ways. Use at your own risk.
8+
> ⚠️ **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.
99
10-
Java SDK for programmatic control of GitHub Copilot CLI.
11-
12-
<p align="center">
13-
<img width="480" src="image.png" alt="Copilot SDK for Java" />
14-
</p>
15-
16-
## Table of Contents
17-
18-
- [Requirements](#Requirements)
19-
- [Installation](#Installation)
20-
- [Quick Start](#Quick_Start)
21-
- [Try it with JBang](#Try_it_with_JBang)
22-
- [Documentation](#Documentation)
23-
- [Building and Testing](#Building_and_Testing)
24-
- [Projects Using This SDK](#Projects_Using_This_SDK)
25-
- [Contributing](#Contributing)
26-
- [License](#License)
27-
28-
## Requirements
29-
30-
- Java 17 or later
31-
- GitHub Copilot CLI installed and in PATH (or provide custom `cliPath`)
32-
- Node.js and npm (required for running tests - the test harness is implemented in Node.js)
10+
Java SDK for programmatic control of GitHub Copilot CLI, enabling you to build AI-powered applications and agentic workflows.
3311

3412
## Installation
3513

@@ -45,40 +23,28 @@ Java SDK for programmatic control of GitHub Copilot CLI.
4523

4624
### Gradle
4725

48-
Groovy:
49-
5026
```groovy
5127
implementation 'io.github.copilot-community-sdk:copilot-sdk:1.0.3'
5228
```
5329

54-
Kotlin:
55-
```kotlin
56-
implementation("io.github.copilot-community-sdk:copilot-sdk:1.0.3")
57-
```
58-
5930
## Quick Start
6031

6132
```java
6233
import com.github.copilot.sdk.*;
6334
import com.github.copilot.sdk.events.*;
6435
import com.github.copilot.sdk.json.*;
65-
6636
import java.util.concurrent.CompletableFuture;
6737

6838
public class Example {
6939
public static void main(String[] args) throws Exception {
70-
// Create and start client
7140
try (var client = new CopilotClient()) {
7241
client.start().get();
73-
74-
// Create a session
42+
7543
var session = client.createSession(
7644
new SessionConfig().setModel("claude-sonnet-4.5")
7745
).get();
7846

79-
// Wait for response using session.idle event
8047
var done = new CompletableFuture<Void>();
81-
8248
session.on(evt -> {
8349
if (evt instanceof AssistantMessageEvent msg) {
8450
System.out.println(msg.getData().getContent());
@@ -87,82 +53,56 @@ public class Example {
8753
}
8854
});
8955

90-
// Send a message and wait for completion
9156
session.send(new MessageOptions().setPrompt("What is 2+2?")).get();
9257
done.get();
9358
}
9459
}
9560
}
9661
```
9762

98-
## Try it with JBang
99-
100-
You can quickly try the SDK without setting up a full project using [JBang](https://www.jbang.dev/):
101-
102-
```bash
103-
# Assuming you are in the `java/` directory of this repository
104-
# Install the SDK locally first (not yet on Maven Central)
105-
mvn install
106-
107-
# Install JBang (if not already installed)
108-
# macOS: brew install jbang
109-
# Linux/Windows: curl -Ls https://sh.jbang.dev | bash -s - app setup
110-
111-
# Run the example
112-
jbang jbang-example.java
113-
```
114-
115-
The `jbang-example.java` file includes the dependency declaration and can be run directly:
116-
117-
```java
118-
//DEPS io.github.copilot-community-sdk:copilot-sdk:1.0.3
119-
```
120-
12163
## Documentation
12264

123-
For detailed API reference and advanced usage examples, see the [Documentation](src/site/markdown/documentation.md).
65+
📚 **[Full Documentation](https://copilot-community-sdk.github.io/copilot-sdk-java/)** — Complete API reference, advanced usage examples, and guides.
12466

125-
## Building and Testing
67+
### Quick Links
12668

127-
The tests require test resources (snapshots, harness) from the official [copilot-sdk](https://github.com/github/copilot-sdk) repository.
128-
The build automatically clones this repository during the `generate-test-resources` phase:
69+
- [Getting Started](https://copilot-community-sdk.github.io/copilot-sdk-java/documentation.html)
70+
- [Javadoc API Reference](https://copilot-community-sdk.github.io/copilot-sdk-java/apidocs/)
71+
- [MCP Servers Integration](https://copilot-community-sdk.github.io/copilot-sdk-java/mcp.html)
12972

130-
```bash
131-
mvn clean verify
132-
```
73+
## Requirements
74+
75+
- Java 17 or later
76+
- GitHub Copilot CLI installed and in PATH (or provide custom `cliPath`)
13377

134-
The official SDK repository is cloned to `target/copilot-sdk/` and the `copilot.tests.dir` property is set to point to its `test/` folder.
78+
## Projects Using This SDK
13579

136-
If you want to use a different location for the SDK repository (e.g., you already have it cloned locally), you can override the properties:
80+
| Project | Description |
81+
|---------|-------------|
82+
| [JMeter Copilot Plugin](https://github.com/brunoborges/jmeter-copilot-plugin) | JMeter plugin for AI-assisted load testing |
13783

138-
```bash
139-
mvn test -Dcopilot.sdk.clone.dir=/path/to/copilot-sdk -Dcopilot.tests.dir=/path/to/copilot-sdk/test
140-
```
84+
> Want to add your project? Open a PR!
14185
14286
## Contributing
14387

144-
### Setting Up Git Hooks
88+
Contributions are welcome! Please see the [Contributing Guide](CONTRIBUTING.md) for details.
14589

146-
This project uses a pre-commit hook to ensure code formatting standards are met before each commit. To enable the hook, run:
90+
### Development Setup
14791

14892
```bash
149-
git config core.hooksPath .githooks
150-
```
93+
# Clone the repository
94+
git clone https://github.com/copilot-community-sdk/copilot-sdk-java.git
95+
cd copilot-sdk-java
15196

152-
The pre-commit hook runs `mvn spotless:check` and will fail the commit if there are formatting issues. To fix formatting issues, run:
97+
# Enable git hooks for code formatting
98+
git config core.hooksPath .githooks
15399

154-
```bash
155-
mvn spotless:apply
100+
# Build and test
101+
mvn clean verify
156102
```
157103

158-
## Projects Using This SDK
159-
160-
| Project | Description |
161-
|---------|-------------|
162-
| [JMeter Copilot Plugin](https://github.com/brunoborges/jmeter-copilot-plugin) | A JMeter plugin that integrates GitHub Copilot for AI-assisted load testing |
163-
164-
> Want to add your project? Open a PR!
104+
The tests require the official [copilot-sdk](https://github.com/github/copilot-sdk) test harness, which is automatically cloned during build.
165105

166106
## License
167107

168-
MIT
108+
MIT — see [LICENSE](LICENSE) for details.

pom.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,20 @@
7878
<artifactId>maven-compiler-plugin</artifactId>
7979
<version>3.14.1</version>
8080
</plugin>
81-
<!-- Copy README.md and image.png to site directory -->
81+
<!-- Copy image.png to site resources directory -->
8282
<plugin>
8383
<groupId>org.apache.maven.plugins</groupId>
8484
<artifactId>maven-antrun-plugin</artifactId>
8585
<version>3.1.0</version>
8686
<executions>
8787
<execution>
88-
<id>copy-readme-to-site</id>
88+
<id>copy-image-to-site</id>
8989
<phase>pre-site</phase>
9090
<goals>
9191
<goal>run</goal>
9292
</goals>
9393
<configuration>
9494
<target>
95-
<copy file="${project.basedir}/README.md" tofile="${project.basedir}/src/site/markdown/index.md" />
9695
<copy file="${project.basedir}/image.png" tofile="${project.basedir}/src/site/resources/image.png" />
9796
</target>
9897
</configuration>
@@ -203,7 +202,7 @@
203202
<plugin>
204203
<groupId>org.apache.maven.plugins</groupId>
205204
<artifactId>maven-site-plugin</artifactId>
206-
<version>4.0.0-M16</version>
205+
<version>3.21.0</version>
207206
</plugin>
208207
</plugins>
209208
</build>

src/site/markdown/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/site/markdown/index.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Copilot SDK for Java
2+
3+
> ⚠️ **Disclaimer:** This is an **unofficial, community-driven SDK** and is **not supported or endorsed by GitHub**. Use at your own risk.
4+
5+
Welcome to the documentation for the **Copilot SDK for Java** — a Java SDK for programmatic control of GitHub Copilot CLI, enabling you to build AI-powered applications and agentic workflows.
6+
7+
## Getting Started
8+
9+
### Requirements
10+
11+
- Java 17 or later
12+
- GitHub Copilot CLI installed and in PATH (or provide custom `cliPath`)
13+
14+
### Installation
15+
16+
Add the dependency to your project:
17+
18+
**Maven:**
19+
20+
```xml
21+
<dependency>
22+
<groupId>io.github.copilot-community-sdk</groupId>
23+
<artifactId>copilot-sdk</artifactId>
24+
<version>${project.version}</version>
25+
</dependency>
26+
```
27+
28+
**Gradle:**
29+
30+
```groovy
31+
implementation 'io.github.copilot-community-sdk:copilot-sdk:${project.version}'
32+
```
33+
34+
### Quick Example
35+
36+
```java
37+
import com.github.copilot.sdk.*;
38+
import com.github.copilot.sdk.events.*;
39+
import com.github.copilot.sdk.json.*;
40+
import java.util.concurrent.CompletableFuture;
41+
42+
public class Example {
43+
public static void main(String[] args) throws Exception {
44+
try (var client = new CopilotClient()) {
45+
client.start().get();
46+
47+
var session = client.createSession(
48+
new SessionConfig().setModel("claude-sonnet-4.5")
49+
).get();
50+
51+
var done = new CompletableFuture<Void>();
52+
session.on(evt -> {
53+
if (evt instanceof AssistantMessageEvent msg) {
54+
System.out.println(msg.getData().getContent());
55+
} else if (evt instanceof SessionIdleEvent) {
56+
done.complete(null);
57+
}
58+
});
59+
60+
session.send(new MessageOptions().setPrompt("What is 2+2?")).get();
61+
done.get();
62+
}
63+
}
64+
}
65+
```
66+
67+
## Documentation
68+
69+
| Document | Description |
70+
|----------|-------------|
71+
| [API Reference & Advanced Usage](documentation.html) | Complete API documentation, event types, streaming, tools, and advanced features |
72+
| [MCP Servers Integration](mcp.html) | Guide to integrating Model Context Protocol servers |
73+
| [Javadoc](apidocs/index.html) | Generated API documentation |
74+
75+
## Try it with JBang
76+
77+
You can quickly try the SDK without setting up a full project using [JBang](https://www.jbang.dev/):
78+
79+
```bash
80+
# Install JBang (if not already installed)
81+
# macOS: brew install jbang
82+
# Linux/Windows: curl -Ls https://sh.jbang.dev | bash -s - app setup
83+
84+
# Create a simple script
85+
cat > hello-copilot.java << 'EOF'
86+
//DEPS io.github.copilot-community-sdk:copilot-sdk:${project.version}
87+
import com.github.copilot.sdk.*;
88+
import com.github.copilot.sdk.events.*;
89+
import com.github.copilot.sdk.json.*;
90+
import java.util.concurrent.CompletableFuture;
91+
92+
class hello {
93+
public static void main(String[] args) throws Exception {
94+
try (var client = new CopilotClient()) {
95+
client.start().get();
96+
var session = client.createSession(new SessionConfig()).get();
97+
var done = new CompletableFuture<Void>();
98+
session.on(evt -> {
99+
if (evt instanceof AssistantMessageEvent msg) {
100+
System.out.print(msg.getData().getContent());
101+
} else if (evt instanceof SessionIdleEvent) {
102+
done.complete(null);
103+
}
104+
});
105+
session.send(new MessageOptions().setPrompt("Say hello!")).get();
106+
done.get();
107+
}
108+
}
109+
}
110+
EOF
111+
112+
# Run it
113+
jbang hello-copilot.java
114+
```
115+
116+
## Source Code
117+
118+
- [GitHub Repository](https://github.com/copilot-community-sdk/copilot-sdk-java)
119+
- [Issue Tracker](https://github.com/copilot-community-sdk/copilot-sdk-java/issues)
120+
- [Contributing Guide](https://github.com/copilot-community-sdk/copilot-sdk-java/blob/main/CONTRIBUTING.md)

src/site/site.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
<!--
33
~ Copyright (c) Microsoft Corporation. All rights reserved.
44
-->
5-
<project xmlns="http://maven.apache.org/DECORATION/1.8.0"
5+
<project xmlns="http://maven.apache.org/SITE/2.0.0"
66
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7-
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.8.0 https://maven.apache.org/xsd/decoration-1.8.0.xsd"
7+
xsi:schemaLocation="http://maven.apache.org/SITE/2.0.0 https://maven.apache.org/xsd/site-2.0.0.xsd"
88
name="GitHub Copilot Community SDK :: Java">
99

1010
<skin>
1111
<groupId>org.apache.maven.skins</groupId>
1212
<artifactId>maven-fluido-skin</artifactId>
13-
<version>2.0.0-M11</version>
13+
<version>2.1.0</version>
1414
</skin>
1515

1616
<custom>

0 commit comments

Comments
 (0)