Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 36 additions & 23 deletions .github/agents/docs-maintenance.agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The human will then review the plan and selectively ask Copilot to implement spe

Create a file called `docs/IMPROVEMENT_PLAN.md` with this structure:

```markdown
````markdown
# Documentation Improvement Plan

Generated: [date]
Expand All @@ -43,6 +43,7 @@ Audited by: docs-maintenance agent
## Critical Issues (Fix Immediately)

### 1. [Issue Title]

- **File**: `docs/path/to/file.md`
- **Line**: ~42
- **Problem**: [description]
Expand All @@ -53,6 +54,7 @@ Audited by: docs-maintenance agent
## High Priority (Should Fix Soon)

### 1. [Issue Title]

- **File**: `docs/path/to/file.md`
- **Problem**: [description]
- **Fix**: [specific action to take]
Expand All @@ -79,15 +81,18 @@ The following code samples don't match the SDK interface:
### File: `docs/example.md`

**Line ~25 - TypeScript sample uses wrong method name:**

```typescript
// Current (wrong):
await client.create_session()
await client.create_session();

// Should be:
await client.createSession()
await client.createSession();
```
````

**Line ~45 - Python sample has camelCase:**

```python
# Current (wrong):
client = CopilotClient(cliPath="/usr/bin/copilot")
Expand All @@ -98,14 +103,15 @@ client = CopilotClient(cli_path="/usr/bin/copilot")

## Broken Links

| Source File | Line | Broken Link | Suggested Fix |
|-------------|------|-------------|---------------|
| `docs/a.md` | 15 | `./missing.md` | Remove or create file |
| Source File | Line | Broken Link | Suggested Fix |
| ----------- | ---- | -------------- | --------------------- |
| `docs/a.md` | 15 | `./missing.md` | Remove or create file |

## Consistency Issues

- [ ] Term "XXX" used inconsistently (file1.md says "A", file2.md says "B")
- [ ] ...

```

Comment on lines 115 to 116
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This closing code fence (``` at line 115) no longer matches any opening fence after the earlier change to use ````markdown; it will break markdown rendering. Remove this stray fence or change it to the correct matching closing fence if the outer example block is intended to end here.

This issue also appears in the following locations of the same file:

  • line 267
  • line 285
  • line 88
Suggested change
```

Copilot uses AI. Check for mistakes.
After creating this plan file, your work is complete. The platform (github.com) will handle creating a PR if applicable.
Expand Down Expand Up @@ -242,21 +248,23 @@ When auditing documentation, check:
The expected documentation structure is:

```

docs/
├── getting-started.md # Quick start tutorial
├── debugging.md # General debugging guide
├── compatibility.md # SDK vs CLI feature comparison
├── getting-started.md # Quick start tutorial
├── debugging.md # General debugging guide
├── compatibility.md # SDK vs CLI feature comparison
├── hooks/
├── overview.md # Hooks introduction
├── pre-tool-use.md # Permission control
├── post-tool-use.md # Result transformation
├── user-prompt-submitted.md
├── session-lifecycle.md
└── error-handling.md
│ ├── overview.md # Hooks introduction
│ ├── pre-tool-use.md # Permission control
│ ├── post-tool-use.md # Result transformation
│ ├── user-prompt-submitted.md
│ ├── session-lifecycle.md
│ └── error-handling.md
└── mcp/
├── overview.md # MCP configuration
└── debugging.md # MCP troubleshooting
```
├── overview.md # MCP configuration
└── debugging.md # MCP troubleshooting

````

Additional directories to consider:
- `docs/tools/` - Custom tool development
Expand All @@ -274,7 +282,7 @@ find docs -name "*.md" -type f | sort

# Check for README references
grep -r "docs/" README.md
```
````

### Step 2: Check Feature Coverage

Expand Down Expand Up @@ -342,6 +350,7 @@ cat nodejs/src/types.ts | grep -A 10 "export interface ExportSessionOptions"
```

**Must match:**

- `CopilotClient` constructor options: `cliPath`, `cliUrl`, `useStdio`, `port`, `logLevel`, `autoStart`, `autoRestart`, `env`, `githubToken`, `useLoggedInUser`
- `createSession()` config: `model`, `tools`, `hooks`, `systemMessage`, `mcpServers`, `availableTools`, `excludedTools`, `streaming`, `reasoningEffort`, `provider`, `infiniteSessions`, `customAgents`, `workingDirectory`
- `CopilotSession` methods: `send()`, `sendAndWait()`, `getMessages()`, `destroy()`, `abort()`, `on()`, `once()`, `off()`
Expand All @@ -360,6 +369,7 @@ cat python/copilot/types.py | grep -A 15 "class SessionHooks"
```

**Must match (snake_case):**

- `CopilotClient` options: `cli_path`, `cli_url`, `use_stdio`, `port`, `log_level`, `auto_start`, `auto_restart`, `env`, `github_token`, `use_logged_in_user`
- `create_session()` config keys: `model`, `tools`, `hooks`, `system_message`, `mcp_servers`, `available_tools`, `excluded_tools`, `streaming`, `reasoning_effort`, `provider`, `infinite_sessions`, `custom_agents`, `working_directory`
- `CopilotSession` methods: `send()`, `send_and_wait()`, `get_messages()`, `destroy()`, `abort()`, `export_session()`
Expand All @@ -378,7 +388,8 @@ cat go/types.go | grep -A 15 "type SessionHooks struct"
```

**Must match (PascalCase for exported):**
- `ClientOptions` fields: `CLIPath`, `CLIUrl`, `UseStdio`, `Port`, `LogLevel`, `AutoStart`, `AutoRestart`, `Env`, `GithubToken`, `UseLoggedInUser`

- `ClientOptions` fields: `CLIPath`, `CLIUrl`, `UseStdio`, `Port`, `LogLevel`, `AutoStart`, `AutoRestart`, `Env`, `GitHubToken`, `UseLoggedInUser`
- `SessionConfig` fields: `Model`, `Tools`, `Hooks`, `SystemMessage`, `MCPServers`, `AvailableTools`, `ExcludedTools`, `Streaming`, `ReasoningEffort`, `Provider`, `InfiniteSessions`, `CustomAgents`, `WorkingDirectory`
- `Session` methods: `Send()`, `SendAndWait()`, `GetMessages()`, `Destroy()`, `Abort()`, `ExportSession()`
- Hook fields: `OnPreToolUse`, `OnPostToolUse`, `OnUserPromptSubmitted`, `OnSessionStart`, `OnSessionEnd`, `OnErrorOccurred`
Expand All @@ -396,7 +407,8 @@ cat dotnet/src/Types.cs | grep -A 15 "public class SessionHooks"
```

**Must match (PascalCase):**
- `CopilotClientOptions` properties: `CliPath`, `CliUrl`, `UseStdio`, `Port`, `LogLevel`, `AutoStart`, `AutoRestart`, `Environment`, `GithubToken`, `UseLoggedInUser`

- `CopilotClientOptions` properties: `CliPath`, `CliUrl`, `UseStdio`, `Port`, `LogLevel`, `AutoStart`, `AutoRestart`, `Environment`, `GitHubToken`, `UseLoggedInUser`
- `SessionConfig` properties: `Model`, `Tools`, `Hooks`, `SystemMessage`, `McpServers`, `AvailableTools`, `ExcludedTools`, `Streaming`, `ReasoningEffort`, `Provider`, `InfiniteSessions`, `CustomAgents`, `WorkingDirectory`
- `CopilotSession` methods: `SendAsync()`, `SendAndWaitAsync()`, `GetMessagesAsync()`, `DisposeAsync()`, `AbortAsync()`, `ExportSessionAsync()`
- Hook properties: `OnPreToolUse`, `OnPostToolUse`, `OnUserPromptSubmitted`, `OnSessionStart`, `OnSessionEnd`, `OnErrorOccurred`
Expand Down Expand Up @@ -429,7 +441,7 @@ cat dotnet/src/Types.cs | grep -A 15 "public class SessionHooks"

Run this to extract all code blocks and check for common issues:

```bash
````bash
# Extract TypeScript examples and check for Python-style naming
grep -A 20 '```typescript' docs/**/*.md | grep -E "cli_path|create_session|send_and_wait" && echo "ERROR: Python naming in TypeScript"

Expand All @@ -438,7 +450,7 @@ grep -A 20 '```python' docs/**/*.md | grep -E "cliPath|createSession|sendAndWait

# Check Go examples have context parameter
grep -A 20 '```go' docs/**/*.md | grep -E "CreateSession\([^c]|Send\([^c]" && echo "WARNING: Go method may be missing context"
```
````

### Step 6: Create the Plan

Expand All @@ -448,6 +460,7 @@ After completing the audit:
2. Your work is complete - the platform handles PR creation

The human reviewer can then:

- Review the plan
- Comment on specific items to prioritize
- Ask Copilot to implement specific fixes from the plan
Expand Down
40 changes: 28 additions & 12 deletions docs/auth/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ The GitHub Copilot SDK supports multiple authentication methods to fit different

## Authentication Methods

| Method | Use Case | Copilot Subscription Required |
|--------|----------|-------------------------------|
| [GitHub Signed-in User](#github-signed-in-user) | Interactive apps where users sign in with GitHub | Yes |
| [OAuth GitHub App](#oauth-github-app) | Apps acting on behalf of users via OAuth | Yes |
| [Environment Variables](#environment-variables) | CI/CD, automation, server-to-server | Yes |
| [BYOK (Bring Your Own Key)](./byok.md) | Using your own API keys (Azure AI Foundry, OpenAI, etc.) | No |
| Method | Use Case | Copilot Subscription Required |
| ----------------------------------------------- | -------------------------------------------------------- | ----------------------------- |
| [GitHub Signed-in User](#github-signed-in-user) | Interactive apps where users sign in with GitHub | Yes |
| [OAuth GitHub App](#oauth-github-app) | Apps acting on behalf of users via OAuth | Yes |
| [Environment Variables](#environment-variables) | CI/CD, automation, server-to-server | Yes |
| [BYOK (Bring Your Own Key)](./byok.md) | Using your own API keys (Azure AI Foundry, OpenAI, etc.) | No |

## GitHub Signed-in User

This is the default authentication method when running the Copilot CLI interactively. Users authenticate via GitHub OAuth device flow, and the SDK uses their stored credentials.

**How it works:**

1. User runs `copilot` CLI and signs in via GitHub OAuth
2. Credentials are stored securely in the system keychain
3. SDK automatically uses stored credentials
Expand Down Expand Up @@ -51,6 +52,7 @@ await client.start()
<summary><strong>Go</strong></summary>

<!-- docs-validate: skip -->

```go
import copilot "github.com/github/copilot-sdk/go"

Expand All @@ -73,6 +75,7 @@ await using var client = new CopilotClient();
</details>

**When to use:**

- Desktop applications where users interact directly
- Development and testing environments
- Any scenario where a user can sign in interactively
Expand All @@ -82,6 +85,7 @@ await using var client = new CopilotClient();
Use an OAuth GitHub App to authenticate users through your application and pass their credentials to the SDK. This enables your application to make Copilot API requests on behalf of users who authorize your app.

**How it works:**

1. User authorizes your OAuth GitHub App
2. Your app receives a user access token (`gho_` or `ghu_` prefix)
3. Pass the token to the SDK via `githubToken` option
Expand All @@ -95,8 +99,8 @@ Use an OAuth GitHub App to authenticate users through your application and pass
import { CopilotClient } from "@github/copilot-sdk";

const client = new CopilotClient({
githubToken: userAccessToken, // Token from OAuth flow
useLoggedInUser: false, // Don't use stored CLI credentials
githubToken: userAccessToken, // Token from OAuth flow
useLoggedInUser: false, // Don't use stored CLI credentials
});
```

Expand All @@ -121,11 +125,12 @@ await client.start()
<summary><strong>Go</strong></summary>

<!-- docs-validate: skip -->

```go
import copilot "github.com/github/copilot-sdk/go"

client := copilot.NewClient(&copilot.ClientOptions{
GithubToken: userAccessToken, // Token from OAuth flow
GitHubToken: userAccessToken, // Token from OAuth flow
UseLoggedInUser: copilot.Bool(false), // Don't use stored CLI credentials
})
```
Expand All @@ -136,27 +141,31 @@ client := copilot.NewClient(&copilot.ClientOptions{
<summary><strong>.NET</strong></summary>

<!-- docs-validate: skip -->

```csharp
using GitHub.Copilot.SDK;

await using var client = new CopilotClient(new CopilotClientOptions
{
GithubToken = userAccessToken, // Token from OAuth flow
GitHubToken = userAccessToken, // Token from OAuth flow
UseLoggedInUser = false, // Don't use stored CLI credentials
});
```

</details>

**Supported token types:**

- `gho_` - OAuth user access tokens
- `ghu_` - GitHub App user access tokens
- `ghu_` - GitHub App user access tokens
- `github_pat_` - Fine-grained personal access tokens

**Not supported:**

- `ghp_` - Classic personal access tokens (deprecated)

**When to use:**

- Web applications where users sign in via GitHub
- SaaS applications building on top of Copilot
- Any multi-user application where you need to make requests on behalf of different users
Expand All @@ -166,11 +175,13 @@ await using var client = new CopilotClient(new CopilotClientOptions
For automation, CI/CD pipelines, and server-to-server scenarios, you can authenticate using environment variables.

**Supported environment variables (in priority order):**

1. `COPILOT_GITHUB_TOKEN` - Recommended for explicit Copilot usage
2. `GH_TOKEN` - GitHub CLI compatible
3. `GITHUB_TOKEN` - GitHub Actions compatible

**How it works:**

1. Set one of the supported environment variables with a valid token
2. The SDK automatically detects and uses the token

Expand Down Expand Up @@ -204,6 +215,7 @@ await client.start()
</details>

**When to use:**

- CI/CD pipelines (GitHub Actions, Jenkins, etc.)
- Automated testing
- Server-side applications with service accounts
Expand All @@ -214,12 +226,14 @@ await client.start()
BYOK allows you to use your own API keys from model providers like Azure AI Foundry, OpenAI, or Anthropic. This bypasses GitHub Copilot authentication entirely.

**Key benefits:**

- No GitHub Copilot subscription required
- Use enterprise model deployments
- Direct billing with your model provider
- Support for Azure AI Foundry, OpenAI, Anthropic, and OpenAI-compatible endpoints

**See the [BYOK documentation](./byok.md) for complete details**, including:

- Azure AI Foundry setup
- Provider configuration options
- Limitations and considerations
Expand All @@ -245,7 +259,7 @@ To prevent the SDK from automatically using stored credentials or `gh` CLI auth,

```typescript
const client = new CopilotClient({
useLoggedInUser: false, // Only use explicit tokens
useLoggedInUser: false, // Only use explicit tokens
});
```

Expand All @@ -255,6 +269,7 @@ const client = new CopilotClient({
<summary><strong>Python</strong></summary>

<!-- docs-validate: skip -->

```python
client = CopilotClient({
"use_logged_in_user": False, # Only use explicit tokens
Expand All @@ -267,6 +282,7 @@ client = CopilotClient({
<summary><strong>Go</strong></summary>

<!-- docs-validate: skip -->

```go
client := copilot.NewClient(&copilot.ClientOptions{
UseLoggedInUser: copilot.Bool(false), // Only use explicit tokens
Expand Down
Loading
Loading