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.
This commit is contained in:
Anthony Shaw
2026-02-11 11:32:42 -08:00
parent 952372c1ec
commit 92df16da5a
8 changed files with 1 additions and 109 deletions

View File

@@ -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.");
}

View File

@@ -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.");
}

View File

@@ -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)
}

View File

@@ -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)
}

View File

@@ -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 {

View File

@@ -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.`);
}

View File

@@ -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}")

View File

@@ -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}")