|
4 | 4 |
|
5 | 5 | ## Big picture 🔧 |
6 | 6 |
|
7 | | -- The repo implements language SDKs (Node/TS, Python, Go, .NET) that speak to the **Copilot CLI** via **JSON‑RPC** (see `README.md` and `nodejs/src/client.ts`). |
8 | | -- Typical flow: your App → SDK client → JSON-RPC → Copilot CLI (server mode). The CLI must be installed or you can connect to an external CLI server via the `CLI URL option (language-specific casing)` (Node: `cliUrl`, Go: `CLIUrl`, .NET: `CliUrl`, Python: `cli_url`). |
| 7 | +- The repo implements language SDKs (Node/TS, Python, Go, .NET, Java) that speak to the **Copilot CLI** via **JSON‑RPC** (see `README.md` and `nodejs/src/client.ts`). |
| 8 | +- Typical flow: your App → SDK client → JSON-RPC → Copilot CLI (server mode). The CLI must be installed or you can connect to an external CLI server via the `CLI URL option (language-specific casing)` (Node: `cliUrl`, Go: `CLIUrl`, .NET: `CliUrl`, Python: `cli_url`, Java: `cliUrl`). |
9 | 9 |
|
10 | 10 | ## Most important files to read first 📚 |
11 | 11 |
|
12 | 12 | - Top-level: `README.md` (architecture + quick start) |
13 | 13 | - Language entry points: `nodejs/src/client.ts`, `python/README.md`, `go/README.md`, `dotnet/README.md` |
| 14 | +- Java: `java/README.md`, `java/pom.xml` |
14 | 15 | - Test harness & E2E: `test/harness/*`, Python harness wrapper `python/e2e/testharness/proxy.py` |
15 | 16 | - Schemas & type generation: `nodejs/scripts/generate-session-types.ts` |
16 | 17 | - Session snapshots used by E2E: `test/snapshots/` (used by the replay proxy) |
|
26 | 27 | - Go: `cd go && go test ./...` |
27 | 28 | - .NET: `cd dotnet && dotnet test test/GitHub.Copilot.SDK.Test.csproj` |
28 | 29 | - **.NET testing note:** Never add `InternalsVisibleTo` to any project file when writing tests. Tests must only access public APIs. |
| 30 | + - Java: `cd java && mvn clean verify` (full build + tests), `mvn spotless:apply` (format code before commit) |
| 31 | + - **Java testing note:** Always use `mvn verify` without `-q` and without piping through `grep`. Never add `InternalsVisibleTo` equivalent — tests must only access public APIs. |
29 | 32 |
|
30 | 33 | ## Testing & E2E tips ⚙️ |
31 | 34 |
|
32 | 35 | - E2E runs against a local **replaying CAPI proxy** (see `test/harness/server.ts`). Most language E2E harnesses spawn that server automatically (see `python/e2e/testharness/proxy.py`). |
33 | 36 | - Tests rely on YAML snapshot exchanges under `test/snapshots/` — to add test scenarios, add or edit the appropriate YAML files and update tests. |
34 | 37 | - The harness prints `Listening: http://...` — tests parse this URL to configure CLI or proxy. |
| 38 | +- Java E2E tests use `E2ETestContext` which manages a `CapiProxy` (Node.js replaying proxy). The harness is cloned during Maven's `generate-test-resources` phase to `java/target/copilot-sdk/`. |
35 | 39 |
|
36 | 40 | ## Project-specific conventions & patterns ✅ |
37 | 41 |
|
|
42 | 46 |
|
43 | 47 | ## Integration & environment notes ⚠️ |
44 | 48 |
|
45 | | -- The SDK requires a Copilot CLI installation or an external server reachable via the `CLI URL option (language-specific casing)` (Node: `cliUrl`, Go: `CLIUrl`, .NET: `CliUrl`, Python: `cli_url`) or `COPILOT_CLI_PATH`. |
| 49 | +- The SDK requires a Copilot CLI installation or an external server reachable via the `CLI URL option (language-specific casing)` (Node: `cliUrl`, Go: `CLIUrl`, .NET: `CliUrl`, Python: `cli_url`, Java: `cliUrl`) or `COPILOT_CLI_PATH`. |
46 | 50 | - Some scripts (typegen, formatting) call external tools: `gofmt`, `dotnet format`, `tsx` (available via npm), `quicktype`/`quicktype-core` (used by the Node typegen script), and `prettier` (provided as an npm devDependency). Most of these are available through the repo's package scripts or devDependencies—run `just install` (and `cd nodejs && npm ci`) to install them. Ensure the required tools are available in CI / developer machines. |
47 | 51 | - Tests may assume `node >= 18`, `python >= 3.9`, platform differences handled (Windows uses `shell=True` for npx in harness). |
| 52 | +- Java requires JDK 17+ and Maven 3.9+. Java E2E tests also require Node.js (for the replay proxy). |
48 | 53 |
|
49 | 54 | ## Where to add new code or tests 🧭 |
50 | 55 |
|
51 | | -- SDK code: `nodejs/src`, `python/copilot`, `go`, `dotnet/src`, `rust/src` |
52 | | -- Unit tests: `nodejs/test`, `python/*`, `go/*`, `dotnet/test`, `rust/tests` |
53 | | -- E2E tests: `*/e2e/` folders that use the shared replay proxy and `test/snapshots/` |
54 | | -- Generated types: update schema in `@github/copilot` then run `cd nodejs && npm run generate:session-types` and commit generated files in `src/generated` or language generated location. |
| 56 | +- SDK code: `nodejs/src`, `python/copilot`, `go`, `dotnet/src`, `rust/src`, `java/src/main/java` |
| 57 | +- Unit tests: `nodejs/test`, `python/*`, `go/*`, `dotnet/test`, `rust/tests`, `java/src/test/java` |
| 58 | +- E2E tests: `*/e2e/` folders that use the shared replay proxy and `test/snapshots/`, `java/src/test/java/**/e2e/` |
| 59 | +- Generated types: update schema in `@github/copilot` then run `cd nodejs && npm run generate:session-types` and commit generated files in `src/generated` or language generated location. Java generated types: `java/src/generated/java` |
0 commit comments