Spaces:
Build error
Build error
Fix: Truncated file app/api/analyze-edit-intent/route.ts (re-upload)
#7
by
harvesthealth
- opened
app/api/analyze-edit-intent/route.ts
CHANGED
|
@@ -80,4 +80,56 @@ export async function POST(request: NextRequest) {
|
|
| 80 |
DO NOT GUESS which files to edit. Instead, provide specific search terms that will locate the code.
|
| 81 |
|
| 82 |
SEARCH STRATEGY RULES:
|
| 83 |
-
1. For text changes (e.g.,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
DO NOT GUESS which files to edit. Instead, provide specific search terms that will locate the code.
|
| 81 |
|
| 82 |
SEARCH STRATEGY RULES:
|
| 83 |
+
1. For text changes (e.g., "change 'Start Deploying' to 'Go Now'"):
|
| 84 |
+
- Search for the EXACT text: "Start Deploying"
|
| 85 |
+
|
| 86 |
+
2. For style changes (e.g., "make header black"):
|
| 87 |
+
- Search for component names: "Header", "<header"
|
| 88 |
+
- Search for class names: "header", "navbar"
|
| 89 |
+
- Search for className attributes containing relevant words
|
| 90 |
+
|
| 91 |
+
3. For removing elements (e.g., "remove the deploy button"):
|
| 92 |
+
- Search for the button text or aria-label
|
| 93 |
+
- Search for relevant IDs or data-testids
|
| 94 |
+
|
| 95 |
+
4. For navigation/header issues:
|
| 96 |
+
- Search for: "navigation", "nav", "Header", "navbar"
|
| 97 |
+
- Look for Link components or href attributes
|
| 98 |
+
|
| 99 |
+
5. Be SPECIFIC:
|
| 100 |
+
- Use exact capitalization for user-visible text
|
| 101 |
+
- Include multiple search terms for redundancy
|
| 102 |
+
- Add regex patterns for structural searches
|
| 103 |
+
|
| 104 |
+
Current project structure for context:
|
| 105 |
+
${fileSummary}`
|
| 106 |
+
},
|
| 107 |
+
{
|
| 108 |
+
role: 'user',
|
| 109 |
+
content: `User request: "${prompt}"
|
| 110 |
+
|
| 111 |
+
Create a search plan to find the exact code that needs to be modified. Include specific search terms and patterns.`
|
| 112 |
+
}
|
| 113 |
+
]
|
| 114 |
+
});
|
| 115 |
+
|
| 116 |
+
console.log('[analyze-edit-intent] Search plan created:', {
|
| 117 |
+
editType: result.object.editType,
|
| 118 |
+
searchTerms: result.object.searchTerms,
|
| 119 |
+
patterns: result.object.regexPatterns?.length || 0,
|
| 120 |
+
reasoning: result.object.reasoning
|
| 121 |
+
});
|
| 122 |
+
|
| 123 |
+
return NextResponse.json({
|
| 124 |
+
success: true,
|
| 125 |
+
searchPlan: result.object
|
| 126 |
+
});
|
| 127 |
+
|
| 128 |
+
} catch (error) {
|
| 129 |
+
console.error('[analyze-edit-intent] Error:', error);
|
| 130 |
+
return NextResponse.json({
|
| 131 |
+
success: false,
|
| 132 |
+
error: (error as Error).message
|
| 133 |
+
}, { status: 500 });
|
| 134 |
+
}
|
| 135 |
+
}
|