From 92df16da5af80cffab9a8a3240dd77ee941e5b5d Mon Sep 17 00:00:00 2001 From: Anthony Shaw Date: Wed, 11 Feb 2026 11:32:42 -0800 Subject: [PATCH] Remove git commands from Ralph loop recipes Git operations (commit, push) belong in the prompt instructions, not hardcoded in the loop orchestrator. The SDK recipes should focus purely on the SDK API: create client, create session, send prompt, destroy. --- cookbook/copilot-sdk/dotnet/ralph-loop.md | 18 ------------------ .../copilot-sdk/dotnet/recipe/ralph-loop.cs | 17 ----------------- cookbook/copilot-sdk/go/ralph-loop.md | 11 ----------- cookbook/copilot-sdk/go/recipe/ralph-loop.go | 10 ---------- cookbook/copilot-sdk/nodejs/ralph-loop.md | 11 +---------- .../copilot-sdk/nodejs/recipe/ralph-loop.ts | 11 ----------- cookbook/copilot-sdk/python/ralph-loop.md | 16 ---------------- .../copilot-sdk/python/recipe/ralph_loop.py | 16 ---------------- 8 files changed, 1 insertion(+), 109 deletions(-) diff --git a/cookbook/copilot-sdk/dotnet/ralph-loop.md b/cookbook/copilot-sdk/dotnet/ralph-loop.md index 1cc98762..0b2bb570 100644 --- a/cookbook/copilot-sdk/dotnet/ralph-loop.md +++ b/cookbook/copilot-sdk/dotnet/ralph-loop.md @@ -92,7 +92,6 @@ This is all you need to get started. The prompt file tells the agent what to do; The full Ralph pattern with planning and building modes, matching the [Ralph Playbook](https://github.com/ClaytonFarr/ralph-playbook) architecture: ```csharp -using System.Diagnostics; using GitHub.Copilot.SDK; // Parse args: dotnet run [plan] [max_iterations] @@ -104,16 +103,9 @@ var promptFile = mode == "plan" ? "PROMPT_plan.md" : "PROMPT_build.md"; var client = new CopilotClient(); await client.StartAsync(); -var branchInfo = new ProcessStartInfo("git", "branch --show-current") - { RedirectStandardOutput = true }; -var branch = Process.Start(branchInfo)!; -var branchName = (await branch.StandardOutput.ReadToEndAsync()).Trim(); -await branch.WaitForExitAsync(); - Console.WriteLine(new string('━', 40)); Console.WriteLine($"Mode: {mode}"); Console.WriteLine($"Prompt: {promptFile}"); -Console.WriteLine($"Branch: {branchName}"); Console.WriteLine($"Max: {maxIterations} iterations"); Console.WriteLine(new string('━', 40)); @@ -145,16 +137,6 @@ try await session.DisposeAsync(); } - // Push changes after each iteration - try - { - Process.Start("git", $"push origin {branchName}")!.WaitForExit(); - } - catch - { - Process.Start("git", $"push -u origin {branchName}")!.WaitForExit(); - } - Console.WriteLine($"\nIteration {i} complete."); } diff --git a/cookbook/copilot-sdk/dotnet/recipe/ralph-loop.cs b/cookbook/copilot-sdk/dotnet/recipe/ralph-loop.cs index c198c727..920a78f2 100644 --- a/cookbook/copilot-sdk/dotnet/recipe/ralph-loop.cs +++ b/cookbook/copilot-sdk/dotnet/recipe/ralph-loop.cs @@ -1,7 +1,6 @@ #:package GitHub.Copilot.SDK@* #:property PublishAot=false -using System.Diagnostics; using GitHub.Copilot.SDK; // Ralph loop: autonomous AI task loop with fresh context per iteration. @@ -28,15 +27,9 @@ var promptFile = mode == "plan" ? "PROMPT_plan.md" : "PROMPT_build.md"; var client = new CopilotClient(); await client.StartAsync(); -var branchProc = Process.Start(new ProcessStartInfo("git", "branch --show-current") - { RedirectStandardOutput = true })!; -var branch = (await branchProc.StandardOutput.ReadToEndAsync()).Trim(); -await branchProc.WaitForExitAsync(); - Console.WriteLine(new string('━', 40)); Console.WriteLine($"Mode: {mode}"); Console.WriteLine($"Prompt: {promptFile}"); -Console.WriteLine($"Branch: {branch}"); Console.WriteLine($"Max: {maxIterations} iterations"); Console.WriteLine(new string('━', 40)); @@ -69,16 +62,6 @@ try await session.DisposeAsync(); } - // Push changes after each iteration - try - { - Process.Start("git", $"push origin {branch}")!.WaitForExit(); - } - catch - { - Process.Start("git", $"push -u origin {branch}")!.WaitForExit(); - } - Console.WriteLine($"\nIteration {i} complete."); } diff --git a/cookbook/copilot-sdk/go/ralph-loop.md b/cookbook/copilot-sdk/go/ralph-loop.md index 44d0d1ca..cc7807c4 100644 --- a/cookbook/copilot-sdk/go/ralph-loop.md +++ b/cookbook/copilot-sdk/go/ralph-loop.md @@ -110,9 +110,7 @@ import ( "fmt" "log" "os" - "os/exec" "strconv" - "strings" copilot "github.com/github/copilot-sdk/go" ) @@ -129,13 +127,9 @@ func ralphLoop(ctx context.Context, mode string, maxIterations int) error { } defer client.Stop() - branchOut, _ := exec.Command("git", "branch", "--show-current").Output() - branch := strings.TrimSpace(string(branchOut)) - fmt.Println(strings.Repeat("━", 40)) fmt.Printf("Mode: %s\n", mode) fmt.Printf("Prompt: %s\n", promptFile) - fmt.Printf("Branch: %s\n", branch) fmt.Printf("Max: %d iterations\n", maxIterations) fmt.Println(strings.Repeat("━", 40)) @@ -163,11 +157,6 @@ func ralphLoop(ctx context.Context, mode string, maxIterations int) error { return err } - // Push changes after each iteration - if err := exec.Command("git", "push", "origin", branch).Run(); err != nil { - exec.Command("git", "push", "-u", "origin", branch).Run() - } - fmt.Printf("\nIteration %d complete.\n", i) } diff --git a/cookbook/copilot-sdk/go/recipe/ralph-loop.go b/cookbook/copilot-sdk/go/recipe/ralph-loop.go index 1d317842..18de5976 100644 --- a/cookbook/copilot-sdk/go/recipe/ralph-loop.go +++ b/cookbook/copilot-sdk/go/recipe/ralph-loop.go @@ -5,7 +5,6 @@ import ( "fmt" "log" "os" - "os/exec" "strconv" "strings" @@ -40,13 +39,9 @@ func ralphLoop(ctx context.Context, mode string, maxIterations int) error { } defer client.Stop() - branchOut, _ := exec.Command("git", "branch", "--show-current").Output() - branch := strings.TrimSpace(string(branchOut)) - fmt.Println(strings.Repeat("━", 40)) fmt.Printf("Mode: %s\n", mode) fmt.Printf("Prompt: %s\n", promptFile) - fmt.Printf("Branch: %s\n", branch) fmt.Printf("Max: %d iterations\n", maxIterations) fmt.Println(strings.Repeat("━", 40)) @@ -74,11 +69,6 @@ func ralphLoop(ctx context.Context, mode string, maxIterations int) error { return fmt.Errorf("send failed on iteration %d: %w", i, err) } - // Push changes after each iteration - if err := exec.Command("git", "push", "origin", branch).Run(); err != nil { - exec.Command("git", "push", "-u", "origin", branch).Run() - } - fmt.Printf("\nIteration %d complete.\n", i) } diff --git a/cookbook/copilot-sdk/nodejs/ralph-loop.md b/cookbook/copilot-sdk/nodejs/ralph-loop.md index 41ad3c71..13e74fc8 100644 --- a/cookbook/copilot-sdk/nodejs/ralph-loop.md +++ b/cookbook/copilot-sdk/nodejs/ralph-loop.md @@ -82,7 +82,6 @@ The full Ralph pattern with planning and building modes, matching the [Ralph Pla ```typescript import { readFile } from "fs/promises"; -import { execSync } from "child_process"; import { CopilotClient } from "@github/copilot-sdk"; type Mode = "plan" | "build"; @@ -92,8 +91,7 @@ async function ralphLoop(mode: Mode, maxIterations: number = 50) { const client = new CopilotClient(); await client.start(); - const branch = execSync("git branch --show-current", { encoding: "utf-8" }).trim(); - console.log(`Mode: ${mode} | Prompt: ${promptFile} | Branch: ${branch}`); + console.log(`Mode: ${mode} | Prompt: ${promptFile}`); try { const prompt = await readFile(promptFile, "utf-8"); @@ -109,13 +107,6 @@ async function ralphLoop(mode: Mode, maxIterations: number = 50) { await session.destroy(); } - // Push changes after each iteration - try { - execSync(`git push origin ${branch}`, { stdio: "inherit" }); - } catch { - execSync(`git push -u origin ${branch}`, { stdio: "inherit" }); - } - console.log(`Iteration ${i} complete.`); } } finally { diff --git a/cookbook/copilot-sdk/nodejs/recipe/ralph-loop.ts b/cookbook/copilot-sdk/nodejs/recipe/ralph-loop.ts index 018b8074..3bd5e4cf 100644 --- a/cookbook/copilot-sdk/nodejs/recipe/ralph-loop.ts +++ b/cookbook/copilot-sdk/nodejs/recipe/ralph-loop.ts @@ -1,5 +1,4 @@ import { readFile } from "fs/promises"; -import { execSync } from "child_process"; import { CopilotClient } from "@github/copilot-sdk"; /** @@ -28,12 +27,9 @@ async function ralphLoop(mode: Mode, maxIterations: number) { const client = new CopilotClient(); await client.start(); - const branch = execSync("git branch --show-current", { encoding: "utf-8" }).trim(); - console.log("━".repeat(40)); console.log(`Mode: ${mode}`); console.log(`Prompt: ${promptFile}`); - console.log(`Branch: ${branch}`); console.log(`Max: ${maxIterations} iterations`); console.log("━".repeat(40)); @@ -54,13 +50,6 @@ async function ralphLoop(mode: Mode, maxIterations: number) { await session.destroy(); } - // Push changes after each iteration - try { - execSync(`git push origin ${branch}`, { stdio: "inherit" }); - } catch { - execSync(`git push -u origin ${branch}`, { stdio: "inherit" }); - } - console.log(`\nIteration ${i} complete.`); } diff --git a/cookbook/copilot-sdk/python/ralph-loop.md b/cookbook/copilot-sdk/python/ralph-loop.md index fb8e3ced..ae666eb2 100644 --- a/cookbook/copilot-sdk/python/ralph-loop.md +++ b/cookbook/copilot-sdk/python/ralph-loop.md @@ -85,7 +85,6 @@ The full Ralph pattern with planning and building modes, matching the [Ralph Pla ```python import asyncio -import subprocess import sys from pathlib import Path @@ -97,14 +96,9 @@ async def ralph_loop(mode: str = "build", max_iterations: int = 50): client = CopilotClient() await client.start() - branch = subprocess.check_output( - ["git", "branch", "--show-current"], text=True - ).strip() - print("━" * 40) print(f"Mode: {mode}") print(f"Prompt: {prompt_file}") - print(f"Branch: {branch}") print(f"Max: {max_iterations} iterations") print("━" * 40) @@ -125,16 +119,6 @@ async def ralph_loop(mode: str = "build", max_iterations: int = 50): finally: await session.destroy() - # Push changes after each iteration - try: - subprocess.run( - ["git", "push", "origin", branch], check=True - ) - except subprocess.CalledProcessError: - subprocess.run( - ["git", "push", "-u", "origin", branch], check=True - ) - print(f"\nIteration {i} complete.") print(f"\nReached max iterations: {max_iterations}") diff --git a/cookbook/copilot-sdk/python/recipe/ralph_loop.py b/cookbook/copilot-sdk/python/recipe/ralph_loop.py index 5e9d9422..f6ef1f62 100644 --- a/cookbook/copilot-sdk/python/recipe/ralph_loop.py +++ b/cookbook/copilot-sdk/python/recipe/ralph_loop.py @@ -19,7 +19,6 @@ Usage: """ import asyncio -import subprocess import sys from pathlib import Path @@ -32,14 +31,9 @@ async def ralph_loop(mode: str = "build", max_iterations: int = 50): client = CopilotClient() await client.start() - branch = subprocess.check_output( - ["git", "branch", "--show-current"], text=True - ).strip() - print("━" * 40) print(f"Mode: {mode}") print(f"Prompt: {prompt_file}") - print(f"Branch: {branch}") print(f"Max: {max_iterations} iterations") print("━" * 40) @@ -60,16 +54,6 @@ async def ralph_loop(mode: str = "build", max_iterations: int = 50): finally: await session.destroy() - # Push changes after each iteration - try: - subprocess.run( - ["git", "push", "origin", branch], check=True - ) - except subprocess.CalledProcessError: - subprocess.run( - ["git", "push", "-u", "origin", branch], check=True - ) - print(f"\nIteration {i} complete.") print(f"\nReached max iterations: {max_iterations}")