aicommits 1.5.0 → 1.5.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.
Files changed (2) hide show
  1. package/dist/cli.mjs +4 -4
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -19,7 +19,7 @@ import cu from"tty";import{Buffer as Lt}from"node:buffer";import L from"node:pat
19
19
  `:"")+(t?this.indentText({text:this.render(t),spaces:n}):"")}
20
20
  `}table({tableData:u,tableOptions:t,tableBreakpoints:n}){return Jn(u.map(D=>D.map(r=>this.render(r))),n?Qn(n):t)}flagParameter(u){return u===Boolean?"":u===String?"<string>":u===Number?"<number>":Array.isArray(u)?this.flagParameter(u[0]):"<value>"}flagOperator(u){return" "}flagName(u){const{flag:t,flagFormatted:n,aliasesEnabled:D,aliasFormatted:r}=u;let i="";if(r?i+=`${r}, `:D&&(i+=" "),i+=n,"placeholder"in t&&typeof t.placeholder=="string")i+=`${this.flagOperator(u)}${t.placeholder}`;else{const o=this.flagParameter("type"in t?t.type:t);o&&(i+=`${this.flagOperator(u)}${o}`)}return i}flagDefault(u){return JSON.stringify(u)}flagDescription({flag:u}){let t="description"in u?u.description??"":"";if("default"in u){let{default:n}=u;typeof n=="function"&&(n=n()),n&&(t+=` (default: ${this.flagDefault(n)})`)}return t}render(u){if(typeof u=="string")return u;if(Array.isArray(u))return u.map(t=>this.render(t)).join(`
21
21
  `);if("type"in u&&this[u.type]){const t=this[u.type];if(typeof t=="function")return t.call(this,u.data)}throw new Error(`Invalid node type: ${JSON.stringify(u)}`)}}const Ae=/^[\w.-]+$/,{stringify:x}=JSON,pD=/[|\\{}()[\]^$+*?.]/;function ve(e){const u=[];let t,n;for(const D of e){if(n)throw new Error(`Invalid parameter: Spread parameter ${x(n)} must be last`);const r=D[0],i=D[D.length-1];let o;if(r==="<"&&i===">"&&(o=!0,t))throw new Error(`Invalid parameter: Required parameter ${x(D)} cannot come after optional parameter ${x(t)}`);if(r==="["&&i==="]"&&(o=!1,t=D),o===void 0)throw new Error(`Invalid parameter: ${x(D)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let s=D.slice(1,-1);const a=s.slice(-3)==="...";a&&(n=D,s=s.slice(0,-3));const l=s.match(pD);if(l)throw new Error(`Invalid parameter: ${x(D)}. Invalid character found ${x(l[0])}`);u.push({name:s,required:o,spread:a})}return u}function xe(e,u,t,n){for(let D=0;D<u.length;D+=1){const{name:r,required:i,spread:o}=u[D],s=eD(r);if(s in e)throw new Error(`Invalid parameter: ${x(r)} is used more than once.`);const a=o?t.slice(D):t[D];if(o&&(D=u.length),i&&(!a||o&&a.length===0))return console.error(`Error: Missing required parameter ${x(r)}
22
- `),n(),process.exit(1);e[s]=a}}function FD(e){return e===void 0||e!==!1}function Ru(e,u,t,n){const D={...u.flags},r=u.version;r&&(D.version={type:Boolean,description:"Show version"});const{help:i}=u,o=FD(i);o&&!("help"in D)&&(D.help={type:Boolean,alias:"h",description:"Show help"});const s=Cn(D,n,{ignore:u.ignoreArgv}),a=()=>{console.log(u.version)};if(r&&s.flags.version===!0)return a(),process.exit(0);const l=new dD,c=o&&i?.render?i.render:F=>l.render(F),f=F=>{const E=lD({...u,...F?{help:F}:{},flags:D});console.log(c(E,l))};if(o&&s.flags.help===!0)return f(),process.exit(0);if(u.parameters){let{parameters:F}=u,E=s._;const b=F.indexOf("--"),P=F.slice(b+1),S=Object.create(null);if(b>-1&&P.length>0){F=F.slice(0,b);const Q=s._["--"];E=E.slice(0,-Q.length||void 0),xe(S,ve(F),E,f),xe(S,ve(P),Q,f)}else xe(S,ve(F),E,f);Object.assign(s._,S)}const d={...s,showVersion:a,showHelp:f};return typeof t=="function"&&t(d),{command:e,...d}}function mD(e,u){const t=new Map;for(const n of u){const D=[n.options.name],{alias:r}=n.options;r&&(Array.isArray(r)?D.push(...r):D.push(r));for(const i of D){if(t.has(i))throw new Error(`Duplicate command name found: ${x(i)}`);t.set(i,n)}}return t.get(e)}function CD(e,u,t=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!Ae.test(e.name)))throw new Error(`Invalid script name: ${x(e.name)}`);const n=t[0];if(e.commands&&Ae.test(n)){const D=mD(n,e.commands);if(D)return Ru(D.options.name,{...D.options,parent:e},D.callback,t.slice(1))}return Ru(void 0,e,u,t)}function _u(e,u){if(!e)throw new Error("Command options are required");const{name:t}=e;if(e.name===void 0)throw new Error("Command name is required");if(!Ae.test(t))throw new Error(`Invalid command name ${JSON.stringify(t)}. Command names must be one word.`);return{options:e,callback:u}}var ju="1.5.0",hD="Writes your git commit messages for you with AI",I=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},R={},ED={get exports(){return R},set exports(e){R=e}},Se,Nu;function gD(){if(Nu)return Se;Nu=1,Se=n,n.sync=D;var e=Ee;function u(r,i){var o=i.pathExt!==void 0?i.pathExt:process.env.PATHEXT;if(!o||(o=o.split(";"),o.indexOf("")!==-1))return!0;for(var s=0;s<o.length;s++){var a=o[s].toLowerCase();if(a&&r.substr(-a.length).toLowerCase()===a)return!0}return!1}function t(r,i,o){return!r.isSymbolicLink()&&!r.isFile()?!1:u(i,o)}function n(r,i,o){e.stat(r,function(s,a){o(s,s?!1:t(a,r,i))})}function D(r,i){return t(e.statSync(r),r,i)}return Se}var Oe,Lu;function BD(){if(Lu)return Oe;Lu=1,Oe=u,u.sync=t;var e=Ee;function u(r,i,o){e.stat(r,function(s,a){o(s,s?!1:n(a,i))})}function t(r,i){return n(e.statSync(r),i)}function n(r,i){return r.isFile()&&D(r,i)}function D(r,i){var o=r.mode,s=r.uid,a=r.gid,l=i.uid!==void 0?i.uid:process.getuid&&process.getuid(),c=i.gid!==void 0?i.gid:process.getgid&&process.getgid(),f=parseInt("100",8),d=parseInt("010",8),F=parseInt("001",8),E=f|d,b=o&F||o&d&&a===c||o&f&&s===l||o&E&&l===0;return b}return Oe}var re;process.platform==="win32"||I.TESTING_WINDOWS?re=gD():re=BD();var wD=Ie;Ie.sync=bD;function Ie(e,u,t){if(typeof u=="function"&&(t=u,u={}),!t){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,D){Ie(e,u||{},function(r,i){r?D(r):n(i)})})}re(e,u||{},function(n,D){n&&(n.code==="EACCES"||u&&u.ignoreErrors)&&(n=null,D=!1),t(n,D)})}function bD(e,u){try{return re.sync(e,u||{})}catch(t){if(u&&u.ignoreErrors||t.code==="EACCES")return!1;throw t}}const M=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Mu=V,yD=M?";":":",Gu=wD,Uu=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),Wu=(e,u)=>{const t=u.colon||yD,n=e.match(/\//)||M&&e.match(/\\/)?[""]:[...M?[process.cwd()]:[],...(u.path||process.env.PATH||"").split(t)],D=M?u.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",r=M?D.split(t):[""];return M&&e.indexOf(".")!==-1&&r[0]!==""&&r.unshift(""),{pathEnv:n,pathExt:r,pathExtExe:D}},Ku=(e,u,t)=>{typeof u=="function"&&(t=u,u={}),u||(u={});const{pathEnv:n,pathExt:D,pathExtExe:r}=Wu(e,u),i=[],o=a=>new Promise((l,c)=>{if(a===n.length)return u.all&&i.length?l(i):c(Uu(e));const f=n[a],d=/^".*"$/.test(f)?f.slice(1,-1):f,F=Mu.join(d,e),E=!d&&/^\.[\\\/]/.test(e)?e.slice(0,2)+F:F;l(s(E,a,0))}),s=(a,l,c)=>new Promise((f,d)=>{if(c===D.length)return f(o(l+1));const F=D[c];Gu(a+F,{pathExt:r},(E,b)=>{if(!E&&b)if(u.all)i.push(a+F);else return f(a+F);return f(s(a,l,c+1))})});return t?o(0).then(a=>t(null,a),t):o(0)},$D=(e,u)=>{u=u||{};const{pathEnv:t,pathExt:n,pathExtExe:D}=Wu(e,u),r=[];for(let i=0;i<t.length;i++){const o=t[i],s=/^".*"$/.test(o)?o.slice(1,-1):o,a=Mu.join(s,e),l=!s&&/^\.[\\\/]/.test(e)?e.slice(0,2)+a:a;for(let c=0;c<n.length;c++){const f=l+n[c];try{if(Gu.sync(f,{pathExt:D}))if(u.all)r.push(f);else return f}catch{}}}if(u.all&&r.length)return r;if(u.nothrow)return null;throw Uu(e)};var AD=Ku;Ku.sync=$D;var ie={},vD={get exports(){return ie},set exports(e){ie=e}};const qu=(e={})=>{const u=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(u).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};vD.exports=qu,ie.default=qu;const zu=V,xD=AD,SD=ie;function Vu(e,u){const t=e.options.env||process.env,n=process.cwd(),D=e.options.cwd!=null,r=D&&process.chdir!==void 0&&!process.chdir.disabled;if(r)try{process.chdir(e.options.cwd)}catch{}let i;try{i=xD.sync(e.command,{path:t[SD({env:t})],pathExt:u?zu.delimiter:void 0})}catch{}finally{r&&process.chdir(n)}return i&&(i=zu.resolve(D?e.options.cwd:"",i)),i}function OD(e){return Vu(e)||Vu(e,!0)}var ID=OD,Te={};const Pe=/([()\][%!^"`<>&|;, *?])/g;function TD(e){return e=e.replace(Pe,"^$1"),e}function PD(e,u){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(Pe,"^$1"),u&&(e=e.replace(Pe,"^$1")),e}Te.command=TD,Te.argument=PD;var kD=/^#!(.*)/;const RD=kD;var _D=(e="")=>{const u=e.match(RD);if(!u)return null;const[t,n]=u[0].replace(/#! ?/,"").split(" "),D=t.split("/").pop();return D==="env"?n:n?`${D} ${n}`:D};const ke=Ee,jD=_D;function ND(e){const t=Buffer.alloc(150);let n;try{n=ke.openSync(e,"r"),ke.readSync(n,t,0,150,0),ke.closeSync(n)}catch{}return jD(t.toString())}var LD=ND;const MD=V,Hu=ID,Yu=Te,GD=LD,UD=process.platform==="win32",WD=/\.(?:com|exe)$/i,KD=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function qD(e){e.file=Hu(e);const u=e.file&&GD(e.file);return u?(e.args.unshift(e.file),e.command=u,Hu(e)):e.file}function zD(e){if(!UD)return e;const u=qD(e),t=!WD.test(u);if(e.options.forceShell||t){const n=KD.test(u);e.command=MD.normalize(e.command),e.command=Yu.command(e.command),e.args=e.args.map(r=>Yu.argument(r,n));const D=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${D}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function VD(e,u,t){u&&!Array.isArray(u)&&(t=u,u=null),u=u?u.slice(0):[],t=Object.assign({},t);const n={command:e,args:u,options:t,file:void 0,original:{command:e,args:u}};return t.shell?n:zD(n)}var HD=VD;const Re=process.platform==="win32";function _e(e,u){return Object.assign(new Error(`${u} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${u} ${e.command}`,path:e.command,spawnargs:e.args})}function YD(e,u){if(!Re)return;const t=e.emit;e.emit=function(n,D){if(n==="exit"){const r=Ju(D,u);if(r)return t.call(e,"error",r)}return t.apply(e,arguments)}}function Ju(e,u){return Re&&e===1&&!u.file?_e(u.original,"spawn"):null}function JD(e,u){return Re&&e===1&&!u.file?_e(u.original,"spawnSync"):null}var XD={hookChildProcess:YD,verifyENOENT:Ju,verifyENOENTSync:JD,notFoundError:_e};const Xu=Mt,je=HD,Ne=XD;function Zu(e,u,t){const n=je(e,u,t),D=Xu.spawn(n.command,n.args,n.options);return Ne.hookChildProcess(D,n),D}function ZD(e,u,t){const n=je(e,u,t),D=Xu.spawnSync(n.command,n.args,n.options);return D.error=D.error||Ne.verifyENOENTSync(D.status,n),D}ED.exports=Zu,R.spawn=Zu,R.sync=ZD,R._parse=je,R._enoent=Ne;function QD(e){const u=typeof e=="string"?`
22
+ `),n(),process.exit(1);e[s]=a}}function FD(e){return e===void 0||e!==!1}function Ru(e,u,t,n){const D={...u.flags},r=u.version;r&&(D.version={type:Boolean,description:"Show version"});const{help:i}=u,o=FD(i);o&&!("help"in D)&&(D.help={type:Boolean,alias:"h",description:"Show help"});const s=Cn(D,n,{ignore:u.ignoreArgv}),a=()=>{console.log(u.version)};if(r&&s.flags.version===!0)return a(),process.exit(0);const l=new dD,c=o&&i?.render?i.render:F=>l.render(F),f=F=>{const E=lD({...u,...F?{help:F}:{},flags:D});console.log(c(E,l))};if(o&&s.flags.help===!0)return f(),process.exit(0);if(u.parameters){let{parameters:F}=u,E=s._;const b=F.indexOf("--"),P=F.slice(b+1),S=Object.create(null);if(b>-1&&P.length>0){F=F.slice(0,b);const Q=s._["--"];E=E.slice(0,-Q.length||void 0),xe(S,ve(F),E,f),xe(S,ve(P),Q,f)}else xe(S,ve(F),E,f);Object.assign(s._,S)}const d={...s,showVersion:a,showHelp:f};return typeof t=="function"&&t(d),{command:e,...d}}function mD(e,u){const t=new Map;for(const n of u){const D=[n.options.name],{alias:r}=n.options;r&&(Array.isArray(r)?D.push(...r):D.push(r));for(const i of D){if(t.has(i))throw new Error(`Duplicate command name found: ${x(i)}`);t.set(i,n)}}return t.get(e)}function CD(e,u,t=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!Ae.test(e.name)))throw new Error(`Invalid script name: ${x(e.name)}`);const n=t[0];if(e.commands&&Ae.test(n)){const D=mD(n,e.commands);if(D)return Ru(D.options.name,{...D.options,parent:e},D.callback,t.slice(1))}return Ru(void 0,e,u,t)}function _u(e,u){if(!e)throw new Error("Command options are required");const{name:t}=e;if(e.name===void 0)throw new Error("Command name is required");if(!Ae.test(t))throw new Error(`Invalid command name ${JSON.stringify(t)}. Command names must be one word.`);return{options:e,callback:u}}var ju="1.5.1",hD="Writes your git commit messages for you with AI",I=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},R={},ED={get exports(){return R},set exports(e){R=e}},Se,Nu;function gD(){if(Nu)return Se;Nu=1,Se=n,n.sync=D;var e=Ee;function u(r,i){var o=i.pathExt!==void 0?i.pathExt:process.env.PATHEXT;if(!o||(o=o.split(";"),o.indexOf("")!==-1))return!0;for(var s=0;s<o.length;s++){var a=o[s].toLowerCase();if(a&&r.substr(-a.length).toLowerCase()===a)return!0}return!1}function t(r,i,o){return!r.isSymbolicLink()&&!r.isFile()?!1:u(i,o)}function n(r,i,o){e.stat(r,function(s,a){o(s,s?!1:t(a,r,i))})}function D(r,i){return t(e.statSync(r),r,i)}return Se}var Oe,Lu;function BD(){if(Lu)return Oe;Lu=1,Oe=u,u.sync=t;var e=Ee;function u(r,i,o){e.stat(r,function(s,a){o(s,s?!1:n(a,i))})}function t(r,i){return n(e.statSync(r),i)}function n(r,i){return r.isFile()&&D(r,i)}function D(r,i){var o=r.mode,s=r.uid,a=r.gid,l=i.uid!==void 0?i.uid:process.getuid&&process.getuid(),c=i.gid!==void 0?i.gid:process.getgid&&process.getgid(),f=parseInt("100",8),d=parseInt("010",8),F=parseInt("001",8),E=f|d,b=o&F||o&d&&a===c||o&f&&s===l||o&E&&l===0;return b}return Oe}var re;process.platform==="win32"||I.TESTING_WINDOWS?re=gD():re=BD();var wD=Ie;Ie.sync=bD;function Ie(e,u,t){if(typeof u=="function"&&(t=u,u={}),!t){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,D){Ie(e,u||{},function(r,i){r?D(r):n(i)})})}re(e,u||{},function(n,D){n&&(n.code==="EACCES"||u&&u.ignoreErrors)&&(n=null,D=!1),t(n,D)})}function bD(e,u){try{return re.sync(e,u||{})}catch(t){if(u&&u.ignoreErrors||t.code==="EACCES")return!1;throw t}}const M=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Mu=V,yD=M?";":":",Gu=wD,Uu=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),Wu=(e,u)=>{const t=u.colon||yD,n=e.match(/\//)||M&&e.match(/\\/)?[""]:[...M?[process.cwd()]:[],...(u.path||process.env.PATH||"").split(t)],D=M?u.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",r=M?D.split(t):[""];return M&&e.indexOf(".")!==-1&&r[0]!==""&&r.unshift(""),{pathEnv:n,pathExt:r,pathExtExe:D}},Ku=(e,u,t)=>{typeof u=="function"&&(t=u,u={}),u||(u={});const{pathEnv:n,pathExt:D,pathExtExe:r}=Wu(e,u),i=[],o=a=>new Promise((l,c)=>{if(a===n.length)return u.all&&i.length?l(i):c(Uu(e));const f=n[a],d=/^".*"$/.test(f)?f.slice(1,-1):f,F=Mu.join(d,e),E=!d&&/^\.[\\\/]/.test(e)?e.slice(0,2)+F:F;l(s(E,a,0))}),s=(a,l,c)=>new Promise((f,d)=>{if(c===D.length)return f(o(l+1));const F=D[c];Gu(a+F,{pathExt:r},(E,b)=>{if(!E&&b)if(u.all)i.push(a+F);else return f(a+F);return f(s(a,l,c+1))})});return t?o(0).then(a=>t(null,a),t):o(0)},$D=(e,u)=>{u=u||{};const{pathEnv:t,pathExt:n,pathExtExe:D}=Wu(e,u),r=[];for(let i=0;i<t.length;i++){const o=t[i],s=/^".*"$/.test(o)?o.slice(1,-1):o,a=Mu.join(s,e),l=!s&&/^\.[\\\/]/.test(e)?e.slice(0,2)+a:a;for(let c=0;c<n.length;c++){const f=l+n[c];try{if(Gu.sync(f,{pathExt:D}))if(u.all)r.push(f);else return f}catch{}}}if(u.all&&r.length)return r;if(u.nothrow)return null;throw Uu(e)};var AD=Ku;Ku.sync=$D;var ie={},vD={get exports(){return ie},set exports(e){ie=e}};const qu=(e={})=>{const u=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(u).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};vD.exports=qu,ie.default=qu;const zu=V,xD=AD,SD=ie;function Vu(e,u){const t=e.options.env||process.env,n=process.cwd(),D=e.options.cwd!=null,r=D&&process.chdir!==void 0&&!process.chdir.disabled;if(r)try{process.chdir(e.options.cwd)}catch{}let i;try{i=xD.sync(e.command,{path:t[SD({env:t})],pathExt:u?zu.delimiter:void 0})}catch{}finally{r&&process.chdir(n)}return i&&(i=zu.resolve(D?e.options.cwd:"",i)),i}function OD(e){return Vu(e)||Vu(e,!0)}var ID=OD,Te={};const Pe=/([()\][%!^"`<>&|;, *?])/g;function TD(e){return e=e.replace(Pe,"^$1"),e}function PD(e,u){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(Pe,"^$1"),u&&(e=e.replace(Pe,"^$1")),e}Te.command=TD,Te.argument=PD;var kD=/^#!(.*)/;const RD=kD;var _D=(e="")=>{const u=e.match(RD);if(!u)return null;const[t,n]=u[0].replace(/#! ?/,"").split(" "),D=t.split("/").pop();return D==="env"?n:n?`${D} ${n}`:D};const ke=Ee,jD=_D;function ND(e){const t=Buffer.alloc(150);let n;try{n=ke.openSync(e,"r"),ke.readSync(n,t,0,150,0),ke.closeSync(n)}catch{}return jD(t.toString())}var LD=ND;const MD=V,Hu=ID,Yu=Te,GD=LD,UD=process.platform==="win32",WD=/\.(?:com|exe)$/i,KD=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function qD(e){e.file=Hu(e);const u=e.file&&GD(e.file);return u?(e.args.unshift(e.file),e.command=u,Hu(e)):e.file}function zD(e){if(!UD)return e;const u=qD(e),t=!WD.test(u);if(e.options.forceShell||t){const n=KD.test(u);e.command=MD.normalize(e.command),e.command=Yu.command(e.command),e.args=e.args.map(r=>Yu.argument(r,n));const D=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${D}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function VD(e,u,t){u&&!Array.isArray(u)&&(t=u,u=null),u=u?u.slice(0):[],t=Object.assign({},t);const n={command:e,args:u,options:t,file:void 0,original:{command:e,args:u}};return t.shell?n:zD(n)}var HD=VD;const Re=process.platform==="win32";function _e(e,u){return Object.assign(new Error(`${u} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${u} ${e.command}`,path:e.command,spawnargs:e.args})}function YD(e,u){if(!Re)return;const t=e.emit;e.emit=function(n,D){if(n==="exit"){const r=Ju(D,u);if(r)return t.call(e,"error",r)}return t.apply(e,arguments)}}function Ju(e,u){return Re&&e===1&&!u.file?_e(u.original,"spawn"):null}function JD(e,u){return Re&&e===1&&!u.file?_e(u.original,"spawnSync"):null}var XD={hookChildProcess:YD,verifyENOENT:Ju,verifyENOENTSync:JD,notFoundError:_e};const Xu=Mt,je=HD,Ne=XD;function Zu(e,u,t){const n=je(e,u,t),D=Xu.spawn(n.command,n.args,n.options);return Ne.hookChildProcess(D,n),D}function ZD(e,u,t){const n=je(e,u,t),D=Xu.spawnSync(n.command,n.args,n.options);return D.error=D.error||Ne.verifyENOENTSync(D.status,n),D}ED.exports=Zu,R.spawn=Zu,R.sync=ZD,R._parse=je,R._enoent=Ne;function QD(e){const u=typeof e=="string"?`
23
23
  `:`
24
24
  `.charCodeAt(),t=typeof e=="string"?"\r":"\r".charCodeAt();return e[e.length-1]===u&&(e=e.slice(0,-1)),e[e.length-1]===t&&(e=e.slice(0,-1)),e}function Qu(e={}){const{env:u=process.env,platform:t=process.platform}=e;return t!=="win32"?"PATH":Object.keys(u).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"}function er(e={}){const{cwd:u=g.cwd(),path:t=g.env[Qu()],execPath:n=g.execPath}=e;let D;const r=u instanceof URL?Gt.fileURLToPath(u):u;let i=L.resolve(r);const o=[];for(;D!==i;)o.push(L.join(i,"node_modules/.bin")),D=i,i=L.resolve(i,"..");return o.push(L.resolve(r,n,"..")),[...o,t].join(L.delimiter)}function ur({env:e=g.env,...u}={}){e={...e};const t=Qu({env:e});return u.path=e[t],e[t]=er(u),e}const tr=(e,u,t,n)=>{if(t==="length"||t==="prototype"||t==="arguments"||t==="caller")return;const D=Object.getOwnPropertyDescriptor(e,t),r=Object.getOwnPropertyDescriptor(u,t);!nr(D,r)&&n||Object.defineProperty(e,t,r)},nr=function(e,u){return e===void 0||e.configurable||e.writable===u.writable&&e.enumerable===u.enumerable&&e.configurable===u.configurable&&(e.writable||e.value===u.value)},Dr=(e,u)=>{const t=Object.getPrototypeOf(u);t!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,t)},rr=(e,u)=>`/* Wrapped ${e}*/
25
25
  ${u}`,ir=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),or=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),sr=(e,u,t)=>{const n=t===""?"":`with ${t.trim()}() `,D=rr.bind(null,n,u.toString());Object.defineProperty(D,"name",or),Object.defineProperty(e,"toString",{...ir,value:D})};function ar(e,u,{ignoreNonConfigurable:t=!1}={}){const{name:n}=e;for(const D of Reflect.ownKeys(u))tr(e,u,D,t);return Dr(e,u),sr(e,u,n),e}const oe=new WeakMap,et=(e,u={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let t,n=0;const D=e.displayName||e.name||"<anonymous>",r=function(...i){if(oe.set(r,++n),n===1)t=e.apply(this,i),e=null;else if(u.throw===!0)throw new Error(`Function \`${D}\` can only be called once`);return t};return ar(r,e),oe.set(r,n),r};et.callCount=e=>{if(!oe.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return oe.get(e)};const cr=function(){const e=tt-ut+1;return Array.from({length:e},lr)},lr=function(e,u){return{name:`SIGRT${u+1}`,number:ut+u,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}},ut=34,tt=64,fr=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}],nt=function(){const e=cr();return[...fr,...e].map(dr)},dr=function({name:e,number:u,description:t,action:n,forced:D=!1,standard:r}){const{signals:{[e]:i}}=pu,o=i!==void 0;return{name:e,number:o?i:u,description:t,supported:o,action:n,forced:D,standard:r}},pr=function(){const e=nt();return Object.fromEntries(e.map(Fr))},Fr=function({name:e,number:u,description:t,supported:n,action:D,forced:r,standard:i}){return[e,{name:e,number:u,description:t,supported:n,action:D,forced:r,standard:i}]},mr=pr(),Cr=function(){const e=nt(),u=tt+1,t=Array.from({length:u},(n,D)=>hr(D,e));return Object.assign({},...t)},hr=function(e,u){const t=Er(e,u);if(t===void 0)return{};const{name:n,description:D,supported:r,action:i,forced:o,standard:s}=t;return{[e]:{name:n,number:e,description:D,supported:r,action:i,forced:o,standard:s}}},Er=function(e,u){const t=u.find(({name:n})=>pu.signals[n]===e);return t!==void 0?t:u.find(n=>n.number===e)};Cr();const gr=({timedOut:e,timeout:u,errorCode:t,signal:n,signalDescription:D,exitCode:r,isCanceled:i})=>e?`timed out after ${u} milliseconds`:i?"was canceled":t!==void 0?`failed with ${t}`:n!==void 0?`was killed with ${n} (${D})`:r!==void 0?`failed with exit code ${r}`:"failed",Dt=({stdout:e,stderr:u,all:t,error:n,signal:D,exitCode:r,command:i,escapedCommand:o,timedOut:s,isCanceled:a,killed:l,parsed:{options:{timeout:c}}})=>{r=r===null?void 0:r,D=D===null?void 0:D;const f=D===void 0?void 0:mr[D].description,d=n&&n.code,E=`Command ${gr({timedOut:s,timeout:c,errorCode:d,signal:D,signalDescription:f,exitCode:r,isCanceled:a})}: ${i}`,b=Object.prototype.toString.call(n)==="[object Error]",P=b?`${E}
@@ -63,12 +63,12 @@ ${uu}Please open a Bug report with the information above:`),console.error(`${uu}
63
63
  ${n}`),t.statusCode===500&&(D+=`
64
64
 
65
65
  Check the API status: https://status.openai.com`),new $(D)}return JSON.parse(n)},ki=e=>e.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1"),Ri=e=>Array.from(new Set(e)),_i=(e,u)=>`Write an insightful but concise Git commit message in a complete sentence in present tense for the following diff without prefacing it with anything, the response must be in the language ${e}:
66
- ${u}`,ji="gpt-3.5-turbo",Ni=Jt("text-davinci-003"),Rt=async(e,u,t,n)=>{const D=_i(u,t);if(Ni.encode(D).length>4e3)throw new $("The diff is too large for the OpenAI API. Try reducing the number of staged changes, or write your own commit message.");try{const r=await Pi(e,{model:ji,messages:[{role:"user",content:D}],temperature:.7,top_p:1,frequency_penalty:0,presence_penalty:0,max_tokens:200,stream:!1,n});return Ri(r.choices.filter(i=>i.message?.content).map(i=>ki(i.message.content)))}catch(r){const i=r;throw i.code==="ENOTFOUND"?new $(`Error connecting to ${i.hostname} (${i.syscall}). Are you connected to the internet?`):i}};var Li=async(e,u)=>(async()=>{yt(Ft(pt(" aicommits "))),await $t();const t=eu();t.start("Detecting staged files");const n=await vt();if(!n)throw new $("No staged changes found. Make sure to stage your changes with `git add`.");t.stop(`${Si(n.files)}:
66
+ ${u}`,ji="gpt-3.5-turbo",Ni=Jt("text-davinci-003"),Rt=async(e,u,t,n)=>{const D=_i(u,t);if(Ni.encode(D).length>4e3)throw new $("The diff is too large for the OpenAI API. Try reducing the number of staged changes, or write your own commit message.");try{const r=await Pi(e,{model:ji,messages:[{role:"user",content:D}],temperature:.7,top_p:1,frequency_penalty:0,presence_penalty:0,max_tokens:200,stream:!1,n});return Ri(r.choices.filter(i=>i.message?.content).map(i=>ki(i.message.content)))}catch(r){const i=r;throw i.code==="ENOTFOUND"?new $(`Error connecting to ${i.hostname} (${i.syscall}). Are you connected to the internet?`):i}};var Li=async(e,u)=>(async()=>{yt(Ft(pt(" aicommits "))),await $t();const t=eu();t.start("Detecting staged files");const n=await vt();if(!n)throw t.stop("Detecting staged files"),new $("No staged changes found. Make sure to stage your changes with `git add`.");t.stop(`${Si(n.files)}:
67
67
  ${n.files.map(s=>` ${s}`).join(`
68
- `)}`);const D=await ru({OPENAI_KEY:process.env.OPENAI_KEY??process.env.OPENAI_API_KEY,generate:e?.toString()}),r=eu();r.start("The AI is analyzing your changes");const i=await Rt(D.OPENAI_KEY,D.locale,n.diff,D.generate);if(r.stop("Changes analyzed"),i.length===0)throw new $("No commit messages were generated. Try again.");let o;if(i.length===1){[o]=i;const s=await vi({message:`Use this commit message?
68
+ `)}`);const D=await ru({OPENAI_KEY:process.env.OPENAI_KEY??process.env.OPENAI_API_KEY,generate:e?.toString()}),r=eu();r.start("The AI is analyzing your changes");let i;try{i=await Rt(D.OPENAI_KEY,D.locale,n.diff,D.generate)}finally{r.stop("Changes analyzed")}if(i.length===0)throw new $("No commit messages were generated. Try again.");let o;if(i.length===1){[o]=i;const s=await vi({message:`Use this commit message?
69
69
 
70
70
  ${o}
71
- `});if(!s||Et(s)){K("Commit cancelled");return}}else{const s=await xi({message:`Pick a commit message to use: ${ze("(Ctrl+c to exit)")}`,options:i.map(a=>({label:a,value:a}))});if(Et(s)){K("Commit cancelled");return}o=s}await le("git",["commit","-m",o,...u]),K(`${de("\u2714")} Successfully committed!`)})().catch(t=>{K(`${fe("\u2716")} ${t.message}`),Fe(t),process.exit(1)});const[_t,Mi]=process.argv.slice(2);var Gi=()=>(async()=>{if(!_t)throw new $('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(Mi)return;const e=await vt();if(!e)return;yt(Ft(pt(" aicommits ")));const u=await ru(),t=eu();t.start("The AI is analyzing your changes");const n=await Rt(u.OPENAI_KEY,u.locale,e.diff,u.generate);t.stop("Changes analyzed");const D=n.length>1;let r=`# \u{1F916} AI generated commit${D?"s":""}
71
+ `});if(!s||Et(s)){K("Commit cancelled");return}}else{const s=await xi({message:`Pick a commit message to use: ${ze("(Ctrl+c to exit)")}`,options:i.map(a=>({label:a,value:a}))});if(Et(s)){K("Commit cancelled");return}o=s}await le("git",["commit","-m",o,...u]),K(`${de("\u2714")} Successfully committed!`)})().catch(t=>{K(`${fe("\u2716")} ${t.message}`),Fe(t),process.exit(1)});const[_t,Mi]=process.argv.slice(2);var Gi=()=>(async()=>{if(!_t)throw new $('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(Mi)return;const e=await vt();if(!e)return;yt(Ft(pt(" aicommits ")));const u=await ru(),t=eu();t.start("The AI is analyzing your changes");let n;try{n=await Rt(u.OPENAI_KEY,u.locale,e.diff,u.generate)}finally{t.stop("Changes analyzed")}const D=n.length>1;let r=`# \u{1F916} AI generated commit${D?"s":""}
72
72
  `;D?(r+=`# Select one of the following messages by uncommeting:
73
73
  `,r+=`
74
74
  ${n.map(i=>`# ${i}`).join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicommits",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "Writes your git commit messages for you with AI",
5
5
  "keywords": [
6
6
  "ai",