fix: Ralph wizard uses file-based prompt to avoid screen escaping issues

- Add /api/sessions/:id/ralph-prompt/write endpoint to write prompt to @ralph_prompt.md
- Wizard now writes full prompt to file, then sends simple read command to Claude
- Fix session readiness check to wait for prompt character instead of notWorking flag
- Add E2E test infrastructure for ralph-loop workflow (port 3190)
- Add ralph-wizard-prod.mjs script for production testing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-27 17:46:43 +01:00
co-authored by Claude Opus 4.5
parent c4e5337480
commit 2e4d89496f
27 changed files with 3960 additions and 32 deletions
+36
View File
@@ -1198,6 +1198,42 @@ export class WebServer extends EventEmitter {
}
});
// Write Ralph prompt to file in session's working directory
// This avoids screen input escaping issues with long multi-line prompts
this.app.post('/api/sessions/:id/ralph-prompt/write', async (req) => {
const { id } = req.params as { id: string };
const { content } = req.body as { content: string };
const session = this.sessions.get(id);
if (!session) {
return createErrorResponse(ApiErrorCode.NOT_FOUND, 'Session not found');
}
const workingDir = session.workingDir;
if (!workingDir) {
return createErrorResponse(ApiErrorCode.INVALID_INPUT, 'Session has no working directory');
}
if (!content || typeof content !== 'string') {
return createErrorResponse(ApiErrorCode.INVALID_INPUT, 'Content is required');
}
const filePath = path.join(workingDir, '@ralph_prompt.md');
try {
await fs.writeFile(filePath, content, 'utf-8');
return {
success: true,
data: {
filePath,
contentLength: content.length,
}
};
} catch (error) {
return createErrorResponse(ApiErrorCode.OPERATION_FAILED, `Failed to write file: ${error}`);
}
});
// Run prompt in session
this.app.post('/api/sessions/:id/run', async (req): Promise<ApiResponse> => {
const { id } = req.params as { id: string };