aicommit2 1.12.1 → 1.12.2

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.
Files changed (2) hide show
  1. package/dist/cli.mjs +6 -6
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -37,9 +37,9 @@ ${n.message}`:m,A=[b,t,e].filter(Boolean).join(`
37
37
  ${Object.entries({":sparkles:":"Introduce new features.",":bug:":"Fix a bug.",":memo:":"Add or update documentation.",":art:":"Improve structure / format of the code.",":zap:":"Improve performance.",":fire:":"Remove code or files.",":ambulance:":"Critical hotfix.",":white_check_mark:":"Add, update, or pass tests.",":lock:":"Fix security or privacy issues.",":rocket:":"Deploy stuff.",":lipstick:":"Add or update the UI and style files.",":tada:":"Begin a project.",":recycle:":"Refactor code.",":wrench:":"Add or update configuration files.",":bulb:":"Add or update comments in source code.",":twisted_rightwards_arrows:":"Merge branches."}).map(([e,t])=>` - ${e}: ${t}`).join(`
38
38
  `)}`,conventional:`
39
39
  ${Object.entries({docs:"Documentation only changes",style:"Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)",refactor:"A code change that neither fixes a bug nor adds a feature",perf:"A code change that improves performance",test:"Adding missing tests or correcting existing tests",build:"Changes that affect the build system or external dependencies",ci:"Changes to CI configuration files, scripts",chore:"Other changes that don't modify src or test files",revert:"Reverts a previous commit",feat:"A new feature",fix:"A bug fix"}).map(([e,t])=>` - ${e}: ${t}`).join(`
40
- `)}`},Oi=(e,t)=>e.replace(/{(\w+)}/g,(r,n)=>t[n]?.toString()||W[n]?.toString()),Ur=e=>{const{type:t,maxLength:r,generate:n,locale:o}=e;return["You are an AI assistant specialized in generating high-quality git commit messages following the Conventional Commits specification.","Your task is to create commit messages based on the following guidelines",`1. Format: follow the ${t} Commits format:`,`${$i[t]}`,`2. Types: use one of the following types:${Bi[t]}`,"3. Scope: optional, can be anything specifying the place of the commit change (e.g., component name, file name, module name)","4. Description: ",' - Use imperative, present tense: "change" not "changed" nor "changes"'," - Don't capitalize the first letter"," - No period (.) at the end","5. Body: Optional"," - Use imperative, present tense"," - Wrap lines at 72 characters","6. Footer: Optional",' - Mention any breaking changes, starting with "BREAKING CHANGE:"',' - Reference any related issues or pull requests (e.g., "Fixes #123", "Closes #456")',"7. General Rules:"," - Be concise but descriptive",' - Focus on the "why" behind the change, not just the "what"'," - Separate subject from body with a blank line"," - Use the body to explain what and why vs. how",`Generate ${n} commit messages based on these guidelines.`].filter(Boolean).join(`
41
- `)},mt=(e,t)=>`Provide your response as a JSON array where each element is an object with "subject", "body", and "footer" keys.
42
- The "subject" should include the ${t==="conventional"?"type":"emoji"}, optional scope, and description . If there's no body or footer, use an empty string for those fields.
40
+ `)}`},Oi=(e,t)=>e.replace(/{(\w+)}/g,(r,n)=>t[n]?.toString()||W[n]?.toString()),Ur=e=>{const{type:t,maxLength:r,generate:n,locale:o}=e;return["You are an AI assistant specialized in generating high-quality git commit messages following the Conventional Commits specification.","Your task is to create commit messages based on the following guidelines",`1. Language: ${o}`,`2. Format: follow the ${t} Commits format:`,`${$i[t]}`,`3. Types: use one of the following types:${Bi[t]}`,"4. Scope: optional, can be anything specifying the place of the commit change (e.g., component name, file name, module name)","5. Description: ",' - Use imperative, present tense: "change" not "changed" nor "changes"'," - Don't capitalize the first letter"," - No period (.) at the end","6. Body: Optional"," - Use imperative, present tense"," - Wrap lines at 72 characters","7. Footer: Optional",' - Mention any breaking changes, starting with "BREAKING CHANGE:"',' - Reference any related issues or pull requests (e.g., "Fixes #123", "Closes #456")',"8. General Rules:"," - Be concise but descriptive",' - Focus on the "why" behind the change, not just the "what"'," - Separate subject from body with a blank line"," - Use the body to explain what and why vs. how",`Generate ${n} commit messages based on these guidelines.`].filter(Boolean).join(`
41
+ `)},mt=e=>`Provide your response as a JSON array where each element is an object with "subject", "body", and "footer" keys.
42
+ The "subject" should include the ${e==="conventional"?"type":"emoji"}, optional scope, and description . If there's no body or footer, use an empty string for those fields.
43
43
  Example response format:
44
44
  [
45
45
  {
@@ -48,9 +48,9 @@ Example response format:
48
48
  "footer": "string"
49
49
  },
50
50
  ]`,re=e=>{const{type:t,generate:r,promptPath:n}=e;if(!n)return`${Ur(e)}
51
- ${mt(r,t)}`;try{const o=k.readFileSync(P.resolve(n),"utf-8");return`${Oi(o,e)}
51
+ ${mt(r)}`;try{const o=k.readFileSync(P.resolve(n),"utf-8");return`${Oi(o,e)}
52
52
  ${mt(r,t)}`}catch{return`${Ur(e)}
53
- ${mt(r,t)}`}},M={OPEN_AI:"OPENAI_KEY",GEMINI:"GEMINI_KEY",ANTHROPIC:"ANTHROPIC_KEY",HUGGINGFACE:"HUGGINGFACE_COOKIE",MISTRAL:"MISTRAL_KEY",CODESTRAL:"CODESTRAL_KEY",OLLAMA:"OLLAMA_MODEL",COHERE:"COHERE_KEY",GROQ:"GROQ_KEY"},Kr=Object.values(M).map(e=>e);class U{constructor(t){this.handleError$=r=>{let n="An error occurred";return r.message&&(n=r.message),x({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.serviceName="AI",this.errorPrefix="ERROR",this.colors={primary:""}}buildPrompt(t,r,n,o,s,u){const i={...W,locale:t,maxLength:o,type:s,generate:n,promptPath:u};return`${re(i)}}
53
+ ${mt(r)}`}},M={OPEN_AI:"OPENAI_KEY",GEMINI:"GEMINI_KEY",ANTHROPIC:"ANTHROPIC_KEY",HUGGINGFACE:"HUGGINGFACE_COOKIE",MISTRAL:"MISTRAL_KEY",CODESTRAL:"CODESTRAL_KEY",OLLAMA:"OLLAMA_MODEL",COHERE:"COHERE_KEY",GROQ:"GROQ_KEY"},Kr=Object.values(M).map(e=>e);class U{constructor(t){this.handleError$=r=>{let n="An error occurred";return r.message&&(n=r.message),x({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.serviceName="AI",this.errorPrefix="ERROR",this.colors={primary:""}}buildPrompt(t,r,n,o,s,u){const i={...W,locale:t,maxLength:o,type:s,generate:n,promptPath:u};return`${re(i)}}
54
54
  Here are diff:
55
55
  ${r}`}sanitizeMessage(t,r,n,o){try{const u=JSON.parse(t).map(i=>this.extractMessageAsType(i,r)).map(i=>o?{title:`${i.subject}`,value:`${i.subject}`}:{title:`${i.subject}`,value:`${i.subject}${i.body?`
56
56
 
@@ -60,7 +60,7 @@ ${i.footer}`:""}`});return u.length>n?u.slice(0,n):u}catch{const u=/\[[\s\S]*?\]
60
60
 
61
61
  ${a.body}`:""}${a.footer?`
62
62
 
63
- ${a.footer}`:""}`});return f.length>n?f.slice(0,n):f}catch{return[]}}}extractMessageAsType(t,r){switch(r){case"conventional":const n=/(\w+)(?:\(.*?\))?:\s*(.*)/,o=t.subject.match(n),s=o?o[0]:t.subject;return{...t,subject:this.normalizeCommitMessage(s)};case"gitmoji":const u=/:\w*:\s*(.*)/,i=t.subject.match(u);return{...t,subject:i?i[0].toLowerCase():t.subject};default:return t}}normalizeCommitMessage(t){const r=/^(\w+)(\(.*?\))?:\s(.*)$/,n=t.match(r);if(n){const[,o,s,u]=n,i=o.toLowerCase(),c=u.charAt(0).toLowerCase()+u.slice(1);t=`${i}${s||""}: ${c}`}return t}}var qr="1.12.1",xi="A Reactive CLI that generates git commit messages with various AI";class F extends Error{}const ht=" ",fe=e=>{e instanceof Error&&(e instanceof F||(e.stack&&console.error(g.dim(e.stack.split(`
63
+ ${a.footer}`:""}`});return f.length>n?f.slice(0,n):f}catch{return[]}}}extractMessageAsType(t,r){switch(r){case"conventional":const n=/(\w+)(?:\(.*?\))?:\s*(.*)/,o=t.subject.match(n),s=o?o[0]:t.subject;return{...t,subject:this.normalizeCommitMessage(s)};case"gitmoji":const u=/:\w*:\s*(.*)/,i=t.subject.match(u);return{...t,subject:i?i[0].toLowerCase():t.subject};default:return t}}normalizeCommitMessage(t){const r=/^(\w+)(\(.*?\))?:\s(.*)$/,n=t.match(r);if(n){const[,o,s,u]=n,i=o.toLowerCase(),c=u.charAt(0).toLowerCase()+u.slice(1);t=`${i}${s||""}: ${c}`}return t}}var qr="1.12.2",xi="A Reactive CLI that generates git commit messages with various AI";class F extends Error{}const ht=" ",fe=e=>{e instanceof Error&&(e instanceof F||(e.stack&&console.error(g.dim(e.stack.split(`
64
64
  `).slice(1).join(`
65
65
  `))),console.error(`
66
66
  ${ht}${g.dim(`aicommit2 v${qr}`)}`),console.error(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicommit2",
3
- "version": "1.12.1",
3
+ "version": "1.12.2",
4
4
  "description": "A Reactive CLI that generates git commit messages with various AI",
5
5
  "keywords": [
6
6
  "cli",