aicommit2 2.1.0 → 2.1.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/dist/cli.mjs +2 -3
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -33,7 +33,7 @@ ${i.footer}`:""}`}));return s.length>o?s.slice(0,o):s}catch{const s=/\[[\s\S]*?\
|
|
|
33
33
|
|
|
34
34
|
${m.body}`:""}${m.footer?`
|
|
35
35
|
|
|
36
|
-
${m.footer}`:""}`}));return l.length>o?l.slice(0,o):l}catch{return[]}}}extractMessageAsType(e,r){switch(r){case"conventional":const o=/(\w+)(?:\(.*?\))?:\s*(.*)/,n=e.subject.match(o),s=n?n[0]:e.subject;return{...e,subject:this.normalizeCommitMessage(s)};case"gitmoji":const i=/:\w*:\s*(.*)/,u=e.subject.match(i);return{...e,subject:u?u[0].toLowerCase():e.subject};default:return e}}normalizeCommitMessage(e){const r=/^(\w+)(\(.*?\))?:\s(.*)$/,o=e.match(r);if(o){const[,n,s,i]=o,u=n.toLowerCase(),a=i.charAt(0).toLowerCase()+i.slice(1);e=`${u}${s||""}: ${a}`}return e}sanitizeResponse(e){if(typeof e=="string")try{return[{title:`${Qr(e)}...`,value:e}]}catch{return[]}return e.map(r=>{try{return{title:`${Qr(r)}...`,value:r}}catch{return{title:"",value:""}}})}}var Zr="2.1.
|
|
36
|
+
${m.footer}`:""}`}));return l.length>o?l.slice(0,o):l}catch{return[]}}}extractMessageAsType(e,r){switch(r){case"conventional":const o=/(\w+)(?:\(.*?\))?:\s*(.*)/,n=e.subject.match(o),s=n?n[0]:e.subject;return{...e,subject:this.normalizeCommitMessage(s)};case"gitmoji":const i=/:\w*:\s*(.*)/,u=e.subject.match(i);return{...e,subject:u?u[0].toLowerCase():e.subject};default:return e}}normalizeCommitMessage(e){const r=/^(\w+)(\(.*?\))?:\s(.*)$/,o=e.match(r);if(o){const[,n,s,i]=o,u=n.toLowerCase(),a=i.charAt(0).toLowerCase()+i.slice(1);e=`${u}${s||""}: ${a}`}return e}sanitizeResponse(e){if(typeof e=="string")try{return[{title:`${Qr(e)}...`,value:e}]}catch{return[]}return e.map(r=>{try{return{title:`${Qr(r)}...`,value:r}}catch{return{title:"",value:""}}})}}var Zr="2.1.1",Ku="A Reactive CLI that generates git commit messages with various AI";class y extends Error{}const $t=" ",pe=t=>{t instanceof Error&&(t instanceof y||(t.stack&&console.error(C.dim(t.stack.split(`
|
|
37
37
|
`).slice(1).join(`
|
|
38
38
|
`))),console.error(`
|
|
39
39
|
${$t}${C.dim(`aicommit2 v${Zr}`)}`),console.error(`
|
|
@@ -125,8 +125,7 @@ import(${JSON.stringify(Cn(qe))})
|
|
|
125
125
|
`),m?(l&&(c+=`# Select one of the following messages by uncommenting:
|
|
126
126
|
`),c+=`
|
|
127
127
|
${u.map(f=>`# ${f}`).join(`
|
|
128
|
-
`)}`):(l&&(c
|
|
129
|
-
`),c+=`
|
|
128
|
+
`)}`):(l&&(c+="# Edit the message below and commit:"),c+=`
|
|
130
129
|
${u[0]}
|
|
131
130
|
`);const D=await I.readFile(We,"utf8"),d=c+`
|
|
132
131
|
`+D;await I.writeFile(We,d),e.printSavedCommitMessage()})().catch(t=>{new Fe().printErrorMessage(t.message),pe(t),process.exit(1)});const Ho=process.argv.slice(2);Gs({name:"aicommit2",version:Zr,flags:{locale:{type:String,description:"Locale to use for the generated commit messages (default: en)",alias:"l"},generate:{type:Number,description:"Number of messages to generate (Warning: generating multiple costs more) (default: 1)",alias:"g"},exclude:{type:[String],description:"Files to exclude from AI analysis",alias:"x"},all:{type:Boolean,description:"Automatically stage changes in tracked files for the commit",alias:"a",default:!1},type:{type:String,description:"Type of commit message to generate",alias:"t"},confirm:{type:Boolean,description:"Skip confirmation when committing after message generation (default: false)",alias:"y",default:!1},clipboard:{type:Boolean,description:"Copy the selected message to the clipboard",alias:"c",default:!1},prompt:{type:String,description:"Custom prompt to let users fine-tune provided prompt",alias:"p"}},commands:[za,Wa,Ka],help:{description:Ku},ignoreArgv:t=>t==="unknown-flag"||t==="argument"},t=>{if(qa){Ja();return}ja(t.flags.locale,t.flags.generate,t.flags.exclude,t.flags.all,t.flags.type,t.flags.confirm,t.flags.clipboard,t.flags.prompt,Ho)},Ho);
|