@@ -1,10 +1,7 @@
11 import * as c from "yoctocolors";
2-import {
3- buildRalphIterationPrompt,
4- hasRalphSignal,
5-} from "../agent/agent-helpers.ts";
62 import type { AgentReporter } from "../agent/reporter.ts";
73 import type { SessionRunner } from "../agent/session-runner.ts";
4+
85 import { getContextWindow } from "../llm-api/providers.ts";
96 import type { CoreMessage } from "../llm-api/turn.ts";
107 import { saveMessages } from "../session/db/index.ts";
@@ -12,7 +9,8 @@ import { getGitBranch, runShellPassthrough } from "./cli-helpers.ts";
129 import { handleCommand } from "./commands.ts";
1310 import { resolveFileRefs } from "./file-refs.ts";
1411 import { type InputResult, readline } from "./input.ts";
15-import { PREFIX, tildePath } from "./output.ts";
12+import { tildePath } from "./output.ts";
13+
1614 import type { CommandContext } from "./types.ts";
1715
1816 interface InputLoopOptions {
@@ -22,8 +20,6 @@ interface InputLoopOptions {
2220 runner: SessionRunner;
2321 }
2422
25-const RALPH_MAX_ITERATIONS = 20;
26-
2723 export async function runInputLoop(opts: InputLoopOptions): Promise<void> {
2824 const { cwd, reporter, cmdCtx, runner } = opts;
2925
@@ -43,7 +39,6 @@ export async function runInputLoop(opts: InputLoopOptions): Promise<void> {
4339 outputTokens: runner.totalOut,
4440 contextTokens: runner.lastContextTokens,
4541 contextWindow: getContextWindow(runner.currentModel) ?? 0,
46- ralphMode: runner.ralphMode,
4742 thinkingEffort: runner.currentThinkingEffort,
4843 activeAgent: cmdCtx.activeAgent,
4944 showReasoning: runner.showReasoning,
@@ -53,7 +48,6 @@ export async function runInputLoop(opts: InputLoopOptions): Promise<void> {
5348 try {
5449 input = await readline({
5550 cwd,
56- ralphMode: runner.ralphMode,
5751 });
5852 } catch {
5953 break;
@@ -107,63 +101,10 @@ export async function runInputLoop(opts: InputLoopOptions): Promise<void> {
107101 cwd,
108102 );
109103 const allImages = [...(input.images || []), ...refImages];
110-
111- if (!runner.ralphMode) {
112- try {
113- await runner.processUserInput(resolvedText, allImages);
114- } catch {
115- // Error already rendered by stream-render; continue the loop.
116- }
117- continue;
118- }
119-
120- // True ralph loop: each iteration is a fresh subprocess.
121- // State persists via the filesystem and git history — NOT the context window.
122- if (allImages.length > 0) {
123- reporter.writeText(
124- `${PREFIX.info} ${c.yellow("ralph")} ${c.dim("— image attachments are not supported and will be ignored")}`,
125- );
126- }
127- const ralphGoal = buildRalphIterationPrompt(resolvedText);
128-
129- for (
130- let iteration = 1;
131- iteration <= RALPH_MAX_ITERATIONS;
132- iteration++
133- ) {
134- reporter.writeText(
135- `${PREFIX.info} ${c.magenta("ralph")} ${c.dim(`— iteration ${String(iteration)}`)}`,
136- );
137-
138- let result: string;
139- try {
140- cmdCtx.startSpinner("ralph");
141- const output = await cmdCtx.runSubagent(ralphGoal);
142- result = output.result;
143- cmdCtx.stopSpinner();
144- } catch (err) {
145- cmdCtx.stopSpinner();
146- reporter.writeText(
147- `${PREFIX.info} ${c.yellow("ralph")} ${c.dim(`— iteration ${String(iteration)} failed: ${String(err)}`)}`,
148- );
149- runner.ralphMode = false;
150- break;
151- }
152-
153- if (hasRalphSignal(result)) {
154- reporter.writeText(
155- `${PREFIX.info} ${c.dim("ralph — task complete")}`,
156- );
157- runner.ralphMode = false;
158- break;
159- }
160-
161- if (iteration === RALPH_MAX_ITERATIONS) {
162- reporter.writeText(
163- `${PREFIX.info} ${c.yellow("ralph")} ${c.dim("— max iterations reached, stopping")}`,
164- );
165- runner.ralphMode = false;
166- }
104+ try {
105+ await runner.processUserInput(resolvedText, allImages);
106+ } catch {
107+ // Error already rendered by stream-render; continue the loop.
167108 }
168109 continue;
169110 }