|
| 1 | +<!DOCTYPE html> |
| 2 | + |
| 3 | + |
| 4 | +<!-- |
| 5 | + | Generated by Apache Maven Doxia Site Renderer 2.0.0 from target/filtered-site/markdown/cookbook/README.md at 2026-08-20 |
| 6 | + | Rendered using Apache Maven Fluido Skin 2.1.0 |
| 7 | +--> |
| 8 | +<html xmlns="http://www.w3.org/1999/xhtml" lang="en"> |
| 9 | + <head> |
| 10 | + <meta charset="UTF-8" /> |
| 11 | + <meta name="viewport" content="width=device-width, initial-scale=1" /> |
| 12 | + <meta name="generator" content="Apache Maven Doxia Site Renderer 2.0.0" /> |
| 13 | + <title>GitHub Copilot SDK Cookbook — Java – GitHub Copilot SDK :: Java</title> |
| 14 | + <link rel="stylesheet" href="../css/apache-maven-fluido-2.1.0.min.css" /> |
| 15 | + <link rel="stylesheet" href="../css/site.css" /> |
| 16 | + <link rel="stylesheet" href="../css/print.css" media="print" /> |
| 17 | + <script src="../js/apache-maven-fluido-2.1.0.min.js"></script> |
| 18 | + <style>.github-fork-ribbon:before { background-color: gray; }</style> |
| 19 | + </head> |
| 20 | + <body class="topBarEnabled"> |
| 21 | + <a class="github-fork-ribbon right-top" href="https://github.com/github/copilot-sdk" data-ribbon="Fork me on GitHub">Fork me on GitHub</a> |
| 22 | + <header id="topbar" class="navbar navbar-fixed-top "> |
| 23 | + <div class="navbar-inner"> |
| 24 | + <div class="container-fluid"> |
| 25 | + <a data-target=".nav-collapse" data-toggle="collapse" class="btn btn-navbar"> |
| 26 | + <span class="icon-bar"></span> |
| 27 | + <span class="icon-bar"></span> |
| 28 | + <span class="icon-bar"></span> |
| 29 | + </a> |
| 30 | +<a class="brand" href="../index.html">GitHub Copilot SDK for Java |
| 31 | +</a> |
| 32 | + <ul class="nav"> |
| 33 | + <li class="dropdown"> |
| 34 | + <a class="dropdown-toggle" data-toggle="dropdown">Overview <b class="caret"></b></a> |
| 35 | + <ul class="dropdown-menu"> |
| 36 | + <li><a href="../index.html">Introduction</a></li> |
| 37 | + <li><a href="../getting-started.html">Getting Started</a></li> |
| 38 | + <li><a href="../setup.html">Setup</a></li> |
| 39 | + <li><a href="../documentation.html">Documentation</a></li> |
| 40 | + <li><a href="../mcp.html">MCP Servers</a></li> |
| 41 | + <li><a href="../hooks.html">Session Hooks</a></li> |
| 42 | + <li><a href="../advanced.html">Advanced Usage</a></li> |
| 43 | + <li><a href="../apidocs/index.html">API Javadoc</a></li> |
| 44 | + </ul> |
| 45 | + </li> |
| 46 | + <li class="dropdown"> |
| 47 | + <a class="dropdown-toggle" data-toggle="dropdown">Guides <b class="caret"></b></a> |
| 48 | + <ul class="dropdown-menu"> |
| 49 | + <li><a href="../documentation.html#Basic_Usage">Basic Usage</a></li> |
| 50 | + <li><a href="../documentation.html#Handling_Responses">Handling Responses</a></li> |
| 51 | + <li><a href="../documentation.html#Streaming_Responses">Streaming</a></li> |
| 52 | + <li><a href="../documentation.html#Choosing_a_Model">Choosing a Model</a></li> |
| 53 | + <li><a href="../documentation.html#Session_Management">Session Management</a></li> |
| 54 | + </ul> |
| 55 | + </li> |
| 56 | + <li class="dropdown"> |
| 57 | + <a class="dropdown-toggle" data-toggle="dropdown">Advanced <b class="caret"></b></a> |
| 58 | + <ul class="dropdown-menu"> |
| 59 | + <li><a href="../advanced.html#Custom_Tools">Custom Tools</a></li> |
| 60 | + <li><a href="../advanced.html#System_Messages">System Messages</a></li> |
| 61 | + <li><a href="../advanced.html#File_Attachments">File Attachments</a></li> |
| 62 | + <li><a href="../advanced.html#Bring_Your_Own_Key_.28BYOK.29">BYOK</a></li> |
| 63 | + <li><a href="../advanced.html#Infinite_Sessions">Infinite Sessions</a></li> |
| 64 | + <li><a href="../advanced.html#MCP_Servers">MCP Servers</a></li> |
| 65 | + <li><a href="../advanced.html#Slash_Commands">Slash Commands</a></li> |
| 66 | + <li><a href="../advanced.html#Elicitation_UI_Dialogs">Elicitation</a></li> |
| 67 | + <li><a href="../advanced.html#Getting_Session_Metadata_by_ID">Session Metadata</a></li> |
| 68 | + <li><a href="../hooks.html">Session Hooks</a></li> |
| 69 | + </ul> |
| 70 | + </li> |
| 71 | + <li class="dropdown"> |
| 72 | + <a class="dropdown-toggle" data-toggle="dropdown">Cookbook <b class="caret"></b></a> |
| 73 | + <ul class="dropdown-menu"> |
| 74 | + <li><a>Overview</a></li> |
| 75 | + <li><a href="../cookbook/error-handling.html">Error Handling</a></li> |
| 76 | + <li><a href="../cookbook/multiple-sessions.html">Multiple Sessions</a></li> |
| 77 | + <li><a href="../cookbook/managing-local-files.html">Managing Local Files</a></li> |
| 78 | + <li><a href="../cookbook/pr-visualization.html">PR Visualization</a></li> |
| 79 | + <li><a href="../cookbook/persisting-sessions.html">Persisting Sessions</a></li> |
| 80 | + </ul> |
| 81 | + </li> |
| 82 | + <li class="dropdown"> |
| 83 | + <a class="dropdown-toggle" data-toggle="dropdown">Project Documentation <b class="caret"></b></a> |
| 84 | + <ul class="dropdown-menu"> |
| 85 | + <li class="dropdown-submenu"> |
| 86 | +<a href="../project-info.html">Project Information</a> |
| 87 | + <ul class="dropdown-menu"> |
| 88 | + <li><a href="../dependencies.html">Dependencies</a></li> |
| 89 | + <li><a href="../dependency-info.html">Maven Coordinates</a></li> |
| 90 | + <li><a href="../index.html">About</a></li> |
| 91 | + <li><a href="../plugin-management.html">Plugin Management</a></li> |
| 92 | + <li><a href="../plugins.html">Plugins</a></li> |
| 93 | + <li><a href="../summary.html">Summary</a></li> |
| 94 | + </ul> |
| 95 | + </li> |
| 96 | + <li class="dropdown-submenu"> |
| 97 | +<a href="../project-reports.html">Project Reports</a> |
| 98 | + <ul class="dropdown-menu"> |
| 99 | + <li><a href="../apidocs/index.html">Javadoc</a></li> |
| 100 | + <li><a href="../surefire.html">Surefire</a></li> |
| 101 | + </ul> |
| 102 | + </li> |
| 103 | + </ul> |
| 104 | + </li> |
| 105 | + </ul> |
| 106 | + </div> |
| 107 | + </div> |
| 108 | + </header> |
| 109 | + <div class="container-fluid container-fluid-top"> |
| 110 | + <header> |
| 111 | + <div id="banner"> |
| 112 | + <div class="pull-left"></div> |
| 113 | + <div class="pull-right"></div> |
| 114 | + <div class="clear"><hr/></div> |
| 115 | + </div> |
| 116 | + |
| 117 | + <div id="breadcrumbs"> |
| 118 | + <ul class="breadcrumb"> |
| 119 | + <li id="publishDate">Last Published: 2026-08-20<span class="divider">|</span> |
| 120 | +</li> |
| 121 | + <li id="projectVersion">Version: 1.0.12-preview.0<span class="divider">|</span></li> |
| 122 | + <li><a href="../index.html">Home</a><span class="divider">/</span></li> |
| 123 | + <li class="active">GitHub Copilot SDK Cookbook — Java</li> |
| 124 | + </ul> |
| 125 | + </div> |
| 126 | + </header> |
| 127 | + <div class="row-fluid"> |
| 128 | + <header id="leftColumn" class="span2"> |
| 129 | + <nav class="well sidebar-nav"> |
| 130 | + <ul class="nav nav-list"> |
| 131 | + <li class="nav-header">Overview</li> |
| 132 | + <li><a href="../index.html">Introduction</a></li> |
| 133 | + <li><a href="../getting-started.html">Getting Started</a></li> |
| 134 | + <li><a href="../setup.html">Setup</a></li> |
| 135 | + <li><a href="../documentation.html">Documentation</a></li> |
| 136 | + <li><a href="../mcp.html">MCP Servers</a></li> |
| 137 | + <li><a href="../hooks.html">Session Hooks</a></li> |
| 138 | + <li><a href="../advanced.html">Advanced Usage</a></li> |
| 139 | + <li><a href="../apidocs/index.html">API Javadoc</a></li> |
| 140 | + <li class="nav-header">Guides</li> |
| 141 | + <li><a href="../documentation.html#Basic_Usage">Basic Usage</a></li> |
| 142 | + <li><a href="../documentation.html#Handling_Responses">Handling Responses</a></li> |
| 143 | + <li><a href="../documentation.html#Streaming_Responses">Streaming</a></li> |
| 144 | + <li><a href="../documentation.html#Choosing_a_Model">Choosing a Model</a></li> |
| 145 | + <li><a href="../documentation.html#Session_Management">Session Management</a></li> |
| 146 | + <li class="nav-header">Advanced</li> |
| 147 | + <li><a href="../advanced.html#Custom_Tools">Custom Tools</a></li> |
| 148 | + <li><a href="../advanced.html#System_Messages">System Messages</a></li> |
| 149 | + <li><a href="../advanced.html#File_Attachments">File Attachments</a></li> |
| 150 | + <li><a href="../advanced.html#Bring_Your_Own_Key_.28BYOK.29">BYOK</a></li> |
| 151 | + <li><a href="../advanced.html#Infinite_Sessions">Infinite Sessions</a></li> |
| 152 | + <li><a href="../advanced.html#MCP_Servers">MCP Servers</a></li> |
| 153 | + <li><a href="../advanced.html#Slash_Commands">Slash Commands</a></li> |
| 154 | + <li><a href="../advanced.html#Elicitation_UI_Dialogs">Elicitation</a></li> |
| 155 | + <li><a href="../advanced.html#Getting_Session_Metadata_by_ID">Session Metadata</a></li> |
| 156 | + <li><a href="../hooks.html">Session Hooks</a></li> |
| 157 | + <li class="nav-header">Cookbook</li> |
| 158 | + <li class="active"><a>Overview</a></li> |
| 159 | + <li><a href="../cookbook/error-handling.html">Error Handling</a></li> |
| 160 | + <li><a href="../cookbook/multiple-sessions.html">Multiple Sessions</a></li> |
| 161 | + <li><a href="../cookbook/managing-local-files.html">Managing Local Files</a></li> |
| 162 | + <li><a href="../cookbook/pr-visualization.html">PR Visualization</a></li> |
| 163 | + <li><a href="../cookbook/persisting-sessions.html">Persisting Sessions</a></li> |
| 164 | + <li class="nav-header">Project Documentation</li> |
| 165 | + <li><a href="../project-info.html"><span class="icon-chevron-right"></span>Project Information</a></li> |
| 166 | + <li><a href="../project-reports.html"><span class="icon-chevron-right"></span>Project Reports</a></li> |
| 167 | + </ul> |
| 168 | + </nav> |
| 169 | + <div class="well sidebar-nav"> |
| 170 | + <div id="poweredBy"> |
| 171 | + <div class="clear"></div> |
| 172 | + <div class="clear"></div> |
| 173 | +<a href="https://maven.apache.org/" class="builtBy" target="_blank"><img class="builtBy" alt="Built by Maven" src="../images/logos/maven-feather.png" /></a> |
| 174 | + </div> |
| 175 | + </div> |
| 176 | + </header> |
| 177 | + <main id="bodyColumn" class="span10"> |
| 178 | +<section><a id="GitHub_Copilot_SDK_Cookbook_.E2.80.94_Java"></a> |
| 179 | +<h1>GitHub Copilot SDK Cookbook — Java</h1> |
| 180 | +<p>This folder hosts short, practical recipes for using the GitHub Copilot SDK with Java. Each recipe is concise, copy‑pasteable, and points to fuller examples and tests.</p><section><a id="Prerequisites"></a> |
| 181 | +<h2>Prerequisites</h2> |
| 182 | +<p>All cookbook examples can be run directly using <a href="https://www.jbang.dev/" class="externalLink">JBang</a>, which allows you to run Java code without a full project setup.</p> |
| 183 | +<p><strong>Install JBang:</strong></p> |
| 184 | + |
| 185 | +<pre class="prettyprint"><code class="language-bash"># macOS (using Homebrew) |
| 186 | +brew install jbangdev/tap/jbang |
| 187 | + |
| 188 | +# Linux/macOS (using curl) |
| 189 | +curl -Ls https://sh.jbang.dev | bash -s - app setup |
| 190 | + |
| 191 | +# Windows (using Scoop) |
| 192 | +scoop install jbang |
| 193 | +</code></pre> |
| 194 | +<p>For other installation methods, see the <a href="https://www.jbang.dev/download/" class="externalLink">JBang installation guide</a>.</p></section><section><a id="Recipes"></a> |
| 195 | +<h2>Recipes</h2> |
| 196 | +<ul> |
| 197 | + |
| 198 | +<li><a href="error-handling.html">Error Handling</a>: Handle errors gracefully including connection failures, timeouts, and cleanup.</li> |
| 199 | +<li><a href="multiple-sessions.html">Multiple Sessions</a>: Manage multiple independent conversations simultaneously.</li> |
| 200 | +<li><a href="managing-local-files.html">Managing Local Files</a>: Organize files by metadata using AI-powered grouping strategies.</li> |
| 201 | +<li><a href="pr-visualization.html">PR Visualization</a>: Generate interactive PR age charts using GitHub MCP Server.</li> |
| 202 | +<li><a href="persisting-sessions.html">Persisting Sessions</a>: Save and resume sessions across restarts.</li> |
| 203 | +</ul></section><section><a id="Contributing"></a> |
| 204 | +<h2>Contributing</h2> |
| 205 | +<p>Add a new recipe by creating a markdown file in this folder and linking it above. Follow repository guidance in the <a href="https://github.com/github/copilot-sdk#contributing" class="externalLink">main README</a>.</p></section><section><a id="Status"></a> |
| 206 | +<h2>Status</h2> |
| 207 | +<p>These recipes are complete, practical examples and can be used directly or adapted for your own projects.</p></section></section> </main> |
| 208 | + </div> |
| 209 | + </div> |
| 210 | + <hr/> |
| 211 | + <footer> |
| 212 | + <div class="container-fluid"> |
| 213 | + <div class="row-fluid"> |
| 214 | + <p>© 2026 |
| 215 | +</p> |
| 216 | + </div> |
| 217 | + </div> |
| 218 | + </footer> |
| 219 | + </body> |
| 220 | +</html> |
0 commit comments