Add Java SDK cookbook with 7 recipes (re-targeted to staged)#1316
Open
brunoborges wants to merge 8 commits intostagedfrom
Open
Add Java SDK cookbook with 7 recipes (re-targeted to staged)#1316brunoborges wants to merge 8 commits intostagedfrom
brunoborges wants to merge 8 commits intostagedfrom
Conversation
Add complete Java cookbook matching the pattern of existing .NET, Go, Node.js, and Python cookbooks. All 7 recipes included: - Ralph Loop: Autonomous AI task loops with JBang - Error Handling: try-with-resources, ExecutionException, timeouts - Multiple Sessions: Parallel sessions with CompletableFuture - Managing Local Files: AI-powered file organization - PR Visualization: Interactive PR age charts - Persisting Sessions: Save/resume with custom IDs - Accessibility Report: WCAG reports via Playwright MCP Each recipe includes both markdown documentation and a standalone JBang-runnable Java file in recipe/.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Replace Thread.sleep with sendAndWait in PRVisualization - Fix top-level statements in multiple-sessions.md (wrap in class) - Fix .getMessage() → .getData().content() in MultipleSessions.java - Guard against null readLine() in AccessibilityReport.java - Add null-safe getCause() + InterruptedException handling in ErrorHandling.java - Fix paths: jbang commands now include recipe/ prefix - Fix root README path: cd java/recipe (not java/cookbook/recipe) - Fix recipe/README.md ralph-loop CLI example
Fix compilation errors and documentation inaccuracies in Java cookbook recipes against the actual SDK API: - MultipleSessions: Replace non-existent destroy() with close() - AccessibilityReport: Replace non-existent McpServerConfig class with Map<String, Object> (the actual type accepted by setMcpServers) - error-handling.md: Replace non-existent session.addTool(), ToolDefinition.builder(), and ToolResultObject with actual SDK APIs (ToolDefinition.create(), SessionConfig.setTools(), CompletableFuture<Object> return type) All 7 recipes now compile successfully with jbang build. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR re-targets the previously merged Java Copilot SDK cookbook content onto staged, adding a full set of Java recipes (docs + runnable JBang scripts) and updating cookbook indexes to include Java.
Changes:
- Add Java cookbook documentation for 7 Copilot SDK recipe topics.
- Add 7 runnable Java (JBang) scripts corresponding to each recipe.
- Update cookbook READMEs to index Java and document how to run Java examples.
Show a summary per file
| File | Description |
|---|---|
| cookbook/README.md | Updates top-level cookbook language list to include Java for Copilot SDK cookbook. |
| cookbook/copilot-sdk/README.md | Adds Java recipe links and Java “Running Examples” instructions; updates supported language count. |
| cookbook/copilot-sdk/java/README.md | Adds Java cookbook landing page with links to all 7 recipes. |
| cookbook/copilot-sdk/java/recipe/README.md | Documents prerequisites and how to run Java recipes via JBang. |
| cookbook/copilot-sdk/java/recipe/RalphLoop.java | Runnable JBang script for a simple Ralph loop pattern. |
| cookbook/copilot-sdk/java/recipe/PRVisualization.java | Runnable interactive CLI that uses GitHub MCP tools to generate PR age charts. |
| cookbook/copilot-sdk/java/recipe/PersistingSessions.java | Runnable example showing session IDs for persistence. |
| cookbook/copilot-sdk/java/recipe/MultipleSessions.java | Runnable example creating multiple sessions in parallel with CompletableFuture. |
| cookbook/copilot-sdk/java/recipe/ManagingLocalFiles.java | Runnable example that asks Copilot to analyze/plan file organization. |
| cookbook/copilot-sdk/java/recipe/ErrorHandling.java | Runnable example demonstrating basic error handling and exception unwrapping. |
| cookbook/copilot-sdk/java/recipe/AccessibilityReport.java | Runnable interactive accessibility report generator using Playwright MCP + streaming. |
| cookbook/copilot-sdk/java/ralph-loop.md | Documentation for the Ralph loop pattern (simple + ideal versions). |
| cookbook/copilot-sdk/java/pr-visualization.md | Documentation for PR visualization recipe and how it works. |
| cookbook/copilot-sdk/java/persisting-sessions.md | Documentation for persisting/resuming/listing/deleting sessions in Java. |
| cookbook/copilot-sdk/java/multiple-sessions.md | Documentation for running multiple sessions concurrently and related patterns. |
| cookbook/copilot-sdk/java/managing-local-files.md | Documentation for AI-assisted file grouping strategies and safety considerations. |
| cookbook/copilot-sdk/java/error-handling.md | Documentation for try-with-resources, timeouts, aborting, and tool error patterns. |
| cookbook/copilot-sdk/java/accessibility-report.md | Documentation for generating WCAG reports + optional test generation via Playwright MCP. |
Copilot's findings
- Files reviewed: 18/18 changed files
- Comments generated: 5
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Re-targets PRs #1313 and #1314 to
staged(they were accidentally merged tomain).This cherry-picks all 4 commits from those PRs onto
staged:4d6855eAdd Java SDK cookbook with 7 recipes0b28003Apply suggestions from code reviewc330a7dAddress review feedbackaa6d771fix: Java cookbook recipes to compile with copilot-sdk-java 0.2.1-java.1The revert from
mainis in PR #1315.Content
7 recipe documentation files + 7 runnable JBang scripts
All 7 recipes compile with
jbang buildagainstcopilot-sdk-java:0.2.1-java.1.