aicommit2 1.12.4 → 1.12.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +18 -18
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import Le from"tty";import{createRequire as vn}from"module";import k from"fs";import P from"path";import{Buffer as $n}from"node:buffer";import J from"node:path";import kt,{ChildProcess as Bn}from"node:child_process";import I from"node:process";import On from"child_process";import{fileURLToPath as jt}from"node:url";import xn,{constants as Gt}from"node:os";import Ht from"assert";import Ut from"events";import{createWriteStream as Mn,createReadStream as Sn}from"node:fs";import Pn from"buffer";import Re from"stream";import Kt from"util";import{debuglog as In}from"node:util";import Ne from"inquirer";import ke from"ora";import g from"chalk";import{of as x,concatMap as j,from as S,map as _,catchError as T,mergeMap as qt,BehaviorSubject as zt,ReplaySubject as _n,lastValueFrom as Tn,filter as Ln,toArray as Rn}from"rxjs";import Nn from"@anthropic-ai/sdk";import{fromPromise as G}from"rxjs/internal/observable/innerFrom";import je from"os";import{xxh64 as kn}from"@pacote/xxhash";import jn from"axios";import{CohereClient as Gn,CohereTimeoutError as Hn}from"cohere-ai";import{GoogleGenerativeAI as Un}from"@google/generative-ai";import Kn from"groq-sdk";import{Ollama as qn}from"ollama";import O from"fs/promises";import zn from"http";import Yn from"https";import Wn from"net";import Jn from"tls";import Vn,{fileURLToPath as Xn,pathToFileURL as Qn}from"url";import Fe from"readline";import Zn from"figlet";import eo from"inquirer-reactive-list-prompt";import{rm as to}from"node:fs/promises";const ro="known-flag",no="unknown-flag",oo="argument",{stringify:ie}=JSON,so=/\B([A-Z])/g,uo=e=>e.replace(so,"-$1").toLowerCase(),{hasOwnProperty:io}=Object.prototype,ae=(e,t)=>io.call(e,t),ao=e=>Array.isArray(e),Yt=e=>typeof e=="function"?[e,!1]:ao(e)?[e[0],!0]:Yt(e.type),co=(e,t)=>e===Boolean?t!=="false":t,Do=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),lo=/[\s.:=]/,fo=e=>{const t=`Flag name ${ie(e)}`;if(e.length===0)throw new Error(`${t} cannot be empty`);if(e.length===1)throw new Error(`${t} must be longer than a character`);const r=e.match(lo);if(r)throw new Error(`${t} cannot contain ${ie(r?.[0])}`)},po=e=>{const t={},r=(n,o)=>{if(ae(t,n))throw new Error(`Duplicate flags named ${ie(n)}`);t[n]=o};for(const n in e){if(!ae(e,n))continue;fo(n);const o=e[n],s=[[],...Yt(o),o];r(n,s);const u=uo(n);if(n!==u&&r(u,s),"alias"in o&&typeof o.alias=="string"){const{alias:i}=o,c=`Flag alias ${ie(i)} for flag ${ie(n)}`;if(i.length===0)throw new Error(`${c} cannot be empty`);if(i.length>1)throw new Error(`${c} must be a single character`);r(i,s)}}return t},mo=(e,t)=>{const r={};for(const n in e){if(!ae(e,n))continue;const[o,,s,u]=t[n];if(o.length===0&&"default"in u){let{default:i}=u;typeof i=="function"&&(i=i()),r[n]=i}else r[n]=s?o:o.pop()}return r},ye="--",ho=/[.:=]/,go=/^-{1,2}\w/,Co=e=>{if(!go.test(e))return;const t=!e.startsWith(ye);let r=e.slice(t?1:2),n;const o=r.match(ho);if(o){const{index:s}=o;n=r.slice(s+1),r=r.slice(0,s)}return[r,n,t]},Eo=(e,{onFlag:t,onArgument:r})=>{let n;const o=(s,u)=>{if(typeof n!="function")return!0;n(s,u),n=void 0};for(let s=0;s<e.length;s+=1){const u=e[s];if(u===ye){o();const c=e.slice(s+1);r?.(c,[s],!0);break}const i=Co(u);if(i){if(o(),!t)continue;const[c,l,f]=i;if(f)for(let a=0;a<c.length;a+=1){o();const D=a===c.length-1;n=t(c[a],D?l:void 0,[s,a+1,D])}else n=t(c,l,[s])}else o(u,[s])&&r?.([u],[s])}o()},Fo=(e,t)=>{for(const[r,n,o]of t.reverse()){if(n){const s=e[r];let u=s.slice(0,n);if(o||(u+=s.slice(n+1)),u!=="-"){e[r]=u;continue}}e.splice(r,1)}},yo=(e,t=process.argv.slice(2),{ignore:r}={})=>{const n=[],o=po(e),s={},u=[];return u[ye]=[],Eo(t,{onFlag(i,c,l){const f=ae(o,i);if(!r?.(f?ro:no,i,c)){if(f){const[a,D]=o[i],p=co(D,c),d=(h,m)=>{n.push(l),m&&n.push(m),a.push(Do(D,h||""))};return p===void 0?d:d(p)}ae(s,i)||(s[i]=[]),s[i].push(c===void 0?!0:c),n.push(l)}},onArgument(i,c,l){r?.(oo,t[c[0]])||(u.push(...i),l?(u[ye]=i,t.splice(c[0])):n.push(c))}}),Fo(t,n),{flags:mo(e,o),unknownFlags:s,_:u}};var bo=Object.create,be=Object.defineProperty,Ao=Object.defineProperties,wo=Object.getOwnPropertyDescriptor,vo=Object.getOwnPropertyDescriptors,$o=Object.getOwnPropertyNames,Wt=Object.getOwnPropertySymbols,Bo=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty,Oo=Object.prototype.propertyIsEnumerable,Vt=(e,t,r)=>t in e?be(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ae=(e,t)=>{for(var r in t||(t={}))Jt.call(t,r)&&Vt(e,r,t[r]);if(Wt)for(var r of Wt(t))Oo.call(t,r)&&Vt(e,r,t[r]);return e},Ge=(e,t)=>Ao(e,vo(t)),xo=e=>be(e,"__esModule",{value:!0}),Mo=(e,t)=>()=>(e&&(t=e(e=0)),t),So=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Po=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $o(t))!Jt.call(e,o)&&(r||o!=="default")&&be(e,o,{get:()=>t[o],enumerable:!(n=wo(t,o))||n.enumerable});return e},Io=(e,t)=>Po(xo(be(e!=null?bo(Bo(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),B=Mo(()=>{}),_o=So((e,t)=>{B(),t.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}});B(),B(),B();var To=e=>{var t,r,n;let o=(t=process.stdout.columns)!=null?t:Number.POSITIVE_INFINITY;return typeof e=="function"&&(e=e(o)),e||(e={}),Array.isArray(e)?{columns:e,stdoutColumns:o}:{columns:(r=e.columns)!=null?r:[],stdoutColumns:(n=e.stdoutColumns)!=null?n:o}};B(),B(),B(),B(),B();function Lo({onlyFirst:e=!1}={}){let t=["[\\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(t,e?void 0:"g")}function Xt(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Lo(),"")}B();function Ro(e){return Number.isInteger(e)?e>=4352&&(e<=4447||e===9001||e===9002||11904<=e&&e<=12871&&e!==12351||12880<=e&&e<=19903||19968<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65131||65281<=e&&e<=65376||65504<=e&&e<=65510||110592<=e&&e<=110593||127488<=e&&e<=127569||131072<=e&&e<=262141):!1}var No=Io(_o(),1);function z(e){if(typeof e!="string"||e.length===0||(e=Xt(e),e.length===0))return 0;e=e.replace((0,No.default)()," ");let t=0;for(let r=0;r<e.length;r++){let n=e.codePointAt(r);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&r++,t+=Ro(n)?2:1)}return t}var Qt=e=>Math.max(...e.split(`
|
|
3
|
-
`).map(z)),ko=e=>{let t=[];for(let r of e){let{length:n}=r,o=n-t.length;for(let s=0;s<o;s+=1)t.push(0);for(let s=0;s<n;s+=1){let u=Qt(r[s]);u>t[s]&&(t[s]=u)}}return t};B();var Zt=/^\d+%$/,er={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},jo=(e,t)=>{var r;let n=[];for(let o=0;o<e.length;o+=1){let s=(r=t[o])!=null?r:"auto";if(typeof s=="number"||s==="auto"||s==="content-width"||typeof s=="string"&&Zt.test(s)){n.push(Ge(
|
|
4
|
-
`)];for(let[l,f]of c.entries()){if(n+=f,
|
|
2
|
+
import Le from"tty";import{createRequire as vn}from"module";import k from"fs";import P from"path";import{Buffer as $n}from"node:buffer";import J from"node:path";import kt,{ChildProcess as Bn}from"node:child_process";import I from"node:process";import On from"child_process";import{fileURLToPath as jt}from"node:url";import xn,{constants as Gt}from"node:os";import Ht from"assert";import Ut from"events";import{createWriteStream as Mn,createReadStream as Sn}from"node:fs";import Pn from"buffer";import Re from"stream";import Kt from"util";import{debuglog as In}from"node:util";import Ne from"inquirer";import ke from"ora";import g from"chalk";import{of as x,concatMap as j,from as S,map as _,catchError as T,mergeMap as qt,BehaviorSubject as zt,ReplaySubject as _n,lastValueFrom as Tn,filter as Ln,toArray as Rn}from"rxjs";import Nn from"@anthropic-ai/sdk";import{fromPromise as G}from"rxjs/internal/observable/innerFrom";import je from"os";import{xxh64 as kn}from"@pacote/xxhash";import jn from"axios";import{CohereClient as Gn,CohereTimeoutError as Hn}from"cohere-ai";import{GoogleGenerativeAI as Un}from"@google/generative-ai";import Kn from"groq-sdk";import{Ollama as qn}from"ollama";import O from"fs/promises";import zn from"http";import Yn from"https";import Wn from"net";import Jn from"tls";import Vn,{fileURLToPath as Xn,pathToFileURL as Qn}from"url";import Fe from"readline";import Zn from"figlet";import eo from"inquirer-reactive-list-prompt";import{rm as to}from"node:fs/promises";const ro="known-flag",no="unknown-flag",oo="argument",{stringify:ie}=JSON,so=/\B([A-Z])/g,uo=e=>e.replace(so,"-$1").toLowerCase(),{hasOwnProperty:io}=Object.prototype,ae=(e,t)=>io.call(e,t),ao=e=>Array.isArray(e),Yt=e=>typeof e=="function"?[e,!1]:ao(e)?[e[0],!0]:Yt(e.type),co=(e,t)=>e===Boolean?t!=="false":t,Do=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),lo=/[\s.:=]/,fo=e=>{const t=`Flag name ${ie(e)}`;if(e.length===0)throw new Error(`${t} cannot be empty`);if(e.length===1)throw new Error(`${t} must be longer than a character`);const r=e.match(lo);if(r)throw new Error(`${t} cannot contain ${ie(r?.[0])}`)},po=e=>{const t={},r=(n,o)=>{if(ae(t,n))throw new Error(`Duplicate flags named ${ie(n)}`);t[n]=o};for(const n in e){if(!ae(e,n))continue;fo(n);const o=e[n],s=[[],...Yt(o),o];r(n,s);const u=uo(n);if(n!==u&&r(u,s),"alias"in o&&typeof o.alias=="string"){const{alias:i}=o,c=`Flag alias ${ie(i)} for flag ${ie(n)}`;if(i.length===0)throw new Error(`${c} cannot be empty`);if(i.length>1)throw new Error(`${c} must be a single character`);r(i,s)}}return t},mo=(e,t)=>{const r={};for(const n in e){if(!ae(e,n))continue;const[o,,s,u]=t[n];if(o.length===0&&"default"in u){let{default:i}=u;typeof i=="function"&&(i=i()),r[n]=i}else r[n]=s?o:o.pop()}return r},ye="--",ho=/[.:=]/,go=/^-{1,2}\w/,Co=e=>{if(!go.test(e))return;const t=!e.startsWith(ye);let r=e.slice(t?1:2),n;const o=r.match(ho);if(o){const{index:s}=o;n=r.slice(s+1),r=r.slice(0,s)}return[r,n,t]},Eo=(e,{onFlag:t,onArgument:r})=>{let n;const o=(s,u)=>{if(typeof n!="function")return!0;n(s,u),n=void 0};for(let s=0;s<e.length;s+=1){const u=e[s];if(u===ye){o();const c=e.slice(s+1);r?.(c,[s],!0);break}const i=Co(u);if(i){if(o(),!t)continue;const[c,l,f]=i;if(f)for(let a=0;a<c.length;a+=1){o();const D=a===c.length-1;n=t(c[a],D?l:void 0,[s,a+1,D])}else n=t(c,l,[s])}else o(u,[s])&&r?.([u],[s])}o()},Fo=(e,t)=>{for(const[r,n,o]of t.reverse()){if(n){const s=e[r];let u=s.slice(0,n);if(o||(u+=s.slice(n+1)),u!=="-"){e[r]=u;continue}}e.splice(r,1)}},yo=(e,t=process.argv.slice(2),{ignore:r}={})=>{const n=[],o=po(e),s={},u=[];return u[ye]=[],Eo(t,{onFlag(i,c,l){const f=ae(o,i);if(!r?.(f?ro:no,i,c)){if(f){const[a,D]=o[i],p=co(D,c),d=(h,m)=>{n.push(l),m&&n.push(m),a.push(Do(D,h||""))};return p===void 0?d:d(p)}ae(s,i)||(s[i]=[]),s[i].push(c===void 0?!0:c),n.push(l)}},onArgument(i,c,l){r?.(oo,t[c[0]])||(u.push(...i),l?(u[ye]=i,t.splice(c[0])):n.push(c))}}),Fo(t,n),{flags:mo(e,o),unknownFlags:s,_:u}};var bo=Object.create,be=Object.defineProperty,wo=Object.defineProperties,Ao=Object.getOwnPropertyDescriptor,vo=Object.getOwnPropertyDescriptors,$o=Object.getOwnPropertyNames,Wt=Object.getOwnPropertySymbols,Bo=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty,Oo=Object.prototype.propertyIsEnumerable,Vt=(e,t,r)=>t in e?be(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,we=(e,t)=>{for(var r in t||(t={}))Jt.call(t,r)&&Vt(e,r,t[r]);if(Wt)for(var r of Wt(t))Oo.call(t,r)&&Vt(e,r,t[r]);return e},Ge=(e,t)=>wo(e,vo(t)),xo=e=>be(e,"__esModule",{value:!0}),Mo=(e,t)=>()=>(e&&(t=e(e=0)),t),So=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Po=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $o(t))!Jt.call(e,o)&&(r||o!=="default")&&be(e,o,{get:()=>t[o],enumerable:!(n=Ao(t,o))||n.enumerable});return e},Io=(e,t)=>Po(xo(be(e!=null?bo(Bo(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),B=Mo(()=>{}),_o=So((e,t)=>{B(),t.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}});B(),B(),B();var To=e=>{var t,r,n;let o=(t=process.stdout.columns)!=null?t:Number.POSITIVE_INFINITY;return typeof e=="function"&&(e=e(o)),e||(e={}),Array.isArray(e)?{columns:e,stdoutColumns:o}:{columns:(r=e.columns)!=null?r:[],stdoutColumns:(n=e.stdoutColumns)!=null?n:o}};B(),B(),B(),B(),B();function Lo({onlyFirst:e=!1}={}){let t=["[\\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(t,e?void 0:"g")}function Xt(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Lo(),"")}B();function Ro(e){return Number.isInteger(e)?e>=4352&&(e<=4447||e===9001||e===9002||11904<=e&&e<=12871&&e!==12351||12880<=e&&e<=19903||19968<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65131||65281<=e&&e<=65376||65504<=e&&e<=65510||110592<=e&&e<=110593||127488<=e&&e<=127569||131072<=e&&e<=262141):!1}var No=Io(_o(),1);function z(e){if(typeof e!="string"||e.length===0||(e=Xt(e),e.length===0))return 0;e=e.replace((0,No.default)()," ");let t=0;for(let r=0;r<e.length;r++){let n=e.codePointAt(r);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&r++,t+=Ro(n)?2:1)}return t}var Qt=e=>Math.max(...e.split(`
|
|
3
|
+
`).map(z)),ko=e=>{let t=[];for(let r of e){let{length:n}=r,o=n-t.length;for(let s=0;s<o;s+=1)t.push(0);for(let s=0;s<n;s+=1){let u=Qt(r[s]);u>t[s]&&(t[s]=u)}}return t};B();var Zt=/^\d+%$/,er={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},jo=(e,t)=>{var r;let n=[];for(let o=0;o<e.length;o+=1){let s=(r=t[o])!=null?r:"auto";if(typeof s=="number"||s==="auto"||s==="content-width"||typeof s=="string"&&Zt.test(s)){n.push(Ge(we({},er),{width:s,contentWidth:e[o]}));continue}if(s&&typeof s=="object"){let u=Ge(we(we({},er),s),{contentWidth:e[o]});u.horizontalPadding=u.paddingLeft+u.paddingRight,n.push(u);continue}throw new Error(`Invalid column width: ${JSON.stringify(s)}`)}return n};function Go(e,t){for(let r of e){let{width:n}=r;if(n==="content-width"&&(r.width=r.contentWidth),n==="auto"){let c=Math.min(20,r.contentWidth);r.width=c,r.autoOverflow=r.contentWidth-c}if(typeof n=="string"&&Zt.test(n)){let c=Number.parseFloat(n.slice(0,-1))/100;r.width=Math.floor(t*c)-(r.paddingLeft+r.paddingRight)}let{horizontalPadding:o}=r,s=1,u=s+o;if(u>=t){let c=u-t,l=Math.ceil(r.paddingLeft/o*c),f=c-l;r.paddingLeft-=l,r.paddingRight-=f,r.horizontalPadding=r.paddingLeft+r.paddingRight}r.paddingLeftString=r.paddingLeft?" ".repeat(r.paddingLeft):"",r.paddingRightString=r.paddingRight?" ".repeat(r.paddingRight):"";let i=t-r.horizontalPadding;r.width=Math.max(Math.min(r.width,i),s)}}var tr=()=>Object.assign([],{columns:0});function Ho(e,t){let r=[tr()],[n]=r;for(let o of e){let s=o.width+o.horizontalPadding;n.columns+s>t&&(n=tr(),r.push(n)),n.push(o),n.columns+=s}for(let o of r){let s=o.reduce((D,p)=>D+p.width+p.horizontalPadding,0),u=t-s;if(u===0)continue;let i=o.filter(D=>"autoOverflow"in D),c=i.filter(D=>D.autoOverflow>0),l=c.reduce((D,p)=>D+p.autoOverflow,0),f=Math.min(l,u);for(let D of c){let p=Math.floor(D.autoOverflow/l*f);D.width+=p,u-=p}let a=Math.floor(u/i.length);for(let D=0;D<i.length;D+=1){let p=i[D];D===i.length-1?p.width+=u:p.width+=a,u-=a}}return r}function Uo(e,t,r){let n=jo(r,t);return Go(n,e),Ho(n,e)}B(),B(),B();var He=10,rr=(e=0)=>t=>`\x1B[${t+e}m`,nr=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,or=(e=0)=>(t,r,n)=>`\x1B[${38+e};2;${t};${r};${n}m`;function Ko(){let e=new Map,t={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]}};t.color.gray=t.color.blackBright,t.bgColor.bgGray=t.bgColor.bgBlackBright,t.color.grey=t.color.blackBright,t.bgColor.bgGrey=t.bgColor.bgBlackBright;for(let[r,n]of Object.entries(t)){for(let[o,s]of Object.entries(n))t[o]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[o]=t[o],e.set(s[0],s[1]);Object.defineProperty(t,r,{value:n,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",t.color.ansi=rr(),t.color.ansi256=nr(),t.color.ansi16m=or(),t.bgColor.ansi=rr(He),t.bgColor.ansi256=nr(He),t.bgColor.ansi16m=or(He),Object.defineProperties(t,{rgbToAnsi256:{value:(r,n,o)=>r===n&&n===o?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(n/255*5)+Math.round(o/255*5),enumerable:!1},hexToRgb:{value:r=>{let n=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(r.toString(16));if(!n)return[0,0,0];let{colorString:o}=n.groups;o.length===3&&(o=o.split("").map(u=>u+u).join(""));let s=Number.parseInt(o,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:r=>t.rgbToAnsi256(...t.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value:r=>{if(r<8)return 30+r;if(r<16)return 90+(r-8);let n,o,s;if(r>=232)n=((r-232)*10+8)/255,o=n,s=n;else{r-=16;let c=r%36;n=Math.floor(r/36)/5,o=Math.floor(c/6)/5,s=c%6/5}let u=Math.max(n,o,s)*2;if(u===0)return 30;let i=30+(Math.round(s)<<2|Math.round(o)<<1|Math.round(n));return u===2&&(i+=60),i},enumerable:!1},rgbToAnsi:{value:(r,n,o)=>t.ansi256ToAnsi(t.rgbToAnsi256(r,n,o)),enumerable:!1},hexToAnsi:{value:r=>t.ansi256ToAnsi(t.hexToAnsi256(r)),enumerable:!1}}),t}var qo=Ko(),zo=qo,Ae=new Set(["\x1B","\x9B"]),Yo=39,Ue="\x07",sr="[",Wo="]",ur="m",Ke=`${Wo}8;;`,ir=e=>`${Ae.values().next().value}${sr}${e}${ur}`,ar=e=>`${Ae.values().next().value}${Ke}${e}${Ue}`,Jo=e=>e.split(" ").map(t=>z(t)),qe=(e,t,r)=>{let n=[...t],o=!1,s=!1,u=z(Xt(e[e.length-1]));for(let[i,c]of n.entries()){let l=z(c);if(u+l<=r?e[e.length-1]+=c:(e.push(c),u=0),Ae.has(c)&&(o=!0,s=n.slice(i+1).join("").startsWith(Ke)),o){s?c===Ue&&(o=!1,s=!1):c===ur&&(o=!1);continue}u+=l,u===r&&i<n.length-1&&(e.push(""),u=0)}!u&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Vo=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(z(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},Xo=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",o,s,u=Jo(e),i=[""];for(let[l,f]of e.split(" ").entries()){r.trim!==!1&&(i[i.length-1]=i[i.length-1].trimStart());let a=z(i[i.length-1]);if(l!==0&&(a>=t&&(r.wordWrap===!1||r.trim===!1)&&(i.push(""),a=0),(a>0||r.trim===!1)&&(i[i.length-1]+=" ",a++)),r.hard&&u[l]>t){let D=t-a,p=1+Math.floor((u[l]-D-1)/t);Math.floor((u[l]-1)/t)<p&&i.push(""),qe(i,f,t);continue}if(a+u[l]>t&&a>0&&u[l]>0){if(r.wordWrap===!1&&a<t){qe(i,f,t);continue}i.push("")}if(a+u[l]>t&&r.wordWrap===!1){qe(i,f,t);continue}i[i.length-1]+=f}r.trim!==!1&&(i=i.map(l=>Vo(l)));let c=[...i.join(`
|
|
4
|
+
`)];for(let[l,f]of c.entries()){if(n+=f,Ae.has(f)){let{groups:D}=new RegExp(`(?:\\${sr}(?<code>\\d+)m|\\${Ke}(?<uri>.*)${Ue})`).exec(c.slice(l).join(""))||{groups:{}};if(D.code!==void 0){let p=Number.parseFloat(D.code);o=p===Yo?void 0:p}else D.uri!==void 0&&(s=D.uri.length===0?void 0:D.uri)}let a=zo.codes.get(Number(o));c[l+1]===`
|
|
5
5
|
`?(s&&(n+=ar("")),o&&a&&(n+=ir(a))):f===`
|
|
6
6
|
`&&(o&&a&&(n+=ir(o)),s&&(n+=ar(s)))}return n};function Qo(e,t,r){return String(e).normalize().replace(/\r\n/g,`
|
|
7
7
|
`).split(`
|
|
8
8
|
`).map(n=>Xo(n,t,r)).join(`
|
|
9
9
|
`)}var cr=e=>Array.from({length:e}).fill("");function Zo(e,t){let r=[],n=0;for(let o of e){let s=0,u=o.map(c=>{var l;let f=(l=t[n])!=null?l:"";n+=1,c.preprocess&&(f=c.preprocess(f)),Qt(f)>c.width&&(f=Qo(f,c.width,{hard:!0}));let a=f.split(`
|
|
10
|
-
`);if(c.postprocess){let{postprocess:D}=c;a=a.map((p,d)=>D.call(c,p,d))}return c.paddingTop&&a.unshift(...cr(c.paddingTop)),c.paddingBottom&&a.push(...cr(c.paddingBottom)),a.length>s&&(s=a.length),Ge(
|
|
10
|
+
`);if(c.postprocess){let{postprocess:D}=c;a=a.map((p,d)=>D.call(c,p,d))}return c.paddingTop&&a.unshift(...cr(c.paddingTop)),c.paddingBottom&&a.push(...cr(c.paddingBottom)),a.length>s&&(s=a.length),Ge(we({},c),{lines:a})}),i=[];for(let c=0;c<s;c+=1){let l=u.map(f=>{var a;let D=(a=f.lines[c])!=null?a:"",p=Number.isFinite(f.width)?" ".repeat(f.width-z(D)):"",d=f.paddingLeftString;return f.align==="right"&&(d+=p),d+=D,f.align==="left"&&(d+=p),d+f.paddingRightString}).join("");i.push(l)}r.push(i.join(`
|
|
11
11
|
`))}return r.join(`
|
|
12
12
|
`)}function es(e,t){if(!e||e.length===0)return"";let r=ko(e),n=r.length;if(n===0)return"";let{stdoutColumns:o,columns:s}=To(t);if(s.length>n)throw new Error(`${s.length} columns defined, but only ${n} columns found`);let u=Uo(o,s,r);return e.map(i=>Zo(u,i)).join(`
|
|
13
13
|
`)}B();var ts=["<",">","=",">=","<="];function rs(e){if(!ts.includes(e))throw new TypeError(`Invalid breakpoint operator: ${e}`)}function ns(e){let t=Object.keys(e).map(r=>{let[n,o]=r.split(" ");rs(n);let s=Number.parseInt(o,10);if(Number.isNaN(s))throw new TypeError(`Invalid breakpoint value: ${o}`);let u=e[r];return{operator:n,breakpoint:s,value:u}}).sort((r,n)=>n.breakpoint-r.breakpoint);return r=>{var n;return(n=t.find(({operator:o,breakpoint:s})=>o==="="&&r===s||o===">"&&r>s||o==="<"&&r<s||o===">="&&r>=s||o==="<="&&r<=s))==null?void 0:n.value}}const os=e=>e.replace(/[\W_]([a-z\d])?/gi,(t,r)=>r?r.toUpperCase():""),ss=e=>e.replace(/\B([A-Z])/g,"-$1").toLowerCase(),us={"> 80":[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"auto"}],"> 40":[{width:"auto",paddingLeft:2,paddingRight:8,preprocess:e=>e.trim()},{width:"100%",paddingLeft:2,paddingBottom:1}],"> 0":{stdoutColumns:1e3,columns:[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"content-width"}]}};function is(e){let t=!1;return{type:"table",data:{tableData:Object.keys(e).sort((r,n)=>r.localeCompare(n)).map(r=>{const n=e[r],o="alias"in n;return o&&(t=!0),{name:r,flag:n,flagFormatted:`--${ss(r)}`,aliasesEnabled:t,aliasFormatted:o?`-${n.alias}`:void 0}}).map(r=>(r.aliasesEnabled=t,[{type:"flagName",data:r},{type:"flagDescription",data:r}])),tableBreakpoints:us}}}const Dr=e=>!e||(e.version??(e.help?e.help.version:void 0)),lr=e=>{const t="parent"in e&&e.parent?.name;return(t?`${t} `:"")+e.name};function as(e){const t=[];e.name&&t.push(lr(e));const r=Dr(e)??("parent"in e&&Dr(e.parent));if(r&&t.push(`v${r}`),t.length!==0)return{id:"name",type:"text",data:`${t.join(" ")}
|
|
@@ -19,13 +19,13 @@ import Le from"tty";import{createRequire as vn}from"module";import k from"fs";im
|
|
|
19
19
|
`:"")+(r?this.indentText({text:this.render(r),spaces:n}):"")}
|
|
20
20
|
`}table({tableData:t,tableOptions:r,tableBreakpoints:n}){return es(t.map(o=>o.map(s=>this.render(s))),n?ns(n):r)}flagParameter(t){return t===Boolean?"":t===String?"<string>":t===Number?"<number>":Array.isArray(t)?this.flagParameter(t[0]):"<value>"}flagOperator(t){return" "}flagName(t){const{flag:r,flagFormatted:n,aliasesEnabled:o,aliasFormatted:s}=t;let u="";if(s?u+=`${s}, `:o&&(u+=" "),u+=n,"placeholder"in r&&typeof r.placeholder=="string")u+=`${this.flagOperator(t)}${r.placeholder}`;else{const i=this.flagParameter("type"in r?r.type:r);i&&(u+=`${this.flagOperator(t)}${i}`)}return u}flagDefault(t){return JSON.stringify(t)}flagDescription({flag:t}){let r="description"in t?t.description??"":"";if("default"in t){let{default:n}=t;typeof n=="function"&&(n=n()),n&&(r+=` (default: ${this.flagDefault(n)})`)}return r}render(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(r=>this.render(r)).join(`
|
|
21
21
|
`);if("type"in t&&this[t.type]){const r=this[t.type];if(typeof r=="function")return r.call(this,t.data)}throw new Error(`Invalid node type: ${JSON.stringify(t)}`)}}const ze=/^[\w.-]+$/,{stringify:L}=JSON,Cs=/[|\\{}()[\]^$+*?.]/;function Ye(e){const t=[];let r,n;for(const o of e){if(n)throw new Error(`Invalid parameter: Spread parameter ${L(n)} must be last`);const s=o[0],u=o[o.length-1];let i;if(s==="<"&&u===">"&&(i=!0,r))throw new Error(`Invalid parameter: Required parameter ${L(o)} cannot come after optional parameter ${L(r)}`);if(s==="["&&u==="]"&&(i=!1,r=o),i===void 0)throw new Error(`Invalid parameter: ${L(o)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let c=o.slice(1,-1);const l=c.slice(-3)==="...";l&&(n=o,c=c.slice(0,-3));const f=c.match(Cs);if(f)throw new Error(`Invalid parameter: ${L(o)}. Invalid character found ${L(f[0])}`);t.push({name:c,required:i,spread:l})}return t}function We(e,t,r,n){for(let o=0;o<t.length;o+=1){const{name:s,required:u,spread:i}=t[o],c=os(s);if(c in e)throw new Error(`Invalid parameter: ${L(s)} is used more than once.`);const l=i?r.slice(o):r[o];if(i&&(o=t.length),u&&(!l||i&&l.length===0))return console.error(`Error: Missing required parameter ${L(s)}
|
|
22
|
-
`),n(),process.exit(1);e[c]=l}}function Es(e){return e===void 0||e!==!1}function fr(e,t,r,n){const o={...t.flags},s=t.version;s&&(o.version={type:Boolean,description:"Show version"});const{help:u}=t,i=Es(u);i&&!("help"in o)&&(o.help={type:Boolean,alias:"h",description:"Show help"});const c=yo(o,n,{ignore:t.ignoreArgv}),l=()=>{console.log(t.version)};if(s&&c.flags.version===!0)return l(),process.exit(0);const f=new gs,a=i&&u?.render?u.render:d=>f.render(d),D=d=>{const h=ms({...t,...d?{help:d}:{},flags:o});console.log(a(h,f))};if(i&&c.flags.help===!0)return D(),process.exit(0);if(t.parameters){let{parameters:d}=t,h=c._;const m=d.indexOf("--"),E=d.slice(m+1),b=Object.create(null);if(m>-1&&E.length>0){d=d.slice(0,m);const
|
|
22
|
+
`),n(),process.exit(1);e[c]=l}}function Es(e){return e===void 0||e!==!1}function fr(e,t,r,n){const o={...t.flags},s=t.version;s&&(o.version={type:Boolean,description:"Show version"});const{help:u}=t,i=Es(u);i&&!("help"in o)&&(o.help={type:Boolean,alias:"h",description:"Show help"});const c=yo(o,n,{ignore:t.ignoreArgv}),l=()=>{console.log(t.version)};if(s&&c.flags.version===!0)return l(),process.exit(0);const f=new gs,a=i&&u?.render?u.render:d=>f.render(d),D=d=>{const h=ms({...t,...d?{help:d}:{},flags:o});console.log(a(h,f))};if(i&&c.flags.help===!0)return D(),process.exit(0);if(t.parameters){let{parameters:d}=t,h=c._;const m=d.indexOf("--"),E=d.slice(m+1),b=Object.create(null);if(m>-1&&E.length>0){d=d.slice(0,m);const A=c._["--"];h=h.slice(0,-A.length||void 0),We(b,Ye(d),h,D),We(b,Ye(E),A,D)}else We(b,Ye(d),h,D);Object.assign(c._,b)}const p={...c,showVersion:l,showHelp:D};return typeof r=="function"&&r(p),{command:e,...p}}function Fs(e,t){const r=new Map;for(const n of t){const o=[n.options.name],{alias:s}=n.options;s&&(Array.isArray(s)?o.push(...s):o.push(s));for(const u of o){if(r.has(u))throw new Error(`Duplicate command name found: ${L(u)}`);r.set(u,n)}}return r.get(e)}function ys(e,t,r=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!ze.test(e.name)))throw new Error(`Invalid script name: ${L(e.name)}`);const n=r[0];if(e.commands&&ze.test(n)){const o=Fs(n,e.commands);if(o)return fr(o.options.name,{...o.options,parent:e},o.callback,r.slice(1))}return fr(void 0,e,t,r)}function Je(e,t){if(!e)throw new Error("Command options are required");const{name:r}=e;if(e.name===void 0)throw new Error("Command name is required");if(!ze.test(r))throw new Error(`Invalid command name ${JSON.stringify(r)}. Command names must be one word.`);return{options:e,callback:t}}var bs=vn(import.meta.url),v=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function V(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var X={exports:{}},Ve,pr;function ws(){if(pr)return Ve;pr=1,Ve=n,n.sync=o;var e=k;function t(s,u){var i=u.pathExt!==void 0?u.pathExt:process.env.PATHEXT;if(!i||(i=i.split(";"),i.indexOf("")!==-1))return!0;for(var c=0;c<i.length;c++){var l=i[c].toLowerCase();if(l&&s.substr(-l.length).toLowerCase()===l)return!0}return!1}function r(s,u,i){return!s.isSymbolicLink()&&!s.isFile()?!1:t(u,i)}function n(s,u,i){e.stat(s,function(c,l){i(c,c?!1:r(l,s,u))})}function o(s,u){return r(e.statSync(s),s,u)}return Ve}var Xe,dr;function As(){if(dr)return Xe;dr=1,Xe=t,t.sync=r;var e=k;function t(s,u,i){e.stat(s,function(c,l){i(c,c?!1:n(l,u))})}function r(s,u){return n(e.statSync(s),u)}function n(s,u){return s.isFile()&&o(s,u)}function o(s,u){var i=s.mode,c=s.uid,l=s.gid,f=u.uid!==void 0?u.uid:process.getuid&&process.getuid(),a=u.gid!==void 0?u.gid:process.getgid&&process.getgid(),D=parseInt("100",8),p=parseInt("010",8),d=parseInt("001",8),h=D|p,m=i&d||i&p&&l===a||i&D&&c===f||i&h&&f===0;return m}return Xe}var ve;process.platform==="win32"||v.TESTING_WINDOWS?ve=ws():ve=As();var vs=Qe;Qe.sync=$s;function Qe(e,t,r){if(typeof t=="function"&&(r=t,t={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,o){Qe(e,t||{},function(s,u){s?o(s):n(u)})})}ve(e,t||{},function(n,o){n&&(n.code==="EACCES"||t&&t.ignoreErrors)&&(n=null,o=!1),r(n,o)})}function $s(e,t){try{return ve.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}const Q=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",mr=P,Bs=Q?";":":",hr=vs,gr=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),Cr=(e,t)=>{const r=t.colon||Bs,n=e.match(/\//)||Q&&e.match(/\\/)?[""]:[...Q?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],o=Q?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=Q?o.split(r):[""];return Q&&e.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:n,pathExt:s,pathExtExe:o}},Er=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});const{pathEnv:n,pathExt:o,pathExtExe:s}=Cr(e,t),u=[],i=l=>new Promise((f,a)=>{if(l===n.length)return t.all&&u.length?f(u):a(gr(e));const D=n[l],p=/^".*"$/.test(D)?D.slice(1,-1):D,d=mr.join(p,e),h=!p&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;f(c(h,l,0))}),c=(l,f,a)=>new Promise((D,p)=>{if(a===o.length)return D(i(f+1));const d=o[a];hr(l+d,{pathExt:s},(h,m)=>{if(!h&&m)if(t.all)u.push(l+d);else return D(l+d);return D(c(l,f,a+1))})});return r?i(0).then(l=>r(null,l),r):i(0)},Os=(e,t)=>{t=t||{};const{pathEnv:r,pathExt:n,pathExtExe:o}=Cr(e,t),s=[];for(let u=0;u<r.length;u++){const i=r[u],c=/^".*"$/.test(i)?i.slice(1,-1):i,l=mr.join(c,e),f=!c&&/^\.[\\\/]/.test(e)?e.slice(0,2)+l:l;for(let a=0;a<n.length;a++){const D=f+n[a];try{if(hr.sync(D,{pathExt:o}))if(t.all)s.push(D);else return D}catch{}}}if(t.all&&s.length)return s;if(t.nothrow)return null;throw gr(e)};var xs=Er;Er.sync=Os;var Ze={exports:{}};const Fr=(e={})=>{const t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};Ze.exports=Fr,Ze.exports.default=Fr;var Ms=Ze.exports;const yr=P,Ss=xs,Ps=Ms;function br(e,t){const r=e.options.env||process.env,n=process.cwd(),o=e.options.cwd!=null,s=o&&process.chdir!==void 0&&!process.chdir.disabled;if(s)try{process.chdir(e.options.cwd)}catch{}let u;try{u=Ss.sync(e.command,{path:r[Ps({env:r})],pathExt:t?yr.delimiter:void 0})}catch{}finally{s&&process.chdir(n)}return u&&(u=yr.resolve(o?e.options.cwd:"",u)),u}function Is(e){return br(e)||br(e,!0)}var _s=Is,et={};const tt=/([()\][%!^"`<>&|;, *?])/g;function Ts(e){return e=e.replace(tt,"^$1"),e}function Ls(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(tt,"^$1"),t&&(e=e.replace(tt,"^$1")),e}et.command=Ts,et.argument=Ls;var Rs=/^#!(.*)/;const Ns=Rs;var ks=(e="")=>{const t=e.match(Ns);if(!t)return null;const[r,n]=t[0].replace(/#! ?/,"").split(" "),o=r.split("/").pop();return o==="env"?n:n?`${o} ${n}`:o};const rt=k,js=ks;function Gs(e){const r=Buffer.alloc(150);let n;try{n=rt.openSync(e,"r"),rt.readSync(n,r,0,150,0),rt.closeSync(n)}catch{}return js(r.toString())}var Hs=Gs;const Us=P,wr=_s,Ar=et,Ks=Hs,qs=process.platform==="win32",zs=/\.(?:com|exe)$/i,Ys=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Ws(e){e.file=wr(e);const t=e.file&&Ks(e.file);return t?(e.args.unshift(e.file),e.command=t,wr(e)):e.file}function Js(e){if(!qs)return e;const t=Ws(e),r=!zs.test(t);if(e.options.forceShell||r){const n=Ys.test(t);e.command=Us.normalize(e.command),e.command=Ar.command(e.command),e.args=e.args.map(s=>Ar.argument(s,n));const o=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${o}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function Vs(e,t,r){t&&!Array.isArray(t)&&(r=t,t=null),t=t?t.slice(0):[],r=Object.assign({},r);const n={command:e,args:t,options:r,file:void 0,original:{command:e,args:t}};return r.shell?n:Js(n)}var Xs=Vs;const nt=process.platform==="win32";function ot(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function Qs(e,t){if(!nt)return;const r=e.emit;e.emit=function(n,o){if(n==="exit"){const s=vr(o,t);if(s)return r.call(e,"error",s)}return r.apply(e,arguments)}}function vr(e,t){return nt&&e===1&&!t.file?ot(t.original,"spawn"):null}function Zs(e,t){return nt&&e===1&&!t.file?ot(t.original,"spawnSync"):null}var eu={hookChildProcess:Qs,verifyENOENT:vr,verifyENOENTSync:Zs,notFoundError:ot};const $r=On,st=Xs,ut=eu;function Br(e,t,r){const n=st(e,t,r),o=$r.spawn(n.command,n.args,n.options);return ut.hookChildProcess(o,n),o}function tu(e,t,r){const n=st(e,t,r),o=$r.spawnSync(n.command,n.args,n.options);return o.error=o.error||ut.verifyENOENTSync(o.status,n),o}X.exports=Br,X.exports.spawn=Br,X.exports.sync=tu,X.exports._parse=st,X.exports._enoent=ut;var ru=X.exports,nu=V(ru);function ou(e){const t=typeof e=="string"?`
|
|
23
23
|
`:`
|
|
24
24
|
`.charCodeAt(),r=typeof e=="string"?"\r":"\r".charCodeAt();return e[e.length-1]===t&&(e=e.slice(0,-1)),e[e.length-1]===r&&(e=e.slice(0,-1)),e}function Or(e={}){const{env:t=process.env,platform:r=process.platform}=e;return r!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"}const su=({cwd:e=I.cwd(),path:t=I.env[Or()],preferLocal:r=!0,execPath:n=I.execPath,addExecPath:o=!0}={})=>{const s=e instanceof URL?jt(e):e,u=J.resolve(s),i=[];return r&&uu(i,u),o&&iu(i,n,u),[...i,t].join(J.delimiter)},uu=(e,t)=>{let r;for(;r!==t;)e.push(J.join(t,"node_modules/.bin")),r=t,t=J.resolve(t,"..")},iu=(e,t,r)=>{const n=t instanceof URL?jt(t):t;e.push(J.resolve(r,n,".."))},au=({env:e=I.env,...t}={})=>{e={...e};const r=Or({env:e});return t.path=e[r],e[r]=su(t),e},cu=(e,t,r,n)=>{if(r==="length"||r==="prototype"||r==="arguments"||r==="caller")return;const o=Object.getOwnPropertyDescriptor(e,r),s=Object.getOwnPropertyDescriptor(t,r);!Du(o,s)&&n||Object.defineProperty(e,r,s)},Du=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},lu=(e,t)=>{const r=Object.getPrototypeOf(t);r!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,r)},fu=(e,t)=>`/* Wrapped ${e}*/
|
|
25
|
-
${t}`,pu=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),du=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),mu=(e,t,r)=>{const n=r===""?"":`with ${r.trim()}() `,o=fu.bind(null,n,t.toString());Object.defineProperty(o,"name",du),Object.defineProperty(e,"toString",{...pu,value:o})};function hu(e,t,{ignoreNonConfigurable:r=!1}={}){const{name:n}=e;for(const o of Reflect.ownKeys(t))cu(e,t,o,r);return lu(e,t),mu(e,t,n),e}const $e=new WeakMap,xr=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let r,n=0;const o=e.displayName||e.name||"<anonymous>",s=function(...u){if($e.set(s,++n),n===1)r=e.apply(this,u),e=null;else if(t.throw===!0)throw new Error(`Function \`${o}\` can only be called once`);return r};return hu(s,e),$e.set(s,n),s};xr.callCount=e=>{if(!$e.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return $e.get(e)};const gu=()=>{const e=Sr-Mr+1;return Array.from({length:e},Cu)},Cu=(e,t)=>({name:`SIGRT${t+1}`,number:Mr+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),Mr=34,Sr=64,Eu=[{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"}],Pr=()=>{const e=gu();return[...Eu,...e].map(Fu)},Fu=({name:e,number:t,description:r,action:n,forced:o=!1,standard:s})=>{const{signals:{[e]:u}}=Gt,i=u!==void 0;return{name:e,number:i?u:t,description:r,supported:i,action:n,forced:o,standard:s}},yu=()=>{const e=Pr();return Object.fromEntries(e.map(bu))},bu=({name:e,number:t,description:r,supported:n,action:o,forced:s,standard:u})=>[e,{name:e,number:t,description:r,supported:n,action:o,forced:s,standard:u}],
|
|
26
|
-
${n.message}`:m,
|
|
27
|
-
`);return E?(n.originalMessage=n.message,n.message=
|
|
28
|
-
`)},
|
|
25
|
+
${t}`,pu=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),du=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),mu=(e,t,r)=>{const n=r===""?"":`with ${r.trim()}() `,o=fu.bind(null,n,t.toString());Object.defineProperty(o,"name",du),Object.defineProperty(e,"toString",{...pu,value:o})};function hu(e,t,{ignoreNonConfigurable:r=!1}={}){const{name:n}=e;for(const o of Reflect.ownKeys(t))cu(e,t,o,r);return lu(e,t),mu(e,t,n),e}const $e=new WeakMap,xr=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let r,n=0;const o=e.displayName||e.name||"<anonymous>",s=function(...u){if($e.set(s,++n),n===1)r=e.apply(this,u),e=null;else if(t.throw===!0)throw new Error(`Function \`${o}\` can only be called once`);return r};return hu(s,e),$e.set(s,n),s};xr.callCount=e=>{if(!$e.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return $e.get(e)};const gu=()=>{const e=Sr-Mr+1;return Array.from({length:e},Cu)},Cu=(e,t)=>({name:`SIGRT${t+1}`,number:Mr+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),Mr=34,Sr=64,Eu=[{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"}],Pr=()=>{const e=gu();return[...Eu,...e].map(Fu)},Fu=({name:e,number:t,description:r,action:n,forced:o=!1,standard:s})=>{const{signals:{[e]:u}}=Gt,i=u!==void 0;return{name:e,number:i?u:t,description:r,supported:i,action:n,forced:o,standard:s}},yu=()=>{const e=Pr();return Object.fromEntries(e.map(bu))},bu=({name:e,number:t,description:r,supported:n,action:o,forced:s,standard:u})=>[e,{name:e,number:t,description:r,supported:n,action:o,forced:s,standard:u}],wu=yu(),Au=()=>{const e=Pr(),t=Sr+1,r=Array.from({length:t},(n,o)=>vu(o,e));return Object.assign({},...r)},vu=(e,t)=>{const r=$u(e,t);if(r===void 0)return{};const{name:n,description:o,supported:s,action:u,forced:i,standard:c}=r;return{[e]:{name:n,number:e,description:o,supported:s,action:u,forced:i,standard:c}}},$u=(e,t)=>{const r=t.find(({name:n})=>Gt.signals[n]===e);return r!==void 0?r:t.find(n=>n.number===e)};Au();const Bu=({timedOut:e,timeout:t,errorCode:r,signal:n,signalDescription:o,exitCode:s,isCanceled:u})=>e?`timed out after ${t} milliseconds`:u?"was canceled":r!==void 0?`failed with ${r}`:n!==void 0?`was killed with ${n} (${o})`:s!==void 0?`failed with exit code ${s}`:"failed",Ir=({stdout:e,stderr:t,all:r,error:n,signal:o,exitCode:s,command:u,escapedCommand:i,timedOut:c,isCanceled:l,killed:f,parsed:{options:{timeout:a,cwd:D=I.cwd()}}})=>{s=s===null?void 0:s,o=o===null?void 0:o;const p=o===void 0?void 0:wu[o].description,d=n&&n.code,m=`Command ${Bu({timedOut:c,timeout:a,errorCode:d,signal:o,signalDescription:p,exitCode:s,isCanceled:l})}: ${u}`,E=Object.prototype.toString.call(n)==="[object Error]",b=E?`${m}
|
|
26
|
+
${n.message}`:m,A=[b,t,e].filter(Boolean).join(`
|
|
27
|
+
`);return E?(n.originalMessage=n.message,n.message=A):n=new Error(A),n.shortMessage=b,n.command=u,n.escapedCommand=i,n.exitCode=s,n.signal=o,n.signalDescription=p,n.stdout=e,n.stderr=t,n.cwd=D,r!==void 0&&(n.all=r),"bufferedData"in n&&delete n.bufferedData,n.failed=!0,n.timedOut=!!c,n.isCanceled=l,n.killed=f&&!c,n},Be=["stdin","stdout","stderr"],Ou=e=>Be.some(t=>e[t]!==void 0),xu=e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return Be.map(n=>e[n]);if(Ou(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Be.map(n=>`\`${n}\``).join(", ")}`);if(typeof t=="string")return t;if(!Array.isArray(t))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);const r=Math.max(t.length,Be.length);return Array.from({length:r},(n,o)=>t[o])};var Z={exports:{}},Oe={exports:{}};Oe.exports;var _r;function Mu(){return _r||(_r=1,function(e){e.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"],process.platform!=="win32"&&e.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),process.platform==="linux"&&e.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")}(Oe)),Oe.exports}var y=v.process;const Y=function(e){return e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function"};if(!Y(y))Z.exports=function(){return function(){}};else{var Su=Ht,ce=Mu(),Pu=/^win/i.test(y.platform),xe=Ut;typeof xe!="function"&&(xe=xe.EventEmitter);var $;y.__signal_exit_emitter__?$=y.__signal_exit_emitter__:($=y.__signal_exit_emitter__=new xe,$.count=0,$.emitted={}),$.infinite||($.setMaxListeners(1/0),$.infinite=!0),Z.exports=function(e,t){if(!Y(v.process))return function(){};Su.equal(typeof e,"function","a callback must be provided for exit handler"),De===!1&&Tr();var r="exit";t&&t.alwaysLast&&(r="afterexit");var n=function(){$.removeListener(r,e),$.listeners("exit").length===0&&$.listeners("afterexit").length===0&&it()};return $.on(r,e),n};var it=function(){!De||!Y(v.process)||(De=!1,ce.forEach(function(t){try{y.removeListener(t,at[t])}catch{}}),y.emit=ct,y.reallyExit=Lr,$.count-=1)};Z.exports.unload=it;var ee=function(t,r,n){$.emitted[t]||($.emitted[t]=!0,$.emit(t,r,n))},at={};ce.forEach(function(e){at[e]=function(){if(Y(v.process)){var r=y.listeners(e);r.length===$.count&&(it(),ee("exit",null,e),ee("afterexit",null,e),Pu&&e==="SIGHUP"&&(e="SIGINT"),y.kill(y.pid,e))}}}),Z.exports.signals=function(){return ce};var De=!1,Tr=function(){De||!Y(v.process)||(De=!0,$.count+=1,ce=ce.filter(function(t){try{return y.on(t,at[t]),!0}catch{return!1}}),y.emit=_u,y.reallyExit=Iu)};Z.exports.load=Tr;var Lr=y.reallyExit,Iu=function(t){Y(v.process)&&(y.exitCode=t||0,ee("exit",y.exitCode,null),ee("afterexit",y.exitCode,null),Lr.call(y,y.exitCode))},ct=y.emit,_u=function(t,r){if(t==="exit"&&Y(v.process)){r!==void 0&&(y.exitCode=r);var n=ct.apply(this,arguments);return ee("exit",y.exitCode,null),ee("afterexit",y.exitCode,null),n}else return ct.apply(this,arguments)}}var Tu=Z.exports,Lu=V(Tu);const Ru=1e3*5,Nu=(e,t="SIGTERM",r={})=>{const n=e(t);return ku(e,t,r,n),n},ku=(e,t,r,n)=>{if(!ju(t,r,n))return;const o=Hu(r),s=setTimeout(()=>{e("SIGKILL")},o);s.unref&&s.unref()},ju=(e,{forceKillAfterTimeout:t},r)=>Gu(e)&&t!==!1&&r,Gu=e=>e===xn.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",Hu=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return Ru;if(!Number.isFinite(e)||e<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e},Uu=(e,t)=>{e.kill()&&(t.isCanceled=!0)},Ku=(e,t,r)=>{e.kill(t),r(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},qu=(e,{timeout:t,killSignal:r="SIGTERM"},n)=>{if(t===0||t===void 0)return n;let o;const s=new Promise((i,c)=>{o=setTimeout(()=>{Ku(e,r,c)},t)}),u=n.finally(()=>{clearTimeout(o)});return Promise.race([s,u])},zu=({timeout:e})=>{if(e!==void 0&&(!Number.isFinite(e)||e<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`)},Yu=async(e,{cleanup:t,detached:r},n)=>{if(!t||r)return n;const o=Lu(()=>{e.kill()});return n.finally(()=>{o()})};function Rr(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}function Nr(e){return Rr(e)&&e.writable!==!1&&typeof e._write=="function"&&typeof e._writableState=="object"}const Wu=e=>e instanceof Bn&&typeof e.then=="function",Dt=(e,t,r)=>{if(typeof r=="string")return e[t].pipe(Mn(r)),e;if(Nr(r))return e[t].pipe(r),e;if(!Wu(r))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!Nr(r.stdin))throw new TypeError("The target child process's stdin must be available.");return e[t].pipe(r.stdin),r},Ju=e=>{e.stdout!==null&&(e.pipeStdout=Dt.bind(void 0,e,"stdout")),e.stderr!==null&&(e.pipeStderr=Dt.bind(void 0,e,"stderr")),e.all!==void 0&&(e.pipeAll=Dt.bind(void 0,e,"all"))};var le={exports:{}};const{PassThrough:Vu}=Re;var Xu=e=>{e={...e};const{array:t}=e;let{encoding:r}=e;const n=r==="buffer";let o=!1;t?o=!(r||n):r=r||"utf8",n&&(r=null);const s=new Vu({objectMode:o});r&&s.setEncoding(r);let u=0;const i=[];return s.on("data",c=>{i.push(c),o?u=i.length:u+=c.length}),s.getBufferedValue=()=>t?i:n?Buffer.concat(i,u):i.join(""),s.getBufferedLength=()=>u,s};const{constants:Qu}=Pn,Zu=Re,{promisify:ei}=Kt,ti=Xu,ri=ei(Zu.pipeline);class kr extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function lt(e,t){if(!e)throw new Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:r}=t,n=ti(t);return await new Promise((o,s)=>{const u=i=>{i&&n.getBufferedLength()<=Qu.MAX_LENGTH&&(i.bufferedData=n.getBufferedValue()),s(i)};(async()=>{try{await ri(e,n),o()}catch(i){u(i)}})(),n.on("data",()=>{n.getBufferedLength()>r&&u(new kr)})}),n.getBufferedValue()}le.exports=lt,le.exports.buffer=(e,t)=>lt(e,{...t,encoding:"buffer"}),le.exports.array=(e,t)=>lt(e,{...t,array:!0}),le.exports.MaxBufferError=kr;var ni=le.exports,jr=V(ni);const{PassThrough:oi}=Re;var si=function(){var e=[],t=new oi({objectMode:!0});return t.setMaxListeners(0),t.add=r,t.isEmpty=n,t.on("unpipe",o),Array.prototype.slice.call(arguments).forEach(r),t;function r(s){return Array.isArray(s)?(s.forEach(r),this):(e.push(s),s.once("end",o.bind(null,s)),s.once("error",t.emit.bind(t,"error")),s.pipe(t,{end:!1}),this)}function n(){return e.length==0}function o(s){e=e.filter(function(u){return u!==s}),!e.length&&t.readable&&t.end()}},ui=V(si);const ii=e=>{if(e!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},ai=({input:e,inputFile:t})=>typeof t!="string"?e:(ii(e),Sn(t)),ci=(e,t)=>{const r=ai(t);r!==void 0&&(Rr(r)?r.pipe(e.stdin):e.stdin.end(r))},Di=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;const r=ui();return e.stdout&&r.add(e.stdout),e.stderr&&r.add(e.stderr),r},ft=async(e,t)=>{if(!(!e||t===void 0)){e.destroy();try{return await t}catch(r){return r.bufferedData}}},pt=(e,{encoding:t,buffer:r,maxBuffer:n})=>{if(!(!e||!r))return t?jr(e,{encoding:t,maxBuffer:n}):jr.buffer(e,{maxBuffer:n})},li=async({stdout:e,stderr:t,all:r},{encoding:n,buffer:o,maxBuffer:s},u)=>{const i=pt(e,{encoding:n,buffer:o,maxBuffer:s}),c=pt(t,{encoding:n,buffer:o,maxBuffer:s}),l=pt(r,{encoding:n,buffer:o,maxBuffer:s*2});try{return await Promise.all([u,i,c,l])}catch(f){return Promise.all([{error:f,signal:f.signal,timedOut:f.timedOut},ft(e,i),ft(t,c),ft(r,l)])}},fi=(async()=>{})().constructor.prototype,pi=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(fi,e)]),Gr=(e,t)=>{for(const[r,n]of pi){const o=typeof t=="function"?(...s)=>Reflect.apply(n.value,t(),s):n.value.bind(t);Reflect.defineProperty(e,r,{...n,value:o})}},di=e=>new Promise((t,r)=>{e.on("exit",(n,o)=>{t({exitCode:n,signal:o})}),e.on("error",n=>{r(n)}),e.stdin&&e.stdin.on("error",n=>{r(n)})}),Hr=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],mi=/^[\w.-]+$/,hi=/"/g,gi=e=>typeof e!="string"||mi.test(e)?e:`"${e.replace(hi,'\\"')}"`,Ci=(e,t)=>Hr(e,t).join(" "),Ei=(e,t)=>Hr(e,t).map(r=>gi(r)).join(" "),Fi=In("execa").enabled,Me=(e,t)=>String(e).padStart(t,"0"),yi=()=>{const e=new Date;return`${Me(e.getHours(),2)}:${Me(e.getMinutes(),2)}:${Me(e.getSeconds(),2)}.${Me(e.getMilliseconds(),3)}`},bi=(e,{verbose:t})=>{t&&I.stderr.write(`[${yi()}] ${e}
|
|
28
|
+
`)},wi=1e3*1e3*100,Ai=({env:e,extendEnv:t,preferLocal:r,localDir:n,execPath:o})=>{const s=t?{...I.env,...e}:e;return r?au({env:s,cwd:n,execPath:o}):s},vi=(e,t,r={})=>{const n=nu._parse(e,t,r);return e=n.command,t=n.args,r=n.options,r={maxBuffer:wi,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:r.cwd||I.cwd(),execPath:I.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:Fi,...r},r.env=Ai(r),r.stdio=xu(r),I.platform==="win32"&&J.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:r,parsed:n}},dt=(e,t,r)=>typeof t!="string"&&!$n.isBuffer(t)?r===void 0?void 0:"":e.stripFinalNewline?ou(t):t;function te(e,t,r){const n=vi(e,t,r),o=Ci(e,t),s=Ei(e,t);bi(s,n.options),zu(n.options);let u;try{u=kt.spawn(n.file,n.args,n.options)}catch(p){const d=new kt.ChildProcess,h=Promise.reject(Ir({error:p,stdout:"",stderr:"",all:"",command:o,escapedCommand:s,parsed:n,timedOut:!1,isCanceled:!1,killed:!1}));return Gr(d,h),d}const i=di(u),c=qu(u,n.options,i),l=Yu(u,n.options,c),f={isCanceled:!1};u.kill=Nu.bind(null,u.kill.bind(u)),u.cancel=Uu.bind(null,u,f);const D=xr(async()=>{const[{error:p,exitCode:d,signal:h,timedOut:m},E,b,A]=await li(u,n.options,l),R=dt(n.options,E),N=dt(n.options,b),se=dt(n.options,A);if(p||d!==0||h!==null){const w=Ir({error:p,exitCode:d,signal:h,stdout:R,stderr:N,all:se,command:o,escapedCommand:s,parsed:n,timedOut:m,isCanceled:f.isCanceled||(n.options.signal?n.options.signal.aborted:!1),killed:u.killed});if(!n.options.reject)return w;throw w}return{command:o,escapedCommand:s,exitCode:0,stdout:R,stderr:N,all:se,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return ci(u,n.options),u.all=Di(u,n.options),Ju(u),Gr(u,D),u}class H{static create(t,r){return new t(r)}}const W={locale:"en",maxLength:50,type:"conventional",generate:1,promptPath:""},$i={"":"<commit message>",conventional:`<type>(<optional scope>): <description>
|
|
29
29
|
|
|
30
30
|
[optional body]
|
|
31
31
|
|
|
@@ -60,7 +60,7 @@ ${i.footer}`:""}`});return u.length>n?u.slice(0,n):u}catch{const u=/\[[\s\S]*?\]
|
|
|
60
60
|
|
|
61
61
|
${a.body}`:""}${a.footer?`
|
|
62
62
|
|
|
63
|
-
${a.footer}`:""}`});return f.length>n?f.slice(0,n):f}catch{return[]}}}extractMessageAsType(t,r){switch(r){case"conventional":const n=/(\w+)(?:\(.*?\))?:\s*(.*)/,o=t.subject.match(n),s=o?o[0]:t.subject;return{...t,subject:this.normalizeCommitMessage(s)};case"gitmoji":const u=/:\w*:\s*(.*)/,i=t.subject.match(u);return{...t,subject:i?i[0].toLowerCase():t.subject};default:return t}}normalizeCommitMessage(t){const r=/^(\w+)(\(.*?\))?:\s(.*)$/,n=t.match(r);if(n){const[,o,s,u]=n,i=o.toLowerCase(),c=u.charAt(0).toLowerCase()+u.slice(1);t=`${i}${s||""}: ${c}`}return t}}var qr="1.12.
|
|
63
|
+
${a.footer}`:""}`});return f.length>n?f.slice(0,n):f}catch{return[]}}}extractMessageAsType(t,r){switch(r){case"conventional":const n=/(\w+)(?:\(.*?\))?:\s*(.*)/,o=t.subject.match(n),s=o?o[0]:t.subject;return{...t,subject:this.normalizeCommitMessage(s)};case"gitmoji":const u=/:\w*:\s*(.*)/,i=t.subject.match(u);return{...t,subject:i?i[0].toLowerCase():t.subject};default:return t}}normalizeCommitMessage(t){const r=/^(\w+)(\(.*?\))?:\s(.*)$/,n=t.match(r);if(n){const[,o,s,u]=n,i=o.toLowerCase(),c=u.charAt(0).toLowerCase()+u.slice(1);t=`${i}${s||""}: ${c}`}return t}}var qr="1.12.5",xi="A Reactive CLI that generates git commit messages with various AI";class F extends Error{}const ht=" ",fe=e=>{e instanceof Error&&(e instanceof F||(e.stack&&console.error(g.dim(e.stack.split(`
|
|
64
64
|
`).slice(1).join(`
|
|
65
65
|
`))),console.error(`
|
|
66
66
|
${ht}${g.dim(`aicommit2 v${qr}`)}`),console.error(`
|
|
@@ -79,23 +79,23 @@ ${i}
|
|
|
79
79
|
${t}`)},Ii=(e,t)=>{const{year:r,month:n,day:o,hours:s,minutes:u,seconds:i}=_i(e),l=kn(0).update(t).digest("hex");return`aic2_${r}-${n}-${o}_${s}:${u}:${i}_${l}.log`},Jr=(e,t="")=>{k.mkdirSync(P.dirname(e),{recursive:!0}),k.writeFileSync(e,t,"utf-8")},_i=e=>{const t=e.getFullYear().toString(),r=(e.getMonth()+1).toString().padStart(2,"0"),n=e.getDate().toString().padStart(2,"0"),o=e.getHours().toString().padStart(2,"0"),s=e.getMinutes().toString().padStart(2,"0"),u=e.getSeconds().toString().padStart(2,"0");return{year:t,month:r,day:n,hours:o,minutes:s,seconds:u}};class Ti extends U{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=r.error?.error?.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return x({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#AE5630",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Anthropic]"),this.errorPrefix=g.red.bold("[Anthropic]"),this.anthropic=new Nn({apiKey:this.params.config.ANTHROPIC_KEY})}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c={...W,locale:r,maxLength:i,type:o,generate:n,promptPath:s},f=`${re(c)}`,a={max_tokens:this.params.config["max-tokens"],temperature:this.params.config.temperature,system:f,messages:[{role:"user",content:`Here are diff: ${t}`}],model:this.params.config.ANTHROPIC_MODEL},p=(await this.anthropic.messages.create(a)).content.map(({text:d})=>d).join("");return u&&K("Anthropic",t,f,p),this.sanitizeMessage(p,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}}class Se{constructor(t={}){if(!t.method)throw new Error("method should be defined!");if(!t.baseURL)throw new Error("baseURL should be defined!");this.config={...t},this.axiosInstance=jn.create(this.config)}setHeaders(t){return this.config.headers=t,this}setParams(t){return this.config.params=t,this}setBody(t){return this.config.data=t,this}setMethod(t){return this.config.method=t,this}async execute(){try{return await this.axiosInstance.request(this.config)}catch(t){throw t}}}class Li extends U{constructor(t){super(t),this.params=t,this.host="https://codestral.mistral.ai",this.apiKey="",this.handleError$=r=>{const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return x({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#e28c58",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Codestral]"),this.errorPrefix=g.red.bold("[Codestral]"),this.apiKey=this.params.config.CODESTRAL_KEY}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(r,t,n,i,o,s);this.checkAvailableModels();const l=await this.createChatCompletions(c);return u&&K("Codestral",t,c,l),this.sanitizeMessage(l,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}checkAvailableModels(){if(["codestral-latest","codestral-2405"].includes(this.params.config.CODESTRAL_MODEL))return!0;throw new Error("Invalid model type of Codestral AI")}async createChatCompletions(t){const n=(await new Se({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.CODESTRAL_MODEL,messages:[{role:"user",content:t}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config["max-tokens"],stream:!1,safe_prompt:!1,random_seed:Yr(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}}class Ri extends U{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=/"message":\s*"([^"]*)"/,o=r.message.match(n);let s=r?.body?.message;o&&o[1]&&(s=o[1]);const u=`${r.statusCode} ${s}`;return x({name:`${this.errorPrefix} ${u}`,value:s,isError:!0,disabled:!0})},this.colors={primary:"#D18EE2",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Cohere]"),this.errorPrefix=g.red.bold("[Cohere]"),this.cohere=new Gn({token:this.params.config.COHERE_KEY})}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(r,t,n,i,o,s),l=this.params.config["max-tokens"],a=(await this.cohere.generate({prompt:c,maxTokens:l,temperature:this.params.config.temperature,model:this.params.config.COHERE_MODEL})).generations.map(D=>D.text).join("");return u&&K("Cohere",t,c,a),this.sanitizeMessage(a,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r instanceof Hn?new F("Request timed out error!"):r}}}class Ni extends U{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=r.message||r.toString(),o=/(\[.*?\]\s*[^[]*)/g,s=[...n.matchAll(o)],u=[];s.forEach(c=>u.push(c[1]));const i=u[1]||"An error occurred";return x({name:`${this.errorPrefix} ${i}`,value:i,isError:!0,disabled:!0})},this.colors={primary:"#0077FF",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Gemini]"),this.errorPrefix=g.red.bold("[Gemini]"),this.genAI=new Un(this.params.config.GEMINI_KEY)}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(r,t,n,i,o,s),l=this.params.config["max-tokens"],p=(await(await this.genAI.getGenerativeModel({model:this.params.config.GEMINI_MODEL,generationConfig:{maxOutputTokens:l,temperature:this.params.config.temperature}}).generateContent(c)).response).text();return u&&K("Gemini",t,c,p),this.sanitizeMessage(p,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}}class ki extends U{constructor(t){super(t),this.params=t,this.handleError$=r=>{let n="An error occurred";const o=/"message":\s*"([^"]*)"/,s=r.message.match(o);s&&s[1]&&(n=s[1]);const u=`${r.status} ${n}`;return x({name:`${this.errorPrefix} ${u}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#f55036",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Groq]"),this.errorPrefix=g.red.bold("[Groq]"),this.groq=new Kn({apiKey:this.params.config.GROQ_KEY})}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c={...W,locale:r,maxLength:i,type:o,generate:n,promptPath:s},f=`${re(c)}`,D=(await this.groq.chat.completions.create({messages:[{role:"system",content:f},{role:"user",content:`Here are diff: ${t}`}],model:this.params.config.GROQ_MODEL},{timeout:this.params.config.timeout})).choices[0].message.content||"";return u&&K("Groq",t,f,D),this.sanitizeMessage(D,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){throw t}}}class ji extends U{constructor(t){super(t),this.params=t,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=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[HuggingFace]"),this.errorPrefix=g.red.bold("[HuggingFace]"),this.cookie=this.params.config.HUGGINGFACE_COOKIE}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{await this.intialize();const t=this.getSystemPrompt(),r=await this.getNewChat(t),n=`Here are diff: ${this.params.stagedDiff.diff}`,s=await(await this.sendMessage(n,r.id)).completeResponsePromise(),{generate:u,logging:i}=this.params.config;return i&&K("HuggingFace",this.params.stagedDiff.diff,t,s),this.sanitizeMessage(s,this.params.config.type,u,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async intialize(){const t=await this.getRemoteLlms(),r=t.find(n=>n.name?.toLowerCase()===this.params.config.HUGGINGFACE_MODEL.toLowerCase());if(r){this.currentModel=r,this.currentModelId=r.id;return}this.currentModel=t[0],this.currentModelId=t[0].id}async getRemoteLlms(){const t=await fetch("https://huggingface.co/chat/__data.json",{headers:{...this.headers,cookie:this.cookie},body:null,method:"GET"});if(t.status!==200)throw new Error(`Failed to get remote LLMs with status code: ${t.status}`);const n=(await t.json()).nodes[0].data,o=n[n[0].models],s=[],u=i=>i===-1?null:n[i];for(const i of o){const c=n[i];if(n[c.unlisted])continue;const l={id:u(c.id),name:u(c.name),displayName:u(c.displayName),preprompt:u(c.preprompt),promptExamples:[],websiteUrl:u(c.websiteUrl),description:u(c.description),datasetName:u(c.datasetName),datasetUrl:u(c.datasetUrl),modelUrl:u(c.modelUrl),parameters:{}},f=u(c.promptExamples);if(f!==null){const p=f.map(d=>u(d));l.promptExamples=p.map(d=>({title:n[d.title],prompt:n[d.prompt]}))}const a=u(c.parameters),D={};for(const[p,d]of Object.entries(a)){if(d===-1){D[p]=null;continue}if(Array.isArray(n[d])){D[p]=n[d].map(h=>n[h]);continue}D[p]=n[d]}l.parameters=D,s.push(l)}return this.models=s,s}async getNewChat(t){const r={model:this.currentModelId,preprompt:t};let n=0;for(;n<5;){const o=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 o.json();if(s){this.currentConversionID=s;break}else n++}if(!this.currentConversionID)throw new Error("Failed to create new conversion");return await this.getConversationHistory(this.currentConversionID)}async getConversationHistory(t){if(!t)throw new Error("conversationId is required for getConversationHistory");const r=await fetch("https://huggingface.co/chat/conversation/"+t+"/__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 n=await r.json();return this.metadataParser(n,t)}}metadataParser(t,r){const n={id:"",model:"",systemPrompt:"",title:"",history:[]},o=t.nodes[1].data,s=o[o[0].model],u=o[o[0].preprompt],i=o[o[0].title],c=o[o[0].messages],l=[];for(const f of c){const a=o[f],D=new Date(o[a.createdAt][1]).getTime()/1e3,p=new Date(o[a.updatedAt][1]).getTime()/1e3;l.push({id:o[a.id],role:o[a.from],content:o[a.content],createdAt:D,updatedAt:p})}return n.id=r,n.model=s,n.systemPrompt=u,n.title=i,n.history=l,this.currentConversation=n,n}async sendMessage(t,r){if(t==="")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 n={inputs:t,id:this.currentConversation.history[this.currentConversation.history.length-1].id,is_retry:!1,is_continue:!1,web_search:!1,tools:{}},o=new FormData;o.append("data",JSON.stringify(n));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:o,method:"POST"});function u(D){try{const p=D.split(`
|
|
80
80
|
`),d=[];for(const h of p)h.trim()&&d.push(JSON.parse(h));return d}catch{return[{}]}}const i=new TextDecoder;let c="";const l=new TransformStream({async transform(D,p){const d=i.decode(D);try{const h=u(d);for(const m of h)m.type==="finalAnswer"?(c=m?.text||"",p.terminate()):m.type==="stream"&&p.enqueue(m?.token||"")}catch{throw new Error("Error during parsing response")}}}),f=s.body?.pipeThrough(l);async function a(){return new Promise(async(D,p)=>{try{if(!f)p("ModifiedStream undefined");else{const d=f.getReader();for(;;){const{done:h,value:m}=await d.read();if(h){D(c);break}}}}catch(d){p(d)}})}return{id:this.currentConversionID,stream:f,completeResponsePromise:a}}async deleteConversation(t){return(await fetch(`https://huggingface.co/chat/conversation/${t}`,{headers:{...this.headers,cookie:this.cookie,Referer:"https://huggingface.co/chat/"},body:null,method:"DELETE"})).json()}getSystemPrompt(){const{locale:t,generate:r,type:n,promptPath:o}=this.params.config,s=this.params.config["max-length"],u={...W,locale:t,maxLength:s,type:n,generate:r,promptPath:o};return`${re(u)}`}}class Gi extends U{constructor(t){super(t),this.params=t,this.host="https://api.mistral.ai",this.apiKey="",this.handleError$=r=>{const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return x({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#ff7000",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[MistralAI]"),this.errorPrefix=g.red.bold("[MistralAI]"),this.apiKey=this.params.config.MISTRAL_KEY}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(r,t,n,i,o,s);await this.checkAvailableModels();const l=await this.createChatCompletions(c);return u&&K("MistralAI",t,c,l),this.sanitizeMessage(l,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async checkAvailableModels(){if((await this.getAvailableModels()).includes(this.params.config.MISTRAL_MODEL))return!0;throw new Error("Invalid model type of Mistral AI")}async getAvailableModels(){return(await new Se({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(t){const n=(await new Se({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.MISTRAL_MODEL,messages:[{role:"user",content:t}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config["max-tokens"],stream:!1,safe_prompt:!1,random_seed:Yr(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:gt}=Object.prototype,Pe=typeof process<"u"&&process.platform==="win32"?`\r
|
|
81
81
|
`:`
|
|
82
|
-
`,Ct=(e,t)=>{const r=[];let n="";typeof t=="string"?t={section:t,whitespace:!1}:(t=t||Object.create(null),t.whitespace=t.whitespace===!0);const o=t.whitespace?" = ":"=";for(const s of Object.keys(e)){const u=e[s];if(u&&Array.isArray(u))for(const i of u)n+=ne(s+"[]")+o+ne(i)+Pe;else u&&typeof u=="object"?r.push(s):n+=ne(s)+o+ne(u)+Pe}t.section&&n.length&&(n="["+ne(t.section)+"]"+Pe+n);for(const s of r){const u=Vr(s).join("\\."),i=(t.section?t.section+".":"")+u,{whitespace:c}=t,l=Ct(e[s],{section:i,whitespace:c});n.length&&l.length&&(n+=Pe),n+=l}return n},Vr=e=>e.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(t=>t.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),Xr=e=>{const t=Object.create(null);let r=t,n=null;const o=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,s=e.split(/[\r\n]+/g);for(const i of s){if(!i||i.match(/^\s*[;#]/))continue;const c=i.match(o);if(!c)continue;if(c[1]!==void 0){if(n=Ie(c[1]),n==="__proto__"){r=Object.create(null);continue}r=t[n]=t[n]||Object.create(null);continue}const l=Ie(c[2]),f=l.length>2&&l.slice(-2)==="[]",a=f?l.slice(0,-2):l;if(a==="__proto__")continue;const D=c[3]?Ie(c[4]):!0,p=D==="true"||D==="false"||D==="null"?JSON.parse(D):D;f&&(gt.call(r,a)?Array.isArray(r[a])||(r[a]=[r[a]]):r[a]=[]),Array.isArray(r[a])?r[a].push(p):r[a]=p}const u=[];for(const i of Object.keys(t)){if(!gt.call(t,i)||typeof t[i]!="object"||Array.isArray(t[i]))continue;const c=Vr(i);r=t;const l=c.pop(),f=l.replace(/\\\./g,".");for(const a of c)a!=="__proto__"&&((!gt.call(r,a)||typeof r[a]!="object")&&(r[a]=Object.create(null)),r=r[a]);r===t&&f===l||(r[f]=t[i],u.push(i))}for(const i of u)delete t[i];return t},Qr=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),ne=e=>typeof e!="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&Qr(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),Ie=(e,t)=>{if(e=(e||"").trim(),Qr(e)){e.charAt(0)==="'"&&(e=e.slice(1,-1));try{e=JSON.parse(e)}catch{}}else{let r=!1,n="";for(let o=0,s=e.length;o<s;o++){const u=e.charAt(o);if(r)"\\;#".indexOf(u)!==-1?n+=u:n+="\\"+u,r=!1;else{if(";#".indexOf(u)!==-1)break;u==="\\"?r=!0:n+=u}}return r&&(n+="\\"),n.trim()}return e};var Hi={parse:Xr,decode:Xr,stringify:Ct,encode:Ct,safe:ne,unsafe:Ie},Zr=V(Hi);const en=e=>O.lstat(e).then(()=>!0,()=>!1),Ui=["","conventional","gitmoji"],Et="http://localhost:11434",{hasOwnProperty:Ki}=Object.prototype,Ft=(e,t)=>Ki.call(e,t),C=(e,t,r)=>{if(!t)throw new F(`Invalid config property ${e}: ${r}`)},tn={confirm(e){return e?typeof e=="boolean"?e:(C("confirm",/^(?:true|false)$/.test(e),"Must be a boolean"),e==="true"):!1},promptPath(e){return e||""},locale(e){return e?(C("locale",e,"Cannot be empty"),C("locale",/^[a-z-]+$/i.test(e),"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"),e):"en"},generate(e){if(!e)return 1;C("generate",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return C("generate",t>0,"Must be greater than 0"),C("generate",t<=5,"Must be less or equal to 5"),t},type(e){return e?(C("type",Ui.includes(e),"Invalid commit type"),e):"conventional"},proxy(e){if(!(!e||e.length===0))return C("proxy",/^https?:\/\//.test(e),"Must be a valid URL"),e},timeout(e){if(!e)return 1e4;C("timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return C("timeout",t>=500,"Must be greater than 500ms"),t},temperature(e){if(!e)return .7;C("temperature",/^(2|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 2");const t=Number(e);return C("temperature",t>0,"Must be greater than 0"),C("temperature",t<=2,"Must be less than or equal to 2"),t},"max-length"(e){if(!e)return 50;C("max-length",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return C("max-length",t>=20,"Must be greater than 20 characters"),t},"max-tokens"(e){return e?(C("max-tokens",/^\d+$/.test(e),"Must be an integer"),Number(e)):1024},logging(e){return e?typeof e=="boolean"?e:(C("logging",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"):!1},ignoreBody(e){return e?typeof e=="boolean"?e:(C("ignoreBody",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"):!0}},rn={OPENAI_KEY(e){return e||""},OPENAI_MODEL(e){return!e||e.length===0?"gpt-3.5-turbo":e},OPENAI_URL(e){return e?(C("OPENAI_URL",/^https?:\/\//.test(e),"Must be a valid URL"),e):"https://api.openai.com"},OPENAI_PATH(e){return e||"/v1/chat/completions"},HUGGINGFACE_COOKIE(e){return e||""},HUGGINGFACE_MODEL(e){return!e||e.length===0?"CohereForAI/c4ai-command-r-plus":(C("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(e),"Invalid model type of HuggingFace chat"),e)},GEMINI_KEY(e){return e||""},GEMINI_MODEL(e){return!e||e.length===0?"gemini-1.5-pro-latest":(C("GEMINI_MODEL",["gemini-1.5-flash-latest","gemini-1.5-pro-latest"].includes(e),"Invalid model type of Gemini"),e)},ANTHROPIC_MODEL(e){return!e||e.length===0?"claude-3-haiku-20240307":(C("ANTHROPIC_MODEL",["claude-2.1","claude-2.0","claude-instant-1.2","claude-3-haiku-20240307","claude-3-sonnet-20240229","claude-3-opus-20240229"].includes(e),"Invalid model type of Anthropic"),e)},ANTHROPIC_KEY(e){return e||""},MISTRAL_KEY(e){return e||""},MISTRAL_MODEL(e){return!e||e.length===0?"mistral-tiny":(C("MISTRAL_MODEL",["open-mistral-7b","mistral-tiny-2312","mistral-tiny","open-mixtral-8x7b","mistral-small-2312","mistral-small","mistral-small-2402","mistral-small-latest","mistral-medium-latest","mistral-medium-2312","mistral-medium","mistral-large-latest","mistral-large-2402","mistral-embed"].includes(e),"Invalid model type of Mistral AI"),e)},CODESTRAL_KEY(e){return e||""},CODESTRAL_MODEL(e){return!e||e.length===0?"codestral-latest":(C("CODESTRAL_MODEL",["codestral-latest","codestral-2405"].includes(e),"Invalid model type of Codestral"),e)},OLLAMA_MODEL(e){return e?(typeof e=="string"?e?.split(","):e).map(r=>r.trim()).filter(r=>!!r&&r.length>0):[]},OLLAMA_HOST(e){return e?(C("OLLAMA_HOST",/^https?:\/\//.test(e),"Must be a valid URL"),e):Et},OLLAMA_TIMEOUT(e){if(!e)return 1e5;C("OLLAMA_TIMEOUT",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return C("OLLAMA_TIMEOUT",t>=500,"Must be greater than 500ms"),t},OLLAMA_STREAM(e){return e?typeof e=="boolean"?e:(C("OLLAMA_STREAM",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"):!1},COHERE_KEY(e){return e||""},COHERE_MODEL(e){return!e||e.length===0?"command":(C("COHERE_MODEL",["command","command-nightly","command-light","command-light-nightly"].includes(e),"Invalid model type of Cohere"),e)},GROQ_KEY(e){return e||""},GROQ_MODEL(e){return!e||e.length===0?"gemma-7b-it":(C("GROQ_MODEL",["llama3-8b-8192","llama3-70b-8192","mixtral-8x7b-32768","gemma-7b-it"].includes(e),"Invalid model type of Groq"),e)}},yt=P.join(je.homedir(),".aicommit2"),nn=async()=>{if(!await en(yt))return Object.create(null);const t=await O.readFile(yt,"utf8");let r=Zr.parse(t);return Ft(r,"OLLAMA_MODEL")&&(r={...r,OLLAMA_MODEL:typeof r.OLLAMA_MODEL=="string"?[r.OLLAMA_MODEL]:r.OLLAMA_MODEL}),r},bt=async(e,t)=>{const r=await nn(),n={},o={...tn,...rn};for(const s of Object.keys(o)){const u=o[s],i=e?.[s]??r[s];if(t)try{n[s]=u(i)}catch{}else n[s]=u(i)}return n},qi=async e=>{const t=await nn(),r={...tn,...rn};for(const[n,o]of e){if(!Ft(r,n))throw new F(`Invalid config property: ${n}`);const s=r[n](o);t[n]=s}await O.writeFile(yt,Zr.stringify(t),"utf8")};class zi extends U{constructor(t){super(t),this.params=t,this.host=Et,this.model="",this.handleError$=r=>{if(r.response&&r.response.data?.error)return x({name:`${this.errorPrefix} ${r.response.data?.error}`,value:r.response.data?.error,isError:!0,disabled:!0});const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return x({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#FFF",secondary:"#000"},this.model=this.params.keyName,this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[${zr(this.model)}]`),this.errorPrefix=g.red.bold(`[${zr(this.model)}]`),this.host=this.params.config.OLLAMA_HOST||Et,this.ollama=new qn({host:this.host})}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{await this.checkIsAvailableOllama();const t=await this.createChatCompletions(),{type:r,generate:n,logging:o}=this.params.config,s=this.createSystemPrompt();return o&&K(`Ollama_${this.model}`,this.params.stagedDiff.diff,s,t),this.sanitizeMessage(t,r,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async checkIsAvailableOllama(){try{return(await new Se({method:"GET",baseURL:`${this.host}`,timeout:this.params.config.OLLAMA_TIMEOUT}).execute()).data}catch(t){throw t.code==="ECONNREFUSED"?new F(`Error connecting to ${this.host}. Please run Ollama or check host`):t}}async createChatCompletions(){const t=this.createSystemPrompt();return(await this.ollama.chat({model:this.model,messages:[{role:"system",content:t},{role:"user",content:`Here are diff: ${this.params.stagedDiff.diff}`}],stream:!1,options:{temperature:this.params.config.temperature}})).message.content}createSystemPrompt(){const t={...W,locale:this.params.config.locale,maxLength:this.params.config["max-length"],type:this.params.config.type,generate:this.params.config.generate,promptPath:this.params.config.promptPath};return`${re(t)}`}}var At={},wt={exports:{}},de={exports:{}},vt,on;function Yi(){if(on)return vt;on=1;var e=1e3,t=e*60,r=t*60,n=r*24,o=n*7,s=n*365.25;vt=function(f,a){a=a||{};var D=typeof f;if(D==="string"&&f.length>0)return u(f);if(D==="number"&&isFinite(f))return a.long?c(f):i(f);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(f))};function u(f){if(f=String(f),!(f.length>100)){var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(f);if(a){var D=parseFloat(a[1]),p=(a[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return D*s;case"weeks":case"week":case"w":return D*o;case"days":case"day":case"d":return D*n;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*t;case"seconds":case"second":case"secs":case"sec":case"s":return D*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return D;default:return}}}}function i(f){var a=Math.abs(f);return a>=n?Math.round(f/n)+"d":a>=r?Math.round(f/r)+"h":a>=t?Math.round(f/t)+"m":a>=e?Math.round(f/e)+"s":f+"ms"}function c(f){var a=Math.abs(f);return a>=n?l(f,a,n,"day"):a>=r?l(f,a,r,"hour"):a>=t?l(f,a,t,"minute"):a>=e?l(f,a,e,"second"):f+" ms"}function l(f,a,D,p){var d=a>=D*1.5;return Math.round(f/D)+" "+p+(d?"s":"")}return vt}var $t,sn;function un(){if(sn)return $t;sn=1;function e(t){n.debug=n,n.default=n,n.coerce=l,n.disable=u,n.enable=s,n.enabled=i,n.humanize=Yi(),n.destroy=f,Object.keys(t).forEach(a=>{n[a]=t[a]}),n.names=[],n.skips=[],n.formatters={};function r(a){let D=0;for(let p=0;p<a.length;p++)D=(D<<5)-D+a.charCodeAt(p),D|=0;return n.colors[Math.abs(D)%n.colors.length]}n.selectColor=r;function n(a){let D,p=null,d,h;function m(...E){if(!m.enabled)return;const b=m,w=Number(new Date),R=w-(D||w);b.diff=R,b.prev=D,b.curr=w,D=w,E[0]=n.coerce(E[0]),typeof E[0]!="string"&&E.unshift("%O");let N=0;E[0]=E[0].replace(/%([a-zA-Z%])/g,(A,ue)=>{if(A==="%%")return"%";N++;const Nt=n.formatters[ue];if(typeof Nt=="function"){const wn=E[N];A=Nt.call(b,wn),E.splice(N,1),N--}return A}),n.formatArgs.call(b,E),(b.log||n.log).apply(b,E)}return m.namespace=a,m.useColors=n.useColors(),m.color=n.selectColor(a),m.extend=o,m.destroy=n.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(d!==n.namespaces&&(d=n.namespaces,h=n.enabled(a)),h),set:E=>{p=E}}),typeof n.init=="function"&&n.init(m),m}function o(a,D){const p=n(this.namespace+(typeof D>"u"?":":D)+a);return p.log=this.log,p}function s(a){n.save(a),n.namespaces=a,n.names=[],n.skips=[];let D;const p=(typeof a=="string"?a:"").split(/[\s,]+/),d=p.length;for(D=0;D<d;D++)p[D]&&(a=p[D].replace(/\*/g,".*?"),a[0]==="-"?n.skips.push(new RegExp("^"+a.slice(1)+"$")):n.names.push(new RegExp("^"+a+"$")))}function u(){const a=[...n.names.map(c),...n.skips.map(c).map(D=>"-"+D)].join(",");return n.enable(""),a}function i(a){if(a[a.length-1]==="*")return!0;let D,p;for(D=0,p=n.skips.length;D<p;D++)if(n.skips[D].test(a))return!1;for(D=0,p=n.names.length;D<p;D++)if(n.names[D].test(a))return!0;return!1}function c(a){return a.toString().substring(2,a.toString().length-2).replace(/\.\*\?$/,"*")}function l(a){return a instanceof Error?a.stack||a.message:a}function f(){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 n.enable(n.load()),n}return $t=e,$t}de.exports;var an;function Wi(){return an||(an=1,function(e,t){t.formatArgs=n,t.save=o,t.load=s,t.useColors=r,t.storage=u(),t.destroy=(()=>{let c=!1;return()=>{c||(c=!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`."))}})(),t.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(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1: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&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;c.splice(1,0,l,"color: inherit");let f=0,a=0;c[0].replace(/%[a-zA-Z%]/g,D=>{D!=="%%"&&(f++,D==="%c"&&(a=f))}),c.splice(a,0,l)}t.log=console.debug||console.log||(()=>{});function o(c){try{c?t.storage.setItem("debug",c):t.storage.removeItem("debug")}catch{}}function s(){let c;try{c=t.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c}function u(){try{return localStorage}catch{}}e.exports=un()(t);const{formatters:i}=e.exports;i.j=function(c){try{return JSON.stringify(c)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(de,de.exports)),de.exports}var me={exports:{}},Bt,cn;function Ji(){return cn||(cn=1,Bt=(e,t=process.argv)=>{const r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),o=t.indexOf("--");return n!==-1&&(o===-1||n<o)}),Bt}var Ot,Dn;function Vi(){if(Dn)return Ot;Dn=1;const e=je,t=Le,r=Ji(),{env:n}=process;let o;r("no-color")||r("no-colors")||r("color=false")||r("color=never")?o=0:(r("color")||r("colors")||r("color=true")||r("color=always"))&&(o=1),"FORCE_COLOR"in n&&(n.FORCE_COLOR==="true"?o=1:n.FORCE_COLOR==="false"?o=0:o=n.FORCE_COLOR.length===0?1:Math.min(parseInt(n.FORCE_COLOR,10),3));function s(c){return c===0?!1:{level:c,hasBasic:!0,has256:c>=2,has16m:c>=3}}function u(c,l){if(o===0)return 0;if(r("color=16m")||r("color=full")||r("color=truecolor"))return 3;if(r("color=256"))return 2;if(c&&!l&&o===void 0)return 0;const f=o||0;if(n.TERM==="dumb")return f;if(process.platform==="win32"){const a=e.release().split(".");return Number(a[0])>=10&&Number(a[2])>=10586?Number(a[2])>=14931?3:2:1}if("CI"in n)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(a=>a in n)||n.CI_NAME==="codeship"?1:f;if("TEAMCITY_VERSION"in n)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(n.TEAMCITY_VERSION)?1:0;if(n.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in n){const a=parseInt((n.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(n.TERM_PROGRAM){case"iTerm.app":return a>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(n.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(n.TERM)||"COLORTERM"in n?1:f}function i(c){const l=u(c,c&&c.isTTY);return s(l)}return Ot={supportsColor:i,stdout:s(u(!0,t.isatty(1))),stderr:s(u(!0,t.isatty(2)))},Ot}me.exports;var ln;function Xi(){return ln||(ln=1,function(e,t){const r=Le,n=Kt;t.init=f,t.log=i,t.formatArgs=s,t.save=c,t.load=l,t.useColors=o,t.destroy=n.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const D=Vi();D&&(D.stderr||D).level>=2&&(t.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{}t.inspectOpts=Object.keys(process.env).filter(D=>/^debug_/i.test(D)).reduce((D,p)=>{const d=p.substring(6).toLowerCase().replace(/_([a-z])/g,(m,E)=>E.toUpperCase());let h=process.env[p];return/^(yes|on|true|enabled)$/i.test(h)?h=!0:/^(no|off|false|disabled)$/i.test(h)?h=!1:h==="null"?h=null:h=Number(h),D[d]=h,D},{});function o(){return"colors"in t.inspectOpts?!!t.inspectOpts.colors:r.isatty(process.stderr.fd)}function s(D){const{namespace:p,useColors:d}=this;if(d){const h=this.color,m="\x1B[3"+(h<8?h:"8;5;"+h),E=` ${m};1m${p} \x1B[0m`;D[0]=E+D[0].split(`
|
|
82
|
+
`,Ct=(e,t)=>{const r=[];let n="";typeof t=="string"?t={section:t,whitespace:!1}:(t=t||Object.create(null),t.whitespace=t.whitespace===!0);const o=t.whitespace?" = ":"=";for(const s of Object.keys(e)){const u=e[s];if(u&&Array.isArray(u))for(const i of u)n+=ne(s+"[]")+o+ne(i)+Pe;else u&&typeof u=="object"?r.push(s):n+=ne(s)+o+ne(u)+Pe}t.section&&n.length&&(n="["+ne(t.section)+"]"+Pe+n);for(const s of r){const u=Vr(s).join("\\."),i=(t.section?t.section+".":"")+u,{whitespace:c}=t,l=Ct(e[s],{section:i,whitespace:c});n.length&&l.length&&(n+=Pe),n+=l}return n},Vr=e=>e.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(t=>t.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),Xr=e=>{const t=Object.create(null);let r=t,n=null;const o=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,s=e.split(/[\r\n]+/g);for(const i of s){if(!i||i.match(/^\s*[;#]/))continue;const c=i.match(o);if(!c)continue;if(c[1]!==void 0){if(n=Ie(c[1]),n==="__proto__"){r=Object.create(null);continue}r=t[n]=t[n]||Object.create(null);continue}const l=Ie(c[2]),f=l.length>2&&l.slice(-2)==="[]",a=f?l.slice(0,-2):l;if(a==="__proto__")continue;const D=c[3]?Ie(c[4]):!0,p=D==="true"||D==="false"||D==="null"?JSON.parse(D):D;f&&(gt.call(r,a)?Array.isArray(r[a])||(r[a]=[r[a]]):r[a]=[]),Array.isArray(r[a])?r[a].push(p):r[a]=p}const u=[];for(const i of Object.keys(t)){if(!gt.call(t,i)||typeof t[i]!="object"||Array.isArray(t[i]))continue;const c=Vr(i);r=t;const l=c.pop(),f=l.replace(/\\\./g,".");for(const a of c)a!=="__proto__"&&((!gt.call(r,a)||typeof r[a]!="object")&&(r[a]=Object.create(null)),r=r[a]);r===t&&f===l||(r[f]=t[i],u.push(i))}for(const i of u)delete t[i];return t},Qr=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),ne=e=>typeof e!="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&Qr(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),Ie=(e,t)=>{if(e=(e||"").trim(),Qr(e)){e.charAt(0)==="'"&&(e=e.slice(1,-1));try{e=JSON.parse(e)}catch{}}else{let r=!1,n="";for(let o=0,s=e.length;o<s;o++){const u=e.charAt(o);if(r)"\\;#".indexOf(u)!==-1?n+=u:n+="\\"+u,r=!1;else{if(";#".indexOf(u)!==-1)break;u==="\\"?r=!0:n+=u}}return r&&(n+="\\"),n.trim()}return e};var Hi={parse:Xr,decode:Xr,stringify:Ct,encode:Ct,safe:ne,unsafe:Ie},Zr=V(Hi);const en=e=>O.lstat(e).then(()=>!0,()=>!1),Ui=["","conventional","gitmoji"],Et="http://localhost:11434",{hasOwnProperty:Ki}=Object.prototype,Ft=(e,t)=>Ki.call(e,t),C=(e,t,r)=>{if(!t)throw new F(`Invalid config property ${e}: ${r}`)},tn={confirm(e){return e?typeof e=="boolean"?e:(C("confirm",/^(?:true|false)$/.test(e),"Must be a boolean"),e==="true"):!1},promptPath(e){return e||""},locale(e){return e?(C("locale",e,"Cannot be empty"),C("locale",/^[a-z-]+$/i.test(e),"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"),e):"en"},generate(e){if(!e)return 1;C("generate",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return C("generate",t>0,"Must be greater than 0"),C("generate",t<=5,"Must be less or equal to 5"),t},type(e){return e?(C("type",Ui.includes(e),"Invalid commit type"),e):"conventional"},proxy(e){if(!(!e||e.length===0))return C("proxy",/^https?:\/\//.test(e),"Must be a valid URL"),e},timeout(e){if(!e)return 1e4;C("timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return C("timeout",t>=500,"Must be greater than 500ms"),t},temperature(e){if(!e)return .7;C("temperature",/^(2|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 2");const t=Number(e);return C("temperature",t>0,"Must be greater than 0"),C("temperature",t<=2,"Must be less than or equal to 2"),t},"max-length"(e){if(!e)return 50;C("max-length",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return C("max-length",t>=20,"Must be greater than 20 characters"),t},"max-tokens"(e){return e?(C("max-tokens",/^\d+$/.test(e),"Must be an integer"),Number(e)):1024},logging(e){return e?typeof e=="boolean"?e:(C("logging",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"):!1},ignoreBody(e){return e?typeof e=="boolean"?e:(C("ignoreBody",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"):!0}},rn={OPENAI_KEY(e){return e||""},OPENAI_MODEL(e){return!e||e.length===0?"gpt-3.5-turbo":e},OPENAI_URL(e){return e?(C("OPENAI_URL",/^https?:\/\//.test(e),"Must be a valid URL"),e):"https://api.openai.com"},OPENAI_PATH(e){return e||"/v1/chat/completions"},HUGGINGFACE_COOKIE(e){return e||""},HUGGINGFACE_MODEL(e){return!e||e.length===0?"CohereForAI/c4ai-command-r-plus":(C("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(e),"Invalid model type of HuggingFace chat"),e)},GEMINI_KEY(e){return e||""},GEMINI_MODEL(e){return!e||e.length===0?"gemini-1.5-pro":(C("GEMINI_MODEL",["gemini-1.5-flash","gemini-1.5-pro","gemini-1.5-pro-exp-0801"].includes(e),"Invalid model type of Gemini"),e)},ANTHROPIC_MODEL(e){return!e||e.length===0?"claude-3-haiku-20240307":(C("ANTHROPIC_MODEL",["claude-3-haiku-20240307","claude-3-sonnet-20240229","claude-3-opus-20240229","claude-3-5-sonnet-20240620"].includes(e),"Invalid model type of Anthropic"),e)},ANTHROPIC_KEY(e){return e||""},MISTRAL_KEY(e){return e||""},MISTRAL_MODEL(e){return!e||e.length===0?"mistral-tiny":(C("MISTRAL_MODEL",["open-mistral-7b","mistral-tiny-2312","mistral-tiny","open-mixtral-8x7b","mistral-small-2312","mistral-small","mistral-small-2402","mistral-small-latest","mistral-medium-latest","mistral-medium-2312","mistral-medium","mistral-large-latest","mistral-large-2402","mistral-embed"].includes(e),"Invalid model type of Mistral AI"),e)},CODESTRAL_KEY(e){return e||""},CODESTRAL_MODEL(e){return!e||e.length===0?"codestral-latest":(C("CODESTRAL_MODEL",["codestral-latest","codestral-2405"].includes(e),"Invalid model type of Codestral"),e)},OLLAMA_MODEL(e){return e?(typeof e=="string"?e?.split(","):e).map(r=>r.trim()).filter(r=>!!r&&r.length>0):[]},OLLAMA_HOST(e){return e?(C("OLLAMA_HOST",/^https?:\/\//.test(e),"Must be a valid URL"),e):Et},OLLAMA_TIMEOUT(e){if(!e)return 1e5;C("OLLAMA_TIMEOUT",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return C("OLLAMA_TIMEOUT",t>=500,"Must be greater than 500ms"),t},OLLAMA_STREAM(e){return e?typeof e=="boolean"?e:(C("OLLAMA_STREAM",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"):!1},COHERE_KEY(e){return e||""},COHERE_MODEL(e){return!e||e.length===0?"command":(C("COHERE_MODEL",["command","command-nightly","command-light","command-light-nightly"].includes(e),"Invalid model type of Cohere"),e)},GROQ_KEY(e){return e||""},GROQ_MODEL(e){return!e||e.length===0?"gemma2-9b-it":(C("GROQ_MODEL",["gemma2-9b-it","gemma-7b-it","llama-3.1-70b-versatile","llama-3.1-8b-instant","llama3-70b-8192","llama3-8b-8192","llama3-groq-70b-8192-tool-use-preview","llama3-groq-8b-8192-tool-use-preview"].includes(e),"Invalid model type of Groq"),e)}},yt=P.join(je.homedir(),".aicommit2"),nn=async()=>{if(!await en(yt))return Object.create(null);const t=await O.readFile(yt,"utf8");let r=Zr.parse(t);return Ft(r,"OLLAMA_MODEL")&&(r={...r,OLLAMA_MODEL:typeof r.OLLAMA_MODEL=="string"?[r.OLLAMA_MODEL]:r.OLLAMA_MODEL}),r},bt=async(e,t)=>{const r=await nn(),n={},o={...tn,...rn};for(const s of Object.keys(o)){const u=o[s],i=e?.[s]??r[s];if(t)try{n[s]=u(i)}catch{}else n[s]=u(i)}return n},qi=async e=>{const t=await nn(),r={...tn,...rn};for(const[n,o]of e){if(!Ft(r,n))throw new F(`Invalid config property: ${n}`);const s=r[n](o);t[n]=s}await O.writeFile(yt,Zr.stringify(t),"utf8")};class zi extends U{constructor(t){super(t),this.params=t,this.host=Et,this.model="",this.handleError$=r=>{if(r.response&&r.response.data?.error)return x({name:`${this.errorPrefix} ${r.response.data?.error}`,value:r.response.data?.error,isError:!0,disabled:!0});const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return x({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#FFF",secondary:"#000"},this.model=this.params.keyName,this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[${zr(this.model)}]`),this.errorPrefix=g.red.bold(`[${zr(this.model)}]`),this.host=this.params.config.OLLAMA_HOST||Et,this.ollama=new qn({host:this.host})}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{await this.checkIsAvailableOllama();const t=await this.createChatCompletions(),{type:r,generate:n,logging:o}=this.params.config,s=this.createSystemPrompt();return o&&K(`Ollama_${this.model}`,this.params.stagedDiff.diff,s,t),this.sanitizeMessage(t,r,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async checkIsAvailableOllama(){try{return(await new Se({method:"GET",baseURL:`${this.host}`,timeout:this.params.config.OLLAMA_TIMEOUT}).execute()).data}catch(t){throw t.code==="ECONNREFUSED"?new F(`Error connecting to ${this.host}. Please run Ollama or check host`):t}}async createChatCompletions(){const t=this.createSystemPrompt();return(await this.ollama.chat({model:this.model,messages:[{role:"system",content:t},{role:"user",content:`Here are diff: ${this.params.stagedDiff.diff}`}],stream:!1,options:{temperature:this.params.config.temperature}})).message.content}createSystemPrompt(){const t={...W,locale:this.params.config.locale,maxLength:this.params.config["max-length"],type:this.params.config.type,generate:this.params.config.generate,promptPath:this.params.config.promptPath};return`${re(t)}`}}var wt={},At={exports:{}},de={exports:{}},vt,on;function Yi(){if(on)return vt;on=1;var e=1e3,t=e*60,r=t*60,n=r*24,o=n*7,s=n*365.25;vt=function(f,a){a=a||{};var D=typeof f;if(D==="string"&&f.length>0)return u(f);if(D==="number"&&isFinite(f))return a.long?c(f):i(f);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(f))};function u(f){if(f=String(f),!(f.length>100)){var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(f);if(a){var D=parseFloat(a[1]),p=(a[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return D*s;case"weeks":case"week":case"w":return D*o;case"days":case"day":case"d":return D*n;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*t;case"seconds":case"second":case"secs":case"sec":case"s":return D*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return D;default:return}}}}function i(f){var a=Math.abs(f);return a>=n?Math.round(f/n)+"d":a>=r?Math.round(f/r)+"h":a>=t?Math.round(f/t)+"m":a>=e?Math.round(f/e)+"s":f+"ms"}function c(f){var a=Math.abs(f);return a>=n?l(f,a,n,"day"):a>=r?l(f,a,r,"hour"):a>=t?l(f,a,t,"minute"):a>=e?l(f,a,e,"second"):f+" ms"}function l(f,a,D,p){var d=a>=D*1.5;return Math.round(f/D)+" "+p+(d?"s":"")}return vt}var $t,sn;function un(){if(sn)return $t;sn=1;function e(t){n.debug=n,n.default=n,n.coerce=l,n.disable=u,n.enable=s,n.enabled=i,n.humanize=Yi(),n.destroy=f,Object.keys(t).forEach(a=>{n[a]=t[a]}),n.names=[],n.skips=[],n.formatters={};function r(a){let D=0;for(let p=0;p<a.length;p++)D=(D<<5)-D+a.charCodeAt(p),D|=0;return n.colors[Math.abs(D)%n.colors.length]}n.selectColor=r;function n(a){let D,p=null,d,h;function m(...E){if(!m.enabled)return;const b=m,A=Number(new Date),R=A-(D||A);b.diff=R,b.prev=D,b.curr=A,D=A,E[0]=n.coerce(E[0]),typeof E[0]!="string"&&E.unshift("%O");let N=0;E[0]=E[0].replace(/%([a-zA-Z%])/g,(w,ue)=>{if(w==="%%")return"%";N++;const Nt=n.formatters[ue];if(typeof Nt=="function"){const An=E[N];w=Nt.call(b,An),E.splice(N,1),N--}return w}),n.formatArgs.call(b,E),(b.log||n.log).apply(b,E)}return m.namespace=a,m.useColors=n.useColors(),m.color=n.selectColor(a),m.extend=o,m.destroy=n.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(d!==n.namespaces&&(d=n.namespaces,h=n.enabled(a)),h),set:E=>{p=E}}),typeof n.init=="function"&&n.init(m),m}function o(a,D){const p=n(this.namespace+(typeof D>"u"?":":D)+a);return p.log=this.log,p}function s(a){n.save(a),n.namespaces=a,n.names=[],n.skips=[];let D;const p=(typeof a=="string"?a:"").split(/[\s,]+/),d=p.length;for(D=0;D<d;D++)p[D]&&(a=p[D].replace(/\*/g,".*?"),a[0]==="-"?n.skips.push(new RegExp("^"+a.slice(1)+"$")):n.names.push(new RegExp("^"+a+"$")))}function u(){const a=[...n.names.map(c),...n.skips.map(c).map(D=>"-"+D)].join(",");return n.enable(""),a}function i(a){if(a[a.length-1]==="*")return!0;let D,p;for(D=0,p=n.skips.length;D<p;D++)if(n.skips[D].test(a))return!1;for(D=0,p=n.names.length;D<p;D++)if(n.names[D].test(a))return!0;return!1}function c(a){return a.toString().substring(2,a.toString().length-2).replace(/\.\*\?$/,"*")}function l(a){return a instanceof Error?a.stack||a.message:a}function f(){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 n.enable(n.load()),n}return $t=e,$t}de.exports;var an;function Wi(){return an||(an=1,function(e,t){t.formatArgs=n,t.save=o,t.load=s,t.useColors=r,t.storage=u(),t.destroy=(()=>{let c=!1;return()=>{c||(c=!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`."))}})(),t.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(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1: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&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;c.splice(1,0,l,"color: inherit");let f=0,a=0;c[0].replace(/%[a-zA-Z%]/g,D=>{D!=="%%"&&(f++,D==="%c"&&(a=f))}),c.splice(a,0,l)}t.log=console.debug||console.log||(()=>{});function o(c){try{c?t.storage.setItem("debug",c):t.storage.removeItem("debug")}catch{}}function s(){let c;try{c=t.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c}function u(){try{return localStorage}catch{}}e.exports=un()(t);const{formatters:i}=e.exports;i.j=function(c){try{return JSON.stringify(c)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(de,de.exports)),de.exports}var me={exports:{}},Bt,cn;function Ji(){return cn||(cn=1,Bt=(e,t=process.argv)=>{const r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),o=t.indexOf("--");return n!==-1&&(o===-1||n<o)}),Bt}var Ot,Dn;function Vi(){if(Dn)return Ot;Dn=1;const e=je,t=Le,r=Ji(),{env:n}=process;let o;r("no-color")||r("no-colors")||r("color=false")||r("color=never")?o=0:(r("color")||r("colors")||r("color=true")||r("color=always"))&&(o=1),"FORCE_COLOR"in n&&(n.FORCE_COLOR==="true"?o=1:n.FORCE_COLOR==="false"?o=0:o=n.FORCE_COLOR.length===0?1:Math.min(parseInt(n.FORCE_COLOR,10),3));function s(c){return c===0?!1:{level:c,hasBasic:!0,has256:c>=2,has16m:c>=3}}function u(c,l){if(o===0)return 0;if(r("color=16m")||r("color=full")||r("color=truecolor"))return 3;if(r("color=256"))return 2;if(c&&!l&&o===void 0)return 0;const f=o||0;if(n.TERM==="dumb")return f;if(process.platform==="win32"){const a=e.release().split(".");return Number(a[0])>=10&&Number(a[2])>=10586?Number(a[2])>=14931?3:2:1}if("CI"in n)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(a=>a in n)||n.CI_NAME==="codeship"?1:f;if("TEAMCITY_VERSION"in n)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(n.TEAMCITY_VERSION)?1:0;if(n.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in n){const a=parseInt((n.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(n.TERM_PROGRAM){case"iTerm.app":return a>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(n.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(n.TERM)||"COLORTERM"in n?1:f}function i(c){const l=u(c,c&&c.isTTY);return s(l)}return Ot={supportsColor:i,stdout:s(u(!0,t.isatty(1))),stderr:s(u(!0,t.isatty(2)))},Ot}me.exports;var ln;function Xi(){return ln||(ln=1,function(e,t){const r=Le,n=Kt;t.init=f,t.log=i,t.formatArgs=s,t.save=c,t.load=l,t.useColors=o,t.destroy=n.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const D=Vi();D&&(D.stderr||D).level>=2&&(t.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{}t.inspectOpts=Object.keys(process.env).filter(D=>/^debug_/i.test(D)).reduce((D,p)=>{const d=p.substring(6).toLowerCase().replace(/_([a-z])/g,(m,E)=>E.toUpperCase());let h=process.env[p];return/^(yes|on|true|enabled)$/i.test(h)?h=!0:/^(no|off|false|disabled)$/i.test(h)?h=!1:h==="null"?h=null:h=Number(h),D[d]=h,D},{});function o(){return"colors"in t.inspectOpts?!!t.inspectOpts.colors:r.isatty(process.stderr.fd)}function s(D){const{namespace:p,useColors:d}=this;if(d){const h=this.color,m="\x1B[3"+(h<8?h:"8;5;"+h),E=` ${m};1m${p} \x1B[0m`;D[0]=E+D[0].split(`
|
|
83
83
|
`).join(`
|
|
84
84
|
`+E),D.push(m+"m+"+e.exports.humanize(this.diff)+"\x1B[0m")}else D[0]=u()+p+" "+D[0]}function u(){return t.inspectOpts.hideDate?"":new Date().toISOString()+" "}function i(...D){return process.stderr.write(n.formatWithOptions(t.inspectOpts,...D)+`
|
|
85
85
|
`)}function c(D){D?process.env.DEBUG=D:delete process.env.DEBUG}function l(){return process.env.DEBUG}function f(D){D.inspectOpts={};const p=Object.keys(t.inspectOpts);for(let d=0;d<p.length;d++)D.inspectOpts[p[d]]=t.inspectOpts[p[d]]}e.exports=un()(t);const{formatters:a}=e.exports;a.o=function(D){return this.inspectOpts.colors=this.useColors,n.inspect(D,this.inspectOpts).split(`
|
|
86
|
-
`).map(p=>p.trim()).join(" ")},a.O=function(D){return this.inspectOpts.colors=this.useColors,n.inspect(D,this.inspectOpts)}}(me,me.exports)),me.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?
|
|
86
|
+
`).map(p=>p.trim()).join(" ")},a.O=function(D){return this.inspectOpts.colors=this.useColors,n.inspect(D,this.inspectOpts)}}(me,me.exports)),me.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?At.exports=Wi():At.exports=Xi();var xt=At.exports,Mt={};Object.defineProperty(Mt,"__esModule",{value:!0});function Qi(e){return function(t,r){return new Promise((n,o)=>{e.call(this,t,r,(s,u)=>{s?o(s):n(u)})})}}Mt.default=Qi;var fn=v&&v.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const Zi=Ut,ea=fn(xt),ta=fn(Mt),he=ea.default("agent-base");function ra(e){return!!e&&typeof e.addRequest=="function"}function St(){const{stack:e}=new Error;return typeof e!="string"?!1:e.split(`
|
|
87
87
|
`).some(t=>t.indexOf("(https.js:")!==-1||t.indexOf("node:https:")!==-1)}function _e(e,t){return new _e.Agent(e,t)}(function(e){class t extends Zi.EventEmitter{constructor(n,o){super();let s=o;typeof n=="function"?this.callback=n:n&&(s=n),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:St()?443:80}set defaultPort(n){this.explicitDefaultPort=n}get protocol(){return typeof this.explicitProtocol=="string"?this.explicitProtocol:St()?"https:":"http:"}set protocol(n){this.explicitProtocol=n}callback(n,o,s){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(n,o){const s=Object.assign({},o);typeof s.secureEndpoint!="boolean"&&(s.secureEndpoint=St()),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,n._last=!0,n.shouldKeepAlive=!1;let u=!1,i=null;const c=s.timeout||this.timeout,l=p=>{n._hadError||(n.emit("error",p),n._hadError=!0)},f=()=>{i=null,u=!0;const p=new Error(`A "socket" was not created for HTTP request before ${c}ms`);p.code="ETIMEOUT",l(p)},a=p=>{u||(i!==null&&(clearTimeout(i),i=null),l(p))},D=p=>{if(u)return;if(i!=null&&(clearTimeout(i),i=null),ra(p)){he("Callback returned another Agent instance %o",p.constructor.name),p.addRequest(n,s);return}if(p){p.once("free",()=>{this.freeSocket(p,s)}),n.onSocket(p);return}const d=new Error(`no Duplex stream was returned to agent-base for \`${n.method} ${n.path}\``);l(d)};if(typeof this.callback!="function"){l(new Error("`callback` is not defined"));return}this.promisifiedCallback||(this.callback.length>=3?(he("Converting legacy callback function to promise"),this.promisifiedCallback=ta.default(this.callback)):this.promisifiedCallback=this.callback),typeof c=="number"&&c>0&&(i=setTimeout(f,c)),"port"in s&&typeof s.port!="number"&&(s.port=Number(s.port));try{he("Resolving socket for %o request: %o",s.protocol,`${n.method} ${n.path}`),Promise.resolve(this.promisifiedCallback(n,s)).then(D,a)}catch(p){Promise.reject(p).catch(a)}}freeSocket(n,o){he("Freeing socket %o %o",n.constructor.name,o),n.destroy()}destroy(){he("Destroying agent %o",this.constructor.name)}}e.Agent=t,e.prototype=e.Agent.prototype})(_e||(_e={}));var na=_e,Pt={},oa=v&&v.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Pt,"__esModule",{value:!0});const sa=oa(xt),ge=sa.default("https-proxy-agent:parse-proxy-response");function ua(e){return new Promise((t,r)=>{let n=0;const o=[];function s(){const a=e.read();a?f(a):e.once("readable",s)}function u(){e.removeListener("end",c),e.removeListener("error",l),e.removeListener("close",i),e.removeListener("readable",s)}function i(a){ge("onclose had error %o",a)}function c(){ge("onend")}function l(a){u(),ge("onerror %o",a),r(a)}function f(a){o.push(a),n+=a.length;const D=Buffer.concat(o,n);if(D.indexOf(`\r
|
|
88
88
|
\r
|
|
89
89
|
`)===-1){ge("have not received end of HTTP headers yet..."),s();return}const d=D.toString("ascii",0,D.indexOf(`\r
|
|
90
|
-
`)),h=+d.split(" ")[1];ge("got proxy server response: %o",d),t({statusCode:h,buffered:D})}e.on("error",l),e.on("close",i),e.on("end",c),s()})}Pt.default=ua;var ia=v&&v.__awaiter||function(e,t,r,n){function o(s){return s instanceof r?s:new r(function(u){u(s)})}return new(r||(r=Promise))(function(s,u){function i(f){try{l(n.next(f))}catch(a){u(a)}}function c(f){try{l(n.throw(f))}catch(a){u(a)}}function l(f){f.done?s(f.value):o(f.value).then(i,c)}l((n=n.apply(e,t||[])).next())})},oe=v&&v.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(
|
|
90
|
+
`)),h=+d.split(" ")[1];ge("got proxy server response: %o",d),t({statusCode:h,buffered:D})}e.on("error",l),e.on("close",i),e.on("end",c),s()})}Pt.default=ua;var ia=v&&v.__awaiter||function(e,t,r,n){function o(s){return s instanceof r?s:new r(function(u){u(s)})}return new(r||(r=Promise))(function(s,u){function i(f){try{l(n.next(f))}catch(a){u(a)}}function c(f){try{l(n.throw(f))}catch(a){u(a)}}function l(f){f.done?s(f.value):o(f.value).then(i,c)}l((n=n.apply(e,t||[])).next())})},oe=v&&v.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(wt,"__esModule",{value:!0});const pn=oe(Wn),dn=oe(Jn),aa=oe(Vn),ca=oe(Ht),Da=oe(xt),la=na,fa=oe(Pt),Ce=Da.default("https-proxy-agent:agent");class pa extends la.Agent{constructor(t){let r;if(typeof t=="string"?r=aa.default.parse(t):r=t,!r)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");Ce("creating new HttpsProxyAgent instance: %o",r),super(r);const n=Object.assign({},r);this.secureProxy=r.secureProxy||ha(n.protocol),n.host=n.hostname||n.host,typeof n.port=="string"&&(n.port=parseInt(n.port,10)),!n.port&&n.host&&(n.port=this.secureProxy?443:80),this.secureProxy&&!("ALPNProtocols"in n)&&(n.ALPNProtocols=["http 1.1"]),n.host&&n.path&&(delete n.path,delete n.pathname),this.proxy=n}callback(t,r){return ia(this,void 0,void 0,function*(){const{proxy:n,secureProxy:o}=this;let s;o?(Ce("Creating `tls.Socket`: %o",n),s=dn.default.connect(n)):(Ce("Creating `net.Socket`: %o",n),s=pn.default.connect(n));const u=Object.assign({},n.headers);let c=`CONNECT ${`${r.host}:${r.port}`} HTTP/1.1\r
|
|
91
91
|
`;n.auth&&(u["Proxy-Authorization"]=`Basic ${Buffer.from(n.auth).toString("base64")}`);let{host:l,port:f,secureEndpoint:a}=r;ma(f,a)||(l+=`:${f}`),u.Host=l,u.Connection="close";for(const m of Object.keys(u))c+=`${m}: ${u[m]}\r
|
|
92
92
|
`;const D=fa.default(s);s.write(`${c}\r
|
|
93
|
-
`);const{statusCode:p,buffered:d}=yield D;if(p===200){if(t.once("socket",da),r.secureEndpoint){Ce("Upgrading socket connection to TLS");const m=r.servername||r.host;return dn.default.connect(Object.assign(Object.assign({},ga(r,"host","hostname","path","port")),{socket:s,servername:m}))}return s}s.destroy();const h=new pn.default.Socket({writable:!1});return h.readable=!0,t.once("socket",m=>{Ce("replaying proxy buffer for failed request"),ca.default(m.listenerCount("data")>0),m.push(d),m.push(null)}),h})}}
|
|
93
|
+
`);const{statusCode:p,buffered:d}=yield D;if(p===200){if(t.once("socket",da),r.secureEndpoint){Ce("Upgrading socket connection to TLS");const m=r.servername||r.host;return dn.default.connect(Object.assign(Object.assign({},ga(r,"host","hostname","path","port")),{socket:s,servername:m}))}return s}s.destroy();const h=new pn.default.Socket({writable:!1});return h.readable=!0,t.once("socket",m=>{Ce("replaying proxy buffer for failed request"),ca.default(m.listenerCount("data")>0),m.push(d),m.push(null)}),h})}}wt.default=pa;function da(e){e.resume()}function ma(e,t){return!!(!t&&e===80||t&&e===443)}function ha(e){return typeof e=="string"?/^https:?$/i.test(e):!1}function ga(e,...t){const r={};let n;for(n in e)t.includes(n)||(r[n]=e[n]);return r}var Ca=v&&v.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const It=Ca(wt);function _t(e){return new It.default(e)}(function(e){e.HttpsProxyAgent=It.default,e.prototype=It.default.prototype})(_t||(_t={}));var Ea=_t,Fa=V(Ea);const ya=async(e,t,r,n,o,s,u)=>new Promise((i,c)=>{const l=JSON.stringify(n),a=(e.protocol.includes("https")?Yn:zn).request({port:u||void 0,hostname:e.hostname,path:t,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(l),...r},timeout:o,agent:s?Fa(s):void 0},D=>{const p=[];D.on("data",d=>p.push(d)),D.on("end",()=>{i({request:a,response:D,data:Buffer.concat(p).toString()})})});a.on("error",c),a.on("timeout",()=>{a.destroy(),c(new F(`Time out error: request took over ${o}ms. Try increasing the \`timeout\` config`))}),a.write(l),a.end()}),ba=async(e,t,r,n,o,s)=>{const u=new URL(e),{response:i,data:c}=await ya(u,t,{Authorization:`Bearer ${r}`},n,o,s);if(!i.statusCode||i.statusCode<200||i.statusCode>299){let l=`OpenAI API Error: ${i.statusCode} - ${i.statusMessage}`;throw c&&(l+=`
|
|
94
94
|
|
|
95
95
|
${c}`),i.statusCode===500&&(l+=`
|
|
96
96
|
|
|
97
|
-
Check the API status: https://status.openai.com`),new F(l)}return JSON.parse(c)},
|
|
98
|
-
`)[0];const o=this.extractJSONFromError(r.message);n+=`: ${o.error.message}`}return x({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#74AA9C",secondary:"#FFF"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[ChatGPT]"),this.errorPrefix=g.red.bold("[ChatGPT]")}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}extractJSONFromError(t){const r=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,n=t.match(r);return n?Object.assign({},...n.map(o=>JSON.parse(o))):{error:{message:"Unknown error"}}}async generateMessage(){const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o}=this.params.config,s=this.params.config["max-length"],u=await
|
|
97
|
+
Check the API status: https://status.openai.com`),new F(l)}return JSON.parse(c)},wa=e=>e.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1"),Aa=async(e,t,r,n,o,s,u,i,c,l,f,a,D,p,d)=>{try{const h={...W,locale:o,maxLength:i,type:c,generate:u,promptPath:D},m=re(h),b=(await ba(e,t,r,{model:n,messages:[{role:"system",content:`${m}`},{role:"user",content:`Here are diff: ${s}`}],temperature:a,top_p:1,frequency_penalty:0,presence_penalty:0,max_tokens:f,stream:!1},l,d)).choices.filter(A=>A.message?.content).map(A=>wa(A.message.content)).join();return p&&K("OPEN AI",s,m,b),b}catch(h){const m=h;throw m.code==="ENOTFOUND"?new F(`Error connecting to ${m.hostname} (${m.syscall})`):m}};class va extends U{constructor(t){super(t),this.params=t,this.handleError$=r=>{let n="An error occurred";if(r.message){n=r.message.split(`
|
|
98
|
+
`)[0];const o=this.extractJSONFromError(r.message);n+=`: ${o.error.message}`}return x({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#74AA9C",secondary:"#FFF"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[ChatGPT]"),this.errorPrefix=g.red.bold("[ChatGPT]")}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}extractJSONFromError(t){const r=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,n=t.match(r);return n?Object.assign({},...n.map(o=>JSON.parse(o))):{error:{message:"Unknown error"}}}async generateMessage(){const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o}=this.params.config,s=this.params.config["max-length"],u=await Aa(this.params.config.OPENAI_URL,this.params.config.OPENAI_PATH,this.params.config.OPENAI_KEY,this.params.config.OPENAI_MODEL,r,t,n,s,o,this.params.config.timeout,this.params.config["max-tokens"],this.params.config.temperature,this.params.config.prompt,this.params.config.logging,this.params.config.proxy);return this.sanitizeMessage(u,this.params.config.type,n,this.params.config.ignoreBody)}}class mn{constructor(t,r){this.config=t,this.stagedDiff=r}createAIRequests$(t){return S(t).pipe(qt(r=>{const n={config:this.config,stagedDiff:this.stagedDiff,keyName:r};switch(r){case M.OPEN_AI:return H.create(va,n).generateCommitMessage$();case M.GEMINI:return H.create(Ni,n).generateCommitMessage$();case M.ANTHROPIC:return H.create(Ti,n).generateCommitMessage$();case M.HUGGINGFACE:return H.create(ji,n).generateCommitMessage$();case M.MISTRAL:return H.create(Gi,n).generateCommitMessage$();case M.CODESTRAL:return H.create(Li,n).generateCommitMessage$();case M.OLLAMA:return S(this.config.OLLAMA_MODEL).pipe(qt(s=>{const u={...n,keyName:s};return H.create(zi,u).generateCommitMessage$()}));case M.COHERE:return H.create(Ri,n).generateCommitMessage$();case M.GROQ:return H.create(ki,n).generateCommitMessage$();default:const o=g.red.bold(`[${r}]`);return x({name:o+" Invalid AI type",value:"Invalid AI type",isError:!0,disabled:!0})}}),T(r=>{const n=g.red.bold("[UNKNOWN]");return x({name:n+` ${r.message||""}`,value:"Unknown error",isError:!0,disabled:!0})}))}}const hn=async()=>{const{stdout:e,failed:t}=await te("git",["rev-parse","--show-toplevel"],{reject:!1});if(t)throw new F("The current directory must be a Git repository!");return e},Tt=e=>`:(exclude)${e}`,gn=["package-lock.json","pnpm-lock.yaml","*.lock","*.gif","*.png"].map(Tt),Cn=async e=>{const t=["diff","--cached","--diff-algorithm=minimal"],{stdout:r}=await te("git",[...t,"--name-only",...gn,...e?e.map(Tt):[]]);if(!r)return null;const{stdout:n}=await te("git",[...t,...gn,...e?e.map(Tt):[]]);return{files:r.split(`
|
|
99
99
|
`),diff:n}},$a=e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`;class Ee{constructor(){this.title="aicommit2"}printTitle(){console.log(Zn.textSync(this.title,{font:"Small"}))}displaySpinner(t){return ke(t).start()}stopSpinner(t){t.stop(),t.clear()}printStagedFiles(t){console.log(g.bold.green("\u2714 ")+g.bold(`${$a(t.files)}:`)),console.log(`${t.files.map(r=>` ${r}`).join(`
|
|
100
100
|
`)}
|
|
101
101
|
`)}printAnalyzed(){console.log(`
|
|
@@ -104,7 +104,7 @@ ${g.bold.green("\u2714")} ${g.bold("Successfully committed!")}`)}printCopied(){c
|
|
|
104
104
|
${g.bold.green("\u2714")} ${g.bold("Successfully copied! Press 'Ctrl + V' to paste")}`)}printSavedCommitMessage(){console.log(`
|
|
105
105
|
${g.bold.green("\u2714")} ${g.bold("Saved commit message")}`)}printCancelledCommit(){console.log(`
|
|
106
106
|
${g.bold.yellow("\u26A0")} ${g.yellow("Commit cancelled")}`)}printErrorMessage(t){console.log(`
|
|
107
|
-
${g.bold.red("\u2716")} ${g.red(`${t}`)}`)}moveCursorUp(){const t=Fe.createInterface({input:process.stdin,output:process.stdout});Fe.moveCursor(process.stdout,0,-1),t.close()}moveCursorDown(){const t=Fe.createInterface({input:process.stdin,output:process.stdout});Fe.moveCursor(process.stdout,0,1),t.close()}}const Ba={isLoading:!1,startOption:{text:"AI is analyzing your changes"}},Lt="No commit messages were generated";class Oa{constructor(){this.choices$=new zt([]),this.loader$=new zt(Ba),this.destroyed$=new _n(1)}initPrompt(t){return Ne.registerPrompt("reactiveListPrompt",eo),Ne.prompt({type:"reactiveListPrompt",name:"aicommit2Prompt",message:"Pick a commit message to use: ",emptyMessage:`\u26A0 ${Lt}`,loop:!1,showDescription:t,descPageSize:10,choices$:this.choices$,loader$:this.loader$})}startLoader(){this.loader$.next({isLoading:!0})}refreshChoices(t){const{value:r,isError:n}=t;if(!t||!r)return;if(!t.id){this.choices$.next([...this.currentChoices,t].sort(pe));return}this.checkStreamChoice(t)}checkErrorOnChoices(){if(this.choices$.getValue().map(r=>r).every(r=>r?.isError||r?.disabled)){this.alertNoGeneratedMessage(),this.logEmptyCommitMessage(),process.exit(1);return}this.stopLoaderOnSuccess()}completeSubject(){this.choices$.complete(),this.loader$.complete(),this.destroyed$.next(!0),this.destroyed$.complete()}alertNoGeneratedMessage(){this.loader$.next({isLoading:!1,message:Lt,stopOption:{doneFrame:"\u26A0",color:"yellow"}})}stopLoaderOnSuccess(){this.loader$.next({isLoading:!1,message:"Changes analyzed"})}logEmptyCommitMessage(){console.log(`${g.bold.yellow("\u26A0")} ${g.yellow(`${Lt}`)}`)}checkStreamChoice(t){if(t.description===Mi){const o=this.currentChoices.find(s=>{const u=s.id||"",i=/\d/.test(u);return t.id?.includes(u)&&!i});if(o){this.choices$.next([...this.currentChoices.filter(s=>s.id!==o.id),t].sort(pe));return}this.choices$.next([...this.currentChoices,t].sort(pe));return}if(this.currentChoices.find(o=>o?.id===t.id)){this.choices$.next(this.currentChoices.map(o=>o?.id===t.id?t:o).sort(pe));return}this.choices$.next([...this.currentChoices,t].sort(pe))}get currentChoices(){return this.choices$.getValue().map(t=>t)}}const q=new Ee;var xa=async(e,t,r,n,o,s,u,i,c)=>(async()=>{q.printTitle(),await hn(),n&&await te("git",["add","--update"]);const l=q.displaySpinner("Detecting staged files"),f=await Cn(r);if(l.stop(),!f)throw new F("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");q.printStagedFiles(f);const{env:a}=process,D=await bt({OPENAI_KEY:a.OPENAI_KEY||a.OPENAI_API_KEY,OPENAI_MODEL:a.OPENAI_MODEL||a["openai-model"]||a.openai_model,OPENAI_URL:a.OPENAI_URL||a["openai-url"]||a.OPENAI_URL,GEMINI_KEY:a.GEMINI_KEY||a.GEMINI_API_KEY,GEMINI_MODEL:a.GEMINI_MODEL||a["gemini-model"]||a.gemini_model,ANTHROPIC_KEY:a.ANTHROPIC_KEY||a.ANTHROPIC_API_KEY,ANTHROPIC_MODEL:a.ANTHROPIC_MODEL||a["anthropic-model"]||a.anthropic_model,HUGGINGFACE_MODEL:a.HUGGINGFACE_MODEL,MISTRAL_KEY:a.MISTRAL_KEY||a.MISTRAL_API_KEY,CODESTRAL_KEY:a.CODESTRAL_KEY||a.CODESTRAL_API_KEY,MISTRAL_MODEL:a.MISTRAL_MODEL||a["mistral-model"]||a.mistral_model,proxy:a.https_proxy||a.HTTPS_PROXY||a.http_proxy||a.HTTP_PROXY,temperature:a.temperature,generate:t?.toString()||a.generate,type:o?.toString()||a.type,locale:e?.toString()||a.locale,promptPath:i?.toString()||a.promptPath});if(D.promptPath)try{k.readFileSync(P.resolve(D.promptPath),"utf-8")}catch{throw new F(`Error reading user prompt file: ${D.promptPath}`)}const p=Object.entries(D).filter(([
|
|
107
|
+
${g.bold.red("\u2716")} ${g.red(`${t}`)}`)}moveCursorUp(){const t=Fe.createInterface({input:process.stdin,output:process.stdout});Fe.moveCursor(process.stdout,0,-1),t.close()}moveCursorDown(){const t=Fe.createInterface({input:process.stdin,output:process.stdout});Fe.moveCursor(process.stdout,0,1),t.close()}}const Ba={isLoading:!1,startOption:{text:"AI is analyzing your changes"}},Lt="No commit messages were generated";class Oa{constructor(){this.choices$=new zt([]),this.loader$=new zt(Ba),this.destroyed$=new _n(1)}initPrompt(t){return Ne.registerPrompt("reactiveListPrompt",eo),Ne.prompt({type:"reactiveListPrompt",name:"aicommit2Prompt",message:"Pick a commit message to use: ",emptyMessage:`\u26A0 ${Lt}`,loop:!1,showDescription:t,descPageSize:10,choices$:this.choices$,loader$:this.loader$})}startLoader(){this.loader$.next({isLoading:!0})}refreshChoices(t){const{value:r,isError:n}=t;if(!t||!r)return;if(!t.id){this.choices$.next([...this.currentChoices,t].sort(pe));return}this.checkStreamChoice(t)}checkErrorOnChoices(){if(this.choices$.getValue().map(r=>r).every(r=>r?.isError||r?.disabled)){this.alertNoGeneratedMessage(),this.logEmptyCommitMessage(),process.exit(1);return}this.stopLoaderOnSuccess()}completeSubject(){this.choices$.complete(),this.loader$.complete(),this.destroyed$.next(!0),this.destroyed$.complete()}alertNoGeneratedMessage(){this.loader$.next({isLoading:!1,message:Lt,stopOption:{doneFrame:"\u26A0",color:"yellow"}})}stopLoaderOnSuccess(){this.loader$.next({isLoading:!1,message:"Changes analyzed"})}logEmptyCommitMessage(){console.log(`${g.bold.yellow("\u26A0")} ${g.yellow(`${Lt}`)}`)}checkStreamChoice(t){if(t.description===Mi){const o=this.currentChoices.find(s=>{const u=s.id||"",i=/\d/.test(u);return t.id?.includes(u)&&!i});if(o){this.choices$.next([...this.currentChoices.filter(s=>s.id!==o.id),t].sort(pe));return}this.choices$.next([...this.currentChoices,t].sort(pe));return}if(this.currentChoices.find(o=>o?.id===t.id)){this.choices$.next(this.currentChoices.map(o=>o?.id===t.id?t:o).sort(pe));return}this.choices$.next([...this.currentChoices,t].sort(pe))}get currentChoices(){return this.choices$.getValue().map(t=>t)}}const q=new Ee;var xa=async(e,t,r,n,o,s,u,i,c)=>(async()=>{q.printTitle(),await hn(),n&&await te("git",["add","--update"]);const l=q.displaySpinner("Detecting staged files"),f=await Cn(r);if(l.stop(),!f)throw new F("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");q.printStagedFiles(f);const{env:a}=process,D=await bt({OPENAI_KEY:a.OPENAI_KEY||a.OPENAI_API_KEY,OPENAI_MODEL:a.OPENAI_MODEL||a["openai-model"]||a.openai_model,OPENAI_URL:a.OPENAI_URL||a["openai-url"]||a.OPENAI_URL,GEMINI_KEY:a.GEMINI_KEY||a.GEMINI_API_KEY,GEMINI_MODEL:a.GEMINI_MODEL||a["gemini-model"]||a.gemini_model,ANTHROPIC_KEY:a.ANTHROPIC_KEY||a.ANTHROPIC_API_KEY,ANTHROPIC_MODEL:a.ANTHROPIC_MODEL||a["anthropic-model"]||a.anthropic_model,HUGGINGFACE_MODEL:a.HUGGINGFACE_MODEL,MISTRAL_KEY:a.MISTRAL_KEY||a.MISTRAL_API_KEY,CODESTRAL_KEY:a.CODESTRAL_KEY||a.CODESTRAL_API_KEY,MISTRAL_MODEL:a.MISTRAL_MODEL||a["mistral-model"]||a.mistral_model,proxy:a.https_proxy||a.HTTPS_PROXY||a.http_proxy||a.HTTP_PROXY,temperature:a.temperature,generate:t?.toString()||a.generate,type:o?.toString()||a.type,locale:e?.toString()||a.locale,promptPath:i?.toString()||a.promptPath});if(D.promptPath)try{k.readFileSync(P.resolve(D.promptPath),"utf-8")}catch{throw new F(`Error reading user prompt file: ${D.promptPath}`)}const p=Object.entries(D).filter(([w])=>Kr.includes(w)).filter(([w,ue])=>w===M.OLLAMA?!!ue&&ue.length>0:!!ue).map(([w])=>w);if(p.length===0)throw new F("Please set at least one API key via the `aicommit2 config set` command");const h=new mn(D,f),m=new Oa,E=m.initPrompt(!D.ignoreBody);m.startLoader();const b=h.createAIRequests$(p).subscribe(w=>m.refreshChoices(w),()=>{},()=>m.checkErrorOnChoices()),A=await E;b.unsubscribe(),m.completeSubject(),q.moveCursorUp();const R=A.aicommit2Prompt?.value;if(!R)throw new F("An error occurred! No selected message");if(u&&(bs("copy-paste").copy(R),q.printCopied(),process.exit()),s){const w=ke("Committing with the generated message").start();await te("git",["commit","-m",R,...c]),w.stop(),w.clear(),q.printCommitted(),process.exit()}const N=await Ne.prompt([{type:"confirm",name:"confirmationPrompt",message:"Use selected message?",default:!0}]),{confirmationPrompt:se}=N;if(se){const w=ke("Committing with the generated message").start();await te("git",["commit","-m",R,...c]),w.stop(),w.clear(),q.printCommitted(),process.exit()}q.printCancelledCommit(),process.exit()})().catch(l=>{q.printErrorMessage(l.message),fe(l),process.exit(1)}),Ma=Je({name:"config",parameters:["<mode>","<key=value...>"]},e=>{(async()=>{const{mode:t,keyValue:r}=e._;if(t==="get"){const n=await bt({},!0);for(const o of r)Ft(n,o)&&console.log(`${o}=${n[o]}`);return}if(t==="set"){await qi(r.map(n=>n.split("=")));return}throw new F(`Invalid mode: ${t}`)})().catch(t=>{new Ee().printErrorMessage(t.message),fe(t),process.exit(1)})});const En="prepare-commit-msg",Fn=`.git/hooks/${En}`,Te=Xn(new URL("cli.mjs",import.meta.url)),Sa=process.argv[1].replace(/\\/g,"/").endsWith(`/${Fn}`),yn=process.platform==="win32",bn=`
|
|
108
108
|
#!/usr/bin/env node
|
|
109
109
|
import(${JSON.stringify(Qn(Te))})
|
|
110
110
|
`.trim();var Pa=Je({name:"hook",parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await hn(),{installUninstall:r}=e._,n=P.join(t,Fn),o=await en(n);if(r==="install"){if(o){if(await O.realpath(n).catch(()=>{})===Te){console.warn("The hook is already installed");return}throw new F(`A different ${En} hook seems to be installed. Please remove it before installing aicommit2.`)}await O.mkdir(P.dirname(n),{recursive:!0}),yn?await O.writeFile(n,bn):(await O.symlink(Te,n,"file"),await O.chmod(n,493)),console.log(`${g.green("\u2714")} Hook installed`);return}if(r==="uninstall"){if(!o){console.warn("Hook is not installed");return}if(yn){if(await O.readFile(n,"utf8")!==bn){console.warn("Hook is not installed");return}}else if(await O.realpath(n)!==Te){console.warn("Hook is not installed");return}await O.rm(n),console.log(`${g.green("\u2714")} Hook uninstalled`);return}throw new F(`Invalid mode: ${r}`)})().catch(t=>{console.error(`${g.red("\u2716")} ${t.message}`),fe(t),process.exit(1)})}),Ia=Je({name:"log",parameters:["<removeAll>"]},e=>{(async()=>{const{removeAll:t}=e._;if(t==="removeAll"){await to(Wr,{recursive:!0,force:!0}),console.log(`${g.green("\u2714")} All Log files are removed!`);return}throw new F(`Invalid mode: ${t}`)})().catch(t=>{new Ee().printErrorMessage(t.message),fe(t),process.exit(1)})});const[Rt,_a]=process.argv.slice(2);var Ta=()=>(async()=>{if(!Rt)throw new F('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(_a)return;const e=await Cn();if(!e)return;const t=new Ee;t.printTitle();const{env:r}=process,n=await bt({proxy:r.https_proxy||r.HTTPS_PROXY||r.http_proxy||r.HTTP_PROXY}),o=Object.entries(n).filter(([p])=>Kr.includes(p)).filter(([p,d])=>p===M.OLLAMA?!!d&&d.length>0:!!d).map(([p])=>p);if(o.length===0)throw new F("Please set at least one API key via `aicommit2 config set OPENAI_KEY=<your token>`");const u=new mn(n,e),i=t.displaySpinner("The AI is analyzing your changes");let c;try{c=await Tn(u.createAIRequests$(o).pipe(Ln(p=>!p.isError),_(p=>p.value),Rn()))}finally{i.stop(),i.clear(),t.printAnalyzed()}const f=await O.readFile(Rt,"utf8")!=="",a=c.length>1;let D="";f&&(D=`# \u{1F916} AI generated commit${a?"s":""}
|
|
@@ -114,4 +114,4 @@ ${c.map(p=>`# ${p}`).join(`
|
|
|
114
114
|
`)}`):(f&&(D+=`# Edit the message below and commit:
|
|
115
115
|
`),D+=`
|
|
116
116
|
${c[0]}
|
|
117
|
-
`),await O.appendFile(Rt,D),t.printSavedCommitMessage()})().catch(e=>{new Ee().printErrorMessage(e.message),fe(e),process.exit(1)});const
|
|
117
|
+
`),await O.appendFile(Rt,D),t.printSavedCommitMessage()})().catch(e=>{new Ee().printErrorMessage(e.message),fe(e),process.exit(1)});const wn=process.argv.slice(2);ys({name:"aicommit2",version:qr,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:"Additional prompt to let users fine-tune provided prompt",alias:"p"}},commands:[Ma,Pa,Ia],help:{description:xi},ignoreArgv:e=>e==="unknown-flag"||e==="argument"},e=>{if(Sa){Ta();return}xa(e.flags.locale,e.flags.generate,e.flags.exclude,e.flags.all,e.flags.type,e.flags.confirm,e.flags.clipboard,e.flags.prompt,wn)},wn);
|