diff --git a/package-lock.json b/package-lock.json index dbb1da5..4fcf413 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ai-commit", - "version": "0.0.5", + "version": "0.0.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ai-commit", - "version": "0.0.5", + "version": "0.0.8", "license": "MIT", "dependencies": { "fs-extra": "^11.0.4", diff --git a/src/generate-commit-msg.ts b/src/generate-commit-msg.ts index 02f16e9..390d321 100644 --- a/src/generate-commit-msg.ts +++ b/src/generate-commit-msg.ts @@ -13,8 +13,8 @@ import { ProgressHandler } from './utils'; * @param {string} diff - The diff string representing changes to be committed. * @returns {Promise>} - A promise that resolves to an array of messages for the chat completion. */ -const generateCommitMessageChatCompletionPrompt = async (diff: string) => { - const INIT_MESSAGES_PROMPT = await getMainCommitPrompt(); +const generateCommitMessageChatCompletionPrompt = async (diff: string, extras: string) => { + const INIT_MESSAGES_PROMPT = await getMainCommitPrompt(extras); const chatContextAsCompletionRequest = [...INIT_MESSAGES_PROMPT]; chatContextAsCompletionRequest.push({ @@ -85,7 +85,8 @@ export async function generateCommitMsg(arg) { } progress.report({ message: 'Analyzing changes...' }); - const messages = await generateCommitMessageChatCompletionPrompt(diff); + const extras = scmInputBox.value; + const messages = await generateCommitMessageChatCompletionPrompt(diff, extras); progress.report({ message: 'Generating commit message...' }); try { diff --git a/src/prompts.ts b/src/prompts.ts index e720f2a..7c0852a 100644 --- a/src/prompts.ts +++ b/src/prompts.ts @@ -6,7 +6,7 @@ import { ConfigKeys, ConfigurationManager } from './config'; * @param {string} language - The language to be used in the prompt. * @returns {Object} - The main prompt object containing role and content. */ -const INIT_MAIN_PROMPT = (language: string) => ({ +const INIT_MAIN_PROMPT = (language: string, extras: string) => ({ role: 'system', content: ConfigurationManager.getInstance().getConfig(ConfigKeys.SYSTEM_PROMPT) || @@ -100,7 +100,10 @@ OUTPUT: - rename port variable to uppercase (PORT) to follow constant naming convention - add environment variable port support for flexible deployment -Remember: All output MUST be in ${language} language. You are to act as a pure commit message generator. Your response should contain NOTHING but the commit message itself.` +Remember: All output MUST be in ${language} language. You are to act as a pure commit message generator. Your response should contain NOTHING but the commit message itself. + +${extras ? `Important additional instructions: ${extras}` : ''} +` }); /** @@ -108,9 +111,9 @@ Remember: All output MUST be in ${language} language. You are to act as a pure c * * @returns {Promise>} - A promise that resolves to an array of prompts. */ -export const getMainCommitPrompt = async () => { +export const getMainCommitPrompt = async (extras: string) => { const language = ConfigurationManager.getInstance().getConfig( ConfigKeys.AI_COMMIT_LANGUAGE ); - return [INIT_MAIN_PROMPT(language)]; + return [INIT_MAIN_PROMPT(language, extras)]; };