aicommit2 1.12.6 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +388 -381
- package/dist/cli.mjs +93 -89
- package/package.json +6 -5
package/dist/cli.mjs
CHANGED
|
@@ -1,118 +1,122 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import Te from"tty";import{createRequire as $n}from"module";import K from"fs";import _ from"path";import{Buffer as vn}from"node:buffer";import V from"node:path";import kt,{ChildProcess as Bn}from"node:child_process";import L from"node:process";import xn from"child_process";import{fileURLToPath as jt}from"node:url";import On,{constants as Gt}from"node:os";import Ht from"assert";import Ut from"events";import{createWriteStream as Mn,createReadStream as Pn}from"node:fs";import Sn 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 T,from as P,map as S,catchError as I,mergeMap as qt,BehaviorSubject as Yt,ReplaySubject as _n,lastValueFrom as Ln,filter as Tn,toArray as Rn}from"rxjs";import Nn from"@anthropic-ai/sdk";import{fromPromise as R}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 Yn from"http";import zn from"https";import Wn from"net";import Jn from"tls";import Vn,{fileURLToPath as Xn,pathToFileURL as Qn}from"url";import ye 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),zt=e=>typeof e=="function"?[e,!1]:ao(e)?[e[0],!0]:zt(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.:=]/,po=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])}`)},fo=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;po(n);const o=e[n],s=[[],...zt(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,a=`Flag alias ${ie(i)} for flag ${ie(n)}`;if(i.length===0)throw new Error(`${a} cannot be empty`);if(i.length>1)throw new Error(`${a} 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},be="--",ho=/[.:=]/,go=/^-{1,2}\w/,Co=e=>{if(!go.test(e))return;const t=!e.startsWith(be);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===be){o();const a=e.slice(s+1);r?.(a,[s],!0);break}const i=Co(u);if(i){if(o(),!t)continue;const[a,l,p]=i;if(p)for(let c=0;c<a.length;c+=1){o();const D=c===a.length-1;n=t(a[c],D?l:void 0,[s,c+1,D])}else n=t(a,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=fo(e),s={},u=[];return u[be]=[],Eo(t,{onFlag(i,a,l){const p=ae(o,i);if(!r?.(p?ro:no,i,a)){if(p){const[c,D]=o[i],f=co(D,a),d=(h,m)=>{n.push(l),m&&n.push(m),c.push(Do(D,h||""))};return f===void 0?d:d(f)}ae(s,i)||(s[i]=[]),s[i].push(a===void 0?!0:a),n.push(l)}},onArgument(i,a,l){r?.(oo,t[a[0]])||(u.push(...i),l?(u[be]=i,t.splice(a[0])):n.push(a))}}),Fo(t,n),{flags:mo(e,o),unknownFlags:s,_:u}};var bo=Object.create,we=Object.defineProperty,wo=Object.defineProperties,Ao=Object.getOwnPropertyDescriptor,$o=Object.getOwnPropertyDescriptors,vo=Object.getOwnPropertyNames,Wt=Object.getOwnPropertySymbols,Bo=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty,xo=Object.prototype.propertyIsEnumerable,Vt=(e,t,r)=>t in e?we(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))xo.call(t,r)&&Vt(e,r,t[r]);return e},Ge=(e,t)=>wo(e,$o(t)),Oo=e=>we(e,"__esModule",{value:!0}),Mo=(e,t)=>()=>(e&&(t=e(e=0)),t),Po=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),So=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of vo(t))!Jt.call(e,o)&&(r||o!=="default")&&we(e,o,{get:()=>t[o],enumerable:!(n=Ao(t,o))||n.enumerable});return e},Io=(e,t)=>So(Oo(we(e!=null?bo(Bo(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),B=Mo(()=>{}),_o=Po((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 Lo=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 To({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(To(),"")}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(
|
|
4
|
-
`)];for(let[l,
|
|
5
|
-
`?(s&&(n+=
|
|
6
|
-
`&&(o&&c&&(n+=
|
|
2
|
+
import _e from"tty";import{createRequire as $n}from"module";import W from"fs";import I from"path";import{Buffer as vn}from"node:buffer";import X from"node:path";import qt,{ChildProcess as Bn}from"node:child_process";import N from"node:process";import xn from"child_process";import{fileURLToPath as zt}from"node:url";import Pn,{constants as Wt}from"node:os";import Kt from"assert";import Jt from"events";import{createWriteStream as Sn,createReadStream as On}from"node:fs";import Mn from"buffer";import Ge from"stream";import Vt from"util";import{debuglog as In}from"node:util";import Ue from"inquirer";import He from"ora";import C from"chalk";import{of as O,concatMap as R,from as M,map as T,catchError as k,mergeMap as Yt,BehaviorSubject as Xt,ReplaySubject as Tn,lastValueFrom as kn,filter as Ln,toArray as Nn}from"rxjs";import Rn from"@anthropic-ai/sdk";import{fromPromise as j}from"rxjs/internal/observable/innerFrom";import qe from"os";import{xxh64 as jn}from"@pacote/xxhash";import _n from"axios";import{CohereClient as Gn,CohereTimeoutError as Un}from"cohere-ai";import{GoogleGenerativeAI as Hn}from"@google/generative-ai";import qn from"groq-sdk";import zn from"http";import Wn from"https";import Kn from"net";import Jn from"tls";import Vn,{fileURLToPath as Yn,pathToFileURL as Xn}from"url";import{Ollama as Zn}from"ollama";import P from"fs/promises";import ye from"readline";import Qn 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),Zt=e=>typeof e=="function"?[e,!1]:ao(e)?[e[0],!0]:Zt(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.:=]/,mo=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;mo(n);const o=e[n],s=[[],...Zt(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,a=`Flag alias ${ie(i)} for flag ${ie(n)}`;if(i.length===0)throw new Error(`${a} cannot be empty`);if(i.length>1)throw new Error(`${a} must be a single character`);r(i,s)}}return t},fo=(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},Ee="--",ho=/[.:=]/,go=/^-{1,2}\w/,Co=e=>{if(!go.test(e))return;const t=!e.startsWith(Ee);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]},Fo=(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===Ee){o();const a=e.slice(s+1);r?.(a,[s],!0);break}const i=Co(u);if(i){if(o(),!t)continue;const[a,l,m]=i;if(m)for(let c=0;c<a.length;c+=1){o();const D=c===a.length-1;n=t(a[c],D?l:void 0,[s,c+1,D])}else n=t(a,l,[s])}else o(u,[s])&&r?.([u],[s])}o()},yo=(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)}},Eo=(e,t=process.argv.slice(2),{ignore:r}={})=>{const n=[],o=po(e),s={},u=[];return u[Ee]=[],Fo(t,{onFlag(i,a,l){const m=ae(o,i);if(!r?.(m?ro:no,i,a)){if(m){const[c,D]=o[i],p=co(D,a),d=(h,g)=>{n.push(l),g&&n.push(g),c.push(Do(D,h||""))};return p===void 0?d:d(p)}ae(s,i)||(s[i]=[]),s[i].push(a===void 0?!0:a),n.push(l)}},onArgument(i,a,l){r?.(oo,t[a[0]])||(u.push(...i),l?(u[Ee]=i,t.splice(a[0])):n.push(a))}}),yo(t,n),{flags:fo(e,o),unknownFlags:s,_:u}};var bo=Object.create,be=Object.defineProperty,wo=Object.defineProperties,Ao=Object.getOwnPropertyDescriptor,$o=Object.getOwnPropertyDescriptors,vo=Object.getOwnPropertyNames,Qt=Object.getOwnPropertySymbols,Bo=Object.getPrototypeOf,er=Object.prototype.hasOwnProperty,xo=Object.prototype.propertyIsEnumerable,tr=(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={}))er.call(t,r)&&tr(e,r,t[r]);if(Qt)for(var r of Qt(t))xo.call(t,r)&&tr(e,r,t[r]);return e},ze=(e,t)=>wo(e,$o(t)),Po=e=>be(e,"__esModule",{value:!0}),So=(e,t)=>()=>(e&&(t=e(e=0)),t),Oo=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Mo=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of vo(t))!er.call(e,o)&&(r||o!=="default")&&be(e,o,{get:()=>t[o],enumerable:!(n=Ao(t,o))||n.enumerable});return e},Io=(e,t)=>Mo(Po(be(e!=null?bo(Bo(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),S=So(()=>{}),To=Oo((e,t)=>{S(),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}});S(),S(),S();var ko=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}};S(),S(),S(),S(),S();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 rr(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Lo(),"")}S();function No(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 Ro=Io(To(),1);function J(e){if(typeof e!="string"||e.length===0||(e=rr(e),e.length===0))return 0;e=e.replace((0,Ro.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+=No(n)?2:1)}return t}var nr=e=>Math.max(...e.split(`
|
|
3
|
+
`).map(J)),jo=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=nr(r[s]);u>t[s]&&(t[s]=u)}}return t};S();var or=/^\d+%$/,sr={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},_o=(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"&&or.test(s)){n.push(ze(we({},sr),{width:s,contentWidth:e[o]}));continue}if(s&&typeof s=="object"){let u=ze(we(we({},sr),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 a=Math.min(20,r.contentWidth);r.width=a,r.autoOverflow=r.contentWidth-a}if(typeof n=="string"&&or.test(n)){let a=Number.parseFloat(n.slice(0,-1))/100;r.width=Math.floor(t*a)-(r.paddingLeft+r.paddingRight)}let{horizontalPadding:o}=r,s=1,u=s+o;if(u>=t){let a=u-t,l=Math.ceil(r.paddingLeft/o*a),m=a-l;r.paddingLeft-=l,r.paddingRight-=m,r.horizontalPadding=r.paddingLeft+r.paddingRight}r.paddingLeftString=r.paddingLeft?" ".repeat(r.paddingLeft):"",r.paddingRightString=r.paddingRight?" ".repeat(r.paddingRight):"";let i=t-r.horizontalPadding;r.width=Math.max(Math.min(r.width,i),s)}}var ur=()=>Object.assign([],{columns:0});function Uo(e,t){let r=[ur()],[n]=r;for(let o of e){let s=o.width+o.horizontalPadding;n.columns+s>t&&(n=ur(),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),a=i.filter(D=>D.autoOverflow>0),l=a.reduce((D,p)=>D+p.autoOverflow,0),m=Math.min(l,u);for(let D of a){let p=Math.floor(D.autoOverflow/l*m);D.width+=p,u-=p}let c=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+=c,u-=c}}return r}function Ho(e,t,r){let n=_o(r,t);return Go(n,e),Uo(n,e)}S(),S(),S();var We=10,ir=(e=0)=>t=>`\x1B[${t+e}m`,ar=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,cr=(e=0)=>(t,r,n)=>`\x1B[${38+e};2;${t};${r};${n}m`;function qo(){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=ir(),t.color.ansi256=ar(),t.color.ansi16m=cr(),t.bgColor.ansi=ir(We),t.bgColor.ansi256=ar(We),t.bgColor.ansi16m=cr(We),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 a=r%36;n=Math.floor(r/36)/5,o=Math.floor(a/6)/5,s=a%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 zo=qo(),Wo=zo,Ae=new Set(["\x1B","\x9B"]),Ko=39,Ke="\x07",Dr="[",Jo="]",lr="m",Je=`${Jo}8;;`,mr=e=>`${Ae.values().next().value}${Dr}${e}${lr}`,pr=e=>`${Ae.values().next().value}${Je}${e}${Ke}`,Vo=e=>e.split(" ").map(t=>J(t)),Ve=(e,t,r)=>{let n=[...t],o=!1,s=!1,u=J(rr(e[e.length-1]));for(let[i,a]of n.entries()){let l=J(a);if(u+l<=r?e[e.length-1]+=a:(e.push(a),u=0),Ae.has(a)&&(o=!0,s=n.slice(i+1).join("").startsWith(Je)),o){s?a===Ke&&(o=!1,s=!1):a===lr&&(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())},Yo=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(J(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=Vo(e),i=[""];for(let[l,m]of e.split(" ").entries()){r.trim!==!1&&(i[i.length-1]=i[i.length-1].trimStart());let c=J(i[i.length-1]);if(l!==0&&(c>=t&&(r.wordWrap===!1||r.trim===!1)&&(i.push(""),c=0),(c>0||r.trim===!1)&&(i[i.length-1]+=" ",c++)),r.hard&&u[l]>t){let D=t-c,p=1+Math.floor((u[l]-D-1)/t);Math.floor((u[l]-1)/t)<p&&i.push(""),Ve(i,m,t);continue}if(c+u[l]>t&&c>0&&u[l]>0){if(r.wordWrap===!1&&c<t){Ve(i,m,t);continue}i.push("")}if(c+u[l]>t&&r.wordWrap===!1){Ve(i,m,t);continue}i[i.length-1]+=m}r.trim!==!1&&(i=i.map(l=>Yo(l)));let a=[...i.join(`
|
|
4
|
+
`)];for(let[l,m]of a.entries()){if(n+=m,Ae.has(m)){let{groups:D}=new RegExp(`(?:\\${Dr}(?<code>\\d+)m|\\${Je}(?<uri>.*)${Ke})`).exec(a.slice(l).join(""))||{groups:{}};if(D.code!==void 0){let p=Number.parseFloat(D.code);o=p===Ko?void 0:p}else D.uri!==void 0&&(s=D.uri.length===0?void 0:D.uri)}let c=Wo.codes.get(Number(o));a[l+1]===`
|
|
5
|
+
`?(s&&(n+=pr("")),o&&c&&(n+=mr(c))):m===`
|
|
6
|
+
`&&(o&&c&&(n+=mr(o)),s&&(n+=pr(s)))}return n};function Zo(e,t,r){return String(e).normalize().replace(/\r\n/g,`
|
|
7
7
|
`).split(`
|
|
8
8
|
`).map(n=>Xo(n,t,r)).join(`
|
|
9
|
-
`)}var
|
|
10
|
-
`);if(a.postprocess){let{postprocess:D}=a;c=c.map((
|
|
9
|
+
`)}var fr=e=>Array.from({length:e}).fill("");function Qo(e,t){let r=[],n=0;for(let o of e){let s=0,u=o.map(a=>{var l;let m=(l=t[n])!=null?l:"";n+=1,a.preprocess&&(m=a.preprocess(m)),nr(m)>a.width&&(m=Zo(m,a.width,{hard:!0}));let c=m.split(`
|
|
10
|
+
`);if(a.postprocess){let{postprocess:D}=a;c=c.map((p,d)=>D.call(a,p,d))}return a.paddingTop&&c.unshift(...fr(a.paddingTop)),a.paddingBottom&&c.push(...fr(a.paddingBottom)),c.length>s&&(s=c.length),ze(we({},a),{lines:c})}),i=[];for(let a=0;a<s;a+=1){let l=u.map(m=>{var c;let D=(c=m.lines[a])!=null?c:"",p=Number.isFinite(m.width)?" ".repeat(m.width-J(D)):"",d=m.paddingLeftString;return m.align==="right"&&(d+=p),d+=D,m.align==="left"&&(d+=p),d+m.paddingRightString}).join("");i.push(l)}r.push(i.join(`
|
|
11
11
|
`))}return r.join(`
|
|
12
|
-
`)}function es(e,t){if(!e||e.length===0)return"";let r=
|
|
13
|
-
`)}
|
|
12
|
+
`)}function es(e,t){if(!e||e.length===0)return"";let r=jo(e),n=r.length;if(n===0)return"";let{stdoutColumns:o,columns:s}=ko(t);if(s.length>n)throw new Error(`${s.length} columns defined, but only ${n} columns found`);let u=Ho(o,s,r);return e.map(i=>Qo(u,i)).join(`
|
|
13
|
+
`)}S();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)),hr=e=>{const t="parent"in e&&e.parent?.name;return(t?`${t} `:"")+e.name};function as(e){const t=[];e.name&&t.push(hr(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(" ")}
|
|
14
14
|
`}}function cs(e){const{help:t}=e;if(!(!t||!t.description))return{id:"description",type:"text",data:`${t.description}
|
|
15
15
|
`}}function Ds(e){const t=e.help||{};if("usage"in t)return t.usage?{id:"usage",type:"section",data:{title:"Usage:",body:Array.isArray(t.usage)?t.usage.join(`
|
|
16
|
-
`):t.usage}}:void 0;if(e.name){const r=[],n=[
|
|
17
|
-
`)}}}}function ls(e){return!("commands"in e)||!e.commands?.length?void 0:{id:"commands",type:"section",data:{title:"Commands:",body:{type:"table",data:{tableData:e.commands.map(t=>[t.options.name,t.options.help?t.options.help.description:""]),tableOptions:[{width:"content-width",paddingLeft:2,paddingRight:8}]}},indentBody:0}}}function
|
|
18
|
-
`)),r)return{id:"examples",type:"section",data:{title:"Examples:",body:r}}}function
|
|
16
|
+
`):t.usage}}:void 0;if(e.name){const r=[],n=[hr(e)];if(e.flags&&Object.keys(e.flags).length>0&&n.push("[flags...]"),e.parameters&&e.parameters.length>0){const{parameters:o}=e,s=o.indexOf("--"),u=s>-1&&o.slice(s+1).some(i=>i.startsWith("<"));n.push(o.map(i=>i!=="--"?i:u?"--":"[--]").join(" "))}if(n.length>1&&r.push(n.join(" ")),"commands"in e&&e.commands?.length&&r.push(`${e.name} <command>`),r.length>0)return{id:"usage",type:"section",data:{title:"Usage:",body:r.join(`
|
|
17
|
+
`)}}}}function ls(e){return!("commands"in e)||!e.commands?.length?void 0:{id:"commands",type:"section",data:{title:"Commands:",body:{type:"table",data:{tableData:e.commands.map(t=>[t.options.name,t.options.help?t.options.help.description:""]),tableOptions:[{width:"content-width",paddingLeft:2,paddingRight:8}]}},indentBody:0}}}function ms(e){if(!(!e.flags||Object.keys(e.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:is(e.flags),indentBody:0}}}function ps(e){const{help:t}=e;if(!t||!t.examples||t.examples.length===0)return;let{examples:r}=t;if(Array.isArray(r)&&(r=r.join(`
|
|
18
|
+
`)),r)return{id:"examples",type:"section",data:{title:"Examples:",body:r}}}function fs(e){if(!("alias"in e)||!e.alias)return;const{alias:t}=e;return{id:"aliases",type:"section",data:{title:"Aliases:",body:Array.isArray(t)?t.join(", "):t}}}const ds=e=>[as,cs,Ds,ls,ms,ps,fs].map(t=>t(e)).filter(Boolean),hs=_e.WriteStream.prototype.hasColors();class gs{text(t){return t}bold(t){return hs?`\x1B[1m${t}\x1B[22m`:t.toLocaleUpperCase()}indentText({text:t,spaces:r}){return t.replace(/^/gm," ".repeat(r))}heading(t){return this.bold(t)}section({title:t,body:r,indentBody:n=2}){return`${(t?`${this.heading(t)}
|
|
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
|
-
`);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 Ye=/^[\w.-]+$/,{stringify:
|
|
22
|
-
`),n(),process.exit(1);e[a]=l}}function
|
|
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 Ye=/^[\w.-]+$/,{stringify:_}=JSON,Cs=/[|\\{}()[\]^$+*?.]/;function Xe(e){const t=[];let r,n;for(const o of e){if(n)throw new Error(`Invalid parameter: Spread parameter ${_(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 ${_(o)} cannot come after optional parameter ${_(r)}`);if(s==="["&&u==="]"&&(i=!1,r=o),i===void 0)throw new Error(`Invalid parameter: ${_(o)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let a=o.slice(1,-1);const l=a.slice(-3)==="...";l&&(n=o,a=a.slice(0,-3));const m=a.match(Cs);if(m)throw new Error(`Invalid parameter: ${_(o)}. Invalid character found ${_(m[0])}`);t.push({name:a,required:i,spread:l})}return t}function Ze(e,t,r,n){for(let o=0;o<t.length;o+=1){const{name:s,required:u,spread:i}=t[o],a=os(s);if(a in e)throw new Error(`Invalid parameter: ${_(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 ${_(s)}
|
|
22
|
+
`),n(),process.exit(1);e[a]=l}}function Fs(e){return e===void 0||e!==!1}function gr(e,t,r,n){const o={...t.flags},s=t.version;s&&(o.version={type:Boolean,description:"Show version"});const{help:u}=t,i=Fs(u);i&&!("help"in o)&&(o.help={type:Boolean,alias:"h",description:"Show help"});const a=Eo(o,n,{ignore:t.ignoreArgv}),l=()=>{console.log(t.version)};if(s&&a.flags.version===!0)return l(),process.exit(0);const m=new gs,c=i&&u?.render?u.render:d=>m.render(d),D=d=>{const h=ds({...t,...d?{help:d}:{},flags:o});console.log(c(h,m))};if(i&&a.flags.help===!0)return D(),process.exit(0);if(t.parameters){let{parameters:d}=t,h=a._;const g=d.indexOf("--"),E=d.slice(g+1),A=Object.create(null);if(g>-1&&E.length>0){d=d.slice(0,g);const v=a._["--"];h=h.slice(0,-v.length||void 0),Ze(A,Xe(d),h,D),Ze(A,Xe(E),v,D)}else Ze(A,Xe(d),h,D);Object.assign(a._,A)}const p={...a,showVersion:l,showHelp:D};return typeof r=="function"&&r(p),{command:e,...p}}function ys(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: ${_(u)}`);r.set(u,n)}}return r.get(e)}function Es(e,t,r=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!Ye.test(e.name)))throw new Error(`Invalid script name: ${_(e.name)}`);const n=r[0];if(e.commands&&Ye.test(n)){const o=ys(n,e.commands);if(o)return gr(o.options.name,{...o.options,parent:e},o.callback,r.slice(1))}return gr(void 0,e,t,r)}function Qe(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(!Ye.test(r))throw new Error(`Invalid command name ${JSON.stringify(r)}. Command names must be one word.`);return{options:e,callback:t}}var bs=$n(import.meta.url),$=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Z(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Q={exports:{}},et,Cr;function ws(){if(Cr)return et;Cr=1,et=n,n.sync=o;var e=W;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 a=0;a<i.length;a++){var l=i[a].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(a,l){i(a,a?!1:r(l,s,u))})}function o(s,u){return r(e.statSync(s),s,u)}return et}var tt,Fr;function As(){if(Fr)return tt;Fr=1,tt=t,t.sync=r;var e=W;function t(s,u,i){e.stat(s,function(a,l){i(a,a?!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,a=s.uid,l=s.gid,m=u.uid!==void 0?u.uid:process.getuid&&process.getuid(),c=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,g=i&d||i&p&&l===c||i&D&&a===m||i&h&&m===0;return g}return tt}var $e;process.platform==="win32"||$.TESTING_WINDOWS?$e=ws():$e=As();var $s=rt;rt.sync=vs;function rt(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){rt(e,t||{},function(s,u){s?o(s):n(u)})})}$e(e,t||{},function(n,o){n&&(n.code==="EACCES"||t&&t.ignoreErrors)&&(n=null,o=!1),r(n,o)})}function vs(e,t){try{return $e.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}const ee=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",yr=I,Bs=ee?";":":",Er=$s,br=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),wr=(e,t)=>{const r=t.colon||Bs,n=e.match(/\//)||ee&&e.match(/\\/)?[""]:[...ee?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],o=ee?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=ee?o.split(r):[""];return ee&&e.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:n,pathExt:s,pathExtExe:o}},Ar=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});const{pathEnv:n,pathExt:o,pathExtExe:s}=wr(e,t),u=[],i=l=>new Promise((m,c)=>{if(l===n.length)return t.all&&u.length?m(u):c(br(e));const D=n[l],p=/^".*"$/.test(D)?D.slice(1,-1):D,d=yr.join(p,e),h=!p&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;m(a(h,l,0))}),a=(l,m,c)=>new Promise((D,p)=>{if(c===o.length)return D(i(m+1));const d=o[c];Er(l+d,{pathExt:s},(h,g)=>{if(!h&&g)if(t.all)u.push(l+d);else return D(l+d);return D(a(l,m,c+1))})});return r?i(0).then(l=>r(null,l),r):i(0)},xs=(e,t)=>{t=t||{};const{pathEnv:r,pathExt:n,pathExtExe:o}=wr(e,t),s=[];for(let u=0;u<r.length;u++){const i=r[u],a=/^".*"$/.test(i)?i.slice(1,-1):i,l=yr.join(a,e),m=!a&&/^\.[\\\/]/.test(e)?e.slice(0,2)+l:l;for(let c=0;c<n.length;c++){const D=m+n[c];try{if(Er.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 br(e)};var Ps=Ar;Ar.sync=xs;var nt={exports:{}};const $r=(e={})=>{const t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};nt.exports=$r,nt.exports.default=$r;var Ss=nt.exports;const vr=I,Os=Ps,Ms=Ss;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=Os.sync(e.command,{path:r[Ms({env:r})],pathExt:t?vr.delimiter:void 0})}catch{}finally{s&&process.chdir(n)}return u&&(u=vr.resolve(o?e.options.cwd:"",u)),u}function Is(e){return Br(e)||Br(e,!0)}var Ts=Is,ot={};const st=/([()\][%!^"`<>&|;, *?])/g;function ks(e){return e=e.replace(st,"^$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(st,"^$1"),t&&(e=e.replace(st,"^$1")),e}ot.command=ks,ot.argument=Ls;var Ns=/^#!(.*)/;const Rs=Ns;var js=(e="")=>{const t=e.match(Rs);if(!t)return null;const[r,n]=t[0].replace(/#! ?/,"").split(" "),o=r.split("/").pop();return o==="env"?n:n?`${o} ${n}`:o};const ut=W,_s=js;function Gs(e){const r=Buffer.alloc(150);let n;try{n=ut.openSync(e,"r"),ut.readSync(n,r,0,150,0),ut.closeSync(n)}catch{}return _s(r.toString())}var Us=Gs;const Hs=I,xr=Ts,Pr=ot,qs=Us,zs=process.platform==="win32",Ws=/\.(?:com|exe)$/i,Ks=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Js(e){e.file=xr(e);const t=e.file&&qs(e.file);return t?(e.args.unshift(e.file),e.command=t,xr(e)):e.file}function Vs(e){if(!zs)return e;const t=Js(e),r=!Ws.test(t);if(e.options.forceShell||r){const n=Ks.test(t);e.command=Hs.normalize(e.command),e.command=Pr.command(e.command),e.args=e.args.map(s=>Pr.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 Ys(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:Vs(n)}var Xs=Ys;const it=process.platform==="win32";function at(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 Zs(e,t){if(!it)return;const r=e.emit;e.emit=function(n,o){if(n==="exit"){const s=Sr(o,t);if(s)return r.call(e,"error",s)}return r.apply(e,arguments)}}function Sr(e,t){return it&&e===1&&!t.file?at(t.original,"spawn"):null}function Qs(e,t){return it&&e===1&&!t.file?at(t.original,"spawnSync"):null}var eu={hookChildProcess:Zs,verifyENOENT:Sr,verifyENOENTSync:Qs,notFoundError:at};const Or=xn,ct=Xs,Dt=eu;function Mr(e,t,r){const n=ct(e,t,r),o=Or.spawn(n.command,n.args,n.options);return Dt.hookChildProcess(o,n),o}function tu(e,t,r){const n=ct(e,t,r),o=Or.spawnSync(n.command,n.args,n.options);return o.error=o.error||Dt.verifyENOENTSync(o.status,n),o}Q.exports=Mr,Q.exports.spawn=Mr,Q.exports.sync=tu,Q.exports._parse=ct,Q.exports._enoent=Dt;var ru=Q.exports,nu=Z(ru);function ou(e){const t=typeof e=="string"?`
|
|
23
23
|
`:`
|
|
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
|
|
25
|
-
${t}`,
|
|
26
|
-
${n.message}`:
|
|
27
|
-
`);return E?(n.originalMessage=n.message,n.message=
|
|
28
|
-
`)},wi=1e3*1e3*100,Ai=({env:e,extendEnv:t,preferLocal:r,localDir:n,execPath:o})=>{const s=t?{...
|
|
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 Ir(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=N.cwd(),path:t=N.env[Ir()],preferLocal:r=!0,execPath:n=N.execPath,addExecPath:o=!0}={})=>{const s=e instanceof URL?zt(e):e,u=X.resolve(s),i=[];return r&&uu(i,u),o&&iu(i,n,u),[...i,t].join(X.delimiter)},uu=(e,t)=>{let r;for(;r!==t;)e.push(X.join(t,"node_modules/.bin")),r=t,t=X.resolve(t,"..")},iu=(e,t,r)=>{const n=t instanceof URL?zt(t):t;e.push(X.resolve(r,n,".."))},au=({env:e=N.env,...t}={})=>{e={...e};const r=Ir({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)},mu=(e,t)=>`/* Wrapped ${e}*/
|
|
25
|
+
${t}`,pu=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),fu=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),du=(e,t,r)=>{const n=r===""?"":`with ${r.trim()}() `,o=mu.bind(null,n,t.toString());Object.defineProperty(o,"name",fu),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),du(e,t,n),e}const ve=new WeakMap,Tr=(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(ve.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),ve.set(s,n),s};Tr.callCount=e=>{if(!ve.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return ve.get(e)};const gu=()=>{const e=Lr-kr+1;return Array.from({length:e},Cu)},Cu=(e,t)=>({name:`SIGRT${t+1}`,number:kr+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),kr=34,Lr=64,Fu=[{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"}],Nr=()=>{const e=gu();return[...Fu,...e].map(yu)},yu=({name:e,number:t,description:r,action:n,forced:o=!1,standard:s})=>{const{signals:{[e]:u}}=Wt,i=u!==void 0;return{name:e,number:i?u:t,description:r,supported:i,action:n,forced:o,standard:s}},Eu=()=>{const e=Nr();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=Eu(),Au=()=>{const e=Nr(),t=Lr+1,r=Array.from({length:t},(n,o)=>$u(o,e));return Object.assign({},...r)},$u=(e,t)=>{const r=vu(e,t);if(r===void 0)return{};const{name:n,description:o,supported:s,action:u,forced:i,standard:a}=r;return{[e]:{name:n,number:e,description:o,supported:s,action:u,forced:i,standard:a}}},vu=(e,t)=>{const r=t.find(({name:n})=>Wt.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",Rr=({stdout:e,stderr:t,all:r,error:n,signal:o,exitCode:s,command:u,escapedCommand:i,timedOut:a,isCanceled:l,killed:m,parsed:{options:{timeout:c,cwd:D=N.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,g=`Command ${Bu({timedOut:a,timeout:c,errorCode:d,signal:o,signalDescription:p,exitCode:s,isCanceled:l})}: ${u}`,E=Object.prototype.toString.call(n)==="[object Error]",A=E?`${g}
|
|
26
|
+
${n.message}`:g,v=[A,t,e].filter(Boolean).join(`
|
|
27
|
+
`);return E?(n.originalMessage=n.message,n.message=v):n=new Error(v),n.shortMessage=A,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=!!a,n.isCanceled=l,n.killed=m&&!a,n},Be=["stdin","stdout","stderr"],xu=e=>Be.some(t=>e[t]!==void 0),Pu=e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return Be.map(n=>e[n]);if(xu(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 te={exports:{}},xe={exports:{}};xe.exports;var jr;function Su(){return jr||(jr=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")}(xe)),xe.exports}var b=$.process;const V=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(!V(b))te.exports=function(){return function(){}};else{var Ou=Kt,ce=Su(),Mu=/^win/i.test(b.platform),Pe=Jt;typeof Pe!="function"&&(Pe=Pe.EventEmitter);var B;b.__signal_exit_emitter__?B=b.__signal_exit_emitter__:(B=b.__signal_exit_emitter__=new Pe,B.count=0,B.emitted={}),B.infinite||(B.setMaxListeners(1/0),B.infinite=!0),te.exports=function(e,t){if(!V($.process))return function(){};Ou.equal(typeof e,"function","a callback must be provided for exit handler"),De===!1&&_r();var r="exit";t&&t.alwaysLast&&(r="afterexit");var n=function(){B.removeListener(r,e),B.listeners("exit").length===0&&B.listeners("afterexit").length===0&<()};return B.on(r,e),n};var lt=function(){!De||!V($.process)||(De=!1,ce.forEach(function(t){try{b.removeListener(t,mt[t])}catch{}}),b.emit=pt,b.reallyExit=Gr,B.count-=1)};te.exports.unload=lt;var re=function(t,r,n){B.emitted[t]||(B.emitted[t]=!0,B.emit(t,r,n))},mt={};ce.forEach(function(e){mt[e]=function(){if(V($.process)){var r=b.listeners(e);r.length===B.count&&(lt(),re("exit",null,e),re("afterexit",null,e),Mu&&e==="SIGHUP"&&(e="SIGINT"),b.kill(b.pid,e))}}}),te.exports.signals=function(){return ce};var De=!1,_r=function(){De||!V($.process)||(De=!0,B.count+=1,ce=ce.filter(function(t){try{return b.on(t,mt[t]),!0}catch{return!1}}),b.emit=Tu,b.reallyExit=Iu)};te.exports.load=_r;var Gr=b.reallyExit,Iu=function(t){V($.process)&&(b.exitCode=t||0,re("exit",b.exitCode,null),re("afterexit",b.exitCode,null),Gr.call(b,b.exitCode))},pt=b.emit,Tu=function(t,r){if(t==="exit"&&V($.process)){r!==void 0&&(b.exitCode=r);var n=pt.apply(this,arguments);return re("exit",b.exitCode,null),re("afterexit",b.exitCode,null),n}else return pt.apply(this,arguments)}}var ku=te.exports,Lu=Z(ku);const Nu=1e3*5,Ru=(e,t="SIGTERM",r={})=>{const n=e(t);return ju(e,t,r,n),n},ju=(e,t,r,n)=>{if(!_u(t,r,n))return;const o=Uu(r),s=setTimeout(()=>{e("SIGKILL")},o);s.unref&&s.unref()},_u=(e,{forceKillAfterTimeout:t},r)=>Gu(e)&&t!==!1&&r,Gu=e=>e===Pn.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",Uu=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return Nu;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},Hu=(e,t)=>{e.kill()&&(t.isCanceled=!0)},qu=(e,t,r)=>{e.kill(t),r(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},zu=(e,{timeout:t,killSignal:r="SIGTERM"},n)=>{if(t===0||t===void 0)return n;let o;const s=new Promise((i,a)=>{o=setTimeout(()=>{qu(e,r,a)},t)}),u=n.finally(()=>{clearTimeout(o)});return Promise.race([s,u])},Wu=({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})`)},Ku=async(e,{cleanup:t,detached:r},n)=>{if(!t||r)return n;const o=Lu(()=>{e.kill()});return n.finally(()=>{o()})};function Ur(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}function Hr(e){return Ur(e)&&e.writable!==!1&&typeof e._write=="function"&&typeof e._writableState=="object"}const Ju=e=>e instanceof Bn&&typeof e.then=="function",ft=(e,t,r)=>{if(typeof r=="string")return e[t].pipe(Sn(r)),e;if(Hr(r))return e[t].pipe(r),e;if(!Ju(r))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!Hr(r.stdin))throw new TypeError("The target child process's stdin must be available.");return e[t].pipe(r.stdin),r},Vu=e=>{e.stdout!==null&&(e.pipeStdout=ft.bind(void 0,e,"stdout")),e.stderr!==null&&(e.pipeStderr=ft.bind(void 0,e,"stderr")),e.all!==void 0&&(e.pipeAll=ft.bind(void 0,e,"all"))};var le={exports:{}};const{PassThrough:Yu}=Ge;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 Yu({objectMode:o});r&&s.setEncoding(r);let u=0;const i=[];return s.on("data",a=>{i.push(a),o?u=i.length:u+=a.length}),s.getBufferedValue=()=>t?i:n?Buffer.concat(i,u):i.join(""),s.getBufferedLength=()=>u,s};const{constants:Zu}=Mn,Qu=Ge,{promisify:ei}=Vt,ti=Xu,ri=ei(Qu.pipeline);class qr extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function dt(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()<=Zu.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 qr)})}),n.getBufferedValue()}le.exports=dt,le.exports.buffer=(e,t)=>dt(e,{...t,encoding:"buffer"}),le.exports.array=(e,t)=>dt(e,{...t,array:!0}),le.exports.MaxBufferError=qr;var ni=le.exports,zr=Z(ni);const{PassThrough:oi}=Ge;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=Z(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),On(t)),ci=(e,t)=>{const r=ai(t);r!==void 0&&(Ur(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},ht=async(e,t)=>{if(!(!e||t===void 0)){e.destroy();try{return await t}catch(r){return r.bufferedData}}},gt=(e,{encoding:t,buffer:r,maxBuffer:n})=>{if(!(!e||!r))return t?zr(e,{encoding:t,maxBuffer:n}):zr.buffer(e,{maxBuffer:n})},li=async({stdout:e,stderr:t,all:r},{encoding:n,buffer:o,maxBuffer:s},u)=>{const i=gt(e,{encoding:n,buffer:o,maxBuffer:s}),a=gt(t,{encoding:n,buffer:o,maxBuffer:s}),l=gt(r,{encoding:n,buffer:o,maxBuffer:s*2});try{return await Promise.all([u,i,a,l])}catch(m){return Promise.all([{error:m,signal:m.signal,timedOut:m.timedOut},ht(e,i),ht(t,a),ht(r,l)])}},mi=(async()=>{})().constructor.prototype,pi=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(mi,e)]),Wr=(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})}},fi=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)})}),Kr=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],di=/^[\w.-]+$/,hi=/"/g,gi=e=>typeof e!="string"||di.test(e)?e:`"${e.replace(hi,'\\"')}"`,Ci=(e,t)=>Kr(e,t).join(" "),Fi=(e,t)=>Kr(e,t).map(r=>gi(r)).join(" "),yi=In("execa").enabled,Se=(e,t)=>String(e).padStart(t,"0"),Ei=()=>{const e=new Date;return`${Se(e.getHours(),2)}:${Se(e.getMinutes(),2)}:${Se(e.getSeconds(),2)}.${Se(e.getMilliseconds(),3)}`},bi=(e,{verbose:t})=>{t&&N.stderr.write(`[${Ei()}] ${e}
|
|
28
|
+
`)},wi=1e3*1e3*100,Ai=({env:e,extendEnv:t,preferLocal:r,localDir:n,execPath:o})=>{const s=t?{...N.env,...e}:e;return r?au({env:s,cwd:n,execPath:o}):s},$i=(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||N.cwd(),execPath:N.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:yi,...r},r.env=Ai(r),r.stdio=Pu(r),N.platform==="win32"&&X.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:r,parsed:n}},Ct=(e,t,r)=>typeof t!="string"&&!vn.isBuffer(t)?r===void 0?void 0:"":e.stripFinalNewline?ou(t):t;function ne(e,t,r){const n=$i(e,t,r),o=Ci(e,t),s=Fi(e,t);bi(s,n.options),Wu(n.options);let u;try{u=qt.spawn(n.file,n.args,n.options)}catch(p){const d=new qt.ChildProcess,h=Promise.reject(Rr({error:p,stdout:"",stderr:"",all:"",command:o,escapedCommand:s,parsed:n,timedOut:!1,isCanceled:!1,killed:!1}));return Wr(d,h),d}const i=fi(u),a=zu(u,n.options,i),l=Ku(u,n.options,a),m={isCanceled:!1};u.kill=Ru.bind(null,u.kill.bind(u)),u.cancel=Hu.bind(null,u,m);const D=Tr(async()=>{const[{error:p,exitCode:d,signal:h,timedOut:g},E,A,v]=await li(u,n.options,l),Y=Ct(n.options,E),z=Ct(n.options,A),w=Ct(n.options,v);if(p||d!==0||h!==null){const x=Rr({error:p,exitCode:d,signal:h,stdout:Y,stderr:z,all:w,command:o,escapedCommand:s,parsed:n,timedOut:g,isCanceled:m.isCanceled||(n.options.signal?n.options.signal.aborted:!1),killed:u.killed});if(!n.options.reject)return x;throw x}return{command:o,escapedCommand:s,exitCode:0,stdout:Y,stderr:z,all:w,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return ci(u,n.options),u.all=Di(u,n.options),Vu(u),Wr(u,D),u}class G{static create(t,r){return new t(r)}}class U{constructor(t){this.handleError$=r=>{let n="An error occurred";return r.message&&(n=r.message),O({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.serviceName="AI",this.errorPrefix="ERROR",this.colors={primary:""}}parseMessage(t,r,n){try{const s=JSON.parse(t).map(u=>this.extractMessageAsType(u,r)).map(u=>({title:`${u.subject}`,value:`${u.subject}${u.body?`
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
${u.body}`:""}${u.footer?`
|
|
31
31
|
|
|
32
|
-
[
|
|
32
|
+
${u.footer}`:""}`}));return s.length>n?s.slice(0,n):s}catch{const s=/\[[\s\S]*?\]/;try{const u=t.match(s);if(!u)return[];const i=u[0],l=JSON.parse(i).map(m=>this.extractMessageAsType(m,r)).map(m=>({title:`${m.subject}`,value:`${m.subject}${m.body?`
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
${m.body}`:""}${m.footer?`
|
|
35
35
|
|
|
36
|
-
[
|
|
37
|
-
${Object.entries({":sparkles:":"Introduce new features.",":bug:":"Fix a bug.",":memo:":"Add or update documentation.",":art:":"Improve structure / format of the code.",":zap:":"Improve performance.",":fire:":"Remove code or files.",":ambulance:":"Critical hotfix.",":white_check_mark:":"Add, update, or pass tests.",":lock:":"Fix security or privacy issues.",":rocket:":"Deploy stuff.",":lipstick:":"Add or update the UI and style files.",":tada:":"Begin a project.",":recycle:":"Refactor code.",":wrench:":"Add or update configuration files.",":bulb:":"Add or update comments in source code.",":twisted_rightwards_arrows:":"Merge branches."}).map(([e,t])=>` - ${e}: ${t}`).join(`
|
|
38
|
-
`)}`,conventional:`
|
|
39
|
-
${Object.entries({docs:"Documentation only changes",style:"Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)",refactor:"A code change that neither fixes a bug nor adds a feature",perf:"A code change that improves performance",test:"Adding missing tests or correcting existing tests",build:"Changes that affect the build system or external dependencies",ci:"Changes to CI configuration files, scripts",chore:"Other changes that don't modify src or test files",revert:"Reverts a previous commit",feat:"A new feature",fix:"A bug fix"}).map(([e,t])=>` - ${e}: ${t}`).join(`
|
|
40
|
-
`)}`},xi=(e,t)=>e.replace(/{(\w+)}/g,(r,n)=>t[n]?.toString()||Y[n]?.toString()),Ur=e=>{const{type:t,maxLength:r,generate:n,locale:o}=e;return["You are an AI assistant specialized in generating high-quality git commit messages following the Conventional Commits specification.","Your task is to create commit messages based on the following guidelines",`1. Language: ${o}`,`2. Format: follow the ${t} Commits format:`,`${vi[t]}`,`3. Types: use one of the following types:${Bi[t]}`,"4. Scope: optional, can be anything specifying the place of the commit change (e.g., component name, file name, module name)","5. Description: ",' - Use imperative, present tense: "change" not "changed" nor "changes"'," - Don't capitalize the first letter"," - No period (.) at the end","6. Body: Optional"," - Use imperative, present tense"," - Wrap lines at 72 characters","7. Footer: Optional",' - Mention any breaking changes, starting with "BREAKING CHANGE:"',' - Reference any related issues or pull requests (e.g., "Fixes #123", "Closes #456")',"8. General Rules:"," - Be concise but descriptive",' - Focus on the "why" behind the change, not just the "what"'," - Separate subject from body with a blank line"," - Use the body to explain what and why vs. how"].filter(Boolean).join(`
|
|
41
|
-
`)},mt=(e,t)=>[`Generate exactly ${t} ${e} commit message${t!==1?"s":""}.`,`Provide your response as a JSON array containing exactly ${t} object${t!==1?"s":""}, each with the following keys:`,'- "subject": The main commit message. It should be a concise summary of the changes.','- "body": An optional detailed explanation of the changes. If not needed, use an empty string.','- "footer": An optional footer for metadata like issue tracker IDs. If not needed, use an empty string.',`The array must always contain ${t} element${t!==1?"s":""}, no more and no less.`,`Example response format:
|
|
42
|
-
[
|
|
43
|
-
${Array(t).fill(null).map((r,n)=>`{
|
|
44
|
-
"subject": "fix: fix bug in user authentication process",
|
|
45
|
-
"body": "- Updated login function to handle edge cases\\n- Added additional error logging for debugging\\n- Refactored password hashing method for better security",
|
|
46
|
-
"footer": ""
|
|
47
|
-
}`).join(`,
|
|
48
|
-
`)}
|
|
49
|
-
]`].filter(Boolean).join(`
|
|
50
|
-
`),J=e=>{const{type:t,generate:r,promptPath:n}=e;if(!n)return`${Ur(e)}
|
|
51
|
-
${mt(t,r)}`;try{const o=K.readFileSync(_.resolve(n),"utf-8");return`${xi(o,e)}
|
|
52
|
-
${mt(t,r)}`}catch{return`${Ur(e)}
|
|
53
|
-
${mt(t,r)}`}},M={OPEN_AI:"OPENAI_KEY",GEMINI:"GEMINI_KEY",ANTHROPIC:"ANTHROPIC_KEY",HUGGINGFACE:"HUGGINGFACE_COOKIE",MISTRAL:"MISTRAL_KEY",CODESTRAL:"CODESTRAL_KEY",OLLAMA:"OLLAMA_MODEL",COHERE:"COHERE_KEY",GROQ:"GROQ_KEY",PERPLEXITY:"PERPLEXITY_KEY"},Kr=Object.values(M).map(e=>e);class j{constructor(t){this.handleError$=r=>{let n="An error occurred";return r.message&&(n=r.message),x({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.serviceName="AI",this.errorPrefix="ERROR",this.colors={primary:""}}buildPrompt(t,r,n,o,s,u){const i={...Y,locale:t,maxLength:o,type:s,generate:n,promptPath:u};return`${J(i)}}
|
|
54
|
-
Here are diff:
|
|
55
|
-
${r}`}sanitizeMessage(t,r,n,o){try{const u=JSON.parse(t).map(i=>this.extractMessageAsType(i,r)).map(i=>o?{title:`${i.subject}`,value:`${i.subject}`}:{title:`${i.subject}`,value:`${i.subject}${i.body?`
|
|
56
|
-
|
|
57
|
-
${i.body}`:""}${i.footer?`
|
|
58
|
-
|
|
59
|
-
${i.footer}`:""}`});return u.length>n?u.slice(0,n):u}catch{const u=/\[[\s\S]*?\]/;try{const i=t.match(u);if(!i)return[];const a=i[0],p=JSON.parse(a).map(c=>this.extractMessageAsType(c,r)).map(c=>o?{title:`${c.subject}`,value:`${c.subject}`}:{title:`${c.subject}`,value:`${c.subject}${c.body?`
|
|
60
|
-
|
|
61
|
-
${c.body}`:""}${c.footer?`
|
|
62
|
-
|
|
63
|
-
${c.footer}`:""}`});return p.length>n?p.slice(0,n):p}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(),a=u.charAt(0).toLowerCase()+u.slice(1);t=`${i}${s||""}: ${a}`}return t}}var qr="1.12.6",Oi="A Reactive CLI that generates git commit messages with various AI";class F extends Error{}const ht=" ",pe=e=>{e instanceof Error&&(e instanceof F||(e.stack&&console.error(g.dim(e.stack.split(`
|
|
36
|
+
${m.footer}`:""}`}));return l.length>n?l.slice(0,n):l}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(),a=u.charAt(0).toLowerCase()+u.slice(1);t=`${i}${s||""}: ${a}`}return t}}var Jr="2.0.0",vi="A Reactive CLI that generates git commit messages with various AI";class F extends Error{}const Ft=" ",me=e=>{e instanceof Error&&(e instanceof F||(e.stack&&console.error(C.dim(e.stack.split(`
|
|
64
37
|
`).slice(1).join(`
|
|
65
38
|
`))),console.error(`
|
|
66
|
-
${
|
|
67
|
-
${
|
|
68
|
-
${
|
|
39
|
+
${Ft}${C.dim(`aicommit2 v${Jr}`)}`),console.error(`
|
|
40
|
+
${Ft}Please open a Bug report with the information above:`),console.error(`${Ft}https://github.com/tak-bro/aicommit2/issues/new/choose`)))},Vr=I.join(qe.homedir(),".aicommit2_log"),Bi=new Date,H=(e,t,r,n)=>{const o=`[${e}]`,s=xi(Bi,t),u=`${Vr}/${s}`,i=`- System Prompt
|
|
41
|
+
${r}`,a=`- Response
|
|
42
|
+
${n}`,l=`[Git Diff]
|
|
43
|
+
${t}`;if(W.existsSync(u)){const m=W.readFileSync(u,"utf-8");Yr(u,`${o}
|
|
44
|
+
${a}
|
|
69
45
|
|
|
70
|
-
${
|
|
71
|
-
${n}
|
|
46
|
+
${i}
|
|
72
47
|
|
|
48
|
+
${m}`);return}Yr(u,`${o}
|
|
49
|
+
${a}
|
|
73
50
|
|
|
74
|
-
[AICommit2 Prompt]
|
|
75
51
|
${i}
|
|
76
52
|
|
|
53
|
+
${l}`)},xi=(e,t)=>{const{year:r,month:n,day:o,hours:s,minutes:u,seconds:i}=Pi(e),l=jn(0).update(t).digest("hex");return`aic2_${r}-${n}-${o}_${s}:${u}:${i}_${l}.log`},Yr=(e,t="")=>{W.mkdirSync(I.dirname(e),{recursive:!0}),W.writeFileSync(e,t,"utf-8")},Pi=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}},L={locale:"en",maxLength:50,type:"conventional",generate:1,systemPrompt:"",systemPromptPath:""},Si={"":"<commit message>",conventional:`<type>(<optional scope>): <description>
|
|
77
54
|
|
|
78
|
-
[
|
|
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(_.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 Li extends j{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 R(this.generateMessage()).pipe(T(t=>P(t)),S(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),I(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"],a={...Y,locale:r,maxLength:i,type:o,generate:n,promptPath:s},p=`${J(a)}`,c={max_tokens:this.params.config["max-tokens"],temperature:this.params.config.temperature,system:p,messages:[{role:"user",content:`Here are diff: ${t}`}],model:this.params.config.ANTHROPIC_MODEL},f=(await this.anthropic.messages.create(c)).content.map(({text:d})=>d).join("");return u&&G("Anthropic",t,p,f),this.sanitizeMessage(f,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 de{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 Ti extends j{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 R(this.generateMessage()).pipe(T(t=>P(t)),S(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),I(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"],a=this.buildPrompt(r,t,n,i,o,s);this.checkAvailableModels();const l=await this.createChatCompletions(a);return u&&G("Codestral",t,a,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 de({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:zr(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 j{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 R(this.generateMessage()).pipe(T(t=>P(t)),S(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),I(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"],a=this.buildPrompt(r,t,n,i,o,s),l=this.params.config["max-tokens"],c=(await this.cohere.generate({prompt:a,maxTokens:l,temperature:this.params.config.temperature,model:this.params.config.COHERE_MODEL})).generations.map(D=>D.text).join("");return u&&G("Cohere",t,a,c),this.sanitizeMessage(c,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 j{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(a=>u.push(a[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 R(this.generateMessage()).pipe(T(t=>P(t)),S(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),I(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"],a=this.buildPrompt(r,t,n,i,o,s),l=this.params.config["max-tokens"],f=(await(await this.genAI.getGenerativeModel({model:this.params.config.GEMINI_MODEL,generationConfig:{maxOutputTokens:l,temperature:this.params.config.temperature}}).generateContent(a)).response).text();return u&&G("Gemini",t,a,f),this.sanitizeMessage(f,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 j{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 R(this.generateMessage()).pipe(T(t=>P(t)),S(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),I(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"],a={...Y,locale:r,maxLength:i,type:o,generate:n,promptPath:s},p=`${J(a)}`,D=(await this.groq.chat.completions.create({messages:[{role:"system",content:p},{role:"user",content:`Here are diff: ${t}`}],model:this.params.config.GROQ_MODEL},{timeout:this.params.config.timeout})).choices[0].message.content||"";return u&&G("Groq",t,p,D),this.sanitizeMessage(D,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){throw t}}}class ji extends j{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 R(this.generateMessage()).pipe(T(t=>P(t)),S(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),I(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&&G("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 a=n[i];if(n[a.unlisted])continue;const l={id:u(a.id),name:u(a.name),displayName:u(a.displayName),preprompt:u(a.preprompt),promptExamples:[],websiteUrl:u(a.websiteUrl),description:u(a.description),datasetName:u(a.datasetName),datasetUrl:u(a.datasetUrl),modelUrl:u(a.modelUrl),parameters:{}},p=u(a.promptExamples);if(p!==null){const f=p.map(d=>u(d));l.promptExamples=f.map(d=>({title:n[d.title],prompt:n[d.prompt]}))}const c=u(a.parameters),D={};for(const[f,d]of Object.entries(c)){if(d===-1){D[f]=null;continue}if(Array.isArray(n[d])){D[f]=n[d].map(h=>n[h]);continue}D[f]=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],a=o[o[0].messages],l=[];for(const p of a){const c=o[p],D=new Date(o[c.createdAt][1]).getTime()/1e3,f=new Date(o[c.updatedAt][1]).getTime()/1e3;l.push({id:o[c.id],role:o[c.from],content:o[c.content],createdAt:D,updatedAt:f})}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 f=D.split(`
|
|
80
|
-
|
|
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)+Se;else u&&typeof u=="object"?r.push(s):n+=ne(s)+o+ne(u)+Se}t.section&&n.length&&(n="["+ne(t.section)+"]"+Se+n);for(const s of r){const u=Vr(s).join("\\."),i=(t.section?t.section+".":"")+u,{whitespace:a}=t,l=Ct(e[s],{section:i,whitespace:a});n.length&&l.length&&(n+=Se),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 a=i.match(o);if(!a)continue;if(a[1]!==void 0){if(n=Ie(a[1]),n==="__proto__"){r=Object.create(null);continue}r=t[n]=t[n]||Object.create(null);continue}const l=Ie(a[2]),p=l.length>2&&l.slice(-2)==="[]",c=p?l.slice(0,-2):l;if(c==="__proto__")continue;const D=a[3]?Ie(a[4]):!0,f=D==="true"||D==="false"||D==="null"?JSON.parse(D):D;p&&(gt.call(r,c)?Array.isArray(r[c])||(r[c]=[r[c]]):r[c]=[]),Array.isArray(r[c])?r[c].push(f):r[c]=f}const u=[];for(const i of Object.keys(t)){if(!gt.call(t,i)||typeof t[i]!="object"||Array.isArray(t[i]))continue;const a=Vr(i);r=t;const l=a.pop(),p=l.replace(/\\\./g,".");for(const c of a)c!=="__proto__"&&((!gt.call(r,c)||typeof r[c]!="object")&&(r[c]=Object.create(null)),r=r[c]);r===t&&p===l||(r[p]=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=X(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)},PERPLEXITY_KEY(e){return e||""},PERPLEXITY_MODEL(e){return!e||e.length===0?"llama-3.1-sonar-small-128k-chat":(C("PERPLEXITY_MODEL",["llama-3.1-sonar-small-128k-online","llama-3.1-sonar-small-128k-chat","llama-3.1-sonar-large-128k-online","llama-3.1-sonar-large-128k-chat","llama-3.1-8b-instruct","llama-3.1-70b-instruct"].includes(e),"Invalid model type of Perplexity"),e)}},yt=_.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 Yi extends j{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(`[${Yr(this.model)}]`),this.errorPrefix=g.red.bold(`[${Yr(this.model)}]`),this.host=this.params.config.OLLAMA_HOST||Et,this.ollama=new qn({host:this.host})}generateCommitMessage$(){return R(this.generateMessage()).pipe(T(t=>P(t)),S(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),I(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&&G(`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 de({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={...Y,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`${J(t)}`}}var wt={},At={exports:{}},me={exports:{}},$t,on;function zi(){if(on)return $t;on=1;var e=1e3,t=e*60,r=t*60,n=r*24,o=n*7,s=n*365.25;$t=function(p,c){c=c||{};var D=typeof p;if(D==="string"&&p.length>0)return u(p);if(D==="number"&&isFinite(p))return c.long?a(p):i(p);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(p))};function u(p){if(p=String(p),!(p.length>100)){var c=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(p);if(c){var D=parseFloat(c[1]),f=(c[2]||"ms").toLowerCase();switch(f){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(p){var c=Math.abs(p);return c>=n?Math.round(p/n)+"d":c>=r?Math.round(p/r)+"h":c>=t?Math.round(p/t)+"m":c>=e?Math.round(p/e)+"s":p+"ms"}function a(p){var c=Math.abs(p);return c>=n?l(p,c,n,"day"):c>=r?l(p,c,r,"hour"):c>=t?l(p,c,t,"minute"):c>=e?l(p,c,e,"second"):p+" ms"}function l(p,c,D,f){var d=c>=D*1.5;return Math.round(p/D)+" "+f+(d?"s":"")}return $t}var vt,sn;function un(){if(sn)return vt;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=zi(),n.destroy=p,Object.keys(t).forEach(c=>{n[c]=t[c]}),n.names=[],n.skips=[],n.formatters={};function r(c){let D=0;for(let f=0;f<c.length;f++)D=(D<<5)-D+c.charCodeAt(f),D|=0;return n.colors[Math.abs(D)%n.colors.length]}n.selectColor=r;function n(c){let D,f=null,d,h;function m(...E){if(!m.enabled)return;const b=m,A=Number(new Date),H=A-(D||A);b.diff=H,b.prev=D,b.curr=A,D=A,E[0]=n.coerce(E[0]),typeof E[0]!="string"&&E.unshift("%O");let U=0;E[0]=E[0].replace(/%([a-zA-Z%])/g,(w,ue)=>{if(w==="%%")return"%";U++;const Nt=n.formatters[ue];if(typeof Nt=="function"){const An=E[U];w=Nt.call(b,An),E.splice(U,1),U--}return w}),n.formatArgs.call(b,E),(b.log||n.log).apply(b,E)}return m.namespace=c,m.useColors=n.useColors(),m.color=n.selectColor(c),m.extend=o,m.destroy=n.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>f!==null?f:(d!==n.namespaces&&(d=n.namespaces,h=n.enabled(c)),h),set:E=>{f=E}}),typeof n.init=="function"&&n.init(m),m}function o(c,D){const f=n(this.namespace+(typeof D>"u"?":":D)+c);return f.log=this.log,f}function s(c){n.save(c),n.namespaces=c,n.names=[],n.skips=[];let D;const f=(typeof c=="string"?c:"").split(/[\s,]+/),d=f.length;for(D=0;D<d;D++)f[D]&&(c=f[D].replace(/\*/g,".*?"),c[0]==="-"?n.skips.push(new RegExp("^"+c.slice(1)+"$")):n.names.push(new RegExp("^"+c+"$")))}function u(){const c=[...n.names.map(a),...n.skips.map(a).map(D=>"-"+D)].join(",");return n.enable(""),c}function i(c){if(c[c.length-1]==="*")return!0;let D,f;for(D=0,f=n.skips.length;D<f;D++)if(n.skips[D].test(c))return!1;for(D=0,f=n.names.length;D<f;D++)if(n.names[D].test(c))return!0;return!1}function a(c){return c.toString().substring(2,c.toString().length-2).replace(/\.\*\?$/,"*")}function l(c){return c instanceof Error?c.stack||c.message:c}function p(){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 vt=e,vt}me.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 a=!1;return()=>{a||(a=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),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(a){if(a[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+a[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;a.splice(1,0,l,"color: inherit");let p=0,c=0;a[0].replace(/%[a-zA-Z%]/g,D=>{D!=="%%"&&(p++,D==="%c"&&(c=p))}),a.splice(c,0,l)}t.log=console.debug||console.log||(()=>{});function o(a){try{a?t.storage.setItem("debug",a):t.storage.removeItem("debug")}catch{}}function s(){let a;try{a=t.storage.getItem("debug")}catch{}return!a&&typeof process<"u"&&"env"in process&&(a=process.env.DEBUG),a}function u(){try{return localStorage}catch{}}e.exports=un()(t);const{formatters:i}=e.exports;i.j=function(a){try{return JSON.stringify(a)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(me,me.exports)),me.exports}var he={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 xt,Dn;function Vi(){if(Dn)return xt;Dn=1;const e=je,t=Te,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(a){return a===0?!1:{level:a,hasBasic:!0,has256:a>=2,has16m:a>=3}}function u(a,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(a&&!l&&o===void 0)return 0;const p=o||0;if(n.TERM==="dumb")return p;if(process.platform==="win32"){const c=e.release().split(".");return Number(c[0])>=10&&Number(c[2])>=10586?Number(c[2])>=14931?3:2:1}if("CI"in n)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(c=>c in n)||n.CI_NAME==="codeship"?1:p;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 c=parseInt((n.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(n.TERM_PROGRAM){case"iTerm.app":return c>=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:p}function i(a){const l=u(a,a&&a.isTTY);return s(l)}return xt={supportsColor:i,stdout:s(u(!0,t.isatty(1))),stderr:s(u(!0,t.isatty(2)))},xt}he.exports;var ln;function Xi(){return ln||(ln=1,function(e,t){const r=Te,n=Kt;t.init=p,t.log=i,t.formatArgs=s,t.save=a,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,f)=>{const d=f.substring(6).toLowerCase().replace(/_([a-z])/g,(m,E)=>E.toUpperCase());let h=process.env[f];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:f,useColors:d}=this;if(d){const h=this.color,m="\x1B[3"+(h<8?h:"8;5;"+h),E=` ${m};1m${f} \x1B[0m`;D[0]=E+D[0].split(`
|
|
55
|
+
[optional body]
|
|
56
|
+
|
|
57
|
+
[optional footer(s)]`,gitmoji:`:<emoji>:(<optional scope>): <description>
|
|
58
|
+
|
|
59
|
+
[optional body]
|
|
60
|
+
|
|
61
|
+
[optional footer(s)]`},Oi={"":"",gitmoji:`
|
|
62
|
+
${Object.entries({":sparkles:":"Introduce new features.",":bug:":"Fix a bug.",":memo:":"Add or update documentation.",":art:":"Improve structure / format of the code.",":zap:":"Improve performance.",":fire:":"Remove code or files.",":ambulance:":"Critical hotfix.",":white_check_mark:":"Add, update, or pass tests.",":lock:":"Fix security or privacy issues.",":rocket:":"Deploy stuff.",":lipstick:":"Add or update the UI and style files.",":tada:":"Begin a project.",":recycle:":"Refactor code.",":wrench:":"Add or update configuration files.",":bulb:":"Add or update comments in source code.",":twisted_rightwards_arrows:":"Merge branches."}).map(([e,t])=>` - ${e}: ${t}`).join(`
|
|
63
|
+
`)}`,conventional:`
|
|
64
|
+
${Object.entries({docs:"Documentation only changes",style:"Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)",refactor:"A code change that neither fixes a bug nor adds a feature",perf:"A code change that improves performance",test:"Adding missing tests or correcting existing tests",build:"Changes that affect the build system or external dependencies",ci:"Changes to CI configuration files, scripts",chore:"Other changes that don't modify src or test files",revert:"Reverts a previous commit",feat:"A new feature",fix:"A bug fix"}).map(([e,t])=>` - ${e}: ${t}`).join(`
|
|
65
|
+
`)}`},Mi=(e,t)=>e.replace(/{(\w+)}/g,(r,n)=>t[n]?.toString()||L[n]?.toString()),Xr=e=>{const{type:t,maxLength:r,generate:n,locale:o}=e;return[`You are a helpful assistant specializing in writing clear and informative Git commit messages using the ${t} style`,`Based on the given code changes or context, generate exactly ${n} ${t} Git commit message${n!==1?"s":""} based on the following guidelines.`,`1. Message Language: ${o}`,`2. Format: follow the ${t} Commits format:`,`${Si[t]}`,`3. Types: use one of the following types:${Oi[t]}`,"4. Exclude anything unnecessary such as translation. Your entire response will be passed directly into git commit."].filter(Boolean).join(`
|
|
66
|
+
`)},Oe=(e,t)=>{const r=n=>n==="conventional"?`${Array(t).fill(null).map((o,s)=>`
|
|
67
|
+
{
|
|
68
|
+
"subject": "fix: fix bug in user authentication process",
|
|
69
|
+
"body": "- Update login function to handle edge cases\\n- Add additional error logging for debugging",
|
|
70
|
+
"footer": ""
|
|
71
|
+
}`).join(",")}`:`${Array(t).fill(null).map((o,s)=>`
|
|
72
|
+
{
|
|
73
|
+
"subject": "\u{1F5BC}\uFE0F Add profile picture upload feature",
|
|
74
|
+
"body": "- Implement server-side handling of file uploads\\n- Add client-side image preview and cropping",
|
|
75
|
+
"footer": ""
|
|
76
|
+
}`).join(",")}`;return[`Provide your response as a JSON array containing exactly ${t} object${t!==1?"s":""}, each with the following keys:`,`- "subject": The main commit message using the ${e} style. It should be a concise summary of the changes.`,'- "body": An optional detailed explanation of the changes. If not needed, use an empty string.','- "footer": An optional footer for metadata like BREAKING CHANGES. If not needed, use an empty string.',`The array must always contain ${t} element${t!==1?"s":""}, no more and no less.`,`Example response format:
|
|
77
|
+
[${r(e)}
|
|
78
|
+
]`,`Ensure you generate exactly ${t} commit message${t!==1?"s":""}, even if it requires creating slightly varied versions for similar changes.`,"The response should be valid JSON that can be parsed without errors."].filter(Boolean).join(`
|
|
79
|
+
`)},q=e=>{const{systemPrompt:t,systemPromptPath:r,type:n,generate:o}=e;if(t)return`${t}
|
|
80
|
+
${Oe(n,o)}`;if(!r)return`${Xr(e)}
|
|
81
|
+
${Oe(n,o)}`;try{const s=W.readFileSync(I.resolve(r),"utf-8");return`${Mi(s,e)}
|
|
82
|
+
${Oe(n,o)}`}catch{return`${Xr(e)}
|
|
83
|
+
${Oe(n,o)}`}};class Ii 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 O({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#AE5630",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Anthropic]"),this.errorPrefix=C.red.bold("[Anthropic]"),this.anthropic=new Rn({apiKey:this.params.config.key})}generateCommitMessage$(){return j(this.generateMessage()).pipe(R(t=>M(t)),T(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),k(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,temperature:s,locale:u,generate:i,type:a,maxLength:l}=this.params.config,m={...L,locale:u,maxLength:l,type:a,generate:i,systemPrompt:r,systemPromptPath:n},c=q(m),D={max_tokens:this.params.config.maxTokens,temperature:s,system:c,messages:[{role:"user",content:`Here are diff: ${t}`}],model:this.params.config.model},d=(await this.anthropic.messages.create(D)).content.map(({text:h})=>h).join("");return o&&H("Anthropic",t,c,d),this.parseMessage(d,a,i)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}}const Zr=e=>e&&`${e[0].toUpperCase()}${e.slice(1)}`,Me=(e,t)=>{const r=Math.ceil(e),n=Math.floor(t);return Math.floor(Math.random()*(n-r+1))+r},Ti=(e,t)=>e.disabled&&!t.disabled?1:!e.disabled&&t.disabled?-1:0,Ie=e=>e.reduce((t,r)=>Array.isArray(r)?t.concat(Ie(r)):t.concat(r),[]);class pe{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=_n.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 ki 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 O({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#e28c58",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Codestral]"),this.errorPrefix=C.red.bold("[Codestral]"),this.apiKey=this.params.config.key}generateCommitMessage$(){return j(this.generateMessage()).pipe(R(t=>M(t)),T(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),k(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,generate:u,type:i,maxLength:a}=this.params.config,l={...L,locale:s,maxLength:a,type:i,generate:u,systemPrompt:r,systemPromptPath:n},m=q(l);this.checkAvailableModels();const c=await this.createChatCompletions(m);return o&&H("Codestral",t,m,c),this.parseMessage(c,i,u)}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.model))return!0;throw new Error("Invalid model type of Codestral AI")}async createChatCompletions(t){const n=(await new pe({method:"POST",baseURL:`${this.host}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.model,messages:[{role:"system",content:t},{role:"user",content:`Here are diff: ${this.params.stagedDiff.diff}`}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config.maxTokens,stream:!1,safe_prompt:!1,random_seed:Me(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 Li 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 O({name:`${this.errorPrefix} ${u}`,value:s,isError:!0,disabled:!0})},this.colors={primary:"#D18EE2",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Cohere]"),this.errorPrefix=C.red.bold("[Cohere]"),this.cohere=new Gn({token:this.params.config.key})}generateCommitMessage$(){return j(this.generateMessage()).pipe(R(t=>M(t)),T(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),k(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,temperature:u,generate:i,type:a,maxLength:l}=this.params.config,m={...L,locale:s,maxLength:l,type:a,generate:i,systemPrompt:r,systemPromptPath:n},c=q(m),D=this.params.config.maxTokens,p=await this.cohere.chat({chatHistory:c?[{role:"SYSTEM",message:c}]:[],message:`Here are diff: ${t}`,connectors:[{id:"web-search"}],maxTokens:D,temperature:u,model:this.params.config.model,seed:Me(10,1e3)});return o&&H("Cohere",t,c,p.text),this.parseMessage(p.text,a,i)}catch(t){const r=t;throw r instanceof Un?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(a=>u.push(a[1]));const i=u[1]||"An error occurred";return O({name:`${this.errorPrefix} ${i}`,value:i,isError:!0,disabled:!0})},this.colors={primary:"#0077FF",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Gemini]"),this.errorPrefix=C.red.bold("[Gemini]"),this.genAI=new Hn(this.params.config.key)}generateCommitMessage$(){return j(this.generateMessage()).pipe(R(t=>M(t)),T(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),k(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,temperature:u,generate:i,type:a,maxLength:l}=this.params.config,m=this.params.config.maxTokens,c={...L,locale:s,maxLength:l,type:a,generate:i,systemPrompt:r,systemPromptPath:n},D=q(c),g=(await this.genAI.getGenerativeModel({model:this.params.config.model,systemInstruction:D,generationConfig:{maxOutputTokens:m,temperature:this.params.config.temperature}}).generateContent(`Here are diff: ${t}`)).response.text();return o&&H("Gemini",t,D,g),this.parseMessage(g,a,i)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}}var yt={},Et={exports:{}},fe={exports:{}},bt,Qr;function Ri(){if(Qr)return bt;Qr=1;var e=1e3,t=e*60,r=t*60,n=r*24,o=n*7,s=n*365.25;bt=function(m,c){c=c||{};var D=typeof m;if(D==="string"&&m.length>0)return u(m);if(D==="number"&&isFinite(m))return c.long?a(m):i(m);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(m))};function u(m){if(m=String(m),!(m.length>100)){var c=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(m);if(c){var D=parseFloat(c[1]),p=(c[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return D*s;case"weeks":case"week":case"w":return D*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(m){var c=Math.abs(m);return c>=n?Math.round(m/n)+"d":c>=r?Math.round(m/r)+"h":c>=t?Math.round(m/t)+"m":c>=e?Math.round(m/e)+"s":m+"ms"}function a(m){var c=Math.abs(m);return c>=n?l(m,c,n,"day"):c>=r?l(m,c,r,"hour"):c>=t?l(m,c,t,"minute"):c>=e?l(m,c,e,"second"):m+" ms"}function l(m,c,D,p){var d=c>=D*1.5;return Math.round(m/D)+" "+p+(d?"s":"")}return bt}var wt,en;function tn(){if(en)return wt;en=1;function e(t){n.debug=n,n.default=n,n.coerce=l,n.disable=u,n.enable=s,n.enabled=i,n.humanize=Ri(),n.destroy=m,Object.keys(t).forEach(c=>{n[c]=t[c]}),n.names=[],n.skips=[],n.formatters={};function r(c){let D=0;for(let p=0;p<c.length;p++)D=(D<<5)-D+c.charCodeAt(p),D|=0;return n.colors[Math.abs(D)%n.colors.length]}n.selectColor=r;function n(c){let D,p=null,d,h;function g(...E){if(!g.enabled)return;const A=g,v=Number(new Date),Y=v-(D||v);A.diff=Y,A.prev=D,A.curr=v,D=v,E[0]=n.coerce(E[0]),typeof E[0]!="string"&&E.unshift("%O");let z=0;E[0]=E[0].replace(/%([a-zA-Z%])/g,(x,wn)=>{if(x==="%%")return"%";z++;const Ht=n.formatters[wn];if(typeof Ht=="function"){const An=E[z];x=Ht.call(A,An),E.splice(z,1),z--}return x}),n.formatArgs.call(A,E),(A.log||n.log).apply(A,E)}return g.namespace=c,g.useColors=n.useColors(),g.color=n.selectColor(c),g.extend=o,g.destroy=n.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(d!==n.namespaces&&(d=n.namespaces,h=n.enabled(c)),h),set:E=>{p=E}}),typeof n.init=="function"&&n.init(g),g}function o(c,D){const p=n(this.namespace+(typeof D>"u"?":":D)+c);return p.log=this.log,p}function s(c){n.save(c),n.namespaces=c,n.names=[],n.skips=[];let D;const p=(typeof c=="string"?c:"").split(/[\s,]+/),d=p.length;for(D=0;D<d;D++)p[D]&&(c=p[D].replace(/\*/g,".*?"),c[0]==="-"?n.skips.push(new RegExp("^"+c.slice(1)+"$")):n.names.push(new RegExp("^"+c+"$")))}function u(){const c=[...n.names.map(a),...n.skips.map(a).map(D=>"-"+D)].join(",");return n.enable(""),c}function i(c){if(c[c.length-1]==="*")return!0;let D,p;for(D=0,p=n.skips.length;D<p;D++)if(n.skips[D].test(c))return!1;for(D=0,p=n.names.length;D<p;D++)if(n.names[D].test(c))return!0;return!1}function a(c){return c.toString().substring(2,c.toString().length-2).replace(/\.\*\?$/,"*")}function l(c){return c instanceof Error?c.stack||c.message:c}function m(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}return wt=e,wt}fe.exports;var rn;function ji(){return rn||(rn=1,function(e,t){t.formatArgs=n,t.save=o,t.load=s,t.useColors=r,t.storage=u(),t.destroy=(()=>{let a=!1;return()=>{a||(a=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),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(a){if(a[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+a[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;a.splice(1,0,l,"color: inherit");let m=0,c=0;a[0].replace(/%[a-zA-Z%]/g,D=>{D!=="%%"&&(m++,D==="%c"&&(c=m))}),a.splice(c,0,l)}t.log=console.debug||console.log||(()=>{});function o(a){try{a?t.storage.setItem("debug",a):t.storage.removeItem("debug")}catch{}}function s(){let a;try{a=t.storage.getItem("debug")}catch{}return!a&&typeof process<"u"&&"env"in process&&(a=process.env.DEBUG),a}function u(){try{return localStorage}catch{}}e.exports=tn()(t);const{formatters:i}=e.exports;i.j=function(a){try{return JSON.stringify(a)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(fe,fe.exports)),fe.exports}var de={exports:{}},At,nn;function _i(){return nn||(nn=1,At=(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)}),At}var $t,on;function Gi(){if(on)return $t;on=1;const e=qe,t=_e,r=_i(),{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(a){return a===0?!1:{level:a,hasBasic:!0,has256:a>=2,has16m:a>=3}}function u(a,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(a&&!l&&o===void 0)return 0;const m=o||0;if(n.TERM==="dumb")return m;if(process.platform==="win32"){const c=e.release().split(".");return Number(c[0])>=10&&Number(c[2])>=10586?Number(c[2])>=14931?3:2:1}if("CI"in n)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(c=>c in n)||n.CI_NAME==="codeship"?1:m;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 c=parseInt((n.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(n.TERM_PROGRAM){case"iTerm.app":return c>=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:m}function i(a){const l=u(a,a&&a.isTTY);return s(l)}return $t={supportsColor:i,stdout:s(u(!0,t.isatty(1))),stderr:s(u(!0,t.isatty(2)))},$t}de.exports;var sn;function Ui(){return sn||(sn=1,function(e,t){const r=_e,n=Vt;t.init=m,t.log=i,t.formatArgs=s,t.save=a,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=Gi();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,(g,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,g="\x1B[3"+(h<8?h:"8;5;"+h),E=` ${g};1m${p} \x1B[0m`;D[0]=E+D[0].split(`
|
|
83
84
|
`).join(`
|
|
84
|
-
`+E),D.push(
|
|
85
|
-
`)}function a(D){D?process.env.DEBUG=D:delete process.env.DEBUG}function l(){return process.env.DEBUG}function
|
|
86
|
-
`).map(
|
|
87
|
-
`).some(t=>t.indexOf("(https.js:")!==-1||t.indexOf("node:https:")!==-1)}function
|
|
85
|
+
`+E),D.push(g+"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)+`
|
|
86
|
+
`)}function a(D){D?process.env.DEBUG=D:delete process.env.DEBUG}function l(){return process.env.DEBUG}function m(D){D.inspectOpts={};const p=Object.keys(t.inspectOpts);for(let d=0;d<p.length;d++)D.inspectOpts[p[d]]=t.inspectOpts[p[d]]}e.exports=tn()(t);const{formatters:c}=e.exports;c.o=function(D){return this.inspectOpts.colors=this.useColors,n.inspect(D,this.inspectOpts).split(`
|
|
87
|
+
`).map(p=>p.trim()).join(" ")},c.O=function(D){return this.inspectOpts.colors=this.useColors,n.inspect(D,this.inspectOpts)}}(de,de.exports)),de.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Et.exports=ji():Et.exports=Ui();var vt=Et.exports,Bt={};Object.defineProperty(Bt,"__esModule",{value:!0});function Hi(e){return function(t,r){return new Promise((n,o)=>{e.call(this,t,r,(s,u)=>{s?o(s):n(u)})})}}Bt.default=Hi;var un=$&&$.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const qi=Jt,zi=un(vt),Wi=un(Bt),he=zi.default("agent-base");function Ki(e){return!!e&&typeof e.addRequest=="function"}function xt(){const{stack:e}=new Error;return typeof e!="string"?!1:e.split(`
|
|
88
|
+
`).some(t=>t.indexOf("(https.js:")!==-1||t.indexOf("node:https:")!==-1)}function Te(e,t){return new Te.Agent(e,t)}(function(e){class t extends qi.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:xt()?443:80}set defaultPort(n){this.explicitDefaultPort=n}get protocol(){return typeof this.explicitProtocol=="string"?this.explicitProtocol:xt()?"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=xt()),s.host==null&&(s.host="localhost"),s.port==null&&(s.port=s.secureEndpoint?443:80),s.protocol==null&&(s.protocol=s.secureEndpoint?"https:":"http:"),s.host&&s.path&&delete s.path,delete s.agent,delete s.hostname,delete s._defaultAgent,delete s.defaultPort,delete s.createConnection,n._last=!0,n.shouldKeepAlive=!1;let u=!1,i=null;const a=s.timeout||this.timeout,l=p=>{n._hadError||(n.emit("error",p),n._hadError=!0)},m=()=>{i=null,u=!0;const p=new Error(`A "socket" was not created for HTTP request before ${a}ms`);p.code="ETIMEOUT",l(p)},c=p=>{u||(i!==null&&(clearTimeout(i),i=null),l(p))},D=p=>{if(u)return;if(i!=null&&(clearTimeout(i),i=null),Ki(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=Wi.default(this.callback)):this.promisifiedCallback=this.callback),typeof a=="number"&&a>0&&(i=setTimeout(m,a)),"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,c)}catch(p){Promise.reject(p).catch(c)}}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})(Te||(Te={}));var Ji=Te,Pt={},Vi=$&&$.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Pt,"__esModule",{value:!0});const Yi=Vi(vt),ge=Yi.default("https-proxy-agent:parse-proxy-response");function Xi(e){return new Promise((t,r)=>{let n=0;const o=[];function s(){const c=e.read();c?m(c):e.once("readable",s)}function u(){e.removeListener("end",a),e.removeListener("error",l),e.removeListener("close",i),e.removeListener("readable",s)}function i(c){ge("onclose had error %o",c)}function a(){ge("onend")}function l(c){u(),ge("onerror %o",c),r(c)}function m(c){o.push(c),n+=c.length;const D=Buffer.concat(o,n);if(D.indexOf(`\r
|
|
88
89
|
\r
|
|
89
|
-
`)===-1){
|
|
90
|
-
`)),h=+d.split(" ")[1];
|
|
91
|
-
`;n.auth&&(u["Proxy-Authorization"]=`Basic ${Buffer.from(n.auth).toString("base64")}`);let{host:l,port:
|
|
92
|
-
`;const D=
|
|
93
|
-
`);const{statusCode:
|
|
90
|
+
`)===-1){ge("have not received end of HTTP headers yet..."),s();return}const d=D.toString("ascii",0,D.indexOf(`\r
|
|
91
|
+
`)),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",a),s()})}Pt.default=Xi;var Zi=$&&$.__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(m){try{l(n.next(m))}catch(c){u(c)}}function a(m){try{l(n.throw(m))}catch(c){u(c)}}function l(m){m.done?s(m.value):o(m.value).then(i,a)}l((n=n.apply(e,t||[])).next())})},oe=$&&$.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(yt,"__esModule",{value:!0});const an=oe(Kn),cn=oe(Jn),Qi=oe(Vn),ea=oe(Kt),ta=oe(vt),ra=Ji,na=oe(Pt),Ce=ta.default("https-proxy-agent:agent");class oa extends ra.Agent{constructor(t){let r;if(typeof t=="string"?r=Qi.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||ia(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 Zi(this,void 0,void 0,function*(){const{proxy:n,secureProxy:o}=this;let s;o?(Ce("Creating `tls.Socket`: %o",n),s=cn.default.connect(n)):(Ce("Creating `net.Socket`: %o",n),s=an.default.connect(n));const u=Object.assign({},n.headers);let a=`CONNECT ${`${r.host}:${r.port}`} HTTP/1.1\r
|
|
92
|
+
`;n.auth&&(u["Proxy-Authorization"]=`Basic ${Buffer.from(n.auth).toString("base64")}`);let{host:l,port:m,secureEndpoint:c}=r;ua(m,c)||(l+=`:${m}`),u.Host=l,u.Connection="close";for(const g of Object.keys(u))a+=`${g}: ${u[g]}\r
|
|
93
|
+
`;const D=na.default(s);s.write(`${a}\r
|
|
94
|
+
`);const{statusCode:p,buffered:d}=yield D;if(p===200){if(t.once("socket",sa),r.secureEndpoint){Ce("Upgrading socket connection to TLS");const g=r.servername||r.host;return cn.default.connect(Object.assign(Object.assign({},aa(r,"host","hostname","path","port")),{socket:s,servername:g}))}return s}s.destroy();const h=new an.default.Socket({writable:!1});return h.readable=!0,t.once("socket",g=>{Ce("replaying proxy buffer for failed request"),ea.default(g.listenerCount("data")>0),g.push(d),g.push(null)}),h})}}yt.default=oa;function sa(e){e.resume()}function ua(e,t){return!!(!t&&e===80||t&&e===443)}function ia(e){return typeof e=="string"?/^https:?$/i.test(e):!1}function aa(e,...t){const r={};let n;for(n in e)t.includes(n)||(r[n]=e[n]);return r}var ca=$&&$.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const St=ca(yt);function Ot(e){return new St.default(e)}(function(e){e.HttpsProxyAgent=St.default,e.prototype=St.default.prototype})(Ot||(Ot={}));var Da=Ot,la=Z(Da);const ma=async(e,t,r,n,o,s,u)=>new Promise((i,a)=>{const l=JSON.stringify(n),c=(e.protocol.includes("https")?Wn: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?la(s):void 0},D=>{const p=[];D.on("data",d=>p.push(d)),D.on("end",()=>{i({request:c,response:D,data:Buffer.concat(p).toString()})})});c.on("error",a),c.on("timeout",()=>{c.destroy(),a(new F(`Time out error: request took over ${o}ms. Try increasing the \`timeout\` config`))}),c.write(l),c.end()}),pa=async(e,t,r,n,o,s)=>{const u=new URL(e),{response:i,data:a}=await ma(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 a&&(l+=`
|
|
94
95
|
|
|
95
96
|
${a}`),i.statusCode===500&&(l+=`
|
|
96
97
|
|
|
97
|
-
Check the API status: https://status.openai.com`),new F(l)}return JSON.parse(a)},
|
|
98
|
-
`)[
|
|
99
|
-
|
|
100
|
-
`),diff:n}},Ba=e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`;class Fe{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(`${Ba(t.files)}:`)),console.log(`${t.files.map(r=>` ${r}`).join(`
|
|
98
|
+
Check the API status: https://status.openai.com`),new F(l)}return JSON.parse(a)},ke=e=>e.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1"),fa=async(e,t,r,n,o,s,u,i,a,l,m,c,D,p)=>{try{const d=await pa(e,t,r,{model:n,messages:[{role:"system",content:c},{role:"user",content:`Here are diff: ${s}`}],temperature:m,top_p:1,frequency_penalty:0,presence_penalty:0,max_tokens:l,stream:!1,n:1},a,p),h=d.choices.filter(g=>g.message?.content).map(g=>ke(g.message.content)).join();return D&&H("OPEN AI",s,c,h),d.choices.filter(g=>g.message?.content).map(g=>ke(g.message.content))}catch(d){const h=d;throw h.code==="ENOTFOUND"?new F(`Error connecting to ${h.hostname} (${h.syscall})`):h}};class da 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 O({name:`${this.errorPrefix} ${u}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#f55036",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Groq]"),this.errorPrefix=C.red.bold("[Groq]"),this.groq=new qn({apiKey:this.params.config.key})}generateCommitMessage$(){return j(this.generateMessage()).pipe(R(t=>M(t)),T(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),k(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,temperature:u,generate:i,type:a,maxLength:l}=this.params.config,m=this.params.config.maxTokens,c={...L,locale:s,maxLength:l,type:a,generate:i,systemPrompt:r,systemPromptPath:n},D=q(c),p=await this.groq.chat.completions.create({messages:[{role:"system",content:D},{role:"user",content:`Here are diff: ${t}`}],model:this.params.config.model,max_tokens:m,temperature:u},{timeout:this.params.config.timeout}),d=p.choices.filter(g=>g.message?.content).map(g=>ke(g.message.content)).join();o&&H("Groq",t,D,d);const h=p.choices.filter(g=>g.message?.content).map(g=>ke(g.message.content));return Ie(h.map(g=>this.parseMessage(g,a,i)))}catch(t){throw t}}}class ha 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=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[HuggingFace]"),this.errorPrefix=C.red.bold("[HuggingFace]"),this.cookie=this.params.config.cookie}generateCommitMessage$(){return j(this.generateMessage()).pipe(R(t=>M(t)),T(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),k(this.handleError$))}async generateMessage(){try{await this.intialize();const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,generate:u,type:i,maxLength:a}=this.params.config,l={...L,locale:s,maxLength:a,type:i,generate:u,systemPrompt:r,systemPromptPath:n},m=q(l),c=await this.getNewChat(m),p=await(await this.sendMessage(`Here are diff: ${t}`,c.id)).completeResponsePromise();return o&&H("HuggingFace",t,m,p),this.parseMessage(p,i,u)}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.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 a=n[i];if(n[a.unlisted])continue;const l={id:u(a.id),name:u(a.name),displayName:u(a.displayName),preprompt:u(a.preprompt),promptExamples:[],websiteUrl:u(a.websiteUrl),description:u(a.description),datasetName:u(a.datasetName),datasetUrl:u(a.datasetUrl),modelUrl:u(a.modelUrl),parameters:{}},m=u(a.promptExamples);if(m!==null){const p=m.map(d=>u(d));l.promptExamples=p.map(d=>({title:n[d.title],prompt:n[d.prompt]}))}const c=u(a.parameters),D={};for(const[p,d]of Object.entries(c)){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],a=o[o[0].messages],l=[];for(const m of a){const c=o[m],D=new Date(o[c.createdAt][1]).getTime()/1e3,p=new Date(o[c.updatedAt][1]).getTime()/1e3;l.push({id:o[c.id],role:o[c.from],content:o[c.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(`
|
|
99
|
+
`),d=[];for(const h of p)h.trim()&&d.push(JSON.parse(h));return d}catch{return[{}]}}const i=new TextDecoder;let a="";const l=new TransformStream({async transform(D,p){const d=i.decode(D);try{const h=u(d);for(const g of h)g.type==="finalAnswer"?(a=g?.text||"",p.terminate()):g.type==="stream"&&p.enqueue(g?.token||"")}catch{throw new Error("Error during parsing response")}}}),m=s.body?.pipeThrough(l);async function c(){return new Promise(async(D,p)=>{try{if(!m)p("ModifiedStream undefined");else{const d=m.getReader();for(;;){const{done:h,value:g}=await d.read();if(h){D(a);break}}}}catch(d){p(d)}})}return{id:this.currentConversionID,stream:m,completeResponsePromise:c}}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()}}class ga 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 O({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#ff7000",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[MistralAI]"),this.errorPrefix=C.red.bold("[MistralAI]"),this.apiKey=this.params.config.key}generateCommitMessage$(){return j(this.generateMessage()).pipe(R(t=>M(t)),T(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),k(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,generate:u,type:i,maxLength:a}=this.params.config,l={...L,locale:s,maxLength:a,type:i,generate:u,systemPrompt:r,systemPromptPath:n},m=q(l);await this.checkAvailableModels();const c=await this.createChatCompletions(m,`Here are diff: ${t}`);return o&&H("MistralAI",t,m,c),this.parseMessage(c,this.params.config.type,u)}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.model))return!0;throw new Error(`Invalid model type of Mistral AI: ${this.params.config.model}`)}async getAvailableModels(){return(await new pe({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,r){const o=(await new pe({method:"POST",baseURL:`${this.host}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.model,messages:[{role:"system",content:t},{role:"user",content:r}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config.maxTokens,stream:!1,safe_prompt:!1,random_seed:Me(10,1e3)}).execute()).data;if(!o.choices||o.choices.length===0||!o.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return o.choices[0].message.content}}const{hasOwnProperty:Mt}=Object.prototype,Le=typeof process<"u"&&process.platform==="win32"?`\r
|
|
100
|
+
`:`
|
|
101
|
+
`,It=(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+=se(s+"[]")+o+se(i)+Le;else u&&typeof u=="object"?r.push(s):n+=se(s)+o+se(u)+Le}t.section&&n.length&&(n="["+se(t.section)+"]"+Le+n);for(const s of r){const u=Dn(s).join("\\."),i=(t.section?t.section+".":"")+u,{whitespace:a}=t,l=It(e[s],{section:i,whitespace:a});n.length&&l.length&&(n+=Le),n+=l}return n},Dn=e=>e.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(t=>t.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),ln=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 a=i.match(o);if(!a)continue;if(a[1]!==void 0){if(n=Ne(a[1]),n==="__proto__"){r=Object.create(null);continue}r=t[n]=t[n]||Object.create(null);continue}const l=Ne(a[2]),m=l.length>2&&l.slice(-2)==="[]",c=m?l.slice(0,-2):l;if(c==="__proto__")continue;const D=a[3]?Ne(a[4]):!0,p=D==="true"||D==="false"||D==="null"?JSON.parse(D):D;m&&(Mt.call(r,c)?Array.isArray(r[c])||(r[c]=[r[c]]):r[c]=[]),Array.isArray(r[c])?r[c].push(p):r[c]=p}const u=[];for(const i of Object.keys(t)){if(!Mt.call(t,i)||typeof t[i]!="object"||Array.isArray(t[i]))continue;const a=Dn(i);r=t;const l=a.pop(),m=l.replace(/\\\./g,".");for(const c of a)c!=="__proto__"&&((!Mt.call(r,c)||typeof r[c]!="object")&&(r[c]=Object.create(null)),r=r[c]);r===t&&m===l||(r[m]=t[i],u.push(i))}for(const i of u)delete t[i];return t},mn=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),se=e=>typeof e!="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&mn(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),Ne=(e,t)=>{if(e=(e||"").trim(),mn(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 Ca={parse:ln,decode:ln,stringify:It,encode:It,safe:se,unsafe:Ne},Tt=Z(Ca);const pn=e=>P.lstat(e).then(()=>!0,()=>!1),Fa=["","conventional","gitmoji"],kt="http://localhost:11434",{hasOwnProperty:ya}=Object.prototype,Lt=(e,t)=>ya.call(e,t),Nt=["OPENAI","OLLAMA","HUGGINGFACE","GEMINI","ANTHROPIC","MISTRAL","CODESTRAL","COHERE","GROQ","PERPLEXITY"],y=(e,t,r)=>{if(!t)throw new F(`Invalid config property ${e}: ${r}`)},f={systemPrompt(e){return e||""},systemPromptPath(e){return e||""},timeout(e){if(!e)return 1e4;y("timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return y("timeout",t>=500,"Must be greater than 500ms"),t},temperature(e){if(!e)return .7;y("temperature",/^(2|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 2");const t=Number(e);return y("temperature",t>0,"Must be greater than 0"),y("temperature",t<=2,"Must be less than or equal to 2"),t},maxTokens(e){return e?(y("maxTokens",/^\d+$/.test(e),"Must be an integer"),Number(e)):1024},logging(e){return typeof e=="boolean"?e:e==null?!0:(y("logging",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true")},locale(e){return e?(y("locale",e,"Cannot be empty"),y("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;y("generate",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return y("generate",t>0,"Must be greater than 0"),y("generate",t<=5,"Must be less or equal to 5"),t},type(e){return e?(y("type",Fa.includes(e),"Invalid commit type"),e):"conventional"},maxLength(e){if(!e)return 50;y("maxLength",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return y("maxLength",t>=20,"Must be greater than 20 characters"),t},ignoreBody(e){return typeof e=="boolean"?e:e==null?!0:(y("ignoreBody",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true")}},ue={OPENAI:{key:e=>e||"",model:e=>e||"gpt-3.5-turbo",url:e=>e?(y("OPENAI.url",/^https?:\/\//.test(e),"Must be a valid URL"),e):"https://api.openai.com",path:e=>e||"/v1/chat/completions",proxy:e=>e||"",systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,timeout:f.timeout,temperature:f.temperature,maxTokens:f.maxTokens,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody},HUGGINGFACE:{cookie:e=>e||"",model:e=>e?(y("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):"CohereForAI/c4ai-command-r-plus",systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody},GEMINI:{key:e=>e||"",model:e=>!e||e.length===0?"gemini-1.5-pro":(y("GEMINI.model",["gemini-1.5-flash","gemini-1.5-pro","gemini-1.5-pro-exp-0801"].includes(e),"Invalid model type of Gemini"),e),systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,temperature:f.temperature,maxTokens:f.maxTokens,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody},ANTHROPIC:{key:e=>e||"",model:e=>!e||e.length===0?"claude-3-haiku-20240307":(y("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),systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,temperature:f.temperature,maxTokens:f.maxTokens,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody},MISTRAL:{key:e=>e||"",model:e=>!e||e.length===0?"mistral-tiny":(y("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),systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,timeout:f.timeout,temperature:f.temperature,maxTokens:f.maxTokens,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody},CODESTRAL:{key:e=>e||"",model:e=>!e||e.length===0?"codestral-latest":(y("CODESTRAL.model",["codestral-latest","codestral-2405"].includes(e),"Invalid model type of Codestral"),e),systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,timeout:f.timeout,temperature:f.temperature,maxTokens:f.maxTokens,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody},OLLAMA:{model:e=>e?(typeof e=="string"?e?.split(","):e).map(r=>r.trim()).filter(r=>!!r&&r.length>0):[],host:e=>e?(y("OLLAMA.host",/^https?:\/\//.test(e),"Must be a valid URL"),e):kt,timeout:e=>{if(!e)return 1e5;y("OLLAMA.timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return y("OLLAMA.timeout",t>=500,"Must be greater than 500ms"),t},systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,temperature:f.temperature,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody},COHERE:{key:e=>e||"",model:e=>!e||e.length===0?"command":(y("COHERE.model",["command","command-nightly","command-light","command-light-nightly"].includes(e),"Invalid model type of Cohere"),e),systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,temperature:f.temperature,maxTokens:f.maxTokens,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody},GROQ:{key:e=>e||"",model:e=>!e||e.length===0?"gemma2-9b-it":(y("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),systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,timeout:f.timeout,temperature:f.temperature,maxTokens:f.maxTokens,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody},PERPLEXITY:{key:e=>e||"",model:e=>!e||e.length===0?"llama-3.1-sonar-small-128k-chat":(y("PERPLEXITY.model",["llama-3.1-sonar-small-128k-online","llama-3.1-sonar-small-128k-chat","llama-3.1-sonar-large-128k-online","llama-3.1-sonar-large-128k-chat","llama-3.1-8b-instruct","llama-3.1-70b-instruct"].includes(e),"Invalid model type of Perplexity"),e),systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,timeout:f.timeout,temperature:f.temperature,maxTokens:f.maxTokens,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody}},Re=I.join(qe.homedir(),".aicommit2"),Ea=(e=[])=>{const t={};for(const r of e)if(r.startsWith("--")){const[n,o]=r.slice(2).split("="),[s,u]=n.split(".");s&&u&&s in ue?(t[s]||(t[s]={}),t[s][u]=o):t[n]=o}return t},Rt=async()=>{if(!await pn(Re))return Object.create(null);const t=await P.readFile(Re,"utf8");let r=Tt.parse(t);return Lt(r,"OLLAMA")&&Lt(r.OLLAMA,"model")&&(r={...r,OLLAMA:{...r.OLLAMA,model:typeof r.OLLAMA.model=="string"?[r.OLLAMA.model]:r.OLLAMA.model}}),r},jt=async(e,t=[])=>{const r=await Rt(),n=Ea(t),o={...e,...n},s={},u=(i,a)=>{const l=o[`${i}.${a}`]??o[i]?.[a],m=r[i]?.[a],c=o[a]??r[a];return l!==void 0?l:m!==void 0?m:c};for(const[i,a]of Object.entries(f)){const l=o[i]??r[i];s[i]=a(l)}for(const[i,a]of Object.entries(ue)){s[i]={};for(const[l,m]of Object.entries(a)){const c=u(i,l);s[i][l]=m(c)}}return s},ba=async e=>{const t=await Rt();for(const[r,n]of e){const[o,s]=r.split(".");if(o in ue){t[o]||(t[o]={});const u=ue[o][s];if(!u)throw new F(`Invalid config property: ${r}`);t[o][s]=u(n)}else{const u=f[r];if(!u)throw new F(`Invalid config property: ${r}`);t[r]=u(n)}}await P.writeFile(Re,Tt.stringify(t),"utf8")},wa=async e=>{const t=await Rt();for(const[r,n]of e){const[o,s]=r.split(".");if(o in ue){t[o]||(t[o]={});const u=o==="OLLAMA"&&s==="model",i=ue[o][s];if(!i||!u)throw new F(`Invalid config property: ${r}. Only supports OLLAMA.model`);const a=t[o][s]||[];t[o][s]=Ie([...a,i(n)])}else throw new F(`Invalid config property: ${r}. Only supports OLLAMA.model`)}await P.writeFile(Re,Tt.stringify(t),"utf8")};class Aa extends U{constructor(t){super(t),this.params=t,this.host=kt,this.model="",this.handleError$=r=>{if(r.response&&r.response.data?.error)return O({name:`${this.errorPrefix} ${r.response.data?.error}`,value:r.response.data?.error,isError:!0,disabled:!0});const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return O({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#FFF",secondary:"#000"},this.model=this.params.keyName,this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[${Zr(this.model)}]`),this.errorPrefix=C.red.bold(`[${Zr(this.model)}]`),this.host=this.params.config.host||kt,this.ollama=new Zn({host:this.host})}generateCommitMessage$(){return j(this.generateMessage()).pipe(R(t=>M(t)),T(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),k(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,generate:u,type:i,maxLength:a}=this.params.config,l={...L,locale:s,maxLength:a,type:i,generate:u,systemPrompt:r,systemPromptPath:n},m=q(l);await this.checkIsAvailableOllama();const c=await this.createChatCompletions(m,`Here are diff: ${t}`);return o&&H(`Ollama_${this.model}`,t,m,c),this.parseMessage(c,i,u)}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 pe({method:"GET",baseURL:`${this.host}`,timeout:this.params.config.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(t,r){return(await this.ollama.chat({model:this.model,messages:[{role:"system",content:t},{role:"user",content:r}],stream:!1,options:{temperature:this.params.config.temperature,seed:Me(10,1e3)}})).message.content}}class $a extends U{constructor(t){super(t),this.params=t,this.handleError$=r=>{let n="An error occurred";if(r.message){n=r.message.split(`
|
|
102
|
+
`)[0];const o=this.extractJSONFromError(r.message);n+=`: ${o.error.message}`}return O({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#74AA9C",secondary:"#FFF"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[ChatGPT]"),this.errorPrefix=C.red.bold("[ChatGPT]")}generateCommitMessage$(){return j(this.generateMessage()).pipe(R(t=>M(t)),T(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),k(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,{systemPrompt:r,systemPromptPath:n,temperature:o,logging:s,locale:u,generate:i,type:a,maxLength:l,proxy:m,maxTokens:c,timeout:D}=this.params.config,p={...L,locale:u,maxLength:l,type:a,generate:i,systemPrompt:r,systemPromptPath:n},d=q(p),h=await fa(this.params.config.url,this.params.config.path,this.params.config.key,this.params.config.model,u,t,i,a,D,c,o,d,s,m);return Ie(h.map(g=>this.parseMessage(g,a,i)))}}class va extends U{constructor(t){super(t),this.params=t,this.host="https://api.perplexity.ai",this.apiKey="",this.handleError$=r=>{let n="An error occurred";if(r.message){n=r.message.split(`
|
|
103
|
+
`)[0];const o=this.extractJSONFromError(r.message);n+=`: ${o.error.message}`}return O({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#20808D",secondary:"#FFF"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Perplexity]"),this.errorPrefix=C.red.bold("[Perplexity]"),this.apiKey=this.params.config.key}generateCommitMessage$(){return j(this.generateMessage()).pipe(R(t=>M(t)),T(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),k(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(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,generate:u,type:i,maxLength:a}=this.params.config,l={...L,locale:s,maxLength:a,type:i,generate:u,systemPrompt:r,systemPromptPath:n},m=q(l),c=await this.createChatCompletions(m,t);return o&&H("Perplexity",t,m,c),this.parseMessage(c,i,u)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async createChatCompletions(t,r){const o=(await new pe({method:"POST",baseURL:`${this.host}/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.model,messages:[{role:"system",content:`${t}`},{role:"user",content:`Here are diff: ${r}`}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config.maxTokens,stream:!1}).execute()).data;if(!o.choices||o.choices.length===0||!o.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return o.choices[0].message.content}}class fn{constructor(t,r){this.config=t,this.stagedDiff=r}createAIRequests$(t){return M(t).pipe(Yt(r=>{switch(r){case"OPENAI":return G.create($a,{config:this.config.OPENAI,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"GEMINI":return G.create(Ni,{config:this.config.GEMINI,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"ANTHROPIC":return G.create(Ii,{config:this.config.ANTHROPIC,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"HUGGINGFACE":return G.create(ha,{config:this.config.HUGGINGFACE,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"MISTRAL":return G.create(ga,{config:this.config.MISTRAL,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"CODESTRAL":return G.create(ki,{config:this.config.CODESTRAL,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"OLLAMA":return M(this.config.OLLAMA.model).pipe(Yt(o=>G.create(Aa,{config:this.config.OLLAMA,keyName:o,stagedDiff:this.stagedDiff}).generateCommitMessage$()));case"COHERE":return G.create(Li,{config:this.config.COHERE,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"GROQ":return G.create(da,{config:this.config.GROQ,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"PERPLEXITY":return G.create(va,{config:this.config.PERPLEXITY,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();default:const n=C.red.bold(`[${r}]`);return O({name:n+" Invalid AI type",value:"Invalid AI type",isError:!0,disabled:!0})}}),k(r=>{const n=C.red.bold("[UNKNOWN]");return O({name:n+` ${r.message||""}`,value:"Unknown error",isError:!0,disabled:!0})}))}}const dn=async()=>{const{stdout:e,failed:t}=await ne("git",["rev-parse","--show-toplevel"],{reject:!1});if(t)throw new F("The current directory must be a Git repository!");return e},_t=e=>`:(exclude)${e}`,hn=["package-lock.json","pnpm-lock.yaml","*.lock","*.gif","*.png"].map(_t),gn=async e=>{const t=["diff","--cached","--diff-algorithm=minimal"],{stdout:r}=await ne("git",[...t,"--name-only",...hn,...e?e.map(_t):[]]);if(!r)return null;const{stdout:n}=await ne("git",[...t,...hn,...e?e.map(_t):[]]);return{files:r.split(`
|
|
104
|
+
`),diff:n}},Ba=e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`;class Fe{constructor(){this.title="aicommit2"}printTitle(){console.log(Qn.textSync(this.title,{font:"Small"}))}displaySpinner(t){return He(t).start()}stopSpinner(t){t.stop(),t.clear()}printStagedFiles(t){console.log(C.bold.green("\u2714 ")+C.bold(`${Ba(t.files)}:`)),console.log(`${t.files.map(r=>` ${r}`).join(`
|
|
101
105
|
`)}
|
|
102
106
|
`)}printAnalyzed(){console.log(`
|
|
103
|
-
${
|
|
104
|
-
${
|
|
105
|
-
${
|
|
106
|
-
${
|
|
107
|
-
${
|
|
108
|
-
${
|
|
107
|
+
${C.bold.green("\u2714")} ${C.bold("Changes analyzed")}`)}printCommitted(){console.log(`
|
|
108
|
+
${C.bold.green("\u2714")} ${C.bold("Successfully committed!")}`)}printCopied(){console.log(`
|
|
109
|
+
${C.bold.green("\u2714")} ${C.bold("Successfully copied! Press 'Ctrl + V' to paste")}`)}printSavedCommitMessage(){console.log(`
|
|
110
|
+
${C.bold.green("\u2714")} ${C.bold("Saved commit message")}`)}printCancelledCommit(){console.log(`
|
|
111
|
+
${C.bold.yellow("\u26A0")} ${C.yellow("Commit cancelled")}`)}printErrorMessage(t){console.log(`
|
|
112
|
+
${C.bold.red("\u2716")} ${C.red(`${t}`)}`)}moveCursorUp(){const t=ye.createInterface({input:process.stdin,output:process.stdout});ye.moveCursor(process.stdout,0,-1),t.close()}moveCursorDown(){const t=ye.createInterface({input:process.stdin,output:process.stdout});ye.moveCursor(process.stdout,0,1),t.close()}}const xa={isLoading:!1,startOption:{text:"AI is analyzing your changes"}},Gt="No commit messages were generated";class Pa{constructor(){this.choices$=new Xt([]),this.loader$=new Xt(xa),this.destroyed$=new Tn(1)}initPrompt(t=!0){return Ue.registerPrompt("reactiveListPrompt",eo),Ue.prompt({type:"reactiveListPrompt",name:"aicommit2Prompt",message:"Pick a commit message to use: ",emptyMessage:`\u26A0 ${Gt}`,loop:!1,showDescription:t,descPageSize:15,choices$:this.choices$,loader$:this.loader$,pickKey:"short"})}startLoader(){this.loader$.next({isLoading:!0})}refreshChoices(t){const{value:r,isError:n}=t;!t||!r||this.choices$.next([...this.currentChoices,t].sort(Ti))}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:Gt,stopOption:{doneFrame:"\u26A0",color:"yellow"}})}stopLoaderOnSuccess(){this.loader$.next({isLoading:!1,message:"Changes analyzed"})}logEmptyCommitMessage(){console.log(`${C.bold.yellow("\u26A0")} ${C.yellow(`${Gt}`)}`)}get currentChoices(){return this.choices$.getValue().map(t=>t)}}const K=new Fe;var Sa=async(e,t,r,n,o,s,u,i,a)=>(async()=>{K.printTitle(),await dn(),n&&await ne("git",["add","--update"]);const l=K.displaySpinner("Detecting staged files"),m=await gn(r);if(l.stop(),!m)throw new F("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");K.printStagedFiles(m);const c=await jt({locale:e?.toString(),generate:t?.toString(),commitType:o?.toString(),systemPrompt:i?.toString()},a);if(c.systemPromptPath)try{W.readFileSync(I.resolve(c.systemPromptPath),"utf-8")}catch{throw new F(`Error reading system prompt file: ${c.systemPromptPath}`)}const D=Object.entries(c).filter(([w])=>Nt.includes(w)).map(([w,x])=>[w,x]).filter(([w,x])=>w==="OLLAMA"?!!x&&!!x.model&&x.model.length>0:w==="HUGGINGFACE"?!!x&&!!x.cookie:!!x.key&&x.key.length>0).map(([w])=>w);if(D.length===0)throw new F("Please set at least one API key via the `aicommit2 config set` command");const d=new fn(c,m),h=new Pa,g=h.initPrompt();h.startLoader();const E=d.createAIRequests$(D).subscribe(w=>h.refreshChoices(w),()=>{},()=>h.checkErrorOnChoices()),A=await g;E.unsubscribe(),h.completeSubject(),K.moveCursorUp();const v=A.aicommit2Prompt?.value;if(!v)throw new F("An error occurred! No selected message");if(u&&(bs("copy-paste").copy(v),K.printCopied(),process.exit()),s){const w=He("Committing with the generated message").start();await ne("git",["commit","-m",v,...a]),w.stop(),w.clear(),K.printCommitted(),process.exit()}const Y=await Ue.prompt([{type:"confirm",name:"confirmationPrompt",message:"Use selected message?",default:!0}]),{confirmationPrompt:z}=Y;if(z){const w=He("Committing with the generated message").start();await ne("git",["commit","-m",v,...a]),w.stop(),w.clear(),K.printCommitted(),process.exit()}K.printCancelledCommit(),process.exit()})().catch(l=>{K.printErrorMessage(l.message),me(l),process.exit(1)}),Oa=Qe({name:"config",parameters:["<mode>","<key=value...>"]},e=>{(async()=>{const{mode:t,keyValue:r}=e._;if(t==="get"){const n=await jt({},[]);for(const o of r)if(Lt(n,o)){if(Nt.includes(o)){console.log(o,n[o]);return}console.log(`${o}=${n[o]}`)}return}if(t==="set"){await ba(r.map(n=>n.split("=")));return}if(t==="add"){await wa(r.map(n=>n.split("=")));return}throw new F(`Invalid mode: ${t}`)})().catch(t=>{new Fe().printErrorMessage(t.message),me(t),process.exit(1)})});const Cn="prepare-commit-msg",Fn=`.git/hooks/${Cn}`,je=Yn(new URL("cli.mjs",import.meta.url)),Ma=process.argv[1].replace(/\\/g,"/").endsWith(`/${Fn}`),yn=process.platform==="win32",En=`
|
|
109
113
|
#!/usr/bin/env node
|
|
110
|
-
import(${JSON.stringify(
|
|
111
|
-
`.trim();var Ia=
|
|
112
|
-
`),
|
|
113
|
-
`),
|
|
114
|
-
${
|
|
115
|
-
`)}`):(
|
|
116
|
-
`),
|
|
117
|
-
${
|
|
118
|
-
`),await
|
|
114
|
+
import(${JSON.stringify(Xn(je))})
|
|
115
|
+
`.trim();var Ia=Qe({name:"hook",parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await dn(),{installUninstall:r}=e._,n=I.join(t,Fn),o=await pn(n);if(r==="install"){if(o){if(await P.realpath(n).catch(()=>{})===je){console.warn("The hook is already installed");return}throw new F(`A different ${Cn} hook seems to be installed. Please remove it before installing aicommit2.`)}await P.mkdir(I.dirname(n),{recursive:!0}),yn?await P.writeFile(n,En):(await P.symlink(je,n,"file"),await P.chmod(n,493)),console.log(`${C.green("\u2714")} Hook installed`);return}if(r==="uninstall"){if(!o){console.warn("Hook is not installed");return}if(yn){if(await P.readFile(n,"utf8")!==En){console.warn("Hook is not installed");return}}else if(await P.realpath(n)!==je){console.warn("Hook is not installed");return}await P.rm(n),console.log(`${C.green("\u2714")} Hook uninstalled`);return}throw new F(`Invalid mode: ${r}`)})().catch(t=>{console.error(`${C.red("\u2716")} ${t.message}`),me(t),process.exit(1)})}),Ta=Qe({name:"log",parameters:["<removeAll>"]},e=>{(async()=>{const{removeAll:t}=e._;if(t==="removeAll"){await to(Vr,{recursive:!0,force:!0}),console.log(`${C.green("\u2714")} All Log files are removed!`);return}throw new F(`Invalid mode: ${t}`)})().catch(t=>{new Fe().printErrorMessage(t.message),me(t),process.exit(1)})});const[Ut,ka]=process.argv.slice(2);var La=()=>(async()=>{if(!Ut)throw new F('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(ka)return;const e=await gn();if(!e)return;const t=new Fe;t.printTitle();const r=await jt({});if(r.systemPromptPath)try{await P.readFile(I.resolve(r.systemPromptPath),"utf-8")}catch{throw new F(`Error reading system prompt file: ${r.systemPromptPath}`)}const n=Object.entries(r).filter(([D])=>Nt.includes(D)).map(([D,p])=>[D,p]).filter(([D,p])=>D==="OLLAMA"?!!p&&!!p.model&&p.model.length>0:D==="HUGGINGFACE"?!!p&&!!p.cookie:!!p.key&&p.key.length>0).map(([D])=>D);if(n.length===0)throw new F("Please set at least one API key via the `aicommit2 config set` command");const s=new fn(r,e),u=t.displaySpinner("The AI is analyzing your changes");let i;try{i=await kn(s.createAIRequests$(n).pipe(Ln(D=>!D.isError),T(D=>D.value),Nn()))}finally{u.stop(),u.clear(),t.printAnalyzed()}const l=await P.readFile(Ut,"utf8")!=="",m=i.length>1;let c="";l&&(c=`# \u{1F916} AI generated commit${m?"s":""}
|
|
116
|
+
`),m?(l&&(c+=`# Select one of the following messages by uncommenting:
|
|
117
|
+
`),c+=`
|
|
118
|
+
${i.map(D=>`# ${D}`).join(`
|
|
119
|
+
`)}`):(l&&(c+=`# Edit the message below and commit:
|
|
120
|
+
`),c+=`
|
|
121
|
+
${i[0]}
|
|
122
|
+
`),await P.appendFile(Ut,c),t.printSavedCommitMessage()})().catch(e=>{new Fe().printErrorMessage(e.message),me(e),process.exit(1)});const bn=process.argv.slice(2);Es({name:"aicommit2",version:Jr,flags:{locale:{type:String,description:"Locale to use for the generated commit messages (default: en)",alias:"l"},generate:{type:Number,description:"Number of messages to generate (Warning: generating multiple costs more) (default: 1)",alias:"g"},exclude:{type:[String],description:"Files to exclude from AI analysis",alias:"x"},all:{type:Boolean,description:"Automatically stage changes in tracked files for the commit",alias:"a",default:!1},type:{type:String,description:"Type of commit message to generate",alias:"t"},confirm:{type:Boolean,description:"Skip confirmation when committing after message generation (default: false)",alias:"y",default:!1},clipboard:{type:Boolean,description:"Copy the selected message to the clipboard",alias:"c",default:!1},prompt:{type:String,description:"Custom prompt to let users fine-tune provided prompt",alias:"p"}},commands:[Oa,Ia,Ta],help:{description:vi},ignoreArgv:e=>e==="unknown-flag"||e==="argument"},e=>{if(Ma){La();return}Sa(e.flags.locale,e.flags.generate,e.flags.exclude,e.flags.all,e.flags.type,e.flags.confirm,e.flags.clipboard,e.flags.prompt,bn)},bn);
|