Skip to content

Commit 3a6342c

Browse files
committed
Phase 1: .githooks and instructions
1 parent 4f6d36f commit 3a6342c

4 files changed

Lines changed: 800 additions & 9 deletions

File tree

.githooks/pre-commit

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/sh
2+
#
3+
# Pre-commit hook that runs Spotless check on the Java SDK when Java source
4+
# files are staged. Only triggers if changes exist under java/src/.
5+
#
6+
# To install this hook, run from the repository root:
7+
# git config core.hooksPath .githooks
8+
#
9+
10+
# Only run Spotless if staged changes include Java source files under java/src/
11+
if ! git diff --cached --name-only | grep -q '^java/src/'; then
12+
exit 0
13+
fi
14+
15+
echo "Running Spotless check on java/ ..."
16+
17+
# Run spotless check from the java directory
18+
(cd java && mvn spotless:check -q)
19+
20+
if [ $? -ne 0 ]; then
21+
echo ""
22+
echo "❌ Spotless check failed!"
23+
echo " Run 'cd java && mvn spotless:apply' to fix formatting issues."
24+
echo ""
25+
exit 1
26+
fi
27+
28+
echo "✓ Spotless check passed"
29+
exit 0

.github/copilot-instructions.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
## Big picture 🔧
66

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`).
99

1010
## Most important files to read first 📚
1111

1212
- Top-level: `README.md` (architecture + quick start)
1313
- Language entry points: `nodejs/src/client.ts`, `python/README.md`, `go/README.md`, `dotnet/README.md`
14+
- Java: `java/README.md`, `java/pom.xml`
1415
- Test harness & E2E: `test/harness/*`, Python harness wrapper `python/e2e/testharness/proxy.py`
1516
- Schemas & type generation: `nodejs/scripts/generate-session-types.ts`
1617
- Session snapshots used by E2E: `test/snapshots/` (used by the replay proxy)
@@ -26,12 +27,15 @@
2627
- Go: `cd go && go test ./...`
2728
- .NET: `cd dotnet && dotnet test test/GitHub.Copilot.SDK.Test.csproj`
2829
- **.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.
2932

3033
## Testing & E2E tips ⚙️
3134

3235
- 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`).
3336
- Tests rely on YAML snapshot exchanges under `test/snapshots/` — to add test scenarios, add or edit the appropriate YAML files and update tests.
3437
- 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/`.
3539

3640
## Project-specific conventions & patterns ✅
3741

@@ -42,13 +46,14 @@
4246

4347
## Integration & environment notes ⚠️
4448

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`.
4650
- 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.
4751
- 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).
4853

4954
## Where to add new code or tests 🧭
5055

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

Comments
 (0)