Skip to content

Commit 7135f86

Browse files
committed
Add Checkstyle configuration and integrate with Maven build
1 parent 6e30b85 commit 7135f86

3 files changed

Lines changed: 144 additions & 1 deletion

File tree

DOCS.md

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This document provides detailed API reference and usage examples for the Copilot
99
- [CopilotSession](#copilotsession)
1010
- [Event Types](#event-types)
1111
- [Streaming](#streaming)
12+
- [Listing Models](#listing-models)
1213
- [Advanced Usage](#advanced-usage)
1314
- [Manual Server Control](#manual-server-control)
1415
- [Tools](#tools)
@@ -83,6 +84,18 @@ Resume an existing session.
8384

8485
Ping the server to check connectivity.
8586

87+
##### `getStatus(): CompletableFuture<GetStatusResponse>`
88+
89+
Get CLI status including version and protocol information.
90+
91+
##### `getAuthStatus(): CompletableFuture<GetAuthStatusResponse>`
92+
93+
Get current authentication status.
94+
95+
##### `listModels(): CompletableFuture<List<ModelInfo>>`
96+
97+
List available models with their metadata (id, name, capabilities, billing info).
98+
8699
##### `getState(): ConnectionState`
87100

88101
Get current connection state. Returns one of: `DISCONNECTED`, `CONNECTING`, `CONNECTED`, `ERROR`.
@@ -111,6 +124,10 @@ Represents a single conversation session.
111124

112125
#### Methods
113126

127+
##### `send(String prompt): CompletableFuture<String>`
128+
129+
Convenience method to send a simple text message. Equivalent to `send(new MessageOptions().setPrompt(prompt))`.
130+
114131
##### `send(MessageOptions options): CompletableFuture<String>`
115132

116133
Send a message to the session.
@@ -123,10 +140,18 @@ Send a message to the session.
123140

124141
Returns the message ID.
125142

126-
##### `sendAndWait(MessageOptions options, long timeoutMs): CompletableFuture<AssistantMessageEvent>`
143+
##### `sendAndWait(String prompt): CompletableFuture<AssistantMessageEvent>`
144+
145+
Convenience method to send a simple text message and wait for the session to become idle. Equivalent to `sendAndWait(new MessageOptions().setPrompt(prompt))`.
146+
147+
##### `sendAndWait(MessageOptions options): CompletableFuture<AssistantMessageEvent>`
127148

128149
Send a message and wait for the session to become idle. Default timeout is 60 seconds.
129150

151+
##### `sendAndWait(MessageOptions options, long timeoutMs): CompletableFuture<AssistantMessageEvent>`
152+
153+
Send a message and wait for the session to become idle with custom timeout.
154+
130155
##### `on(Consumer<AbstractSessionEvent> handler): Closeable`
131156

132157
Subscribe to session events. Returns a `Closeable` to unsubscribe.
@@ -211,6 +236,45 @@ session.send(new MessageOptions().setPrompt("Tell me a short story")).get();
211236
done.get();
212237
```
213238

239+
## Listing Models
240+
241+
Query available models and their capabilities before creating a session:
242+
243+
```java
244+
try (var client = new CopilotClient()) {
245+
client.start().get();
246+
247+
// List all available models
248+
List<ModelInfo> models = client.listModels().get();
249+
250+
for (ModelInfo model : models) {
251+
System.out.println("Model: " + model.getId());
252+
System.out.println(" Name: " + model.getName());
253+
254+
if (model.getCapabilities() != null) {
255+
System.out.println(" Max Output Tokens: " + model.getCapabilities().getMaxOutputTokens());
256+
}
257+
258+
if (model.getPolicy() != null) {
259+
System.out.println(" State: " + model.getPolicy().getState());
260+
}
261+
}
262+
263+
// Use a specific model from the list
264+
var session = client.createSession(
265+
new SessionConfig().setModel(models.get(0).getId())
266+
).get();
267+
}
268+
```
269+
270+
Each `ModelInfo` contains:
271+
272+
- `id` - Model identifier (e.g., "claude-sonnet-4.5", "gpt-4o")
273+
- `name` - Human-readable display name
274+
- `capabilities` - Model limits including max output tokens
275+
- `policy` - Policy state information
276+
- `billing` - Billing/usage information
277+
214278
## Advanced Usage
215279

216280
### Manual Server Control

checkstyle.xml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!DOCTYPE module PUBLIC
2+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
3+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
4+
5+
<!--
6+
Checkstyle configuration for Copilot SDK for Java.
7+
Focuses on ensuring core public API classes have proper Javadoc documentation.
8+
Excludes JSON DTOs and event data classes which are self-documenting.
9+
-->
10+
<module name="Checker">
11+
<property name="charset" value="UTF-8"/>
12+
<property name="severity" value="error"/>
13+
14+
<!-- Exclude json package and events package (self-documenting DTOs) -->
15+
<module name="BeforeExecutionExclusionFileFilter">
16+
<property name="fileNamePattern" value=".*[\\/](json|events)[\\/].*\.java$"/>
17+
</module>
18+
19+
<module name="TreeWalker">
20+
<!-- Require Javadoc on public types (classes, interfaces, enums) -->
21+
<module name="MissingJavadocType">
22+
<property name="scope" value="public"/>
23+
<property name="excludeScope" value="nothing"/>
24+
<property name="skipAnnotations" value="Generated"/>
25+
<!-- Exclude nested/inner classes -->
26+
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF"/>
27+
</module>
28+
29+
<!-- Require Javadoc on public methods, but allow missing on getters/setters -->
30+
<module name="MissingJavadocMethod">
31+
<property name="scope" value="public"/>
32+
<property name="minLineCount" value="-1"/>
33+
<property name="allowedAnnotations" value="Override, Deprecated, Generated"/>
34+
<property name="allowMissingPropertyJavadoc" value="true"/>
35+
</module>
36+
37+
<!-- Validate Javadoc format on types -->
38+
<module name="JavadocType">
39+
<property name="scope" value="public"/>
40+
<property name="allowMissingParamTags" value="true"/>
41+
<property name="allowUnknownTags" value="true"/>
42+
</module>
43+
44+
<!-- Ensure Javadoc has proper structure -->
45+
<module name="JavadocStyle">
46+
<property name="scope" value="public"/>
47+
<property name="checkFirstSentence" value="false"/>
48+
<property name="checkEmptyJavadoc" value="true"/>
49+
<property name="checkHtml" value="false"/>
50+
</module>
51+
</module>
52+
</module>

pom.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,33 @@
151151
</java>
152152
</configuration>
153153
</plugin>
154+
<plugin>
155+
<groupId>org.apache.maven.plugins</groupId>
156+
<artifactId>maven-checkstyle-plugin</artifactId>
157+
<version>3.6.0</version>
158+
<configuration>
159+
<configLocation>checkstyle.xml</configLocation>
160+
<consoleOutput>true</consoleOutput>
161+
<failsOnError>true</failsOnError>
162+
<includeTestSourceDirectory>false</includeTestSourceDirectory>
163+
</configuration>
164+
<executions>
165+
<execution>
166+
<id>validate</id>
167+
<phase>validate</phase>
168+
<goals>
169+
<goal>check</goal>
170+
</goals>
171+
</execution>
172+
</executions>
173+
<dependencies>
174+
<dependency>
175+
<groupId>com.puppycrawl.tools</groupId>
176+
<artifactId>checkstyle</artifactId>
177+
<version>10.21.4</version>
178+
</dependency>
179+
</dependencies>
180+
</plugin>
154181
</plugins>
155182
</build>
156183

0 commit comments

Comments
 (0)