From 7425ccaa1f826a7f817705dad197653e71878d85 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Mon, 8 Jul 2024 23:22:50 -0700 Subject: [PATCH] tweaks --- backend/scripts/manicode.ts | 48 +++++++++++++------------------------ 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/backend/scripts/manicode.ts b/backend/scripts/manicode.ts index 6b2027301c..cc7fe0fb9c 100644 --- a/backend/scripts/manicode.ts +++ b/backend/scripts/manicode.ts @@ -59,8 +59,8 @@ The user has a coding question for you. Please provide a detailed response follo 2. Implementation Strategy: Outline your approach to implement the requested changes. -3. File Modifications: List all files that need to be modified or created. For each file, provide the following details: - +3. File Modifications: List all files that need to be modified or created, and they will be changed according to your instruction. + For each file, provide the following details: a) File path b) Whether it's a new file or an existing file to be modified c) Specific changes to be made, using the format below: @@ -217,25 +217,20 @@ Based on the conversation above, which files do you need to read to answer the u const finalPrompt = `${fullPrompt}\n\nRelevant file contents:\n\n${fileContents}` - try { - const claudeResponse = await promptClaudeAndApplyFileChanges( - finalPrompt, - { - system, - } - ) + const claudeResponse = await promptClaudeAndApplyFileChanges( + finalPrompt, + { + system, + } + ) - conversationHistory.push({ - role: 'assistant', - content: claudeResponse, - }) + conversationHistory.push({ + role: 'assistant', + content: claudeResponse, + }) - // Continue the loop - } catch (error) { - console.error('Error:', error) - } finally { - promptUser() - } + // Continue the loop + promptUser() } ) } @@ -310,8 +305,6 @@ ${fullResponse}` } } - console.log(currentFileBlock.replace('[END_OF_RESPONSE]', '')) - return fullResponse } @@ -322,18 +315,13 @@ async function processFileBlock(filePath: string, fileContent: string) { : '' if (fileContent.includes('')) { - const replaceRegex = - /([\s\S]*?)<\/old>\s*([\s\S]*?)<\/new>/g + const replaceRegex = /([\s\S]*?)<\/old>\s*([\s\S]*?)<\/new>/g let replaceMatch let updatedContent = currentContent while ((replaceMatch = replaceRegex.exec(fileContent)) !== null) { const [, oldContent, newContent] = replaceMatch - const replaced = applyReplacement( - updatedContent, - oldContent, - newContent - ) + const replaced = applyReplacement(updatedContent, oldContent, newContent) if (replaced) { updatedContent = replaced @@ -567,9 +555,7 @@ If you can't find a suitable expansion, please respond with "No expansion possib system: getSystemPrompt(), }) - const expandedOldMatch = expandedResponse.match( - /([\s\S]*?)<\/old>/ - ) + const expandedOldMatch = expandedResponse.match(/([\s\S]*?)<\/old>/) const expandedNewMatch = expandedResponse.match(/([\s\S]*?)<\/new>/) if (expandedOldMatch && expandedNewMatch) {