UNPKG

@parvez3019/gemini-review-code

Version:
59 lines 3.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getLineObj = exports.getDiffBlocks = exports.delay = exports.geminiCompletionsConfig = exports.geminiSuggestContent = exports.geminiSystemContent = void 0; exports.geminiSystemContent = "You are a senior software engineer and an expert code reviewer. " + "You provide detailed, constructive, and actionable feedback to help developers write clean, " + "efficient, secure, and maintainable code. You strictly follow industry best practices, " + "language-specific style guides, and architecture principles. You point out bugs, " + "performance issues, code smells, security concerns, and violations of clean code and SOLID principles. " + "You offer specific suggestions for improvement and rewrite snippets when needed. " + "Your tone is respectful, collaborative, and helpful—focused on mentoring and guiding. " + "Keep you suggestions short and concise with code examples if required."; exports.geminiSuggestContent = "Next, I will send you each step of the merge request in standard git diff format, your task is:\n" + " - Review the code changes (diffs) in the patch and provide feedback.\n" + " - Examine it carefully to see if it really has code quality issues, bugs or needs room for optimization, highlight them. \n" + " - Use bullet points if you have multiple comments.\n" + " - You don't have to explain what the code does\n" + " - Follow the system prompt carefully\n" + " - Keep you suggestions short and concise with code examples if required\n" + " Here are the changes that were committed this time"; exports.geminiCompletionsConfig = { temperature: 1, topP: 0.95, topK: 64, maxOutputTokens: 8192, responseMimeType: "text/plain", model: "gemini-1.5-flash", }; const delay = (time) => { return new Promise(resolve => setTimeout(resolve, time)); }; exports.delay = delay; const getDiffBlocks = (diff) => { const regex = /(?=@@\s-\d+(?:,\d+)?\s\+\d+(?:,\d+)?\s@@)/g; const diffBlocks = diff.split(regex); return diffBlocks; }; exports.getDiffBlocks = getDiffBlocks; const getLineObj = (matches, item) => { var _a, _b, _c; const lineObj = {}; const lastLine = (_c = (_b = (_a = item.split(/\r?\n/)) === null || _a === void 0 ? void 0 : _a.reverse()) === null || _b === void 0 ? void 0 : _b[1]) === null || _c === void 0 ? void 0 : _c.trim(); const oldLineStart = +matches[1]; const oldLineEnd = +matches[2] || 0; const newLineStart = +matches[3]; const newLineEnd = +matches[4] || 0; if ((lastLine === null || lastLine === void 0 ? void 0 : lastLine[0]) === '+') { lineObj.new_line = newLineStart + newLineEnd - 1; } else if ((lastLine === null || lastLine === void 0 ? void 0 : lastLine[0]) === '-') { lineObj.old_line = oldLineStart + oldLineEnd - 1; } else { lineObj.new_line = newLineStart + newLineEnd - 1; lineObj.old_line = oldLineStart + oldLineEnd - 1; } return lineObj; }; exports.getLineObj = getLineObj; //# sourceMappingURL=utils.js.map