git-auto-ai-himamshu 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/ai.js +12 -1
package/package.json
CHANGED
package/src/ai.js
CHANGED
|
@@ -17,13 +17,24 @@ async function generateCommitMessage(diff) {
|
|
|
17
17
|
throw new Error('GROQ_API_KEY is missing from .env file.');
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
// TRUNCATION LOGIC:
|
|
21
|
+
// Prevent "Request too large" errors by limiting the diff size.
|
|
22
|
+
// 10,000 characters is usually enough to understand the changes
|
|
23
|
+
// while staying safely under free-tier token limits.
|
|
24
|
+
const MAX_DIFF_LENGTH = 10000;
|
|
25
|
+
let processedDiff = diff;
|
|
26
|
+
if (diff.length > MAX_DIFF_LENGTH) {
|
|
27
|
+
processedDiff = diff.substring(0, MAX_DIFF_LENGTH) +
|
|
28
|
+
'\n\n... (diff truncated due to size)';
|
|
29
|
+
}
|
|
30
|
+
|
|
20
31
|
const prompt = `
|
|
21
32
|
Analyze the following git diff and write a professional, concise commit message.
|
|
22
33
|
Follow the Conventional Commits specification (e.g., feat: ..., fix: ..., chore: ..., docs: ..., style: ..., refactor: ..., perf: ..., test: ...).
|
|
23
34
|
Only return the commit message string itself, without any quotes or explanation.
|
|
24
35
|
|
|
25
36
|
Diff:
|
|
26
|
-
${
|
|
37
|
+
${processedDiff}
|
|
27
38
|
`.trim();
|
|
28
39
|
|
|
29
40
|
try {
|