Skip to content

Commit 7d9b2e5

Browse files
Remove ralph-loop tool and delegate to memory-plan-ralph
1 parent 0255f9f commit 7d9b2e5

6 files changed

Lines changed: 11 additions & 73 deletions

File tree

docs/features/memory.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -434,17 +434,6 @@ No parameters required.
434434

435435
Returns a list of all stored keys with their values and expiration times. Useful for debugging or inspecting current project state.
436436

437-
### ralph-loop
438-
439-
Start a Ralph iterative development loop. By default runs in an isolated git worktree. Set `inPlace` to `true` to run in the current directory instead.
440-
441-
| Parameter | Type | Required | Description |
442-
|-----------|------|----------|-------------|
443-
| `prompt` | string | Yes | The task prompt to iterate on |
444-
| `completionPromise` | string | No | Phrase that signals completion when wrapped in `<promise>` tags |
445-
| `name` | string | No | Name for the worktree branch |
446-
| `inPlace` | boolean | No | Run in current directory instead of creating a worktree |
447-
448437
### ralph-cancel
449438

450439
Cancel an active Ralph loop and optionally clean up the worktree.
@@ -551,7 +540,6 @@ During a Ralph loop, certain tools are blocked to keep the agent focused:
551540
- `question` — No interactive questions; work autonomously
552541
- `memory-plan-execute` — Cannot start new plan sessions
553542
- `memory-plan-ralph` — Cannot start nested Ralph loops
554-
- `ralph-loop` — Cannot start additional loops
555543

556544
Blocking is enforced via `tool.execute.before` (throws error) with `tool.execute.after` as defense in depth.
557545

@@ -566,7 +554,7 @@ Blocking is enforced via `tool.execute.before` (throws error) with `tool.execute
566554

567555
| Command | Description |
568556
|---------|-------------|
569-
| `/ralph-loop <prompt>` | Start a Ralph loop via the Code agent |
557+
| `/ralph-loop <prompt>` | Start a Ralph loop (delegates to memory-plan-ralph) |
570558
| `/cancel-ralph` | Cancel the active Ralph loop |
571559

572560
---
@@ -654,7 +642,7 @@ The default agent is set to `code`.
654642
| Command | Description | Agent | Mode |
655643
|---------|-------------|-------|------|
656644
| `/review` | Run a code review on current changes | auditor | subtask |
657-
| `/ralph-loop` | Start a Ralph iterative development loop | code | direct |
645+
| `/ralph-loop` | Start a Ralph loop (delegates to memory-plan-ralph) | code | direct |
658646
| `/cancel-ralph` | Cancel the active Ralph loop | code | direct |
659647

660648
---
@@ -711,7 +699,7 @@ Memory injection is controlled independently by `memoryInjection.enabled` (defau
711699

712700
### tool.execute.before
713701

714-
Blocks certain tools during active Ralph loops to keep the agent focused on the current task. Throws an error with a descriptive message when a blocked tool is called. Blocked tools: `question`, `memory-plan-execute`, `memory-plan-ralph`, `ralph-loop`.
702+
Blocks certain tools during active Ralph loops to keep the agent focused on the current task. Throws an error with a descriptive message when a blocked tool is called. Blocked tools: `question`, `memory-plan-execute`, `memory-plan-ralph`.
715703

716704
### tool.execute.after
717705

packages/memory/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ Iterative development loops with automatic auditing. Runs in an isolated git wor
8282

8383
| Tool | Description |
8484
|------|-------------|
85-
| `ralph-loop` | Start an iterative development loop with optional auditing |
8685
| `ralph-cancel` | Cancel an active Ralph loop and clean up the worktree |
8786
| `ralph-status` | Check status of active Ralph loops |
8887
| `memory-plan-ralph` | Execute an architect plan using a Ralph iterative loop |
@@ -92,7 +91,7 @@ Iterative development loops with automatic auditing. Runs in an isolated git wor
9291
| Command | Description | Agent |
9392
|---------|-------------|-------|
9493
| `/review` | Run a code review on current changes | auditor (subtask) |
95-
| `/ralph-loop` | Start a Ralph iterative development loop | code |
94+
| `/ralph-loop` | Start a Ralph loop (delegates to memory-plan-ralph) | code |
9695
| `/cancel-ralph` | Cancel the active Ralph loop | code |
9796

9897
## CLI
@@ -330,7 +329,7 @@ The loop completes when the Code agent outputs the completion promise. It auto-t
330329

331330
By default, Ralph loops run in an isolated git worktree. Set `inPlace: true` to run in the current directory instead (skips worktree creation, auto-commit, and cleanup).
332331

333-
See the [full documentation](https://chriswritescode-dev.github.io/opencode-manager/features/memory/#ralph-loop) for details.
332+
See the [full documentation](https://chriswritescode-dev.github.io/opencode-manager/features/memory/#ralph-loop) for details on the Ralph loop system.
334333

335334
## Documentation
336335

packages/memory/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const PLUGIN_COMMANDS: Record<string, { template: string; description: string; a
2121
description: 'Start a Ralph iterative development loop in a worktree',
2222
agent: 'code',
2323
subtask: false,
24-
template: 'Use the ralph-loop tool to start a Ralph loop with the following arguments: $ARGUMENTS',
24+
template: 'Use the memory-plan-ralph tool to start a Ralph loop. Use the following as the plan: $ARGUMENTS. Derive a short title from the plan.',
2525
},
2626
'cancel-ralph': {
2727
description: 'Cancel the active Ralph loop',

packages/memory/src/index.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ export function createMemoryPlugin(config: PluginConfig): Plugin {
592592
question: 'The question tool is not available during a Ralph loop. Do not ask questions — continue working on the task autonomously.',
593593
'memory-plan-execute': 'The memory-plan-execute tool is not available during a Ralph loop. Focus on executing the current plan.',
594594
'memory-plan-ralph': 'The memory-plan-ralph tool is not available during a Ralph loop. Focus on executing the current plan.',
595-
'ralph-loop': 'The ralph-loop tool is not available during a Ralph loop. Focus on executing the current plan.',
596595
}
597596

598597
const PLAN_APPROVAL_LABELS = ['New session', 'Execute here', 'Ralph (worktree)', 'Ralph (in place)']
@@ -936,38 +935,7 @@ Do NOT output text without also making this tool call.
936935
return `${entries.length} active KV entries:\n\n${formatted.join('\n')}`
937936
},
938937
}),
939-
'ralph-loop': tool({
940-
description: 'Start a Ralph Wiggum iterative development loop. By default runs in an isolated git worktree. Set inPlace to true to run in the current directory instead.',
941-
args: {
942-
prompt: z.string().describe('The task prompt to iterate on'),
943-
completionPromise: z.string().optional().describe('Phrase that signals completion when wrapped in <promise> tags'),
944-
name: z.string().optional().describe('Optional name for the worktree branch'),
945-
inPlace: z.boolean().optional().describe('Run in current directory instead of creating a worktree'),
946-
},
947-
execute: async (args, context) => {
948-
if (config.ralph?.enabled === false) {
949-
return 'Ralph loops are disabled in plugin config.'
950-
}
951938

952-
logger.log(`ralph-loop: creating worktree for prompt="${args.prompt.substring(0, 80)}"`)
953-
954-
const titlePreview = args.prompt.length > 40 ? `${args.prompt.substring(0, 37)}...` : args.prompt
955-
const ralphModel = parseModelString(config.ralph?.model) ?? parseModelString(config.executionModel)
956-
957-
return setupRalphLoop({
958-
prompt: args.prompt,
959-
sessionTitle: `Ralph: ${titlePreview}`,
960-
worktreeName: args.name,
961-
completionPromise: args.completionPromise ?? null,
962-
maxIterations: config.ralph?.defaultMaxIterations ?? 0,
963-
audit: config.ralph?.defaultAudit ?? true,
964-
model: ralphModel,
965-
inPlace: args.inPlace,
966-
parentSessionId: context.sessionID,
967-
onLoopStarted: (id) => ralphHandler.startWatchdog(id),
968-
})
969-
},
970-
}),
971939
'ralph-cancel': tool({
972940
description: 'Cancel an active Ralph loop and optionally clean up the worktree.',
973941
args: {

packages/memory/test/plan-approval.test.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ Do NOT output text without also making this tool call.
132132
question: 'The question tool is not available during a Ralph loop. Do not ask questions — continue working on the task autonomously.',
133133
'memory-plan-execute': 'The memory-plan-execute tool is not available during a Ralph loop. Focus on executing the current plan.',
134134
'memory-plan-ralph': 'The memory-plan-ralph tool is not available during a Ralph loop. Focus on executing the current plan.',
135-
'ralph-loop': 'The ralph-loop tool is not available during a Ralph loop. Focus on executing the current plan.',
136135
}
137136

138137
if (!(tool in RALPH_BLOCKED_TOOLS)) return
@@ -348,15 +347,6 @@ Do NOT output text without also making this tool call.
348347
expect(output.output).toContain('memory-plan-ralph tool is not available')
349348
})
350349

351-
test('Ralph blocking works for ralph-loop tool', () => {
352-
const output = { title: '', output: 'test', metadata: {} }
353-
354-
simulateToolExecuteAfter('ralph-loop', {}, output, true)
355-
356-
expect(output.title).toBe('Tool blocked')
357-
expect(output.output).toContain('ralph-loop tool is not available')
358-
})
359-
360350
test('Ralph blocking does not affect non-blocked tools', () => {
361351
const output = { title: '', output: 'test', metadata: {} }
362352

packages/memory/test/tool-blocking.test.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,32 +107,27 @@ describe('Tool Blocking Logic', () => {
107107

108108
describe('Blocked tools list', () => {
109109
test('includes question tool', () => {
110-
const blockedTools = ['question', 'memory-plan-execute', 'memory-plan-ralph', 'ralph-loop']
110+
const blockedTools = ['question', 'memory-plan-execute', 'memory-plan-ralph']
111111
expect(blockedTools).toContain('question')
112112
})
113113

114114
test('includes memory-plan-execute tool', () => {
115-
const blockedTools = ['question', 'memory-plan-execute', 'memory-plan-ralph', 'ralph-loop']
115+
const blockedTools = ['question', 'memory-plan-execute', 'memory-plan-ralph']
116116
expect(blockedTools).toContain('memory-plan-execute')
117117
})
118118

119119
test('includes memory-plan-ralph tool', () => {
120-
const blockedTools = ['question', 'memory-plan-execute', 'memory-plan-ralph', 'ralph-loop']
120+
const blockedTools = ['question', 'memory-plan-execute', 'memory-plan-ralph']
121121
expect(blockedTools).toContain('memory-plan-ralph')
122122
})
123123

124-
test('includes ralph-loop tool', () => {
125-
const blockedTools = ['question', 'memory-plan-execute', 'memory-plan-ralph', 'ralph-loop']
126-
expect(blockedTools).toContain('ralph-loop')
127-
})
128-
129124
test('does not include memory-read tool', () => {
130-
const blockedTools = ['question', 'memory-plan-execute', 'memory-plan-ralph', 'ralph-loop']
125+
const blockedTools = ['question', 'memory-plan-execute', 'memory-plan-ralph']
131126
expect(blockedTools).not.toContain('memory-read')
132127
})
133128

134129
test('does not include memory-write tool', () => {
135-
const blockedTools = ['question', 'memory-plan-execute', 'memory-plan-ralph', 'ralph-loop']
130+
const blockedTools = ['question', 'memory-plan-execute', 'memory-plan-ralph']
136131
expect(blockedTools).not.toContain('memory-write')
137132
})
138133
})
@@ -143,7 +138,6 @@ describe('Tool Blocking Logic', () => {
143138
'question': 'The question tool is not available during a Ralph loop. Do not ask questions — continue working on the task autonomously.',
144139
'memory-plan-execute': 'The memory-plan-execute tool is not available during a Ralph loop. Focus on executing the current plan.',
145140
'memory-plan-ralph': 'The memory-plan-ralph tool is not available during a Ralph loop. Focus on executing the current plan.',
146-
'ralph-loop': 'The ralph-loop tool is not available during a Ralph loop. Focus on executing the current plan.',
147141
}
148142
expect(messages['question']).toContain('question tool is not available')
149143
})
@@ -153,7 +147,6 @@ describe('Tool Blocking Logic', () => {
153147
'question': 'The question tool is not available during a Ralph loop. Do not ask questions — continue working on the task autonomously.',
154148
'memory-plan-execute': 'The memory-plan-execute tool is not available during a Ralph loop. Focus on executing the current plan.',
155149
'memory-plan-ralph': 'The memory-plan-ralph tool is not available during a Ralph loop. Focus on executing the current plan.',
156-
'ralph-loop': 'The ralph-loop tool is not available during a Ralph loop. Focus on executing the current plan.',
157150
}
158151
expect(messages['memory-plan-execute']).toContain('memory-plan-execute tool is not available')
159152
})

0 commit comments

Comments
 (0)