Refactor: replace Ralph terminology with Loop

This commit is contained in:
Chris Scott committed 2026-03-27 15:31:59 -04:00
1 parent 2c4a9c9257
commit 5f7abe3fd8
7 files changed
+43 -32

No files matched your search

+1 -1
View File
@@ -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",
+1 -1
View File
@@ -138,7 +138,7 @@ export async function run(argv: StatusArgs): Promise<void> {
}
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:')
+2 -2
View File
@@ -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> Path to memory database
+15 -15
View File
@@ -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 <promise>${currentState.completionPromise}</promise> at iteration ${currentState.iteration} (${currentAuditCount}/${minAudits} audits)`)
logger.log(`Loop completed: detected <promise>${currentState.completionPromise}</promise> 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 <promise>${currentState.completionPromise}</promise> in audit at iteration ${currentState.iteration} (${newAuditCount}/${minAudits} audits)`)
logger.log(`Loop completed: detected <promise>${currentState.completionPromise}</promise> 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`)
+22 -12
View File
@@ -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
}
+1
View File
@@ -80,6 +80,7 @@ export interface PluginConfig {
executionModel?: string
auditorModel?: string
loop?: LoopConfig
/** @deprecated Use `loop` instead */
ralph?: LoopConfig
defaultKvTtlMs?: number
}
+1 -1
View File
@@ -1 +1 @@
export const VERSION = '0.0.26'
export const VERSION = '0.0.27'