aicommit2 2.2.9 → 2.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/dist/cli.mjs +42 -42
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1156,6 +1156,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
1156
1156
  </tr>
1157
1157
  <tr>
1158
1158
  <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>
1159
+ <td align="center"><a href="https://github.com/delenzhang"><img src="https://avatars.githubusercontent.com/delenzhang" width="100px;" alt=""/><br /><sub><b>@delenzhang</b></sub></a><br /><a href="https://github.com/tak-bro/aicommit2/commits?author=delenzhang" title="Code">💻</a></td>
1159
1160
  </tr>
1160
1161
  </table>
1161
1162
  <!-- markdownlint-restore -->
package/dist/cli.mjs CHANGED
@@ -1,52 +1,52 @@
1
1
  #!/usr/bin/env node
2
- import st from"tty";import{createRequire as gn}from"module";import{Buffer as Cn}from"node:buffer";import ne from"node:path";import Dr,{ChildProcess as yn}from"node:child_process";import z from"node:process";import En from"child_process";import I from"path";import N from"fs";import{fileURLToPath as mr}from"node:url";import Fn,{constants as dr}from"node:os";import pr from"assert";import fr from"events";import{createWriteStream as wn,createReadStream as vn}from"node:fs";import bn from"buffer";import it from"stream";import hr from"util";import{debuglog as $n}from"node:util";import Pe from"inquirer";import at from"ora";import C from"chalk";import{of as O,concatMap as A,from as v,map as b,catchError as $,mergeMap as Be,BehaviorSubject as gr,ReplaySubject as An,lastValueFrom as Cr,filter as yr,toArray as Er,Subject as Fr}from"rxjs";import Pn from"@anthropic-ai/sdk";import{fromPromise as P}from"rxjs/internal/observable/innerFrom";import ut from"os";import{xxh64 as Bn}from"@pacote/xxhash";import xn from"axios";import{CohereClient as Mn,CohereTimeoutError as Sn}from"cohere-ai";import xe from"openai";import{GoogleGenerativeAI as Rn,HarmCategory as Me,HarmBlockThreshold as Se}from"@google/generative-ai";import wr from"groq-sdk";import{Ollama as On}from"ollama";import M from"fs/promises";import kn from"http";import In from"https";import Ln from"net";import Nn from"tls";import Tn,{fileURLToPath as _n,pathToFileURL as jn}from"url";import Re from"readline";import Gn from"figlet";import Hn from"inquirer-reactive-list-prompt";import{rm as Un}from"node:fs/promises";import qn from"chokidar";import{takeUntil as zn}from"rxjs/operators";const Wn="known-flag",Kn="unknown-flag",Vn="argument",{stringify:de}=JSON,Jn=/\B([A-Z])/g,Yn=t=>t.replace(Jn,"-$1").toLowerCase(),{hasOwnProperty:Xn}=Object.prototype,pe=(t,e)=>Xn.call(t,e),Zn=t=>Array.isArray(t),vr=t=>typeof t=="function"?[t,!1]:Zn(t)?[t[0],!0]:vr(t.type),Qn=(t,e)=>t===Boolean?e!=="false":e,es=(t,e)=>typeof e=="boolean"?e:t===Number&&e===""?Number.NaN:t(e),ts=/[\s.:=]/,rs=t=>{const e=`Flag name ${de(t)}`;if(t.length===0)throw new Error(`${e} cannot be empty`);if(t.length===1)throw new Error(`${e} must be longer than a character`);const r=t.match(ts);if(r)throw new Error(`${e} cannot contain ${de(r?.[0])}`)},os=t=>{const e={},r=(o,n)=>{if(pe(e,o))throw new Error(`Duplicate flags named ${de(o)}`);e[o]=n};for(const o in t){if(!pe(t,o))continue;rs(o);const n=t[o],s=[[],...vr(n),n];r(o,s);const i=Yn(o);if(o!==i&&r(i,s),"alias"in n&&typeof n.alias=="string"){const{alias:u}=n,a=`Flag alias ${de(u)} for flag ${de(o)}`;if(u.length===0)throw new Error(`${a} cannot be empty`);if(u.length>1)throw new Error(`${a} must be a single character`);r(u,s)}}return e},ns=(t,e)=>{const r={};for(const o in t){if(!pe(t,o))continue;const[n,,s,i]=e[o];if(n.length===0&&"default"in i){let{default:u}=i;typeof u=="function"&&(u=u()),r[o]=u}else r[o]=s?n:n.pop()}return r},Oe="--",ss=/[.:=]/,is=/^-{1,2}\w/,as=t=>{if(!is.test(t))return;const e=!t.startsWith(Oe);let r=t.slice(e?1:2),o;const n=r.match(ss);if(n){const{index:s}=n;o=r.slice(s+1),r=r.slice(0,s)}return[r,o,e]},us=(t,{onFlag:e,onArgument:r})=>{let o;const n=(s,i)=>{if(typeof o!="function")return!0;o(s,i),o=void 0};for(let s=0;s<t.length;s+=1){const i=t[s];if(i===Oe){n();const a=t.slice(s+1);r?.(a,[s],!0);break}const u=as(i);if(u){if(n(),!e)continue;const[a,l,m]=u;if(m)for(let c=0;c<a.length;c+=1){n();const D=c===a.length-1;o=e(a[c],D?l:void 0,[s,c+1,D])}else o=e(a,l,[s])}else n(i,[s])&&r?.([i],[s])}n()},cs=(t,e)=>{for(const[r,o,n]of e.reverse()){if(o){const s=t[r];let i=s.slice(0,o);if(n||(i+=s.slice(o+1)),i!=="-"){t[r]=i;continue}}t.splice(r,1)}},ls=(t,e=process.argv.slice(2),{ignore:r}={})=>{const o=[],n=os(t),s={},i=[];return i[Oe]=[],us(e,{onFlag(u,a,l){const m=pe(n,u);if(!r?.(m?Wn:Kn,u,a)){if(m){const[c,D]=n[u],d=Qn(D,a),f=(h,g)=>{o.push(l),g&&o.push(g),c.push(es(D,h||""))};return d===void 0?f:f(d)}pe(s,u)||(s[u]=[]),s[u].push(a===void 0?!0:a),o.push(l)}},onArgument(u,a,l){r?.(Vn,e[a[0]])||(i.push(...u),l?(i[Oe]=u,e.splice(a[0])):o.push(a))}}),cs(e,o),{flags:ns(t,n),unknownFlags:s,_:i}};var Ds=Object.create,ke=Object.defineProperty,ms=Object.defineProperties,ds=Object.getOwnPropertyDescriptor,ps=Object.getOwnPropertyDescriptors,fs=Object.getOwnPropertyNames,br=Object.getOwnPropertySymbols,hs=Object.getPrototypeOf,$r=Object.prototype.hasOwnProperty,gs=Object.prototype.propertyIsEnumerable,Ar=(t,e,r)=>e in t?ke(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ie=(t,e)=>{for(var r in e||(e={}))$r.call(e,r)&&Ar(t,r,e[r]);if(br)for(var r of br(e))gs.call(e,r)&&Ar(t,r,e[r]);return t},ct=(t,e)=>ms(t,ps(e)),Cs=t=>ke(t,"__esModule",{value:!0}),ys=(t,e)=>()=>(t&&(e=t(t=0)),e),Es=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Fs=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of fs(e))!$r.call(t,n)&&(r||n!=="default")&&ke(t,n,{get:()=>e[n],enumerable:!(o=ds(e,n))||o.enumerable});return t},ws=(t,e)=>Fs(Cs(ke(t!=null?Ds(hs(t)):{},"default",!e&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t),T=ys(()=>{}),vs=Es((t,e)=>{T(),e.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});T(),T(),T();var bs=t=>{var e,r,o;let n=(e=process.stdout.columns)!=null?e:Number.POSITIVE_INFINITY;return typeof t=="function"&&(t=t(n)),t||(t={}),Array.isArray(t)?{columns:t,stdoutColumns:n}:{columns:(r=t.columns)!=null?r:[],stdoutColumns:(o=t.stdoutColumns)!=null?o:n}};T(),T(),T(),T(),T();function $s({onlyFirst:t=!1}={}){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(e,t?void 0:"g")}function Pr(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace($s(),"")}T();function As(t){return Number.isInteger(t)?t>=4352&&(t<=4447||t===9001||t===9002||11904<=t&&t<=12871&&t!==12351||12880<=t&&t<=19903||19968<=t&&t<=42182||43360<=t&&t<=43388||44032<=t&&t<=55203||63744<=t&&t<=64255||65040<=t&&t<=65049||65072<=t&&t<=65131||65281<=t&&t<=65376||65504<=t&&t<=65510||110592<=t&&t<=110593||127488<=t&&t<=127569||131072<=t&&t<=262141):!1}var Ps=ws(vs(),1);function ee(t){if(typeof t!="string"||t.length===0||(t=Pr(t),t.length===0))return 0;t=t.replace((0,Ps.default)()," ");let e=0;for(let r=0;r<t.length;r++){let o=t.codePointAt(r);o<=31||o>=127&&o<=159||o>=768&&o<=879||(o>65535&&r++,e+=As(o)?2:1)}return e}var Br=t=>Math.max(...t.split(`
3
- `).map(ee)),Bs=t=>{let e=[];for(let r of t){let{length:o}=r,n=o-e.length;for(let s=0;s<n;s+=1)e.push(0);for(let s=0;s<o;s+=1){let i=Br(r[s]);i>e[s]&&(e[s]=i)}}return e};T();var xr=/^\d+%$/,Mr={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},xs=(t,e)=>{var r;let o=[];for(let n=0;n<t.length;n+=1){let s=(r=e[n])!=null?r:"auto";if(typeof s=="number"||s==="auto"||s==="content-width"||typeof s=="string"&&xr.test(s)){o.push(ct(Ie({},Mr),{width:s,contentWidth:t[n]}));continue}if(s&&typeof s=="object"){let i=ct(Ie(Ie({},Mr),s),{contentWidth:t[n]});i.horizontalPadding=i.paddingLeft+i.paddingRight,o.push(i);continue}throw new Error(`Invalid column width: ${JSON.stringify(s)}`)}return o};function Ms(t,e){for(let r of t){let{width:o}=r;if(o==="content-width"&&(r.width=r.contentWidth),o==="auto"){let a=Math.min(20,r.contentWidth);r.width=a,r.autoOverflow=r.contentWidth-a}if(typeof o=="string"&&xr.test(o)){let a=Number.parseFloat(o.slice(0,-1))/100;r.width=Math.floor(e*a)-(r.paddingLeft+r.paddingRight)}let{horizontalPadding:n}=r,s=1,i=s+n;if(i>=e){let a=i-e,l=Math.ceil(r.paddingLeft/n*a),m=a-l;r.paddingLeft-=l,r.paddingRight-=m,r.horizontalPadding=r.paddingLeft+r.paddingRight}r.paddingLeftString=r.paddingLeft?" ".repeat(r.paddingLeft):"",r.paddingRightString=r.paddingRight?" ".repeat(r.paddingRight):"";let u=e-r.horizontalPadding;r.width=Math.max(Math.min(r.width,u),s)}}var Sr=()=>Object.assign([],{columns:0});function Ss(t,e){let r=[Sr()],[o]=r;for(let n of t){let s=n.width+n.horizontalPadding;o.columns+s>e&&(o=Sr(),r.push(o)),o.push(n),o.columns+=s}for(let n of r){let s=n.reduce((D,d)=>D+d.width+d.horizontalPadding,0),i=e-s;if(i===0)continue;let u=n.filter(D=>"autoOverflow"in D),a=u.filter(D=>D.autoOverflow>0),l=a.reduce((D,d)=>D+d.autoOverflow,0),m=Math.min(l,i);for(let D of a){let d=Math.floor(D.autoOverflow/l*m);D.width+=d,i-=d}let c=Math.floor(i/u.length);for(let D=0;D<u.length;D+=1){let d=u[D];D===u.length-1?d.width+=i:d.width+=c,i-=c}}return r}function Rs(t,e,r){let o=xs(r,e);return Ms(o,t),Ss(o,t)}T(),T(),T();var lt=10,Rr=(t=0)=>e=>`\x1B[${e+t}m`,Or=(t=0)=>e=>`\x1B[${38+t};5;${e}m`,kr=(t=0)=>(e,r,o)=>`\x1B[${38+t};2;${e};${r};${o}m`;function Os(){let t=new Map,e={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};e.color.gray=e.color.blackBright,e.bgColor.bgGray=e.bgColor.bgBlackBright,e.color.grey=e.color.blackBright,e.bgColor.bgGrey=e.bgColor.bgBlackBright;for(let[r,o]of Object.entries(e)){for(let[n,s]of Object.entries(o))e[n]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},o[n]=e[n],t.set(s[0],s[1]);Object.defineProperty(e,r,{value:o,enumerable:!1})}return Object.defineProperty(e,"codes",{value:t,enumerable:!1}),e.color.close="\x1B[39m",e.bgColor.close="\x1B[49m",e.color.ansi=Rr(),e.color.ansi256=Or(),e.color.ansi16m=kr(),e.bgColor.ansi=Rr(lt),e.bgColor.ansi256=Or(lt),e.bgColor.ansi16m=kr(lt),Object.defineProperties(e,{rgbToAnsi256:{value:(r,o,n)=>r===o&&o===n?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(o/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:r=>{let o=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(r.toString(16));if(!o)return[0,0,0];let{colorString:n}=o.groups;n.length===3&&(n=n.split("").map(i=>i+i).join(""));let s=Number.parseInt(n,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:r=>e.rgbToAnsi256(...e.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value:r=>{if(r<8)return 30+r;if(r<16)return 90+(r-8);let o,n,s;if(r>=232)o=((r-232)*10+8)/255,n=o,s=o;else{r-=16;let a=r%36;o=Math.floor(r/36)/5,n=Math.floor(a/6)/5,s=a%6/5}let i=Math.max(o,n,s)*2;if(i===0)return 30;let u=30+(Math.round(s)<<2|Math.round(n)<<1|Math.round(o));return i===2&&(u+=60),u},enumerable:!1},rgbToAnsi:{value:(r,o,n)=>e.ansi256ToAnsi(e.rgbToAnsi256(r,o,n)),enumerable:!1},hexToAnsi:{value:r=>e.ansi256ToAnsi(e.hexToAnsi256(r)),enumerable:!1}}),e}var ks=Os(),Is=ks,Le=new Set(["\x1B","\x9B"]),Ls=39,Dt="\x07",Ir="[",Ns="]",Lr="m",mt=`${Ns}8;;`,Nr=t=>`${Le.values().next().value}${Ir}${t}${Lr}`,Tr=t=>`${Le.values().next().value}${mt}${t}${Dt}`,Ts=t=>t.split(" ").map(e=>ee(e)),dt=(t,e,r)=>{let o=[...e],n=!1,s=!1,i=ee(Pr(t[t.length-1]));for(let[u,a]of o.entries()){let l=ee(a);if(i+l<=r?t[t.length-1]+=a:(t.push(a),i=0),Le.has(a)&&(n=!0,s=o.slice(u+1).join("").startsWith(mt)),n){s?a===Dt&&(n=!1,s=!1):a===Lr&&(n=!1);continue}i+=l,i===r&&u<o.length-1&&(t.push(""),i=0)}!i&&t[t.length-1].length>0&&t.length>1&&(t[t.length-2]+=t.pop())},_s=t=>{let e=t.split(" "),r=e.length;for(;r>0&&!(ee(e[r-1])>0);)r--;return r===e.length?t:e.slice(0,r).join(" ")+e.slice(r).join("")},js=(t,e,r={})=>{if(r.trim!==!1&&t.trim()==="")return"";let o="",n,s,i=Ts(t),u=[""];for(let[l,m]of t.split(" ").entries()){r.trim!==!1&&(u[u.length-1]=u[u.length-1].trimStart());let c=ee(u[u.length-1]);if(l!==0&&(c>=e&&(r.wordWrap===!1||r.trim===!1)&&(u.push(""),c=0),(c>0||r.trim===!1)&&(u[u.length-1]+=" ",c++)),r.hard&&i[l]>e){let D=e-c,d=1+Math.floor((i[l]-D-1)/e);Math.floor((i[l]-1)/e)<d&&u.push(""),dt(u,m,e);continue}if(c+i[l]>e&&c>0&&i[l]>0){if(r.wordWrap===!1&&c<e){dt(u,m,e);continue}u.push("")}if(c+i[l]>e&&r.wordWrap===!1){dt(u,m,e);continue}u[u.length-1]+=m}r.trim!==!1&&(u=u.map(l=>_s(l)));let a=[...u.join(`
4
- `)];for(let[l,m]of a.entries()){if(o+=m,Le.has(m)){let{groups:D}=new RegExp(`(?:\\${Ir}(?<code>\\d+)m|\\${mt}(?<uri>.*)${Dt})`).exec(a.slice(l).join(""))||{groups:{}};if(D.code!==void 0){let d=Number.parseFloat(D.code);n=d===Ls?void 0:d}else D.uri!==void 0&&(s=D.uri.length===0?void 0:D.uri)}let c=Is.codes.get(Number(n));a[l+1]===`
5
- `?(s&&(o+=Tr("")),n&&c&&(o+=Nr(c))):m===`
6
- `&&(n&&c&&(o+=Nr(n)),s&&(o+=Tr(s)))}return o};function Gs(t,e,r){return String(t).normalize().replace(/\r\n/g,`
2
+ import st from"tty";import{createRequire as gn}from"module";import{Buffer as Cn}from"node:buffer";import ne from"node:path";import cr,{ChildProcess as yn}from"node:child_process";import z from"node:process";import En from"child_process";import I from"path";import N from"fs";import{fileURLToPath as lr}from"node:url";import Fn,{constants as Dr}from"node:os";import mr from"assert";import dr from"events";import{createWriteStream as wn,createReadStream as vn}from"node:fs";import bn from"buffer";import it from"stream";import pr from"util";import{debuglog as $n}from"node:util";import Pe from"inquirer";import at from"ora";import C from"chalk";import{of as O,concatMap as A,from as v,map as b,catchError as $,mergeMap as Be,BehaviorSubject as fr,ReplaySubject as An,lastValueFrom as hr,filter as gr,toArray as Cr,Subject as yr}from"rxjs";import Pn from"@anthropic-ai/sdk";import{fromPromise as P}from"rxjs/internal/observable/innerFrom";import ut from"os";import{xxh64 as Bn}from"@pacote/xxhash";import xn from"axios";import{CohereClient as Mn,CohereTimeoutError as Sn}from"cohere-ai";import xe from"openai";import{GoogleGenerativeAI as Rn,HarmCategory as Me,HarmBlockThreshold as Se}from"@google/generative-ai";import Er from"groq-sdk";import{Ollama as On}from"ollama";import M from"fs/promises";import kn from"http";import In from"https";import Ln from"net";import Nn from"tls";import Tn,{fileURLToPath as _n,pathToFileURL as jn}from"url";import Re from"readline";import Gn from"figlet";import Hn from"inquirer-reactive-list-prompt";import{rm as Un}from"node:fs/promises";import qn from"chokidar";import{takeUntil as zn}from"rxjs/operators";const Wn="known-flag",Kn="unknown-flag",Vn="argument",{stringify:de}=JSON,Jn=/\B([A-Z])/g,Yn=t=>t.replace(Jn,"-$1").toLowerCase(),{hasOwnProperty:Xn}=Object.prototype,pe=(t,e)=>Xn.call(t,e),Zn=t=>Array.isArray(t),Fr=t=>typeof t=="function"?[t,!1]:Zn(t)?[t[0],!0]:Fr(t.type),Qn=(t,e)=>t===Boolean?e!=="false":e,es=(t,e)=>typeof e=="boolean"?e:t===Number&&e===""?Number.NaN:t(e),ts=/[\s.:=]/,rs=t=>{const e=`Flag name ${de(t)}`;if(t.length===0)throw new Error(`${e} cannot be empty`);if(t.length===1)throw new Error(`${e} must be longer than a character`);const r=t.match(ts);if(r)throw new Error(`${e} cannot contain ${de(r?.[0])}`)},os=t=>{const e={},r=(o,n)=>{if(pe(e,o))throw new Error(`Duplicate flags named ${de(o)}`);e[o]=n};for(const o in t){if(!pe(t,o))continue;rs(o);const n=t[o],s=[[],...Fr(n),n];r(o,s);const i=Yn(o);if(o!==i&&r(i,s),"alias"in n&&typeof n.alias=="string"){const{alias:u}=n,a=`Flag alias ${de(u)} for flag ${de(o)}`;if(u.length===0)throw new Error(`${a} cannot be empty`);if(u.length>1)throw new Error(`${a} must be a single character`);r(u,s)}}return e},ns=(t,e)=>{const r={};for(const o in t){if(!pe(t,o))continue;const[n,,s,i]=e[o];if(n.length===0&&"default"in i){let{default:u}=i;typeof u=="function"&&(u=u()),r[o]=u}else r[o]=s?n:n.pop()}return r},Oe="--",ss=/[.:=]/,is=/^-{1,2}\w/,as=t=>{if(!is.test(t))return;const e=!t.startsWith(Oe);let r=t.slice(e?1:2),o;const n=r.match(ss);if(n){const{index:s}=n;o=r.slice(s+1),r=r.slice(0,s)}return[r,o,e]},us=(t,{onFlag:e,onArgument:r})=>{let o;const n=(s,i)=>{if(typeof o!="function")return!0;o(s,i),o=void 0};for(let s=0;s<t.length;s+=1){const i=t[s];if(i===Oe){n();const a=t.slice(s+1);r?.(a,[s],!0);break}const u=as(i);if(u){if(n(),!e)continue;const[a,l,m]=u;if(m)for(let c=0;c<a.length;c+=1){n();const D=c===a.length-1;o=e(a[c],D?l:void 0,[s,c+1,D])}else o=e(a,l,[s])}else n(i,[s])&&r?.([i],[s])}n()},cs=(t,e)=>{for(const[r,o,n]of e.reverse()){if(o){const s=t[r];let i=s.slice(0,o);if(n||(i+=s.slice(o+1)),i!=="-"){t[r]=i;continue}}t.splice(r,1)}},ls=(t,e=process.argv.slice(2),{ignore:r}={})=>{const o=[],n=os(t),s={},i=[];return i[Oe]=[],us(e,{onFlag(u,a,l){const m=pe(n,u);if(!r?.(m?Wn:Kn,u,a)){if(m){const[c,D]=n[u],d=Qn(D,a),f=(h,g)=>{o.push(l),g&&o.push(g),c.push(es(D,h||""))};return d===void 0?f:f(d)}pe(s,u)||(s[u]=[]),s[u].push(a===void 0?!0:a),o.push(l)}},onArgument(u,a,l){r?.(Vn,e[a[0]])||(i.push(...u),l?(i[Oe]=u,e.splice(a[0])):o.push(a))}}),cs(e,o),{flags:ns(t,n),unknownFlags:s,_:i}};var Ds=Object.create,ke=Object.defineProperty,ms=Object.defineProperties,ds=Object.getOwnPropertyDescriptor,ps=Object.getOwnPropertyDescriptors,fs=Object.getOwnPropertyNames,wr=Object.getOwnPropertySymbols,hs=Object.getPrototypeOf,vr=Object.prototype.hasOwnProperty,gs=Object.prototype.propertyIsEnumerable,br=(t,e,r)=>e in t?ke(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ie=(t,e)=>{for(var r in e||(e={}))vr.call(e,r)&&br(t,r,e[r]);if(wr)for(var r of wr(e))gs.call(e,r)&&br(t,r,e[r]);return t},ct=(t,e)=>ms(t,ps(e)),Cs=t=>ke(t,"__esModule",{value:!0}),ys=(t,e)=>()=>(t&&(e=t(t=0)),e),Es=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Fs=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of fs(e))!vr.call(t,n)&&(r||n!=="default")&&ke(t,n,{get:()=>e[n],enumerable:!(o=ds(e,n))||o.enumerable});return t},ws=(t,e)=>Fs(Cs(ke(t!=null?Ds(hs(t)):{},"default",!e&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t),T=ys(()=>{}),vs=Es((t,e)=>{T(),e.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});T(),T(),T();var bs=t=>{var e,r,o;let n=(e=process.stdout.columns)!=null?e:Number.POSITIVE_INFINITY;return typeof t=="function"&&(t=t(n)),t||(t={}),Array.isArray(t)?{columns:t,stdoutColumns:n}:{columns:(r=t.columns)!=null?r:[],stdoutColumns:(o=t.stdoutColumns)!=null?o:n}};T(),T(),T(),T(),T();function $s({onlyFirst:t=!1}={}){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(e,t?void 0:"g")}function $r(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace($s(),"")}T();function As(t){return Number.isInteger(t)?t>=4352&&(t<=4447||t===9001||t===9002||11904<=t&&t<=12871&&t!==12351||12880<=t&&t<=19903||19968<=t&&t<=42182||43360<=t&&t<=43388||44032<=t&&t<=55203||63744<=t&&t<=64255||65040<=t&&t<=65049||65072<=t&&t<=65131||65281<=t&&t<=65376||65504<=t&&t<=65510||110592<=t&&t<=110593||127488<=t&&t<=127569||131072<=t&&t<=262141):!1}var Ps=ws(vs(),1);function ee(t){if(typeof t!="string"||t.length===0||(t=$r(t),t.length===0))return 0;t=t.replace((0,Ps.default)()," ");let e=0;for(let r=0;r<t.length;r++){let o=t.codePointAt(r);o<=31||o>=127&&o<=159||o>=768&&o<=879||(o>65535&&r++,e+=As(o)?2:1)}return e}var Ar=t=>Math.max(...t.split(`
3
+ `).map(ee)),Bs=t=>{let e=[];for(let r of t){let{length:o}=r,n=o-e.length;for(let s=0;s<n;s+=1)e.push(0);for(let s=0;s<o;s+=1){let i=Ar(r[s]);i>e[s]&&(e[s]=i)}}return e};T();var Pr=/^\d+%$/,Br={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},xs=(t,e)=>{var r;let o=[];for(let n=0;n<t.length;n+=1){let s=(r=e[n])!=null?r:"auto";if(typeof s=="number"||s==="auto"||s==="content-width"||typeof s=="string"&&Pr.test(s)){o.push(ct(Ie({},Br),{width:s,contentWidth:t[n]}));continue}if(s&&typeof s=="object"){let i=ct(Ie(Ie({},Br),s),{contentWidth:t[n]});i.horizontalPadding=i.paddingLeft+i.paddingRight,o.push(i);continue}throw new Error(`Invalid column width: ${JSON.stringify(s)}`)}return o};function Ms(t,e){for(let r of t){let{width:o}=r;if(o==="content-width"&&(r.width=r.contentWidth),o==="auto"){let a=Math.min(20,r.contentWidth);r.width=a,r.autoOverflow=r.contentWidth-a}if(typeof o=="string"&&Pr.test(o)){let a=Number.parseFloat(o.slice(0,-1))/100;r.width=Math.floor(e*a)-(r.paddingLeft+r.paddingRight)}let{horizontalPadding:n}=r,s=1,i=s+n;if(i>=e){let a=i-e,l=Math.ceil(r.paddingLeft/n*a),m=a-l;r.paddingLeft-=l,r.paddingRight-=m,r.horizontalPadding=r.paddingLeft+r.paddingRight}r.paddingLeftString=r.paddingLeft?" ".repeat(r.paddingLeft):"",r.paddingRightString=r.paddingRight?" ".repeat(r.paddingRight):"";let u=e-r.horizontalPadding;r.width=Math.max(Math.min(r.width,u),s)}}var xr=()=>Object.assign([],{columns:0});function Ss(t,e){let r=[xr()],[o]=r;for(let n of t){let s=n.width+n.horizontalPadding;o.columns+s>e&&(o=xr(),r.push(o)),o.push(n),o.columns+=s}for(let n of r){let s=n.reduce((D,d)=>D+d.width+d.horizontalPadding,0),i=e-s;if(i===0)continue;let u=n.filter(D=>"autoOverflow"in D),a=u.filter(D=>D.autoOverflow>0),l=a.reduce((D,d)=>D+d.autoOverflow,0),m=Math.min(l,i);for(let D of a){let d=Math.floor(D.autoOverflow/l*m);D.width+=d,i-=d}let c=Math.floor(i/u.length);for(let D=0;D<u.length;D+=1){let d=u[D];D===u.length-1?d.width+=i:d.width+=c,i-=c}}return r}function Rs(t,e,r){let o=xs(r,e);return Ms(o,t),Ss(o,t)}T(),T(),T();var lt=10,Mr=(t=0)=>e=>`\x1B[${e+t}m`,Sr=(t=0)=>e=>`\x1B[${38+t};5;${e}m`,Rr=(t=0)=>(e,r,o)=>`\x1B[${38+t};2;${e};${r};${o}m`;function Os(){let t=new Map,e={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};e.color.gray=e.color.blackBright,e.bgColor.bgGray=e.bgColor.bgBlackBright,e.color.grey=e.color.blackBright,e.bgColor.bgGrey=e.bgColor.bgBlackBright;for(let[r,o]of Object.entries(e)){for(let[n,s]of Object.entries(o))e[n]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},o[n]=e[n],t.set(s[0],s[1]);Object.defineProperty(e,r,{value:o,enumerable:!1})}return Object.defineProperty(e,"codes",{value:t,enumerable:!1}),e.color.close="\x1B[39m",e.bgColor.close="\x1B[49m",e.color.ansi=Mr(),e.color.ansi256=Sr(),e.color.ansi16m=Rr(),e.bgColor.ansi=Mr(lt),e.bgColor.ansi256=Sr(lt),e.bgColor.ansi16m=Rr(lt),Object.defineProperties(e,{rgbToAnsi256:{value:(r,o,n)=>r===o&&o===n?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(o/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:r=>{let o=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(r.toString(16));if(!o)return[0,0,0];let{colorString:n}=o.groups;n.length===3&&(n=n.split("").map(i=>i+i).join(""));let s=Number.parseInt(n,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:r=>e.rgbToAnsi256(...e.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value:r=>{if(r<8)return 30+r;if(r<16)return 90+(r-8);let o,n,s;if(r>=232)o=((r-232)*10+8)/255,n=o,s=o;else{r-=16;let a=r%36;o=Math.floor(r/36)/5,n=Math.floor(a/6)/5,s=a%6/5}let i=Math.max(o,n,s)*2;if(i===0)return 30;let u=30+(Math.round(s)<<2|Math.round(n)<<1|Math.round(o));return i===2&&(u+=60),u},enumerable:!1},rgbToAnsi:{value:(r,o,n)=>e.ansi256ToAnsi(e.rgbToAnsi256(r,o,n)),enumerable:!1},hexToAnsi:{value:r=>e.ansi256ToAnsi(e.hexToAnsi256(r)),enumerable:!1}}),e}var ks=Os(),Is=ks,Le=new Set(["\x1B","\x9B"]),Ls=39,Dt="\x07",Or="[",Ns="]",kr="m",mt=`${Ns}8;;`,Ir=t=>`${Le.values().next().value}${Or}${t}${kr}`,Lr=t=>`${Le.values().next().value}${mt}${t}${Dt}`,Ts=t=>t.split(" ").map(e=>ee(e)),dt=(t,e,r)=>{let o=[...e],n=!1,s=!1,i=ee($r(t[t.length-1]));for(let[u,a]of o.entries()){let l=ee(a);if(i+l<=r?t[t.length-1]+=a:(t.push(a),i=0),Le.has(a)&&(n=!0,s=o.slice(u+1).join("").startsWith(mt)),n){s?a===Dt&&(n=!1,s=!1):a===kr&&(n=!1);continue}i+=l,i===r&&u<o.length-1&&(t.push(""),i=0)}!i&&t[t.length-1].length>0&&t.length>1&&(t[t.length-2]+=t.pop())},_s=t=>{let e=t.split(" "),r=e.length;for(;r>0&&!(ee(e[r-1])>0);)r--;return r===e.length?t:e.slice(0,r).join(" ")+e.slice(r).join("")},js=(t,e,r={})=>{if(r.trim!==!1&&t.trim()==="")return"";let o="",n,s,i=Ts(t),u=[""];for(let[l,m]of t.split(" ").entries()){r.trim!==!1&&(u[u.length-1]=u[u.length-1].trimStart());let c=ee(u[u.length-1]);if(l!==0&&(c>=e&&(r.wordWrap===!1||r.trim===!1)&&(u.push(""),c=0),(c>0||r.trim===!1)&&(u[u.length-1]+=" ",c++)),r.hard&&i[l]>e){let D=e-c,d=1+Math.floor((i[l]-D-1)/e);Math.floor((i[l]-1)/e)<d&&u.push(""),dt(u,m,e);continue}if(c+i[l]>e&&c>0&&i[l]>0){if(r.wordWrap===!1&&c<e){dt(u,m,e);continue}u.push("")}if(c+i[l]>e&&r.wordWrap===!1){dt(u,m,e);continue}u[u.length-1]+=m}r.trim!==!1&&(u=u.map(l=>_s(l)));let a=[...u.join(`
4
+ `)];for(let[l,m]of a.entries()){if(o+=m,Le.has(m)){let{groups:D}=new RegExp(`(?:\\${Or}(?<code>\\d+)m|\\${mt}(?<uri>.*)${Dt})`).exec(a.slice(l).join(""))||{groups:{}};if(D.code!==void 0){let d=Number.parseFloat(D.code);n=d===Ls?void 0:d}else D.uri!==void 0&&(s=D.uri.length===0?void 0:D.uri)}let c=Is.codes.get(Number(n));a[l+1]===`
5
+ `?(s&&(o+=Lr("")),n&&c&&(o+=Ir(c))):m===`
6
+ `&&(n&&c&&(o+=Ir(n)),s&&(o+=Lr(s)))}return o};function Gs(t,e,r){return String(t).normalize().replace(/\r\n/g,`
7
7
  `).split(`
8
8
  `).map(o=>js(o,e,r)).join(`
9
- `)}var _r=t=>Array.from({length:t}).fill("");function Hs(t,e){let r=[],o=0;for(let n of t){let s=0,i=n.map(a=>{var l;let m=(l=e[o])!=null?l:"";o+=1,a.preprocess&&(m=a.preprocess(m)),Br(m)>a.width&&(m=Gs(m,a.width,{hard:!0}));let c=m.split(`
10
- `);if(a.postprocess){let{postprocess:D}=a;c=c.map((d,f)=>D.call(a,d,f))}return a.paddingTop&&c.unshift(..._r(a.paddingTop)),a.paddingBottom&&c.push(..._r(a.paddingBottom)),c.length>s&&(s=c.length),ct(Ie({},a),{lines:c})}),u=[];for(let a=0;a<s;a+=1){let l=i.map(m=>{var c;let D=(c=m.lines[a])!=null?c:"",d=Number.isFinite(m.width)?" ".repeat(m.width-ee(D)):"",f=m.paddingLeftString;return m.align==="right"&&(f+=d),f+=D,m.align==="left"&&(f+=d),f+m.paddingRightString}).join("");u.push(l)}r.push(u.join(`
9
+ `)}var Nr=t=>Array.from({length:t}).fill("");function Hs(t,e){let r=[],o=0;for(let n of t){let s=0,i=n.map(a=>{var l;let m=(l=e[o])!=null?l:"";o+=1,a.preprocess&&(m=a.preprocess(m)),Ar(m)>a.width&&(m=Gs(m,a.width,{hard:!0}));let c=m.split(`
10
+ `);if(a.postprocess){let{postprocess:D}=a;c=c.map((d,f)=>D.call(a,d,f))}return a.paddingTop&&c.unshift(...Nr(a.paddingTop)),a.paddingBottom&&c.push(...Nr(a.paddingBottom)),c.length>s&&(s=c.length),ct(Ie({},a),{lines:c})}),u=[];for(let a=0;a<s;a+=1){let l=i.map(m=>{var c;let D=(c=m.lines[a])!=null?c:"",d=Number.isFinite(m.width)?" ".repeat(m.width-ee(D)):"",f=m.paddingLeftString;return m.align==="right"&&(f+=d),f+=D,m.align==="left"&&(f+=d),f+m.paddingRightString}).join("");u.push(l)}r.push(u.join(`
11
11
  `))}return r.join(`
12
12
  `)}function Us(t,e){if(!t||t.length===0)return"";let r=Bs(t),o=r.length;if(o===0)return"";let{stdoutColumns:n,columns:s}=bs(e);if(s.length>o)throw new Error(`${s.length} columns defined, but only ${o} columns found`);let i=Rs(n,s,r);return t.map(u=>Hs(i,u)).join(`
13
- `)}T();var qs=["<",">","=",">=","<="];function zs(t){if(!qs.includes(t))throw new TypeError(`Invalid breakpoint operator: ${t}`)}function Ws(t){let e=Object.keys(t).map(r=>{let[o,n]=r.split(" ");zs(o);let s=Number.parseInt(n,10);if(Number.isNaN(s))throw new TypeError(`Invalid breakpoint value: ${n}`);let i=t[r];return{operator:o,breakpoint:s,value:i}}).sort((r,o)=>o.breakpoint-r.breakpoint);return r=>{var o;return(o=e.find(({operator:n,breakpoint:s})=>n==="="&&r===s||n===">"&&r>s||n==="<"&&r<s||n===">="&&r>=s||n==="<="&&r<=s))==null?void 0:o.value}}const Ks=t=>t.replace(/[\W_]([a-z\d])?/gi,(e,r)=>r?r.toUpperCase():""),Vs=t=>t.replace(/\B([A-Z])/g,"-$1").toLowerCase(),Js={"> 80":[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"auto"}],"> 40":[{width:"auto",paddingLeft:2,paddingRight:8,preprocess:t=>t.trim()},{width:"100%",paddingLeft:2,paddingBottom:1}],"> 0":{stdoutColumns:1e3,columns:[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"content-width"}]}};function Ys(t){let e=!1;return{type:"table",data:{tableData:Object.keys(t).sort((r,o)=>r.localeCompare(o)).map(r=>{const o=t[r],n="alias"in o;return n&&(e=!0),{name:r,flag:o,flagFormatted:`--${Vs(r)}`,aliasesEnabled:e,aliasFormatted:n?`-${o.alias}`:void 0}}).map(r=>(r.aliasesEnabled=e,[{type:"flagName",data:r},{type:"flagDescription",data:r}])),tableBreakpoints:Js}}}const jr=t=>!t||(t.version??(t.help?t.help.version:void 0)),Gr=t=>{const e="parent"in t&&t.parent?.name;return(e?`${e} `:"")+t.name};function Xs(t){const e=[];t.name&&e.push(Gr(t));const r=jr(t)??("parent"in t&&jr(t.parent));if(r&&e.push(`v${r}`),e.length!==0)return{id:"name",type:"text",data:`${e.join(" ")}
13
+ `)}T();var qs=["<",">","=",">=","<="];function zs(t){if(!qs.includes(t))throw new TypeError(`Invalid breakpoint operator: ${t}`)}function Ws(t){let e=Object.keys(t).map(r=>{let[o,n]=r.split(" ");zs(o);let s=Number.parseInt(n,10);if(Number.isNaN(s))throw new TypeError(`Invalid breakpoint value: ${n}`);let i=t[r];return{operator:o,breakpoint:s,value:i}}).sort((r,o)=>o.breakpoint-r.breakpoint);return r=>{var o;return(o=e.find(({operator:n,breakpoint:s})=>n==="="&&r===s||n===">"&&r>s||n==="<"&&r<s||n===">="&&r>=s||n==="<="&&r<=s))==null?void 0:o.value}}const Ks=t=>t.replace(/[\W_]([a-z\d])?/gi,(e,r)=>r?r.toUpperCase():""),Vs=t=>t.replace(/\B([A-Z])/g,"-$1").toLowerCase(),Js={"> 80":[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"auto"}],"> 40":[{width:"auto",paddingLeft:2,paddingRight:8,preprocess:t=>t.trim()},{width:"100%",paddingLeft:2,paddingBottom:1}],"> 0":{stdoutColumns:1e3,columns:[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"content-width"}]}};function Ys(t){let e=!1;return{type:"table",data:{tableData:Object.keys(t).sort((r,o)=>r.localeCompare(o)).map(r=>{const o=t[r],n="alias"in o;return n&&(e=!0),{name:r,flag:o,flagFormatted:`--${Vs(r)}`,aliasesEnabled:e,aliasFormatted:n?`-${o.alias}`:void 0}}).map(r=>(r.aliasesEnabled=e,[{type:"flagName",data:r},{type:"flagDescription",data:r}])),tableBreakpoints:Js}}}const Tr=t=>!t||(t.version??(t.help?t.help.version:void 0)),_r=t=>{const e="parent"in t&&t.parent?.name;return(e?`${e} `:"")+t.name};function Xs(t){const e=[];t.name&&e.push(_r(t));const r=Tr(t)??("parent"in t&&Tr(t.parent));if(r&&e.push(`v${r}`),e.length!==0)return{id:"name",type:"text",data:`${e.join(" ")}
14
14
  `}}function Zs(t){const{help:e}=t;if(!(!e||!e.description))return{id:"description",type:"text",data:`${e.description}
15
15
  `}}function Qs(t){const e=t.help||{};if("usage"in e)return e.usage?{id:"usage",type:"section",data:{title:"Usage:",body:Array.isArray(e.usage)?e.usage.join(`
16
- `):e.usage}}:void 0;if(t.name){const r=[],o=[Gr(t)];if(t.flags&&Object.keys(t.flags).length>0&&o.push("[flags...]"),t.parameters&&t.parameters.length>0){const{parameters:n}=t,s=n.indexOf("--"),i=s>-1&&n.slice(s+1).some(u=>u.startsWith("<"));o.push(n.map(u=>u!=="--"?u:i?"--":"[--]").join(" "))}if(o.length>1&&r.push(o.join(" ")),"commands"in t&&t.commands?.length&&r.push(`${t.name} <command>`),r.length>0)return{id:"usage",type:"section",data:{title:"Usage:",body:r.join(`
16
+ `):e.usage}}:void 0;if(t.name){const r=[],o=[_r(t)];if(t.flags&&Object.keys(t.flags).length>0&&o.push("[flags...]"),t.parameters&&t.parameters.length>0){const{parameters:n}=t,s=n.indexOf("--"),i=s>-1&&n.slice(s+1).some(u=>u.startsWith("<"));o.push(n.map(u=>u!=="--"?u:i?"--":"[--]").join(" "))}if(o.length>1&&r.push(o.join(" ")),"commands"in t&&t.commands?.length&&r.push(`${t.name} <command>`),r.length>0)return{id:"usage",type:"section",data:{title:"Usage:",body:r.join(`
17
17
  `)}}}}function ei(t){return!("commands"in t)||!t.commands?.length?void 0:{id:"commands",type:"section",data:{title:"Commands:",body:{type:"table",data:{tableData:t.commands.map(e=>[e.options.name,e.options.help?e.options.help.description:""]),tableOptions:[{width:"content-width",paddingLeft:2,paddingRight:8}]}},indentBody:0}}}function ti(t){if(!(!t.flags||Object.keys(t.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:Ys(t.flags),indentBody:0}}}function ri(t){const{help:e}=t;if(!e||!e.examples||e.examples.length===0)return;let{examples:r}=e;if(Array.isArray(r)&&(r=r.join(`
18
18
  `)),r)return{id:"examples",type:"section",data:{title:"Examples:",body:r}}}function oi(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 ni=t=>[Xs,Zs,Qs,ei,ti,ri,oi].map(e=>e(t)).filter(Boolean),si=st.WriteStream.prototype.hasColors();class ii{text(e){return e}bold(e){return si?`\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 Us(e.map(n=>n.map(s=>this.render(s))),o?Ws(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
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 pt=t=>t.length>0&&!t.includes(" "),{stringify:W}=JSON,ai=/[|\\{}()[\]^$+*?.]/;function ft(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(ai);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 ht(t,e,r,o){for(let n=0;n<e.length;n+=1){const{name:s,required:i,spread:u}=e[n],a=Ks(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 ui(t){return t===void 0||t!==!1}function Hr(t,e,r,o){const n={...e.flags},s=e.version;s&&(n.version={type:Boolean,description:"Show version"});const{help:i}=e,u=ui(i);u&&!("help"in n)&&(n.help={type:Boolean,alias:"h",description:"Show help"});const a=ls(n,o,{ignore:e.ignoreArgv}),l=()=>{console.log(e.version)};if(s&&a.flags.version===!0)return l(),process.exit(0);const m=new ii,c=u&&i?.render?i.render:f=>m.render(f),D=f=>{const h=ni({...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),w=Object.create(null);if(g>-1&&y.length>0){f=f.slice(0,g);const S=a._["--"];h=h.slice(0,-S.length||void 0),ht(w,ft(f),h,D),ht(w,ft(y),S,D)}else ht(w,ft(f),h,D);Object.assign(a._,w)}const d={...a,showVersion:l,showHelp:D};return typeof r=="function"&&r(d),{command:t,...d}}function ci(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 li(t,e,r=process.argv.slice(2)){if(!t)throw new Error("Options is required");if("name"in t&&(!t.name||!pt(t.name)))throw new Error(`Invalid script name: ${W(t.name)}`);const o=r[0];if(t.commands&&o&&pt(o)){const n=ci(o,t.commands);if(n)return Hr(n.options.name,{...n.options,parent:t},n.callback,r.slice(1))}return Hr(void 0,t,e,r)}function gt(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(!pt(r))throw new Error(`Invalid command name ${JSON.stringify(r)}. Command names must be one word.`);return{options:t,callback:e}}var Di=gn(import.meta.url),R=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function se(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ie={exports:{}},Ct,Ur;function mi(){if(Ur)return Ct;Ur=1,Ct=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 Ct}var yt,qr;function di(){if(qr)return yt;qr=1,yt=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),d=parseInt("010",8),f=parseInt("001",8),h=D|d,g=u&f||u&d&&l===c||u&D&&a===m||u&h&&m===0;return g}return yt}var Ne;process.platform==="win32"||R.TESTING_WINDOWS?Ne=mi():Ne=di();var pi=Et;Et.sync=fi;function Et(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){Et(t,e||{},function(s,i){s?n(s):o(i)})})}Ne(t,e||{},function(o,n){o&&(o.code==="EACCES"||e&&e.ignoreErrors)&&(o=null,n=!1),r(o,n)})}function fi(t,e){try{return Ne.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}const ae=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",zr=I,hi=ae?";":":",Wr=pi,Kr=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),Vr=(t,e)=>{const r=e.colon||hi,o=t.match(/\//)||ae&&t.match(/\\/)?[""]:[...ae?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(r)],n=ae?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=ae?n.split(r):[""];return ae&&t.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:o,pathExt:s,pathExtExe:n}},Jr=(t,e,r)=>{typeof e=="function"&&(r=e,e={}),e||(e={});const{pathEnv:o,pathExt:n,pathExtExe:s}=Vr(t,e),i=[],u=l=>new Promise((m,c)=>{if(l===o.length)return e.all&&i.length?m(i):c(Kr(t));const D=o[l],d=/^".*"$/.test(D)?D.slice(1,-1):D,f=zr.join(d,t),h=!d&&/^\.[\\\/]/.test(t)?t.slice(0,2)+f:f;m(a(h,l,0))}),a=(l,m,c)=>new Promise((D,d)=>{if(c===n.length)return D(u(m+1));const f=n[c];Wr(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)},gi=(t,e)=>{e=e||{};const{pathEnv:r,pathExt:o,pathExtExe:n}=Vr(t,e),s=[];for(let i=0;i<r.length;i++){const u=r[i],a=/^".*"$/.test(u)?u.slice(1,-1):u,l=zr.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(Wr.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 Kr(t)};var Ci=Jr;Jr.sync=gi;var Ft={exports:{}};const Yr=(t={})=>{const e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(o=>o.toUpperCase()==="PATH")||"Path"};Ft.exports=Yr,Ft.exports.default=Yr;var yi=Ft.exports;const Xr=I,Ei=Ci,Fi=yi;function Zr(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=Ei.sync(t.command,{path:r[Fi({env:r})],pathExt:e?Xr.delimiter:void 0})}catch{}finally{s&&process.chdir(o)}return i&&(i=Xr.resolve(n?t.options.cwd:"",i)),i}function wi(t){return Zr(t)||Zr(t,!0)}var vi=wi,wt={};const vt=/([()\][%!^"`<>&|;, *?])/g;function bi(t){return t=t.replace(vt,"^$1"),t}function $i(t,e){return t=`${t}`,t=t.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),t=t.replace(/(?=(\\+?)?)\1$/,"$1$1"),t=`"${t}"`,t=t.replace(vt,"^$1"),e&&(t=t.replace(vt,"^$1")),t}wt.command=bi,wt.argument=$i;var Ai=/^#!(.*)/;const Pi=Ai;var Bi=(t="")=>{const e=t.match(Pi);if(!e)return null;const[r,o]=e[0].replace(/#! ?/,"").split(" "),n=r.split("/").pop();return n==="env"?o:o?`${n} ${o}`:n};const bt=N,xi=Bi;function Mi(t){const r=Buffer.alloc(150);let o;try{o=bt.openSync(t,"r"),bt.readSync(o,r,0,150,0),bt.closeSync(o)}catch{}return xi(r.toString())}var Si=Mi;const Ri=I,Qr=vi,eo=wt,Oi=Si,ki=process.platform==="win32",Ii=/\.(?:com|exe)$/i,Li=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Ni(t){t.file=Qr(t);const e=t.file&&Oi(t.file);return e?(t.args.unshift(t.file),t.command=e,Qr(t)):t.file}function Ti(t){if(!ki)return t;const e=Ni(t),r=!Ii.test(e);if(t.options.forceShell||r){const o=Li.test(e);t.command=Ri.normalize(t.command),t.command=eo.command(t.command),t.args=t.args.map(s=>eo.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 _i(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:Ti(o)}var ji=_i;const $t=process.platform==="win32";function At(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 Gi(t,e){if(!$t)return;const r=t.emit;t.emit=function(o,n){if(o==="exit"){const s=to(n,e);if(s)return r.call(t,"error",s)}return r.apply(t,arguments)}}function to(t,e){return $t&&t===1&&!e.file?At(e.original,"spawn"):null}function Hi(t,e){return $t&&t===1&&!e.file?At(e.original,"spawnSync"):null}var Ui={hookChildProcess:Gi,verifyENOENT:to,verifyENOENTSync:Hi,notFoundError:At};const ro=En,Pt=ji,Bt=Ui;function oo(t,e,r){const o=Pt(t,e,r),n=ro.spawn(o.command,o.args,o.options);return Bt.hookChildProcess(n,o),n}function qi(t,e,r){const o=Pt(t,e,r),n=ro.spawnSync(o.command,o.args,o.options);return n.error=n.error||Bt.verifyENOENTSync(n.status,o),n}ie.exports=oo,ie.exports.spawn=oo,ie.exports.sync=qi,ie.exports._parse=Pt,ie.exports._enoent=Bt;var zi=ie.exports,Wi=se(zi);function Ki(t){const e=typeof t=="string"?`
22
+ `),o(),process.exit(1);t[a]=l}}function ui(t){return t===void 0||t!==!1}function jr(t,e,r,o){const n={...e.flags},s=e.version;s&&(n.version={type:Boolean,description:"Show version"});const{help:i}=e,u=ui(i);u&&!("help"in n)&&(n.help={type:Boolean,alias:"h",description:"Show help"});const a=ls(n,o,{ignore:e.ignoreArgv}),l=()=>{console.log(e.version)};if(s&&a.flags.version===!0)return l(),process.exit(0);const m=new ii,c=u&&i?.render?i.render:f=>m.render(f),D=f=>{const h=ni({...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),w=Object.create(null);if(g>-1&&y.length>0){f=f.slice(0,g);const S=a._["--"];h=h.slice(0,-S.length||void 0),ht(w,ft(f),h,D),ht(w,ft(y),S,D)}else ht(w,ft(f),h,D);Object.assign(a._,w)}const d={...a,showVersion:l,showHelp:D};return typeof r=="function"&&r(d),{command:t,...d}}function ci(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 li(t,e,r=process.argv.slice(2)){if(!t)throw new Error("Options is required");if("name"in t&&(!t.name||!pt(t.name)))throw new Error(`Invalid script name: ${W(t.name)}`);const o=r[0];if(t.commands&&o&&pt(o)){const n=ci(o,t.commands);if(n)return jr(n.options.name,{...n.options,parent:t},n.callback,r.slice(1))}return jr(void 0,t,e,r)}function gt(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(!pt(r))throw new Error(`Invalid command name ${JSON.stringify(r)}. Command names must be one word.`);return{options:t,callback:e}}var Di=gn(import.meta.url),R=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function se(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ie={exports:{}},Ct,Gr;function mi(){if(Gr)return Ct;Gr=1,Ct=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 Ct}var yt,Hr;function di(){if(Hr)return yt;Hr=1,yt=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),d=parseInt("010",8),f=parseInt("001",8),h=D|d,g=u&f||u&d&&l===c||u&D&&a===m||u&h&&m===0;return g}return yt}var Ne;process.platform==="win32"||R.TESTING_WINDOWS?Ne=mi():Ne=di();var pi=Et;Et.sync=fi;function Et(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){Et(t,e||{},function(s,i){s?n(s):o(i)})})}Ne(t,e||{},function(o,n){o&&(o.code==="EACCES"||e&&e.ignoreErrors)&&(o=null,n=!1),r(o,n)})}function fi(t,e){try{return Ne.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}const ae=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Ur=I,hi=ae?";":":",qr=pi,zr=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),Wr=(t,e)=>{const r=e.colon||hi,o=t.match(/\//)||ae&&t.match(/\\/)?[""]:[...ae?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(r)],n=ae?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=ae?n.split(r):[""];return ae&&t.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:o,pathExt:s,pathExtExe:n}},Kr=(t,e,r)=>{typeof e=="function"&&(r=e,e={}),e||(e={});const{pathEnv:o,pathExt:n,pathExtExe:s}=Wr(t,e),i=[],u=l=>new Promise((m,c)=>{if(l===o.length)return e.all&&i.length?m(i):c(zr(t));const D=o[l],d=/^".*"$/.test(D)?D.slice(1,-1):D,f=Ur.join(d,t),h=!d&&/^\.[\\\/]/.test(t)?t.slice(0,2)+f:f;m(a(h,l,0))}),a=(l,m,c)=>new Promise((D,d)=>{if(c===n.length)return D(u(m+1));const f=n[c];qr(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)},gi=(t,e)=>{e=e||{};const{pathEnv:r,pathExt:o,pathExtExe:n}=Wr(t,e),s=[];for(let i=0;i<r.length;i++){const u=r[i],a=/^".*"$/.test(u)?u.slice(1,-1):u,l=Ur.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(qr.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 zr(t)};var Ci=Kr;Kr.sync=gi;var Ft={exports:{}};const Vr=(t={})=>{const e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(o=>o.toUpperCase()==="PATH")||"Path"};Ft.exports=Vr,Ft.exports.default=Vr;var yi=Ft.exports;const Jr=I,Ei=Ci,Fi=yi;function Yr(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=Ei.sync(t.command,{path:r[Fi({env:r})],pathExt:e?Jr.delimiter:void 0})}catch{}finally{s&&process.chdir(o)}return i&&(i=Jr.resolve(n?t.options.cwd:"",i)),i}function wi(t){return Yr(t)||Yr(t,!0)}var vi=wi,wt={};const vt=/([()\][%!^"`<>&|;, *?])/g;function bi(t){return t=t.replace(vt,"^$1"),t}function $i(t,e){return t=`${t}`,t=t.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),t=t.replace(/(?=(\\+?)?)\1$/,"$1$1"),t=`"${t}"`,t=t.replace(vt,"^$1"),e&&(t=t.replace(vt,"^$1")),t}wt.command=bi,wt.argument=$i;var Ai=/^#!(.*)/;const Pi=Ai;var Bi=(t="")=>{const e=t.match(Pi);if(!e)return null;const[r,o]=e[0].replace(/#! ?/,"").split(" "),n=r.split("/").pop();return n==="env"?o:o?`${n} ${o}`:n};const bt=N,xi=Bi;function Mi(t){const r=Buffer.alloc(150);let o;try{o=bt.openSync(t,"r"),bt.readSync(o,r,0,150,0),bt.closeSync(o)}catch{}return xi(r.toString())}var Si=Mi;const Ri=I,Xr=vi,Zr=wt,Oi=Si,ki=process.platform==="win32",Ii=/\.(?:com|exe)$/i,Li=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Ni(t){t.file=Xr(t);const e=t.file&&Oi(t.file);return e?(t.args.unshift(t.file),t.command=e,Xr(t)):t.file}function Ti(t){if(!ki)return t;const e=Ni(t),r=!Ii.test(e);if(t.options.forceShell||r){const o=Li.test(e);t.command=Ri.normalize(t.command),t.command=Zr.command(t.command),t.args=t.args.map(s=>Zr.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 _i(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:Ti(o)}var ji=_i;const $t=process.platform==="win32";function At(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 Gi(t,e){if(!$t)return;const r=t.emit;t.emit=function(o,n){if(o==="exit"){const s=Qr(n,e);if(s)return r.call(t,"error",s)}return r.apply(t,arguments)}}function Qr(t,e){return $t&&t===1&&!e.file?At(e.original,"spawn"):null}function Hi(t,e){return $t&&t===1&&!e.file?At(e.original,"spawnSync"):null}var Ui={hookChildProcess:Gi,verifyENOENT:Qr,verifyENOENTSync:Hi,notFoundError:At};const eo=En,Pt=ji,Bt=Ui;function to(t,e,r){const o=Pt(t,e,r),n=eo.spawn(o.command,o.args,o.options);return Bt.hookChildProcess(n,o),n}function qi(t,e,r){const o=Pt(t,e,r),n=eo.spawnSync(o.command,o.args,o.options);return n.error=n.error||Bt.verifyENOENTSync(n.status,o),n}ie.exports=to,ie.exports.spawn=to,ie.exports.sync=qi,ie.exports._parse=Pt,ie.exports._enoent=Bt;var zi=ie.exports,Wi=se(zi);function Ki(t){const e=typeof t=="string"?`
23
23
  `:`
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 no(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 Vi=({cwd:t=z.cwd(),path:e=z.env[no()],preferLocal:r=!0,execPath:o=z.execPath,addExecPath:n=!0}={})=>{const s=t instanceof URL?mr(t):t,i=ne.resolve(s),u=[];return r&&Ji(u,i),n&&Yi(u,o,i),[...u,e].join(ne.delimiter)},Ji=(t,e)=>{let r;for(;r!==e;)t.push(ne.join(e,"node_modules/.bin")),r=e,e=ne.resolve(e,"..")},Yi=(t,e,r)=>{const o=e instanceof URL?mr(e):e;t.push(ne.resolve(r,o,".."))},Xi=({env:t=z.env,...e}={})=>{t={...t};const r=no({env:t});return e.path=t[r],t[r]=Vi(e),t},Zi=(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);!Qi(n,s)&&o||Object.defineProperty(t,r,s)},Qi=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)},ea=(t,e)=>{const r=Object.getPrototypeOf(e);r!==Object.getPrototypeOf(t)&&Object.setPrototypeOf(t,r)},ta=(t,e)=>`/* Wrapped ${t}*/
25
- ${e}`,ra=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),oa=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),na=(t,e,r)=>{const o=r===""?"":`with ${r.trim()}() `,n=ta.bind(null,o,e.toString());Object.defineProperty(n,"name",oa),Object.defineProperty(t,"toString",{...ra,value:n})};function sa(t,e,{ignoreNonConfigurable:r=!1}={}){const{name:o}=t;for(const n of Reflect.ownKeys(e))Zi(t,e,n,r);return ea(t,e),na(t,e,o),t}const Te=new WeakMap,so=(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(Te.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 sa(s,t),Te.set(s,o),s};so.callCount=t=>{if(!Te.has(t))throw new Error(`The given function \`${t.name}\` is not wrapped by the \`onetime\` package`);return Te.get(t)};const ia=()=>{const t=ao-io+1;return Array.from({length:t},aa)},aa=(t,e)=>({name:`SIGRT${e+1}`,number:io+e,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),io=34,ao=64,ua=[{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"}],uo=()=>{const t=ia();return[...ua,...t].map(ca)},ca=({name:t,number:e,description:r,action:o,forced:n=!1,standard:s})=>{const{signals:{[t]:i}}=dr,u=i!==void 0;return{name:t,number:u?i:e,description:r,supported:u,action:o,forced:n,standard:s}},la=()=>{const t=uo();return Object.fromEntries(t.map(Da))},Da=({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}],ma=la(),da=()=>{const t=uo(),e=ao+1,r=Array.from({length:e},(o,n)=>pa(n,t));return Object.assign({},...r)},pa=(t,e)=>{const r=fa(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}}},fa=(t,e)=>{const r=e.find(({name:o})=>dr.signals[o]===t);return r!==void 0?r:e.find(o=>o.number===t)};da();const ha=({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",co=({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=z.cwd()}}})=>{s=s===null?void 0:s,n=n===null?void 0:n;const d=n===void 0?void 0:ma[n].description,f=o&&o.code,g=`Command ${ha({timedOut:a,timeout:c,errorCode:f,signal:n,signalDescription:d,exitCode:s,isCanceled:l})}: ${i}`,y=Object.prototype.toString.call(o)==="[object Error]",w=y?`${g}
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 ro(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 Vi=({cwd:t=z.cwd(),path:e=z.env[ro()],preferLocal:r=!0,execPath:o=z.execPath,addExecPath:n=!0}={})=>{const s=t instanceof URL?lr(t):t,i=ne.resolve(s),u=[];return r&&Ji(u,i),n&&Yi(u,o,i),[...u,e].join(ne.delimiter)},Ji=(t,e)=>{let r;for(;r!==e;)t.push(ne.join(e,"node_modules/.bin")),r=e,e=ne.resolve(e,"..")},Yi=(t,e,r)=>{const o=e instanceof URL?lr(e):e;t.push(ne.resolve(r,o,".."))},Xi=({env:t=z.env,...e}={})=>{t={...t};const r=ro({env:t});return e.path=t[r],t[r]=Vi(e),t},Zi=(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);!Qi(n,s)&&o||Object.defineProperty(t,r,s)},Qi=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)},ea=(t,e)=>{const r=Object.getPrototypeOf(e);r!==Object.getPrototypeOf(t)&&Object.setPrototypeOf(t,r)},ta=(t,e)=>`/* Wrapped ${t}*/
25
+ ${e}`,ra=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),oa=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),na=(t,e,r)=>{const o=r===""?"":`with ${r.trim()}() `,n=ta.bind(null,o,e.toString());Object.defineProperty(n,"name",oa),Object.defineProperty(t,"toString",{...ra,value:n})};function sa(t,e,{ignoreNonConfigurable:r=!1}={}){const{name:o}=t;for(const n of Reflect.ownKeys(e))Zi(t,e,n,r);return ea(t,e),na(t,e,o),t}const Te=new WeakMap,oo=(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(Te.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 sa(s,t),Te.set(s,o),s};oo.callCount=t=>{if(!Te.has(t))throw new Error(`The given function \`${t.name}\` is not wrapped by the \`onetime\` package`);return Te.get(t)};const ia=()=>{const t=so-no+1;return Array.from({length:t},aa)},aa=(t,e)=>({name:`SIGRT${e+1}`,number:no+e,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),no=34,so=64,ua=[{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"}],io=()=>{const t=ia();return[...ua,...t].map(ca)},ca=({name:t,number:e,description:r,action:o,forced:n=!1,standard:s})=>{const{signals:{[t]:i}}=Dr,u=i!==void 0;return{name:t,number:u?i:e,description:r,supported:u,action:o,forced:n,standard:s}},la=()=>{const t=io();return Object.fromEntries(t.map(Da))},Da=({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}],ma=la(),da=()=>{const t=io(),e=so+1,r=Array.from({length:e},(o,n)=>pa(n,t));return Object.assign({},...r)},pa=(t,e)=>{const r=fa(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}}},fa=(t,e)=>{const r=e.find(({name:o})=>Dr.signals[o]===t);return r!==void 0?r:e.find(o=>o.number===t)};da();const ha=({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",ao=({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=z.cwd()}}})=>{s=s===null?void 0:s,n=n===null?void 0:n;const d=n===void 0?void 0:ma[n].description,f=o&&o.code,g=`Command ${ha({timedOut:a,timeout:c,errorCode:f,signal:n,signalDescription:d,exitCode:s,isCanceled:l})}: ${i}`,y=Object.prototype.toString.call(o)==="[object Error]",w=y?`${g}
26
26
  ${o.message}`:g,S=[w,e,t].filter(Boolean).join(`
27
- `);return y?(o.originalMessage=o.message,o.message=S):o=new Error(S),o.shortMessage=w,o.command=i,o.escapedCommand=u,o.exitCode=s,o.signal=n,o.signalDescription=d,o.stdout=t,o.stderr=e,o.cwd=D,r!==void 0&&(o.all=r),"bufferedData"in o&&delete o.bufferedData,o.failed=!0,o.timedOut=!!a,o.isCanceled=l,o.killed=m&&!a,o},_e=["stdin","stdout","stderr"],ga=t=>_e.some(e=>t[e]!==void 0),Ca=t=>{if(!t)return;const{stdio:e}=t;if(e===void 0)return _e.map(o=>t[o]);if(ga(t))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${_e.map(o=>`\`${o}\``).join(", ")}`);if(typeof e=="string")return e;if(!Array.isArray(e))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof e}\``);const r=Math.max(e.length,_e.length);return Array.from({length:r},(o,n)=>e[n])};var ue={exports:{}},je={exports:{}};je.exports;var lo;function ya(){return lo||(lo=1,function(t){t.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"],process.platform!=="win32"&&t.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),process.platform==="linux"&&t.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")}(je)),je.exports}var B=R.process;const te=function(t){return t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function"};if(!te(B))ue.exports=function(){return function(){}};else{var Ea=pr,fe=ya(),Fa=/^win/i.test(B.platform),Ge=fr;typeof Ge!="function"&&(Ge=Ge.EventEmitter);var k;B.__signal_exit_emitter__?k=B.__signal_exit_emitter__:(k=B.__signal_exit_emitter__=new Ge,k.count=0,k.emitted={}),k.infinite||(k.setMaxListeners(1/0),k.infinite=!0),ue.exports=function(t,e){if(!te(R.process))return function(){};Ea.equal(typeof t,"function","a callback must be provided for exit handler"),he===!1&&Do();var r="exit";e&&e.alwaysLast&&(r="afterexit");var o=function(){k.removeListener(r,t),k.listeners("exit").length===0&&k.listeners("afterexit").length===0&&xt()};return k.on(r,t),o};var xt=function(){!he||!te(R.process)||(he=!1,fe.forEach(function(e){try{B.removeListener(e,Mt[e])}catch{}}),B.emit=St,B.reallyExit=mo,k.count-=1)};ue.exports.unload=xt;var ce=function(e,r,o){k.emitted[e]||(k.emitted[e]=!0,k.emit(e,r,o))},Mt={};fe.forEach(function(t){Mt[t]=function(){if(te(R.process)){var r=B.listeners(t);r.length===k.count&&(xt(),ce("exit",null,t),ce("afterexit",null,t),Fa&&t==="SIGHUP"&&(t="SIGINT"),B.kill(B.pid,t))}}}),ue.exports.signals=function(){return fe};var he=!1,Do=function(){he||!te(R.process)||(he=!0,k.count+=1,fe=fe.filter(function(e){try{return B.on(e,Mt[e]),!0}catch{return!1}}),B.emit=va,B.reallyExit=wa)};ue.exports.load=Do;var mo=B.reallyExit,wa=function(e){te(R.process)&&(B.exitCode=e||0,ce("exit",B.exitCode,null),ce("afterexit",B.exitCode,null),mo.call(B,B.exitCode))},St=B.emit,va=function(e,r){if(e==="exit"&&te(R.process)){r!==void 0&&(B.exitCode=r);var o=St.apply(this,arguments);return ce("exit",B.exitCode,null),ce("afterexit",B.exitCode,null),o}else return St.apply(this,arguments)}}var ba=ue.exports,$a=se(ba);const Aa=1e3*5,Pa=(t,e="SIGTERM",r={})=>{const o=t(e);return Ba(t,e,r,o),o},Ba=(t,e,r,o)=>{if(!xa(e,r,o))return;const n=Sa(r),s=setTimeout(()=>{t("SIGKILL")},n);s.unref&&s.unref()},xa=(t,{forceKillAfterTimeout:e},r)=>Ma(t)&&e!==!1&&r,Ma=t=>t===Fn.constants.signals.SIGTERM||typeof t=="string"&&t.toUpperCase()==="SIGTERM",Sa=({forceKillAfterTimeout:t=!0})=>{if(t===!0)return Aa;if(!Number.isFinite(t)||t<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${t}\` (${typeof t})`);return t},Ra=(t,e)=>{t.kill()&&(e.isCanceled=!0)},Oa=(t,e,r)=>{t.kill(e),r(Object.assign(new Error("Timed out"),{timedOut:!0,signal:e}))},ka=(t,{timeout:e,killSignal:r="SIGTERM"},o)=>{if(e===0||e===void 0)return o;let n;const s=new Promise((u,a)=>{n=setTimeout(()=>{Oa(t,r,a)},e)}),i=o.finally(()=>{clearTimeout(n)});return Promise.race([s,i])},Ia=({timeout:t})=>{if(t!==void 0&&(!Number.isFinite(t)||t<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${t}\` (${typeof t})`)},La=async(t,{cleanup:e,detached:r},o)=>{if(!e||r)return o;const n=$a(()=>{t.kill()});return o.finally(()=>{n()})};function po(t){return t!==null&&typeof t=="object"&&typeof t.pipe=="function"}function fo(t){return po(t)&&t.writable!==!1&&typeof t._write=="function"&&typeof t._writableState=="object"}const Na=t=>t instanceof yn&&typeof t.then=="function",Rt=(t,e,r)=>{if(typeof r=="string")return t[e].pipe(wn(r)),t;if(fo(r))return t[e].pipe(r),t;if(!Na(r))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!fo(r.stdin))throw new TypeError("The target child process's stdin must be available.");return t[e].pipe(r.stdin),r},Ta=t=>{t.stdout!==null&&(t.pipeStdout=Rt.bind(void 0,t,"stdout")),t.stderr!==null&&(t.pipeStderr=Rt.bind(void 0,t,"stderr")),t.all!==void 0&&(t.pipeAll=Rt.bind(void 0,t,"all"))};var ge={exports:{}};const{PassThrough:_a}=it;var ja=t=>{t={...t};const{array:e}=t;let{encoding:r}=t;const o=r==="buffer";let n=!1;e?n=!(r||o):r=r||"utf8",o&&(r=null);const s=new _a({objectMode:n});r&&s.setEncoding(r);let i=0;const u=[];return s.on("data",a=>{u.push(a),n?i=u.length:i+=a.length}),s.getBufferedValue=()=>e?u:o?Buffer.concat(u,i):u.join(""),s.getBufferedLength=()=>i,s};const{constants:Ga}=bn,Ha=it,{promisify:Ua}=hr,qa=ja,za=Ua(Ha.pipeline);class ho extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function Ot(t,e){if(!t)throw new Error("Expected a stream");e={maxBuffer:1/0,...e};const{maxBuffer:r}=e,o=qa(e);return await new Promise((n,s)=>{const i=u=>{u&&o.getBufferedLength()<=Ga.MAX_LENGTH&&(u.bufferedData=o.getBufferedValue()),s(u)};(async()=>{try{await za(t,o),n()}catch(u){i(u)}})(),o.on("data",()=>{o.getBufferedLength()>r&&i(new ho)})}),o.getBufferedValue()}ge.exports=Ot,ge.exports.buffer=(t,e)=>Ot(t,{...e,encoding:"buffer"}),ge.exports.array=(t,e)=>Ot(t,{...e,array:!0}),ge.exports.MaxBufferError=ho;var Wa=ge.exports,go=se(Wa);const{PassThrough:Ka}=it;var Va=function(){var t=[],e=new Ka({objectMode:!0});return e.setMaxListeners(0),e.add=r,e.isEmpty=o,e.on("unpipe",n),Array.prototype.slice.call(arguments).forEach(r),e;function r(s){return Array.isArray(s)?(s.forEach(r),this):(t.push(s),s.once("end",n.bind(null,s)),s.once("error",e.emit.bind(e,"error")),s.pipe(e,{end:!1}),this)}function o(){return t.length==0}function n(s){t=t.filter(function(i){return i!==s}),!t.length&&e.readable&&e.end()}},Ja=se(Va);const Ya=t=>{if(t!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},Xa=({input:t,inputFile:e})=>typeof e!="string"?t:(Ya(t),vn(e)),Za=(t,e)=>{const r=Xa(e);r!==void 0&&(po(r)?r.pipe(t.stdin):t.stdin.end(r))},Qa=(t,{all:e})=>{if(!e||!t.stdout&&!t.stderr)return;const r=Ja();return t.stdout&&r.add(t.stdout),t.stderr&&r.add(t.stderr),r},kt=async(t,e)=>{if(!(!t||e===void 0)){t.destroy();try{return await e}catch(r){return r.bufferedData}}},It=(t,{encoding:e,buffer:r,maxBuffer:o})=>{if(!(!t||!r))return e?go(t,{encoding:e,maxBuffer:o}):go.buffer(t,{maxBuffer:o})},eu=async({stdout:t,stderr:e,all:r},{encoding:o,buffer:n,maxBuffer:s},i)=>{const u=It(t,{encoding:o,buffer:n,maxBuffer:s}),a=It(e,{encoding:o,buffer:n,maxBuffer:s}),l=It(r,{encoding:o,buffer:n,maxBuffer:s*2});try{return await Promise.all([i,u,a,l])}catch(m){return Promise.all([{error:m,signal:m.signal,timedOut:m.timedOut},kt(t,u),kt(e,a),kt(r,l)])}},tu=(async()=>{})().constructor.prototype,ru=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(tu,t)]),Co=(t,e)=>{for(const[r,o]of ru){const n=typeof e=="function"?(...s)=>Reflect.apply(o.value,e(),s):o.value.bind(e);Reflect.defineProperty(t,r,{...o,value:n})}},ou=t=>new Promise((e,r)=>{t.on("exit",(o,n)=>{e({exitCode:o,signal:n})}),t.on("error",o=>{r(o)}),t.stdin&&t.stdin.on("error",o=>{r(o)})}),yo=(t,e=[])=>Array.isArray(e)?[t,...e]:[t],nu=/^[\w.-]+$/,su=/"/g,iu=t=>typeof t!="string"||nu.test(t)?t:`"${t.replace(su,'\\"')}"`,au=(t,e)=>yo(t,e).join(" "),uu=(t,e)=>yo(t,e).map(r=>iu(r)).join(" "),cu=$n("execa").enabled,He=(t,e)=>String(t).padStart(e,"0"),lu=()=>{const t=new Date;return`${He(t.getHours(),2)}:${He(t.getMinutes(),2)}:${He(t.getSeconds(),2)}.${He(t.getMilliseconds(),3)}`},Du=(t,{verbose:e})=>{e&&z.stderr.write(`[${lu()}] ${t}
28
- `)},mu=1e3*1e3*100,du=({env:t,extendEnv:e,preferLocal:r,localDir:o,execPath:n})=>{const s=e?{...z.env,...t}:t;return r?Xi({env:s,cwd:o,execPath:n}):s},pu=(t,e,r={})=>{const o=Wi._parse(t,e,r);return t=o.command,e=o.args,r=o.options,r={maxBuffer:mu,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:r.cwd||z.cwd(),execPath:z.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:cu,...r},r.env=du(r),r.stdio=Ca(r),z.platform==="win32"&&ne.basename(t,".exe")==="cmd"&&e.unshift("/q"),{file:t,args:e,options:r,parsed:o}},Lt=(t,e,r)=>typeof e!="string"&&!Cn.isBuffer(e)?r===void 0?void 0:"":t.stripFinalNewline?Ki(e):e;function re(t,e,r){const o=pu(t,e,r),n=au(t,e),s=uu(t,e);Du(s,o.options),Ia(o.options);let i;try{i=Dr.spawn(o.file,o.args,o.options)}catch(d){const f=new Dr.ChildProcess,h=Promise.reject(co({error:d,stdout:"",stderr:"",all:"",command:n,escapedCommand:s,parsed:o,timedOut:!1,isCanceled:!1,killed:!1}));return Co(f,h),f}const u=ou(i),a=ka(i,o.options,u),l=La(i,o.options,a),m={isCanceled:!1};i.kill=Pa.bind(null,i.kill.bind(i)),i.cancel=Ra.bind(null,i,m);const D=so(async()=>{const[{error:d,exitCode:f,signal:h,timedOut:g},y,w,S]=await eu(i,o.options,l),V=Lt(o.options,y),J=Lt(o.options,w),me=Lt(o.options,S);if(d||f!==0||h!==null){const Y=co({error:d,exitCode:f,signal:h,stdout:V,stderr:J,all:me,command:n,escapedCommand:s,parsed:o,timedOut:g,isCanceled:m.isCanceled||(o.options.signal?o.options.signal.aborted:!1),killed:i.killed});if(!o.options.reject)return Y;throw Y}return{command:n,escapedCommand:s,exitCode:0,stdout:V,stderr:J,all:me,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return Za(i,o.options),i.all=Qa(i,o.options),Ta(i),Co(i,D),i}class x{static create(e,r){return new e(r)}}const Ue=t=>t&&`${t[0].toUpperCase()}${t.slice(1)}`,qe=(t,e)=>{const r=Math.ceil(t),o=Math.floor(e);return Math.floor(Math.random()*(o-r+1))+r},fu=(t,e)=>t.disabled&&!e.disabled?1:!t.disabled&&e.disabled?-1:0,ze=t=>t.reduce((e,r)=>Array.isArray(r)?e.concat(ze(r)):e.concat(r),[]),Eo=(t,e=5)=>t.replace(/[\n\r]/g,"").split(" ").slice(0,e).join(" "),hu=t=>{let e=0;for(let r=0;r<t.length;r++){const o=t.charCodeAt(r);e=(e<<5)-e+o,e=e&e}return Math.abs(e)},gu=t=>{const e=t%360,r=65+t%15,o=45+t%10;return`hsl(${e}, ${r}%, ${o}%)`},Cu=t=>{const[e,r,o]=t.match(/\d+/g).map((c,D)=>D===0?Number(c):Number(c)/100),n=(1-Math.abs(2*o-1))*r,s=n*(1-Math.abs(e/60%2-1)),i=o-n/2;let u,a,l;e<60?[u,a,l]=[n,s,0]:e<120?[u,a,l]=[s,n,0]:e<180?[u,a,l]=[0,n,s]:e<240?[u,a,l]=[0,s,n]:e<300?[u,a,l]=[s,0,n]:[u,a,l]=[n,0,s];const m=c=>{const D=Math.round((c+i)*255).toString(16);return D.length===1?"0"+D:D};return`#${m(u)}${m(a)}${m(l)}`},yu=t=>{const e=hu(t),r=gu(e);return{primary:Cu(r),secondary:"#FFFFFF"}};class G{constructor(e){this.handleError$=r=>{let o="An error occurred";return r.message&&(o=r.message),O({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.serviceName="AI",this.errorPrefix="ERROR",this.colors={primary:""}}parseMessage(e,r,o){try{let n;const s=l=>l.replace(/[\u0000-\u001F\u007F-\u009F]/g,"").replace(/\\(?!["\\/bfnrtu])/g,"\\\\"),i=/\[\s*\{[\s\S]*?\}\s*\]/,u=e.match(i);if(u)try{const l=JSON.parse(s(u[0]));n=Array.isArray(l)?l:[l]}catch{return[]}else{const l=/\{[\s\S]*?\}/,m=e.match(l);if(!m)return[];try{n=[JSON.parse(s(m[0]))]}catch{return[]}}return!n.length||!n.every(l=>typeof l.subject=="string")?[]:n.map(l=>this.extractMessageAsType(l,r)).map(l=>({title:`${l.subject}`,value:`${l.subject}${l.body?`
27
+ `);return y?(o.originalMessage=o.message,o.message=S):o=new Error(S),o.shortMessage=w,o.command=i,o.escapedCommand=u,o.exitCode=s,o.signal=n,o.signalDescription=d,o.stdout=t,o.stderr=e,o.cwd=D,r!==void 0&&(o.all=r),"bufferedData"in o&&delete o.bufferedData,o.failed=!0,o.timedOut=!!a,o.isCanceled=l,o.killed=m&&!a,o},_e=["stdin","stdout","stderr"],ga=t=>_e.some(e=>t[e]!==void 0),Ca=t=>{if(!t)return;const{stdio:e}=t;if(e===void 0)return _e.map(o=>t[o]);if(ga(t))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${_e.map(o=>`\`${o}\``).join(", ")}`);if(typeof e=="string")return e;if(!Array.isArray(e))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof e}\``);const r=Math.max(e.length,_e.length);return Array.from({length:r},(o,n)=>e[n])};var ue={exports:{}},je={exports:{}};je.exports;var uo;function ya(){return uo||(uo=1,function(t){t.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"],process.platform!=="win32"&&t.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),process.platform==="linux"&&t.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")}(je)),je.exports}var B=R.process;const te=function(t){return t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function"};if(!te(B))ue.exports=function(){return function(){}};else{var Ea=mr,fe=ya(),Fa=/^win/i.test(B.platform),Ge=dr;typeof Ge!="function"&&(Ge=Ge.EventEmitter);var k;B.__signal_exit_emitter__?k=B.__signal_exit_emitter__:(k=B.__signal_exit_emitter__=new Ge,k.count=0,k.emitted={}),k.infinite||(k.setMaxListeners(1/0),k.infinite=!0),ue.exports=function(t,e){if(!te(R.process))return function(){};Ea.equal(typeof t,"function","a callback must be provided for exit handler"),he===!1&&co();var r="exit";e&&e.alwaysLast&&(r="afterexit");var o=function(){k.removeListener(r,t),k.listeners("exit").length===0&&k.listeners("afterexit").length===0&&xt()};return k.on(r,t),o};var xt=function(){!he||!te(R.process)||(he=!1,fe.forEach(function(e){try{B.removeListener(e,Mt[e])}catch{}}),B.emit=St,B.reallyExit=lo,k.count-=1)};ue.exports.unload=xt;var ce=function(e,r,o){k.emitted[e]||(k.emitted[e]=!0,k.emit(e,r,o))},Mt={};fe.forEach(function(t){Mt[t]=function(){if(te(R.process)){var r=B.listeners(t);r.length===k.count&&(xt(),ce("exit",null,t),ce("afterexit",null,t),Fa&&t==="SIGHUP"&&(t="SIGINT"),B.kill(B.pid,t))}}}),ue.exports.signals=function(){return fe};var he=!1,co=function(){he||!te(R.process)||(he=!0,k.count+=1,fe=fe.filter(function(e){try{return B.on(e,Mt[e]),!0}catch{return!1}}),B.emit=va,B.reallyExit=wa)};ue.exports.load=co;var lo=B.reallyExit,wa=function(e){te(R.process)&&(B.exitCode=e||0,ce("exit",B.exitCode,null),ce("afterexit",B.exitCode,null),lo.call(B,B.exitCode))},St=B.emit,va=function(e,r){if(e==="exit"&&te(R.process)){r!==void 0&&(B.exitCode=r);var o=St.apply(this,arguments);return ce("exit",B.exitCode,null),ce("afterexit",B.exitCode,null),o}else return St.apply(this,arguments)}}var ba=ue.exports,$a=se(ba);const Aa=1e3*5,Pa=(t,e="SIGTERM",r={})=>{const o=t(e);return Ba(t,e,r,o),o},Ba=(t,e,r,o)=>{if(!xa(e,r,o))return;const n=Sa(r),s=setTimeout(()=>{t("SIGKILL")},n);s.unref&&s.unref()},xa=(t,{forceKillAfterTimeout:e},r)=>Ma(t)&&e!==!1&&r,Ma=t=>t===Fn.constants.signals.SIGTERM||typeof t=="string"&&t.toUpperCase()==="SIGTERM",Sa=({forceKillAfterTimeout:t=!0})=>{if(t===!0)return Aa;if(!Number.isFinite(t)||t<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${t}\` (${typeof t})`);return t},Ra=(t,e)=>{t.kill()&&(e.isCanceled=!0)},Oa=(t,e,r)=>{t.kill(e),r(Object.assign(new Error("Timed out"),{timedOut:!0,signal:e}))},ka=(t,{timeout:e,killSignal:r="SIGTERM"},o)=>{if(e===0||e===void 0)return o;let n;const s=new Promise((u,a)=>{n=setTimeout(()=>{Oa(t,r,a)},e)}),i=o.finally(()=>{clearTimeout(n)});return Promise.race([s,i])},Ia=({timeout:t})=>{if(t!==void 0&&(!Number.isFinite(t)||t<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${t}\` (${typeof t})`)},La=async(t,{cleanup:e,detached:r},o)=>{if(!e||r)return o;const n=$a(()=>{t.kill()});return o.finally(()=>{n()})};function Do(t){return t!==null&&typeof t=="object"&&typeof t.pipe=="function"}function mo(t){return Do(t)&&t.writable!==!1&&typeof t._write=="function"&&typeof t._writableState=="object"}const Na=t=>t instanceof yn&&typeof t.then=="function",Rt=(t,e,r)=>{if(typeof r=="string")return t[e].pipe(wn(r)),t;if(mo(r))return t[e].pipe(r),t;if(!Na(r))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!mo(r.stdin))throw new TypeError("The target child process's stdin must be available.");return t[e].pipe(r.stdin),r},Ta=t=>{t.stdout!==null&&(t.pipeStdout=Rt.bind(void 0,t,"stdout")),t.stderr!==null&&(t.pipeStderr=Rt.bind(void 0,t,"stderr")),t.all!==void 0&&(t.pipeAll=Rt.bind(void 0,t,"all"))};var ge={exports:{}};const{PassThrough:_a}=it;var ja=t=>{t={...t};const{array:e}=t;let{encoding:r}=t;const o=r==="buffer";let n=!1;e?n=!(r||o):r=r||"utf8",o&&(r=null);const s=new _a({objectMode:n});r&&s.setEncoding(r);let i=0;const u=[];return s.on("data",a=>{u.push(a),n?i=u.length:i+=a.length}),s.getBufferedValue=()=>e?u:o?Buffer.concat(u,i):u.join(""),s.getBufferedLength=()=>i,s};const{constants:Ga}=bn,Ha=it,{promisify:Ua}=pr,qa=ja,za=Ua(Ha.pipeline);class po extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function Ot(t,e){if(!t)throw new Error("Expected a stream");e={maxBuffer:1/0,...e};const{maxBuffer:r}=e,o=qa(e);return await new Promise((n,s)=>{const i=u=>{u&&o.getBufferedLength()<=Ga.MAX_LENGTH&&(u.bufferedData=o.getBufferedValue()),s(u)};(async()=>{try{await za(t,o),n()}catch(u){i(u)}})(),o.on("data",()=>{o.getBufferedLength()>r&&i(new po)})}),o.getBufferedValue()}ge.exports=Ot,ge.exports.buffer=(t,e)=>Ot(t,{...e,encoding:"buffer"}),ge.exports.array=(t,e)=>Ot(t,{...e,array:!0}),ge.exports.MaxBufferError=po;var Wa=ge.exports,fo=se(Wa);const{PassThrough:Ka}=it;var Va=function(){var t=[],e=new Ka({objectMode:!0});return e.setMaxListeners(0),e.add=r,e.isEmpty=o,e.on("unpipe",n),Array.prototype.slice.call(arguments).forEach(r),e;function r(s){return Array.isArray(s)?(s.forEach(r),this):(t.push(s),s.once("end",n.bind(null,s)),s.once("error",e.emit.bind(e,"error")),s.pipe(e,{end:!1}),this)}function o(){return t.length==0}function n(s){t=t.filter(function(i){return i!==s}),!t.length&&e.readable&&e.end()}},Ja=se(Va);const Ya=t=>{if(t!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},Xa=({input:t,inputFile:e})=>typeof e!="string"?t:(Ya(t),vn(e)),Za=(t,e)=>{const r=Xa(e);r!==void 0&&(Do(r)?r.pipe(t.stdin):t.stdin.end(r))},Qa=(t,{all:e})=>{if(!e||!t.stdout&&!t.stderr)return;const r=Ja();return t.stdout&&r.add(t.stdout),t.stderr&&r.add(t.stderr),r},kt=async(t,e)=>{if(!(!t||e===void 0)){t.destroy();try{return await e}catch(r){return r.bufferedData}}},It=(t,{encoding:e,buffer:r,maxBuffer:o})=>{if(!(!t||!r))return e?fo(t,{encoding:e,maxBuffer:o}):fo.buffer(t,{maxBuffer:o})},eu=async({stdout:t,stderr:e,all:r},{encoding:o,buffer:n,maxBuffer:s},i)=>{const u=It(t,{encoding:o,buffer:n,maxBuffer:s}),a=It(e,{encoding:o,buffer:n,maxBuffer:s}),l=It(r,{encoding:o,buffer:n,maxBuffer:s*2});try{return await Promise.all([i,u,a,l])}catch(m){return Promise.all([{error:m,signal:m.signal,timedOut:m.timedOut},kt(t,u),kt(e,a),kt(r,l)])}},tu=(async()=>{})().constructor.prototype,ru=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(tu,t)]),ho=(t,e)=>{for(const[r,o]of ru){const n=typeof e=="function"?(...s)=>Reflect.apply(o.value,e(),s):o.value.bind(e);Reflect.defineProperty(t,r,{...o,value:n})}},ou=t=>new Promise((e,r)=>{t.on("exit",(o,n)=>{e({exitCode:o,signal:n})}),t.on("error",o=>{r(o)}),t.stdin&&t.stdin.on("error",o=>{r(o)})}),go=(t,e=[])=>Array.isArray(e)?[t,...e]:[t],nu=/^[\w.-]+$/,su=/"/g,iu=t=>typeof t!="string"||nu.test(t)?t:`"${t.replace(su,'\\"')}"`,au=(t,e)=>go(t,e).join(" "),uu=(t,e)=>go(t,e).map(r=>iu(r)).join(" "),cu=$n("execa").enabled,He=(t,e)=>String(t).padStart(e,"0"),lu=()=>{const t=new Date;return`${He(t.getHours(),2)}:${He(t.getMinutes(),2)}:${He(t.getSeconds(),2)}.${He(t.getMilliseconds(),3)}`},Du=(t,{verbose:e})=>{e&&z.stderr.write(`[${lu()}] ${t}
28
+ `)},mu=1e3*1e3*100,du=({env:t,extendEnv:e,preferLocal:r,localDir:o,execPath:n})=>{const s=e?{...z.env,...t}:t;return r?Xi({env:s,cwd:o,execPath:n}):s},pu=(t,e,r={})=>{const o=Wi._parse(t,e,r);return t=o.command,e=o.args,r=o.options,r={maxBuffer:mu,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:r.cwd||z.cwd(),execPath:z.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:cu,...r},r.env=du(r),r.stdio=Ca(r),z.platform==="win32"&&ne.basename(t,".exe")==="cmd"&&e.unshift("/q"),{file:t,args:e,options:r,parsed:o}},Lt=(t,e,r)=>typeof e!="string"&&!Cn.isBuffer(e)?r===void 0?void 0:"":t.stripFinalNewline?Ki(e):e;function re(t,e,r){const o=pu(t,e,r),n=au(t,e),s=uu(t,e);Du(s,o.options),Ia(o.options);let i;try{i=cr.spawn(o.file,o.args,o.options)}catch(d){const f=new cr.ChildProcess,h=Promise.reject(ao({error:d,stdout:"",stderr:"",all:"",command:n,escapedCommand:s,parsed:o,timedOut:!1,isCanceled:!1,killed:!1}));return ho(f,h),f}const u=ou(i),a=ka(i,o.options,u),l=La(i,o.options,a),m={isCanceled:!1};i.kill=Pa.bind(null,i.kill.bind(i)),i.cancel=Ra.bind(null,i,m);const D=oo(async()=>{const[{error:d,exitCode:f,signal:h,timedOut:g},y,w,S]=await eu(i,o.options,l),V=Lt(o.options,y),J=Lt(o.options,w),me=Lt(o.options,S);if(d||f!==0||h!==null){const Y=ao({error:d,exitCode:f,signal:h,stdout:V,stderr:J,all:me,command:n,escapedCommand:s,parsed:o,timedOut:g,isCanceled:m.isCanceled||(o.options.signal?o.options.signal.aborted:!1),killed:i.killed});if(!o.options.reject)return Y;throw Y}return{command:n,escapedCommand:s,exitCode:0,stdout:V,stderr:J,all:me,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return Za(i,o.options),i.all=Qa(i,o.options),Ta(i),ho(i,D),i}class x{static create(e,r){return new e(r)}}const Ue=t=>t&&`${t[0].toUpperCase()}${t.slice(1)}`,qe=(t,e)=>{const r=Math.ceil(t),o=Math.floor(e);return Math.floor(Math.random()*(o-r+1))+r},fu=(t,e)=>t.disabled&&!e.disabled?1:!t.disabled&&e.disabled?-1:0,ze=t=>t.reduce((e,r)=>Array.isArray(r)?e.concat(ze(r)):e.concat(r),[]),Co=(t,e=5)=>t.replace(/[\n\r]/g,"").split(" ").slice(0,e).join(" "),hu=t=>{let e=0;for(let r=0;r<t.length;r++){const o=t.charCodeAt(r);e=(e<<5)-e+o,e=e&e}return Math.abs(e)},gu=t=>{const e=t%360,r=65+t%15,o=45+t%10;return`hsl(${e}, ${r}%, ${o}%)`},Cu=t=>{const[e,r,o]=t.match(/\d+/g).map((c,D)=>D===0?Number(c):Number(c)/100),n=(1-Math.abs(2*o-1))*r,s=n*(1-Math.abs(e/60%2-1)),i=o-n/2;let u,a,l;e<60?[u,a,l]=[n,s,0]:e<120?[u,a,l]=[s,n,0]:e<180?[u,a,l]=[0,n,s]:e<240?[u,a,l]=[0,s,n]:e<300?[u,a,l]=[s,0,n]:[u,a,l]=[n,0,s];const m=c=>{const D=Math.round((c+i)*255).toString(16);return D.length===1?"0"+D:D};return`#${m(u)}${m(a)}${m(l)}`},yu=t=>{const e=hu(t),r=gu(e);return{primary:Cu(r),secondary:"#FFFFFF"}};class G{constructor(e){this.handleError$=r=>{let o="An error occurred";return r.message&&(o=r.message),O({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.serviceName="AI",this.errorPrefix="ERROR",this.colors={primary:""}}parseMessage(e,r,o){try{let n;const s=l=>l.replace(/[\u0000-\u001F\u007F-\u009F]/g,"").replace(/\\(?!["\\/bfnrtu])/g,"\\\\"),i=/\[\s*\{[\s\S]*?\}\s*\]/,u=e.match(i);if(u)try{const l=JSON.parse(s(u[0]));n=Array.isArray(l)?l:[l]}catch{return[]}else{const l=/\{[\s\S]*?\}/,m=e.match(l);if(!m)return[];try{n=[JSON.parse(s(m[0]))]}catch{return[]}}return!n.length||!n.every(l=>typeof l.subject=="string")?[]:n.map(l=>this.extractMessageAsType(l,r)).map(l=>({title:`${l.subject}`,value:`${l.subject}${l.body?`
29
29
 
30
30
  ${l.body}`:""}${l.footer?`
31
31
 
32
- ${l.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:`${Eo(e)}...`,value:e}]}catch{return[]}return e.map(r=>{try{return{title:`${Eo(r)}...`,value:r}}catch{return{title:"",value:""}}})}}var Fo="2.2.9",Eu="A Reactive CLI that generates git commit messages with various AI";class E extends Error{}const Nt=" ",oe=t=>{t instanceof Error&&(t instanceof E||(t.stack&&console.error(C.dim(t.stack.split(`
32
+ ${l.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:`${Co(e)}...`,value:e}]}catch{return[]}return e.map(r=>{try{return{title:`${Co(r)}...`,value:r}}catch{return{title:"",value:""}}})}}var yo="2.2.10",Eu="A Reactive CLI that generates git commit messages with various AI";class E extends Error{}const Nt=" ",oe=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
- ${Nt}${C.dim(`aicommit2 v${Fo}`)}`),console.error(`
36
- ${Nt}Please open a Bug report with the information above:`),console.error(`${Nt}https://github.com/tak-bro/aicommit2/issues/new/choose`)))},wo=I.join(ut.homedir(),".aicommit2_log"),Fu=new Date,H=(t,e,r,o,n)=>{const s=`[${t}]`,i=wu(Fu,e,n),u=`${wo}/${i}`,a=`- System Prompt
35
+ ${Nt}${C.dim(`aicommit2 v${yo}`)}`),console.error(`
36
+ ${Nt}Please open a Bug report with the information above:`),console.error(`${Nt}https://github.com/tak-bro/aicommit2/issues/new/choose`)))},Eo=I.join(ut.homedir(),".aicommit2_log"),Fu=new Date,H=(t,e,r,o,n)=>{const s=`[${t}]`,i=wu(Fu,e,n),u=`${Eo}/${i}`,a=`- System Prompt
37
37
  ${r}`,l=`- Response
38
38
  ${o}`,m=`[Git Diff]
39
- ${e}`;if(N.existsSync(u)){const c=N.readFileSync(u,"utf-8");vo(u,`${s}
39
+ ${e}`;if(N.existsSync(u)){const c=N.readFileSync(u,"utf-8");Fo(u,`${s}
40
40
  ${l}
41
41
 
42
42
  ${a}
43
43
 
44
- ${c}`);return}vo(u,`${s}
44
+ ${c}`);return}Fo(u,`${s}
45
45
  ${l}
46
46
 
47
47
  ${a}
48
48
 
49
- ${m}`)},wu=(t,e,r)=>{const{year:o,month:n,day:s,hours:i,minutes:u,seconds:a}=vu(t),m=Bn(0).update(e).digest("hex");return r==="review"?`aic2_review_${o}-${n}-${s}_${i}-${u}-${a}_${m}.log`:`aic2_${o}-${n}-${s}_${i}-${u}-${a}_${m}.log`},vo=(t,e="")=>{N.mkdirSync(I.dirname(t),{recursive:!0}),N.writeFileSync(t,e,"utf-8")},vu=t=>{const e=t.getFullYear().toString(),r=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),n=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0"),i=t.getSeconds().toString().padStart(2,"0");return{year:e,month:r,day:o,hours:n,minutes:s,seconds:i}},j={locale:"en",maxLength:50,type:"conventional",generate:1,systemPrompt:"",systemPromptPath:"",codeReviewPromptPath:""},bu={"":"<commit message>",conventional:`<type>(<optional scope>): <description>
49
+ ${m}`)},wu=(t,e,r)=>{const{year:o,month:n,day:s,hours:i,minutes:u,seconds:a}=vu(t),m=Bn(0).update(e).digest("hex");return r==="review"?`aic2_review_${o}-${n}-${s}_${i}-${u}-${a}_${m}.log`:`aic2_${o}-${n}-${s}_${i}-${u}-${a}_${m}.log`},Fo=(t,e="")=>{N.mkdirSync(I.dirname(t),{recursive:!0}),N.writeFileSync(t,e,"utf-8")},vu=t=>{const e=t.getFullYear().toString(),r=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),n=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0"),i=t.getSeconds().toString().padStart(2,"0");return{year:e,month:r,day:o,hours:n,minutes:s,seconds:i}},j={locale:"en",maxLength:50,type:"conventional",generate:1,systemPrompt:"",systemPromptPath:"",codeReviewPromptPath:""},bu={"":"<commit message>",conventional:`<type>(<optional scope>): <description>
50
50
 
51
51
  [optional body]
52
52
 
@@ -58,7 +58,7 @@ ${m}`)},wu=(t,e,r)=>{const{year:o,month:n,day:s,hours:i,minutes:u,seconds:a}=vu(
58
58
  ${Object.entries({":sparkles:":"Introduce new features.",":bug:":"Fix a bug.",":memo:":"Add or update documentation.",":art:":"Improve structure / format of the code.",":zap:":"Improve performance.",":fire:":"Remove code or files.",":ambulance:":"Critical hotfix.",":white_check_mark:":"Add, update, or pass tests.",":lock:":"Fix security or privacy issues.",":rocket:":"Deploy stuff.",":lipstick:":"Add or update the UI and style files.",":tada:":"Begin a project.",":recycle:":"Refactor code.",":wrench:":"Add or update configuration files.",":bulb:":"Add or update comments in source code.",":twisted_rightwards_arrows:":"Merge branches."}).map(([t,e])=>` - ${t}: ${e}`).join(`
59
59
  `)}`,conventional:`
60
60
  ${Object.entries({docs:"Documentation only changes",style:"Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)",refactor:"A code change that neither fixes a bug nor adds a feature",perf:"A code change that improves performance",test:"Adding missing tests or correcting existing tests",build:"Changes that affect the build system or external dependencies",ci:"Changes to CI configuration files, scripts",chore:"Other changes that don't modify src or test files",revert:"Reverts a previous commit",feat:"A new feature",fix:"A bug fix"}).map(([t,e])=>` - ${t}: ${e}`).join(`
61
- `)}`},bo=(t,e)=>t.replace(/{(\w+)}/g,(r,o)=>e[o]?.toString()||j[o]?.toString()),$o=t=>{const{type:e,maxLength:r,generate:o,locale:n}=t;return[`You are a helpful assistant specializing in writing clear and informative Git commit messages using the ${e} style`,`Based on the given code changes or context, generate exactly ${o} ${e} Git commit message${o!==1?"s":""} based on the following guidelines.`,`1. Message Language: ${n}`,`2. Format: follow the ${e} Commits format:`,`${bu[e]}`,`3. Types: use one of the following types:${$u[e]}`,"4. Guidelines for writing commit messages:"," - Be specific about what changes were made",' - Use imperative mood ("add feature" not "added feature")',` - Keep subject line under ${r} characters`," - Do not end the subject line with a period"," - Use the body to explain what and why vs. how","5. Focus on:"," - What problem this commit solves"," - Why this change was necessary"," - Any important technical details","6. Exclude anything unnecessary such as translation or implementation details."].filter(Boolean).join(`
61
+ `)}`},wo=(t,e)=>t.replace(/{(\w+)}/g,(r,o)=>e[o]?.toString()||j[o]?.toString()),vo=t=>{const{type:e,maxLength:r,generate:o,locale:n}=t;return[`You are a helpful assistant specializing in writing clear and informative Git commit messages using the ${e} style`,`Based on the given code changes or context, generate exactly ${o} ${e} Git commit message${o!==1?"s":""} based on the following guidelines.`,`1. Message Language: ${n}`,`2. Format: follow the ${e} Commits format:`,`${bu[e]}`,`3. Types: use one of the following types:${$u[e]}`,"4. Guidelines for writing commit messages:"," - Be specific about what changes were made",' - Use imperative mood ("add feature" not "added feature")',` - Keep subject line under ${r} characters`," - Do not end the subject line with a period"," - Use the body to explain what and why vs. how","5. Focus on:"," - What problem this commit solves"," - Why this change was necessary"," - Any important technical details","6. Exclude anything unnecessary such as translation or implementation details."].filter(Boolean).join(`
62
62
  `)},We=(t,e)=>{const r=o=>o==="conventional"?`${Array(e).fill(null).map((n,s)=>`
63
63
  {
64
64
  "subject": "fix(auth): fix bug in user authentication process",
@@ -74,9 +74,9 @@ Lastly, Provide your response as a JSON array containing exactly ${e} object${e!
74
74
  [${r(t)}
75
75
  ]`,`Ensure you generate exactly ${e} commit message${e!==1?"s":""}, even if it requires creating slightly varied versions for similar changes.`,"The response should be valid JSON that can be parsed without errors."].filter(Boolean).join(`
76
76
  `)},U=t=>{const{systemPrompt:e,systemPromptPath:r,type:o,generate:n}=t;if(e)return`${e}
77
- ${We(o,n)}`;if(!r)return`${$o(t)}
78
- ${We(o,n)}`;try{const s=N.readFileSync(I.resolve(r),"utf-8");return`${bo(s,t)}
79
- ${We(o,n)}`}catch{return`${$o(t)}
77
+ ${We(o,n)}`;if(!r)return`${vo(t)}
78
+ ${We(o,n)}`;try{const s=N.readFileSync(I.resolve(r),"utf-8");return`${wo(s,t)}
79
+ ${We(o,n)}`}catch{return`${vo(t)}
80
80
  ${We(o,n)}`}},q=t=>{const{codeReviewPromptPath:e,locale:r}=t,o=`I'll give you the output of the "git diff" command as an input. Please review the following code and provide your feedback in Markdown format. Focus on:
81
81
 
82
82
  1. Language: ${r}
@@ -85,27 +85,27 @@ ${We(o,n)}`}},q=t=>{const{codeReviewPromptPath:e,locale:r}=t,o=`I'll give you th
85
85
  4. Performance improvements
86
86
  5. Readability and maintainability
87
87
 
88
- Please structure your response with appropriate Markdown headings, code blocks, and bullet points.`;if(!e)return o;try{const n=N.readFileSync(I.resolve(e),"utf-8");return`${bo(n,t)}`}catch{return o}},Ao=async t=>{if(t.systemPromptPath)try{N.readFileSync(I.resolve(t.systemPromptPath),"utf-8")}catch{throw new E(`Error reading system prompt file: ${t.systemPromptPath}`)}if(t.codeReview&&t.codeReviewPromptPath)try{N.readFileSync(I.resolve(t.codeReviewPromptPath),"utf-8")}catch{throw new E(`Error reading code review prompt file: ${t.codeReviewPromptPath}`)}};class Po 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 O({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 Pn({apiKey:this.params.config.key})}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(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:d,model:f}=this.params.config,h={...j,locale:a,maxLength:c,type:m,generate:l,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},g=e==="review"?q(h):U(h),y={max_tokens:D,temperature:u,system:g,messages:[{role:"user",content:`Here is the diff: ${r}`}],top_p:d,model:f},S=(await this.anthropic.messages.create(y)).content.map(({text:V})=>V).join("");return i&&H("Anthropic",r,g,S,e),e==="review"?this.sanitizeResponse(S):this.parseMessage(S,m,l)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new E(`Error connecting to ${o.hostname} (${o.syscall})`):o}}}class Ce{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=xn.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 Bo 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 O({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=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(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"?q(c):U(c);this.checkAvailableModels();const d=await this.createChatCompletions(D,e);return i&&H("Codestral",r,D,d,e),e==="review"?this.sanitizeResponse(d):this.parseMessage(d,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 Ce({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:qe(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 xo 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 O({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 Mn({token:this.params.config.key})}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(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:d,model:f}=this.params.config,h={...j,locale:a,maxLength:c,type:m,generate:l,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},g=e==="review"?q(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:qe(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 Sn?new E("Request timed out error!"):o}}}class Mo 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 O({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 xe({baseURL:this.host,apiKey:this.params.config.key})}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(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"?q(c):U(c);this.checkAvailableModels();const d=await this.createChatCompletions(D);return i&&H("DeepSeek",r,D,d,e),e==="review"?this.sanitizeResponse(d):this.parseMessage(d,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 So 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 O({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 Rn(this.params.config.key)}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(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},d=e==="review"?q(D):U(D),f={maxOutputTokens:c,temperature:this.params.config.temperature,topP:this.params.config.topP},w=(await this.genAI.getGenerativeModel({model:this.params.config.model,systemInstruction:d,generationConfig:f,safetySettings:[{category:Me.HARM_CATEGORY_HATE_SPEECH,threshold:Se.BLOCK_LOW_AND_ABOVE},{category:Me.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:Se.BLOCK_LOW_AND_ABOVE},{category:Me.HARM_CATEGORY_HARASSMENT,threshold:Se.BLOCK_LOW_AND_ABOVE},{category:Me.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:Se.BLOCK_LOW_AND_ABOVE}]}).generateContent(`Here is the diff: ${r}`)).response.text();return s&&H("Gemini",r,d,w,e),e==="review"?this.sanitizeResponse(w):this.parseMessage(w,l,a)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new E(`Error connecting to ${o.hostname} (${o.syscall})`):o}}}class Ro extends G{constructor(e){super(e),this.params=e,this.handleError$=r=>{let o="N/A",n="An error occurred";r instanceof wr.APIError&&(o=`${r.status}`,n=r.name);const s=`${o} ${n}`;return O({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 wr({apiKey:this.params.config.key})}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(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,d={...j,locale:u,maxLength:c,type:m,generate:l,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},f=e==="review"?q(d):U(d),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 Oo 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=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(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"?q(c):U(c),d=await this.getNewChat(D),h=await(await this.sendMessage(`Here is the diff: ${r}`,d.id)).completeResponsePromise();return await this.deleteConversation(d.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 d=m.map(f=>i(f));l.promptExamples=d.map(f=>({title:o[f.title],prompt:o[f.prompt]}))}const c=i(a.parameters),D={};for(const[d,f]of Object.entries(c)){if(f===-1){D[d]=null;continue}if(Array.isArray(o[f])){D[d]=o[f].map(h=>o[h]);continue}D[d]=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,d=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:d})}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 d=D.split(`
89
- `),f=[];for(const h of d)h.trim()&&f.push(JSON.parse(h));return f}catch{return[{}]}}const u=new TextDecoder;let a="";const l=new TransformStream({async transform(D,d){const f=u.decode(D);try{const h=i(f);for(const g of h)g.type==="finalAnswer"?(a=g?.text||"",d.terminate()):g.type==="stream"&&d.enqueue(g?.token||"")}catch{throw new Error("Error during parsing response")}}}),m=s.body?.pipeThrough(l);async function c(){return new Promise(async(D,d)=>{try{if(!m)d("ModifiedStream undefined");else{const f=m.getReader();for(;;){const{done:h,value:g}=await f.read();if(h){D(a);break}}}}catch(f){d(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 ko 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 O({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=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(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"?q(c):U(c);await this.checkAvailableModels();const d=await this.createChatCompletions(D,`Here is the diff: ${r}`);return i&&H("MistralAI",r,D,d,e),e==="review"?this.sanitizeResponse(d):this.parseMessage(d,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 Ce({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 Ce({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:qe(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:Tt}=Object.prototype,Ke=typeof process<"u"&&process.platform==="win32"?`\r
88
+ Please structure your response with appropriate Markdown headings, code blocks, and bullet points.`;if(!e)return o;try{const n=N.readFileSync(I.resolve(e),"utf-8");return`${wo(n,t)}`}catch{return o}},bo=async t=>{if(t.systemPromptPath)try{N.readFileSync(I.resolve(t.systemPromptPath),"utf-8")}catch{throw new E(`Error reading system prompt file: ${t.systemPromptPath}`)}if(t.codeReview&&t.codeReviewPromptPath)try{N.readFileSync(I.resolve(t.codeReviewPromptPath),"utf-8")}catch{throw new E(`Error reading code review prompt file: ${t.codeReviewPromptPath}`)}};class $o 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 O({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 Pn({apiKey:this.params.config.key})}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(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:d,model:f}=this.params.config,h={...j,locale:a,maxLength:c,type:m,generate:l,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},g=e==="review"?q(h):U(h),y={max_tokens:D,temperature:u,system:g,messages:[{role:"user",content:`Here is the diff: ${r}`}],top_p:d,model:f},S=(await this.anthropic.messages.create(y)).content.map(({text:V})=>V).join("");return i&&H("Anthropic",r,g,S,e),e==="review"?this.sanitizeResponse(S):this.parseMessage(S,m,l)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new E(`Error connecting to ${o.hostname} (${o.syscall})`):o}}}class Ce{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=xn.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 Ao 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 O({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=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(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"?q(c):U(c);this.checkAvailableModels();const d=await this.createChatCompletions(D,e);return i&&H("Codestral",r,D,d,e),e==="review"?this.sanitizeResponse(d):this.parseMessage(d,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 Ce({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:qe(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 Po 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 O({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 Mn({token:this.params.config.key})}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(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:d,model:f}=this.params.config,h={...j,locale:a,maxLength:c,type:m,generate:l,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},g=e==="review"?q(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:qe(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 Sn?new E("Request timed out error!"):o}}}class Bo 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 O({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 xe({baseURL:this.host,apiKey:this.params.config.key})}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(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"?q(c):U(c);this.checkAvailableModels();const d=await this.createChatCompletions(D);return i&&H("DeepSeek",r,D,d,e),e==="review"?this.sanitizeResponse(d):this.parseMessage(d,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 xo 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 O({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 Rn(this.params.config.key)}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(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},d=e==="review"?q(D):U(D),f={maxOutputTokens:c,temperature:this.params.config.temperature,topP:this.params.config.topP},w=(await this.genAI.getGenerativeModel({model:this.params.config.model,systemInstruction:d,generationConfig:f,safetySettings:[{category:Me.HARM_CATEGORY_HATE_SPEECH,threshold:Se.BLOCK_LOW_AND_ABOVE},{category:Me.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:Se.BLOCK_LOW_AND_ABOVE},{category:Me.HARM_CATEGORY_HARASSMENT,threshold:Se.BLOCK_LOW_AND_ABOVE},{category:Me.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:Se.BLOCK_LOW_AND_ABOVE}]}).generateContent(`Here is the diff: ${r}`)).response.text();return s&&H("Gemini",r,d,w,e),e==="review"?this.sanitizeResponse(w):this.parseMessage(w,l,a)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new E(`Error connecting to ${o.hostname} (${o.syscall})`):o}}}class Mo extends G{constructor(e){super(e),this.params=e,this.handleError$=r=>{let o="N/A",n="An error occurred";r instanceof Er.APIError&&(o=`${r.status}`,n=r.name);const s=`${o} ${n}`;return O({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 Er({apiKey:this.params.config.key})}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(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,d={...j,locale:u,maxLength:c,type:m,generate:l,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},f=e==="review"?q(d):U(d),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 So 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=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(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"?q(c):U(c),d=await this.getNewChat(D),h=await(await this.sendMessage(`Here is the diff: ${r}`,d.id)).completeResponsePromise();return await this.deleteConversation(d.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 d=m.map(f=>i(f));l.promptExamples=d.map(f=>({title:o[f.title],prompt:o[f.prompt]}))}const c=i(a.parameters),D={};for(const[d,f]of Object.entries(c)){if(f===-1){D[d]=null;continue}if(Array.isArray(o[f])){D[d]=o[f].map(h=>o[h]);continue}D[d]=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,d=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:d})}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 d=D.split(`
89
+ `),f=[];for(const h of d)h.trim()&&f.push(JSON.parse(h));return f}catch{return[{}]}}const u=new TextDecoder;let a="";const l=new TransformStream({async transform(D,d){const f=u.decode(D);try{const h=i(f);for(const g of h)g.type==="finalAnswer"?(a=g?.text||"",d.terminate()):g.type==="stream"&&d.enqueue(g?.token||"")}catch{throw new Error("Error during parsing response")}}}),m=s.body?.pipeThrough(l);async function c(){return new Promise(async(D,d)=>{try{if(!m)d("ModifiedStream undefined");else{const f=m.getReader();for(;;){const{done:h,value:g}=await f.read();if(h){D(a);break}}}}catch(f){d(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 Ro 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 O({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=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(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"?q(c):U(c);await this.checkAvailableModels();const d=await this.createChatCompletions(D,`Here is the diff: ${r}`);return i&&H("MistralAI",r,D,d,e),e==="review"?this.sanitizeResponse(d):this.parseMessage(d,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 Ce({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 Ce({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:qe(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:Tt}=Object.prototype,Ke=typeof process<"u"&&process.platform==="win32"?`\r
90
90
  `:`
91
- `,_t=(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+=le(s+"[]")+n+le(u)+Ke;else i&&typeof i=="object"?r.push(s):o+=le(s)+n+le(i)+Ke}e.section&&o.length&&(o="["+le(e.section)+"]"+Ke+o);for(const s of r){const i=Io(s).join("\\."),u=(e.section?e.section+".":"")+i,{whitespace:a}=e,l=_t(t[s],{section:u,whitespace:a});o.length&&l.length&&(o+=Ke),o+=l}return o},Io=t=>t.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(e=>e.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),Lo=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=Ve(a[1]),o==="__proto__"){r=Object.create(null);continue}r=e[o]=e[o]||Object.create(null);continue}const l=Ve(a[2]),m=l.length>2&&l.slice(-2)==="[]",c=m?l.slice(0,-2):l;if(c==="__proto__")continue;const D=a[3]?Ve(a[4]):!0,d=D==="true"||D==="false"||D==="null"?JSON.parse(D):D;m&&(Tt.call(r,c)?Array.isArray(r[c])||(r[c]=[r[c]]):r[c]=[]),Array.isArray(r[c])?r[c].push(d):r[c]=d}const i=[];for(const u of Object.keys(e)){if(!Tt.call(e,u)||typeof e[u]!="object"||Array.isArray(e[u]))continue;const a=Io(u);r=e;const l=a.pop(),m=l.replace(/\\\./g,".");for(const c of a)c!=="__proto__"&&((!Tt.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},No=t=>t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"),le=t=>typeof t!="string"||t.match(/[=\r\n]/)||t.match(/^\[/)||t.length>1&&No(t)||t!==t.trim()?JSON.stringify(t):t.split(";").join("\\;").split("#").join("\\#"),Ve=(t,e)=>{if(t=(t||"").trim(),No(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 Au={parse:Lo,decode:Lo,stringify:_t,encode:_t,safe:le,unsafe:Ve},jt=se(Au);const To=t=>M.lstat(t).then(()=>!0,()=>!1),Pu=["","conventional","gitmoji"],Gt="http://localhost:11434",{hasOwnProperty:Bu}=Object.prototype,Je=(t,e)=>Bu.call(t,e),X=["OPENAI","OLLAMA","HUGGINGFACE","GEMINI","ANTHROPIC","MISTRAL","CODESTRAL","COHERE","GROQ","PERPLEXITY","DEEPSEEK"],xu=t=>{const e=Object.keys(t),r=new Set([...X,...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}`)},p={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",Pu.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")}},ye={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:p.topP,systemPrompt:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,timeout:p.timeout,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.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:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.watchMode},GEMINI:{key:t=>t||"",model:t=>!t||t.length===0?"gemini-2.0-flash":(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:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,topP:p.topP,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.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:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,topP:p.topP,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.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:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,timeout:p.timeout,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,topP:p.topP,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.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:p.topP,systemPrompt:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,timeout:p.timeout,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.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):Gt,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:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,temperature:p.temperature,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,topP:p.topP,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.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:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,topP:p.topP,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.watchMode},GROQ:{key:t=>t||"",model:t=>!t||t.length===0?"deepseek-r1-distill-llama-70b":(F("GROQ.model",["qwen-2.5-32b","qwen-2.5-coder-32b","deepseek-r1-distill-qwen-32b","deepseek-r1-distill-llama-70b","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","distil-whisper-large-v3-en","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:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,timeout:p.timeout,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,topP:p.topP,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.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:p.topP,systemPrompt:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,timeout:p.timeout,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.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:p.topP,systemPrompt:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,timeout:p.timeout,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.watchMode}},Ye=I.join(ut.homedir(),".aicommit2"),Mu=(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 ye?(e[s]||(e[s]={}),e[s][i]=n):e[o]=n}return e},_o=async()=>await To(Ye)?await M.readFile(Ye,"utf8"):Object.create(null),Ht=async()=>{const t=await _o();let e=jt.parse(t);return Je(e,"OLLAMA")&&Je(e.OLLAMA,"model")&&(e={...e,OLLAMA:{...e.OLLAMA,model:typeof e.OLLAMA.model=="string"?[e.OLLAMA.model]:e.OLLAMA.model}}),Je(e,"exclude")&&(e={...e,exclude:typeof e.exclude=="string"?[e.exclude]:e.exclude}),e},Ee=async(t,e=[])=>{const r=await Ht(),o=Mu(e),n={...t,...o},s={},i=xu(r),u={},a=X.map(m=>({service:m,envKey:`${m}_API_KEY`}));for(const{service:m,envKey:c}of a){const D=process.env[c];D&&(u[m]={key:D})}const l=(m,c)=>{const D=n[`${m}.${c}`]??n[m]?.[c],d=u[m]?.[c],f=r[m]?.[c],h=n[c]??r[c];return D!==void 0?D:d!==void 0?d:f!==void 0?f:h};for(const[m,c]of Object.entries(p)){const D=n[m]??r[m];s[m]=c(D)}for(const m of i){s[m]={};const c=ye[m]||Xe(m);for(const[D,d]of Object.entries(c)){const f=l(m,D);s[m][D]=d(f)}}return s},Su=async t=>{const e=await Ht();for(const[r,o]of t){const[n,s]=r.split(".");if(!s){const a=p[r];if(!a)throw new E(`Invalid config property: ${r}`);e[r]=a(o);continue}if(e[n]||(e[n]={}),X.includes(n)){const a=ye[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=Xe(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 M.writeFile(Ye,jt.stringify(e),"utf8")},Ru=async t=>{const e=await Ht();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]=ze([...a,o]);continue}if(i&&i.compatible===!0){i||(e[n]={});const a=Xe(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 ye){i||(e[n]={});const a=ye[n][s];if(!a)throw new E(`Invalid config property: ${r}`);e[n][s]=a(o)}else{const a=Xe(n);if(!a[s])throw new E(`Invalid config property: ${r}`);e[n]||(e[n]={}),e[n][s]=a[s](o)}}await M.writeFile(Ye,jt.stringify(e),"utf8")},Ou=async()=>{const t=await _o();console.log(t)},Xe=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"),stream:e=>typeof e=="boolean"?e:e==null?!1:(F("stream",/^(?: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:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,timeout:p.timeout,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,topP:p.topP,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.watchMode});class jo extends G{constructor(e){super(e),this.params=e,this.host=Gt,this.model="",this.key="",this.auth="",this.handleError$=r=>{if(r.response&&r.response.data?.error)return O({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 O({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(`[${Ue(this.model)}]`),this.errorPrefix=C.red.bold(`[${Ue(this.model)}]`),this.host=this.params.config.host||Gt,this.auth=this.params.config.auth||"Bearer",this.key=this.params.config.key||"",this.ollama=new On({host:this.host,...this.key&&{headers:{Authorization:`${this.auth} ${this.key}`}}})}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(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"?q(c):U(c);await this.checkIsAvailableOllama();const d=await this.createChatCompletions(D,`Here is the diff: ${r}`);return i&&H(`Ollama_${this.model}`,r,D,d,e),e==="review"?this.sanitizeResponse(d):this.parseMessage(d,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 Ce({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:qe(10,1e3)}})).message.content}}class Go extends G{constructor(e){super(e),this.params=e,this.handleError$=o=>{let n="N/A",s=o.message;o instanceof xe.APIConnectionTimeoutError?s=`Connection timeout: ${o.message}`:o instanceof xe.APIError&&(n=`${o.status}`,s=o.name);const i=`${n} ${s}`;return O({name:`${this.errorPrefix} ${i}`,value:s,isError:!0,disabled:!0})};const r=this.params.keyName||"OPENAI_COMPATIBLE";this.colors=yu(r),this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[${Ue(r)}]`),this.errorPrefix=C.red.bold(`[${Ue(r)}]`),this.openAI=new xe({apiKey:this.params.config.key,baseURL:`${this.params.config.url}${this.params.config.path}`})}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(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,timeout:D,stream:d=!1}=this.params.config,f=this.params.config.maxTokens,h={...j,locale:u,maxLength:c,type:m,generate:l,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},g=e==="review"?q(h):U(h),y=await this.openAI.chat.completions.create({messages:[{role:"system",content:g},{role:"user",content:`Here is the diff: ${r}`}],model:this.params.config.model,stream:d,max_tokens:f,top_p:this.params.config.topP,temperature:a},{timeout:D});let w="";if(d&&y){const S=y;for await(const V of S){const J=V.choices[0]?.delta?.content||"",me=V.choices[0]?.delta?.reasoning_content||"",Y=`${J}${me}`;w+=Y}}else w=y.choices[0].message.content||"";return i&&H(this.params.keyName,r,g,w,e),e==="review"?this.sanitizeResponse(w):this.parseMessage(w,m,l)}catch(r){throw console.error("generateMessage error >>>",r),r}}}var Ut={},qt={exports:{}},Fe={exports:{}},zt,Ho;function ku(){if(Ho)return zt;Ho=1;var t=1e3,e=t*60,r=e*60,o=r*24,n=o*7,s=o*365.25;zt=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]),d=(c[2]||"ms").toLowerCase();switch(d){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,d){var f=c>=D*1.5;return Math.round(m/D)+" "+d+(f?"s":"")}return zt}var Wt,Uo;function qo(){if(Uo)return Wt;Uo=1;function t(e){o.debug=o,o.default=o,o.coerce=l,o.disable=u,o.enable=s,o.enabled=a,o.humanize=ku(),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 d=0;d<c.length;d++)D=(D<<5)-D+c.charCodeAt(d),D|=0;return o.colors[Math.abs(D)%o.colors.length]}o.selectColor=r;function o(c){let D,d=null,f,h;function g(...y){if(!g.enabled)return;const w=g,S=Number(new Date),V=S-(D||S);w.diff=V,w.prev=D,w.curr=S,D=S,y[0]=o.coerce(y[0]),typeof y[0]!="string"&&y.unshift("%O");let J=0;y[0]=y[0].replace(/%([a-zA-Z%])/g,(Y,fn)=>{if(Y==="%%")return"%";J++;const lr=o.formatters[fn];if(typeof lr=="function"){const hn=y[J];Y=lr.call(w,hn),y.splice(J,1),J--}return Y}),o.formatArgs.call(w,y),(w.log||o.log).apply(w,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:()=>d!==null?d:(f!==o.namespaces&&(f=o.namespaces,h=o.enabled(c)),h),set:y=>{d=y}}),typeof o.init=="function"&&o.init(g),g}function n(c,D){const d=o(this.namespace+(typeof D>"u"?":":D)+c);return d.log=this.log,d}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 d of D)d[0]==="-"?o.skips.push(d.slice(1)):o.names.push(d)}function i(c,D){let d=0,f=0,h=-1,g=0;for(;d<c.length;)if(f<D.length&&(D[f]===c[d]||D[f]==="*"))D[f]==="*"?(h=f,g=d,f++):(d++,f++);else if(h!==-1)f=h+1,g++,d=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 Wt=t,Wt}Fe.exports;var zo;function Iu(){return zo||(zo=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=qo()(e);const{formatters:u}=t.exports;u.j=function(a){try{return JSON.stringify(a)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(Fe,Fe.exports)),Fe.exports}var we={exports:{}},Kt,Wo;function Lu(){return Wo||(Wo=1,Kt=(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)}),Kt}var Vt,Ko;function Nu(){if(Ko)return Vt;Ko=1;const t=ut,e=st,r=Lu(),{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 Vt={supportsColor:u,stdout:s(i(!0,e.isatty(1))),stderr:s(i(!0,e.isatty(2)))},Vt}we.exports;var Vo;function Tu(){return Vo||(Vo=1,function(t,e){const r=st,o=hr;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=Nu();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,d)=>{const f=d.substring(6).toLowerCase().replace(/_([a-z])/g,(g,y)=>y.toUpperCase());let h=process.env[d];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:d,useColors:f}=this;if(f){const h=this.color,g="\x1B[3"+(h<8?h:"8;5;"+h),y=` ${g};1m${d} \x1B[0m`;D[0]=y+D[0].split(`
91
+ `,_t=(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+=le(s+"[]")+n+le(u)+Ke;else i&&typeof i=="object"?r.push(s):o+=le(s)+n+le(i)+Ke}e.section&&o.length&&(o="["+le(e.section)+"]"+Ke+o);for(const s of r){const i=Oo(s).join("\\."),u=(e.section?e.section+".":"")+i,{whitespace:a}=e,l=_t(t[s],{section:u,whitespace:a});o.length&&l.length&&(o+=Ke),o+=l}return o},Oo=t=>t.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(e=>e.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),ko=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=Ve(a[1]),o==="__proto__"){r=Object.create(null);continue}r=e[o]=e[o]||Object.create(null);continue}const l=Ve(a[2]),m=l.length>2&&l.slice(-2)==="[]",c=m?l.slice(0,-2):l;if(c==="__proto__")continue;const D=a[3]?Ve(a[4]):!0,d=D==="true"||D==="false"||D==="null"?JSON.parse(D):D;m&&(Tt.call(r,c)?Array.isArray(r[c])||(r[c]=[r[c]]):r[c]=[]),Array.isArray(r[c])?r[c].push(d):r[c]=d}const i=[];for(const u of Object.keys(e)){if(!Tt.call(e,u)||typeof e[u]!="object"||Array.isArray(e[u]))continue;const a=Oo(u);r=e;const l=a.pop(),m=l.replace(/\\\./g,".");for(const c of a)c!=="__proto__"&&((!Tt.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},Io=t=>t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"),le=t=>typeof t!="string"||t.match(/[=\r\n]/)||t.match(/^\[/)||t.length>1&&Io(t)||t!==t.trim()?JSON.stringify(t):t.split(";").join("\\;").split("#").join("\\#"),Ve=(t,e)=>{if(t=(t||"").trim(),Io(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 Au={parse:ko,decode:ko,stringify:_t,encode:_t,safe:le,unsafe:Ve},jt=se(Au);const Lo=t=>M.lstat(t).then(()=>!0,()=>!1),Pu=["","conventional","gitmoji"],Gt="http://localhost:11434",{hasOwnProperty:Bu}=Object.prototype,Je=(t,e)=>Bu.call(t,e),X=["OPENAI","OLLAMA","HUGGINGFACE","GEMINI","ANTHROPIC","MISTRAL","CODESTRAL","COHERE","GROQ","PERPLEXITY","DEEPSEEK"],xu=t=>{const e=Object.keys(t),r=new Set([...X,...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}`)},p={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",Pu.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")}},ye={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:p.topP,systemPrompt:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,timeout:p.timeout,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.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:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.watchMode},GEMINI:{key:t=>t||"",model:t=>!t||t.length===0?"gemini-2.0-flash":(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:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,topP:p.topP,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.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:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,topP:p.topP,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.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:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,timeout:p.timeout,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,topP:p.topP,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.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:p.topP,systemPrompt:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,timeout:p.timeout,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.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):Gt,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:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,temperature:p.temperature,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,topP:p.topP,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.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:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,topP:p.topP,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.watchMode},GROQ:{key:t=>t||"",model:t=>!t||t.length===0?"deepseek-r1-distill-llama-70b":(F("GROQ.model",["qwen-2.5-32b","qwen-2.5-coder-32b","deepseek-r1-distill-qwen-32b","deepseek-r1-distill-llama-70b","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","distil-whisper-large-v3-en","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:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,timeout:p.timeout,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,topP:p.topP,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.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:p.topP,systemPrompt:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,timeout:p.timeout,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.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:p.topP,systemPrompt:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,timeout:p.timeout,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.watchMode}},Ye=I.join(ut.homedir(),".aicommit2"),Mu=(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 ye?(e[s]||(e[s]={}),e[s][i]=n):e[o]=n}return e},No=async()=>await Lo(Ye)?await M.readFile(Ye,"utf8"):Object.create(null),Ht=async()=>{const t=await No();let e=jt.parse(t);return Je(e,"OLLAMA")&&Je(e.OLLAMA,"model")&&(e={...e,OLLAMA:{...e.OLLAMA,model:typeof e.OLLAMA.model=="string"?[e.OLLAMA.model]:e.OLLAMA.model}}),Je(e,"exclude")&&(e={...e,exclude:typeof e.exclude=="string"?[e.exclude]:e.exclude}),e},Ee=async(t,e=[])=>{const r=await Ht(),o=Mu(e),n={...t,...o},s={},i=xu(r),u={},a=X.map(m=>({service:m,envKey:`${m}_API_KEY`}));for(const{service:m,envKey:c}of a){const D=process.env[c];D&&(u[m]={key:D})}const l=(m,c)=>{const D=n[`${m}.${c}`]??n[m]?.[c],d=u[m]?.[c],f=r[m]?.[c],h=n[c]??r[c];return D!==void 0?D:d!==void 0?d:f!==void 0?f:h};for(const[m,c]of Object.entries(p)){const D=n[m]??r[m];s[m]=c(D)}for(const m of i){s[m]={};const c=ye[m]||Xe(m);for(const[D,d]of Object.entries(c)){const f=l(m,D);s[m][D]=d(f)}}return s},Su=async t=>{const e=await Ht();for(const[r,o]of t){const[n,s]=r.split(".");if(!s){const a=p[r];if(!a)throw new E(`Invalid config property: ${r}`);e[r]=a(o);continue}if(e[n]||(e[n]={}),X.includes(n)){const a=ye[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=Xe(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 M.writeFile(Ye,jt.stringify(e),"utf8")},Ru=async t=>{const e=await Ht();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]=ze([...a,o]);continue}if(i&&i.compatible===!0){i||(e[n]={});const a=Xe(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 ye){i||(e[n]={});const a=ye[n][s];if(!a)throw new E(`Invalid config property: ${r}`);e[n][s]=a(o)}else{const a=Xe(n);if(!a[s])throw new E(`Invalid config property: ${r}`);e[n]||(e[n]={}),e[n][s]=a[s](o)}}await M.writeFile(Ye,jt.stringify(e),"utf8")},Ou=async()=>{const t=await No();console.log(t)},Xe=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"),stream:e=>typeof e=="boolean"?e:e==null?!1:(F("stream",/^(?: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:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,timeout:p.timeout,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,topP:p.topP,codeReview:p.codeReview,disabled:p.disabled,watchMode:p.watchMode});class To extends G{constructor(e){super(e),this.params=e,this.host=Gt,this.model="",this.key="",this.auth="",this.handleError$=r=>{if(r.response&&r.response.data?.error)return O({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 O({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(`[${Ue(this.model)}]`),this.errorPrefix=C.red.bold(`[${Ue(this.model)}]`),this.host=this.params.config.host||Gt,this.auth=this.params.config.auth||"Bearer",this.key=this.params.config.key||"",this.ollama=new On({host:this.host,...this.key&&{headers:{Authorization:`${this.auth} ${this.key}`}}})}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(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"?q(c):U(c);await this.checkIsAvailableOllama();const d=await this.createChatCompletions(D,`Here is the diff: ${r}`);return i&&H(`Ollama_${this.model}`,r,D,d,e),e==="review"?this.sanitizeResponse(d):this.parseMessage(d,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 Ce({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:qe(10,1e3)}})).message.content}}class _o extends G{constructor(e){super(e),this.params=e,this.handleError$=o=>{let n="N/A",s=o.message;o instanceof xe.APIConnectionTimeoutError?s=`Connection timeout: ${o.message}`:o instanceof xe.APIError&&(n=`${o.status}`,s=o.name);const i=`${n} ${s}`;return O({name:`${this.errorPrefix} ${i}`,value:s,isError:!0,disabled:!0})};const r=this.params.keyName||"OPENAI_COMPATIBLE";this.colors=yu(r),this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[${Ue(r)}]`),this.errorPrefix=C.red.bold(`[${Ue(r)}]`),this.openAI=new xe({apiKey:this.params.config.key,baseURL:`${this.params.config.url}${this.params.config.path}`})}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(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,timeout:D,stream:d=!1}=this.params.config,f=this.params.config.maxTokens,h={...j,locale:u,maxLength:c,type:m,generate:l,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},g=e==="review"?q(h):U(h),y=await this.openAI.chat.completions.create({messages:[{role:"system",content:g},{role:"user",content:`Here is the diff: ${r}`}],model:this.params.config.model,stream:d,max_tokens:f,top_p:this.params.config.topP,temperature:a},{timeout:D});let w="";if(d&&y){const S=y;for await(const V of S){const J=V.choices[0]?.delta?.content||"",me=V.choices[0]?.delta?.reasoning_content||"",Y=`${J}${me}`;w+=Y}}else w=y.choices[0].message.content||"";return i&&H(this.params.keyName,r,g,w,e),e==="review"?this.sanitizeResponse(w):this.parseMessage(w,m,l)}catch(r){throw console.error("generateMessage error >>>",r),r}}}var Ut={},qt={exports:{}},Fe={exports:{}},zt,jo;function ku(){if(jo)return zt;jo=1;var t=1e3,e=t*60,r=e*60,o=r*24,n=o*7,s=o*365.25;zt=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]),d=(c[2]||"ms").toLowerCase();switch(d){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,d){var f=c>=D*1.5;return Math.round(m/D)+" "+d+(f?"s":"")}return zt}var Wt,Go;function Ho(){if(Go)return Wt;Go=1;function t(e){o.debug=o,o.default=o,o.coerce=l,o.disable=u,o.enable=s,o.enabled=a,o.humanize=ku(),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 d=0;d<c.length;d++)D=(D<<5)-D+c.charCodeAt(d),D|=0;return o.colors[Math.abs(D)%o.colors.length]}o.selectColor=r;function o(c){let D,d=null,f,h;function g(...y){if(!g.enabled)return;const w=g,S=Number(new Date),V=S-(D||S);w.diff=V,w.prev=D,w.curr=S,D=S,y[0]=o.coerce(y[0]),typeof y[0]!="string"&&y.unshift("%O");let J=0;y[0]=y[0].replace(/%([a-zA-Z%])/g,(Y,fn)=>{if(Y==="%%")return"%";J++;const ur=o.formatters[fn];if(typeof ur=="function"){const hn=y[J];Y=ur.call(w,hn),y.splice(J,1),J--}return Y}),o.formatArgs.call(w,y),(w.log||o.log).apply(w,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:()=>d!==null?d:(f!==o.namespaces&&(f=o.namespaces,h=o.enabled(c)),h),set:y=>{d=y}}),typeof o.init=="function"&&o.init(g),g}function n(c,D){const d=o(this.namespace+(typeof D>"u"?":":D)+c);return d.log=this.log,d}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 d of D)d[0]==="-"?o.skips.push(d.slice(1)):o.names.push(d)}function i(c,D){let d=0,f=0,h=-1,g=0;for(;d<c.length;)if(f<D.length&&(D[f]===c[d]||D[f]==="*"))D[f]==="*"?(h=f,g=d,f++):(d++,f++);else if(h!==-1)f=h+1,g++,d=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 Wt=t,Wt}Fe.exports;var Uo;function Iu(){return Uo||(Uo=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=Ho()(e);const{formatters:u}=t.exports;u.j=function(a){try{return JSON.stringify(a)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(Fe,Fe.exports)),Fe.exports}var we={exports:{}},Kt,qo;function Lu(){return qo||(qo=1,Kt=(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)}),Kt}var Vt,zo;function Nu(){if(zo)return Vt;zo=1;const t=ut,e=st,r=Lu(),{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 Vt={supportsColor:u,stdout:s(i(!0,e.isatty(1))),stderr:s(i(!0,e.isatty(2)))},Vt}we.exports;var Wo;function Tu(){return Wo||(Wo=1,function(t,e){const r=st,o=pr;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=Nu();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,d)=>{const f=d.substring(6).toLowerCase().replace(/_([a-z])/g,(g,y)=>y.toUpperCase());let h=process.env[d];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:d,useColors:f}=this;if(f){const h=this.color,g="\x1B[3"+(h<8?h:"8;5;"+h),y=` ${g};1m${d} \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()+d+" "+D[0]}function i(){return e.inspectOpts.hideDate?"":new Date().toISOString()+" "}function u(...D){return process.stderr.write(o.formatWithOptions(e.inspectOpts,...D)+`
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 d=Object.keys(e.inspectOpts);for(let f=0;f<d.length;f++)D.inspectOpts[d[f]]=e.inspectOpts[d[f]]}t.exports=qo()(e);const{formatters:c}=t.exports;c.o=function(D){return this.inspectOpts.colors=this.useColors,o.inspect(D,this.inspectOpts).split(`
95
- `).map(d=>d.trim()).join(" ")},c.O=function(D){return this.inspectOpts.colors=this.useColors,o.inspect(D,this.inspectOpts)}}(we,we.exports)),we.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?qt.exports=Iu():qt.exports=Tu();var Jt=qt.exports,Yt={};Object.defineProperty(Yt,"__esModule",{value:!0});function _u(t){return function(e,r){return new Promise((o,n)=>{t.call(this,e,r,(s,i)=>{s?n(s):o(i)})})}}Yt.default=_u;var Jo=R&&R.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const ju=fr,Gu=Jo(Jt),Hu=Jo(Yt),ve=Gu.default("agent-base");function Uu(t){return!!t&&typeof t.addRequest=="function"}function Xt(){const{stack:t}=new Error;return typeof t!="string"?!1:t.split(`
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 d=Object.keys(e.inspectOpts);for(let f=0;f<d.length;f++)D.inspectOpts[d[f]]=e.inspectOpts[d[f]]}t.exports=Ho()(e);const{formatters:c}=t.exports;c.o=function(D){return this.inspectOpts.colors=this.useColors,o.inspect(D,this.inspectOpts).split(`
95
+ `).map(d=>d.trim()).join(" ")},c.O=function(D){return this.inspectOpts.colors=this.useColors,o.inspect(D,this.inspectOpts)}}(we,we.exports)),we.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?qt.exports=Iu():qt.exports=Tu();var Jt=qt.exports,Yt={};Object.defineProperty(Yt,"__esModule",{value:!0});function _u(t){return function(e,r){return new Promise((o,n)=>{t.call(this,e,r,(s,i)=>{s?n(s):o(i)})})}}Yt.default=_u;var Ko=R&&R.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const ju=dr,Gu=Ko(Jt),Hu=Ko(Yt),ve=Gu.default("agent-base");function Uu(t){return!!t&&typeof t.addRequest=="function"}function Xt(){const{stack:t}=new Error;return typeof t!="string"?!1:t.split(`
96
96
  `).some(e=>e.indexOf("(https.js:")!==-1||e.indexOf("node:https:")!==-1)}function Ze(t,e){return new Ze.Agent(t,e)}(function(t){class e extends ju.EventEmitter{constructor(o,n){super();let s=n;typeof o=="function"?this.callback=o:o&&(s=o),this.timeout=null,s&&typeof s.timeout=="number"&&(this.timeout=s.timeout),this.maxFreeSockets=1,this.maxSockets=1,this.maxTotalSockets=1/0,this.sockets={},this.freeSockets={},this.requests={},this.options={}}get defaultPort(){return typeof this.explicitDefaultPort=="number"?this.explicitDefaultPort:Xt()?443:80}set defaultPort(o){this.explicitDefaultPort=o}get protocol(){return typeof this.explicitProtocol=="string"?this.explicitProtocol:Xt()?"https:":"http:"}set protocol(o){this.explicitProtocol=o}callback(o,n,s){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(o,n){const s=Object.assign({},n);typeof s.secureEndpoint!="boolean"&&(s.secureEndpoint=Xt()),s.host==null&&(s.host="localhost"),s.port==null&&(s.port=s.secureEndpoint?443:80),s.protocol==null&&(s.protocol=s.secureEndpoint?"https:":"http:"),s.host&&s.path&&delete s.path,delete s.agent,delete s.hostname,delete s._defaultAgent,delete s.defaultPort,delete s.createConnection,o._last=!0,o.shouldKeepAlive=!1;let i=!1,u=null;const a=s.timeout||this.timeout,l=d=>{o._hadError||(o.emit("error",d),o._hadError=!0)},m=()=>{u=null,i=!0;const d=new Error(`A "socket" was not created for HTTP request before ${a}ms`);d.code="ETIMEOUT",l(d)},c=d=>{i||(u!==null&&(clearTimeout(u),u=null),l(d))},D=d=>{if(i)return;if(u!=null&&(clearTimeout(u),u=null),Uu(d)){ve("Callback returned another Agent instance %o",d.constructor.name),d.addRequest(o,s);return}if(d){d.once("free",()=>{this.freeSocket(d,s)}),o.onSocket(d);return}const f=new Error(`no Duplex stream was returned to agent-base for \`${o.method} ${o.path}\``);l(f)};if(typeof this.callback!="function"){l(new Error("`callback` is not defined"));return}this.promisifiedCallback||(this.callback.length>=3?(ve("Converting legacy callback function to promise"),this.promisifiedCallback=Hu.default(this.callback)):this.promisifiedCallback=this.callback),typeof a=="number"&&a>0&&(u=setTimeout(m,a)),"port"in s&&typeof s.port!="number"&&(s.port=Number(s.port));try{ve("Resolving socket for %o request: %o",s.protocol,`${o.method} ${o.path}`),Promise.resolve(this.promisifiedCallback(o,s)).then(D,c)}catch(d){Promise.reject(d).catch(c)}}freeSocket(o,n){ve("Freeing socket %o %o",o.constructor.name,n),o.destroy()}destroy(){ve("Destroying agent %o",this.constructor.name)}}t.Agent=e,t.prototype=t.Agent.prototype})(Ze||(Ze={}));var qu=Ze,Zt={},zu=R&&R.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Zt,"__esModule",{value:!0});const Wu=zu(Jt),be=Wu.default("https-proxy-agent:parse-proxy-response");function Ku(t){return new Promise((e,r)=>{let o=0;const n=[];function s(){const c=t.read();c?m(c):t.once("readable",s)}function i(){t.removeListener("end",a),t.removeListener("error",l),t.removeListener("close",u),t.removeListener("readable",s)}function u(c){be("onclose had error %o",c)}function a(){be("onend")}function l(c){i(),be("onerror %o",c),r(c)}function m(c){n.push(c),o+=c.length;const D=Buffer.concat(n,o);if(D.indexOf(`\r
97
97
  \r
98
98
  `)===-1){be("have not received end of HTTP headers yet..."),s();return}const f=D.toString("ascii",0,D.indexOf(`\r
99
- `)),h=+f.split(" ")[1];be("got proxy server response: %o",f),e({statusCode:h,buffered:D})}t.on("error",l),t.on("close",u),t.on("end",a),s()})}Zt.default=Ku;var Vu=R&&R.__awaiter||function(t,e,r,o){function n(s){return s instanceof r?s:new r(function(i){i(s)})}return new(r||(r=Promise))(function(s,i){function u(m){try{l(o.next(m))}catch(c){i(c)}}function a(m){try{l(o.throw(m))}catch(c){i(c)}}function l(m){m.done?s(m.value):n(m.value).then(u,a)}l((o=o.apply(t,e||[])).next())})},De=R&&R.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ut,"__esModule",{value:!0});const Yo=De(Ln),Xo=De(Nn),Ju=De(Tn),Yu=De(pr),Xu=De(Jt),Zu=qu,Qu=De(Zt),$e=Xu.default("https-proxy-agent:agent");class ec extends Zu.Agent{constructor(e){let r;if(typeof e=="string"?r=Ju.default.parse(e):r=e,!r)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");$e("creating new HttpsProxyAgent instance: %o",r),super(r);const o=Object.assign({},r);this.secureProxy=r.secureProxy||oc(o.protocol),o.host=o.hostname||o.host,typeof o.port=="string"&&(o.port=parseInt(o.port,10)),!o.port&&o.host&&(o.port=this.secureProxy?443:80),this.secureProxy&&!("ALPNProtocols"in o)&&(o.ALPNProtocols=["http 1.1"]),o.host&&o.path&&(delete o.path,delete o.pathname),this.proxy=o}callback(e,r){return Vu(this,void 0,void 0,function*(){const{proxy:o,secureProxy:n}=this;let s;n?($e("Creating `tls.Socket`: %o",o),s=Xo.default.connect(o)):($e("Creating `net.Socket`: %o",o),s=Yo.default.connect(o));const i=Object.assign({},o.headers);let a=`CONNECT ${`${r.host}:${r.port}`} HTTP/1.1\r
99
+ `)),h=+f.split(" ")[1];be("got proxy server response: %o",f),e({statusCode:h,buffered:D})}t.on("error",l),t.on("close",u),t.on("end",a),s()})}Zt.default=Ku;var Vu=R&&R.__awaiter||function(t,e,r,o){function n(s){return s instanceof r?s:new r(function(i){i(s)})}return new(r||(r=Promise))(function(s,i){function u(m){try{l(o.next(m))}catch(c){i(c)}}function a(m){try{l(o.throw(m))}catch(c){i(c)}}function l(m){m.done?s(m.value):n(m.value).then(u,a)}l((o=o.apply(t,e||[])).next())})},De=R&&R.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ut,"__esModule",{value:!0});const Vo=De(Ln),Jo=De(Nn),Ju=De(Tn),Yu=De(mr),Xu=De(Jt),Zu=qu,Qu=De(Zt),$e=Xu.default("https-proxy-agent:agent");class ec extends Zu.Agent{constructor(e){let r;if(typeof e=="string"?r=Ju.default.parse(e):r=e,!r)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");$e("creating new HttpsProxyAgent instance: %o",r),super(r);const o=Object.assign({},r);this.secureProxy=r.secureProxy||oc(o.protocol),o.host=o.hostname||o.host,typeof o.port=="string"&&(o.port=parseInt(o.port,10)),!o.port&&o.host&&(o.port=this.secureProxy?443:80),this.secureProxy&&!("ALPNProtocols"in o)&&(o.ALPNProtocols=["http 1.1"]),o.host&&o.path&&(delete o.path,delete o.pathname),this.proxy=o}callback(e,r){return Vu(this,void 0,void 0,function*(){const{proxy:o,secureProxy:n}=this;let s;n?($e("Creating `tls.Socket`: %o",o),s=Jo.default.connect(o)):($e("Creating `net.Socket`: %o",o),s=Vo.default.connect(o));const i=Object.assign({},o.headers);let a=`CONNECT ${`${r.host}:${r.port}`} HTTP/1.1\r
100
100
  `;o.auth&&(i["Proxy-Authorization"]=`Basic ${Buffer.from(o.auth).toString("base64")}`);let{host:l,port:m,secureEndpoint:c}=r;rc(m,c)||(l+=`:${m}`),i.Host=l,i.Connection="close";for(const g of Object.keys(i))a+=`${g}: ${i[g]}\r
101
101
  `;const D=Qu.default(s);s.write(`${a}\r
102
- `);const{statusCode:d,buffered:f}=yield D;if(d===200){if(e.once("socket",tc),r.secureEndpoint){$e("Upgrading socket connection to TLS");const g=r.servername||r.host;return Xo.default.connect(Object.assign(Object.assign({},nc(r,"host","hostname","path","port")),{socket:s,servername:g}))}return s}s.destroy();const h=new Yo.default.Socket({writable:!1});return h.readable=!0,e.once("socket",g=>{$e("replaying proxy buffer for failed request"),Yu.default(g.listenerCount("data")>0),g.push(f),g.push(null)}),h})}}Ut.default=ec;function tc(t){t.resume()}function rc(t,e){return!!(!e&&t===80||e&&t===443)}function oc(t){return typeof t=="string"?/^https:?$/i.test(t):!1}function nc(t,...e){const r={};let o;for(o in t)e.includes(o)||(r[o]=t[o]);return r}var sc=R&&R.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const Qt=sc(Ut);function er(t){return new Qt.default(t)}(function(t){t.HttpsProxyAgent=Qt.default,t.prototype=Qt.default.prototype})(er||(er={}));var ic=er,ac=se(ic);const uc=async(t,e,r,o,n,s,i)=>new Promise((u,a)=>{const l=JSON.stringify(o),c=(t.protocol.includes("https")?In:kn).request({port:i||void 0,hostname:t.hostname,path:e,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(l),...r},timeout:n,agent:s?ac(s):void 0},D=>{const d=[];D.on("data",f=>d.push(f)),D.on("end",()=>{u({request:c,response:D,data:Buffer.concat(d).toString()})})});c.on("error",a),c.on("timeout",()=>{c.destroy(),a(new E(`Time out error: request took over ${n}ms. Try increasing the \`timeout\` config`))}),c.write(l),c.end()}),cc=async(t,e,r,o,n,s)=>{const i=new URL(t),{response:u,data:a}=await uc(i,e,{Authorization:`Bearer ${r}`},o,n,s);if(!u.statusCode||u.statusCode<200||u.statusCode>299){let l=`API Error: ${u.statusCode} - ${u.statusMessage}`;throw a&&(l+=`
102
+ `);const{statusCode:d,buffered:f}=yield D;if(d===200){if(e.once("socket",tc),r.secureEndpoint){$e("Upgrading socket connection to TLS");const g=r.servername||r.host;return Jo.default.connect(Object.assign(Object.assign({},nc(r,"host","hostname","path","port")),{socket:s,servername:g}))}return s}s.destroy();const h=new Vo.default.Socket({writable:!1});return h.readable=!0,e.once("socket",g=>{$e("replaying proxy buffer for failed request"),Yu.default(g.listenerCount("data")>0),g.push(f),g.push(null)}),h})}}Ut.default=ec;function tc(t){t.resume()}function rc(t,e){return!!(!e&&t===80||e&&t===443)}function oc(t){return typeof t=="string"?/^https:?$/i.test(t):!1}function nc(t,...e){const r={};let o;for(o in t)e.includes(o)||(r[o]=t[o]);return r}var sc=R&&R.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const Qt=sc(Ut);function er(t){return new Qt.default(t)}(function(t){t.HttpsProxyAgent=Qt.default,t.prototype=Qt.default.prototype})(er||(er={}));var ic=er,ac=se(ic);const uc=async(t,e,r,o,n,s,i)=>new Promise((u,a)=>{const l=JSON.stringify(o),c=(t.protocol.includes("https")?In:kn).request({port:i||void 0,hostname:t.hostname,path:e,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(l),...r},timeout:n,agent:s?ac(s):void 0},D=>{const d=[];D.on("data",f=>d.push(f)),D.on("end",()=>{u({request:c,response:D,data:Buffer.concat(d).toString()})})});c.on("error",a),c.on("timeout",()=>{c.destroy(),a(new E(`Time out error: request took over ${n}ms. Try increasing the \`timeout\` config`))}),c.write(l),c.end()}),cc=async(t,e,r,o,n,s)=>{const i=new URL(t),{response:u,data:a}=await uc(i,e,{Authorization:`Bearer ${r}`},o,n,s);if(!u.statusCode||u.statusCode<200||u.statusCode>299){let l=`API Error: ${u.statusCode} - ${u.statusMessage}`;throw a&&(l+=`
103
103
 
104
104
  ${a}`),u.statusCode===500&&(l+=`
105
105
 
106
- Check the API status: ${t}`),new E(l)}return JSON.parse(a)},Zo=t=>t.trim(),lc=async(t,e,r,o,n,s,i,u,a,l,m,c,D,d)=>{try{const f={model:n,messages:[{role:"system",content:m},{role:"user",content:`Here is the diff: ${s}`}],temperature:a,max_tokens:u,stream:!1,n:1,top_p:l,frequency_penalty:0,presence_penalty:0},h=await cc(e,r,o,f,i,d),g=h.choices.filter(y=>y.message?.content).map(y=>Zo(y.message.content)).join();return c&&H(t,s,m,g,D),h.choices.filter(y=>y.message?.content).map(y=>Zo(y.message.content))}catch(f){const h=f;throw h.code==="ENOTFOUND"?new E(`Error connecting to ${h.hostname} (${h.syscall})`):h}};class Qo extends G{constructor(e){super(e),this.params=e,this.handleError$=r=>{let o="An error occurred";if(r.message){o=r.message.split(`
107
- `)[0];const n=this.extractJSONFromError(r.message);o+=`: ${n.error.message}`}return O({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#74AA9C",secondary:"#FFF"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[ChatGPT]"),this.errorPrefix=C.red.bold("[ChatGPT]")}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(this.handleError$))}extractJSONFromError(e){const r=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,o=e.match(r);return o?Object.assign({},...o.map(n=>JSON.parse(n))):{error:{message:"Unknown error"}}}async generateMessage(e){const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,temperature:i,logging:u,locale:a,generate:l,type:m,maxLength:c,proxy:D,maxTokens:d,timeout:f}=this.params.config,h={...j,locale:a,maxLength:c,type:m,generate:l,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},g=e==="review"?q(h):U(h),y=await lc("ChatGPT",this.params.config.url,this.params.config.path,this.params.config.key,this.params.config.model,r,f,d,i,this.params.config.topP,g,u,e,D);return ze(e==="review"?y.map(w=>this.sanitizeResponse(w)):y.map(w=>this.parseMessage(w,m,l)))}}class en extends G{constructor(e){super(e),this.params=e,this.host="https://api.perplexity.ai",this.apiKey="",this.handleError$=r=>{let o="An error occurred";if(r.message){o=r.message.split(`
108
- `)[0];const n=this.extractJSONFromError(r.message);o+=`: ${n.error.message}`}return O({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#20808D",secondary:"#FFF"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Perplexity]"),this.errorPrefix=C.red.bold("[Perplexity]"),this.apiKey=this.params.config.key}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(this.handleError$))}extractJSONFromError(e){const r=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,o=e.match(r);return o?Object.assign({},...o.map(n=>JSON.parse(n))):{error:{message:"Unknown error"}}}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"?q(c):U(c),d=await this.createChatCompletions(D,r);return i&&H("Perplexity",r,D,d,e),this.parseMessage(d,l,a)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new E(`Error connecting to ${o.hostname} (${o.syscall})`):o}}async createChatCompletions(e,r){const n=(await new Ce({method:"POST",baseURL:`${this.host}/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: ${r}`}],temperature:this.params.config.temperature,top_p:this.params.config.topP,max_tokens:this.params.config.maxTokens,stream:!1}).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}}class Qe{constructor(e,r){this.config=e,this.stagedDiff=r}createCommitMsgRequests$(e){return v(e).pipe(Be(r=>{const o=this.config[r];if(o.compatible)return x.create(Go,{config:{...o,url:o.url||"",path:o.path||""},stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();switch(r){case"OPENAI":return x.create(Qo,{config:this.config.OPENAI,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"GEMINI":return x.create(So,{config:this.config.GEMINI,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"ANTHROPIC":return x.create(Po,{config:this.config.ANTHROPIC,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"HUGGINGFACE":return x.create(Oo,{config:this.config.HUGGINGFACE,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"MISTRAL":return x.create(ko,{config:this.config.MISTRAL,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"CODESTRAL":return x.create(Bo,{config:this.config.CODESTRAL,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"OLLAMA":return v(this.config.OLLAMA.model).pipe(Be(s=>x.create(jo,{config:this.config.OLLAMA,keyName:s,stagedDiff:this.stagedDiff}).generateCommitMessage$()));case"COHERE":return x.create(xo,{config:this.config.COHERE,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"GROQ":return x.create(Ro,{config:this.config.GROQ,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"PERPLEXITY":return x.create(en,{config:this.config.PERPLEXITY,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"DEEPSEEK":return x.create(Mo,{config:this.config.DEEPSEEK,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();default:const n=C.red.bold(`[${r}]`);return O({name:n+" Invalid AI type",value:"Invalid AI type",isError:!0,disabled:!0})}}),$(r=>{const o=C.red.bold("[UNKNOWN]");return O({name:o+` ${r.message||""}`,value:"Unknown error",isError:!0,disabled:!0})}))}createCodeReviewRequests$(e){return v(e).pipe(Be(r=>{const o=this.config[r];if(o.compatible)return x.create(Go,{config:{...o,url:o.url||"",path:o.path||""},stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();switch(r){case"OPENAI":return x.create(Qo,{config:this.config.OPENAI,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"GEMINI":return x.create(So,{config:this.config.GEMINI,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"ANTHROPIC":return x.create(Po,{config:this.config.ANTHROPIC,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"HUGGINGFACE":return x.create(Oo,{config:this.config.HUGGINGFACE,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"MISTRAL":return x.create(ko,{config:this.config.MISTRAL,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"CODESTRAL":return x.create(Bo,{config:this.config.CODESTRAL,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"OLLAMA":return v(this.config.OLLAMA.model).pipe(Be(s=>x.create(jo,{config:this.config.OLLAMA,keyName:s,stagedDiff:this.stagedDiff}).generateCodeReview$()));case"COHERE":return x.create(xo,{config:this.config.COHERE,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"GROQ":return x.create(Ro,{config:this.config.GROQ,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"PERPLEXITY":return x.create(en,{config:this.config.PERPLEXITY,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"DEEPSEEK":return x.create(Mo,{config:this.config.DEEPSEEK,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();default:const n=C.red.bold(`[${r}]`);return O({name:n+" Invalid AI type",value:"Invalid AI type",isError:!0,disabled:!0})}}),$(r=>{const o=C.red.bold("[UNKNOWN]");return O({name:o+` ${r.message||""}`,value:"Unknown error",isError:!0,disabled:!0})}))}}const tr=async()=>{const{stdout:t,failed:e}=await re("git",["rev-parse","--show-toplevel"],{reject:!1});if(e)throw new E("The current directory must be a Git repository!");return t},Z=t=>`:(exclude)${t}`,et=["package-lock.json","pnpm-lock.yaml","*.lock","*.lockb","*.gif","*.png"].map(Z),rr=async(t,e)=>{const r=["diff","--cached","--diff-algorithm=minimal"],{stdout:o}=await re("git",[...r,"--name-only",...et,...t?t.map(Z):[],...e?e.map(Z):[]]);if(!o)return null;const{stdout:n}=await re("git",[...r,...et,...t?t.map(Z):[]]);return{files:o.split(`
106
+ Check the API status: ${t}`),new E(l)}return JSON.parse(a)},Yo=t=>t.trim(),lc=async(t,e,r,o,n,s,i,u,a,l,m,c,D,d)=>{try{const f={model:n,messages:[{role:"system",content:m},{role:"user",content:`Here is the diff: ${s}`}],temperature:a,max_tokens:u,stream:!1,n:1,top_p:l,frequency_penalty:0,presence_penalty:0},h=await cc(e,r,o,f,i,d),g=h.choices.filter(y=>y.message?.content).map(y=>Yo(y.message.content)).join();return c&&H(t,s,m,g,D),h.choices.filter(y=>y.message?.content).map(y=>Yo(y.message.content))}catch(f){const h=f;throw h.code==="ENOTFOUND"?new E(`Error connecting to ${h.hostname} (${h.syscall})`):h}};class Xo extends G{constructor(e){super(e),this.params=e,this.handleError$=r=>{let o="An error occurred";if(r.message){o=r.message.split(`
107
+ `)[0];const n=this.extractJSONFromError(r.message);o+=`: ${n.error.message}`}return O({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#74AA9C",secondary:"#FFF"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[ChatGPT]"),this.errorPrefix=C.red.bold("[ChatGPT]")}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(this.handleError$))}extractJSONFromError(e){const r=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,o=e.match(r);return o?Object.assign({},...o.map(n=>JSON.parse(n))):{error:{message:"Unknown error"}}}async generateMessage(e){const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,temperature:i,logging:u,locale:a,generate:l,type:m,maxLength:c,proxy:D,maxTokens:d,timeout:f}=this.params.config,h={...j,locale:a,maxLength:c,type:m,generate:l,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},g=e==="review"?q(h):U(h),y=await lc("ChatGPT",this.params.config.url,this.params.config.path,this.params.config.key,this.params.config.model,r,f,d,i,this.params.config.topP,g,u,e,D);return ze(e==="review"?y.map(w=>this.sanitizeResponse(w)):y.map(w=>this.parseMessage(w,m,l)))}}class Zo extends G{constructor(e){super(e),this.params=e,this.host="https://api.perplexity.ai",this.apiKey="",this.handleError$=r=>{let o="An error occurred";if(r.message){o=r.message.split(`
108
+ `)[0];const n=this.extractJSONFromError(r.message);o+=`: ${n.error.message}`}return O({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#20808D",secondary:"#FFF"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Perplexity]"),this.errorPrefix=C.red.bold("[Perplexity]"),this.apiKey=this.params.config.key}generateCommitMessage$(){return P(this.generateMessage("commit")).pipe(A(e=>v(e)),b(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})),$(this.handleError$))}generateCodeReview$(){return P(this.generateMessage("review")).pipe(A(e=>v(e)),b(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),$(this.handleError$))}extractJSONFromError(e){const r=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,o=e.match(r);return o?Object.assign({},...o.map(n=>JSON.parse(n))):{error:{message:"Unknown error"}}}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"?q(c):U(c),d=await this.createChatCompletions(D,r);return i&&H("Perplexity",r,D,d,e),this.parseMessage(d,l,a)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new E(`Error connecting to ${o.hostname} (${o.syscall})`):o}}async createChatCompletions(e,r){const n=(await new Ce({method:"POST",baseURL:`${this.host}/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: ${r}`}],temperature:this.params.config.temperature,top_p:this.params.config.topP,max_tokens:this.params.config.maxTokens,stream:!1}).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}}class Qe{constructor(e,r){this.config=e,this.stagedDiff=r}createCommitMsgRequests$(e){return v(e).pipe(Be(r=>{const o=this.config[r];if(o.compatible)return x.create(_o,{config:{...o,url:o.url||"",path:o.path||""},stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();switch(r){case"OPENAI":return x.create(Xo,{config:this.config.OPENAI,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"GEMINI":return x.create(xo,{config:this.config.GEMINI,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"ANTHROPIC":return x.create($o,{config:this.config.ANTHROPIC,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"HUGGINGFACE":return x.create(So,{config:this.config.HUGGINGFACE,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"MISTRAL":return x.create(Ro,{config:this.config.MISTRAL,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"CODESTRAL":return x.create(Ao,{config:this.config.CODESTRAL,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"OLLAMA":return v(this.config.OLLAMA.model).pipe(Be(s=>x.create(To,{config:this.config.OLLAMA,keyName:s,stagedDiff:this.stagedDiff}).generateCommitMessage$()));case"COHERE":return x.create(Po,{config:this.config.COHERE,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"GROQ":return x.create(Mo,{config:this.config.GROQ,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"PERPLEXITY":return x.create(Zo,{config:this.config.PERPLEXITY,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"DEEPSEEK":return x.create(Bo,{config:this.config.DEEPSEEK,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();default:const n=C.red.bold(`[${r}]`);return O({name:n+" Invalid AI type",value:"Invalid AI type",isError:!0,disabled:!0})}}),$(r=>{const o=C.red.bold("[UNKNOWN]");return O({name:o+` ${r.message||""}`,value:"Unknown error",isError:!0,disabled:!0})}))}createCodeReviewRequests$(e){return v(e).pipe(Be(r=>{const o=this.config[r];if(o.compatible)return x.create(_o,{config:{...o,url:o.url||"",path:o.path||""},stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();switch(r){case"OPENAI":return x.create(Xo,{config:this.config.OPENAI,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"GEMINI":return x.create(xo,{config:this.config.GEMINI,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"ANTHROPIC":return x.create($o,{config:this.config.ANTHROPIC,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"HUGGINGFACE":return x.create(So,{config:this.config.HUGGINGFACE,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"MISTRAL":return x.create(Ro,{config:this.config.MISTRAL,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"CODESTRAL":return x.create(Ao,{config:this.config.CODESTRAL,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"OLLAMA":return v(this.config.OLLAMA.model).pipe(Be(s=>x.create(To,{config:this.config.OLLAMA,keyName:s,stagedDiff:this.stagedDiff}).generateCodeReview$()));case"COHERE":return x.create(Po,{config:this.config.COHERE,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"GROQ":return x.create(Mo,{config:this.config.GROQ,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"PERPLEXITY":return x.create(Zo,{config:this.config.PERPLEXITY,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"DEEPSEEK":return x.create(Bo,{config:this.config.DEEPSEEK,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();default:const n=C.red.bold(`[${r}]`);return O({name:n+" Invalid AI type",value:"Invalid AI type",isError:!0,disabled:!0})}}),$(r=>{const o=C.red.bold("[UNKNOWN]");return O({name:o+` ${r.message||""}`,value:"Unknown error",isError:!0,disabled:!0})}))}}const tr=async()=>{const{stdout:t,failed:e}=await re("git",["rev-parse","--show-toplevel"],{reject:!1});if(e)throw new E("The current directory must be a Git repository!");return t},Z=t=>`:(exclude)${t}`,et=["package-lock.json","pnpm-lock.yaml","*.lock","*.lockb","*.gif","*.png"].map(Z),rr=async(t,e)=>{const r=["diff","--cached","--diff-algorithm=minimal"],{stdout:o}=await re("git",[...r,"--name-only",...et,...t?t.map(Z):[],...e?e.map(Z):[]]);if(!o)return null;const{stdout:n}=await re("git",[...r,...et,...t?t.map(Z):[]]);return{files:o.split(`
109
109
  `),diff:n}},Dc=t=>`Detected ${t.length.toLocaleString()} staged file${t.length>1?"s":""}`,mc=async(t,e,r)=>{const o=["diff-tree","-r","--no-commit-id","--name-only",t],{stdout:n}=await re("git",[...o,...et,...e?e.map(Z):[],...r?r.map(Z):[]]);if(!n)return null;const{stdout:s}=await re("git",["show",t,"--",...et,...e?e.map(Z):[],...r?r.map(Z):[]]);return{files:n.split(`
110
110
  `).filter(Boolean),diff:s}};class Q{constructor(){this.title="aicommit2"}printTitle(){console.log(Gn.textSync(this.title,{font:"Small"}))}showLoader(e){if(this.loader){this.loader.text=e;return}this.loader=at(e).start()}stopLoader(){this.loader?.stop(),this.loader=void 0}displaySpinner(e){return at(e).start()}stopSpinner(e){e.stop(),e.clear()}printStagedFiles(e){console.log(C.bold.green("\u2714 ")+C.bold(`${Dc(e.files)}:`)),console.log(`${e.files.map(r=>` ${r}`).join(`
111
111
  `)}
@@ -117,11 +117,11 @@ ${C.bold.green("\u2714")} ${C.bold("Saved commit message")}`)}printCancelledComm
117
117
  ${C.bold.yellow("\u26A0")} ${C.yellow("Commit cancelled")}`)}printError(e){console.log(`
118
118
  ${C.bold.red("\u2716")} ${C.red(`${e}`)}`)}printWarning(e){console.log(`
119
119
  ${C.bold.yellow("\u26A0")} ${C.red(`${e}`)}`)}printSetupGitEvent(e){console.log(`
120
- ${C.bold.green("\u2714")} ${C.bold(`Git ${e} hook has been set up`)}`)}moveCursorUp(){const e=Re.createInterface({input:process.stdin,output:process.stdout});Re.moveCursor(process.stdout,0,-1),e.close()}moveCursorDown(){const e=Re.createInterface({input:process.stdin,output:process.stdout});Re.moveCursor(process.stdout,0,2),e.close()}}const dc={isLoading:!1,startOption:{text:"AI is analyzing your changes"}},tn={isLoading:!1,startOption:{text:"AI is performing a code review"}},or="No commit messages were generated",rn="No code reviews were generated",nr={type:"reactiveListPrompt",name:"aicommit2Prompt",message:"Pick a commit message to use: ",emptyMessage:`\u26A0 ${or}`,loop:!1,descPageSize:15,showDescription:!0,pickKey:"short",isDescriptionDim:!0,stopMessage:"Changes analyzed"};class sr{constructor(e){this.choices$=new gr([]),this.destroyed$=new An(1),this.stopMessage="Changes analyzed",this.inquirerInstance=null,this.loader$=new gr(e)}initPrompt(e=nr){return this.stopMessage=e.stopMessage,Pe.registerPrompt("reactiveListPrompt",Hn),this.inquirerInstance=Pe.prompt({choices$:this.choices$,loader$:this.loader$,...e}),this.inquirerInstance}startLoader(){this.loader$.next({isLoading:!0})}clearLoader(){this.inquirerInstance&&this.loader$.next({isLoading:!1,clear:!0})}refreshChoices(e){const{value:r,isError:o}=e;!e||!r||this.choices$.next([...this.currentChoices,e].sort(fu))}checkErrorOnChoices(e=!0){if(this.choices$.getValue().map(o=>o).every(o=>o?.isError||o?.disabled)){this.alertNoGeneratedMessage(),this.logEmptyCommitMessage(),e&&process.exit(1);return}this.stopLoaderOnSuccess()}completeSubject(){this.choices$.complete(),this.loader$.complete(),this.destroyed$.next(!0),this.destroyed$.complete()}closeInquirerInstance(){this.inquirerInstance&&this.inquirerInstance.ui.close()}cancel(){this.inquirerInstance?.ui?.activePrompt&&this.inquirerInstance.ui.activePrompt.abortPrompt()}alertNoGeneratedMessage(){this.loader$.next({isLoading:!1,message:or,stopOption:{doneFrame:"\u26A0",color:"yellow"}})}stopLoaderOnSuccess(){this.loader$.next({isLoading:!1,message:this.stopMessage})}logEmptyCommitMessage(){console.log(`${C.bold.yellow("\u26A0")} ${C.yellow(`${or}`)}`)}get currentChoices(){return this.choices$.getValue().map(e=>e)}}const K=new Q;var pc=async(t,e,r,o,n,s,i,u,a)=>(async()=>{K.printTitle(),await tr(),o&&await re("git",["add","--update"]);const l=await Ee({locale:t?.toString(),generate:e?.toString(),commitType:n?.toString(),systemPrompt:u?.toString()},a);await Ao(l);const m=K.displaySpinner("Detecting staged files"),c=await rr(r,l.exclude);if(m.stop(),!c)throw new E("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");K.printStagedFiles(c);const D=on(l,"commit");if(D.length===0)throw new E("Please set at least one API key via the `aicommit2 config set` command");const d=new Qe(l,c),f=on(l,"review");f.length>0&&await fc(d,f);const h=await hc(d,D);i&&(Di("copy-paste").copy(h),K.printCopied(),process.exit()),s&&(await nn(h,a),process.exit());const{confirmationPrompt:g}=await Pe.prompt([{type:"confirm",name:"confirmationPrompt",message:"Use selected message?",default:!0}]);g?await nn(h,a):K.printCancelledCommit(),process.exit()})().catch(l=>{K.printError(l.message),oe(l),process.exit(1)});function on(t,e){return Object.entries(t).map(([r,o])=>[r,o]).filter(([r,o])=>!o.disabled).filter(([r,o])=>X.includes(r)||o.compatible===!0).filter(([r,o])=>{switch(e){case"commit":return r==="OLLAMA"?!!o&&!!o.model&&o.model.length>0:r==="HUGGINGFACE"?!!o&&!!o.cookie:!!o.key&&o.key.length>0;case"review":const n=t.codeReview||o.codeReview;return r==="OLLAMA"?!!o&&!!o.model&&o.model.length>0&&n:r==="HUGGINGFACE"?!!o&&!!o.cookie&&n:!!o.key&&o.key.length>0&&n}}).map(([r])=>r)}async function fc(t,e){const r=new sr(tn),o=r.initPrompt({...nr,name:"codeReviewPrompt",message:"Please check code reviews: ",emptyMessage:`\u26A0 ${rn}`,isDescriptionDim:!1,stopMessage:"Code review completed",descPageSize:20});r.startLoader();const n=t.createCodeReviewRequests$(e).subscribe(a=>r.refreshChoices(a),()=>{},()=>r.checkErrorOnChoices());if(!(await o).codeReviewPrompt?.value)throw new E("An error occurred! No selected code review");n.unsubscribe(),r.completeSubject(),K.moveCursorUp();const{continuePrompt:u}=await Pe.prompt([{type:"confirm",name:"continuePrompt",message:"Will you continue without changing the code?",default:!0}]);u||(K.printCancelledCommit(),process.exit())}async function hc(t,e){const r=new sr(dc),o=r.initPrompt();r.startLoader();const n=t.createCommitMsgRequests$(e).subscribe(u=>r.refreshChoices(u),()=>{},()=>r.checkErrorOnChoices()),s=await o;n.unsubscribe(),r.completeSubject(),K.moveCursorUp();const i=s.aicommit2Prompt?.value;if(!i)throw new E("An error occurred! No selected message");return i}async function nn(t,e){const r=at("Committing with the generated message").start();await re("git",["commit","-m",t,...e]),r.stop(),r.clear(),K.printCommitted()}var gc=gt({name:"config",parameters:["<mode>","[key=value...]"],help:{usage:["aic2 config set <key>=<value> [<key>=<value> ...]","aic2 config get [<key> [<key> ...]]","aic2 config add <key>=<value> [<key>=<value> ...]","aic2 config list"].join(`
121
- `)}},t=>{(async()=>{const{mode:e,keyValue:r}=t._;if(e==="get"){const o=await Ee({},[]);for(const n of r)if(Je(o,n)){if(X.includes(n)){console.log(n,o[n]);return}console.log(`${n}=${o[n]}`)}return}if(e==="set"){await Su(r.map(o=>o.split("=")));return}if(e==="add"){await Ru(r.map(o=>o.split("=")));return}if(e==="list"){await Ou();return}throw new E(`Invalid mode: ${e}`)})().catch(e=>{new Q().printError(e.message),oe(e),process.exit(1)})});const sn="prepare-commit-msg",an=`.git/hooks/${sn}`,tt=_n(new URL("cli.mjs",import.meta.url)),Cc=process.argv[1].replace(/\\/g,"/").endsWith(`/${an}`),un=process.platform==="win32",cn=`
120
+ ${C.bold.green("\u2714")} ${C.bold(`Git ${e} hook has been set up`)}`)}moveCursorUp(){const e=Re.createInterface({input:process.stdin,output:process.stdout});Re.moveCursor(process.stdout,0,-1),e.close()}moveCursorDown(){const e=Re.createInterface({input:process.stdin,output:process.stdout});Re.moveCursor(process.stdout,0,2),e.close()}}const dc={isLoading:!1,startOption:{text:"AI is analyzing your changes"}},Qo={isLoading:!1,startOption:{text:"AI is performing a code review"}},or="No commit messages were generated",en="No code reviews were generated",nr={type:"reactiveListPrompt",name:"aicommit2Prompt",message:"Pick a commit message to use: ",emptyMessage:`\u26A0 ${or}`,loop:!1,descPageSize:15,showDescription:!0,pickKey:"short",isDescriptionDim:!0,stopMessage:"Changes analyzed"};class sr{constructor(e){this.choices$=new fr([]),this.destroyed$=new An(1),this.stopMessage="Changes analyzed",this.inquirerInstance=null,this.loader$=new fr(e)}initPrompt(e=nr){return this.stopMessage=e.stopMessage,Pe.registerPrompt("reactiveListPrompt",Hn),this.inquirerInstance=Pe.prompt({choices$:this.choices$,loader$:this.loader$,...e}),this.inquirerInstance}startLoader(){this.loader$.next({isLoading:!0})}clearLoader(){this.inquirerInstance&&this.loader$.next({isLoading:!1,clear:!0})}refreshChoices(e){const{value:r,isError:o}=e;!e||!r||this.choices$.next([...this.currentChoices,e].sort(fu))}checkErrorOnChoices(e=!0){if(this.choices$.getValue().map(o=>o).every(o=>o?.isError||o?.disabled)){this.alertNoGeneratedMessage(),this.logEmptyCommitMessage(),e&&process.exit(1);return}this.stopLoaderOnSuccess()}completeSubject(){this.choices$.complete(),this.loader$.complete(),this.destroyed$.next(!0),this.destroyed$.complete()}closeInquirerInstance(){this.inquirerInstance&&this.inquirerInstance.ui.close()}cancel(){this.inquirerInstance?.ui?.activePrompt&&this.inquirerInstance.ui.activePrompt.abortPrompt()}alertNoGeneratedMessage(){this.loader$.next({isLoading:!1,message:or,stopOption:{doneFrame:"\u26A0",color:"yellow"}})}stopLoaderOnSuccess(){this.loader$.next({isLoading:!1,message:this.stopMessage})}logEmptyCommitMessage(){console.log(`${C.bold.yellow("\u26A0")} ${C.yellow(`${or}`)}`)}get currentChoices(){return this.choices$.getValue().map(e=>e)}}const K=new Q;var pc=async(t,e,r,o,n,s,i,u,a)=>(async()=>{K.printTitle(),await tr(),o&&await re("git",["add","--update"]);const l=await Ee({locale:t?.toString(),generate:e?.toString(),commitType:n?.toString(),systemPrompt:u?.toString()},a);await bo(l);const m=K.displaySpinner("Detecting staged files"),c=await rr(r,l.exclude);if(m.stop(),!c)throw new E("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");K.printStagedFiles(c);const D=tn(l,"commit");if(D.length===0)throw new E("Please set at least one API key via the `aicommit2 config set` command");const d=new Qe(l,c),f=tn(l,"review");f.length>0&&await fc(d,f);const h=await hc(d,D);i&&(Di("copy-paste").copy(h),K.printCopied(),process.exit()),s&&(await rn(h,a),process.exit());const{confirmationPrompt:g}=await Pe.prompt([{type:"confirm",name:"confirmationPrompt",message:"Use selected message?",default:!0}]);g?await rn(h,a):K.printCancelledCommit(),process.exit()})().catch(l=>{K.printError(l.message),oe(l),process.exit(1)});function tn(t,e){return Object.entries(t).map(([r,o])=>[r,o]).filter(([r,o])=>!o.disabled).filter(([r,o])=>X.includes(r)||o.compatible===!0).filter(([r,o])=>{switch(e){case"commit":return r==="OLLAMA"?!!o&&!!o.model&&o.model.length>0:r==="HUGGINGFACE"?!!o&&!!o.cookie:!!o.key&&o.key.length>0;case"review":const n=t.codeReview||o.codeReview;return r==="OLLAMA"?!!o&&!!o.model&&o.model.length>0&&n:r==="HUGGINGFACE"?!!o&&!!o.cookie&&n:!!o.key&&o.key.length>0&&n}}).map(([r])=>r)}async function fc(t,e){const r=new sr(Qo),o=r.initPrompt({...nr,name:"codeReviewPrompt",message:"Please check code reviews: ",emptyMessage:`\u26A0 ${en}`,isDescriptionDim:!1,stopMessage:"Code review completed",descPageSize:20});r.startLoader();const n=t.createCodeReviewRequests$(e).subscribe(a=>r.refreshChoices(a),()=>{},()=>r.checkErrorOnChoices());if(!(await o).codeReviewPrompt?.value)throw new E("An error occurred! No selected code review");n.unsubscribe(),r.completeSubject(),K.moveCursorUp();const{continuePrompt:u}=await Pe.prompt([{type:"confirm",name:"continuePrompt",message:"Will you continue without changing the code?",default:!0}]);u||(K.printCancelledCommit(),process.exit())}async function hc(t,e){const r=new sr(dc),o=r.initPrompt();r.startLoader();const n=t.createCommitMsgRequests$(e).subscribe(u=>r.refreshChoices(u),()=>{},()=>r.checkErrorOnChoices()),s=await o;n.unsubscribe(),r.completeSubject(),K.moveCursorUp();const i=s.aicommit2Prompt?.value;if(!i)throw new E("An error occurred! No selected message");return i}async function rn(t,e){const r=at("Committing with the generated message").start();await re("git",["commit","-m",t,...e]),r.stop(),r.clear(),K.printCommitted()}var gc=gt({name:"config",parameters:["<mode>","[key=value...]"],help:{usage:["aic2 config set <key>=<value> [<key>=<value> ...]","aic2 config get [<key> [<key> ...]]","aic2 config add <key>=<value> [<key>=<value> ...]","aic2 config list","","Note: When setting API keys with dots in the key name, wrap the entire key-value pair in quotes:",' aic2 config set "OPENAI.key=your-api-key"'].join(`
121
+ `)}},t=>{(async()=>{const{mode:e,keyValue:r}=t._;if(e==="get"){const o=await Ee({},[]);for(const n of r)if(Je(o,n)){if(X.includes(n)){console.log(n,o[n]);return}console.log(`${n}=${o[n]}`)}return}if(e==="set"){await Su(r.map(o=>{const n=o.indexOf("=");if(n===-1)throw new E("Invalid format. Use: key=value");const s=o.slice(0,n),i=o.slice(n+1);return[s,i]}));return}if(e==="add"){await Ru(r.map(o=>o.split("=")));return}if(e==="list"){await Ou();return}throw new E(`Invalid mode: ${e}`)})().catch(e=>{new Q().printError(e.message),oe(e),process.exit(1)})});const on="prepare-commit-msg",nn=`.git/hooks/${on}`,tt=_n(new URL("cli.mjs",import.meta.url)),Cc=process.argv[1].replace(/\\/g,"/").endsWith(`/${nn}`),sn=process.platform==="win32",an=`
122
122
  #!/usr/bin/env node
123
123
  import(${JSON.stringify(jn(tt))})
124
- `.trim();var yc=gt({name:"hook",parameters:["<install/uninstall>"]},t=>{(async()=>{const e=await tr(),{installUninstall:r}=t._,o=I.join(e,an),n=await To(o);if(r==="install"){if(n){if(await M.realpath(o).catch(()=>{})===tt){console.warn("The hook is already installed");return}throw new E(`A different ${sn} hook seems to be installed. Please remove it before installing aicommit2.`)}await M.mkdir(I.dirname(o),{recursive:!0}),un?await M.writeFile(o,cn):(await M.symlink(tt,o,"file"),await M.chmod(o,493)),console.log(`${C.green("\u2714")} Hook installed`);return}if(r==="uninstall"){if(!n){console.warn("Hook is not installed");return}if(un){if(await M.readFile(o,"utf8")!==cn){console.warn("Hook is not installed");return}}else if(await M.realpath(o)!==tt){console.warn("Hook is not installed");return}await M.rm(o),console.log(`${C.green("\u2714")} Hook uninstalled`);return}throw new E(`Invalid mode: ${r}`)})().catch(e=>{console.error(`${C.red("\u2716")} ${e.message}`),oe(e),process.exit(1)})}),Ec=gt({name:"log",parameters:["<removeAll>"]},t=>{(async()=>{const{removeAll:e}=t._;if(e==="removeAll"){await Un(wo,{recursive:!0,force:!0}),console.log(`${C.green("\u2714")} All Log files are removed!`);return}throw new E(`Invalid mode: ${e}`)})().catch(e=>{new Q().printError(e.message),oe(e),process.exit(1)})});const Fc=process.argv.slice(2).filter(t=>!t.startsWith("--pre-commit")),[rt,ir]=Fc;var wc=()=>(async()=>{if(!rt)throw new E('Commit message file path is missing. This file should be called from the "pre-commit framework"');if(ir&&["message","template","merge","squash"].includes(ir)){console.log(`Skipping aicommit2 message generation for ${ir} commit`);return}const t=await rr();if(!t)return;const e=new Q;e.printTitle();const r=await Ee({});if(r.systemPromptPath)try{await M.readFile(I.resolve(r.systemPromptPath),"utf-8")}catch{throw new E(`Error reading system prompt file: ${r.systemPromptPath}`)}const o=Object.entries(r).filter(([d])=>X.includes(d)).map(([d,f])=>[d,f]).filter(([d,f])=>!f.disabled).filter(([d,f])=>d==="OLLAMA"?!!f&&!!f.model&&f.model.length>0:d==="HUGGINGFACE"?!!f&&!!f.cookie:!!f.key&&f.key.length>0).map(([d])=>d);if(o.length===0)throw new E("Please set at least one API key via the `aicommit2 config set` command");const s=new Qe(r,t);let i;try{i=await Cr(s.createCommitMsgRequests$(o).pipe(yr(d=>!d.isError),b(d=>d.value),Er()))}finally{e.printAnalyzed()}const a=await M.readFile(rt,"utf8")!=="",l=i.length>1;let m="";a&&(m=`# \u{1F916} Generated by aicommit2 (https://github.com/tak-bro/aicommit2)
124
+ `.trim();var yc=gt({name:"hook",parameters:["<install/uninstall>"]},t=>{(async()=>{const e=await tr(),{installUninstall:r}=t._,o=I.join(e,nn),n=await Lo(o);if(r==="install"){if(n){if(await M.realpath(o).catch(()=>{})===tt){console.warn("The hook is already installed");return}throw new E(`A different ${on} hook seems to be installed. Please remove it before installing aicommit2.`)}await M.mkdir(I.dirname(o),{recursive:!0}),sn?await M.writeFile(o,an):(await M.symlink(tt,o,"file"),await M.chmod(o,493)),console.log(`${C.green("\u2714")} Hook installed`);return}if(r==="uninstall"){if(!n){console.warn("Hook is not installed");return}if(sn){if(await M.readFile(o,"utf8")!==an){console.warn("Hook is not installed");return}}else if(await M.realpath(o)!==tt){console.warn("Hook is not installed");return}await M.rm(o),console.log(`${C.green("\u2714")} Hook uninstalled`);return}throw new E(`Invalid mode: ${r}`)})().catch(e=>{console.error(`${C.red("\u2716")} ${e.message}`),oe(e),process.exit(1)})}),Ec=gt({name:"log",parameters:["<removeAll>"]},t=>{(async()=>{const{removeAll:e}=t._;if(e==="removeAll"){await Un(Eo,{recursive:!0,force:!0}),console.log(`${C.green("\u2714")} All Log files are removed!`);return}throw new E(`Invalid mode: ${e}`)})().catch(e=>{new Q().printError(e.message),oe(e),process.exit(1)})});const Fc=process.argv.slice(2).filter(t=>!t.startsWith("--pre-commit")),[rt,un]=Fc;var wc=()=>(async()=>{if(!rt)throw new E('Commit message file path is missing. This file should be called from the "pre-commit framework"');if(un){console.log(`Skipping aicommit2 message generation for ${un} commit`);return}const t=await rr();if(!t)return;const e=new Q;e.printTitle();const r=await Ee({});if(r.systemPromptPath)try{await M.readFile(I.resolve(r.systemPromptPath),"utf-8")}catch{throw new E(`Error reading system prompt file: ${r.systemPromptPath}`)}const o=Object.entries(r).filter(([d])=>X.includes(d)).map(([d,f])=>[d,f]).filter(([d,f])=>!f.disabled).filter(([d,f])=>d==="OLLAMA"?!!f&&!!f.model&&f.model.length>0:d==="HUGGINGFACE"?!!f&&!!f.cookie:!!f.key&&f.key.length>0).map(([d])=>d);if(o.length===0)throw new E("Please set at least one API key via the `aicommit2 config set` command");const s=new Qe(r,t);let i;try{i=await hr(s.createCommitMsgRequests$(o).pipe(gr(d=>!d.isError),b(d=>d.value),Cr()))}finally{e.printAnalyzed()}const a=await M.readFile(rt,"utf8")!=="",l=i.length>1;let m="";a&&(m=`# \u{1F916} Generated by aicommit2 (https://github.com/tak-bro/aicommit2)
125
125
  `,m+=`# ----------------------------------------
126
126
  `,m+=`# How to use:
127
127
  `,l?(m+=`# 1. Remove the "#" from your chosen message
@@ -140,7 +140,7 @@ ${i.map(d=>`# ${d}`).join(`
140
140
  `),m+=`
141
141
  ${i[0]}
142
142
  `);const c=await M.readFile(rt,"utf8"),D=m+`
143
- `+c;await M.writeFile(rt,D),e.printSavedCommitMessage()})().catch(t=>{new Q().printError(t.message),oe(t),process.exit(1)});const vc=process.argv.slice(2).filter(t=>!t.startsWith("--hook-mode")),[ot,ar]=vc;var bc=()=>(async()=>{if(!ot)throw new E('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook or with --hook-mode flag');if(ar&&["message","template","merge","squash"].includes(ar)){console.log(`Skipping aicommit2 message generation for ${ar} commit`);return}const t=await rr();if(!t)return;const e=new Q;e.printTitle();const r=await Ee({});if(r.systemPromptPath)try{await M.readFile(I.resolve(r.systemPromptPath),"utf-8")}catch{throw new E(`Error reading system prompt file: ${r.systemPromptPath}`)}const o=Object.entries(r).filter(([f])=>X.includes(f)).map(([f,h])=>[f,h]).filter(([f,h])=>!h.disabled).filter(([f,h])=>f==="OLLAMA"?!!h&&!!h.model&&h.model.length>0:f==="HUGGINGFACE"?!!h&&!!h.cookie:!!h.key&&h.key.length>0).map(([f])=>f);if(o.length===0)throw new E("Please set at least one API key via the `aicommit2 config set` command");const s=new Qe(r,t),i=e.displaySpinner("The AI is analyzing your changes");let u;try{u=await Cr(s.createCommitMsgRequests$(o).pipe(yr(f=>!f.isError),b(f=>f.value),Er()))}finally{i.stop(),i.clear(),e.printAnalyzed()}const l=await M.readFile(ot,"utf8")!=="",m=u.length>1;let c="";l&&(c=`# \u{1F916} Generated by aicommit2 (https://github.com/tak-bro/aicommit2)
143
+ `+c;await M.writeFile(rt,D),e.printSavedCommitMessage()})().catch(t=>{new Q().printError(t.message),oe(t),process.exit(1)});const vc=process.argv.slice(2).filter(t=>!t.startsWith("--hook-mode")),[ot,cn]=vc;var bc=()=>(async()=>{if(!ot)throw new E('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook or with --hook-mode flag');if(cn){console.log(`Skipping aicommit2 message generation for ${cn} commit`);return}const t=await rr();if(!t)return;const e=new Q;e.printTitle();const r=await Ee({});if(r.systemPromptPath)try{await M.readFile(I.resolve(r.systemPromptPath),"utf-8")}catch{throw new E(`Error reading system prompt file: ${r.systemPromptPath}`)}const o=Object.entries(r).filter(([f])=>X.includes(f)).map(([f,h])=>[f,h]).filter(([f,h])=>!h.disabled).filter(([f,h])=>f==="OLLAMA"?!!h&&!!h.model&&h.model.length>0:f==="HUGGINGFACE"?!!h&&!!h.cookie:!!h.key&&h.key.length>0).map(([f])=>f);if(o.length===0)throw new E("Please set at least one API key via the `aicommit2 config set` command");const s=new Qe(r,t),i=e.displaySpinner("The AI is analyzing your changes");let u;try{u=await hr(s.createCommitMsgRequests$(o).pipe(gr(f=>!f.isError),b(f=>f.value),Cr()))}finally{i.stop(),i.clear(),e.printAnalyzed()}const l=await M.readFile(ot,"utf8")!=="",m=u.length>1;let c="";l&&(c=`# \u{1F916} Generated by aicommit2 (https://github.com/tak-bro/aicommit2)
144
144
  `,c+=`# ----------------------------------------
145
145
  `,c+=`# How to use:
146
146
  `,m?(c+=`# 1. Remove the "#" from your chosen message
@@ -159,13 +159,13 @@ ${u.map(f=>`# ${f}`).join(`
159
159
  `),c+=`
160
160
  ${u[0]}
161
161
  `);const D=await M.readFile(ot,"utf8"),d=c+`
162
- `+D;await M.writeFile(ot,d),e.printSavedCommitMessage()})().catch(t=>{new Q().printError(t.message),oe(t),process.exit(1)});let nt=new Fr;const _=new Q,ln=process.cwd(),$c=I.join(ln,".git","hooks","post-commit"),Ae=I.join(ln,".git","commit-log.txt"),Ac=`#!/bin/sh
162
+ `+D;await M.writeFile(ot,d),e.printSavedCommitMessage()})().catch(t=>{new Q().printError(t.message),oe(t),process.exit(1)});let nt=new yr;const _=new Q,ln=process.cwd(),$c=I.join(ln,".git","hooks","post-commit"),Ae=I.join(ln,".git","commit-log.txt"),Ac=`#!/bin/sh
163
163
  commit_hash=$(git rev-parse HEAD)
164
164
  commit_message=$(git log -1 --pretty=%B)
165
165
  echo "$commit_hash: $commit_message" >> ${Ae}
166
- `;let ur=null,L=null;const Dn=async(t,e,r,o,n)=>{_.printTitle(),await tr();const s=await Pc(t,e,o,n);Sc(),xc();try{await pn(s)}catch(i){return Bc(i),Dn(t,e,r,o,n)}},Pc=async(t,e,r,o)=>{const n=await Ee({locale:t?.toString(),generate:e?.toString(),systemPrompt:r?.toString()},o);return await Ao(n),mn(n).length===0&&(_.printError(`Please set at least one API key and watchMode via the config command:
166
+ `;let ir=null,L=null;const Dn=async(t,e,r,o,n)=>{_.printTitle(),await tr();const s=await Pc(t,e,o,n);Sc(),xc();try{await pn(s)}catch(i){return Bc(i),Dn(t,e,r,o,n)}},Pc=async(t,e,r,o)=>{const n=await Ee({locale:t?.toString(),generate:e?.toString(),systemPrompt:r?.toString()},o);return await bo(n),mn(n).length===0&&(_.printError(`Please set at least one API key and watchMode via the config command:
167
167
  aicommit2 config set [MODEL].key="YOUR_API_KEY"
168
168
  aicommit2 config set [MODEL].watchMode="true"`),process.exit()),n},Bc=async t=>{_.printError(`An error occurred: ${t.message}`),oe(t),await new Promise(e=>setTimeout(e,3e3)),_.printWarning("Restarting the commit monitoring process...")},xc=()=>{N.writeFileSync(Ae,"",{flag:"w"})},mn=t=>Object.entries(t).filter(([e,r])=>X.includes(e)||r.compatible===!0).map(([e,r])=>[e,r]).filter(([e,r])=>!r.disabled).filter(([e,r])=>Mc(e,r,t)).map(([e])=>e),Mc=(t,e,r)=>{const o=r.watchMode||e.watchMode;return t==="OLLAMA"?!!e&&!!e.model&&e.model.length>0&&o:t==="HUGGINGFACE"?!!e&&!!e.cookie&&o:e.compatible?!!e.url&&!!e.key&&o:!!e.key&&e.key.length>0&&o},Sc=()=>{N.writeFileSync($c,Ac,{mode:493}),_.printSetupGitEvent("post-commit")},dn=()=>{process.stdout.write("\x1Bc")},Rc=async(t,e)=>{try{const r=await mc(e);if(!r){_.printWarning("No changes found in this commit");return}_.stopLoader(),_.printStagedFiles(r);const o=mn(t);if(o.length===0){_.printError(`Please set at least one API key and watchMode via the config command:
169
169
  aicommit2 config set [MODEL].key="YOUR_API_KEY"
170
- aicommit2 config set [MODEL].watchMode="true"`),process.exit();return}await Oc(t,r,o)}catch(r){_.printError(`Error processing commit ${e}: ${r.message}`)}},Oc=async(t,e,r)=>{kc();const o=new Qe(t,e);L=new sr(tn);const n=Ic();L.startLoader(),ur=Lc(o,r),await n,Nc()},kc=()=>{L&&(ur?.unsubscribe(),L.clearLoader(),L.completeSubject(),L.cancel(),L.closeInquirerInstance()),nt.next(),nt.complete(),nt=new Fr},Ic=()=>L.initPrompt({...nr,name:"codeReviewPrompt",message:"Please check code reviews: ",emptyMessage:`\u26A0 ${rn}`,isDescriptionDim:!1,stopMessage:"Code review completed",descPageSize:20}),Lc=(t,e)=>t.createCodeReviewRequests$(e).pipe(zn(nt)).subscribe(r=>{L?.refreshChoices(r)},()=>{},()=>{L?.checkErrorOnChoices(!1)}),Nc=()=>{L&&(ur?.unsubscribe(),L.clearLoader(),L.completeSubject(),L.cancel(),L.closeInquirerInstance(),L=null),dn(),_.showLoader("Watching for new Git commits...")},pn=async t=>{const e=qn.watch(Ae,{persistent:!0});e.on("change",async()=>{try{const r=await Tc();for(const o of r)o&&await _c(t,o)}catch(r){_.printError(`Error reading or processing commit log: ${r.message}`)}finally{jc()}}),e.on("error",Gc(t))},Tc=async()=>(await N.promises.readFile(Ae,"utf8")).trim().split(`
171
- `),_c=async(t,e)=>{const[r]=e.split(":");if(!r){_.printWarning("Empty commit hash detected, skipping...");return}dn(),await Rc(t,r.trim())},jc=()=>{try{N.truncateSync(Ae)}catch(t){_.printError(`Error truncating log file: ${t.message}`)}},Gc=t=>e=>{_.printError(`Watcher error: ${e.message}`),setTimeout(()=>pn(t),1e3)},cr=process.argv.slice(2);li({name:"aicommit2",version:Fo,flags:{locale:{type:String,description:"Locale to use for the generated commit messages (default: en)",alias:"l"},generate:{type:Number,description:"Number of messages to generate (Warning: generating multiple costs more) (default: 1)",alias:"g"},exclude:{type:[String],description:"Files to exclude from AI analysis",alias:"x"},all:{type:Boolean,description:"Automatically stage changes in tracked files for the commit",alias:"a",default:!1},type:{type:String,description:"Type of commit message to generate",alias:"t"},confirm:{type:Boolean,description:"Skip confirmation when committing after message generation (default: false)",alias:"y",default:!1},clipboard:{type:Boolean,description:"Copy the selected message to the clipboard",alias:"c",default:!1},prompt:{type:String,description:"Custom prompt to let users fine-tune provided prompt",alias:"p"},"watch-commit":{type:Boolean,default:!1},"hook-mode":{type:Boolean,description:"Run in git hook mode, allowing chaining with other hooks",default:!1},"pre-commit":{type:Boolean,description:"Run in pre-commit Framework, allowing chaining with other hooks",default:!1}},commands:[gc,yc,Ec],help:{description:Eu},ignoreArgv:t=>t==="unknown-flag"||t==="argument"},t=>{if(t.flags["pre-commit"]){wc();return}if(t.flags["hook-mode"]||Cc){bc();return}if(t.flags["watch-commit"]){Dn(t.flags.locale,t.flags.generate,t.flags.exclude,t.flags.prompt,cr);return}pc(t.flags.locale,t.flags.generate,t.flags.exclude,t.flags.all,t.flags.type,t.flags.confirm,t.flags.clipboard,t.flags.prompt,cr)},cr);
170
+ aicommit2 config set [MODEL].watchMode="true"`),process.exit();return}await Oc(t,r,o)}catch(r){_.printError(`Error processing commit ${e}: ${r.message}`)}},Oc=async(t,e,r)=>{kc();const o=new Qe(t,e);L=new sr(Qo);const n=Ic();L.startLoader(),ir=Lc(o,r),await n,Nc()},kc=()=>{L&&(ir?.unsubscribe(),L.clearLoader(),L.completeSubject(),L.cancel(),L.closeInquirerInstance()),nt.next(),nt.complete(),nt=new yr},Ic=()=>L.initPrompt({...nr,name:"codeReviewPrompt",message:"Please check code reviews: ",emptyMessage:`\u26A0 ${en}`,isDescriptionDim:!1,stopMessage:"Code review completed",descPageSize:20}),Lc=(t,e)=>t.createCodeReviewRequests$(e).pipe(zn(nt)).subscribe(r=>{L?.refreshChoices(r)},()=>{},()=>{L?.checkErrorOnChoices(!1)}),Nc=()=>{L&&(ir?.unsubscribe(),L.clearLoader(),L.completeSubject(),L.cancel(),L.closeInquirerInstance(),L=null),dn(),_.showLoader("Watching for new Git commits...")},pn=async t=>{const e=qn.watch(Ae,{persistent:!0});e.on("change",async()=>{try{const r=await Tc();for(const o of r)o&&await _c(t,o)}catch(r){_.printError(`Error reading or processing commit log: ${r.message}`)}finally{jc()}}),e.on("error",Gc(t))},Tc=async()=>(await N.promises.readFile(Ae,"utf8")).trim().split(`
171
+ `),_c=async(t,e)=>{const[r]=e.split(":");if(!r){_.printWarning("Empty commit hash detected, skipping...");return}dn(),await Rc(t,r.trim())},jc=()=>{try{N.truncateSync(Ae)}catch(t){_.printError(`Error truncating log file: ${t.message}`)}},Gc=t=>e=>{_.printError(`Watcher error: ${e.message}`),setTimeout(()=>pn(t),1e3)},ar=process.argv.slice(2);li({name:"aicommit2",version:yo,flags:{locale:{type:String,description:"Locale to use for the generated commit messages (default: en)",alias:"l"},generate:{type:Number,description:"Number of messages to generate (Warning: generating multiple costs more) (default: 1)",alias:"g"},exclude:{type:[String],description:"Files to exclude from AI analysis",alias:"x"},all:{type:Boolean,description:"Automatically stage changes in tracked files for the commit",alias:"a",default:!1},type:{type:String,description:"Type of commit message to generate",alias:"t"},confirm:{type:Boolean,description:"Skip confirmation when committing after message generation (default: false)",alias:"y",default:!1},clipboard:{type:Boolean,description:"Copy the selected message to the clipboard",alias:"c",default:!1},prompt:{type:String,description:"Custom prompt to let users fine-tune provided prompt",alias:"p"},"watch-commit":{type:Boolean,default:!1},"hook-mode":{type:Boolean,description:"Run in git hook mode, allowing chaining with other hooks",default:!1},"pre-commit":{type:Boolean,description:"Run in pre-commit Framework, allowing chaining with other hooks",default:!1}},commands:[gc,yc,Ec],help:{description:Eu},ignoreArgv:t=>t==="unknown-flag"||t==="argument"},t=>{if(t.flags["pre-commit"]){wc();return}if(t.flags["hook-mode"]||Cc){bc();return}if(t.flags["watch-commit"]){Dn(t.flags.locale,t.flags.generate,t.flags.exclude,t.flags.prompt,ar);return}pc(t.flags.locale,t.flags.generate,t.flags.exclude,t.flags.all,t.flags.type,t.flags.confirm,t.flags.clipboard,t.flags.prompt,ar)},ar);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicommit2",
3
- "version": "2.2.9",
3
+ "version": "2.2.10",
4
4
  "description": "A Reactive CLI that generates git commit messages with various AI",
5
5
  "keywords": [
6
6
  "cli",