From e71145e7a8ec95b7eab4c38c53da111c91a3ee58 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sat, 24 May 2025 14:21:48 +0200 Subject: [PATCH] auto-git: [change] main.js --- main.js | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/main.js b/main.js index bc3b32e..268f0cb 100644 --- a/main.js +++ b/main.js @@ -254,42 +254,6 @@ async function streamLLMCommitMessages(prompt, onDataChunk) { return fullOutput.trim(); } -// 4. JSON Output robust parsen -function parseLLMCommitMessages(rawOutput) { - let cleaned = rawOutput.trim(); - cleaned = cleaned.replace(/^```(?:json)?|```$/gmi, ''); - - try { - if (cleaned.trim().startsWith('[')) return JSON.parse(cleaned); - if (cleaned.trim().startsWith('{')) { - const obj = JSON.parse(cleaned); - return Object.entries(obj).map(([commit, newMessage]) => ({ commit, newMessage })); - } - // Zeilenweise Objekte (fuzzy) - if (cleaned.includes('\n')) { - let lines = cleaned.split('\n').map(l => l.trim()).filter(Boolean); - let objs = []; - for (let line of lines) { - try { let o = JSON.parse(line); objs.push(o); } catch {} - } - if (objs.length) return objs; - } - } catch (err) { - // Fallback repair - try { - cleaned = cleaned.replace(/}\s*{/g, '},\n{'); - if (!cleaned.startsWith('[')) cleaned = '[' + cleaned; - if (!cleaned.endsWith(']')) cleaned = cleaned + ']'; - return JSON.parse(cleaned); - } catch (e) { - throw new Error('Could not parse LLM output:\n' + rawOutput); - } - } - throw new Error('Could not parse LLM output:\n' + rawOutput); -} - - - async function squashCommitMessages(repoPath, commitMessage, hashes) { const git = simpleGit(repoPath);