From 5f7abe3fd88ed534099a5a7fe42b6996638fffc1 Mon Sep 17 00:00:00 2001 From: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com> Date: Fri, 27 Mar 2026 15:31:59 -0400 Subject: [PATCH] Refactor: replace Ralph terminology with Loop --- packages/memory/package.json | 2 +- packages/memory/src/cli/commands/status.ts | 2 +- packages/memory/src/cli/index.ts | 4 +-- packages/memory/src/hooks/loop.ts | 30 +++++++++---------- packages/memory/src/index.ts | 34 ++++++++++++++-------- packages/memory/src/types.ts | 1 + packages/memory/src/version.ts | 2 +- 7 files changed, 43 insertions(+), 32 deletions(-) diff --git a/packages/memory/package.json b/packages/memory/package.json index 00e0f710..b7ce9a77 100644 --- a/packages/memory/package.json +++ b/packages/memory/package.json @@ -1,6 +1,6 @@ { "name": "@opencode-manager/memory", - "version": "0.0.26", + "version": "0.0.27", "type": "module", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/packages/memory/src/cli/commands/status.ts b/packages/memory/src/cli/commands/status.ts index ed538246..5ec63e1b 100644 --- a/packages/memory/src/cli/commands/status.ts +++ b/packages/memory/src/cli/commands/status.ts @@ -138,7 +138,7 @@ export async function run(argv: StatusArgs): Promise { } if (!match && candidates.length === 0) { - console.error(`Ralph loop not found: ${worktreeName}`) + console.error(`Loop not found: ${worktreeName}`) console.error('') if (activeLoops.length > 0) { console.error('Active loops:') diff --git a/packages/memory/src/cli/index.ts b/packages/memory/src/cli/index.ts index 9f2d4988..4ca16a20 100644 --- a/packages/memory/src/cli/index.ts +++ b/packages/memory/src/cli/index.ts @@ -103,8 +103,8 @@ Commands: stats Show memory statistics cleanup Delete memories by criteria upgrade Check for and install plugin updates - status Show Ralph loop status - cancel Cancel a Ralph loop + status Show loop status + cancel Cancel a loop Global Options: --db-path Path to memory database diff --git a/packages/memory/src/hooks/loop.ts b/packages/memory/src/hooks/loop.ts index 8062165f..52d4887a 100644 --- a/packages/memory/src/hooks/loop.ts +++ b/packages/memory/src/hooks/loop.ts @@ -123,11 +123,11 @@ export function createLoopEventHandler( if (hasActiveWork) { lastActivityTime.set(worktreeName, Date.now()) - logger.log(`Ralph watchdog: worktree ${worktreeName} has active work, resetting timer`) + logger.log(`Loop watchdog: worktree ${worktreeName} has active work, resetting timer`) return } } catch (err) { - logger.error(`Ralph watchdog: failed to check session status`, err) + logger.error(`Loop watchdog: failed to check session status`, err) return } @@ -136,12 +136,12 @@ export function createLoopEventHandler( lastActivityTime.set(worktreeName, Date.now()) if (stallCount >= MAX_CONSECUTIVE_STALLS) { - logger.error(`Ralph watchdog: worktree ${worktreeName} exceeded max consecutive stalls (${MAX_CONSECUTIVE_STALLS}), terminating`) + logger.error(`Loop watchdog: worktree ${worktreeName} exceeded max consecutive stalls (${MAX_CONSECUTIVE_STALLS}), terminating`) await terminateLoop(worktreeName, state, 'stall_timeout') return } - logger.log(`Ralph watchdog: stall detected for worktree ${worktreeName} (${stallCount}/${MAX_CONSECUTIVE_STALLS}), re-triggering ${state.phase} phase`) + logger.log(`Loop watchdog: stall detected for worktree ${worktreeName} (${stallCount}/${MAX_CONSECUTIVE_STALLS}), re-triggering ${state.phase} phase`) try { if (state.phase === 'auditing') { @@ -155,7 +155,7 @@ export function createLoopEventHandler( }, stallTimeout) stallWatchdogs.set(worktreeName, interval) - logger.log(`Ralph watchdog: started for worktree ${worktreeName} (timeout: ${stallTimeout}ms)`) + logger.log(`Loop watchdog: started for worktree ${worktreeName} (timeout: ${stallTimeout}ms)`) } function getStallInfo(worktreeName: string): { consecutiveStalls: number; lastActivityTime: number } | null { @@ -192,7 +192,7 @@ export function createLoopEventHandler( // Session may already be idle } - logger.log(`Ralph loop terminated: reason="${reason}", worktree="${state.worktreeName}", iteration=${state.iteration}`) + logger.log(`Loop terminated: reason="${reason}", worktree="${state.worktreeName}", iteration=${state.iteration}`) let commitResult: { committed: boolean; cleaned: boolean } | undefined if (reason === 'completed' || reason === 'cancelled') { @@ -334,7 +334,7 @@ export function createLoopEventHandler( const currentAuditCount = currentState.auditCount ?? 0 if (!currentState.audit || currentAuditCount >= minAudits) { await terminateLoop(worktreeName, currentState, 'completed') - logger.log(`Ralph loop completed: detected ${currentState.completionPromise} at iteration ${currentState.iteration} (${currentAuditCount}/${minAudits} audits)`) + logger.log(`Loop completed: detected ${currentState.completionPromise} at iteration ${currentState.iteration} (${currentAuditCount}/${minAudits} audits)`) return } logger.log(`Loop: completion promise detected but only ${currentAuditCount}/${minAudits} audits performed, continuing`) @@ -354,7 +354,7 @@ export function createLoopEventHandler( if (currentState.audit) { loopService.setState(worktreeName, { ...currentState, phase: 'auditing', errorCount: 0 }) - logger.log(`Ralph iteration ${currentState.iteration ?? 0} complete, running auditor for session ${currentState.sessionId}`) + logger.log(`Loop iteration ${currentState.iteration ?? 0} complete, running auditor for session ${currentState.sessionId}`) const auditPrompt = { sessionID: currentState.sessionId, @@ -381,7 +381,7 @@ export function createLoopEventHandler( } const currentConfig = getConfig() - const configuredModel = currentConfig.auditorModel ?? currentConfig.ralph?.model ?? currentConfig.executionModel + const configuredModel = currentConfig.auditorModel ?? currentConfig.loop?.model ?? currentConfig.executionModel logger.log(`auditor using agent-configured model: ${configuredModel ?? 'default'}`) consecutiveStalls.set(worktreeName, 0) @@ -404,13 +404,13 @@ export function createLoopEventHandler( }) const continuationPrompt = loopService.buildContinuationPrompt({ ...currentState, iteration: nextIteration }) - logger.log(`Ralph iteration ${nextIteration} for session ${activeSessionId}`) + logger.log(`Loop iteration ${nextIteration} for session ${activeSessionId}`) const currentConfig = getConfig() const freshStateForModel = loopService.getActiveState(worktreeName) const loopModel = freshStateForModel?.modelFailed ? undefined - : (parseModelString(currentConfig.ralph?.model) ?? parseModelString(currentConfig.executionModel)) + : (parseModelString(currentConfig.loop?.model) ?? parseModelString(currentConfig.executionModel)) if (freshStateForModel?.modelFailed) { logger.log(`Loop: configured model previously failed, using default model`) @@ -512,7 +512,7 @@ export function createLoopEventHandler( const nextIteration = (currentState.iteration ?? 0) + 1 const newAuditCount = (currentState.auditCount ?? 0) + 1 - logger.log(`Ralph audit ${newAuditCount} at iteration ${currentState.iteration ?? 0}`) + logger.log(`Loop audit ${newAuditCount} at iteration ${currentState.iteration ?? 0}`) // Always pass the full audit response to the code agent const auditFindings = auditText ?? undefined @@ -522,7 +522,7 @@ export function createLoopEventHandler( // Check if minimum audits have been performed if (!currentState.audit || newAuditCount >= minAudits) { await terminateLoop(worktreeName, currentState, 'completed') - logger.log(`Ralph loop completed: detected ${currentState.completionPromise} in audit at iteration ${currentState.iteration} (${newAuditCount}/${minAudits} audits)`) + logger.log(`Loop completed: detected ${currentState.completionPromise} in audit at iteration ${currentState.iteration} (${newAuditCount}/${minAudits} audits)`) return } logger.log(`Loop: completion promise detected but only ${newAuditCount}/${minAudits} audits performed, continuing`) @@ -555,13 +555,13 @@ export function createLoopEventHandler( { ...currentState, iteration: nextIteration }, auditFindings, ) - logger.log(`Ralph iteration ${nextIteration} for session ${activeSessionId}`) + logger.log(`Loop iteration ${nextIteration} for session ${activeSessionId}`) const currentConfig = getConfig() const freshStateForModel = loopService.getActiveState(worktreeName) const loopModel = freshStateForModel?.modelFailed ? undefined - : (parseModelString(currentConfig.ralph?.model) ?? parseModelString(currentConfig.executionModel)) + : (parseModelString(currentConfig.loop?.model) ?? parseModelString(currentConfig.executionModel)) if (freshStateForModel?.modelFailed) { logger.log(`Loop: configured model previously failed, using default model`) diff --git a/packages/memory/src/index.ts b/packages/memory/src/index.ts index 466530de..98b3450d 100644 --- a/packages/memory/src/index.ts +++ b/packages/memory/src/index.ts @@ -457,7 +457,7 @@ export function createMemoryPlugin(config: PluginConfig): Plugin { if (createResult.error || !createResult.data) { logger.error(`loop: failed to create session`, createResult.error) - return 'Failed to create Ralph session.' + return 'Failed to create loop session.' } loopContext = { @@ -491,7 +491,7 @@ export function createMemoryPlugin(config: PluginConfig): Plugin { } catch (cleanupErr) { logger.error(`loop: failed to cleanup worktree`, cleanupErr) } - return 'Failed to create Ralph session.' + return 'Failed to create loop session.' } loopContext = { @@ -560,12 +560,18 @@ export function createMemoryPlugin(config: PluginConfig): Plugin { } } return !options.worktree - ? 'Ralph session created but failed to send prompt.' - : 'Ralph session created but failed to send prompt. Cleaned up.' + ? 'Loop session created but failed to send prompt.' + : 'Loop session created but failed to send prompt. Cleaned up.' } options.onLoopStarted?.(autoWorktreeName) + if (!options.worktree) { + v2.tui.selectSession({ sessionID: loopContext.sessionId }).catch((err) => { + logger.error('loop: failed to navigate TUI to new session', err) + }) + } + const maxInfo = maxIter > 0 ? maxIter.toString() : 'unlimited' const auditInfo = options.audit ? 'enabled' : 'disabled' const modelInfo = actualModel ? `${actualModel.providerID}/${actualModel.modelID}` : 'default' @@ -859,8 +865,12 @@ Do NOT output text without also making this tool call. logger.log(`memory-plan-execute: prompted session=${newSessionId}`) + v2.tui.selectSession({ sessionID: newSessionId }).catch((err) => { + logger.error('memory-plan-execute: failed to navigate TUI to new session', err) + }) + const modelInfo = actualModel ? `${actualModel.providerID}/${actualModel.modelID}` : 'default' - return `Implementation session created and plan sent.\n\nSession: ${newSessionId}\nTitle: ${sessionTitle}\nModel: ${modelInfo}\n\nSwitch to this session to begin. You can change the model from the session dropdown.` + return `Implementation session created and plan sent.\n\nSession: ${newSessionId}\nTitle: ${sessionTitle}\nModel: ${modelInfo}\n\nNavigated to the new session. You can change the model from the session dropdown.` }, }), 'memory-loop': tool({ @@ -872,7 +882,7 @@ Do NOT output text without also making this tool call. }, execute: async (args, context) => { if (config.loop?.enabled === false) { - return 'Ralph loops are disabled in plugin config. Use memory-plan-execute instead.' + return 'Loops are disabled in plugin config. Use memory-plan-execute instead.' } logger.log(`memory-loop: creating worktree for plan="${args.title}"`) @@ -1223,7 +1233,7 @@ Do NOT output text without also making this tool call. if (candidates.length > 0) { return `Multiple loops match "${args.name}":\n${candidates.map((s) => `- ${s.worktreeName}`).join('\n')}\n\nBe more specific.` } - return `No Ralph loop found for worktree "${args.name}".` + return `No loop found for worktree "${args.name}".` } if (!state.active) { @@ -1236,7 +1246,7 @@ Do NOT output text without also making this tool call. const durationStr = minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s` const statusLines: string[] = [ - 'Ralph Loop Status (Inactive)', + 'Loop Status (Inactive)', '', `Name: ${state.worktreeName}`, `Session: ${state.sessionId}`, @@ -1303,7 +1313,7 @@ Do NOT output text without also making this tool call. const stallCount = stallInfo?.consecutiveStalls ?? 0 const statusLines: string[] = [ - 'Ralph Loop Status', + 'Loop Status', '', `Name: ${state.worktreeName}`, `Session: ${state.sessionId}`, @@ -1379,7 +1389,7 @@ Do NOT output text without also making this tool call. if (!(input.tool in LOOP_BLOCKED_TOOLS)) return - logger.log(`Ralph: blocking ${input.tool} tool before execution in ${state.phase} phase for session ${input.sessionID}`) + logger.log(`Loop: blocking ${input.tool} tool before execution in ${state.phase} phase for session ${input.sessionID}`) throw new Error(LOOP_BLOCKED_TOOLS[input.tool]!) }, @@ -1411,7 +1421,7 @@ Do NOT output text without also making this tool call. if (!(input.tool in LOOP_BLOCKED_TOOLS)) return - logger.log(`Ralph: blocked ${input.tool} tool in ${state.phase} phase for session ${input.sessionID}`) + logger.log(`Loop: blocked ${input.tool} tool in ${state.phase} phase for session ${input.sessionID}`) output.title = 'Tool blocked' output.output = LOOP_BLOCKED_TOOLS[input.tool]! @@ -1423,7 +1433,7 @@ Do NOT output text without also making this tool call. if (!state?.active) return if (req.patterns.some((p) => p.startsWith('git push'))) { - logger.log(`Ralph: denied git push for session ${req.sessionID}`) + logger.log(`Loop: denied git push for session ${req.sessionID}`) output.status = 'deny' return } diff --git a/packages/memory/src/types.ts b/packages/memory/src/types.ts index 83870768..4fbbc035 100644 --- a/packages/memory/src/types.ts +++ b/packages/memory/src/types.ts @@ -80,6 +80,7 @@ export interface PluginConfig { executionModel?: string auditorModel?: string loop?: LoopConfig + /** @deprecated Use `loop` instead */ ralph?: LoopConfig defaultKvTtlMs?: number } diff --git a/packages/memory/src/version.ts b/packages/memory/src/version.ts index 17f6208e..7cb5d48b 100644 --- a/packages/memory/src/version.ts +++ b/packages/memory/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.0.26' +export const VERSION = '0.0.27'