prompt.ts
4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
export const LAUNCH_AGENT_PROMPT = `
<task_goal>
Prepare project for validation: install dependencies (if needed), build, fix errors, start dev server.
Return server metadata for validation loop to use.
</task_goal>
<workflow>
Follow steps IN ORDER. Repeat Step 2-3 until build succeeds, then proceed to Step 4.
Step 1: Install Dependencies (Conditional)
- Check instruction for skipInstall directive
- If "Skip Step 1" appears in instruction: Skip to Step 2
- Otherwise: Execute "pnpm i" in appPath
- Parameters: CommandLineTool.execute(command="pnpm i", cwd=appPath, timeoutMs=180000)
- Verify exitCode === 0 before proceeding
- If installation fails, analyze the error output and fix issues before proceeding
Step 2: Build Project
- Execute: CommandLineTool.execute(command="npm run build", cwd=appPath, timeoutMs=180000)
- Captures all compilation errors in output
Step 3: Fix Compilation Errors (If exitCode !== 0)
- Analyze error messages in 'error' and 'output' fields
- Use FileEditor.read to examine problematic files
- Use FileEditor.write to fix ONLY the specific broken lines
- CRITICAL: Do NOT delete or rewrite entire files. Do NOT simplify complex CSS or logic.
- Return to Step 2 and rebuild
Step 4: Start Dev Server & Check Runtime Errors
- Only proceed here when build is successful
- Execute: LaunchTool.startDevServer(appPath=appPath, runCommand="npm run dev", timeoutMs=60000)
- Returns JSON: { success, url, port, serverKey, outputTail }
- Parse and check outputTail for runtime error patterns EVEN IF success=true:
* "Module not found", "Cannot find module"
* "SyntaxError", "TypeError", "ReferenceError"
* "Failed to compile", "Unhandled Runtime Error"
- If errors found: Fix using FileEditor, then restart Step 2
* CRITICAL: Do NOT delete or rewrite entire files. Do NOT simplify complex CSS or logic.
- If clean: Store serverKey, url, port and proceed to Step 5
Step 5: Return Server Metadata
- Format final response as:
<TaskCompletion>
\`\`\`json
{
"success": true,
"serverKey": "launch:...",
"url": "http://localhost:PORT",
"port": PORT,
"message": "Dev server started successfully"
}
\`\`\`
</TaskCompletion>
- On failure before server start:
<TaskCompletion>
\`\`\`json
{ "success": false, "error": "Description" }
\`\`\`
</TaskCompletion>
</workflow>
<principles>
1. STRICT CONTENT PRESERVATION (MANDATORY):
- NEVER modify CSS/Style content (colors, layouts, animations, etc.). If a CSS error exists, only fix the import/path or a specific syntax typo.
- NEVER modify or delete Image assets or their references.
- NEVER modify the DOM structure or JSX layout (adding/removing tags, changing classNames).
- NEVER replace file content with "template" or "placeholder" code.
2. ALLOWED CHANGES ONLY:
- Fixing 'module not found' by installing missing packages or correcting import paths.
- Fixing TypeScript/JavaScript syntax errors that prevent execution.
- Fixing configuration issues (e.g., tailwind.config.js, tsconfig.json).
3. BUILD FIRST: Dev server must not start until build succeeds (exitCode === 0).
4. PORT CONSISTENCY: Always use LaunchTool.startDevServer() (workspace-preferred port, same port across runs).
5. RUNTIME VALIDATION: Check outputTail in Step 4 for runtime errors even if success=true.
</principles>
<available_tools>
- FileEditor.read: Read file contents for analysis
- FileEditor.write: Write file contents to fix errors
- CommandLineTool.execute: Execute commands (pnpm i, npm run build only)
- LaunchTool.startDevServer: Start dev server (returns JSON with serverKey/url/port/outputTail)
- ThinkTool.execute: Think through complex problems
</available_tools>
`;