Skip to content

Commit d542b0f

Browse files
Copilotedburns
andauthored
Update documentation for copilotHome, tcpConnectionToken, and instructionDirectories
Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
1 parent 637b51b commit d542b0f

2 files changed

Lines changed: 46 additions & 3 deletions

File tree

src/site/markdown/advanced.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,31 @@ var session = client.createSession(
626626

627627
---
628628

629+
## Instruction Directories
630+
631+
Provide additional directories containing custom instruction files. These instructions are automatically included in the system message for all conversations in the session.
632+
633+
```java
634+
var session = client.createSession(
635+
new SessionConfig().setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
636+
.setInstructionDirectories(List.of("/path/to/instructions"))
637+
).get();
638+
```
639+
640+
Instruction files are discovered from `.github/instructions/` subdirectories within each specified path and should use the `.instructions.md` extension.
641+
642+
This is also supported on session resume:
643+
644+
```java
645+
var session = client.resumeSession(sessionId,
646+
new ResumeSessionConfig()
647+
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
648+
.setInstructionDirectories(List.of("/path/to/instructions"))
649+
);
650+
```
651+
652+
---
653+
629654
## Custom Configuration Directory
630655

631656
Use a custom configuration directory for session settings:

src/site/markdown/setup.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,28 @@ try (var client = new CopilotClient(options)) {
157157
Multiple application instances can share a single CLI server:
158158

159159
```java
160-
// In different parts of your application or different containers
161-
var client1 = new CopilotClient(new CopilotClientOptions().setCliUrl("cli-server:4321"));
162-
var client2 = new CopilotClient(new CopilotClientOptions().setCliUrl("cli-server:4321"));
160+
// Use an explicit connection token so all clients can authenticate
161+
var token = "my-shared-secret";
162+
var client1 = new CopilotClient(new CopilotClientOptions()
163+
.setCliUrl("cli-server:4321").setTcpConnectionToken(token));
164+
var client2 = new CopilotClient(new CopilotClientOptions()
165+
.setCliUrl("cli-server:4321").setTcpConnectionToken(token));
163166
// Both connect to the same CLI server
164167
```
165168

169+
### Connection Token (TCP Security)
170+
171+
When the SDK spawns the CLI in TCP mode, a random connection token is generated automatically
172+
to protect the loopback listener. You can also provide an explicit token:
173+
174+
```java
175+
var options = new CopilotClientOptions()
176+
.setUseStdio(false)
177+
.setTcpConnectionToken("my-secret-token");
178+
```
179+
180+
> **Note:** `tcpConnectionToken` cannot be used with `useStdio = true`.
181+
166182
### Deployment Patterns
167183

168184
**Container deployment:**
@@ -340,10 +356,12 @@ Complete list of `CopilotClientOptions` settings:
340356
| `cliPath` | String | Path to CLI executable | `"copilot"` from PATH |
341357
| `cliUrl` | String | External CLI server URL | `null` (spawn process) |
342358
| `cliArgs` | String[] | Extra CLI arguments | `null` |
359+
| `copilotHome` | String | Base directory for Copilot data | `null` (~/.copilot) |
343360
| `gitHubToken` | String | GitHub OAuth token | `null` |
344361
| `useLoggedInUser` | Boolean | Use system credentials | `true` |
345362
| `useStdio` | boolean | Use stdio transport | `true` |
346363
| `port` | int | TCP port for CLI | `0` (random) |
364+
| `tcpConnectionToken` | String | Connection token for TCP mode | `null` (auto-generated) |
347365
| `autoStart` | boolean | Auto-start server | `true` |
348366
| `autoRestart` | boolean | Auto-restart on crash | `true` |
349367
| `logLevel` | String | CLI log level | `"info"` |

0 commit comments

Comments
 (0)