aicommit2 2.2.3 → 2.2.5

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/README.md CHANGED
@@ -513,7 +513,7 @@ aicommit2 config set OPENAI.topP=0.2
513
513
 
514
514
  | Setting | Description | Default |
515
515
  |-------------|----------------|-----------------------------|
516
- | `key` | API key | - |
516
+ | `key` | API key | - |
517
517
  | `model` | Model to use | `claude-3-5-haiku-20241022` |
518
518
 
519
519
  ##### ANTHROPIC.key
@@ -525,6 +525,7 @@ The Anthropic API key. To get started with Anthropic Claude, request access to t
525
525
  Default: `claude-3-5-haiku-20241022`
526
526
 
527
527
  Supported:
528
+ - `claude-3-7-sonnet-20250219`
528
529
  - `claude-3-5-sonnet-20241022`
529
530
  - `claude-3-5-haiku-20241022`
530
531
  - `claude-3-opus-20240229`
@@ -558,16 +559,20 @@ aicommit2 config set GEMINI.key="your api key"
558
559
 
559
560
  ##### GEMINI.model
560
561
 
561
- Default: `gemini-2.0-flash-exp`
562
+ Default: `gemini-2.0-flash`
562
563
 
563
564
  Supported:
565
+ - `gemini-2.0-flash`
566
+ - `gemini-2.0-flash-lite`
567
+ - `gemini-2.0-pro-exp-02-05`
568
+ - `gemini-2.0-flash-thinking-exp-01-21`
564
569
  - `gemini-2.0-flash-exp`
565
570
  - `gemini-1.5-flash`
566
571
  - `gemini-1.5-flash-8b`
567
572
  - `gemini-1.5-pro`
568
573
 
569
574
  ```sh
570
- aicommit2 config set GEMINI.model="gemini-1.5-flash"
575
+ aicommit2 config set GEMINI.model="gemini-2.0-flash"
571
576
  ```
572
577
 
573
578
  ##### Unsupported Options
@@ -863,7 +868,6 @@ Request timeout for the Ollama.
863
868
  ```sh
864
869
  aicommit2 config set OLLAMA.timeout=<timeout>
865
870
  ```
866
-
867
871
  ##### OLLAMA.numCtx
868
872
 
869
873
  The maximum number of tokens the model can process at once, determining its context length and memory usage.
@@ -1108,7 +1112,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
1108
1112
  </tr>
1109
1113
  <tr>
1110
1114
  <td align="center"><a href="https://github.com/devxpain"><img src="https://avatars.githubusercontent.com/devxpain" width="100px;" alt=""/><br /><sub><b>@devxpain</b></sub></a><br /><a href="https://github.com/tak-bro/aicommit2/commits?author=devxpain" title="Code">💻</a></td>
1111
- </tr>
1115
+ </tr>
1112
1116
  </table>
1113
1117
  <!-- markdownlint-restore -->
1114
1118
  <!-- prettier-ignore-end -->
package/dist/cli.mjs CHANGED
@@ -18,8 +18,8 @@ import rt from"tty";import{createRequire as ln}from"module";import{Buffer as Dn}
18
18
  `)),r)return{id:"examples",type:"section",data:{title:"Examples:",body:r}}}function Qs(t){if(!("alias"in t)||!t.alias)return;const{alias:e}=t;return{id:"aliases",type:"section",data:{title:"Aliases:",body:Array.isArray(e)?e.join(", "):e}}}const ei=t=>[Ks,Vs,Ys,Js,Xs,Zs,Qs].map(e=>e(t)).filter(Boolean),ti=rt.WriteStream.prototype.hasColors();class ri{text(e){return e}bold(e){return ti?`\x1B[1m${e}\x1B[22m`:e.toLocaleUpperCase()}indentText({text:e,spaces:r}){return e.replace(/^/gm," ".repeat(r))}heading(e){return this.bold(e)}section({title:e,body:r,indentBody:o=2}){return`${(e?`${this.heading(e)}
19
19
  `:"")+(r?this.indentText({text:this.render(r),spaces:o}):"")}
20
20
  `}table({tableData:e,tableOptions:r,tableBreakpoints:o}){return _s(e.map(n=>n.map(s=>this.render(s))),o?Hs(o):r)}flagParameter(e){return e===Boolean?"":e===String?"<string>":e===Number?"<number>":Array.isArray(e)?this.flagParameter(e[0]):"<value>"}flagOperator(e){return" "}flagName(e){const{flag:r,flagFormatted:o,aliasesEnabled:n,aliasFormatted:s}=e;let i="";if(s?i+=`${s}, `:n&&(i+=" "),i+=o,"placeholder"in r&&typeof r.placeholder=="string")i+=`${this.flagOperator(e)}${r.placeholder}`;else{const u=this.flagParameter("type"in r?r.type:r);u&&(i+=`${this.flagOperator(e)}${u}`)}return i}flagDefault(e){return JSON.stringify(e)}flagDescription({flag:e}){let r="description"in e?e.description??"":"";if("default"in e){let{default:o}=e;typeof o=="function"&&(o=o()),o&&(r+=` (default: ${this.flagDefault(o)})`)}return r}render(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(r=>this.render(r)).join(`
21
- `);if("type"in e&&this[e.type]){const r=this[e.type];if(typeof r=="function")return r.call(this,e.data)}throw new Error(`Invalid node type: ${JSON.stringify(e)}`)}}const mt=/^[\w.-]+$/,{stringify:W}=JSON,oi=/[|\\{}()[\]^$+*?.]/;function dt(t){const e=[];let r,o;for(const n of t){if(o)throw new Error(`Invalid parameter: Spread parameter ${W(o)} must be last`);const s=n[0],i=n[n.length-1];let u;if(s==="<"&&i===">"&&(u=!0,r))throw new Error(`Invalid parameter: Required parameter ${W(n)} cannot come after optional parameter ${W(r)}`);if(s==="["&&i==="]"&&(u=!1,r=n),u===void 0)throw new Error(`Invalid parameter: ${W(n)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let a=n.slice(1,-1);const l=a.slice(-3)==="...";l&&(o=n,a=a.slice(0,-3));const m=a.match(oi);if(m)throw new Error(`Invalid parameter: ${W(n)}. Invalid character found ${W(m[0])}`);e.push({name:a,required:u,spread:l})}return e}function pt(t,e,r,o){for(let n=0;n<e.length;n+=1){const{name:s,required:i,spread:u}=e[n],a=Us(s);if(a in t)throw new Error(`Invalid parameter: ${W(s)} is used more than once.`);const l=u?r.slice(n):r[n];if(u&&(n=e.length),i&&(!l||u&&l.length===0))return console.error(`Error: Missing required parameter ${W(s)}
22
- `),o(),process.exit(1);t[a]=l}}function ni(t){return t===void 0||t!==!1}function kr(t,e,r,o){const n={...e.flags},s=e.version;s&&(n.version={type:Boolean,description:"Show version"});const{help:i}=e,u=ni(i);u&&!("help"in n)&&(n.help={type:Boolean,alias:"h",description:"Show help"});const a=is(n,o,{ignore:e.ignoreArgv}),l=()=>{console.log(e.version)};if(s&&a.flags.version===!0)return l(),process.exit(0);const m=new ri,c=u&&i?.render?i.render:f=>m.render(f),D=f=>{const h=ei({...e,...f?{help:f}:{},flags:n});console.log(c(h,m))};if(u&&a.flags.help===!0)return D(),process.exit(0);if(e.parameters){let{parameters:f}=e,h=a._;const g=f.indexOf("--"),y=f.slice(g+1),v=Object.create(null);if(g>-1&&y.length>0){f=f.slice(0,g);const O=a._["--"];h=h.slice(0,-O.length||void 0),pt(v,dt(f),h,D),pt(v,dt(y),O,D)}else pt(v,dt(f),h,D);Object.assign(a._,v)}const p={...a,showVersion:l,showHelp:D};return typeof r=="function"&&r(p),{command:t,...p}}function si(t,e){const r=new Map;for(const o of e){const n=[o.options.name],{alias:s}=o.options;s&&(Array.isArray(s)?n.push(...s):n.push(s));for(const i of n){if(r.has(i))throw new Error(`Duplicate command name found: ${W(i)}`);r.set(i,o)}}return r.get(t)}function ii(t,e,r=process.argv.slice(2)){if(!t)throw new Error("Options is required");if("name"in t&&(!t.name||!mt.test(t.name)))throw new Error(`Invalid script name: ${W(t.name)}`);const o=r[0];if(t.commands&&mt.test(o)){const n=si(o,t.commands);if(n)return kr(n.options.name,{...n.options,parent:t},n.callback,r.slice(1))}return kr(void 0,t,e,r)}function ft(t,e){if(!t)throw new Error("Command options are required");const{name:r}=t;if(t.name===void 0)throw new Error("Command name is required");if(!mt.test(r))throw new Error(`Invalid command name ${JSON.stringify(r)}. Command names must be one word.`);return{options:t,callback:e}}var ai=ln(import.meta.url),M=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function re(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var oe={exports:{}},ht,Lr;function ui(){if(Lr)return ht;Lr=1,ht=o,o.sync=n;var t=N;function e(s,i){var u=i.pathExt!==void 0?i.pathExt:process.env.PATHEXT;if(!u||(u=u.split(";"),u.indexOf("")!==-1))return!0;for(var a=0;a<u.length;a++){var l=u[a].toLowerCase();if(l&&s.substr(-l.length).toLowerCase()===l)return!0}return!1}function r(s,i,u){return!s.isSymbolicLink()&&!s.isFile()?!1:e(i,u)}function o(s,i,u){t.stat(s,function(a,l){u(a,a?!1:r(l,s,i))})}function n(s,i){return r(t.statSync(s),s,i)}return ht}var gt,Nr;function ci(){if(Nr)return gt;Nr=1,gt=e,e.sync=r;var t=N;function e(s,i,u){t.stat(s,function(a,l){u(a,a?!1:o(l,i))})}function r(s,i){return o(t.statSync(s),i)}function o(s,i){return s.isFile()&&n(s,i)}function n(s,i){var u=s.mode,a=s.uid,l=s.gid,m=i.uid!==void 0?i.uid:process.getuid&&process.getuid(),c=i.gid!==void 0?i.gid:process.getgid&&process.getgid(),D=parseInt("100",8),p=parseInt("010",8),f=parseInt("001",8),h=D|p,g=u&f||u&p&&l===c||u&D&&a===m||u&h&&m===0;return g}return gt}var Ie;process.platform==="win32"||M.TESTING_WINDOWS?Ie=ui():Ie=ci();var li=Ct;Ct.sync=Di;function Ct(t,e,r){if(typeof e=="function"&&(r=e,e={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(o,n){Ct(t,e||{},function(s,i){s?n(s):o(i)})})}Ie(t,e||{},function(o,n){o&&(o.code==="EACCES"||e&&e.ignoreErrors)&&(o=null,n=!1),r(o,n)})}function Di(t,e){try{return Ie.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}const ne=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Tr=L,mi=ne?";":":",_r=li,jr=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),Gr=(t,e)=>{const r=e.colon||mi,o=t.match(/\//)||ne&&t.match(/\\/)?[""]:[...ne?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(r)],n=ne?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=ne?n.split(r):[""];return ne&&t.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:o,pathExt:s,pathExtExe:n}},Hr=(t,e,r)=>{typeof e=="function"&&(r=e,e={}),e||(e={});const{pathEnv:o,pathExt:n,pathExtExe:s}=Gr(t,e),i=[],u=l=>new Promise((m,c)=>{if(l===o.length)return e.all&&i.length?m(i):c(jr(t));const D=o[l],p=/^".*"$/.test(D)?D.slice(1,-1):D,f=Tr.join(p,t),h=!p&&/^\.[\\\/]/.test(t)?t.slice(0,2)+f:f;m(a(h,l,0))}),a=(l,m,c)=>new Promise((D,p)=>{if(c===n.length)return D(u(m+1));const f=n[c];_r(l+f,{pathExt:s},(h,g)=>{if(!h&&g)if(e.all)i.push(l+f);else return D(l+f);return D(a(l,m,c+1))})});return r?u(0).then(l=>r(null,l),r):u(0)},di=(t,e)=>{e=e||{};const{pathEnv:r,pathExt:o,pathExtExe:n}=Gr(t,e),s=[];for(let i=0;i<r.length;i++){const u=r[i],a=/^".*"$/.test(u)?u.slice(1,-1):u,l=Tr.join(a,t),m=!a&&/^\.[\\\/]/.test(t)?t.slice(0,2)+l:l;for(let c=0;c<o.length;c++){const D=m+o[c];try{if(_r.sync(D,{pathExt:n}))if(e.all)s.push(D);else return D}catch{}}}if(e.all&&s.length)return s;if(e.nothrow)return null;throw jr(t)};var pi=Hr;Hr.sync=di;var yt={exports:{}};const Ur=(t={})=>{const e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(o=>o.toUpperCase()==="PATH")||"Path"};yt.exports=Ur,yt.exports.default=Ur;var fi=yt.exports;const zr=L,hi=pi,gi=fi;function qr(t,e){const r=t.options.env||process.env,o=process.cwd(),n=t.options.cwd!=null,s=n&&process.chdir!==void 0&&!process.chdir.disabled;if(s)try{process.chdir(t.options.cwd)}catch{}let i;try{i=hi.sync(t.command,{path:r[gi({env:r})],pathExt:e?zr.delimiter:void 0})}catch{}finally{s&&process.chdir(o)}return i&&(i=zr.resolve(n?t.options.cwd:"",i)),i}function Ci(t){return qr(t)||qr(t,!0)}var yi=Ci,Et={};const Ft=/([()\][%!^"`<>&|;, *?])/g;function Ei(t){return t=t.replace(Ft,"^$1"),t}function Fi(t,e){return t=`${t}`,t=t.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),t=t.replace(/(?=(\\+?)?)\1$/,"$1$1"),t=`"${t}"`,t=t.replace(Ft,"^$1"),e&&(t=t.replace(Ft,"^$1")),t}Et.command=Ei,Et.argument=Fi;var wi=/^#!(.*)/;const vi=wi;var bi=(t="")=>{const e=t.match(vi);if(!e)return null;const[r,o]=e[0].replace(/#! ?/,"").split(" "),n=r.split("/").pop();return n==="env"?o:o?`${n} ${o}`:n};const wt=N,$i=bi;function Ai(t){const r=Buffer.alloc(150);let o;try{o=wt.openSync(t,"r"),wt.readSync(o,r,0,150,0),wt.closeSync(o)}catch{}return $i(r.toString())}var Pi=Ai;const Bi=L,Wr=yi,Kr=Et,xi=Pi,Mi=process.platform==="win32",Si=/\.(?:com|exe)$/i,Ri=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Oi(t){t.file=Wr(t);const e=t.file&&xi(t.file);return e?(t.args.unshift(t.file),t.command=e,Wr(t)):t.file}function Ii(t){if(!Mi)return t;const e=Oi(t),r=!Si.test(e);if(t.options.forceShell||r){const o=Ri.test(e);t.command=Bi.normalize(t.command),t.command=Kr.command(t.command),t.args=t.args.map(s=>Kr.argument(s,o));const n=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${n}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}function ki(t,e,r){e&&!Array.isArray(e)&&(r=e,e=null),e=e?e.slice(0):[],r=Object.assign({},r);const o={command:t,args:e,options:r,file:void 0,original:{command:t,args:e}};return r.shell?o:Ii(o)}var Li=ki;const vt=process.platform==="win32";function bt(t,e){return Object.assign(new Error(`${e} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${t.command}`,path:t.command,spawnargs:t.args})}function Ni(t,e){if(!vt)return;const r=t.emit;t.emit=function(o,n){if(o==="exit"){const s=Vr(n,e);if(s)return r.call(t,"error",s)}return r.apply(t,arguments)}}function Vr(t,e){return vt&&t===1&&!e.file?bt(e.original,"spawn"):null}function Ti(t,e){return vt&&t===1&&!e.file?bt(e.original,"spawnSync"):null}var _i={hookChildProcess:Ni,verifyENOENT:Vr,verifyENOENTSync:Ti,notFoundError:bt};const Yr=dn,$t=Li,At=_i;function Jr(t,e,r){const o=$t(t,e,r),n=Yr.spawn(o.command,o.args,o.options);return At.hookChildProcess(n,o),n}function ji(t,e,r){const o=$t(t,e,r),n=Yr.spawnSync(o.command,o.args,o.options);return n.error=n.error||At.verifyENOENTSync(n.status,o),n}oe.exports=Jr,oe.exports.spawn=Jr,oe.exports.sync=ji,oe.exports._parse=$t,oe.exports._enoent=At;var Gi=oe.exports,Hi=re(Gi);function Ui(t){const e=typeof t=="string"?`
21
+ `);if("type"in e&&this[e.type]){const r=this[e.type];if(typeof r=="function")return r.call(this,e.data)}throw new Error(`Invalid node type: ${JSON.stringify(e)}`)}}const mt=t=>t.length>0&&!t.includes(" "),{stringify:W}=JSON,oi=/[|\\{}()[\]^$+*?.]/;function dt(t){const e=[];let r,o;for(const n of t){if(o)throw new Error(`Invalid parameter: Spread parameter ${W(o)} must be last`);const s=n[0],i=n[n.length-1];let u;if(s==="<"&&i===">"&&(u=!0,r))throw new Error(`Invalid parameter: Required parameter ${W(n)} cannot come after optional parameter ${W(r)}`);if(s==="["&&i==="]"&&(u=!1,r=n),u===void 0)throw new Error(`Invalid parameter: ${W(n)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let a=n.slice(1,-1);const l=a.slice(-3)==="...";l&&(o=n,a=a.slice(0,-3));const m=a.match(oi);if(m)throw new Error(`Invalid parameter: ${W(n)}. Invalid character found ${W(m[0])}`);e.push({name:a,required:u,spread:l})}return e}function pt(t,e,r,o){for(let n=0;n<e.length;n+=1){const{name:s,required:i,spread:u}=e[n],a=Us(s);if(a in t)throw new Error(`Invalid parameter: ${W(s)} is used more than once.`);const l=u?r.slice(n):r[n];if(u&&(n=e.length),i&&(!l||u&&l.length===0))return console.error(`Error: Missing required parameter ${W(s)}
22
+ `),o(),process.exit(1);t[a]=l}}function ni(t){return t===void 0||t!==!1}function kr(t,e,r,o){const n={...e.flags},s=e.version;s&&(n.version={type:Boolean,description:"Show version"});const{help:i}=e,u=ni(i);u&&!("help"in n)&&(n.help={type:Boolean,alias:"h",description:"Show help"});const a=is(n,o,{ignore:e.ignoreArgv}),l=()=>{console.log(e.version)};if(s&&a.flags.version===!0)return l(),process.exit(0);const m=new ri,c=u&&i?.render?i.render:f=>m.render(f),D=f=>{const h=ei({...e,...f?{help:f}:{},flags:n});console.log(c(h,m))};if(u&&a.flags.help===!0)return D(),process.exit(0);if(e.parameters){let{parameters:f}=e,h=a._;const g=f.indexOf("--"),y=f.slice(g+1),v=Object.create(null);if(g>-1&&y.length>0){f=f.slice(0,g);const O=a._["--"];h=h.slice(0,-O.length||void 0),pt(v,dt(f),h,D),pt(v,dt(y),O,D)}else pt(v,dt(f),h,D);Object.assign(a._,v)}const p={...a,showVersion:l,showHelp:D};return typeof r=="function"&&r(p),{command:t,...p}}function si(t,e){const r=new Map;for(const o of e){const n=[o.options.name],{alias:s}=o.options;s&&(Array.isArray(s)?n.push(...s):n.push(s));for(const i of n){if(r.has(i))throw new Error(`Duplicate command name found: ${W(i)}`);r.set(i,o)}}return r.get(t)}function ii(t,e,r=process.argv.slice(2)){if(!t)throw new Error("Options is required");if("name"in t&&(!t.name||!mt(t.name)))throw new Error(`Invalid script name: ${W(t.name)}`);const o=r[0];if(t.commands&&o&&mt(o)){const n=si(o,t.commands);if(n)return kr(n.options.name,{...n.options,parent:t},n.callback,r.slice(1))}return kr(void 0,t,e,r)}function ft(t,e){if(!t)throw new Error("Command options are required");const{name:r}=t;if(r===void 0)throw new Error("Command name is required");if(!mt(r))throw new Error(`Invalid command name ${JSON.stringify(r)}. Command names must be one word.`);return{options:t,callback:e}}var ai=ln(import.meta.url),M=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function re(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var oe={exports:{}},ht,Lr;function ui(){if(Lr)return ht;Lr=1,ht=o,o.sync=n;var t=N;function e(s,i){var u=i.pathExt!==void 0?i.pathExt:process.env.PATHEXT;if(!u||(u=u.split(";"),u.indexOf("")!==-1))return!0;for(var a=0;a<u.length;a++){var l=u[a].toLowerCase();if(l&&s.substr(-l.length).toLowerCase()===l)return!0}return!1}function r(s,i,u){return!s.isSymbolicLink()&&!s.isFile()?!1:e(i,u)}function o(s,i,u){t.stat(s,function(a,l){u(a,a?!1:r(l,s,i))})}function n(s,i){return r(t.statSync(s),s,i)}return ht}var gt,Nr;function ci(){if(Nr)return gt;Nr=1,gt=e,e.sync=r;var t=N;function e(s,i,u){t.stat(s,function(a,l){u(a,a?!1:o(l,i))})}function r(s,i){return o(t.statSync(s),i)}function o(s,i){return s.isFile()&&n(s,i)}function n(s,i){var u=s.mode,a=s.uid,l=s.gid,m=i.uid!==void 0?i.uid:process.getuid&&process.getuid(),c=i.gid!==void 0?i.gid:process.getgid&&process.getgid(),D=parseInt("100",8),p=parseInt("010",8),f=parseInt("001",8),h=D|p,g=u&f||u&p&&l===c||u&D&&a===m||u&h&&m===0;return g}return gt}var Ie;process.platform==="win32"||M.TESTING_WINDOWS?Ie=ui():Ie=ci();var li=Ct;Ct.sync=Di;function Ct(t,e,r){if(typeof e=="function"&&(r=e,e={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(o,n){Ct(t,e||{},function(s,i){s?n(s):o(i)})})}Ie(t,e||{},function(o,n){o&&(o.code==="EACCES"||e&&e.ignoreErrors)&&(o=null,n=!1),r(o,n)})}function Di(t,e){try{return Ie.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}const ne=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Tr=L,mi=ne?";":":",_r=li,jr=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),Gr=(t,e)=>{const r=e.colon||mi,o=t.match(/\//)||ne&&t.match(/\\/)?[""]:[...ne?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(r)],n=ne?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=ne?n.split(r):[""];return ne&&t.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:o,pathExt:s,pathExtExe:n}},Hr=(t,e,r)=>{typeof e=="function"&&(r=e,e={}),e||(e={});const{pathEnv:o,pathExt:n,pathExtExe:s}=Gr(t,e),i=[],u=l=>new Promise((m,c)=>{if(l===o.length)return e.all&&i.length?m(i):c(jr(t));const D=o[l],p=/^".*"$/.test(D)?D.slice(1,-1):D,f=Tr.join(p,t),h=!p&&/^\.[\\\/]/.test(t)?t.slice(0,2)+f:f;m(a(h,l,0))}),a=(l,m,c)=>new Promise((D,p)=>{if(c===n.length)return D(u(m+1));const f=n[c];_r(l+f,{pathExt:s},(h,g)=>{if(!h&&g)if(e.all)i.push(l+f);else return D(l+f);return D(a(l,m,c+1))})});return r?u(0).then(l=>r(null,l),r):u(0)},di=(t,e)=>{e=e||{};const{pathEnv:r,pathExt:o,pathExtExe:n}=Gr(t,e),s=[];for(let i=0;i<r.length;i++){const u=r[i],a=/^".*"$/.test(u)?u.slice(1,-1):u,l=Tr.join(a,t),m=!a&&/^\.[\\\/]/.test(t)?t.slice(0,2)+l:l;for(let c=0;c<o.length;c++){const D=m+o[c];try{if(_r.sync(D,{pathExt:n}))if(e.all)s.push(D);else return D}catch{}}}if(e.all&&s.length)return s;if(e.nothrow)return null;throw jr(t)};var pi=Hr;Hr.sync=di;var yt={exports:{}};const Ur=(t={})=>{const e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(o=>o.toUpperCase()==="PATH")||"Path"};yt.exports=Ur,yt.exports.default=Ur;var fi=yt.exports;const zr=L,hi=pi,gi=fi;function qr(t,e){const r=t.options.env||process.env,o=process.cwd(),n=t.options.cwd!=null,s=n&&process.chdir!==void 0&&!process.chdir.disabled;if(s)try{process.chdir(t.options.cwd)}catch{}let i;try{i=hi.sync(t.command,{path:r[gi({env:r})],pathExt:e?zr.delimiter:void 0})}catch{}finally{s&&process.chdir(o)}return i&&(i=zr.resolve(n?t.options.cwd:"",i)),i}function Ci(t){return qr(t)||qr(t,!0)}var yi=Ci,Et={};const Ft=/([()\][%!^"`<>&|;, *?])/g;function Ei(t){return t=t.replace(Ft,"^$1"),t}function Fi(t,e){return t=`${t}`,t=t.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),t=t.replace(/(?=(\\+?)?)\1$/,"$1$1"),t=`"${t}"`,t=t.replace(Ft,"^$1"),e&&(t=t.replace(Ft,"^$1")),t}Et.command=Ei,Et.argument=Fi;var wi=/^#!(.*)/;const vi=wi;var bi=(t="")=>{const e=t.match(vi);if(!e)return null;const[r,o]=e[0].replace(/#! ?/,"").split(" "),n=r.split("/").pop();return n==="env"?o:o?`${n} ${o}`:n};const wt=N,$i=bi;function Ai(t){const r=Buffer.alloc(150);let o;try{o=wt.openSync(t,"r"),wt.readSync(o,r,0,150,0),wt.closeSync(o)}catch{}return $i(r.toString())}var Pi=Ai;const Bi=L,Wr=yi,Kr=Et,xi=Pi,Mi=process.platform==="win32",Si=/\.(?:com|exe)$/i,Ri=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Oi(t){t.file=Wr(t);const e=t.file&&xi(t.file);return e?(t.args.unshift(t.file),t.command=e,Wr(t)):t.file}function Ii(t){if(!Mi)return t;const e=Oi(t),r=!Si.test(e);if(t.options.forceShell||r){const o=Ri.test(e);t.command=Bi.normalize(t.command),t.command=Kr.command(t.command),t.args=t.args.map(s=>Kr.argument(s,o));const n=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${n}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}function ki(t,e,r){e&&!Array.isArray(e)&&(r=e,e=null),e=e?e.slice(0):[],r=Object.assign({},r);const o={command:t,args:e,options:r,file:void 0,original:{command:t,args:e}};return r.shell?o:Ii(o)}var Li=ki;const vt=process.platform==="win32";function bt(t,e){return Object.assign(new Error(`${e} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${t.command}`,path:t.command,spawnargs:t.args})}function Ni(t,e){if(!vt)return;const r=t.emit;t.emit=function(o,n){if(o==="exit"){const s=Vr(n,e);if(s)return r.call(t,"error",s)}return r.apply(t,arguments)}}function Vr(t,e){return vt&&t===1&&!e.file?bt(e.original,"spawn"):null}function Ti(t,e){return vt&&t===1&&!e.file?bt(e.original,"spawnSync"):null}var _i={hookChildProcess:Ni,verifyENOENT:Vr,verifyENOENTSync:Ti,notFoundError:bt};const Yr=dn,$t=Li,At=_i;function Jr(t,e,r){const o=$t(t,e,r),n=Yr.spawn(o.command,o.args,o.options);return At.hookChildProcess(n,o),n}function ji(t,e,r){const o=$t(t,e,r),n=Yr.spawnSync(o.command,o.args,o.options);return n.error=n.error||At.verifyENOENTSync(n.status,o),n}oe.exports=Jr,oe.exports.spawn=Jr,oe.exports.sync=ji,oe.exports._parse=$t,oe.exports._enoent=At;var Gi=oe.exports,Hi=re(Gi);function Ui(t){const e=typeof t=="string"?`
23
23
  `:`
24
24
  `.charCodeAt(),r=typeof t=="string"?"\r":"\r".charCodeAt();return t[t.length-1]===e&&(t=t.slice(0,-1)),t[t.length-1]===r&&(t=t.slice(0,-1)),t}function Xr(t={}){const{env:e=process.env,platform:r=process.platform}=t;return r!=="win32"?"PATH":Object.keys(e).reverse().find(o=>o.toUpperCase()==="PATH")||"Path"}const zi=({cwd:t=q.cwd(),path:e=q.env[Xr()],preferLocal:r=!0,execPath:o=q.execPath,addExecPath:n=!0}={})=>{const s=t instanceof URL?ur(t):t,i=te.resolve(s),u=[];return r&&qi(u,i),n&&Wi(u,o,i),[...u,e].join(te.delimiter)},qi=(t,e)=>{let r;for(;r!==e;)t.push(te.join(e,"node_modules/.bin")),r=e,e=te.resolve(e,"..")},Wi=(t,e,r)=>{const o=e instanceof URL?ur(e):e;t.push(te.resolve(r,o,".."))},Ki=({env:t=q.env,...e}={})=>{t={...t};const r=Xr({env:t});return e.path=t[r],t[r]=zi(e),t},Vi=(t,e,r,o)=>{if(r==="length"||r==="prototype"||r==="arguments"||r==="caller")return;const n=Object.getOwnPropertyDescriptor(t,r),s=Object.getOwnPropertyDescriptor(e,r);!Yi(n,s)&&o||Object.defineProperty(t,r,s)},Yi=function(t,e){return t===void 0||t.configurable||t.writable===e.writable&&t.enumerable===e.enumerable&&t.configurable===e.configurable&&(t.writable||t.value===e.value)},Ji=(t,e)=>{const r=Object.getPrototypeOf(e);r!==Object.getPrototypeOf(t)&&Object.setPrototypeOf(t,r)},Xi=(t,e)=>`/* Wrapped ${t}*/
25
25
  ${e}`,Zi=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Qi=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),ea=(t,e,r)=>{const o=r===""?"":`with ${r.trim()}() `,n=Xi.bind(null,o,e.toString());Object.defineProperty(n,"name",Qi),Object.defineProperty(t,"toString",{...Zi,value:n})};function ta(t,e,{ignoreNonConfigurable:r=!1}={}){const{name:o}=t;for(const n of Reflect.ownKeys(e))Vi(t,e,n,r);return Ji(t,e),ea(t,e,o),t}const ke=new WeakMap,Zr=(t,e={})=>{if(typeof t!="function")throw new TypeError("Expected a function");let r,o=0;const n=t.displayName||t.name||"<anonymous>",s=function(...i){if(ke.set(s,++o),o===1)r=t.apply(this,i),t=null;else if(e.throw===!0)throw new Error(`Function \`${n}\` can only be called once`);return r};return ta(s,t),ke.set(s,o),s};Zr.callCount=t=>{if(!ke.has(t))throw new Error(`The given function \`${t.name}\` is not wrapped by the \`onetime\` package`);return ke.get(t)};const ra=()=>{const t=eo-Qr+1;return Array.from({length:t},oa)},oa=(t,e)=>({name:`SIGRT${e+1}`,number:Qr+e,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),Qr=34,eo=64,na=[{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"}],to=()=>{const t=ra();return[...na,...t].map(sa)},sa=({name:t,number:e,description:r,action:o,forced:n=!1,standard:s})=>{const{signals:{[t]:i}}=cr,u=i!==void 0;return{name:t,number:u?i:e,description:r,supported:u,action:o,forced:n,standard:s}},ia=()=>{const t=to();return Object.fromEntries(t.map(aa))},aa=({name:t,number:e,description:r,supported:o,action:n,forced:s,standard:i})=>[t,{name:t,number:e,description:r,supported:o,action:n,forced:s,standard:i}],ua=ia(),ca=()=>{const t=to(),e=eo+1,r=Array.from({length:e},(o,n)=>la(n,t));return Object.assign({},...r)},la=(t,e)=>{const r=Da(t,e);if(r===void 0)return{};const{name:o,description:n,supported:s,action:i,forced:u,standard:a}=r;return{[t]:{name:o,number:t,description:n,supported:s,action:i,forced:u,standard:a}}},Da=(t,e)=>{const r=e.find(({name:o})=>cr.signals[o]===t);return r!==void 0?r:e.find(o=>o.number===t)};ca();const ma=({timedOut:t,timeout:e,errorCode:r,signal:o,signalDescription:n,exitCode:s,isCanceled:i})=>t?`timed out after ${e} milliseconds`:i?"was canceled":r!==void 0?`failed with ${r}`:o!==void 0?`was killed with ${o} (${n})`:s!==void 0?`failed with exit code ${s}`:"failed",ro=({stdout:t,stderr:e,all:r,error:o,signal:n,exitCode:s,command:i,escapedCommand:u,timedOut:a,isCanceled:l,killed:m,parsed:{options:{timeout:c,cwd:D=q.cwd()}}})=>{s=s===null?void 0:s,n=n===null?void 0:n;const p=n===void 0?void 0:ua[n].description,f=o&&o.code,g=`Command ${ma({timedOut:a,timeout:c,errorCode:f,signal:n,signalDescription:p,exitCode:s,isCanceled:l})}: ${i}`,y=Object.prototype.toString.call(o)==="[object Error]",v=y?`${g}
@@ -29,7 +29,7 @@ ${o.message}`:g,O=[v,e,t].filter(Boolean).join(`
29
29
 
30
30
  ${i.body}`:""}${i.footer?`
31
31
 
32
- ${i.footer}`:""}`})).slice(0,o)}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:`${mo(e)}...`,value:e}]}catch{return[]}return e.map(r=>{try{return{title:`${mo(r)}...`,value:r}}catch{return{title:"",value:""}}})}}var po="2.2.3",hu="A Reactive CLI that generates git commit messages with various AI";class E extends Error{}const kt=" ",ae=t=>{t instanceof Error&&(t instanceof E||(t.stack&&console.error(C.dim(t.stack.split(`
32
+ ${i.footer}`:""}`})).slice(0,o)}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:`${mo(e)}...`,value:e}]}catch{return[]}return e.map(r=>{try{return{title:`${mo(r)}...`,value:r}}catch{return{title:"",value:""}}})}}var po="2.2.5",hu="A Reactive CLI that generates git commit messages with various AI";class E extends Error{}const kt=" ",ae=t=>{t instanceof Error&&(t instanceof E||(t.stack&&console.error(C.dim(t.stack.split(`
33
33
  `).slice(1).join(`
34
34
  `))),console.error(`
35
35
  ${kt}${C.dim(`aicommit2 v${po}`)}`),console.error(`
@@ -88,7 +88,7 @@ ${Ue(o,n)}`}},z=t=>{const{codeReviewPromptPath:e,locale:r}=t,o=`I'll give you th
88
88
  Please structure your response with appropriate Markdown headings, code blocks, and bullet points.`;if(!e)return o;try{const n=N.readFileSync(L.resolve(e),"utf-8");return`${go(n,t)}`}catch{return o}},yo=async t=>{if(t.systemPromptPath)try{N.readFileSync(L.resolve(t.systemPromptPath),"utf-8")}catch{throw new E(`Error reading system prompt file: ${t.systemPromptPath}`)}if(t.codeReview&&t.codeReviewPromptPath)try{N.readFileSync(L.resolve(t.codeReviewPromptPath),"utf-8")}catch{throw new E(`Error reading code review prompt file: ${t.codeReviewPromptPath}`)}};class Eo extends G{constructor(e){super(e),this.params=e,this.handleError$=r=>{const o=r.error?.error?.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return S({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#AE5630",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Anthropic]"),this.errorPrefix=C.red.bold("[Anthropic]"),this.anthropic=new vn({apiKey:this.params.config.key})}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,logging:i,temperature:u,locale:a,generate:l,type:m,maxLength:c,maxTokens:D,topP:p,model:f}=this.params.config,h={...j,locale:a,maxLength:c,type:m,generate:l,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},g=e==="review"?z(h):U(h),y={max_tokens:D,temperature:u,system:g,messages:[{role:"user",content:`Here is the diff: ${r}`}],top_p:p,model:f},O=(await this.anthropic.messages.create(y)).content.map(({text:Q})=>Q).join("");return i&&H("Anthropic",r,g,O,e),e==="review"?this.sanitizeResponse(O):this.parseMessage(O,m,l)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new E(`Error connecting to ${o.hostname} (${o.syscall})`):o}}}class ge{constructor(e={}){if(!e.method)throw new Error("method should be defined!");if(!e.baseURL)throw new Error("baseURL should be defined!");this.config={...e},this.axiosInstance=$n.create(this.config)}setHeaders(e){return this.config.headers=e,this}setParams(e){return this.config.params=e,this}setBody(e){return this.config.data=e,this}addBody(e){return this.config.data={...this.config.data,...e},this}setMethod(e){return this.config.method=e,this}async execute(){try{return await this.axiosInstance.request(this.config)}catch(e){throw e}}}class Fo extends G{constructor(e){super(e),this.params=e,this.host="https://codestral.mistral.ai",this.apiKey="",this.handleError$=r=>{const o=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return S({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#e28c58",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Codestral]"),this.errorPrefix=C.red.bold("[Codestral]"),this.apiKey=this.params.config.key}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,logging:i,locale:u,generate:a,type:l,maxLength:m}=this.params.config,c={...j,locale:u,maxLength:m,type:l,generate:a,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},D=e==="review"?z(c):U(c);this.checkAvailableModels();const p=await this.createChatCompletions(D,e);return i&&H("Codestral",r,D,p,e),e==="review"?this.sanitizeResponse(p):this.parseMessage(p,l,a)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new E(`Error connecting to ${o.hostname} (${o.syscall})`):o}}checkAvailableModels(){if(["codestral-latest","codestral-2501"].includes(this.params.config.model))return!0;throw new Error("Invalid model type of Codestral AI")}async createChatCompletions(e,r){const o=new ge({method:"POST",baseURL:`${this.host}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.model,messages:[{role:"system",content:e},{role:"user",content:`Here is the diff: ${this.params.stagedDiff.diff}`}],temperature:this.params.config.temperature,top_p:this.params.config.topP,max_tokens:this.params.config.maxTokens,stream:!1,safe_prompt:!1,random_seed:Ge(10,1e3)});r==="commit"&&o.addBody({response_format:{type:"json_object"}});const s=(await o.execute()).data;if(!s.choices||s.choices.length===0||!s.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return s.choices[0].message.content}}class wo extends G{constructor(e){super(e),this.params=e,this.handleError$=r=>{const o=/"message":\s*"([^"]*)"/,n=r.message.match(o);let s=r?.body?.message;n&&n[1]&&(s=n[1]);const i=`${r.statusCode} ${s}`;return S({name:`${this.errorPrefix} ${i}`,value:s,isError:!0,disabled:!0})},this.colors={primary:"#D18EE2",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Cohere]"),this.errorPrefix=C.red.bold("[Cohere]"),this.cohere=new An({token:this.params.config.key})}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,logging:i,temperature:u,locale:a,generate:l,type:m,maxLength:c,maxTokens:D,topP:p,model:f}=this.params.config,h={...j,locale:a,maxLength:c,type:m,generate:l,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},g=e==="review"?z(h):U(h),y=await this.cohere.chat({chatHistory:g?[{role:"SYSTEM",message:g}]:[],message:`Here is the diff: ${r}`,connectors:[{id:"web-search"}],maxTokens:D,temperature:u,model:this.params.config.model,seed:Ge(10,1e3),p:this.params.config.topP});return i&&H("Cohere",r,g,y.text,e),e==="review"?this.sanitizeResponse(y.text):this.parseMessage(y.text,m,l)}catch(r){const o=r;throw o instanceof Pn?new E("Request timed out error!"):o}}}class vo extends G{constructor(e){super(e),this.params=e,this.host="https://api.deepseek.com",this.handleError$=r=>{const o=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return S({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#53a3f9",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[DeepSeek]"),this.errorPrefix=C.red.bold("[DeepSeek]"),this.deepSeek=new it({baseURL:this.host,apiKey:this.params.config.key})}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,logging:i,locale:u,generate:a,type:l,maxLength:m}=this.params.config,c={...j,locale:u,maxLength:m,type:l,generate:a,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},D=e==="review"?z(c):U(c);this.checkAvailableModels();const p=await this.createChatCompletions(D);return i&&H("DeepSeek",r,D,p,e),e==="review"?this.sanitizeResponse(p):this.parseMessage(p,l,a)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new E(`Error connecting to ${o.hostname} (${o.syscall})`):o}}checkAvailableModels(){if(["deepseek-reasoner","deepseek-chat"].includes(this.params.config.model))return!0;throw new Error("Invalid model type of DeepSeek")}async createChatCompletions(e){return(await this.deepSeek.chat.completions.create({messages:[{role:"system",content:e},{role:"user",content:`Here is the diff: ${this.params.stagedDiff.diff}`}],model:this.params.config.model,max_tokens:this.params.config.maxTokens,top_p:this.params.config.topP,temperature:this.params.config.temperature},{timeout:this.params.config.timeout})).choices[0].message.content||""}}class bo extends G{constructor(e){super(e),this.params=e,this.handleError$=r=>{const o=r.message||r.toString(),n=/(\[.*?\]\s*[^[]*)/g,s=[...o.matchAll(n)],i=[];s.forEach(a=>i.push(a[1]));const u=i[1]||"An error occurred";return S({name:`${this.errorPrefix} ${u}`,value:u,isError:!0,disabled:!0})},this.colors={primary:"#0077FF",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Gemini]"),this.errorPrefix=C.red.bold("[Gemini]"),this.genAI=new Bn(this.params.config.key)}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,logging:s,locale:i,codeReviewPromptPath:u,generate:a,type:l,maxLength:m}=this.params.config,c=this.params.config.maxTokens,D={...j,locale:i,maxLength:m,type:l,generate:a,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:u},p=e==="review"?z(D):U(D),f={maxOutputTokens:c,temperature:this.params.config.temperature,topP:this.params.config.topP},v=(await this.genAI.getGenerativeModel({model:this.params.config.model,systemInstruction:p,generationConfig:f,safetySettings:[{category:Pe.HARM_CATEGORY_HATE_SPEECH,threshold:Be.BLOCK_LOW_AND_ABOVE},{category:Pe.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:Be.BLOCK_LOW_AND_ABOVE},{category:Pe.HARM_CATEGORY_HARASSMENT,threshold:Be.BLOCK_LOW_AND_ABOVE},{category:Pe.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:Be.BLOCK_LOW_AND_ABOVE}]}).generateContent(`Here is the diff: ${r}`)).response.text();return s&&H("Gemini",r,p,v,e),e==="review"?this.sanitizeResponse(v):this.parseMessage(v,l,a)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new E(`Error connecting to ${o.hostname} (${o.syscall})`):o}}}class $o extends G{constructor(e){super(e),this.params=e,this.handleError$=r=>{let o="N/A",n="An error occurred";r instanceof fr.APIError&&(o=`${r.status}`,n=r.name);const s=`${o} ${n}`;return S({name:`${this.errorPrefix} ${s}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#f55036",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Groq]"),this.errorPrefix=C.red.bold("[Groq]"),this.groq=new fr({apiKey:this.params.config.key})}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,logging:i,locale:u,temperature:a,generate:l,type:m,maxLength:c}=this.params.config,D=this.params.config.maxTokens,p={...j,locale:u,maxLength:c,type:m,generate:l,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},f=e==="review"?z(p):U(p),g=(await this.groq.chat.completions.create({messages:[{role:"system",content:f},{role:"user",content:`Here is the diff: ${r}`}],model:this.params.config.model,max_tokens:D,top_p:this.params.config.topP,temperature:a},{timeout:this.params.config.timeout})).choices[0].message.content||"";return i&&H("Groq",r,f,g,e),e==="review"?this.sanitizeResponse(g):this.parseMessage(g,m,l)}catch(r){throw r}}}class Ao extends G{constructor(e){super(e),this.params=e,this.headers={accept:"*/*","accept-language":"en-US,en;q=0.9","sec-ch-ua":'"Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"Windows"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin",origin:"https://huggingface.co","Referrer-Policy":"strict-origin-when-cross-origin"},this.models=[],this.currentModelId=null,this.currentConversation=void 0,this.currentConversionID=void 0,this.cookie="",this.colors={primary:"#FED21F",secondary:"#000"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[HuggingFace]"),this.errorPrefix=C.red.bold("[HuggingFace]"),this.cookie=this.params.config.cookie}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{await this.intialize();const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,logging:i,locale:u,generate:a,type:l,maxLength:m}=this.params.config,c={...j,locale:u,maxLength:m,type:l,generate:a,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},D=e==="review"?z(c):U(c),p=await this.getNewChat(D),h=await(await this.sendMessage(`Here is the diff: ${r}`,p.id)).completeResponsePromise();return await this.deleteConversation(p.id),i&&H("HuggingFace",r,D,h,e),e==="review"?this.sanitizeResponse(h):this.parseMessage(h,l,a)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new E(`Error connecting to ${o.hostname} (${o.syscall})`):o}}async intialize(){const e=await this.getRemoteLlms(),r=e.find(o=>o.name?.toLowerCase()===this.params.config.model.toLowerCase());if(r){this.currentModel=r,this.currentModelId=r.id;return}this.currentModel=e[0],this.currentModelId=e[0].id}async getRemoteLlms(){const e=await fetch("https://huggingface.co/chat/__data.json",{headers:{...this.headers,cookie:this.cookie},body:null,method:"GET"});if(e.status!==200)throw new Error(`Failed to get remote LLMs with status code: ${e.status}`);const o=(await e.json()).nodes[0].data,n=o[o[0].models],s=[],i=u=>u===-1?null:o[u];for(const u of n){const a=o[u];if(o[a.unlisted])continue;const l={id:i(a.id),name:i(a.name),displayName:i(a.displayName),preprompt:i(a.preprompt),promptExamples:[],websiteUrl:i(a.websiteUrl),description:i(a.description),datasetName:i(a.datasetName),datasetUrl:i(a.datasetUrl),modelUrl:i(a.modelUrl),parameters:{}},m=i(a.promptExamples);if(m!==null){const p=m.map(f=>i(f));l.promptExamples=p.map(f=>({title:o[f.title],prompt:o[f.prompt]}))}const c=i(a.parameters),D={};for(const[p,f]of Object.entries(c)){if(f===-1){D[p]=null;continue}if(Array.isArray(o[f])){D[p]=o[f].map(h=>o[h]);continue}D[p]=o[f]}l.parameters=D,s.push(l)}return this.models=s,s}async getNewChat(e){const r={model:this.currentModelId,preprompt:e};let o=0;for(;o<5;){const n=await fetch("https://huggingface.co/chat/conversation",{headers:{...this.headers,"content-type":"application/json",cookie:this.cookie,Referer:"https://huggingface.co/chat/"},body:JSON.stringify(r),method:"POST"}),{conversationId:s}=await n.json();if(s){this.currentConversionID=s;break}else o++}if(!this.currentConversionID)throw new Error("Failed to create new conversion");return await this.getConversationHistory(this.currentConversionID)}async getConversationHistory(e){if(!e)throw new Error("conversationId is required for getConversationHistory");const r=await fetch("https://huggingface.co/chat/conversation/"+e+"/__data.json",{headers:{...this.headers,cookie:this.cookie,Referer:"https://huggingface.co/chat/"},body:null,method:"GET"});if(r.status!=200)throw new Error("Unable get conversation details "+r);{const o=await r.json();return this.metadataParser(o,e)}}metadataParser(e,r){const o={id:"",model:"",systemPrompt:"",title:"",history:[]},n=e.nodes[1].data,s=n[n[0].model],i=n[n[0].preprompt],u=n[n[0].title],a=n[n[0].messages],l=[];for(const m of a){const c=n[m],D=new Date(n[c.createdAt][1]).getTime()/1e3,p=new Date(n[c.updatedAt][1]).getTime()/1e3;l.push({id:n[c.id],role:n[c.from],content:n[c.content],createdAt:D,updatedAt:p})}return o.id=r,o.model=s,o.systemPrompt=i,o.title=u,o.history=l,this.currentConversation=o,o}async sendMessage(e,r){if(e==="")throw new Error("the prompt can not be empty.");if(!r&&!this.currentConversionID?await this.getNewChat():r?(this.currentConversionID=r,await this.getConversationHistory(r)):this.currentConversionID&&await this.getConversationHistory(this.currentConversionID),!this.currentConversation)throw new Error("Failed to create new conversion");const o={inputs:e,id:this.currentConversation.history[this.currentConversation.history.length-1].id,is_retry:!1,is_continue:!1,web_search:!1,tools:[]},n=new FormData;n.append("data",JSON.stringify(o));const s=await fetch("https://huggingface.co/chat/conversation/"+this.currentConversionID,{headers:{...this.headers,cookie:this.cookie,Referer:"https://huggingface.co/chat/conversation/"+this.currentConversionID},body:n,method:"POST"});function i(D){try{const p=D.split(`
89
89
  `),f=[];for(const h of p)h.trim()&&f.push(JSON.parse(h));return f}catch{return[{}]}}const u=new TextDecoder;let a="";const l=new TransformStream({async transform(D,p){const f=u.decode(D);try{const h=i(f);for(const g of h)g.type==="finalAnswer"?(a=g?.text||"",p.terminate()):g.type==="stream"&&p.enqueue(g?.token||"")}catch{throw new Error("Error during parsing response")}}}),m=s.body?.pipeThrough(l);async function c(){return new Promise(async(D,p)=>{try{if(!m)p("ModifiedStream undefined");else{const f=m.getReader();for(;;){const{done:h,value:g}=await f.read();if(h){D(a);break}}}}catch(f){p(f)}})}return{id:this.currentConversionID,stream:m,completeResponsePromise:c}}async deleteConversation(e){return(await fetch(`https://huggingface.co/chat/conversation/${e}`,{headers:{...this.headers,cookie:this.cookie,Referer:"https://huggingface.co/chat/"},body:null,method:"DELETE"})).json()}}class Po extends G{constructor(e){super(e),this.params=e,this.host="https://api.mistral.ai",this.apiKey="",this.handleError$=r=>{const o=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return S({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#ff7000",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[MistralAI]"),this.errorPrefix=C.red.bold("[MistralAI]"),this.apiKey=this.params.config.key}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,logging:i,locale:u,generate:a,type:l,maxLength:m}=this.params.config,c={...j,locale:u,maxLength:m,type:l,generate:a,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},D=e==="review"?z(c):U(c);await this.checkAvailableModels();const p=await this.createChatCompletions(D,`Here is the diff: ${r}`);return i&&H("MistralAI",r,D,p,e),e==="review"?this.sanitizeResponse(p):this.parseMessage(p,l,a)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new E(`Error connecting to ${o.hostname} (${o.syscall})`):o}}async checkAvailableModels(){if((await this.getAvailableModels()).includes(this.params.config.model))return!0;throw new Error(`Invalid model type of Mistral AI: ${this.params.config.model}`)}async getAvailableModels(){return(await new ge({method:"GET",baseURL:`${this.host}/v1/models`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).execute()).data.data.filter(r=>r.object==="model").map(r=>r.id)}async createChatCompletions(e,r){const n=(await new ge({method:"POST",baseURL:`${this.host}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.model,messages:[{role:"system",content:e},{role:"user",content:r}],temperature:this.params.config.temperature,top_p:this.params.config.topP,max_tokens:this.params.config.maxTokens,stream:!1,safe_prompt:!1,random_seed:Ge(10,1e3)}).execute()).data;if(!n.choices||n.choices.length===0||!n.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return n.choices[0].message.content}}const{hasOwnProperty:Lt}=Object.prototype,ze=typeof process<"u"&&process.platform==="win32"?`\r
90
90
  `:`
91
- `,Nt=(t,e)=>{const r=[];let o="";typeof e=="string"?e={section:e,whitespace:!1}:(e=e||Object.create(null),e.whitespace=e.whitespace===!0);const n=e.whitespace?" = ":"=";for(const s of Object.keys(t)){const i=t[s];if(i&&Array.isArray(i))for(const u of i)o+=ue(s+"[]")+n+ue(u)+ze;else i&&typeof i=="object"?r.push(s):o+=ue(s)+n+ue(i)+ze}e.section&&o.length&&(o="["+ue(e.section)+"]"+ze+o);for(const s of r){const i=Bo(s).join("\\."),u=(e.section?e.section+".":"")+i,{whitespace:a}=e,l=Nt(t[s],{section:u,whitespace:a});o.length&&l.length&&(o+=ze),o+=l}return o},Bo=t=>t.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(e=>e.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),xo=t=>{const e=Object.create(null);let r=e,o=null;const n=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,s=t.split(/[\r\n]+/g);for(const u of s){if(!u||u.match(/^\s*[;#]/))continue;const a=u.match(n);if(!a)continue;if(a[1]!==void 0){if(o=qe(a[1]),o==="__proto__"){r=Object.create(null);continue}r=e[o]=e[o]||Object.create(null);continue}const l=qe(a[2]),m=l.length>2&&l.slice(-2)==="[]",c=m?l.slice(0,-2):l;if(c==="__proto__")continue;const D=a[3]?qe(a[4]):!0,p=D==="true"||D==="false"||D==="null"?JSON.parse(D):D;m&&(Lt.call(r,c)?Array.isArray(r[c])||(r[c]=[r[c]]):r[c]=[]),Array.isArray(r[c])?r[c].push(p):r[c]=p}const i=[];for(const u of Object.keys(e)){if(!Lt.call(e,u)||typeof e[u]!="object"||Array.isArray(e[u]))continue;const a=Bo(u);r=e;const l=a.pop(),m=l.replace(/\\\./g,".");for(const c of a)c!=="__proto__"&&((!Lt.call(r,c)||typeof r[c]!="object")&&(r[c]=Object.create(null)),r=r[c]);r===e&&m===l||(r[m]=e[u],i.push(u))}for(const u of i)delete e[u];return e},Mo=t=>t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"),ue=t=>typeof t!="string"||t.match(/[=\r\n]/)||t.match(/^\[/)||t.length>1&&Mo(t)||t!==t.trim()?JSON.stringify(t):t.split(";").join("\\;").split("#").join("\\#"),qe=(t,e)=>{if(t=(t||"").trim(),Mo(t)){t.charAt(0)==="'"&&(t=t.slice(1,-1));try{t=JSON.parse(t)}catch{}}else{let r=!1,o="";for(let n=0,s=t.length;n<s;n++){const i=t.charAt(n);if(r)"\\;#".indexOf(i)!==-1?o+=i:o+="\\"+i,r=!1;else{if(";#".indexOf(i)!==-1)break;i==="\\"?r=!0:o+=i}}return r&&(o+="\\"),o.trim()}return t};var wu={parse:xo,decode:xo,stringify:Nt,encode:Nt,safe:ue,unsafe:qe},Tt=re(wu);const So=t=>I.lstat(t).then(()=>!0,()=>!1),vu=["","conventional","gitmoji"],_t="http://localhost:11434",{hasOwnProperty:bu}=Object.prototype,We=(t,e)=>bu.call(t,e),ce=["OPENAI","OLLAMA","HUGGINGFACE","GEMINI","ANTHROPIC","MISTRAL","CODESTRAL","COHERE","GROQ","PERPLEXITY","DEEPSEEK"],$u=t=>{const e=Object.keys(t),r=new Set([...ce,...e.filter(o=>/^[A-Z][A-Z0-9_]*$/.test(o))]);return Array.from(r)},F=(t,e,r)=>{if(!e)throw new E(`Invalid config property ${t}: ${r}`)},d={systemPrompt(t){return t||""},systemPromptPath(t){return t||""},codeReviewPromptPath(t){return t||""},timeout(t){if(!t)return 1e4;F("timeout",/^\d+$/.test(t),"Must be an integer");const e=Number(t);return F("timeout",e>=500,"Must be greater than 500ms"),e},temperature(t){if(!t)return .7;F("temperature",/^(2|\d)(\.\d{1,2})?$/.test(t),"Must be decimal between 0 and 2");const e=Number(t);return F("temperature",e>0,"Must be greater than 0"),F("temperature",e<=2,"Must be less than or equal to 2"),e},maxTokens(t){return t?(F("maxTokens",/^\d+$/.test(t),"Must be an integer"),Number(t)):1024},logging(t){return typeof t=="boolean"?t:t==null?!0:(F("logging",/^(?:true|false)$/.test(t),"Must be a boolean(true or false)"),t==="true")},locale(t){return t?(F("locale",t,"Cannot be empty"),F("locale",/^[a-z-]+$/i.test(t),"Must be a valid locale (letters and dashes/underscores). You can consult the list of codes in: https://wikipedia.org/wiki/List_of_ISO_639-1_codes"),t):"en"},generate(t){if(!t)return 1;F("generate",/^\d+$/.test(t),"Must be an integer");const e=Number(t);return F("generate",e>0,"Must be greater than 0"),F("generate",e<=5,"Must be less or equal to 5"),e},type(t){return t?(F("type",vu.includes(t),"Invalid commit type"),t):"conventional"},maxLength(t){if(!t)return 50;F("maxLength",/^\d+$/.test(t),"Must be an integer");const e=Number(t);return F("maxLength",e>=20,"Must be greater than 20 characters"),e},includeBody(t){return typeof t=="boolean"?t:t==null?!1:(F("includeBody",/^(?:true|false)$/.test(t),"Must be a boolean(true or false)"),t==="true")},exclude:t=>t?(typeof t=="string"?t?.split(","):t).map(r=>r.trim()).filter(r=>!!r&&r.length>0):[],topP:t=>{if(!t)return .9;F("topP",/^(1|\d)(\.\d{1,2})?$/.test(t),"Must be decimal between 0 and 1");const e=Number(t);return F("topP",e>0,"Must be greater than 0"),F("topP",e<=1,"Must be less than or equal to 1"),e},codeReview(t){return typeof t=="boolean"?t:t==null?!1:(F("codeReview",/^(?:true|false)$/.test(t),"Must be a boolean(true or false)"),t==="true")},disabled(t){return typeof t=="boolean"?t:t==null?!1:(F("disabled",/^(?:true|false)$/.test(t),"Must be a boolean(true or false)"),t==="true")},watchMode(t){return typeof t=="boolean"?t:t==null?!1:(F("watchMode",/^(?:true|false)$/.test(t),"Must be a boolean(true or false)"),t==="true")}},Ce={OPENAI:{key:t=>t||"",model:t=>t||"gpt-4o-mini",url:t=>t?(F("OPENAI.url",/^https?:\/\//.test(t),"Must be a valid URL"),t):"https://api.openai.com",path:t=>t||"/v1/chat/completions",proxy:t=>t||"",topP:d.topP,systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,timeout:d.timeout,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode},HUGGINGFACE:{cookie:t=>t||"",model:t=>t?(F("HUGGINGFACE.model",["CohereForAI/c4ai-command-r-plus","meta-llama/Meta-Llama-3-70B-Instruct","HuggingFaceH4/zephyr-orpo-141b-A35b-v0.1","mistralai/Mixtral-8x7B-Instruct-v0.1","NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO","01-ai/Yi-1.5-34B-Chat","mistralai/Mistral-7B-Instruct-v0.2","microsoft/Phi-3-mini-4k-instruct"].includes(t),"Invalid model type of HuggingFace chat"),t):"CohereForAI/c4ai-command-r-plus",systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode},GEMINI:{key:t=>t||"",model:t=>!t||t.length===0?"gemini-2.0-flash-exp":(F("GEMINI.model",["gemini-2.0-flash-exp","gemini-1.5-flash","gemini-1.5-flash-8b","gemini-1.5-pro"].includes(t),"Invalid model type of Gemini"),t),systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,topP:d.topP,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode},ANTHROPIC:{key:t=>t||"",model:t=>!t||t.length===0?"claude-3-5-haiku-20241022":(F("ANTHROPIC.model",["claude-3-5-sonnet-20241022","claude-3-5-haiku-20241022","claude-3-opus-20240229","claude-3-sonnet-20240229","claude-3-haiku-20240307"].includes(t),"Invalid model type of Anthropic"),t),systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,topP:d.topP,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode},MISTRAL:{key:t=>t||"",model:t=>!t||t.length===0?"pixtral-12b-2409":(F("MISTRAL.model",["codestral-latest","mistral-large-latest","pixtral-large-latest","ministral-8b-latest","mistral-small-latest","mistral-embed","mistral-moderation-latest"].includes(t),"Invalid model type of Mistral AI"),t),systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,timeout:d.timeout,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,topP:d.topP,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode},CODESTRAL:{key:t=>t||"",model:t=>!t||t.length===0?"codestral-latest":(F("CODESTRAL.model",["codestral-latest","codestral-2501"].includes(t),"Invalid model type of Codestral"),t),topP:d.topP,systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,timeout:d.timeout,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode},OLLAMA:{model:t=>t?(typeof t=="string"?t?.split(","):t).map(r=>r.trim()).filter(r=>!!r&&r.length>0):[],host:t=>t?(F("OLLAMA.host",/^https?:\/\//.test(t),"Must be a valid URL"),t):_t,timeout:t=>{if(!t)return 1e5;F("OLLAMA.timeout",/^\d+$/.test(t),"Must be an integer");const e=Number(t);return F("OLLAMA.timeout",e>=500,"Must be greater than 500ms"),e},auth:t=>t||"",key:t=>t||"",numCtx:t=>{if(!t)return 2048;F("OLLAMA.numCtx",/^\d+$/.test(t),"Must be an integer");const e=Number(t);return F("OLLAMA.numCtx",e>=2048,"Must be greater than 2048"),e},systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,temperature:d.temperature,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,topP:d.topP,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode},COHERE:{key:t=>t||"",model:t=>!t||t.length===0?"command":(F("COHERE.model",["command-r7b-12-2024","command-r-plus-08-2024","command-r-plus-04-2024","command-r-plus","command-r-08-2024","command-r-03-2024","command-r","command","command-nightly","command-light","command-light-nightly","c4ai-aya-expanse-8b","c4ai-aya-expanse-32b"].includes(t),"Invalid model type of Cohere"),t),systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,topP:d.topP,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode},GROQ:{key:t=>t||"",model:t=>!t||t.length===0?"gemma2-9b-it":(F("GROQ.model",["distil-whisper-large-v3-en","gemma2-9b-it","llama-3.3-70b-versatile","llama-3.1-8b-instant","llama-guard-3-8b","llama3-70b-8192","llama3-8b-8192","mixtral-8x7b-32768","whisper-large-v3","whisper-large-v3-turbo","llama-3.3-70b-specdec","llama-3.2-1b-preview","llama-3.2-3b-preview","llama-3.2-11b-vision-preview","llama-3.2-90b-vision-preview"].includes(t),"Invalid model type of Groq"),t),systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,timeout:d.timeout,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,topP:d.topP,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode},PERPLEXITY:{key:t=>t||"",model:t=>!t||t.length===0?"sonar":(F("PERPLEXITY.model",["sonar-pro","sonar","llama-3.1-sonar-small-128k-online","llama-3.1-sonar-large-128k-online","llama-3.1-sonar-huge-128k-online"].includes(t),"Invalid model type of Perplexity"),t),topP:d.topP,systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,timeout:d.timeout,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode},DEEPSEEK:{key:t=>t||"",model:t=>!t||t.length===0?"deepseek-chat":(console.log(t),F("DEEPSEEK.model",["deepseek-reasoner","deepseek-chat"].includes(t),"Invalid model type of DeepSeek"),t),topP:d.topP,systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,timeout:d.timeout,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode}},Ke=L.join(st.homedir(),".aicommit2"),Au=(t=[])=>{const e={};for(const r of t)if(r.startsWith("--")){const[o,n]=r.slice(2).split("="),[s,i]=o.split(".");s&&i&&s in Ce?(e[s]||(e[s]={}),e[s][i]=n):e[o]=n}return e},jt=async()=>{if(!await So(Ke))return Object.create(null);const e=await I.readFile(Ke,"utf8");let r=Tt.parse(e);return We(r,"OLLAMA")&&We(r.OLLAMA,"model")&&(r={...r,OLLAMA:{...r.OLLAMA,model:typeof r.OLLAMA.model=="string"?[r.OLLAMA.model]:r.OLLAMA.model}}),We(r,"exclude")&&(r={...r,exclude:typeof r.exclude=="string"?[r.exclude]:r.exclude}),r},Ve=async(t,e=[])=>{const r=await jt(),o=Au(e),n={...t,...o},s={},i=$u(r),u=(a,l)=>{const m=n[`${a}.${l}`]??n[a]?.[l],c=r[a]?.[l],D=n[l]??r[l];return m!==void 0?m:c!==void 0?c:D};for(const[a,l]of Object.entries(d)){const m=n[a]??r[a];s[a]=l(m)}for(const a of i){s[a]={};const l=Ce[a]||Ye(a);for(const[m,c]of Object.entries(l)){const D=u(a,m);s[a][m]=c(D)}}return s},Pu=async t=>{const e=await jt();for(const[r,o]of t){const[n,s]=r.split(".");if(!s){const a=d[r];if(!a)throw new E(`Invalid config property: ${r}`);e[r]=a(o);continue}if(e[n]||(e[n]={}),ce.includes(n)){const a=Ce[n][s];if(!a)throw new E(`Invalid config property: ${r}`);e[n][s]=a(o);continue}if(!/^[A-Z][A-Z0-9_]*$/.test(n))throw new E(`Invalid service name: ${n}. Service names must be uppercase letters, numbers, and underscores.`);const u=Ye(n);if(!u[s])throw new E(`Invalid config property for custom service: ${r}`);try{e[n][s]=u[s](o)}catch(a){throw a instanceof E?a:new E(`Invalid value for ${r}: ${a.message}`)}}await I.writeFile(Ke,Tt.stringify(e),"utf8")},Bu=async t=>{const e=await jt();for(const[r,o]of t){const[n,s]=r.split("."),i=e[n];if(n==="OLLAMA"&&s==="model"){i||(e[n]={});const a=e[n][s]||[];e[n][s]=He([...a,o]);continue}if(i&&i.compatible===!0){i||(e[n]={});const a=Ye(n);if(!a[s])throw new E(`Invalid config property: ${r}`);try{e[n][s]=a[s](o)}catch(l){throw l instanceof E?l:new E(`Invalid value for ${r}: ${l.message}`)}continue}if(n in Ce){i||(e[n]={});const a=Ce[n][s];if(!a)throw new E(`Invalid config property: ${r}`);e[n][s]=a(o)}else{const a=Ye(n);if(!a[s])throw new E(`Invalid config property: ${r}`);e[n]||(e[n]={}),e[n][s]=a[s](o)}}await I.writeFile(Ke,Tt.stringify(e),"utf8")},Ye=t=>({compatible:e=>typeof e=="boolean"?e:e==null?!1:(F("compatible",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"),url:e=>e?(F(`${t}.url`,/^https?:\/\//.test(e),"Must be a valid URL"),e):"",path:e=>e||"",key:e=>e||"",model:e=>e||"",systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,timeout:d.timeout,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,topP:d.topP,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode});class Ro extends G{constructor(e){super(e),this.params=e,this.host=_t,this.model="",this.key="",this.auth="",this.handleError$=r=>{if(r.response&&r.response.data?.error)return S({name:`${this.errorPrefix} ${r.response.data?.error}`,value:r.response.data?.error,isError:!0,disabled:!0});const o=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return S({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#FFF",secondary:"#000"},this.model=this.params.keyName,this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[${je(this.model)}]`),this.errorPrefix=C.red.bold(`[${je(this.model)}]`),this.host=this.params.config.host||_t,this.auth=this.params.config.auth||"Bearer",this.key=this.params.config.key||"",this.ollama=new xn({host:this.host,...this.key&&{headers:{Authorization:`${this.auth} ${this.key}`}}})}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,logging:i,locale:u,generate:a,type:l,maxLength:m}=this.params.config,c={...j,locale:u,maxLength:m,type:l,generate:a,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},D=e==="review"?z(c):U(c);await this.checkIsAvailableOllama();const p=await this.createChatCompletions(D,`Here is the diff: ${r}`);return i&&H(`Ollama_${this.model}`,r,D,p,e),e==="review"?this.sanitizeResponse(p):this.parseMessage(p,l,a)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new E(`Error connecting to ${o.hostname} (${o.syscall})`):o}}async checkIsAvailableOllama(){try{const e=new ge({method:"GET",baseURL:`${this.host}`,timeout:this.params.config.timeout});return this.key&&e.setHeaders({Authorization:`${this.auth} ${this.key}`}),(await e.execute()).data}catch(e){throw e.code==="ECONNREFUSED"?new E(`Error connecting to ${this.host}. Please run Ollama or check host`):e}}async createChatCompletions(e,r){return(await this.ollama.chat({model:this.model,messages:[{role:"system",content:e},{role:"user",content:r}],stream:!1,options:{num_ctx:this.params.config.numCtx,temperature:this.params.config.temperature,top_p:this.params.config.topP,seed:Ge(10,1e3)}})).message.content}}class Oo extends G{constructor(e){super(e),this.params=e,this.handleError$=o=>{let n="N/A",s=o.message;o instanceof it.APIError&&(n=`${o.status}`,s=o.name);const i=`${n} ${s}`;return S({name:`${this.errorPrefix} ${i}`,value:s,isError:!0,disabled:!0})};const r=this.params.keyName||"OPENAI_COMPATIBLE";this.colors=fu(r),this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[${je(r)}]`),this.errorPrefix=C.red.bold(`[${je(r)}]`),this.openAI=new it({apiKey:this.params.config.key,baseURL:`${this.params.config.url}${this.params.config.path}`})}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,logging:i,locale:u,temperature:a,generate:l,type:m,maxLength:c}=this.params.config,D=this.params.config.maxTokens,p={...j,locale:u,maxLength:c,type:m,generate:l,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},f=e==="review"?z(p):U(p),g=(await this.openAI.chat.completions.create({messages:[{role:"system",content:f},{role:"user",content:`Here is the diff: ${r}`}],model:this.params.config.model,max_tokens:D,top_p:this.params.config.topP,temperature:a},{timeout:this.params.config.timeout})).choices[0].message.content||"";return i&&H(this.params.keyName,r,f,g,e),e==="review"?this.sanitizeResponse(g):this.parseMessage(g,m,l)}catch(r){throw r}}}var Gt={},Ht={exports:{}},ye={exports:{}},Ut,Io;function xu(){if(Io)return Ut;Io=1;var t=1e3,e=t*60,r=e*60,o=r*24,n=o*7,s=o*365.25;Ut=function(m,c){c=c||{};var D=typeof m;if(D==="string"&&m.length>0)return i(m);if(D==="number"&&isFinite(m))return c.long?a(m):u(m);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(m))};function i(m){if(m=String(m),!(m.length>100)){var c=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(m);if(c){var D=parseFloat(c[1]),p=(c[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return D*s;case"weeks":case"week":case"w":return D*n;case"days":case"day":case"d":return D*o;case"hours":case"hour":case"hrs":case"hr":case"h":return D*r;case"minutes":case"minute":case"mins":case"min":case"m":return D*e;case"seconds":case"second":case"secs":case"sec":case"s":return D*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return D;default:return}}}}function u(m){var c=Math.abs(m);return c>=o?Math.round(m/o)+"d":c>=r?Math.round(m/r)+"h":c>=e?Math.round(m/e)+"m":c>=t?Math.round(m/t)+"s":m+"ms"}function a(m){var c=Math.abs(m);return c>=o?l(m,c,o,"day"):c>=r?l(m,c,r,"hour"):c>=e?l(m,c,e,"minute"):c>=t?l(m,c,t,"second"):m+" ms"}function l(m,c,D,p){var f=c>=D*1.5;return Math.round(m/D)+" "+p+(f?"s":"")}return Ut}var zt,ko;function Lo(){if(ko)return zt;ko=1;function t(e){o.debug=o,o.default=o,o.coerce=l,o.disable=u,o.enable=s,o.enabled=a,o.humanize=xu(),o.destroy=m,Object.keys(e).forEach(c=>{o[c]=e[c]}),o.names=[],o.skips=[],o.formatters={};function r(c){let D=0;for(let p=0;p<c.length;p++)D=(D<<5)-D+c.charCodeAt(p),D|=0;return o.colors[Math.abs(D)%o.colors.length]}o.selectColor=r;function o(c){let D,p=null,f,h;function g(...y){if(!g.enabled)return;const v=g,O=Number(new Date),Q=O-(D||O);v.diff=Q,v.prev=D,v.curr=O,D=O,y[0]=o.coerce(y[0]),typeof y[0]!="string"&&y.unshift("%O");let Y=0;y[0]=y[0].replace(/%([a-zA-Z%])/g,(ee,un)=>{if(ee==="%%")return"%";Y++;const ir=o.formatters[un];if(typeof ir=="function"){const cn=y[Y];ee=ir.call(v,cn),y.splice(Y,1),Y--}return ee}),o.formatArgs.call(v,y),(v.log||o.log).apply(v,y)}return g.namespace=c,g.useColors=o.useColors(),g.color=o.selectColor(c),g.extend=n,g.destroy=o.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(f!==o.namespaces&&(f=o.namespaces,h=o.enabled(c)),h),set:y=>{p=y}}),typeof o.init=="function"&&o.init(g),g}function n(c,D){const p=o(this.namespace+(typeof D>"u"?":":D)+c);return p.log=this.log,p}function s(c){o.save(c),o.namespaces=c,o.names=[],o.skips=[];const D=(typeof c=="string"?c:"").trim().replace(" ",",").split(",").filter(Boolean);for(const p of D)p[0]==="-"?o.skips.push(p.slice(1)):o.names.push(p)}function i(c,D){let p=0,f=0,h=-1,g=0;for(;p<c.length;)if(f<D.length&&(D[f]===c[p]||D[f]==="*"))D[f]==="*"?(h=f,g=p,f++):(p++,f++);else if(h!==-1)f=h+1,g++,p=g;else return!1;for(;f<D.length&&D[f]==="*";)f++;return f===D.length}function u(){const c=[...o.names,...o.skips.map(D=>"-"+D)].join(",");return o.enable(""),c}function a(c){for(const D of o.skips)if(i(c,D))return!1;for(const D of o.names)if(i(c,D))return!0;return!1}function l(c){return c instanceof Error?c.stack||c.message:c}function m(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return o.enable(o.load()),o}return zt=t,zt}ye.exports;var No;function Mu(){return No||(No=1,function(t,e){e.formatArgs=o,e.save=n,e.load=s,e.useColors=r,e.storage=i(),e.destroy=(()=>{let a=!1;return()=>{a||(a=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let a;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(a=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(a[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function o(a){if(a[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+a[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;a.splice(1,0,l,"color: inherit");let m=0,c=0;a[0].replace(/%[a-zA-Z%]/g,D=>{D!=="%%"&&(m++,D==="%c"&&(c=m))}),a.splice(c,0,l)}e.log=console.debug||console.log||(()=>{});function n(a){try{a?e.storage.setItem("debug",a):e.storage.removeItem("debug")}catch{}}function s(){let a;try{a=e.storage.getItem("debug")}catch{}return!a&&typeof process<"u"&&"env"in process&&(a=process.env.DEBUG),a}function i(){try{return localStorage}catch{}}t.exports=Lo()(e);const{formatters:u}=t.exports;u.j=function(a){try{return JSON.stringify(a)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(ye,ye.exports)),ye.exports}var Ee={exports:{}},qt,To;function Su(){return To||(To=1,qt=(t,e=process.argv)=>{const r=t.startsWith("-")?"":t.length===1?"-":"--",o=e.indexOf(r+t),n=e.indexOf("--");return o!==-1&&(n===-1||o<n)}),qt}var Wt,_o;function Ru(){if(_o)return Wt;_o=1;const t=st,e=rt,r=Su(),{env:o}=process;let n;r("no-color")||r("no-colors")||r("color=false")||r("color=never")?n=0:(r("color")||r("colors")||r("color=true")||r("color=always"))&&(n=1),"FORCE_COLOR"in o&&(o.FORCE_COLOR==="true"?n=1:o.FORCE_COLOR==="false"?n=0:n=o.FORCE_COLOR.length===0?1:Math.min(parseInt(o.FORCE_COLOR,10),3));function s(a){return a===0?!1:{level:a,hasBasic:!0,has256:a>=2,has16m:a>=3}}function i(a,l){if(n===0)return 0;if(r("color=16m")||r("color=full")||r("color=truecolor"))return 3;if(r("color=256"))return 2;if(a&&!l&&n===void 0)return 0;const m=n||0;if(o.TERM==="dumb")return m;if(process.platform==="win32"){const c=t.release().split(".");return Number(c[0])>=10&&Number(c[2])>=10586?Number(c[2])>=14931?3:2:1}if("CI"in o)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(c=>c in o)||o.CI_NAME==="codeship"?1:m;if("TEAMCITY_VERSION"in o)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(o.TEAMCITY_VERSION)?1:0;if(o.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in o){const c=parseInt((o.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(o.TERM_PROGRAM){case"iTerm.app":return c>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(o.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(o.TERM)||"COLORTERM"in o?1:m}function u(a){const l=i(a,a&&a.isTTY);return s(l)}return Wt={supportsColor:u,stdout:s(i(!0,e.isatty(1))),stderr:s(i(!0,e.isatty(2)))},Wt}Ee.exports;var jo;function Ou(){return jo||(jo=1,function(t,e){const r=rt,o=mr;e.init=m,e.log=u,e.formatArgs=s,e.save=a,e.load=l,e.useColors=n,e.destroy=o.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),e.colors=[6,2,3,4,5,1];try{const D=Ru();D&&(D.stderr||D).level>=2&&(e.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}e.inspectOpts=Object.keys(process.env).filter(D=>/^debug_/i.test(D)).reduce((D,p)=>{const f=p.substring(6).toLowerCase().replace(/_([a-z])/g,(g,y)=>y.toUpperCase());let h=process.env[p];return/^(yes|on|true|enabled)$/i.test(h)?h=!0:/^(no|off|false|disabled)$/i.test(h)?h=!1:h==="null"?h=null:h=Number(h),D[f]=h,D},{});function n(){return"colors"in e.inspectOpts?!!e.inspectOpts.colors:r.isatty(process.stderr.fd)}function s(D){const{namespace:p,useColors:f}=this;if(f){const h=this.color,g="\x1B[3"+(h<8?h:"8;5;"+h),y=` ${g};1m${p} \x1B[0m`;D[0]=y+D[0].split(`
91
+ `,Nt=(t,e)=>{const r=[];let o="";typeof e=="string"?e={section:e,whitespace:!1}:(e=e||Object.create(null),e.whitespace=e.whitespace===!0);const n=e.whitespace?" = ":"=";for(const s of Object.keys(t)){const i=t[s];if(i&&Array.isArray(i))for(const u of i)o+=ue(s+"[]")+n+ue(u)+ze;else i&&typeof i=="object"?r.push(s):o+=ue(s)+n+ue(i)+ze}e.section&&o.length&&(o="["+ue(e.section)+"]"+ze+o);for(const s of r){const i=Bo(s).join("\\."),u=(e.section?e.section+".":"")+i,{whitespace:a}=e,l=Nt(t[s],{section:u,whitespace:a});o.length&&l.length&&(o+=ze),o+=l}return o},Bo=t=>t.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(e=>e.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),xo=t=>{const e=Object.create(null);let r=e,o=null;const n=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,s=t.split(/[\r\n]+/g);for(const u of s){if(!u||u.match(/^\s*[;#]/))continue;const a=u.match(n);if(!a)continue;if(a[1]!==void 0){if(o=qe(a[1]),o==="__proto__"){r=Object.create(null);continue}r=e[o]=e[o]||Object.create(null);continue}const l=qe(a[2]),m=l.length>2&&l.slice(-2)==="[]",c=m?l.slice(0,-2):l;if(c==="__proto__")continue;const D=a[3]?qe(a[4]):!0,p=D==="true"||D==="false"||D==="null"?JSON.parse(D):D;m&&(Lt.call(r,c)?Array.isArray(r[c])||(r[c]=[r[c]]):r[c]=[]),Array.isArray(r[c])?r[c].push(p):r[c]=p}const i=[];for(const u of Object.keys(e)){if(!Lt.call(e,u)||typeof e[u]!="object"||Array.isArray(e[u]))continue;const a=Bo(u);r=e;const l=a.pop(),m=l.replace(/\\\./g,".");for(const c of a)c!=="__proto__"&&((!Lt.call(r,c)||typeof r[c]!="object")&&(r[c]=Object.create(null)),r=r[c]);r===e&&m===l||(r[m]=e[u],i.push(u))}for(const u of i)delete e[u];return e},Mo=t=>t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"),ue=t=>typeof t!="string"||t.match(/[=\r\n]/)||t.match(/^\[/)||t.length>1&&Mo(t)||t!==t.trim()?JSON.stringify(t):t.split(";").join("\\;").split("#").join("\\#"),qe=(t,e)=>{if(t=(t||"").trim(),Mo(t)){t.charAt(0)==="'"&&(t=t.slice(1,-1));try{t=JSON.parse(t)}catch{}}else{let r=!1,o="";for(let n=0,s=t.length;n<s;n++){const i=t.charAt(n);if(r)"\\;#".indexOf(i)!==-1?o+=i:o+="\\"+i,r=!1;else{if(";#".indexOf(i)!==-1)break;i==="\\"?r=!0:o+=i}}return r&&(o+="\\"),o.trim()}return t};var wu={parse:xo,decode:xo,stringify:Nt,encode:Nt,safe:ue,unsafe:qe},Tt=re(wu);const So=t=>I.lstat(t).then(()=>!0,()=>!1),vu=["","conventional","gitmoji"],_t="http://localhost:11434",{hasOwnProperty:bu}=Object.prototype,We=(t,e)=>bu.call(t,e),ce=["OPENAI","OLLAMA","HUGGINGFACE","GEMINI","ANTHROPIC","MISTRAL","CODESTRAL","COHERE","GROQ","PERPLEXITY","DEEPSEEK"],$u=t=>{const e=Object.keys(t),r=new Set([...ce,...e.filter(o=>/^[A-Z][A-Z0-9_]*$/.test(o))]);return Array.from(r)},F=(t,e,r)=>{if(!e)throw new E(`Invalid config property ${t}: ${r}`)},d={systemPrompt(t){return t||""},systemPromptPath(t){return t||""},codeReviewPromptPath(t){return t||""},timeout(t){if(!t)return 1e4;F("timeout",/^\d+$/.test(t),"Must be an integer");const e=Number(t);return F("timeout",e>=500,"Must be greater than 500ms"),e},temperature(t){if(!t)return .7;F("temperature",/^(2|\d)(\.\d{1,2})?$/.test(t),"Must be decimal between 0 and 2");const e=Number(t);return F("temperature",e>0,"Must be greater than 0"),F("temperature",e<=2,"Must be less than or equal to 2"),e},maxTokens(t){return t?(F("maxTokens",/^\d+$/.test(t),"Must be an integer"),Number(t)):1024},logging(t){return typeof t=="boolean"?t:t==null?!0:(F("logging",/^(?:true|false)$/.test(t),"Must be a boolean(true or false)"),t==="true")},locale(t){return t?(F("locale",t,"Cannot be empty"),F("locale",/^[a-z-]+$/i.test(t),"Must be a valid locale (letters and dashes/underscores). You can consult the list of codes in: https://wikipedia.org/wiki/List_of_ISO_639-1_codes"),t):"en"},generate(t){if(!t)return 1;F("generate",/^\d+$/.test(t),"Must be an integer");const e=Number(t);return F("generate",e>0,"Must be greater than 0"),F("generate",e<=5,"Must be less or equal to 5"),e},type(t){return t?(F("type",vu.includes(t),"Invalid commit type"),t):"conventional"},maxLength(t){if(!t)return 50;F("maxLength",/^\d+$/.test(t),"Must be an integer");const e=Number(t);return F("maxLength",e>=20,"Must be greater than 20 characters"),e},includeBody(t){return typeof t=="boolean"?t:t==null?!1:(F("includeBody",/^(?:true|false)$/.test(t),"Must be a boolean(true or false)"),t==="true")},exclude:t=>t?(typeof t=="string"?t?.split(","):t).map(r=>r.trim()).filter(r=>!!r&&r.length>0):[],topP:t=>{if(!t)return .9;F("topP",/^(1|\d)(\.\d{1,2})?$/.test(t),"Must be decimal between 0 and 1");const e=Number(t);return F("topP",e>0,"Must be greater than 0"),F("topP",e<=1,"Must be less than or equal to 1"),e},codeReview(t){return typeof t=="boolean"?t:t==null?!1:(F("codeReview",/^(?:true|false)$/.test(t),"Must be a boolean(true or false)"),t==="true")},disabled(t){return typeof t=="boolean"?t:t==null?!1:(F("disabled",/^(?:true|false)$/.test(t),"Must be a boolean(true or false)"),t==="true")},watchMode(t){return typeof t=="boolean"?t:t==null?!1:(F("watchMode",/^(?:true|false)$/.test(t),"Must be a boolean(true or false)"),t==="true")}},Ce={OPENAI:{key:t=>t||"",model:t=>t||"gpt-4o-mini",url:t=>t?(F("OPENAI.url",/^https?:\/\//.test(t),"Must be a valid URL"),t):"https://api.openai.com",path:t=>t||"/v1/chat/completions",proxy:t=>t||"",topP:d.topP,systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,timeout:d.timeout,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode},HUGGINGFACE:{cookie:t=>t||"",model:t=>t?(F("HUGGINGFACE.model",["CohereForAI/c4ai-command-r-plus","meta-llama/Meta-Llama-3-70B-Instruct","HuggingFaceH4/zephyr-orpo-141b-A35b-v0.1","mistralai/Mixtral-8x7B-Instruct-v0.1","NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO","01-ai/Yi-1.5-34B-Chat","mistralai/Mistral-7B-Instruct-v0.2","microsoft/Phi-3-mini-4k-instruct"].includes(t),"Invalid model type of HuggingFace chat"),t):"CohereForAI/c4ai-command-r-plus",systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode},GEMINI:{key:t=>t||"",model:t=>!t||t.length===0?"gemini-2.0-flash-exp":(F("GEMINI.model",["gemini-2.0-flash","gemini-2.0-flash-lite","gemini-2.0-pro-exp-02-05","gemini-2.0-flash-thinking-exp-01-21","gemini-2.0-flash-exp","gemini-1.5-flash","gemini-1.5-flash-8b","gemini-1.5-pro"].includes(t),"Invalid model type of Gemini"),t),systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,topP:d.topP,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode},ANTHROPIC:{key:t=>t||"",model:t=>!t||t.length===0?"claude-3-5-haiku-20241022":(F("ANTHROPIC.model",["claude-3-7-sonnet-20250219","claude-3-5-sonnet-20241022","claude-3-5-haiku-20241022","claude-3-opus-20240229","claude-3-sonnet-20240229","claude-3-haiku-20240307"].includes(t),"Invalid model type of Anthropic"),t),systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,topP:d.topP,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode},MISTRAL:{key:t=>t||"",model:t=>!t||t.length===0?"pixtral-12b-2409":(F("MISTRAL.model",["codestral-latest","mistral-large-latest","pixtral-large-latest","ministral-8b-latest","mistral-small-latest","mistral-embed","mistral-moderation-latest"].includes(t),"Invalid model type of Mistral AI"),t),systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,timeout:d.timeout,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,topP:d.topP,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode},CODESTRAL:{key:t=>t||"",model:t=>!t||t.length===0?"codestral-latest":(F("CODESTRAL.model",["codestral-latest","codestral-2501"].includes(t),"Invalid model type of Codestral"),t),topP:d.topP,systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,timeout:d.timeout,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode},OLLAMA:{model:t=>t?(typeof t=="string"?t?.split(","):t).map(r=>r.trim()).filter(r=>!!r&&r.length>0):[],host:t=>t?(F("OLLAMA.host",/^https?:\/\//.test(t),"Must be a valid URL"),t):_t,timeout:t=>{if(!t)return 1e5;F("OLLAMA.timeout",/^\d+$/.test(t),"Must be an integer");const e=Number(t);return F("OLLAMA.timeout",e>=500,"Must be greater than 500ms"),e},auth:t=>t||"",key:t=>t||"",numCtx:t=>{if(!t)return 2048;F("OLLAMA.numCtx",/^\d+$/.test(t),"Must be an integer");const e=Number(t);return F("OLLAMA.numCtx",e>=2048,"Must be greater than 2048"),e},systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,temperature:d.temperature,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,topP:d.topP,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode},COHERE:{key:t=>t||"",model:t=>!t||t.length===0?"command":(F("COHERE.model",["command-r7b-12-2024","command-r-plus-08-2024","command-r-plus-04-2024","command-r-plus","command-r-08-2024","command-r-03-2024","command-r","command","command-nightly","command-light","command-light-nightly","c4ai-aya-expanse-8b","c4ai-aya-expanse-32b"].includes(t),"Invalid model type of Cohere"),t),systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,topP:d.topP,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode},GROQ:{key:t=>t||"",model:t=>!t||t.length===0?"gemma2-9b-it":(F("GROQ.model",["distil-whisper-large-v3-en","gemma2-9b-it","llama-3.3-70b-versatile","llama-3.1-8b-instant","llama-guard-3-8b","llama3-70b-8192","llama3-8b-8192","mixtral-8x7b-32768","whisper-large-v3","whisper-large-v3-turbo","llama-3.3-70b-specdec","llama-3.2-1b-preview","llama-3.2-3b-preview","llama-3.2-11b-vision-preview","llama-3.2-90b-vision-preview"].includes(t),"Invalid model type of Groq"),t),systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,timeout:d.timeout,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,topP:d.topP,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode},PERPLEXITY:{key:t=>t||"",model:t=>!t||t.length===0?"sonar":(F("PERPLEXITY.model",["sonar-pro","sonar","llama-3.1-sonar-small-128k-online","llama-3.1-sonar-large-128k-online","llama-3.1-sonar-huge-128k-online"].includes(t),"Invalid model type of Perplexity"),t),topP:d.topP,systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,timeout:d.timeout,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode},DEEPSEEK:{key:t=>t||"",model:t=>!t||t.length===0?"deepseek-chat":(console.log(t),F("DEEPSEEK.model",["deepseek-reasoner","deepseek-chat"].includes(t),"Invalid model type of DeepSeek"),t),topP:d.topP,systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,timeout:d.timeout,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode}},Ke=L.join(st.homedir(),".aicommit2"),Au=(t=[])=>{const e={};for(const r of t)if(r.startsWith("--")){const[o,n]=r.slice(2).split("="),[s,i]=o.split(".");s&&i&&s in Ce?(e[s]||(e[s]={}),e[s][i]=n):e[o]=n}return e},jt=async()=>{if(!await So(Ke))return Object.create(null);const e=await I.readFile(Ke,"utf8");let r=Tt.parse(e);return We(r,"OLLAMA")&&We(r.OLLAMA,"model")&&(r={...r,OLLAMA:{...r.OLLAMA,model:typeof r.OLLAMA.model=="string"?[r.OLLAMA.model]:r.OLLAMA.model}}),We(r,"exclude")&&(r={...r,exclude:typeof r.exclude=="string"?[r.exclude]:r.exclude}),r},Ve=async(t,e=[])=>{const r=await jt(),o=Au(e),n={...t,...o},s={},i=$u(r),u=(a,l)=>{const m=n[`${a}.${l}`]??n[a]?.[l],c=r[a]?.[l],D=n[l]??r[l];return m!==void 0?m:c!==void 0?c:D};for(const[a,l]of Object.entries(d)){const m=n[a]??r[a];s[a]=l(m)}for(const a of i){s[a]={};const l=Ce[a]||Ye(a);for(const[m,c]of Object.entries(l)){const D=u(a,m);s[a][m]=c(D)}}return s},Pu=async t=>{const e=await jt();for(const[r,o]of t){const[n,s]=r.split(".");if(!s){const a=d[r];if(!a)throw new E(`Invalid config property: ${r}`);e[r]=a(o);continue}if(e[n]||(e[n]={}),ce.includes(n)){const a=Ce[n][s];if(!a)throw new E(`Invalid config property: ${r}`);e[n][s]=a(o);continue}if(!/^[A-Z][A-Z0-9_]*$/.test(n))throw new E(`Invalid service name: ${n}. Service names must be uppercase letters, numbers, and underscores.`);const u=Ye(n);if(!u[s])throw new E(`Invalid config property for custom service: ${r}`);try{e[n][s]=u[s](o)}catch(a){throw a instanceof E?a:new E(`Invalid value for ${r}: ${a.message}`)}}await I.writeFile(Ke,Tt.stringify(e),"utf8")},Bu=async t=>{const e=await jt();for(const[r,o]of t){const[n,s]=r.split("."),i=e[n];if(n==="OLLAMA"&&s==="model"){i||(e[n]={});const a=e[n][s]||[];e[n][s]=He([...a,o]);continue}if(i&&i.compatible===!0){i||(e[n]={});const a=Ye(n);if(!a[s])throw new E(`Invalid config property: ${r}`);try{e[n][s]=a[s](o)}catch(l){throw l instanceof E?l:new E(`Invalid value for ${r}: ${l.message}`)}continue}if(n in Ce){i||(e[n]={});const a=Ce[n][s];if(!a)throw new E(`Invalid config property: ${r}`);e[n][s]=a(o)}else{const a=Ye(n);if(!a[s])throw new E(`Invalid config property: ${r}`);e[n]||(e[n]={}),e[n][s]=a[s](o)}}await I.writeFile(Ke,Tt.stringify(e),"utf8")},Ye=t=>({compatible:e=>typeof e=="boolean"?e:e==null?!1:(F("compatible",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"),url:e=>e?(F(`${t}.url`,/^https?:\/\//.test(e),"Must be a valid URL"),e):"",path:e=>e||"",key:e=>e||"",model:e=>e||"",systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,codeReviewPromptPath:d.codeReviewPromptPath,timeout:d.timeout,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,includeBody:d.includeBody,topP:d.topP,codeReview:d.codeReview,disabled:d.disabled,watchMode:d.watchMode});class Ro extends G{constructor(e){super(e),this.params=e,this.host=_t,this.model="",this.key="",this.auth="",this.handleError$=r=>{if(r.response&&r.response.data?.error)return S({name:`${this.errorPrefix} ${r.response.data?.error}`,value:r.response.data?.error,isError:!0,disabled:!0});const o=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return S({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#FFF",secondary:"#000"},this.model=this.params.keyName,this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[${je(this.model)}]`),this.errorPrefix=C.red.bold(`[${je(this.model)}]`),this.host=this.params.config.host||_t,this.auth=this.params.config.auth||"Bearer",this.key=this.params.config.key||"",this.ollama=new xn({host:this.host,...this.key&&{headers:{Authorization:`${this.auth} ${this.key}`}}})}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,logging:i,locale:u,generate:a,type:l,maxLength:m}=this.params.config,c={...j,locale:u,maxLength:m,type:l,generate:a,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},D=e==="review"?z(c):U(c);await this.checkIsAvailableOllama();const p=await this.createChatCompletions(D,`Here is the diff: ${r}`);return i&&H(`Ollama_${this.model}`,r,D,p,e),e==="review"?this.sanitizeResponse(p):this.parseMessage(p,l,a)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new E(`Error connecting to ${o.hostname} (${o.syscall})`):o}}async checkIsAvailableOllama(){try{const e=new ge({method:"GET",baseURL:`${this.host}`,timeout:this.params.config.timeout});return this.key&&e.setHeaders({Authorization:`${this.auth} ${this.key}`}),(await e.execute()).data}catch(e){throw e.code==="ECONNREFUSED"?new E(`Error connecting to ${this.host}. Please run Ollama or check host`):e}}async createChatCompletions(e,r){return(await this.ollama.chat({model:this.model,messages:[{role:"system",content:e},{role:"user",content:r}],stream:!1,options:{num_ctx:this.params.config.numCtx,temperature:this.params.config.temperature,top_p:this.params.config.topP,seed:Ge(10,1e3)}})).message.content}}class Oo extends G{constructor(e){super(e),this.params=e,this.handleError$=o=>{let n="N/A",s=o.message;o instanceof it.APIError&&(n=`${o.status}`,s=o.name);const i=`${n} ${s}`;return S({name:`${this.errorPrefix} ${i}`,value:s,isError:!0,disabled:!0})};const r=this.params.keyName||"OPENAI_COMPATIBLE";this.colors=fu(r),this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[${je(r)}]`),this.errorPrefix=C.red.bold(`[${je(r)}]`),this.openAI=new it({apiKey:this.params.config.key,baseURL:`${this.params.config.url}${this.params.config.path}`})}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>w(e)),$(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,logging:i,locale:u,temperature:a,generate:l,type:m,maxLength:c}=this.params.config,D=this.params.config.maxTokens,p={...j,locale:u,maxLength:c,type:m,generate:l,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},f=e==="review"?z(p):U(p),g=(await this.openAI.chat.completions.create({messages:[{role:"system",content:f},{role:"user",content:`Here is the diff: ${r}`}],model:this.params.config.model,max_tokens:D,top_p:this.params.config.topP,temperature:a},{timeout:this.params.config.timeout})).choices[0].message.content||"";return i&&H(this.params.keyName,r,f,g,e),e==="review"?this.sanitizeResponse(g):this.parseMessage(g,m,l)}catch(r){throw r}}}var Gt={},Ht={exports:{}},ye={exports:{}},Ut,Io;function xu(){if(Io)return Ut;Io=1;var t=1e3,e=t*60,r=e*60,o=r*24,n=o*7,s=o*365.25;Ut=function(m,c){c=c||{};var D=typeof m;if(D==="string"&&m.length>0)return i(m);if(D==="number"&&isFinite(m))return c.long?a(m):u(m);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(m))};function i(m){if(m=String(m),!(m.length>100)){var c=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(m);if(c){var D=parseFloat(c[1]),p=(c[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return D*s;case"weeks":case"week":case"w":return D*n;case"days":case"day":case"d":return D*o;case"hours":case"hour":case"hrs":case"hr":case"h":return D*r;case"minutes":case"minute":case"mins":case"min":case"m":return D*e;case"seconds":case"second":case"secs":case"sec":case"s":return D*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return D;default:return}}}}function u(m){var c=Math.abs(m);return c>=o?Math.round(m/o)+"d":c>=r?Math.round(m/r)+"h":c>=e?Math.round(m/e)+"m":c>=t?Math.round(m/t)+"s":m+"ms"}function a(m){var c=Math.abs(m);return c>=o?l(m,c,o,"day"):c>=r?l(m,c,r,"hour"):c>=e?l(m,c,e,"minute"):c>=t?l(m,c,t,"second"):m+" ms"}function l(m,c,D,p){var f=c>=D*1.5;return Math.round(m/D)+" "+p+(f?"s":"")}return Ut}var zt,ko;function Lo(){if(ko)return zt;ko=1;function t(e){o.debug=o,o.default=o,o.coerce=l,o.disable=u,o.enable=s,o.enabled=a,o.humanize=xu(),o.destroy=m,Object.keys(e).forEach(c=>{o[c]=e[c]}),o.names=[],o.skips=[],o.formatters={};function r(c){let D=0;for(let p=0;p<c.length;p++)D=(D<<5)-D+c.charCodeAt(p),D|=0;return o.colors[Math.abs(D)%o.colors.length]}o.selectColor=r;function o(c){let D,p=null,f,h;function g(...y){if(!g.enabled)return;const v=g,O=Number(new Date),Q=O-(D||O);v.diff=Q,v.prev=D,v.curr=O,D=O,y[0]=o.coerce(y[0]),typeof y[0]!="string"&&y.unshift("%O");let Y=0;y[0]=y[0].replace(/%([a-zA-Z%])/g,(ee,un)=>{if(ee==="%%")return"%";Y++;const ir=o.formatters[un];if(typeof ir=="function"){const cn=y[Y];ee=ir.call(v,cn),y.splice(Y,1),Y--}return ee}),o.formatArgs.call(v,y),(v.log||o.log).apply(v,y)}return g.namespace=c,g.useColors=o.useColors(),g.color=o.selectColor(c),g.extend=n,g.destroy=o.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(f!==o.namespaces&&(f=o.namespaces,h=o.enabled(c)),h),set:y=>{p=y}}),typeof o.init=="function"&&o.init(g),g}function n(c,D){const p=o(this.namespace+(typeof D>"u"?":":D)+c);return p.log=this.log,p}function s(c){o.save(c),o.namespaces=c,o.names=[],o.skips=[];const D=(typeof c=="string"?c:"").trim().replace(" ",",").split(",").filter(Boolean);for(const p of D)p[0]==="-"?o.skips.push(p.slice(1)):o.names.push(p)}function i(c,D){let p=0,f=0,h=-1,g=0;for(;p<c.length;)if(f<D.length&&(D[f]===c[p]||D[f]==="*"))D[f]==="*"?(h=f,g=p,f++):(p++,f++);else if(h!==-1)f=h+1,g++,p=g;else return!1;for(;f<D.length&&D[f]==="*";)f++;return f===D.length}function u(){const c=[...o.names,...o.skips.map(D=>"-"+D)].join(",");return o.enable(""),c}function a(c){for(const D of o.skips)if(i(c,D))return!1;for(const D of o.names)if(i(c,D))return!0;return!1}function l(c){return c instanceof Error?c.stack||c.message:c}function m(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return o.enable(o.load()),o}return zt=t,zt}ye.exports;var No;function Mu(){return No||(No=1,function(t,e){e.formatArgs=o,e.save=n,e.load=s,e.useColors=r,e.storage=i(),e.destroy=(()=>{let a=!1;return()=>{a||(a=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let a;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(a=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(a[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function o(a){if(a[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+a[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;a.splice(1,0,l,"color: inherit");let m=0,c=0;a[0].replace(/%[a-zA-Z%]/g,D=>{D!=="%%"&&(m++,D==="%c"&&(c=m))}),a.splice(c,0,l)}e.log=console.debug||console.log||(()=>{});function n(a){try{a?e.storage.setItem("debug",a):e.storage.removeItem("debug")}catch{}}function s(){let a;try{a=e.storage.getItem("debug")}catch{}return!a&&typeof process<"u"&&"env"in process&&(a=process.env.DEBUG),a}function i(){try{return localStorage}catch{}}t.exports=Lo()(e);const{formatters:u}=t.exports;u.j=function(a){try{return JSON.stringify(a)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(ye,ye.exports)),ye.exports}var Ee={exports:{}},qt,To;function Su(){return To||(To=1,qt=(t,e=process.argv)=>{const r=t.startsWith("-")?"":t.length===1?"-":"--",o=e.indexOf(r+t),n=e.indexOf("--");return o!==-1&&(n===-1||o<n)}),qt}var Wt,_o;function Ru(){if(_o)return Wt;_o=1;const t=st,e=rt,r=Su(),{env:o}=process;let n;r("no-color")||r("no-colors")||r("color=false")||r("color=never")?n=0:(r("color")||r("colors")||r("color=true")||r("color=always"))&&(n=1),"FORCE_COLOR"in o&&(o.FORCE_COLOR==="true"?n=1:o.FORCE_COLOR==="false"?n=0:n=o.FORCE_COLOR.length===0?1:Math.min(parseInt(o.FORCE_COLOR,10),3));function s(a){return a===0?!1:{level:a,hasBasic:!0,has256:a>=2,has16m:a>=3}}function i(a,l){if(n===0)return 0;if(r("color=16m")||r("color=full")||r("color=truecolor"))return 3;if(r("color=256"))return 2;if(a&&!l&&n===void 0)return 0;const m=n||0;if(o.TERM==="dumb")return m;if(process.platform==="win32"){const c=t.release().split(".");return Number(c[0])>=10&&Number(c[2])>=10586?Number(c[2])>=14931?3:2:1}if("CI"in o)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(c=>c in o)||o.CI_NAME==="codeship"?1:m;if("TEAMCITY_VERSION"in o)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(o.TEAMCITY_VERSION)?1:0;if(o.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in o){const c=parseInt((o.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(o.TERM_PROGRAM){case"iTerm.app":return c>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(o.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(o.TERM)||"COLORTERM"in o?1:m}function u(a){const l=i(a,a&&a.isTTY);return s(l)}return Wt={supportsColor:u,stdout:s(i(!0,e.isatty(1))),stderr:s(i(!0,e.isatty(2)))},Wt}Ee.exports;var jo;function Ou(){return jo||(jo=1,function(t,e){const r=rt,o=mr;e.init=m,e.log=u,e.formatArgs=s,e.save=a,e.load=l,e.useColors=n,e.destroy=o.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),e.colors=[6,2,3,4,5,1];try{const D=Ru();D&&(D.stderr||D).level>=2&&(e.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}e.inspectOpts=Object.keys(process.env).filter(D=>/^debug_/i.test(D)).reduce((D,p)=>{const f=p.substring(6).toLowerCase().replace(/_([a-z])/g,(g,y)=>y.toUpperCase());let h=process.env[p];return/^(yes|on|true|enabled)$/i.test(h)?h=!0:/^(no|off|false|disabled)$/i.test(h)?h=!1:h==="null"?h=null:h=Number(h),D[f]=h,D},{});function n(){return"colors"in e.inspectOpts?!!e.inspectOpts.colors:r.isatty(process.stderr.fd)}function s(D){const{namespace:p,useColors:f}=this;if(f){const h=this.color,g="\x1B[3"+(h<8?h:"8;5;"+h),y=` ${g};1m${p} \x1B[0m`;D[0]=y+D[0].split(`
92
92
  `).join(`
93
93
  `+y),D.push(g+"m+"+t.exports.humanize(this.diff)+"\x1B[0m")}else D[0]=i()+p+" "+D[0]}function i(){return e.inspectOpts.hideDate?"":new Date().toISOString()+" "}function u(...D){return process.stderr.write(o.formatWithOptions(e.inspectOpts,...D)+`
94
94
  `)}function a(D){D?process.env.DEBUG=D:delete process.env.DEBUG}function l(){return process.env.DEBUG}function m(D){D.inspectOpts={};const p=Object.keys(e.inspectOpts);for(let f=0;f<p.length;f++)D.inspectOpts[p[f]]=e.inspectOpts[p[f]]}t.exports=Lo()(e);const{formatters:c}=t.exports;c.o=function(D){return this.inspectOpts.colors=this.useColors,o.inspect(D,this.inspectOpts).split(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicommit2",
3
- "version": "2.2.3",
3
+ "version": "2.2.5",
4
4
  "description": "A Reactive CLI that generates git commit messages with various AI",
5
5
  "keywords": [
6
6
  "cli",