Skip to content

Commit 7efcfe5

Browse files
committed
Fix documentation accuracy issues
Go SDK fixes: - NewClient returns *Client (not error), takes *ClientOptions - CreateSession requires context.Context and *SessionConfig (pointer) - Updated all Go examples in debugging.md, hooks/*.md Session API fixes: - sendPrompt/SendPrompt doesn't exist - use send/sendAndWait - Fixed all TypeScript, Python, Go, .NET examples in session-persistence.md Link fixes: - getting-started.md: ./mcp.md → ./mcp/overview.md (file moved)
1 parent c67c16b commit 7efcfe5

File tree

8 files changed

+25
-23
lines changed

8 files changed

+25
-23
lines changed

docs/debugging.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ client = CopilotClient(log_level="debug")
4747
```go
4848
import copilot "github.com/github/copilot-sdk/go"
4949

50-
client, err := copilot.NewClient(copilot.ClientOptions{
50+
client := copilot.NewClient(&copilot.ClientOptions{
5151
LogLevel: "debug",
5252
})
5353
```
@@ -169,7 +169,7 @@ var client = new CopilotClient(new CopilotClientOptions
169169
<summary><strong>Go</strong></summary>
170170

171171
```go
172-
client, _ := copilot.NewClient(copilot.ClientOptions{
172+
client := copilot.NewClient(&copilot.ClientOptions{
173173
CLIPath: "/usr/local/bin/copilot",
174174
})
175175
```
@@ -222,7 +222,7 @@ var client = new CopilotClient(new CopilotClientOptions
222222
<summary><strong>Go</strong></summary>
223223

224224
```go
225-
client, _ := copilot.NewClient(copilot.ClientOptions{
225+
client := copilot.NewClient(&copilot.ClientOptions{
226226
GithubToken: os.Getenv("GITHUB_TOKEN"),
227227
})
228228
```

docs/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ const session = await client.createSession({
10201020
});
10211021
```
10221022

1023-
📖 **[Full MCP documentation →](./mcp.md)** - Learn about local vs remote servers, all configuration options, and troubleshooting.
1023+
📖 **[Full MCP documentation →](./mcp/overview.md)** - Learn about local vs remote servers, all configuration options, and troubleshooting.
10241024

10251025
### Create Custom Agents
10261026

docs/guides/session-persistence.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const session = await client.createSession({
3737
});
3838

3939
// Do some work...
40-
await session.sendPrompt({ content: "Analyze my codebase" });
40+
await session.sendAndWait({ prompt: "Analyze my codebase" });
4141

4242
// Session state is automatically persisted
4343
// You can safely close the client
@@ -57,24 +57,24 @@ session = await client.create_session(
5757
)
5858

5959
# Do some work...
60-
await session.send_prompt(content="Analyze my codebase")
60+
await session.send_and_wait({"prompt": "Analyze my codebase"})
6161

6262
# Session state is automatically persisted
6363
```
6464

6565
### Go
6666

6767
```go
68-
client, _ := copilot.NewClient()
68+
client := copilot.NewClient(nil)
6969

7070
// Create a session with a meaningful ID
71-
session, _ := client.CreateSession(copilot.CreateSessionOptions{
71+
session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{
7272
SessionID: "user-123-task-456",
7373
Model: "gpt-5.2-codex",
7474
})
7575

7676
// Do some work...
77-
session.SendPrompt(copilot.PromptOptions{Content: "Analyze my codebase"})
77+
session.SendAndWait(context.Background(), copilot.MessageOptions{Prompt: "Analyze my codebase"})
7878

7979
// Session state is automatically persisted
8080
```
@@ -94,7 +94,7 @@ var session = await client.CreateSessionAsync(new CreateSessionOptions
9494
});
9595

9696
// Do some work...
97-
await session.SendPromptAsync(new PromptOptions { Content = "Analyze my codebase" });
97+
await session.SendAndWaitAsync(new MessageOptions { Prompt = "Analyze my codebase" });
9898

9999
// Session state is automatically persisted
100100
```
@@ -124,7 +124,7 @@ flowchart LR
124124
const session = await client.resumeSession("user-123-task-456");
125125

126126
// Continue where you left off
127-
await session.sendPrompt({ content: "What did we discuss earlier?" });
127+
await session.sendAndWait({ prompt: "What did we discuss earlier?" });
128128
```
129129

130130
### Python
@@ -134,17 +134,17 @@ await session.sendPrompt({ content: "What did we discuss earlier?" });
134134
session = await client.resume_session("user-123-task-456")
135135

136136
# Continue where you left off
137-
await session.send_prompt(content="What did we discuss earlier?")
137+
await session.send_and_wait({"prompt": "What did we discuss earlier?"})
138138
```
139139

140140
### Go
141141

142142
```go
143143
// Resume from a different client instance (or after restart)
144-
session, _ := client.ResumeSession("user-123-task-456", copilot.ResumeSessionOptions{})
144+
session, _ := client.ResumeSession(context.Background(), "user-123-task-456", nil)
145145

146146
// Continue where you left off
147-
session.SendPrompt(copilot.PromptOptions{Content: "What did we discuss earlier?"})
147+
session.SendAndWait(context.Background(), copilot.MessageOptions{Prompt: "What did we discuss earlier?"})
148148
```
149149

150150
### C# (.NET)
@@ -154,7 +154,7 @@ session.SendPrompt(copilot.PromptOptions{Content: "What did we discuss earlier?"
154154
var session = await client.ResumeSessionAsync("user-123-task-456");
155155

156156
// Continue where you left off
157-
await session.SendPromptAsync(new PromptOptions { Content = "What did we discuss earlier?" });
157+
await session.SendAndWaitAsync(new MessageOptions { Prompt = "What did we discuss earlier?" });
158158
```
159159

160160
## Using BYOK (Bring Your Own Key) with Resumed Sessions
@@ -290,7 +290,7 @@ When a task completes, destroy the session explicitly rather than waiting for ti
290290
```typescript
291291
try {
292292
// Do work...
293-
await session.sendPrompt({ content: "Complete the task" });
293+
await session.sendAndWait({ prompt: "Complete the task" });
294294

295295
// Task complete - clean up
296296
await session.destroy();
@@ -472,7 +472,7 @@ async function withSessionLock<T>(
472472
// Usage
473473
await withSessionLock("user-123-task-456", async () => {
474474
const session = await client.resumeSession("user-123-task-456");
475-
await session.sendPrompt({ content: "Continue the task" });
475+
await session.sendAndWait({ prompt: "Continue the task" });
476476
});
477477
```
478478

docs/hooks/error-handling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ session = await client.create_session({
120120
<summary><strong>Go</strong></summary>
121121

122122
```go
123-
session, _ := client.CreateSession(ctx, copilot.SessionConfig{
123+
session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{
124124
Hooks: &copilot.SessionHooks{
125125
OnErrorOccurred: func(input copilot.ErrorOccurredHookInput, inv copilot.HookInvocation) (*copilot.ErrorOccurredHookOutput, error) {
126126
fmt.Printf("[%s] Error: %s\n", inv.SessionID, input.Error)

docs/hooks/overview.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,15 @@ async def main():
8787
package main
8888

8989
import (
90+
"context"
9091
"fmt"
9192
copilot "github.com/github/copilot-sdk/go"
9293
)
9394

9495
func main() {
95-
client, _ := copilot.NewClient(copilot.ClientOptions{})
96+
client := copilot.NewClient(nil)
9697

97-
session, _ := client.CreateSession(ctx, copilot.SessionConfig{
98+
session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{
9899
Hooks: &copilot.SessionHooks{
99100
OnPreToolUse: func(input copilot.PreToolUseHookInput, inv copilot.HookInvocation) (*copilot.PreToolUseHookOutput, error) {
100101
fmt.Printf("Tool called: %s\n", input.ToolName)
@@ -113,6 +114,7 @@ func main() {
113114
},
114115
},
115116
})
117+
_ = session
116118
}
117119
```
118120

docs/hooks/post-tool-use.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ session = await client.create_session({
119119
<summary><strong>Go</strong></summary>
120120

121121
```go
122-
session, _ := client.CreateSession(ctx, copilot.SessionConfig{
122+
session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{
123123
Hooks: &copilot.SessionHooks{
124124
OnPostToolUse: func(input copilot.PostToolUseHookInput, inv copilot.HookInvocation) (*copilot.PostToolUseHookOutput, error) {
125125
fmt.Printf("[%s] Tool: %s\n", inv.SessionID, input.ToolName)

docs/hooks/pre-tool-use.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ session = await client.create_session({
126126
<summary><strong>Go</strong></summary>
127127

128128
```go
129-
session, _ := client.CreateSession(ctx, copilot.SessionConfig{
129+
session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{
130130
Hooks: &copilot.SessionHooks{
131131
OnPreToolUse: func(input copilot.PreToolUseHookInput, inv copilot.HookInvocation) (*copilot.PreToolUseHookOutput, error) {
132132
fmt.Printf("[%s] Calling %s\n", inv.SessionID, input.ToolName)

docs/hooks/user-prompt-submitted.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ session = await client.create_session({
113113
<summary><strong>Go</strong></summary>
114114

115115
```go
116-
session, _ := client.CreateSession(ctx, copilot.SessionConfig{
116+
session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{
117117
Hooks: &copilot.SessionHooks{
118118
OnUserPromptSubmitted: func(input copilot.UserPromptSubmittedHookInput, inv copilot.HookInvocation) (*copilot.UserPromptSubmittedHookOutput, error) {
119119
fmt.Printf("[%s] User: %s\n", inv.SessionID, input.Prompt)

0 commit comments

Comments
 (0)