Skip to content

Add Java SDK cookbook with 7 recipes (re-targeted to staged)#1316

Open
brunoborges wants to merge 8 commits intostagedfrom
cookbook/java-to-staged
Open

Add Java SDK cookbook with 7 recipes (re-targeted to staged)#1316
brunoborges wants to merge 8 commits intostagedfrom
cookbook/java-to-staged

Conversation

@brunoborges
Copy link
Copy Markdown
Contributor

Summary

Re-targets PRs #1313 and #1314 to staged (they were accidentally merged to main).

This cherry-picks all 4 commits from those PRs onto staged:

  • 4d6855e Add Java SDK cookbook with 7 recipes
  • 0b28003 Apply suggestions from code review
  • c330a7d Address review feedback
  • aa6d771 fix: Java cookbook recipes to compile with copilot-sdk-java 0.2.1-java.1

The revert from main is in PR #1315.

Content

7 recipe documentation files + 7 runnable JBang scripts

Recipe Description
Ralph Loop Autonomous AI task loops with fresh context per iteration
Error Handling try-with-resources, ExecutionException unwrapping, timeouts
Multiple Sessions Parallel sessions with CompletableFuture.allOf
Managing Local Files AI-powered file organization with event handlers
PR Visualization Interactive PR age charts via GitHub MCP Server
Persisting Sessions Save/resume sessions with custom IDs
Accessibility Report WCAG reports via Playwright MCP server

All 7 recipes compile with jbang build against copilot-sdk-java:0.2.1-java.1.

brunoborges and others added 4 commits April 6, 2026 15:20
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>
Copilot AI review requested due to automatic review settings April 6, 2026 19:20
@brunoborges brunoborges requested a review from aaronpowell as a code owner April 6, 2026 19:20
@brunoborges brunoborges enabled auto-merge April 6, 2026 19:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

brunoborges and others added 4 commits April 6, 2026 16:30
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants