From c2c7e11e00dfe29a29c820d6a724f704c226cdb0 Mon Sep 17 00:00:00 2001 From: sebseb7 Date: Mon, 4 Aug 2025 10:41:37 +0200 Subject: [PATCH] feat(api): include unified diff in DE summary prompt and extend timeout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add getLastCommitDiff to fetch the latest commit’s unified diff and append it to the system prompt for German summaries. Increase LLM call timeout to handle larger prompts. --- x.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/x.js b/x.js index 125bda1..f779bca 100644 --- a/x.js +++ b/x.js @@ -40,6 +40,19 @@ async function getLastCommits({ count = 10, repoDir = process.cwd() } = {}) { } } +// Get unified diff for the latest commit (against its parent) +async function getLastCommitDiff({ repoDir = process.cwd(), contextLines = 3 } = {}) { + try { + // --pretty=format: to avoid commit message in diff header; use -1 for last commit + const cmd = `git show -1 --unified=${contextLines} --no-color`; + const { stdout } = await execCmd(cmd, { cwd: repoDir, timeoutMs: 8000 }); + return stdout || ''; + } catch (e) { + logMessage(`getLastCommitDiff failed: ${e.message}`, 'warn'); + return ''; + } +} + function buildMostRecentCommitPromptGerman(commits) { if (!commits || commits.length === 0) return null; const c0 = commits[0]; @@ -122,14 +135,21 @@ async function summarizeMostRecentCommitDE() { const prompt = buildMostRecentCommitPromptGerman(commits); if (!prompt) return null; + // Also include the unified diff of the latest commit in the system prompt + const diff = await getLastCommitDiff({ repoDir: process.cwd(), contextLines: 3 }); + const systemWithDiff = + `${prompt.system}\n\n` + + `Kontext (unified diff der neuesten Änderung):\n` + + `${diff ? diff.slice(0, 120000) : '(kein Diff verfügbar)'}`; + try { const summary = await callLLMOpenAICompatible({ baseUrl, apiKey, model, - system: prompt.system, + system: systemWithDiff, user: prompt.user, - timeoutMs: 15000 + timeoutMs: 20000 }); if (!summary) return null; return summary;