|
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, Rust) 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`, Rust: `cli_url`). |
9 | 9 |
|
10 | 10 | ## Most important files to read first 📚 |
11 | 11 |
|
12 | 12 | - Top-level: `README.md` (architecture + quick start) |
13 | | -- Language entry points: `nodejs/src/client.ts`, `python/README.md`, `go/README.md`, `dotnet/README.md` |
| 13 | +- Language entry points: `nodejs/src/client.ts`, `python/README.md`, `go/README.md`, `dotnet/README.md`, `rust/README.md` |
14 | 14 | - Test harness & E2E: `test/harness/*`, Python harness wrapper `python/e2e/testharness/proxy.py` |
15 | 15 | - Schemas & type generation: `nodejs/scripts/generate-session-types.ts` |
16 | 16 | - Session snapshots used by E2E: `test/snapshots/` (used by the replay proxy) |
|
25 | 25 | - Python: `cd python && uv pip install -e ".[dev]"` → `uv run pytest` (E2E tests use the test harness) |
26 | 26 | - Go: `cd go && go test ./...` |
27 | 27 | - .NET: `cd dotnet && dotnet test test/GitHub.Copilot.SDK.Test.csproj` |
| 28 | + - Rust: `cd rust && cargo test` |
28 | 29 | - **.NET testing note:** Never add `InternalsVisibleTo` to any project file when writing tests. Tests must only access public APIs. |
29 | 30 |
|
30 | 31 | ## Testing & E2E tips ⚙️ |
|
35 | 36 |
|
36 | 37 | ## Project-specific conventions & patterns ✅ |
37 | 38 |
|
38 | | -- Tools: each SDK has helper APIs to expose functions as tools; prefer the language's `DefineTool`/`@define_tool`/`AIFunctionFactory.Create` patterns (see language READMEs). |
| 39 | +- Tools: each SDK has helper APIs to expose functions as tools; prefer the language's `DefineTool`/`@define_tool`/`AIFunctionFactory.Create`/`ToolHandler` trait patterns (see language READMEs). |
39 | 40 | - Infinite sessions are enabled by default and persist workspace state to `~/.copilot/session-state/{sessionId}`; compaction events are emitted (`session.compaction_start`, `session.compaction_complete`). See language READMEs for usage. |
40 | 41 | - Streaming: when `streaming`/`Streaming=true` you receive delta events (`assistant.message_delta`, `assistant.reasoning_delta`) and final events (`assistant.message`, `assistant.reasoning`) — tests expect this behavior. |
41 | 42 | - Type generation is centralized in `nodejs/scripts/generate-session-types.ts` and requires the `@github/copilot` schema to be present (often via `npm link` or installed package). |
42 | 43 |
|
43 | 44 | ## Integration & environment notes ⚠️ |
44 | 45 |
|
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`. |
| 46 | +- 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`, Rust: `cli_url`) or `COPILOT_CLI_PATH`. |
46 | 47 | - 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 | 48 | - Tests may assume `node >= 18`, `python >= 3.9`, platform differences handled (Windows uses `shell=True` for npx in harness). |
48 | 49 |
|
49 | 50 | ## Where to add new code or tests 🧭 |
50 | 51 |
|
51 | | -- SDK code: `nodejs/src`, `python/copilot`, `go`, `dotnet/src` |
52 | | -- Unit tests: `nodejs/test`, `python/*`, `go/*`, `dotnet/test` |
| 52 | +- SDK code: `nodejs/src`, `python/copilot`, `go`, `dotnet/src`, `rust/src` |
| 53 | +- Unit tests: `nodejs/test`, `python/*`, `go/*`, `dotnet/test`, `rust/tests` |
53 | 54 | - E2E tests: `*/e2e/` folders that use the shared replay proxy and `test/snapshots/` |
54 | 55 | - 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. |
0 commit comments