Skip to content

Commit 327a798

Browse files
patnikoCopilot
andauthored
docs: replace 72 skip directives with hidden compilable blocks (#721)
that the validator checks, while keeping user-facing snippets unchanged. Changes across 22 markdown files: - Hook type signatures (5 files × 4 langs): 20 skips removed - Hook Go/C# implementations (4 files): 10 skips removed - Guide Go/C#/Py snippets (8 files): 21 skips removed - Setup/auth snippets (7 files): 11 skips removed - OpenTelemetry Python (1 file): 4 skips removed - Misc snippets (2 files): 4 skips removed Remaining 14 skips are due to external package dependencies not available to the validator (Microsoft.Agents.AI, @azure/identity, Azure.Identity, aiofiles, Microsoft.Extensions.Logging). All 305 extracted code blocks pass validation across TypeScript (160), Python (62), Go (41), and C# (42). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c786a35 commit 327a798

22 files changed

+1478
-72
lines changed

docs/auth/byok.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,21 @@ const session = await client.createSession({
363363

364364
For Azure OpenAI endpoints (`*.openai.azure.com`), use the correct type:
365365

366-
<!-- docs-validate: skip -->
366+
<!-- docs-validate: hidden -->
367+
```typescript
368+
import { CopilotClient } from "@github/copilot-sdk";
369+
370+
const client = new CopilotClient();
371+
const session = await client.createSession({
372+
model: "gpt-4.1",
373+
provider: {
374+
type: "azure",
375+
baseUrl: "https://my-resource.openai.azure.com",
376+
},
377+
});
378+
```
379+
<!-- /docs-validate: hidden -->
380+
367381
```typescript
368382
// ❌ Wrong: Using "openai" type with native Azure endpoint
369383
provider: {
@@ -380,7 +394,21 @@ provider: {
380394

381395
However, if your Azure AI Foundry deployment provides an OpenAI-compatible endpoint path (e.g., `/openai/v1/`), use `type: "openai"`:
382396

383-
<!-- docs-validate: skip -->
397+
<!-- docs-validate: hidden -->
398+
```typescript
399+
import { CopilotClient } from "@github/copilot-sdk";
400+
401+
const client = new CopilotClient();
402+
const session = await client.createSession({
403+
model: "gpt-4.1",
404+
provider: {
405+
type: "openai",
406+
baseUrl: "https://your-resource.openai.azure.com/openai/v1/",
407+
},
408+
});
409+
```
410+
<!-- /docs-validate: hidden -->
411+
384412
```typescript
385413
// ✅ Correct: OpenAI-compatible Azure AI Foundry endpoint
386414
provider: {

docs/auth/index.md

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,20 @@ await client.start()
5050
<details>
5151
<summary><strong>Go</strong></summary>
5252

53-
<!-- docs-validate: skip -->
53+
<!-- docs-validate: hidden -->
54+
```go
55+
package main
56+
57+
import copilot "github.com/github/copilot-sdk/go"
58+
59+
func main() {
60+
// Default: uses logged-in user credentials
61+
client := copilot.NewClient(nil)
62+
_ = client
63+
}
64+
```
65+
<!-- /docs-validate: hidden -->
66+
5467
```go
5568
import copilot "github.com/github/copilot-sdk/go"
5669

@@ -120,7 +133,23 @@ await client.start()
120133
<details>
121134
<summary><strong>Go</strong></summary>
122135

123-
<!-- docs-validate: skip -->
136+
<!-- docs-validate: hidden -->
137+
```go
138+
package main
139+
140+
import copilot "github.com/github/copilot-sdk/go"
141+
142+
func main() {
143+
userAccessToken := "token"
144+
client := copilot.NewClient(&copilot.ClientOptions{
145+
GitHubToken: userAccessToken,
146+
UseLoggedInUser: copilot.Bool(false),
147+
})
148+
_ = client
149+
}
150+
```
151+
<!-- /docs-validate: hidden -->
152+
124153
```go
125154
import copilot "github.com/github/copilot-sdk/go"
126155

@@ -135,7 +164,19 @@ client := copilot.NewClient(&copilot.ClientOptions{
135164
<details>
136165
<summary><strong>.NET</strong></summary>
137166

138-
<!-- docs-validate: skip -->
167+
<!-- docs-validate: hidden -->
168+
```csharp
169+
using GitHub.Copilot.SDK;
170+
171+
var userAccessToken = "token";
172+
await using var client = new CopilotClient(new CopilotClientOptions
173+
{
174+
GithubToken = userAccessToken,
175+
UseLoggedInUser = false,
176+
});
177+
```
178+
<!-- /docs-validate: hidden -->
179+
139180
```csharp
140181
using GitHub.Copilot.SDK;
141182

@@ -254,7 +295,16 @@ const client = new CopilotClient({
254295
<details>
255296
<summary><strong>Python</strong></summary>
256297

257-
<!-- docs-validate: skip -->
298+
<!-- docs-validate: hidden -->
299+
```python
300+
from copilot import CopilotClient
301+
302+
client = CopilotClient({
303+
"use_logged_in_user": False,
304+
})
305+
```
306+
<!-- /docs-validate: hidden -->
307+
258308
```python
259309
client = CopilotClient({
260310
"use_logged_in_user": False, # Only use explicit tokens
@@ -266,7 +316,21 @@ client = CopilotClient({
266316
<details>
267317
<summary><strong>Go</strong></summary>
268318

269-
<!-- docs-validate: skip -->
319+
<!-- docs-validate: hidden -->
320+
```go
321+
package main
322+
323+
import copilot "github.com/github/copilot-sdk/go"
324+
325+
func main() {
326+
client := copilot.NewClient(&copilot.ClientOptions{
327+
UseLoggedInUser: copilot.Bool(false),
328+
})
329+
_ = client
330+
}
331+
```
332+
<!-- /docs-validate: hidden -->
333+
270334
```go
271335
client := copilot.NewClient(&copilot.ClientOptions{
272336
UseLoggedInUser: copilot.Bool(false), // Only use explicit tokens

docs/debugging.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,21 @@ client = CopilotClient({"log_level": "debug"})
4444
<details>
4545
<summary><strong>Go</strong></summary>
4646

47-
<!-- docs-validate: skip -->
47+
<!-- docs-validate: hidden -->
48+
```go
49+
package main
50+
51+
import copilot "github.com/github/copilot-sdk/go"
52+
53+
func main() {
54+
client := copilot.NewClient(&copilot.ClientOptions{
55+
LogLevel: "debug",
56+
})
57+
_ = client
58+
}
59+
```
60+
<!-- /docs-validate: hidden -->
61+
4862
```go
4963
import copilot "github.com/github/copilot-sdk/go"
5064

@@ -59,6 +73,7 @@ client := copilot.NewClient(&copilot.ClientOptions{
5973
<summary><strong>.NET</strong></summary>
6074

6175
<!-- docs-validate: skip -->
76+
6277
```csharp
6378
using GitHub.Copilot.SDK;
6479
using Microsoft.Extensions.Logging;
@@ -110,7 +125,18 @@ const client = new CopilotClient({
110125
<details>
111126
<summary><strong>Go</strong></summary>
112127

113-
<!-- docs-validate: skip -->
128+
<!-- docs-validate: hidden -->
129+
```go
130+
package main
131+
132+
func main() {
133+
// The Go SDK does not currently support passing extra CLI arguments.
134+
// For custom log directories, run the CLI manually with --log-dir
135+
// and connect via CLIUrl option.
136+
}
137+
```
138+
<!-- /docs-validate: hidden -->
139+
114140
```go
115141
// The Go SDK does not currently support passing extra CLI arguments.
116142
// For custom log directories, run the CLI manually with --log-dir

docs/guides/custom-agents.md

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,47 @@ session = await client.create_session({
9797
<details>
9898
<summary><strong>Go</strong></summary>
9999

100-
<!-- docs-validate: skip -->
100+
<!-- docs-validate: hidden -->
101+
```go
102+
package main
103+
104+
import (
105+
"context"
106+
copilot "github.com/github/copilot-sdk/go"
107+
)
108+
109+
func main() {
110+
ctx := context.Background()
111+
client := copilot.NewClient(nil)
112+
client.Start(ctx)
113+
114+
session, _ := client.CreateSession(ctx, &copilot.SessionConfig{
115+
Model: "gpt-4.1",
116+
CustomAgents: []copilot.CustomAgentConfig{
117+
{
118+
Name: "researcher",
119+
DisplayName: "Research Agent",
120+
Description: "Explores codebases and answers questions using read-only tools",
121+
Tools: []string{"grep", "glob", "view"},
122+
Prompt: "You are a research assistant. Analyze code and answer questions. Do not modify any files.",
123+
},
124+
{
125+
Name: "editor",
126+
DisplayName: "Editor Agent",
127+
Description: "Makes targeted code changes",
128+
Tools: []string{"view", "edit", "bash"},
129+
Prompt: "You are a code editor. Make minimal, surgical changes to files as requested.",
130+
},
131+
},
132+
OnPermissionRequest: func(req copilot.PermissionRequest, inv copilot.PermissionInvocation) (copilot.PermissionRequestResult, error) {
133+
return copilot.PermissionRequestResult{Kind: copilot.PermissionRequestResultKindApproved}, nil
134+
},
135+
})
136+
_ = session
137+
}
138+
```
139+
<!-- /docs-validate: hidden -->
140+
101141
```go
102142
ctx := context.Background()
103143
client := copilot.NewClient(nil)
@@ -287,7 +327,51 @@ response = await session.send_and_wait({
287327
<details>
288328
<summary><strong>Go</strong></summary>
289329

290-
<!-- docs-validate: skip -->
330+
<!-- docs-validate: hidden -->
331+
```go
332+
package main
333+
334+
import (
335+
"context"
336+
"fmt"
337+
copilot "github.com/github/copilot-sdk/go"
338+
)
339+
340+
func main() {
341+
ctx := context.Background()
342+
client := copilot.NewClient(nil)
343+
client.Start(ctx)
344+
345+
session, _ := client.CreateSession(ctx, &copilot.SessionConfig{
346+
Model: "gpt-4.1",
347+
OnPermissionRequest: func(req copilot.PermissionRequest, inv copilot.PermissionInvocation) (copilot.PermissionRequestResult, error) {
348+
return copilot.PermissionRequestResult{Kind: copilot.PermissionRequestResultKindApproved}, nil
349+
},
350+
})
351+
352+
session.On(func(event copilot.SessionEvent) {
353+
switch event.Type {
354+
case "subagent.started":
355+
fmt.Printf("▶ Sub-agent started: %s\n", *event.Data.AgentDisplayName)
356+
fmt.Printf(" Description: %s\n", *event.Data.AgentDescription)
357+
fmt.Printf(" Tool call ID: %s\n", *event.Data.ToolCallID)
358+
case "subagent.completed":
359+
fmt.Printf("✅ Sub-agent completed: %s\n", *event.Data.AgentDisplayName)
360+
case "subagent.failed":
361+
fmt.Printf("❌ Sub-agent failed: %s%v\n", *event.Data.AgentDisplayName, event.Data.Error)
362+
case "subagent.selected":
363+
fmt.Printf("🎯 Agent selected: %s\n", *event.Data.AgentDisplayName)
364+
}
365+
})
366+
367+
_, err := session.SendAndWait(ctx, copilot.MessageOptions{
368+
Prompt: "Research how authentication works in this codebase",
369+
})
370+
_ = err
371+
}
372+
```
373+
<!-- /docs-validate: hidden -->
374+
291375
```go
292376
session.On(func(event copilot.SessionEvent) {
293377
switch event.Type {

0 commit comments

Comments
 (0)