You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(prompts): null-safe, trim-aware user context handling
The previous userInputCodeContext only skipped the context block
when context was exactly '' or ' '. Anything else (e.g. a string of
whitespace, null, undefined) would inject an empty or
whitespace-only <context>…</context> tag into the system prompt.
Trim the input and guard against null/undefined:
- accept string | undefined | null
- normalize via `(context ?? '').trim()`
- skip the injection whenever the trimmed value is empty
Also inline the INIT_MAIN_PROMPT IIFE into a normal function body
and introduce a `content` local, removing a layer of nesting that
obscured the prompt assembly. Behavior is unchanged.
* $ oco -- This is a context used to generate the commit message
124
124
* @returns - The context of the user input
125
125
*/
126
-
constuserInputCodeContext=(context: string)=>{
127
-
if(context!==''&&context!==' '){
128
-
return`Additional context provided by the user: <context>${context}</context>\nConsider this context when generating the commit message, incorporating relevant information when appropriate.`;
return`Additional context provided by the user: <context>${trimmed}</context>\nConsider this context when generating the commit message, incorporating relevant information when appropriate.`;
constmissionStatement=`${IDENTITY} Your mission is to create clean and comprehensive commit messages as per the ${commitConvention} and explain WHAT were the changes and mainly WHY the changes were done.`;
144
-
constdiffInstruction=
145
-
"I'll send you an output of 'git diff --staged' command, and you are to convert it into a commit message.";
constmissionStatement=`${IDENTITY} Your mission is to create clean and comprehensive commit messages as per the ${commitConvention} and explain WHAT were the changes and mainly WHY the changes were done.`;
143
+
constdiffInstruction=
144
+
"I'll send you an output of 'git diff --staged' command, and you are to convert it into a commit message.";
0 commit comments