Skip to content

Commit 4c2ab53

Browse files
Copilotedburns
andauthored
Add documentation for new features from reference implementation
- Document instructionDirectories in advanced.md - Document continuePendingWork in advanced.md - Document copilotHome and tcpConnectionToken in advanced.md - Update Table of Contents Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
1 parent 764900f commit 4c2ab53

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

src/site/markdown/advanced.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ This guide covers advanced scenarios for extending and customizing your Copilot
2525
- [Skills Configuration](#Skills_Configuration)
2626
- [Loading Skills](#Loading_Skills)
2727
- [Disabling Skills](#Disabling_Skills)
28+
- [Instruction Directories](#Instruction_Directories)
2829
- [Custom Configuration Directory](#Custom_Configuration_Directory)
30+
- [Continuing Pending Work on Resume](#Continuing_Pending_Work_on_Resume)
2931
- [Session Logging](#Session_Logging)
3032
- [Early Event Registration](#Early_Event_Registration)
3133
- [User Input Handling](#User_Input_Handling)
3234
- [Permission Handling](#Permission_Handling)
3335
- [Session Hooks](#Session_Hooks)
3436
- [Manual Server Control](#Manual_Server_Control)
37+
- [Copilot Home Directory](#Copilot_Home_Directory)
38+
- [TCP Connection Token](#TCP_Connection_Token)
3539
- [Session Context and Filtering](#Session_Context_and_Filtering)
3640
- [Listing Sessions with Context](#Listing_Sessions_with_Context)
3741
- [Filtering Sessions by Context](#Filtering_Sessions_by_Context)
@@ -626,6 +630,32 @@ var session = client.createSession(
626630

627631
---
628632

633+
## Instruction Directories
634+
635+
Specify additional directories to search for custom instruction files. These directories are scanned
636+
for `.instructions.md` files (typically placed under `.github/instructions/`) which are included in
637+
the system message for the session.
638+
639+
```java
640+
var session = client.createSession(
641+
new SessionConfig().setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
642+
.setWorkingDirectory("/path/to/project")
643+
.setInstructionDirectories(List.of("/path/to/extra-instructions"))
644+
).get();
645+
```
646+
647+
Instruction directories can also be set when resuming a session:
648+
649+
```java
650+
var session = client.resumeSession(sessionId,
651+
new ResumeSessionConfig()
652+
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
653+
.setInstructionDirectories(List.of("/path/to/extra-instructions"))
654+
).get();
655+
```
656+
657+
---
658+
629659
## Custom Configuration Directory
630660

631661
Use a custom configuration directory for session settings:
@@ -641,6 +671,25 @@ This is useful when you need to isolate session configuration or use different s
641671

642672
---
643673

674+
## Continuing Pending Work on Resume
675+
676+
When resuming a suspended session, you can instruct the runtime to continue any tool calls or
677+
permission prompts that were still pending when the session was last suspended:
678+
679+
```java
680+
var session = client.resumeSession(sessionId,
681+
new ResumeSessionConfig()
682+
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
683+
.setContinuePendingWork(true)
684+
).get();
685+
```
686+
687+
When `continuePendingWork` is `false` (the default), the runtime treats pending work as
688+
interrupted on resume. For permission requests, the runtime re-emits `permission.requested`
689+
so the registered handler can re-prompt.
690+
691+
---
692+
644693
## Session Logging
645694

646695
Send log messages to the session for debugging, status updates, or UI feedback.
@@ -828,6 +877,32 @@ client.forceStop().get();
828877
> **Tip:** In `try-with-resources` blocks, `close()` delegates to `stop()`, so graceful session cleanup happens automatically.
829878
> `close()` is blocking and waits up to `CopilotClient.AUTOCLOSEABLE_TIMEOUT_SECONDS` seconds for shutdown to complete.
830879
880+
### Copilot Home Directory
881+
882+
Configure a custom base directory for Copilot data (session state, config, etc.):
883+
884+
```java
885+
var client = new CopilotClient(
886+
new CopilotClientOptions().setCopilotHome("/custom/copilot/data")
887+
);
888+
```
889+
890+
This sets the `COPILOT_HOME` environment variable on the spawned CLI process. When not set, the CLI defaults to `~/.copilot`. This option is only used when the SDK spawns the CLI process; it is ignored when connecting to an external server via `setCliUrl()`.
891+
892+
### TCP Connection Token
893+
894+
When using TCP transport, you can set a connection token for authentication:
895+
896+
```java
897+
var client = new CopilotClient(
898+
new CopilotClientOptions()
899+
.setUseStdio(false)
900+
.setTcpConnectionToken("my-secret-token")
901+
);
902+
```
903+
904+
When the SDK spawns its own CLI in TCP mode and no token is specified, a UUID is generated automatically so the loopback listener is safe by default. The token cannot be used with stdio transport.
905+
831906
---
832907

833908
## Session Context and Filtering

0 commit comments

Comments
 (0)