Skip to content

Commit 92df16d

Browse files
committed
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.
1 parent 952372c commit 92df16d

File tree

8 files changed

+1
-109
lines changed

8 files changed

+1
-109
lines changed

cookbook/copilot-sdk/dotnet/ralph-loop.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ This is all you need to get started. The prompt file tells the agent what to do;
9292
The full Ralph pattern with planning and building modes, matching the [Ralph Playbook](https://github.com/ClaytonFarr/ralph-playbook) architecture:
9393
9494
```csharp
95-
using System.Diagnostics;
9695
using GitHub.Copilot.SDK;
9796
9897
// Parse args: dotnet run [plan] [max_iterations]
@@ -104,16 +103,9 @@ var promptFile = mode == "plan" ? "PROMPT_plan.md" : "PROMPT_build.md";
104103
var client = new CopilotClient();
105104
await client.StartAsync();
106105
107-
var branchInfo = new ProcessStartInfo("git", "branch --show-current")
108-
{ RedirectStandardOutput = true };
109-
var branch = Process.Start(branchInfo)!;
110-
var branchName = (await branch.StandardOutput.ReadToEndAsync()).Trim();
111-
await branch.WaitForExitAsync();
112-
113106
Console.WriteLine(new string('', 40));
114107
Console.WriteLine($"Mode: {mode}");
115108
Console.WriteLine($"Prompt: {promptFile}");
116-
Console.WriteLine($"Branch: {branchName}");
117109
Console.WriteLine($"Max: {maxIterations} iterations");
118110
Console.WriteLine(new string('', 40));
119111
@@ -145,16 +137,6 @@ try
145137
await session.DisposeAsync();
146138
}
147139
148-
// Push changes after each iteration
149-
try
150-
{
151-
Process.Start("git", $"push origin {branchName}")!.WaitForExit();
152-
}
153-
catch
154-
{
155-
Process.Start("git", $"push -u origin {branchName}")!.WaitForExit();
156-
}
157-
158140
Console.WriteLine($"\nIteration {i} complete.");
159141
}
160142

cookbook/copilot-sdk/dotnet/recipe/ralph-loop.cs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#:package GitHub.Copilot.SDK@*
22
#:property PublishAot=false
33

4-
using System.Diagnostics;
54
using GitHub.Copilot.SDK;
65

76
// Ralph loop: autonomous AI task loop with fresh context per iteration.
@@ -28,15 +27,9 @@
2827
var client = new CopilotClient();
2928
await client.StartAsync();
3029

31-
var branchProc = Process.Start(new ProcessStartInfo("git", "branch --show-current")
32-
{ RedirectStandardOutput = true })!;
33-
var branch = (await branchProc.StandardOutput.ReadToEndAsync()).Trim();
34-
await branchProc.WaitForExitAsync();
35-
3630
Console.WriteLine(new string('━', 40));
3731
Console.WriteLine($"Mode: {mode}");
3832
Console.WriteLine($"Prompt: {promptFile}");
39-
Console.WriteLine($"Branch: {branch}");
4033
Console.WriteLine($"Max: {maxIterations} iterations");
4134
Console.WriteLine(new string('━', 40));
4235

@@ -69,16 +62,6 @@
6962
await session.DisposeAsync();
7063
}
7164

72-
// Push changes after each iteration
73-
try
74-
{
75-
Process.Start("git", $"push origin {branch}")!.WaitForExit();
76-
}
77-
catch
78-
{
79-
Process.Start("git", $"push -u origin {branch}")!.WaitForExit();
80-
}
81-
8265
Console.WriteLine($"\nIteration {i} complete.");
8366
}
8467

cookbook/copilot-sdk/go/ralph-loop.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ import (
110110
"fmt"
111111
"log"
112112
"os"
113-
"os/exec"
114113
"strconv"
115-
"strings"
116114
117115
copilot "github.com/github/copilot-sdk/go"
118116
)
@@ -129,13 +127,9 @@ func ralphLoop(ctx context.Context, mode string, maxIterations int) error {
129127
}
130128
defer client.Stop()
131129
132-
branchOut, _ := exec.Command("git", "branch", "--show-current").Output()
133-
branch := strings.TrimSpace(string(branchOut))
134-
135130
fmt.Println(strings.Repeat("━", 40))
136131
fmt.Printf("Mode: %s\n", mode)
137132
fmt.Printf("Prompt: %s\n", promptFile)
138-
fmt.Printf("Branch: %s\n", branch)
139133
fmt.Printf("Max: %d iterations\n", maxIterations)
140134
fmt.Println(strings.Repeat("━", 40))
141135
@@ -163,11 +157,6 @@ func ralphLoop(ctx context.Context, mode string, maxIterations int) error {
163157
return err
164158
}
165159
166-
// Push changes after each iteration
167-
if err := exec.Command("git", "push", "origin", branch).Run(); err != nil {
168-
exec.Command("git", "push", "-u", "origin", branch).Run()
169-
}
170-
171160
fmt.Printf("\nIteration %d complete.\n", i)
172161
}
173162

cookbook/copilot-sdk/go/recipe/ralph-loop.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"log"
77
"os"
8-
"os/exec"
98
"strconv"
109
"strings"
1110

@@ -40,13 +39,9 @@ func ralphLoop(ctx context.Context, mode string, maxIterations int) error {
4039
}
4140
defer client.Stop()
4241

43-
branchOut, _ := exec.Command("git", "branch", "--show-current").Output()
44-
branch := strings.TrimSpace(string(branchOut))
45-
4642
fmt.Println(strings.Repeat("━", 40))
4743
fmt.Printf("Mode: %s\n", mode)
4844
fmt.Printf("Prompt: %s\n", promptFile)
49-
fmt.Printf("Branch: %s\n", branch)
5045
fmt.Printf("Max: %d iterations\n", maxIterations)
5146
fmt.Println(strings.Repeat("━", 40))
5247

@@ -74,11 +69,6 @@ func ralphLoop(ctx context.Context, mode string, maxIterations int) error {
7469
return fmt.Errorf("send failed on iteration %d: %w", i, err)
7570
}
7671

77-
// Push changes after each iteration
78-
if err := exec.Command("git", "push", "origin", branch).Run(); err != nil {
79-
exec.Command("git", "push", "-u", "origin", branch).Run()
80-
}
81-
8272
fmt.Printf("\nIteration %d complete.\n", i)
8373
}
8474

cookbook/copilot-sdk/nodejs/ralph-loop.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ The full Ralph pattern with planning and building modes, matching the [Ralph Pla
8282
8383
```typescript
8484
import { readFile } from "fs/promises";
85-
import { execSync } from "child_process";
8685
import { CopilotClient } from "@github/copilot-sdk";
8786
8887
type Mode = "plan" | "build";
@@ -92,8 +91,7 @@ async function ralphLoop(mode: Mode, maxIterations: number = 50) {
9291
const client = new CopilotClient();
9392
await client.start();
9493
95-
const branch = execSync("git branch --show-current", { encoding: "utf-8" }).trim();
96-
console.log(`Mode: ${mode} | Prompt: ${promptFile} | Branch: ${branch}`);
94+
console.log(`Mode: ${mode} | Prompt: ${promptFile}`);
9795
9896
try {
9997
const prompt = await readFile(promptFile, "utf-8");
@@ -109,13 +107,6 @@ async function ralphLoop(mode: Mode, maxIterations: number = 50) {
109107
await session.destroy();
110108
}
111109
112-
// Push changes after each iteration
113-
try {
114-
execSync(`git push origin ${branch}`, { stdio: "inherit" });
115-
} catch {
116-
execSync(`git push -u origin ${branch}`, { stdio: "inherit" });
117-
}
118-
119110
console.log(`Iteration ${i} complete.`);
120111
}
121112
} finally {

cookbook/copilot-sdk/nodejs/recipe/ralph-loop.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { readFile } from "fs/promises";
2-
import { execSync } from "child_process";
32
import { CopilotClient } from "@github/copilot-sdk";
43

54
/**
@@ -28,12 +27,9 @@ async function ralphLoop(mode: Mode, maxIterations: number) {
2827
const client = new CopilotClient();
2928
await client.start();
3029

31-
const branch = execSync("git branch --show-current", { encoding: "utf-8" }).trim();
32-
3330
console.log("━".repeat(40));
3431
console.log(`Mode: ${mode}`);
3532
console.log(`Prompt: ${promptFile}`);
36-
console.log(`Branch: ${branch}`);
3733
console.log(`Max: ${maxIterations} iterations`);
3834
console.log("━".repeat(40));
3935

@@ -54,13 +50,6 @@ async function ralphLoop(mode: Mode, maxIterations: number) {
5450
await session.destroy();
5551
}
5652

57-
// Push changes after each iteration
58-
try {
59-
execSync(`git push origin ${branch}`, { stdio: "inherit" });
60-
} catch {
61-
execSync(`git push -u origin ${branch}`, { stdio: "inherit" });
62-
}
63-
6453
console.log(`\nIteration ${i} complete.`);
6554
}
6655

cookbook/copilot-sdk/python/ralph-loop.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ The full Ralph pattern with planning and building modes, matching the [Ralph Pla
8585
8686
```python
8787
import asyncio
88-
import subprocess
8988
import sys
9089
from pathlib import Path
9190
@@ -97,14 +96,9 @@ async def ralph_loop(mode: str = "build", max_iterations: int = 50):
9796
client = CopilotClient()
9897
await client.start()
9998
100-
branch = subprocess.check_output(
101-
["git", "branch", "--show-current"], text=True
102-
).strip()
103-
10499
print("━" * 40)
105100
print(f"Mode: {mode}")
106101
print(f"Prompt: {prompt_file}")
107-
print(f"Branch: {branch}")
108102
print(f"Max: {max_iterations} iterations")
109103
print("━" * 40)
110104
@@ -125,16 +119,6 @@ async def ralph_loop(mode: str = "build", max_iterations: int = 50):
125119
finally:
126120
await session.destroy()
127121
128-
# Push changes after each iteration
129-
try:
130-
subprocess.run(
131-
["git", "push", "origin", branch], check=True
132-
)
133-
except subprocess.CalledProcessError:
134-
subprocess.run(
135-
["git", "push", "-u", "origin", branch], check=True
136-
)
137-
138122
print(f"\nIteration {i} complete.")
139123
140124
print(f"\nReached max iterations: {max_iterations}")

cookbook/copilot-sdk/python/recipe/ralph_loop.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"""
2020

2121
import asyncio
22-
import subprocess
2322
import sys
2423
from pathlib import Path
2524

@@ -32,14 +31,9 @@ async def ralph_loop(mode: str = "build", max_iterations: int = 50):
3231
client = CopilotClient()
3332
await client.start()
3433

35-
branch = subprocess.check_output(
36-
["git", "branch", "--show-current"], text=True
37-
).strip()
38-
3934
print("━" * 40)
4035
print(f"Mode: {mode}")
4136
print(f"Prompt: {prompt_file}")
42-
print(f"Branch: {branch}")
4337
print(f"Max: {max_iterations} iterations")
4438
print("━" * 40)
4539

@@ -60,16 +54,6 @@ async def ralph_loop(mode: str = "build", max_iterations: int = 50):
6054
finally:
6155
await session.destroy()
6256

63-
# Push changes after each iteration
64-
try:
65-
subprocess.run(
66-
["git", "push", "origin", branch], check=True
67-
)
68-
except subprocess.CalledProcessError:
69-
subprocess.run(
70-
["git", "push", "-u", "origin", branch], check=True
71-
)
72-
7357
print(f"\nIteration {i} complete.")
7458

7559
print(f"\nReached max iterations: {max_iterations}")

0 commit comments

Comments
 (0)