aicommit2 2.0.7 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +53 -53
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import He from"tty";import{createRequire as $n}from"module";import K from"fs";import L from"path";import{Buffer as vn}from"node:buffer";import X from"node:path";import qt,{ChildProcess as Bn}from"node:child_process";import U from"node:process";import xn from"child_process";import{fileURLToPath as zt}from"node:url";import Pn,{constants as Kt}from"node:os";import Wt from"assert";import Jt from"events";import{createWriteStream as Sn,createReadStream as Mn}from"node:fs";import On from"buffer";import Ue from"stream";import Vt from"util";import{debuglog as In}from"node:util";import qe from"inquirer";import ze from"ora";import C from"chalk";import{of as M,concatMap as N,from as O,map as I,catchError as T,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 R}from"rxjs/internal/observable/innerFrom";import Ke from"os";import{xxh64 as jn}from"@pacote/xxhash";import _n from"axios";import{CohereClient as Gn,CohereTimeoutError as Hn}from"cohere-ai";import{GoogleGenerativeAI as Un}from"@google/generative-ai";import qn from"groq-sdk";import zn from"http";import Kn from"https";import Wn 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 Ee 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:ae}=JSON,so=/\B([A-Z])/g,io=e=>e.replace(so,"-$1").toLowerCase(),{hasOwnProperty:uo}=Object.prototype,ce=(e,t)=>uo.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 ${ae(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 ${ae(r?.[0])}`)},po=e=>{const t={},r=(n,o)=>{if(ce(t,n))throw new Error(`Duplicate flags named ${ae(n)}`);t[n]=o};for(const n in e){if(!ce(e,n))continue;mo(n);const o=e[n],s=[[],...Zt(o),o];r(n,s);const i=io(n);if(n!==i&&r(i,s),"alias"in o&&typeof o.alias=="string"){const{alias:u}=o,a=`Flag alias ${ae(u)} for flag ${ae(n)}`;if(u.length===0)throw new Error(`${a} cannot be empty`);if(u.length>1)throw new Error(`${a} must be a single character`);r(u,s)}}return t},fo=(e,t)=>{const r={};for(const n in e){if(!ce(e,n))continue;const[o,,s,i]=t[n];if(o.length===0&&"default"in i){let{default:u}=i;typeof u=="function"&&(u=u()),r[n]=u}else r[n]=s?o:o.pop()}return r},ye="--",ho=/[.:=]/,go=/^-{1,2}\w/,Co=e=>{if(!go.test(e))return;const t=!e.startsWith(ye);let r=e.slice(t?1:2),n;const o=r.match(ho);if(o){const{index:s}=o;n=r.slice(s+1),r=r.slice(0,s)}return[r,n,t]},Fo=(e,{onFlag:t,onArgument:r})=>{let n;const o=(s,i)=>{if(typeof n!="function")return!0;n(s,i),n=void 0};for(let s=0;s<e.length;s+=1){const i=e[s];if(i===ye){o();const a=e.slice(s+1);r?.(a,[s],!0);break}const u=Co(i);if(u){if(o(),!t)continue;const[a,l,m]=u;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(i,[s])&&r?.([i],[s])}o()},Eo=(e,t)=>{for(const[r,n,o]of t.reverse()){if(n){const s=e[r];let i=s.slice(0,n);if(o||(i+=s.slice(n+1)),i!=="-"){e[r]=i;continue}}e.splice(r,1)}},yo=(e,t=process.argv.slice(2),{ignore:r}={})=>{const n=[],o=po(e),s={},i=[];return i[ye]=[],Fo(t,{onFlag(u,a,l){const m=ce(o,u);if(!r?.(m?ro:no,u,a)){if(m){const[c,D]=o[u],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)}ce(s,u)||(s[u]=[]),s[u].push(a===void 0?!0:a),n.push(l)}},onArgument(u,a,l){r?.(oo,t[a[0]])||(i.push(...u),l?(i[ye]=u,t.splice(a[0])):n.push(a))}}),Eo(t,n),{flags:fo(e,o),unknownFlags:s,_:i}};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},We=(e,t)=>wo(e,$o(t)),Po=e=>be(e,"__esModule",{value:!0}),So=(e,t)=>()=>(e&&(t=e(e=0)),t),Mo=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Oo=(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)=>Oo(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=Mo((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(
|
|
4
|
-
`)];for(let[l,m]of a.entries()){if(n+=m,
|
|
5
|
-
`?(s&&(n+=
|
|
6
|
-
`&&(o&&c&&(n+=
|
|
2
|
+
import qe from"tty";import{createRequire as Bn}from"module";import K from"fs";import L from"path";import{Buffer as xn}from"node:buffer";import X from"node:path";import Kt,{ChildProcess as Pn}from"node:child_process";import U from"node:process";import Sn from"child_process";import{fileURLToPath as Wt}from"node:url";import On,{constants as Vt}from"node:os";import Jt from"assert";import Yt from"events";import{createWriteStream as Mn,createReadStream as In}from"node:fs";import Tn from"buffer";import ze from"stream";import Xt from"util";import{debuglog as kn}from"node:util";import Ke from"inquirer";import We from"ora";import C from"chalk";import{of as O,concatMap as N,from as M,map as I,catchError as T,mergeMap as Zt,BehaviorSubject as Qt,ReplaySubject as Ln,lastValueFrom as Nn,filter as Rn,toArray as _n}from"rxjs";import jn from"@anthropic-ai/sdk";import{fromPromise as R}from"rxjs/internal/observable/innerFrom";import Ve from"os";import{xxh64 as Gn}from"@pacote/xxhash";import Hn from"axios";import{CohereClient as Un,CohereTimeoutError as qn}from"cohere-ai";import{GoogleGenerativeAI as zn,HarmCategory as Ee,HarmBlockThreshold as ye}from"@google/generative-ai";import Kn from"groq-sdk";import Wn from"http";import Vn from"https";import Jn from"net";import Yn from"tls";import Xn,{fileURLToPath as Zn,pathToFileURL as Qn}from"url";import{Ollama as eo}from"ollama";import P from"fs/promises";import be from"readline";import to from"figlet";import ro from"inquirer-reactive-list-prompt";import{rm as no}from"node:fs/promises";const oo="known-flag",so="unknown-flag",io="argument",{stringify:ae}=JSON,uo=/\B([A-Z])/g,ao=e=>e.replace(uo,"-$1").toLowerCase(),{hasOwnProperty:co}=Object.prototype,ce=(e,t)=>co.call(e,t),Do=e=>Array.isArray(e),er=e=>typeof e=="function"?[e,!1]:Do(e)?[e[0],!0]:er(e.type),lo=(e,t)=>e===Boolean?t!=="false":t,mo=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),po=/[\s.:=]/,fo=e=>{const t=`Flag name ${ae(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(po);if(r)throw new Error(`${t} cannot contain ${ae(r?.[0])}`)},ho=e=>{const t={},r=(n,o)=>{if(ce(t,n))throw new Error(`Duplicate flags named ${ae(n)}`);t[n]=o};for(const n in e){if(!ce(e,n))continue;fo(n);const o=e[n],s=[[],...er(o),o];r(n,s);const i=ao(n);if(n!==i&&r(i,s),"alias"in o&&typeof o.alias=="string"){const{alias:u}=o,a=`Flag alias ${ae(u)} for flag ${ae(n)}`;if(u.length===0)throw new Error(`${a} cannot be empty`);if(u.length>1)throw new Error(`${a} must be a single character`);r(u,s)}}return t},go=(e,t)=>{const r={};for(const n in e){if(!ce(e,n))continue;const[o,,s,i]=t[n];if(o.length===0&&"default"in i){let{default:u}=i;typeof u=="function"&&(u=u()),r[n]=u}else r[n]=s?o:o.pop()}return r},we="--",Co=/[.:=]/,Fo=/^-{1,2}\w/,Eo=e=>{if(!Fo.test(e))return;const t=!e.startsWith(we);let r=e.slice(t?1:2),n;const o=r.match(Co);if(o){const{index:s}=o;n=r.slice(s+1),r=r.slice(0,s)}return[r,n,t]},yo=(e,{onFlag:t,onArgument:r})=>{let n;const o=(s,i)=>{if(typeof n!="function")return!0;n(s,i),n=void 0};for(let s=0;s<e.length;s+=1){const i=e[s];if(i===we){o();const a=e.slice(s+1);r?.(a,[s],!0);break}const u=Eo(i);if(u){if(o(),!t)continue;const[a,l,m]=u;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(i,[s])&&r?.([i],[s])}o()},bo=(e,t)=>{for(const[r,n,o]of t.reverse()){if(n){const s=e[r];let i=s.slice(0,n);if(o||(i+=s.slice(n+1)),i!=="-"){e[r]=i;continue}}e.splice(r,1)}},wo=(e,t=process.argv.slice(2),{ignore:r}={})=>{const n=[],o=ho(e),s={},i=[];return i[we]=[],yo(t,{onFlag(u,a,l){const m=ce(o,u);if(!r?.(m?oo:so,u,a)){if(m){const[c,D]=o[u],p=lo(D,a),f=(h,g)=>{n.push(l),g&&n.push(g),c.push(mo(D,h||""))};return p===void 0?f:f(p)}ce(s,u)||(s[u]=[]),s[u].push(a===void 0?!0:a),n.push(l)}},onArgument(u,a,l){r?.(io,t[a[0]])||(i.push(...u),l?(i[we]=u,t.splice(a[0])):n.push(a))}}),bo(t,n),{flags:go(e,o),unknownFlags:s,_:i}};var Ao=Object.create,Ae=Object.defineProperty,$o=Object.defineProperties,vo=Object.getOwnPropertyDescriptor,Bo=Object.getOwnPropertyDescriptors,xo=Object.getOwnPropertyNames,tr=Object.getOwnPropertySymbols,Po=Object.getPrototypeOf,rr=Object.prototype.hasOwnProperty,So=Object.prototype.propertyIsEnumerable,nr=(e,t,r)=>t in e?Ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$e=(e,t)=>{for(var r in t||(t={}))rr.call(t,r)&&nr(e,r,t[r]);if(tr)for(var r of tr(t))So.call(t,r)&&nr(e,r,t[r]);return e},Je=(e,t)=>$o(e,Bo(t)),Oo=e=>Ae(e,"__esModule",{value:!0}),Mo=(e,t)=>()=>(e&&(t=e(e=0)),t),Io=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),To=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of xo(t))!rr.call(e,o)&&(r||o!=="default")&&Ae(e,o,{get:()=>t[o],enumerable:!(n=vo(t,o))||n.enumerable});return e},ko=(e,t)=>To(Oo(Ae(e!=null?Ao(Po(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),S=Mo(()=>{}),Lo=Io((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 No=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 Ro({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 or(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Ro(),"")}S();function _o(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 jo=ko(Lo(),1);function V(e){if(typeof e!="string"||e.length===0||(e=or(e),e.length===0))return 0;e=e.replace((0,jo.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+=_o(n)?2:1)}return t}var sr=e=>Math.max(...e.split(`
|
|
3
|
+
`).map(V)),Go=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 i=sr(r[s]);i>t[s]&&(t[s]=i)}}return t};S();var ir=/^\d+%$/,ur={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},Ho=(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"&&ir.test(s)){n.push(Je($e({},ur),{width:s,contentWidth:e[o]}));continue}if(s&&typeof s=="object"){let i=Je($e($e({},ur),s),{contentWidth:e[o]});i.horizontalPadding=i.paddingLeft+i.paddingRight,n.push(i);continue}throw new Error(`Invalid column width: ${JSON.stringify(s)}`)}return n};function Uo(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"&&ir.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,i=s+o;if(i>=t){let a=i-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 u=t-r.horizontalPadding;r.width=Math.max(Math.min(r.width,u),s)}}var ar=()=>Object.assign([],{columns:0});function qo(e,t){let r=[ar()],[n]=r;for(let o of e){let s=o.width+o.horizontalPadding;n.columns+s>t&&(n=ar(),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),i=t-s;if(i===0)continue;let u=o.filter(D=>"autoOverflow"in D),a=u.filter(D=>D.autoOverflow>0),l=a.reduce((D,p)=>D+p.autoOverflow,0),m=Math.min(l,i);for(let D of a){let p=Math.floor(D.autoOverflow/l*m);D.width+=p,i-=p}let c=Math.floor(i/u.length);for(let D=0;D<u.length;D+=1){let p=u[D];D===u.length-1?p.width+=i:p.width+=c,i-=c}}return r}function zo(e,t,r){let n=Ho(r,t);return Uo(n,e),qo(n,e)}S(),S(),S();var Ye=10,cr=(e=0)=>t=>`\x1B[${t+e}m`,Dr=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,lr=(e=0)=>(t,r,n)=>`\x1B[${38+e};2;${t};${r};${n}m`;function Ko(){let e=new Map,t={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};t.color.gray=t.color.blackBright,t.bgColor.bgGray=t.bgColor.bgBlackBright,t.color.grey=t.color.blackBright,t.bgColor.bgGrey=t.bgColor.bgBlackBright;for(let[r,n]of Object.entries(t)){for(let[o,s]of Object.entries(n))t[o]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[o]=t[o],e.set(s[0],s[1]);Object.defineProperty(t,r,{value:n,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",t.color.ansi=cr(),t.color.ansi256=Dr(),t.color.ansi16m=lr(),t.bgColor.ansi=cr(Ye),t.bgColor.ansi256=Dr(Ye),t.bgColor.ansi16m=lr(Ye),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(i=>i+i).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 i=Math.max(n,o,s)*2;if(i===0)return 30;let u=30+(Math.round(s)<<2|Math.round(o)<<1|Math.round(n));return i===2&&(u+=60),u},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 Wo=Ko(),Vo=Wo,ve=new Set(["\x1B","\x9B"]),Jo=39,Xe="\x07",mr="[",Yo="]",pr="m",Ze=`${Yo}8;;`,dr=e=>`${ve.values().next().value}${mr}${e}${pr}`,fr=e=>`${ve.values().next().value}${Ze}${e}${Xe}`,Xo=e=>e.split(" ").map(t=>V(t)),Qe=(e,t,r)=>{let n=[...t],o=!1,s=!1,i=V(or(e[e.length-1]));for(let[u,a]of n.entries()){let l=V(a);if(i+l<=r?e[e.length-1]+=a:(e.push(a),i=0),ve.has(a)&&(o=!0,s=n.slice(u+1).join("").startsWith(Ze)),o){s?a===Xe&&(o=!1,s=!1):a===pr&&(o=!1);continue}i+=l,i===r&&u<n.length-1&&(e.push(""),i=0)}!i&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Zo=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(V(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},Qo=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",o,s,i=Xo(e),u=[""];for(let[l,m]of e.split(" ").entries()){r.trim!==!1&&(u[u.length-1]=u[u.length-1].trimStart());let c=V(u[u.length-1]);if(l!==0&&(c>=t&&(r.wordWrap===!1||r.trim===!1)&&(u.push(""),c=0),(c>0||r.trim===!1)&&(u[u.length-1]+=" ",c++)),r.hard&&i[l]>t){let D=t-c,p=1+Math.floor((i[l]-D-1)/t);Math.floor((i[l]-1)/t)<p&&u.push(""),Qe(u,m,t);continue}if(c+i[l]>t&&c>0&&i[l]>0){if(r.wordWrap===!1&&c<t){Qe(u,m,t);continue}u.push("")}if(c+i[l]>t&&r.wordWrap===!1){Qe(u,m,t);continue}u[u.length-1]+=m}r.trim!==!1&&(u=u.map(l=>Zo(l)));let a=[...u.join(`
|
|
4
|
+
`)];for(let[l,m]of a.entries()){if(n+=m,ve.has(m)){let{groups:D}=new RegExp(`(?:\\${mr}(?<code>\\d+)m|\\${Ze}(?<uri>.*)${Xe})`).exec(a.slice(l).join(""))||{groups:{}};if(D.code!==void 0){let p=Number.parseFloat(D.code);o=p===Jo?void 0:p}else D.uri!==void 0&&(s=D.uri.length===0?void 0:D.uri)}let c=Vo.codes.get(Number(o));a[l+1]===`
|
|
5
|
+
`?(s&&(n+=fr("")),o&&c&&(n+=dr(c))):m===`
|
|
6
|
+
`&&(o&&c&&(n+=dr(o)),s&&(n+=fr(s)))}return n};function es(e,t,r){return String(e).normalize().replace(/\r\n/g,`
|
|
7
7
|
`).split(`
|
|
8
|
-
`).map(n=>
|
|
9
|
-
`)}var
|
|
10
|
-
`);if(a.postprocess){let{postprocess:D}=a;c=c.map((p,
|
|
8
|
+
`).map(n=>Qo(n,t,r)).join(`
|
|
9
|
+
`)}var hr=e=>Array.from({length:e}).fill("");function ts(e,t){let r=[],n=0;for(let o of e){let s=0,i=o.map(a=>{var l;let m=(l=t[n])!=null?l:"";n+=1,a.preprocess&&(m=a.preprocess(m)),sr(m)>a.width&&(m=es(m,a.width,{hard:!0}));let c=m.split(`
|
|
10
|
+
`);if(a.postprocess){let{postprocess:D}=a;c=c.map((p,f)=>D.call(a,p,f))}return a.paddingTop&&c.unshift(...hr(a.paddingTop)),a.paddingBottom&&c.push(...hr(a.paddingBottom)),c.length>s&&(s=c.length),Je($e({},a),{lines:c})}),u=[];for(let a=0;a<s;a+=1){let l=i.map(m=>{var c;let D=(c=m.lines[a])!=null?c:"",p=Number.isFinite(m.width)?" ".repeat(m.width-V(D)):"",f=m.paddingLeftString;return m.align==="right"&&(f+=p),f+=D,m.align==="left"&&(f+=p),f+m.paddingRightString}).join("");u.push(l)}r.push(u.join(`
|
|
11
11
|
`))}return r.join(`
|
|
12
|
-
`)}function
|
|
13
|
-
`)}S();var
|
|
14
|
-
`}}function
|
|
15
|
-
`}}function
|
|
16
|
-
`):t.usage}}:void 0;if(e.name){const r=[],n=[
|
|
17
|
-
`)}}}}function
|
|
18
|
-
`)),r)return{id:"examples",type:"section",data:{title:"Examples:",body:r}}}function
|
|
12
|
+
`)}function rs(e,t){if(!e||e.length===0)return"";let r=Go(e),n=r.length;if(n===0)return"";let{stdoutColumns:o,columns:s}=No(t);if(s.length>n)throw new Error(`${s.length} columns defined, but only ${n} columns found`);let i=zo(o,s,r);return e.map(u=>ts(i,u)).join(`
|
|
13
|
+
`)}S();var ns=["<",">","=",">=","<="];function os(e){if(!ns.includes(e))throw new TypeError(`Invalid breakpoint operator: ${e}`)}function ss(e){let t=Object.keys(e).map(r=>{let[n,o]=r.split(" ");os(n);let s=Number.parseInt(o,10);if(Number.isNaN(s))throw new TypeError(`Invalid breakpoint value: ${o}`);let i=e[r];return{operator:n,breakpoint:s,value:i}}).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 is=e=>e.replace(/[\W_]([a-z\d])?/gi,(t,r)=>r?r.toUpperCase():""),us=e=>e.replace(/\B([A-Z])/g,"-$1").toLowerCase(),as={"> 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 cs(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:`--${us(r)}`,aliasesEnabled:t,aliasFormatted:o?`-${n.alias}`:void 0}}).map(r=>(r.aliasesEnabled=t,[{type:"flagName",data:r},{type:"flagDescription",data:r}])),tableBreakpoints:as}}}const gr=e=>!e||(e.version??(e.help?e.help.version:void 0)),Cr=e=>{const t="parent"in e&&e.parent?.name;return(t?`${t} `:"")+e.name};function Ds(e){const t=[];e.name&&t.push(Cr(e));const r=gr(e)??("parent"in e&&gr(e.parent));if(r&&t.push(`v${r}`),t.length!==0)return{id:"name",type:"text",data:`${t.join(" ")}
|
|
14
|
+
`}}function ls(e){const{help:t}=e;if(!(!t||!t.description))return{id:"description",type:"text",data:`${t.description}
|
|
15
|
+
`}}function ms(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=[Cr(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("--"),i=s>-1&&o.slice(s+1).some(u=>u.startsWith("<"));n.push(o.map(u=>u!=="--"?u:i?"--":"[--]").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 ps(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 ds(e){if(!(!e.flags||Object.keys(e.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:cs(e.flags),indentBody:0}}}function fs(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 hs(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 gs=e=>[Ds,ls,ms,ps,ds,fs,hs].map(t=>t(e)).filter(Boolean),Cs=qe.WriteStream.prototype.hasColors();class Fs{text(t){return t}bold(t){return Cs?`\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
|
-
`}table({tableData:t,tableOptions:r,tableBreakpoints:n}){return
|
|
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
|
|
22
|
-
`),n(),process.exit(1);e[a]=l}}function
|
|
20
|
+
`}table({tableData:t,tableOptions:r,tableBreakpoints:n}){return rs(t.map(o=>o.map(s=>this.render(s))),n?ss(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 i="";if(s?i+=`${s}, `:o&&(i+=" "),i+=n,"placeholder"in r&&typeof r.placeholder=="string")i+=`${this.flagOperator(t)}${r.placeholder}`;else{const u=this.flagParameter("type"in r?r.type:r);u&&(i+=`${this.flagOperator(t)}${u}`)}return i}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 et=/^[\w.-]+$/,{stringify:q}=JSON,Es=/[|\\{}()[\]^$+*?.]/;function tt(e){const t=[];let r,n;for(const o of e){if(n)throw new Error(`Invalid parameter: Spread parameter ${q(n)} must be last`);const s=o[0],i=o[o.length-1];let u;if(s==="<"&&i===">"&&(u=!0,r))throw new Error(`Invalid parameter: Required parameter ${q(o)} cannot come after optional parameter ${q(r)}`);if(s==="["&&i==="]"&&(u=!1,r=o),u===void 0)throw new Error(`Invalid parameter: ${q(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(Es);if(m)throw new Error(`Invalid parameter: ${q(o)}. Invalid character found ${q(m[0])}`);t.push({name:a,required:u,spread:l})}return t}function rt(e,t,r,n){for(let o=0;o<t.length;o+=1){const{name:s,required:i,spread:u}=t[o],a=is(s);if(a in e)throw new Error(`Invalid parameter: ${q(s)} is used more than once.`);const l=u?r.slice(o):r[o];if(u&&(o=t.length),i&&(!l||u&&l.length===0))return console.error(`Error: Missing required parameter ${q(s)}
|
|
22
|
+
`),n(),process.exit(1);e[a]=l}}function ys(e){return e===void 0||e!==!1}function Fr(e,t,r,n){const o={...t.flags},s=t.version;s&&(o.version={type:Boolean,description:"Show version"});const{help:i}=t,u=ys(i);u&&!("help"in o)&&(o.help={type:Boolean,alias:"h",description:"Show help"});const a=wo(o,n,{ignore:t.ignoreArgv}),l=()=>{console.log(t.version)};if(s&&a.flags.version===!0)return l(),process.exit(0);const m=new Fs,c=u&&i?.render?i.render:f=>m.render(f),D=f=>{const h=gs({...t,...f?{help:f}:{},flags:o});console.log(c(h,m))};if(u&&a.flags.help===!0)return D(),process.exit(0);if(t.parameters){let{parameters:f}=t,h=a._;const g=f.indexOf("--"),y=f.slice(g+1),A=Object.create(null);if(g>-1&&y.length>0){f=f.slice(0,g);const v=a._["--"];h=h.slice(0,-v.length||void 0),rt(A,tt(f),h,D),rt(A,tt(y),v,D)}else rt(A,tt(f),h,D);Object.assign(a._,A)}const p={...a,showVersion:l,showHelp:D};return typeof r=="function"&&r(p),{command:e,...p}}function bs(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 i of o){if(r.has(i))throw new Error(`Duplicate command name found: ${q(i)}`);r.set(i,n)}}return r.get(e)}function ws(e,t,r=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!et.test(e.name)))throw new Error(`Invalid script name: ${q(e.name)}`);const n=r[0];if(e.commands&&et.test(n)){const o=bs(n,e.commands);if(o)return Fr(o.options.name,{...o.options,parent:e},o.callback,r.slice(1))}return Fr(void 0,e,t,r)}function nt(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(!et.test(r))throw new Error(`Invalid command name ${JSON.stringify(r)}. Command names must be one word.`);return{options:e,callback:t}}var As=Bn(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:{}},ot,Er;function $s(){if(Er)return ot;Er=1,ot=n,n.sync=o;var e=K;function t(s,i){var u=i.pathExt!==void 0?i.pathExt:process.env.PATHEXT;if(!u||(u=u.split(";"),u.indexOf("")!==-1))return!0;for(var a=0;a<u.length;a++){var l=u[a].toLowerCase();if(l&&s.substr(-l.length).toLowerCase()===l)return!0}return!1}function r(s,i,u){return!s.isSymbolicLink()&&!s.isFile()?!1:t(i,u)}function n(s,i,u){e.stat(s,function(a,l){u(a,a?!1:r(l,s,i))})}function o(s,i){return r(e.statSync(s),s,i)}return ot}var st,yr;function vs(){if(yr)return st;yr=1,st=t,t.sync=r;var e=K;function t(s,i,u){e.stat(s,function(a,l){u(a,a?!1:n(l,i))})}function r(s,i){return n(e.statSync(s),i)}function n(s,i){return s.isFile()&&o(s,i)}function o(s,i){var u=s.mode,a=s.uid,l=s.gid,m=i.uid!==void 0?i.uid:process.getuid&&process.getuid(),c=i.gid!==void 0?i.gid:process.getgid&&process.getgid(),D=parseInt("100",8),p=parseInt("010",8),f=parseInt("001",8),h=D|p,g=u&f||u&p&&l===c||u&D&&a===m||u&h&&m===0;return g}return st}var Be;process.platform==="win32"||$.TESTING_WINDOWS?Be=$s():Be=vs();var Bs=it;it.sync=xs;function it(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){it(e,t||{},function(s,i){s?o(s):n(i)})})}Be(e,t||{},function(n,o){n&&(n.code==="EACCES"||t&&t.ignoreErrors)&&(n=null,o=!1),r(n,o)})}function xs(e,t){try{return Be.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",br=L,Ps=ee?";":":",wr=Bs,Ar=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),$r=(e,t)=>{const r=t.colon||Ps,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}},vr=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});const{pathEnv:n,pathExt:o,pathExtExe:s}=$r(e,t),i=[],u=l=>new Promise((m,c)=>{if(l===n.length)return t.all&&i.length?m(i):c(Ar(e));const D=n[l],p=/^".*"$/.test(D)?D.slice(1,-1):D,f=br.join(p,e),h=!p&&/^\.[\\\/]/.test(e)?e.slice(0,2)+f:f;m(a(h,l,0))}),a=(l,m,c)=>new Promise((D,p)=>{if(c===o.length)return D(u(m+1));const f=o[c];wr(l+f,{pathExt:s},(h,g)=>{if(!h&&g)if(t.all)i.push(l+f);else return D(l+f);return D(a(l,m,c+1))})});return r?u(0).then(l=>r(null,l),r):u(0)},Ss=(e,t)=>{t=t||{};const{pathEnv:r,pathExt:n,pathExtExe:o}=$r(e,t),s=[];for(let i=0;i<r.length;i++){const u=r[i],a=/^".*"$/.test(u)?u.slice(1,-1):u,l=br.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(wr.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 Ar(e)};var Os=vr;vr.sync=Ss;var ut={exports:{}};const Br=(e={})=>{const t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};ut.exports=Br,ut.exports.default=Br;var Ms=ut.exports;const xr=L,Is=Os,Ts=Ms;function Pr(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 i;try{i=Is.sync(e.command,{path:r[Ts({env:r})],pathExt:t?xr.delimiter:void 0})}catch{}finally{s&&process.chdir(n)}return i&&(i=xr.resolve(o?e.options.cwd:"",i)),i}function ks(e){return Pr(e)||Pr(e,!0)}var Ls=ks,at={};const ct=/([()\][%!^"`<>&|;, *?])/g;function Ns(e){return e=e.replace(ct,"^$1"),e}function Rs(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(ct,"^$1"),t&&(e=e.replace(ct,"^$1")),e}at.command=Ns,at.argument=Rs;var _s=/^#!(.*)/;const js=_s;var Gs=(e="")=>{const t=e.match(js);if(!t)return null;const[r,n]=t[0].replace(/#! ?/,"").split(" "),o=r.split("/").pop();return o==="env"?n:n?`${o} ${n}`:o};const Dt=K,Hs=Gs;function Us(e){const r=Buffer.alloc(150);let n;try{n=Dt.openSync(e,"r"),Dt.readSync(n,r,0,150,0),Dt.closeSync(n)}catch{}return Hs(r.toString())}var qs=Us;const zs=L,Sr=Ls,Or=at,Ks=qs,Ws=process.platform==="win32",Vs=/\.(?:com|exe)$/i,Js=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Ys(e){e.file=Sr(e);const t=e.file&&Ks(e.file);return t?(e.args.unshift(e.file),e.command=t,Sr(e)):e.file}function Xs(e){if(!Ws)return e;const t=Ys(e),r=!Vs.test(t);if(e.options.forceShell||r){const n=Js.test(t);e.command=zs.normalize(e.command),e.command=Or.command(e.command),e.args=e.args.map(s=>Or.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 Zs(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:Xs(n)}var Qs=Zs;const lt=process.platform==="win32";function mt(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 ei(e,t){if(!lt)return;const r=e.emit;e.emit=function(n,o){if(n==="exit"){const s=Mr(o,t);if(s)return r.call(e,"error",s)}return r.apply(e,arguments)}}function Mr(e,t){return lt&&e===1&&!t.file?mt(t.original,"spawn"):null}function ti(e,t){return lt&&e===1&&!t.file?mt(t.original,"spawnSync"):null}var ri={hookChildProcess:ei,verifyENOENT:Mr,verifyENOENTSync:ti,notFoundError:mt};const Ir=Sn,pt=Qs,dt=ri;function Tr(e,t,r){const n=pt(e,t,r),o=Ir.spawn(n.command,n.args,n.options);return dt.hookChildProcess(o,n),o}function ni(e,t,r){const n=pt(e,t,r),o=Ir.spawnSync(n.command,n.args,n.options);return o.error=o.error||dt.verifyENOENTSync(o.status,n),o}Q.exports=Tr,Q.exports.spawn=Tr,Q.exports.sync=ni,Q.exports._parse=pt,Q.exports._enoent=dt;var oi=Q.exports,si=Z(oi);function ii(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}`,
|
|
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 kr(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 ui=({cwd:e=U.cwd(),path:t=U.env[kr()],preferLocal:r=!0,execPath:n=U.execPath,addExecPath:o=!0}={})=>{const s=e instanceof URL?Wt(e):e,i=X.resolve(s),u=[];return r&&ai(u,i),o&&ci(u,n,i),[...u,t].join(X.delimiter)},ai=(e,t)=>{let r;for(;r!==t;)e.push(X.join(t,"node_modules/.bin")),r=t,t=X.resolve(t,"..")},ci=(e,t,r)=>{const n=t instanceof URL?Wt(t):t;e.push(X.resolve(r,n,".."))},Di=({env:e=U.env,...t}={})=>{e={...e};const r=kr({env:e});return t.path=e[r],e[r]=ui(t),e},li=(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);!mi(o,s)&&n||Object.defineProperty(e,r,s)},mi=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)},pi=(e,t)=>{const r=Object.getPrototypeOf(t);r!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,r)},di=(e,t)=>`/* Wrapped ${e}*/
|
|
25
|
+
${t}`,fi=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),hi=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),gi=(e,t,r)=>{const n=r===""?"":`with ${r.trim()}() `,o=di.bind(null,n,t.toString());Object.defineProperty(o,"name",hi),Object.defineProperty(e,"toString",{...fi,value:o})};function Ci(e,t,{ignoreNonConfigurable:r=!1}={}){const{name:n}=e;for(const o of Reflect.ownKeys(t))li(e,t,o,r);return pi(e,t),gi(e,t,n),e}const xe=new WeakMap,Lr=(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(...i){if(xe.set(s,++n),n===1)r=e.apply(this,i),e=null;else if(t.throw===!0)throw new Error(`Function \`${o}\` can only be called once`);return r};return Ci(s,e),xe.set(s,n),s};Lr.callCount=e=>{if(!xe.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return xe.get(e)};const Fi=()=>{const e=Rr-Nr+1;return Array.from({length:e},Ei)},Ei=(e,t)=>({name:`SIGRT${t+1}`,number:Nr+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),Nr=34,Rr=64,yi=[{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"}],_r=()=>{const e=Fi();return[...yi,...e].map(bi)},bi=({name:e,number:t,description:r,action:n,forced:o=!1,standard:s})=>{const{signals:{[e]:i}}=Vt,u=i!==void 0;return{name:e,number:u?i:t,description:r,supported:u,action:n,forced:o,standard:s}},wi=()=>{const e=_r();return Object.fromEntries(e.map(Ai))},Ai=({name:e,number:t,description:r,supported:n,action:o,forced:s,standard:i})=>[e,{name:e,number:t,description:r,supported:n,action:o,forced:s,standard:i}],$i=wi(),vi=()=>{const e=_r(),t=Rr+1,r=Array.from({length:t},(n,o)=>Bi(o,e));return Object.assign({},...r)},Bi=(e,t)=>{const r=xi(e,t);if(r===void 0)return{};const{name:n,description:o,supported:s,action:i,forced:u,standard:a}=r;return{[e]:{name:n,number:e,description:o,supported:s,action:i,forced:u,standard:a}}},xi=(e,t)=>{const r=t.find(({name:n})=>Vt.signals[n]===e);return r!==void 0?r:t.find(n=>n.number===e)};vi();const Pi=({timedOut:e,timeout:t,errorCode:r,signal:n,signalDescription:o,exitCode:s,isCanceled:i})=>e?`timed out after ${t} milliseconds`:i?"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",jr=({stdout:e,stderr:t,all:r,error:n,signal:o,exitCode:s,command:i,escapedCommand:u,timedOut:a,isCanceled:l,killed:m,parsed:{options:{timeout:c,cwd:D=U.cwd()}}})=>{s=s===null?void 0:s,o=o===null?void 0:o;const p=o===void 0?void 0:$i[o].description,f=n&&n.code,g=`Command ${Pi({timedOut:a,timeout:c,errorCode:f,signal:o,signalDescription:p,exitCode:s,isCanceled:l})}: ${i}`,y=Object.prototype.toString.call(n)==="[object Error]",A=y?`${g}
|
|
26
26
|
${n.message}`:g,v=[A,t,e].filter(Boolean).join(`
|
|
27
|
-
`);return y?(n.originalMessage=n.message,n.message=v):n=new Error(v),n.shortMessage=A,n.command=i,n.escapedCommand=u,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},
|
|
28
|
-
`)}
|
|
27
|
+
`);return y?(n.originalMessage=n.message,n.message=v):n=new Error(v),n.shortMessage=A,n.command=i,n.escapedCommand=u,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},Pe=["stdin","stdout","stderr"],Si=e=>Pe.some(t=>e[t]!==void 0),Oi=e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return Pe.map(n=>e[n]);if(Si(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Pe.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,Pe.length);return Array.from({length:r},(n,o)=>t[o])};var te={exports:{}},Se={exports:{}};Se.exports;var Gr;function Mi(){return Gr||(Gr=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")}(Se)),Se.exports}var b=$.process;const J=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(!J(b))te.exports=function(){return function(){}};else{var Ii=Jt,De=Mi(),Ti=/^win/i.test(b.platform),Oe=Yt;typeof Oe!="function"&&(Oe=Oe.EventEmitter);var B;b.__signal_exit_emitter__?B=b.__signal_exit_emitter__:(B=b.__signal_exit_emitter__=new Oe,B.count=0,B.emitted={}),B.infinite||(B.setMaxListeners(1/0),B.infinite=!0),te.exports=function(e,t){if(!J($.process))return function(){};Ii.equal(typeof e,"function","a callback must be provided for exit handler"),le===!1&&Hr();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&&ft()};return B.on(r,e),n};var ft=function(){!le||!J($.process)||(le=!1,De.forEach(function(t){try{b.removeListener(t,ht[t])}catch{}}),b.emit=gt,b.reallyExit=Ur,B.count-=1)};te.exports.unload=ft;var re=function(t,r,n){B.emitted[t]||(B.emitted[t]=!0,B.emit(t,r,n))},ht={};De.forEach(function(e){ht[e]=function(){if(J($.process)){var r=b.listeners(e);r.length===B.count&&(ft(),re("exit",null,e),re("afterexit",null,e),Ti&&e==="SIGHUP"&&(e="SIGINT"),b.kill(b.pid,e))}}}),te.exports.signals=function(){return De};var le=!1,Hr=function(){le||!J($.process)||(le=!0,B.count+=1,De=De.filter(function(t){try{return b.on(t,ht[t]),!0}catch{return!1}}),b.emit=Li,b.reallyExit=ki)};te.exports.load=Hr;var Ur=b.reallyExit,ki=function(t){J($.process)&&(b.exitCode=t||0,re("exit",b.exitCode,null),re("afterexit",b.exitCode,null),Ur.call(b,b.exitCode))},gt=b.emit,Li=function(t,r){if(t==="exit"&&J($.process)){r!==void 0&&(b.exitCode=r);var n=gt.apply(this,arguments);return re("exit",b.exitCode,null),re("afterexit",b.exitCode,null),n}else return gt.apply(this,arguments)}}var Ni=te.exports,Ri=Z(Ni);const _i=1e3*5,ji=(e,t="SIGTERM",r={})=>{const n=e(t);return Gi(e,t,r,n),n},Gi=(e,t,r,n)=>{if(!Hi(t,r,n))return;const o=qi(r),s=setTimeout(()=>{e("SIGKILL")},o);s.unref&&s.unref()},Hi=(e,{forceKillAfterTimeout:t},r)=>Ui(e)&&t!==!1&&r,Ui=e=>e===On.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",qi=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return _i;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},zi=(e,t)=>{e.kill()&&(t.isCanceled=!0)},Ki=(e,t,r)=>{e.kill(t),r(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},Wi=(e,{timeout:t,killSignal:r="SIGTERM"},n)=>{if(t===0||t===void 0)return n;let o;const s=new Promise((u,a)=>{o=setTimeout(()=>{Ki(e,r,a)},t)}),i=n.finally(()=>{clearTimeout(o)});return Promise.race([s,i])},Vi=({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})`)},Ji=async(e,{cleanup:t,detached:r},n)=>{if(!t||r)return n;const o=Ri(()=>{e.kill()});return n.finally(()=>{o()})};function qr(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}function zr(e){return qr(e)&&e.writable!==!1&&typeof e._write=="function"&&typeof e._writableState=="object"}const Yi=e=>e instanceof Pn&&typeof e.then=="function",Ct=(e,t,r)=>{if(typeof r=="string")return e[t].pipe(Mn(r)),e;if(zr(r))return e[t].pipe(r),e;if(!Yi(r))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!zr(r.stdin))throw new TypeError("The target child process's stdin must be available.");return e[t].pipe(r.stdin),r},Xi=e=>{e.stdout!==null&&(e.pipeStdout=Ct.bind(void 0,e,"stdout")),e.stderr!==null&&(e.pipeStderr=Ct.bind(void 0,e,"stderr")),e.all!==void 0&&(e.pipeAll=Ct.bind(void 0,e,"all"))};var me={exports:{}};const{PassThrough:Zi}=ze;var Qi=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 Zi({objectMode:o});r&&s.setEncoding(r);let i=0;const u=[];return s.on("data",a=>{u.push(a),o?i=u.length:i+=a.length}),s.getBufferedValue=()=>t?u:n?Buffer.concat(u,i):u.join(""),s.getBufferedLength=()=>i,s};const{constants:eu}=Tn,tu=ze,{promisify:ru}=Xt,nu=Qi,ou=ru(tu.pipeline);class Kr extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function Ft(e,t){if(!e)throw new Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:r}=t,n=nu(t);return await new Promise((o,s)=>{const i=u=>{u&&n.getBufferedLength()<=eu.MAX_LENGTH&&(u.bufferedData=n.getBufferedValue()),s(u)};(async()=>{try{await ou(e,n),o()}catch(u){i(u)}})(),n.on("data",()=>{n.getBufferedLength()>r&&i(new Kr)})}),n.getBufferedValue()}me.exports=Ft,me.exports.buffer=(e,t)=>Ft(e,{...t,encoding:"buffer"}),me.exports.array=(e,t)=>Ft(e,{...t,array:!0}),me.exports.MaxBufferError=Kr;var su=me.exports,Wr=Z(su);const{PassThrough:iu}=ze;var uu=function(){var e=[],t=new iu({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(i){return i!==s}),!e.length&&t.readable&&t.end()}},au=Z(uu);const cu=e=>{if(e!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},Du=({input:e,inputFile:t})=>typeof t!="string"?e:(cu(e),In(t)),lu=(e,t)=>{const r=Du(t);r!==void 0&&(qr(r)?r.pipe(e.stdin):e.stdin.end(r))},mu=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;const r=au();return e.stdout&&r.add(e.stdout),e.stderr&&r.add(e.stderr),r},Et=async(e,t)=>{if(!(!e||t===void 0)){e.destroy();try{return await t}catch(r){return r.bufferedData}}},yt=(e,{encoding:t,buffer:r,maxBuffer:n})=>{if(!(!e||!r))return t?Wr(e,{encoding:t,maxBuffer:n}):Wr.buffer(e,{maxBuffer:n})},pu=async({stdout:e,stderr:t,all:r},{encoding:n,buffer:o,maxBuffer:s},i)=>{const u=yt(e,{encoding:n,buffer:o,maxBuffer:s}),a=yt(t,{encoding:n,buffer:o,maxBuffer:s}),l=yt(r,{encoding:n,buffer:o,maxBuffer:s*2});try{return await Promise.all([i,u,a,l])}catch(m){return Promise.all([{error:m,signal:m.signal,timedOut:m.timedOut},Et(e,u),Et(t,a),Et(r,l)])}},du=(async()=>{})().constructor.prototype,fu=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(du,e)]),Vr=(e,t)=>{for(const[r,n]of fu){const o=typeof t=="function"?(...s)=>Reflect.apply(n.value,t(),s):n.value.bind(t);Reflect.defineProperty(e,r,{...n,value:o})}},hu=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)})}),Jr=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],gu=/^[\w.-]+$/,Cu=/"/g,Fu=e=>typeof e!="string"||gu.test(e)?e:`"${e.replace(Cu,'\\"')}"`,Eu=(e,t)=>Jr(e,t).join(" "),yu=(e,t)=>Jr(e,t).map(r=>Fu(r)).join(" "),bu=kn("execa").enabled,Me=(e,t)=>String(e).padStart(t,"0"),wu=()=>{const e=new Date;return`${Me(e.getHours(),2)}:${Me(e.getMinutes(),2)}:${Me(e.getSeconds(),2)}.${Me(e.getMilliseconds(),3)}`},Au=(e,{verbose:t})=>{t&&U.stderr.write(`[${wu()}] ${e}
|
|
28
|
+
`)},$u=1e3*1e3*100,vu=({env:e,extendEnv:t,preferLocal:r,localDir:n,execPath:o})=>{const s=t?{...U.env,...e}:e;return r?Di({env:s,cwd:n,execPath:o}):s},Bu=(e,t,r={})=>{const n=si._parse(e,t,r);return e=n.command,t=n.args,r=n.options,r={maxBuffer:$u,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:r.cwd||U.cwd(),execPath:U.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:bu,...r},r.env=vu(r),r.stdio=Oi(r),U.platform==="win32"&&X.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:r,parsed:n}},bt=(e,t,r)=>typeof t!="string"&&!xn.isBuffer(t)?r===void 0?void 0:"":e.stripFinalNewline?ii(t):t;function ne(e,t,r){const n=Bu(e,t,r),o=Eu(e,t),s=yu(e,t);Au(s,n.options),Vi(n.options);let i;try{i=Kt.spawn(n.file,n.args,n.options)}catch(p){const f=new Kt.ChildProcess,h=Promise.reject(jr({error:p,stdout:"",stderr:"",all:"",command:o,escapedCommand:s,parsed:n,timedOut:!1,isCanceled:!1,killed:!1}));return Vr(f,h),f}const u=hu(i),a=Wi(i,n.options,u),l=Ji(i,n.options,a),m={isCanceled:!1};i.kill=ji.bind(null,i.kill.bind(i)),i.cancel=zi.bind(null,i,m);const D=Lr(async()=>{const[{error:p,exitCode:f,signal:h,timedOut:g},y,A,v]=await pu(i,n.options,l),Y=bt(n.options,y),z=bt(n.options,A),w=bt(n.options,v);if(p||f!==0||h!==null){const x=jr({error:p,exitCode:f,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:i.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 lu(i,n.options),i.all=mu(i,n.options),Xi(i),Vr(i,D),i}class _{static create(t,r){return new t(r)}}class j{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(i=>this.extractMessageAsType(i,r)).map(i=>({title:`${i.subject}`,value:`${i.subject}${i.body?`
|
|
29
29
|
|
|
30
30
|
${i.body}`:""}${i.footer?`
|
|
31
31
|
|
|
@@ -33,24 +33,24 @@ ${i.footer}`:""}`}));return s.length>n?s.slice(0,n):s}catch{const s=/\[[\s\S]*?\
|
|
|
33
33
|
|
|
34
34
|
${m.body}`:""}${m.footer?`
|
|
35
35
|
|
|
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 i=/:\w*:\s*(.*)/,u=t.subject.match(i);return{...t,subject:u?u[0].toLowerCase():t.subject};default:return t}}normalizeCommitMessage(t){const r=/^(\w+)(\(.*?\))?:\s(.*)$/,n=t.match(r);if(n){const[,o,s,i]=n,u=o.toLowerCase(),a=i.charAt(0).toLowerCase()+i.slice(1);t=`${u}${s||""}: ${a}`}return t}}var
|
|
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 i=/:\w*:\s*(.*)/,u=t.subject.match(i);return{...t,subject:u?u[0].toLowerCase():t.subject};default:return t}}normalizeCommitMessage(t){const r=/^(\w+)(\(.*?\))?:\s(.*)$/,n=t.match(r);if(n){const[,o,s,i]=n,u=o.toLowerCase(),a=i.charAt(0).toLowerCase()+i.slice(1);t=`${u}${s||""}: ${a}`}return t}}var Yr="2.0.8",xu="A Reactive CLI that generates git commit messages with various AI";class E extends Error{}const wt=" ",pe=e=>{e instanceof Error&&(e instanceof E||(e.stack&&console.error(C.dim(e.stack.split(`
|
|
37
37
|
`).slice(1).join(`
|
|
38
38
|
`))),console.error(`
|
|
39
|
-
${
|
|
40
|
-
${
|
|
39
|
+
${wt}${C.dim(`aicommit2 v${Yr}`)}`),console.error(`
|
|
40
|
+
${wt}Please open a Bug report with the information above:`),console.error(`${wt}https://github.com/tak-bro/aicommit2/issues/new/choose`)))},Xr=L.join(Ve.homedir(),".aicommit2_log"),Pu=new Date,G=(e,t,r,n)=>{const o=`[${e}]`,s=Su(Pu,t),i=`${Xr}/${s}`,u=`- System Prompt
|
|
41
41
|
${r}`,a=`- Response
|
|
42
42
|
${n}`,l=`[Git Diff]
|
|
43
|
-
${t}`;if(K.existsSync(i)){const m=K.readFileSync(i,"utf-8");
|
|
43
|
+
${t}`;if(K.existsSync(i)){const m=K.readFileSync(i,"utf-8");Zr(i,`${o}
|
|
44
44
|
${a}
|
|
45
45
|
|
|
46
46
|
${u}
|
|
47
47
|
|
|
48
|
-
${m}`);return}
|
|
48
|
+
${m}`);return}Zr(i,`${o}
|
|
49
49
|
${a}
|
|
50
50
|
|
|
51
51
|
${u}
|
|
52
52
|
|
|
53
|
-
${l}`)},
|
|
53
|
+
${l}`)},Su=(e,t)=>{const{year:r,month:n,day:o,hours:s,minutes:i,seconds:u}=Ou(e),l=Gn(0).update(t).digest("hex");return`aic2_${r}-${n}-${o}_${s}-${i}-${u}_${l}.log`},Zr=(e,t="")=>{K.mkdirSync(L.dirname(e),{recursive:!0}),K.writeFileSync(e,t,"utf-8")},Ou=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"),i=e.getSeconds().toString().padStart(2,"0");return{year:t,month:r,day:n,hours:o,minutes:s,seconds:i}},k={locale:"en",maxLength:50,type:"conventional",generate:1,systemPrompt:"",systemPromptPath:""},Mu={"":"<commit message>",conventional:`<type>(<optional scope>): <description>
|
|
54
54
|
|
|
55
55
|
[optional body]
|
|
56
56
|
|
|
@@ -58,12 +58,12 @@ ${l}`)},xu=(e,t)=>{const{year:r,month:n,day:o,hours:s,minutes:i,seconds:u}=Pu(e)
|
|
|
58
58
|
|
|
59
59
|
[optional body]
|
|
60
60
|
|
|
61
|
-
[optional footer(s)]`},
|
|
61
|
+
[optional footer(s)]`},Iu={"":"",gitmoji:`
|
|
62
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
63
|
`)}`,conventional:`
|
|
64
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
|
-
`)}`},
|
|
66
|
-
`)},
|
|
65
|
+
`)}`},Tu=(e,t)=>e.replace(/{(\w+)}/g,(r,n)=>t[n]?.toString()||k[n]?.toString()),Qr=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:`,`${Mu[t]}`,`3. Types: use one of the following types:${Iu[t]}`,"4. Exclude anything unnecessary such as translation. Your entire response will be passed directly into git commit."].filter(Boolean).join(`
|
|
66
|
+
`)},Ie=(e,t)=>{const r=n=>n==="conventional"?`${Array(t).fill(null).map((o,s)=>`
|
|
67
67
|
{
|
|
68
68
|
"subject": "fix: fix bug in user authentication process",
|
|
69
69
|
"body": "- Update login function to handle edge cases\\n- Add additional error logging for debugging",
|
|
@@ -77,31 +77,31 @@ ${Object.entries({docs:"Documentation only changes",style:"Changes that do not a
|
|
|
77
77
|
[${r(e)}
|
|
78
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
79
|
`)},H=e=>{const{systemPrompt:t,systemPromptPath:r,type:n,generate:o}=e;if(t)return`${t}
|
|
80
|
-
${
|
|
81
|
-
${
|
|
82
|
-
${
|
|
83
|
-
${Me(n,o)}`}};class Iu extends _{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 M({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 R(this.generateMessage()).pipe(N(t=>O(t)),I(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})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,temperature:s,locale:i,generate:u,type:a,maxLength:l}=this.params.config,m={...k,locale:i,maxLength:l,type:a,generate:u,systemPrompt:r,systemPromptPath:n},c=H(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&&G("Anthropic",t,c,d),this.parseMessage(d,a,u)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new E(`Error connecting to ${r.hostname} (${r.syscall})`):r}}}const Zr=e=>e&&`${e[0].toUpperCase()}${e.slice(1)}`,Oe=(e,t)=>{const r=Math.ceil(e),n=Math.floor(t);return Math.floor(Math.random()*(n-r+1))+r},Tu=(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 oe{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 ku extends _{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 M({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 R(this.generateMessage()).pipe(N(t=>O(t)),I(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})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,generate:i,type:u,maxLength:a}=this.params.config,l={...k,locale:s,maxLength:a,type:u,generate:i,systemPrompt:r,systemPromptPath:n},m=H(l);this.checkAvailableModels();const c=await this.createChatCompletions(m);return o&&G("Codestral",t,m,c),this.parseMessage(c,u,i)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new E(`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 oe({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:this.params.config.topP,max_tokens:this.params.config.maxTokens,stream:!1,safe_prompt:!1,random_seed:Oe(10,1e3),response_format:{type:"json_object"}}).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 Lu extends _{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 i=`${r.statusCode} ${s}`;return M({name:`${this.errorPrefix} ${i}`,value:s,isError:!0,disabled:!0})},this.colors={primary:"#D18EE2",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Cohere]"),this.errorPrefix=C.red.bold("[Cohere]"),this.cohere=new Gn({token:this.params.config.key})}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>O(t)),I(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})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,temperature:i,generate:u,type:a,maxLength:l}=this.params.config,m={...k,locale:s,maxLength:l,type:a,generate:u,systemPrompt:r,systemPromptPath:n},c=H(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:i,model:this.params.config.model,seed:Oe(10,1e3)});return o&&G("Cohere",t,c,p.text),this.parseMessage(p.text,a,u)}catch(t){const r=t;throw r instanceof Hn?new E("Request timed out error!"):r}}}class Nu extends _{constructor(t){super(t),this.params=t,this.host="https://api.deepseek.com",this.apiKey="",this.handleError$=r=>{const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return M({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#53a3f9",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[DeepSeek]"),this.errorPrefix=C.red.bold("[DeepSeek]"),this.apiKey=this.params.config.key}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>O(t)),I(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})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,generate:i,type:u,maxLength:a}=this.params.config,l={...k,locale:s,maxLength:a,type:u,generate:i,systemPrompt:r,systemPromptPath:n},m=H(l);this.checkAvailableModels();const c=await this.createChatCompletions(m);return o&&G("DeepSeek",t,m,c),this.parseMessage(c,u,i)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new E(`Error connecting to ${r.hostname} (${r.syscall})`):r}}checkAvailableModels(){if(["deepseek-coder","deepseek-chat"].includes(this.params.config.model))return!0;throw new Error("Invalid model type of DeepSeek")}async createChatCompletions(t){const n=(await new oe({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: ${this.params.stagedDiff.diff}`}],response_format:{type:"json_object"},temperature:this.params.config.temperature,top_p:this.params.config.topP,max_tokens:this.params.config.maxTokens,stream:!1}).execute()).data;if(!n.choices||n.choices.length===0||!n.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return n.choices[0].message.content}}class Ru extends _{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=r.message||r.toString(),o=/(\[.*?\]\s*[^[]*)/g,s=[...n.matchAll(o)],i=[];s.forEach(a=>i.push(a[1]));const u=i[1]||"An error occurred";return M({name:`${this.errorPrefix} ${u}`,value:u,isError:!0,disabled:!0})},this.colors={primary:"#0077FF",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Gemini]"),this.errorPrefix=C.red.bold("[Gemini]"),this.genAI=new Un(this.params.config.key)}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>O(t)),I(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})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,temperature:i,generate:u,type:a,maxLength:l}=this.params.config,m=this.params.config.maxTokens,c={...k,locale:s,maxLength:l,type:a,generate:u,systemPrompt:r,systemPromptPath:n},D=H(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&&G("Gemini",t,D,g),this.parseMessage(g,a,u)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new E(`Error connecting to ${r.hostname} (${r.syscall})`):r}}}var bt={},wt={exports:{}},fe={exports:{}},At,Qr;function ju(){if(Qr)return At;Qr=1;var e=1e3,t=e*60,r=t*60,n=r*24,o=n*7,s=n*365.25;At=function(m,c){c=c||{};var D=typeof m;if(D==="string"&&m.length>0)return i(m);if(D==="number"&&isFinite(m))return c.long?a(m):u(m);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(m))};function i(m){if(m=String(m),!(m.length>100)){var c=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(m);if(c){var D=parseFloat(c[1]),p=(c[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return D*s;case"weeks":case"week":case"w":return D*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 u(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 At}var $t,en;function tn(){if(en)return $t;en=1;function e(t){n.debug=n,n.default=n,n.coerce=l,n.disable=i,n.enable=s,n.enabled=u,n.humanize=ju(),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(...y){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,y[0]=n.coerce(y[0]),typeof y[0]!="string"&&y.unshift("%O");let z=0;y[0]=y[0].replace(/%([a-zA-Z%])/g,(x,wn)=>{if(x==="%%")return"%";z++;const Ut=n.formatters[wn];if(typeof Ut=="function"){const An=y[z];x=Ut.call(A,An),y.splice(z,1),z--}return x}),n.formatArgs.call(A,y),(A.log||n.log).apply(A,y)}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:y=>{p=y}}),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 i(){const c=[...n.names.map(a),...n.skips.map(a).map(D=>"-"+D)].join(",");return n.enable(""),c}function u(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 $t=e,$t}fe.exports;var rn;function _u(){return rn||(rn=1,function(e,t){t.formatArgs=n,t.save=o,t.load=s,t.useColors=r,t.storage=i(),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 i(){try{return localStorage}catch{}}e.exports=tn()(t);const{formatters:u}=e.exports;u.j=function(a){try{return JSON.stringify(a)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(fe,fe.exports)),fe.exports}var de={exports:{}},vt,nn;function Gu(){return nn||(nn=1,vt=(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)}),vt}var Bt,on;function Hu(){if(on)return Bt;on=1;const e=Ke,t=He,r=Gu(),{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 i(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 u(a){const l=i(a,a&&a.isTTY);return s(l)}return Bt={supportsColor:u,stdout:s(i(!0,t.isatty(1))),stderr:s(i(!0,t.isatty(2)))},Bt}de.exports;var sn;function Uu(){return sn||(sn=1,function(e,t){const r=He,n=Vt;t.init=m,t.log=u,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=Hu();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,y)=>y.toUpperCase());let h=process.env[p];return/^(yes|on|true|enabled)$/i.test(h)?h=!0:/^(no|off|false|disabled)$/i.test(h)?h=!1:h==="null"?h=null:h=Number(h),D[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),y=` ${g};1m${p} \x1B[0m`;D[0]=y+D[0].split(`
|
|
80
|
+
${Ie(n,o)}`;if(!r)return`${Qr(e)}
|
|
81
|
+
${Ie(n,o)}`;try{const s=K.readFileSync(L.resolve(r),"utf-8");return`${Tu(s,e)}
|
|
82
|
+
${Ie(n,o)}`}catch{return`${Qr(e)}
|
|
83
|
+
${Ie(n,o)}`}};class ku 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 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 jn({apiKey:this.params.config.key})}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>M(t)),I(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})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,temperature:s,locale:i,generate:u,type:a,maxLength:l}=this.params.config,m={...k,locale:i,maxLength:l,type:a,generate:u,systemPrompt:r,systemPromptPath:n},c=H(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},f=(await this.anthropic.messages.create(D)).content.map(({text:h})=>h).join("");return o&&G("Anthropic",t,c,f),this.parseMessage(f,a,u)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new E(`Error connecting to ${r.hostname} (${r.syscall})`):r}}}const en=e=>e&&`${e[0].toUpperCase()}${e.slice(1)}`,Te=(e,t)=>{const r=Math.ceil(e),n=Math.floor(t);return Math.floor(Math.random()*(n-r+1))+r},Lu=(e,t)=>e.disabled&&!t.disabled?1:!e.disabled&&t.disabled?-1:0,ke=e=>e.reduce((t,r)=>Array.isArray(r)?t.concat(ke(r)):t.concat(r),[]);class oe{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=Hn.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 Nu 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 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 R(this.generateMessage()).pipe(N(t=>M(t)),I(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})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,generate:i,type:u,maxLength:a}=this.params.config,l={...k,locale:s,maxLength:a,type:u,generate:i,systemPrompt:r,systemPromptPath:n},m=H(l);this.checkAvailableModels();const c=await this.createChatCompletions(m);return o&&G("Codestral",t,m,c),this.parseMessage(c,u,i)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new E(`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 oe({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:this.params.config.topP,max_tokens:this.params.config.maxTokens,stream:!1,safe_prompt:!1,random_seed:Te(10,1e3),response_format:{type:"json_object"}}).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 Ru 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 i=`${r.statusCode} ${s}`;return O({name:`${this.errorPrefix} ${i}`,value:s,isError:!0,disabled:!0})},this.colors={primary:"#D18EE2",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Cohere]"),this.errorPrefix=C.red.bold("[Cohere]"),this.cohere=new Un({token:this.params.config.key})}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>M(t)),I(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})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,temperature:i,generate:u,type:a,maxLength:l}=this.params.config,m={...k,locale:s,maxLength:l,type:a,generate:u,systemPrompt:r,systemPromptPath:n},c=H(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:i,model:this.params.config.model,seed:Te(10,1e3)});return o&&G("Cohere",t,c,p.text),this.parseMessage(p.text,a,u)}catch(t){const r=t;throw r instanceof qn?new E("Request timed out error!"):r}}}class _u extends j{constructor(t){super(t),this.params=t,this.host="https://api.deepseek.com",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:"#53a3f9",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[DeepSeek]"),this.errorPrefix=C.red.bold("[DeepSeek]"),this.apiKey=this.params.config.key}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>M(t)),I(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})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,generate:i,type:u,maxLength:a}=this.params.config,l={...k,locale:s,maxLength:a,type:u,generate:i,systemPrompt:r,systemPromptPath:n},m=H(l);this.checkAvailableModels();const c=await this.createChatCompletions(m);return o&&G("DeepSeek",t,m,c),this.parseMessage(c,u,i)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new E(`Error connecting to ${r.hostname} (${r.syscall})`):r}}checkAvailableModels(){if(["deepseek-coder","deepseek-chat"].includes(this.params.config.model))return!0;throw new Error("Invalid model type of DeepSeek")}async createChatCompletions(t){const n=(await new oe({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: ${this.params.stagedDiff.diff}`}],response_format:{type:"json_object"},temperature:this.params.config.temperature,top_p:this.params.config.topP,max_tokens:this.params.config.maxTokens,stream:!1}).execute()).data;if(!n.choices||n.choices.length===0||!n.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return n.choices[0].message.content}}class ju 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)],i=[];s.forEach(a=>i.push(a[1]));const u=i[1]||"An error occurred";return O({name:`${this.errorPrefix} ${u}`,value:u,isError:!0,disabled:!0})},this.colors={primary:"#0077FF",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Gemini]"),this.errorPrefix=C.red.bold("[Gemini]"),this.genAI=new zn(this.params.config.key)}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>M(t)),I(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})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,temperature:i,generate:u,type:a,maxLength:l}=this.params.config,m=this.params.config.maxTokens,c={...k,locale:s,maxLength:l,type:a,generate:u,systemPrompt:r,systemPromptPath:n},D=H(c),g=(await this.genAI.getGenerativeModel({model:this.params.config.model,systemInstruction:D,generationConfig:{maxOutputTokens:m,temperature:this.params.config.temperature},safetySettings:[{category:Ee.HARM_CATEGORY_HATE_SPEECH,threshold:ye.BLOCK_LOW_AND_ABOVE},{category:Ee.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:ye.BLOCK_LOW_AND_ABOVE},{category:Ee.HARM_CATEGORY_HARASSMENT,threshold:ye.BLOCK_LOW_AND_ABOVE},{category:Ee.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:ye.BLOCK_LOW_AND_ABOVE}]}).generateContent(`Here are diff: ${t}`)).response.text();return o&&G("Gemini",t,D,g),this.parseMessage(g,a,u)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new E(`Error connecting to ${r.hostname} (${r.syscall})`):r}}}var At={},$t={exports:{}},de={exports:{}},vt,tn;function Gu(){if(tn)return vt;tn=1;var e=1e3,t=e*60,r=t*60,n=r*24,o=n*7,s=n*365.25;vt=function(m,c){c=c||{};var D=typeof m;if(D==="string"&&m.length>0)return i(m);if(D==="number"&&isFinite(m))return c.long?a(m):u(m);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(m))};function i(m){if(m=String(m),!(m.length>100)){var c=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(m);if(c){var D=parseFloat(c[1]),p=(c[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return D*s;case"weeks":case"week":case"w":return D*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 u(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 f=c>=D*1.5;return Math.round(m/D)+" "+p+(f?"s":"")}return vt}var Bt,rn;function nn(){if(rn)return Bt;rn=1;function e(t){n.debug=n,n.default=n,n.coerce=l,n.disable=i,n.enable=s,n.enabled=u,n.humanize=Gu(),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,f,h;function g(...y){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,y[0]=n.coerce(y[0]),typeof y[0]!="string"&&y.unshift("%O");let z=0;y[0]=y[0].replace(/%([a-zA-Z%])/g,(x,$n)=>{if(x==="%%")return"%";z++;const zt=n.formatters[$n];if(typeof zt=="function"){const vn=y[z];x=zt.call(A,vn),y.splice(z,1),z--}return x}),n.formatArgs.call(A,y),(A.log||n.log).apply(A,y)}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:(f!==n.namespaces&&(f=n.namespaces,h=n.enabled(c)),h),set:y=>{p=y}}),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,]+/),f=p.length;for(D=0;D<f;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 i(){const c=[...n.names.map(a),...n.skips.map(a).map(D=>"-"+D)].join(",");return n.enable(""),c}function u(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 Bt=e,Bt}de.exports;var on;function Hu(){return on||(on=1,function(e,t){t.formatArgs=n,t.save=o,t.load=s,t.useColors=r,t.storage=i(),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 i(){try{return localStorage}catch{}}e.exports=nn()(t);const{formatters:u}=e.exports;u.j=function(a){try{return JSON.stringify(a)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(de,de.exports)),de.exports}var fe={exports:{}},xt,sn;function Uu(){return sn||(sn=1,xt=(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)}),xt}var Pt,un;function qu(){if(un)return Pt;un=1;const e=Ve,t=qe,r=Uu(),{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 i(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 u(a){const l=i(a,a&&a.isTTY);return s(l)}return Pt={supportsColor:u,stdout:s(i(!0,t.isatty(1))),stderr:s(i(!0,t.isatty(2)))},Pt}fe.exports;var an;function zu(){return an||(an=1,function(e,t){const r=qe,n=Xt;t.init=m,t.log=u,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=qu();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 f=p.substring(6).toLowerCase().replace(/_([a-z])/g,(g,y)=>y.toUpperCase());let h=process.env[p];return/^(yes|on|true|enabled)$/i.test(h)?h=!0:/^(no|off|false|disabled)$/i.test(h)?h=!1:h==="null"?h=null:h=Number(h),D[f]=h,D},{});function o(){return"colors"in t.inspectOpts?!!t.inspectOpts.colors:r.isatty(process.stderr.fd)}function s(D){const{namespace:p,useColors:f}=this;if(f){const h=this.color,g="\x1B[3"+(h<8?h:"8;5;"+h),y=` ${g};1m${p} \x1B[0m`;D[0]=y+D[0].split(`
|
|
84
84
|
`).join(`
|
|
85
85
|
`+y),D.push(g+"m+"+e.exports.humanize(this.diff)+"\x1B[0m")}else D[0]=i()+p+" "+D[0]}function i(){return t.inspectOpts.hideDate?"":new Date().toISOString()+" "}function u(...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
|
|
87
|
-
`).map(p=>p.trim()).join(" ")},c.O=function(D){return this.inspectOpts.colors=this.useColors,n.inspect(D,this.inspectOpts)}}(
|
|
88
|
-
`).some(t=>t.indexOf("(https.js:")!==-1||t.indexOf("node:https:")!==-1)}function
|
|
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 f=0;f<p.length;f++)D.inspectOpts[p[f]]=t.inspectOpts[p[f]]}e.exports=nn()(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)}}(fe,fe.exports)),fe.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?$t.exports=Hu():$t.exports=zu();var St=$t.exports,Ot={};Object.defineProperty(Ot,"__esModule",{value:!0});function Ku(e){return function(t,r){return new Promise((n,o)=>{e.call(this,t,r,(s,i)=>{s?o(s):n(i)})})}}Ot.default=Ku;var cn=$&&$.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const Wu=Yt,Vu=cn(St),Ju=cn(Ot),he=Vu.default("agent-base");function Yu(e){return!!e&&typeof e.addRequest=="function"}function Mt(){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 Le(e,t){return new Le.Agent(e,t)}(function(e){class t extends Wu.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:Mt()?443:80}set defaultPort(n){this.explicitDefaultPort=n}get protocol(){return typeof this.explicitProtocol=="string"?this.explicitProtocol:Mt()?"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=Mt()),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 i=!1,u=null;const a=s.timeout||this.timeout,l=p=>{n._hadError||(n.emit("error",p),n._hadError=!0)},m=()=>{u=null,i=!0;const p=new Error(`A "socket" was not created for HTTP request before ${a}ms`);p.code="ETIMEOUT",l(p)},c=p=>{i||(u!==null&&(clearTimeout(u),u=null),l(p))},D=p=>{if(i)return;if(u!=null&&(clearTimeout(u),u=null),Yu(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 f=new Error(`no Duplex stream was returned to agent-base for \`${n.method} ${n.path}\``);l(f)};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=Ju.default(this.callback)):this.promisifiedCallback=this.callback),typeof a=="number"&&a>0&&(u=setTimeout(m,a)),"port"in s&&typeof s.port!="number"&&(s.port=Number(s.port));try{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})(Le||(Le={}));var Xu=Le,It={},Zu=$&&$.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(It,"__esModule",{value:!0});const Qu=Zu(St),ge=Qu.default("https-proxy-agent:parse-proxy-response");function ea(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 i(){e.removeListener("end",a),e.removeListener("error",l),e.removeListener("close",u),e.removeListener("readable",s)}function u(c){ge("onclose had error %o",c)}function a(){ge("onend")}function l(c){i(),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
|
|
89
89
|
\r
|
|
90
|
-
`)===-1){ge("have not received end of HTTP headers yet..."),s();return}const
|
|
91
|
-
`)),h=+
|
|
92
|
-
`;n.auth&&(i["Proxy-Authorization"]=`Basic ${Buffer.from(n.auth).toString("base64")}`);let{host:l,port:m,secureEndpoint:c}=r;
|
|
93
|
-
`;const D=
|
|
94
|
-
`);const{statusCode:p,buffered:
|
|
90
|
+
`)===-1){ge("have not received end of HTTP headers yet..."),s();return}const f=D.toString("ascii",0,D.indexOf(`\r
|
|
91
|
+
`)),h=+f.split(" ")[1];ge("got proxy server response: %o",f),t({statusCode:h,buffered:D})}e.on("error",l),e.on("close",u),e.on("end",a),s()})}It.default=ea;var ta=$&&$.__awaiter||function(e,t,r,n){function o(s){return s instanceof r?s:new r(function(i){i(s)})}return new(r||(r=Promise))(function(s,i){function u(m){try{l(n.next(m))}catch(c){i(c)}}function a(m){try{l(n.throw(m))}catch(c){i(c)}}function l(m){m.done?s(m.value):o(m.value).then(u,a)}l((n=n.apply(e,t||[])).next())})},se=$&&$.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(At,"__esModule",{value:!0});const Dn=se(Jn),ln=se(Yn),ra=se(Xn),na=se(Jt),oa=se(St),sa=Xu,ia=se(It),Ce=oa.default("https-proxy-agent:agent");class ua extends sa.Agent{constructor(t){let r;if(typeof t=="string"?r=ra.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||Da(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 ta(this,void 0,void 0,function*(){const{proxy:n,secureProxy:o}=this;let s;o?(Ce("Creating `tls.Socket`: %o",n),s=ln.default.connect(n)):(Ce("Creating `net.Socket`: %o",n),s=Dn.default.connect(n));const i=Object.assign({},n.headers);let a=`CONNECT ${`${r.host}:${r.port}`} HTTP/1.1\r
|
|
92
|
+
`;n.auth&&(i["Proxy-Authorization"]=`Basic ${Buffer.from(n.auth).toString("base64")}`);let{host:l,port:m,secureEndpoint:c}=r;ca(m,c)||(l+=`:${m}`),i.Host=l,i.Connection="close";for(const g of Object.keys(i))a+=`${g}: ${i[g]}\r
|
|
93
|
+
`;const D=ia.default(s);s.write(`${a}\r
|
|
94
|
+
`);const{statusCode:p,buffered:f}=yield D;if(p===200){if(t.once("socket",aa),r.secureEndpoint){Ce("Upgrading socket connection to TLS");const g=r.servername||r.host;return ln.default.connect(Object.assign(Object.assign({},la(r,"host","hostname","path","port")),{socket:s,servername:g}))}return s}s.destroy();const h=new Dn.default.Socket({writable:!1});return h.readable=!0,t.once("socket",g=>{Ce("replaying proxy buffer for failed request"),na.default(g.listenerCount("data")>0),g.push(f),g.push(null)}),h})}}At.default=ua;function aa(e){e.resume()}function ca(e,t){return!!(!t&&e===80||t&&e===443)}function Da(e){return typeof e=="string"?/^https:?$/i.test(e):!1}function la(e,...t){const r={};let n;for(n in e)t.includes(n)||(r[n]=e[n]);return r}var ma=$&&$.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const Tt=ma(At);function kt(e){return new Tt.default(e)}(function(e){e.HttpsProxyAgent=Tt.default,e.prototype=Tt.default.prototype})(kt||(kt={}));var pa=kt,da=Z(pa);const fa=async(e,t,r,n,o,s,i)=>new Promise((u,a)=>{const l=JSON.stringify(n),c=(e.protocol.includes("https")?Vn:Wn).request({port:i||void 0,hostname:e.hostname,path:t,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(l),...r},timeout:o,agent:s?da(s):void 0},D=>{const p=[];D.on("data",f=>p.push(f)),D.on("end",()=>{u({request:c,response:D,data:Buffer.concat(p).toString()})})});c.on("error",a),c.on("timeout",()=>{c.destroy(),a(new E(`Time out error: request took over ${o}ms. Try increasing the \`timeout\` config`))}),c.write(l),c.end()}),ha=async(e,t,r,n,o,s)=>{const i=new URL(e),{response:u,data:a}=await fa(i,t,{Authorization:`Bearer ${r}`},n,o,s);if(!u.statusCode||u.statusCode<200||u.statusCode>299){let l=`OpenAI API Error: ${u.statusCode} - ${u.statusMessage}`;throw a&&(l+=`
|
|
95
95
|
|
|
96
96
|
${a}`),u.statusCode===500&&(l+=`
|
|
97
97
|
|
|
98
|
-
Check the API status: https://status.openai.com`),new E(l)}return JSON.parse(a)},
|
|
99
|
-
`),
|
|
98
|
+
Check the API status: https://status.openai.com`),new E(l)}return JSON.parse(a)},Ne=e=>e.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1"),ga=async(e,t,r,n,o,s,i,u,a,l,m,c)=>{try{const D={model:n,messages:[{role:"system",content:l},{role:"user",content:`Here are diff: ${o}`}],temperature:u,max_tokens:i,stream:!1,n:1,top_p:a,frequency_penalty:0,presence_penalty:0};a<=0&&delete D.top_p;const p=await ha(e,t,r,D,s,c),f=p.choices.filter(h=>h.message?.content).map(h=>Ne(h.message.content)).join();return m&&G("OPENAI",o,l,f),p.choices.filter(h=>h.message?.content).map(h=>Ne(h.message.content))}catch(D){const p=D;throw p.code==="ENOTFOUND"?new E(`Error connecting to ${p.hostname} (${p.syscall})`):p}};class Ca 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 i=`${r.status} ${n}`;return O({name:`${this.errorPrefix} ${i}`,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 Kn({apiKey:this.params.config.key})}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>M(t)),I(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})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,temperature:i,generate:u,type:a,maxLength:l}=this.params.config,m=this.params.config.maxTokens,c={...k,locale:s,maxLength:l,type:a,generate:u,systemPrompt:r,systemPromptPath:n},D=H(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:i},{timeout:this.params.config.timeout}),f=p.choices.filter(g=>g.message?.content).map(g=>Ne(g.message.content)).join();o&&G("Groq",t,D,f);const h=p.choices.filter(g=>g.message?.content).map(g=>Ne(g.message.content));return ke(h.map(g=>this.parseMessage(g,a,u)))}catch(t){throw t}}}class Fa 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=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 R(this.generateMessage()).pipe(N(t=>M(t)),I(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})),T(this.handleError$))}async generateMessage(){try{await this.intialize();const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,generate:i,type:u,maxLength:a}=this.params.config,l={...k,locale:s,maxLength:a,type:u,generate:i,systemPrompt:r,systemPromptPath:n},m=H(l),c=await this.getNewChat(m),p=await(await this.sendMessage(`Here are diff: ${t}`,c.id)).completeResponsePromise();return o&&G("HuggingFace",t,m,p),this.parseMessage(p,u,i)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new E(`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=[],i=u=>u===-1?null:n[u];for(const u of o){const a=n[u];if(n[a.unlisted])continue;const l={id:i(a.id),name:i(a.name),displayName:i(a.displayName),preprompt:i(a.preprompt),promptExamples:[],websiteUrl:i(a.websiteUrl),description:i(a.description),datasetName:i(a.datasetName),datasetUrl:i(a.datasetUrl),modelUrl:i(a.modelUrl),parameters:{}},m=i(a.promptExamples);if(m!==null){const p=m.map(f=>i(f));l.promptExamples=p.map(f=>({title:n[f.title],prompt:n[f.prompt]}))}const c=i(a.parameters),D={};for(const[p,f]of Object.entries(c)){if(f===-1){D[p]=null;continue}if(Array.isArray(n[f])){D[p]=n[f].map(h=>n[h]);continue}D[p]=n[f]}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],i=o[o[0].preprompt],u=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=i,n.title=u,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 i(D){try{const p=D.split(`
|
|
99
|
+
`),f=[];for(const h of p)h.trim()&&f.push(JSON.parse(h));return f}catch{return[{}]}}const u=new TextDecoder;let a="";const l=new TransformStream({async transform(D,p){const f=u.decode(D);try{const h=i(f);for(const g of h)g.type==="finalAnswer"?(a=g?.text||"",p.terminate()):g.type==="stream"&&p.enqueue(g?.token||"")}catch{throw new Error("Error during parsing response")}}}),m=s.body?.pipeThrough(l);async function c(){return new Promise(async(D,p)=>{try{if(!m)p("ModifiedStream undefined");else{const f=m.getReader();for(;;){const{done:h,value:g}=await f.read();if(h){D(a);break}}}}catch(f){p(f)}})}return{id:this.currentConversionID,stream:m,completeResponsePromise:c}}async deleteConversation(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 Ea extends j{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 R(this.generateMessage()).pipe(N(t=>M(t)),I(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})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,generate:i,type:u,maxLength:a}=this.params.config,l={...k,locale:s,maxLength:a,type:u,generate:i,systemPrompt:r,systemPromptPath:n},m=H(l);await this.checkAvailableModels();const c=await this.createChatCompletions(m,`Here are diff: ${t}`);return o&&G("MistralAI",t,m,c),this.parseMessage(c,this.params.config.type,i)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new E(`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 oe({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 oe({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:this.params.config.topP,max_tokens:this.params.config.maxTokens,stream:!1,safe_prompt:!1,random_seed:Te(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:Lt}=Object.prototype,Re=typeof process<"u"&&process.platform==="win32"?`\r
|
|
100
100
|
`:`
|
|
101
|
-
`,kt=(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 i=e[s];if(i&&Array.isArray(i))for(const u of i)n+=ie(s+"[]")+o+ie(u)+Le;else i&&typeof i=="object"?r.push(s):n+=ie(s)+o+ie(i)+Le}t.section&&n.length&&(n="["+ie(t.section)+"]"+Le+n);for(const s of r){const i=Dn(s).join("\\."),u=(t.section?t.section+".":"")+i,{whitespace:a}=t,l=kt(e[s],{section:u,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 u of s){if(!u||u.match(/^\s*[;#]/))continue;const a=u.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&&(Tt.call(r,c)?Array.isArray(r[c])||(r[c]=[r[c]]):r[c]=[]),Array.isArray(r[c])?r[c].push(p):r[c]=p}const i=[];for(const u of Object.keys(t)){if(!Tt.call(t,u)||typeof t[u]!="object"||Array.isArray(t[u]))continue;const a=Dn(u);r=t;const l=a.pop(),m=l.replace(/\\\./g,".");for(const c of a)c!=="__proto__"&&((!Tt.call(r,c)||typeof r[c]!="object")&&(r[c]=Object.create(null)),r=r[c]);r===t&&m===l||(r[m]=t[u],i.push(u))}for(const u of i)delete t[u];return t},mn=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),ie=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 i=e.charAt(o);if(r)"\\;#".indexOf(i)!==-1?n+=i:n+="\\"+i,r=!1;else{if(";#".indexOf(i)!==-1)break;i==="\\"?r=!0:n+=i}}return r&&(n+="\\"),n.trim()}return e};var Fa={parse:ln,decode:ln,stringify:kt,encode:kt,safe:ie,unsafe:Ne},Lt=Z(Fa);const pn=e=>P.lstat(e).then(()=>!0,()=>!1),Ea=["","conventional","gitmoji"],Nt="http://localhost:11434",{hasOwnProperty:ya}=Object.prototype,Re=(e,t)=>ya.call(e,t),Rt=["OPENAI","OLLAMA","HUGGINGFACE","GEMINI","ANTHROPIC","MISTRAL","CODESTRAL","COHERE","GROQ","PERPLEXITY","DEEPSEEK"],F=(e,t,r)=>{if(!t)throw new E(`Invalid config property ${e}: ${r}`)},f={systemPrompt(e){return e||""},systemPromptPath(e){return e||""},timeout(e){if(!e)return 1e4;F("timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return F("timeout",t>=500,"Must be greater than 500ms"),t},temperature(e){if(!e)return .7;F("temperature",/^(2|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 2");const t=Number(e);return F("temperature",t>0,"Must be greater than 0"),F("temperature",t<=2,"Must be less than or equal to 2"),t},maxTokens(e){return e?(F("maxTokens",/^\d+$/.test(e),"Must be an integer"),Number(e)):1024},logging(e){return typeof e=="boolean"?e:e==null?!0:(F("logging",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true")},locale(e){return e?(F("locale",e,"Cannot be empty"),F("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;F("generate",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return F("generate",t>0,"Must be greater than 0"),F("generate",t<=5,"Must be less or equal to 5"),t},type(e){return e?(F("type",Ea.includes(e),"Invalid commit type"),e):"conventional"},maxLength(e){if(!e)return 50;F("maxLength",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return F("maxLength",t>=20,"Must be greater than 20 characters"),t},ignoreBody(e){return typeof e=="boolean"?e:e==null?!0:(F("ignoreBody",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true")},exclude:e=>e?(typeof e=="string"?e?.split(","):e).map(r=>r.trim()).filter(r=>!!r&&r.length>0):[]},ue={OPENAI:{key:e=>e||"",model:e=>e||"gpt-4o-mini",url:e=>e?(F("OPENAI.url",/^https?:\/\//.test(e),"Must be a valid URL"),e):"https://api.openai.com",path:e=>e||"/v1/chat/completions",proxy:e=>e||"",topP:e=>{if(!e)return 1;const t=Number(e);return F("OPENAI.topP",t<=1,"Must be less than or equal to 1"),t},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?(F("HUGGINGFACE.model",["CohereForAI/c4ai-command-r-plus","meta-llama/Meta-Llama-3-70B-Instruct","HuggingFaceH4/zephyr-orpo-141b-A35b-v0.1","mistralai/Mixtral-8x7B-Instruct-v0.1","NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO","01-ai/Yi-1.5-34B-Chat","mistralai/Mistral-7B-Instruct-v0.2","microsoft/Phi-3-mini-4k-instruct"].includes(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":(F("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":(F("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),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":(F("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),topP:e=>{if(!e)return 1;F("MISTRAL.topP",/^(1|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 1");const t=Number(e);return F("MISTRAL.topP",t>0,"Must be greater than 0"),F("MISTRAL.topP",t<=1,"Must be less than or equal to 1"),t},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":(F("CODESTRAL.model",["codestral-latest","codestral-2405"].includes(e),"Invalid model type of Codestral"),e),topP:e=>{if(!e)return 1;F("CODESTRAL.topP",/^(1|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 1");const t=Number(e);return F("CODESTRAL.topP",t>0,"Must be greater than 0"),F("CODESTRAL.topP",t<=1,"Must be less than or equal to 1"),t},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?(F("OLLAMA.host",/^https?:\/\//.test(e),"Must be a valid URL"),e):Nt,timeout:e=>{if(!e)return 1e5;F("OLLAMA.timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return F("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":(F("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":(F("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","llama-guard-3-8b","mixtral-8x7b-32768"].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":(F("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),topP:e=>{if(!e)return 1;F("PERPLEXITY.topP",/^(1|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 1");const t=Number(e);return F("PERPLEXITY.topP",t>0,"Must be greater than 0"),F("PERPLEXITY.topP",t<=1,"Must be less than or equal to 1"),t},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},DEEPSEEK:{key:e=>e||"",model:e=>!e||e.length===0?"deepseek-coder":(F("DEEPSEEK.model",["deepseek-coder","deepseek-chat"].includes(e),"Invalid model type of DeepSeek"),e),topP:e=>{if(!e)return 1;F("DEEPSEEK.topP",/^(1|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 1");const t=Number(e);return F("DEEPSEEK.topP",t>0,"Must be greater than 0"),F("DEEPSEEK.topP",t<=1,"Must be less than or equal to 1"),t},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}},je=L.join(Ke.homedir(),".aicommit2"),ba=(e=[])=>{const t={};for(const r of e)if(r.startsWith("--")){const[n,o]=r.slice(2).split("="),[s,i]=n.split(".");s&&i&&s in ue?(t[s]||(t[s]={}),t[s][i]=o):t[n]=o}return t},jt=async()=>{if(!await pn(je))return Object.create(null);const t=await P.readFile(je,"utf8");let r=Lt.parse(t);return Re(r,"OLLAMA")&&Re(r.OLLAMA,"model")&&(r={...r,OLLAMA:{...r.OLLAMA,model:typeof r.OLLAMA.model=="string"?[r.OLLAMA.model]:r.OLLAMA.model}}),Re(r,"exclude")&&(r={...r,exclude:typeof r.exclude=="string"?[r.exclude]:r.exclude}),r},_t=async(e,t=[])=>{const r=await jt(),n=ba(t),o={...e,...n},s={},i=(u,a)=>{const l=o[`${u}.${a}`]??o[u]?.[a],m=r[u]?.[a],c=o[a]??r[a];return l!==void 0?l:m!==void 0?m:c};for(const[u,a]of Object.entries(f)){const l=o[u]??r[u];s[u]=a(l)}for(const[u,a]of Object.entries(ue)){s[u]={};for(const[l,m]of Object.entries(a)){const c=i(u,l);s[u][l]=m(c)}}return s},wa=async e=>{const t=await jt();for(const[r,n]of e){const[o,s]=r.split(".");if(o in ue){t[o]||(t[o]={});const i=ue[o][s];if(!i)throw new E(`Invalid config property: ${r}`);t[o][s]=i(n)}else{const i=f[r];if(!i)throw new E(`Invalid config property: ${r}`);t[r]=i(n)}}await P.writeFile(je,Lt.stringify(t),"utf8")},Aa=async e=>{const t=await jt();for(const[r,n]of e){const[o,s]=r.split(".");if(o in ue){t[o]||(t[o]={});const i=o==="OLLAMA"&&s==="model",u=ue[o][s];if(!u||!i)throw new E(`Invalid config property: ${r}. Only supports OLLAMA.model`);const a=t[o][s]||[];t[o][s]=Ie([...a,u(n)])}else throw new E(`Invalid config property: ${r}. Only supports OLLAMA.model`)}await P.writeFile(je,Lt.stringify(t),"utf8")};class $a extends _{constructor(t){super(t),this.params=t,this.host=Nt,this.model="",this.handleError$=r=>{if(r.response&&r.response.data?.error)return M({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 M({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||Nt,this.ollama=new Zn({host:this.host})}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>O(t)),I(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})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,generate:i,type:u,maxLength:a}=this.params.config,l={...k,locale:s,maxLength:a,type:u,generate:i,systemPrompt:r,systemPromptPath:n},m=H(l);await this.checkIsAvailableOllama();const c=await this.createChatCompletions(m,`Here are diff: ${t}`);return o&&G(`Ollama_${this.model}`,t,m,c),this.parseMessage(c,u,i)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new E(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async checkIsAvailableOllama(){try{return(await new oe({method:"GET",baseURL:`${this.host}`,timeout:this.params.config.timeout}).execute()).data}catch(t){throw t.code==="ECONNREFUSED"?new E(`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:Oe(10,1e3)}})).message.content}}class va extends _{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
|
|
103
|
-
`)[0];const o=this.extractJSONFromError(r.message);n+=`: ${o.error.message}`}return
|
|
104
|
-
`),diff:o}},
|
|
101
|
+
`,Nt=(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 i=e[s];if(i&&Array.isArray(i))for(const u of i)n+=ie(s+"[]")+o+ie(u)+Re;else i&&typeof i=="object"?r.push(s):n+=ie(s)+o+ie(i)+Re}t.section&&n.length&&(n="["+ie(t.section)+"]"+Re+n);for(const s of r){const i=mn(s).join("\\."),u=(t.section?t.section+".":"")+i,{whitespace:a}=t,l=Nt(e[s],{section:u,whitespace:a});n.length&&l.length&&(n+=Re),n+=l}return n},mn=e=>e.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(t=>t.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),pn=e=>{const t=Object.create(null);let r=t,n=null;const o=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,s=e.split(/[\r\n]+/g);for(const u of s){if(!u||u.match(/^\s*[;#]/))continue;const a=u.match(o);if(!a)continue;if(a[1]!==void 0){if(n=_e(a[1]),n==="__proto__"){r=Object.create(null);continue}r=t[n]=t[n]||Object.create(null);continue}const l=_e(a[2]),m=l.length>2&&l.slice(-2)==="[]",c=m?l.slice(0,-2):l;if(c==="__proto__")continue;const D=a[3]?_e(a[4]):!0,p=D==="true"||D==="false"||D==="null"?JSON.parse(D):D;m&&(Lt.call(r,c)?Array.isArray(r[c])||(r[c]=[r[c]]):r[c]=[]),Array.isArray(r[c])?r[c].push(p):r[c]=p}const i=[];for(const u of Object.keys(t)){if(!Lt.call(t,u)||typeof t[u]!="object"||Array.isArray(t[u]))continue;const a=mn(u);r=t;const l=a.pop(),m=l.replace(/\\\./g,".");for(const c of a)c!=="__proto__"&&((!Lt.call(r,c)||typeof r[c]!="object")&&(r[c]=Object.create(null)),r=r[c]);r===t&&m===l||(r[m]=t[u],i.push(u))}for(const u of i)delete t[u];return t},dn=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),ie=e=>typeof e!="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&dn(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),_e=(e,t)=>{if(e=(e||"").trim(),dn(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 i=e.charAt(o);if(r)"\\;#".indexOf(i)!==-1?n+=i:n+="\\"+i,r=!1;else{if(";#".indexOf(i)!==-1)break;i==="\\"?r=!0:n+=i}}return r&&(n+="\\"),n.trim()}return e};var ya={parse:pn,decode:pn,stringify:Nt,encode:Nt,safe:ie,unsafe:_e},Rt=Z(ya);const fn=e=>P.lstat(e).then(()=>!0,()=>!1),ba=["","conventional","gitmoji"],_t="http://localhost:11434",{hasOwnProperty:wa}=Object.prototype,je=(e,t)=>wa.call(e,t),jt=["OPENAI","OLLAMA","HUGGINGFACE","GEMINI","ANTHROPIC","MISTRAL","CODESTRAL","COHERE","GROQ","PERPLEXITY","DEEPSEEK"],F=(e,t,r)=>{if(!t)throw new E(`Invalid config property ${e}: ${r}`)},d={systemPrompt(e){return e||""},systemPromptPath(e){return e||""},timeout(e){if(!e)return 1e4;F("timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return F("timeout",t>=500,"Must be greater than 500ms"),t},temperature(e){if(!e)return .7;F("temperature",/^(2|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 2");const t=Number(e);return F("temperature",t>0,"Must be greater than 0"),F("temperature",t<=2,"Must be less than or equal to 2"),t},maxTokens(e){return e?(F("maxTokens",/^\d+$/.test(e),"Must be an integer"),Number(e)):1024},logging(e){return typeof e=="boolean"?e:e==null?!0:(F("logging",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true")},locale(e){return e?(F("locale",e,"Cannot be empty"),F("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;F("generate",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return F("generate",t>0,"Must be greater than 0"),F("generate",t<=5,"Must be less or equal to 5"),t},type(e){return e?(F("type",ba.includes(e),"Invalid commit type"),e):"conventional"},maxLength(e){if(!e)return 50;F("maxLength",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return F("maxLength",t>=20,"Must be greater than 20 characters"),t},ignoreBody(e){return typeof e=="boolean"?e:e==null?!0:(F("ignoreBody",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true")},exclude:e=>e?(typeof e=="string"?e?.split(","):e).map(r=>r.trim()).filter(r=>!!r&&r.length>0):[]},ue={OPENAI:{key:e=>e||"",model:e=>e||"gpt-4o-mini",url:e=>e?(F("OPENAI.url",/^https?:\/\//.test(e),"Must be a valid URL"),e):"https://api.openai.com",path:e=>e||"/v1/chat/completions",proxy:e=>e||"",topP:e=>{if(!e)return 1;const t=Number(e);return F("OPENAI.topP",t<=1,"Must be less than or equal to 1"),t},systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,timeout:d.timeout,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,ignoreBody:d.ignoreBody},HUGGINGFACE:{cookie:e=>e||"",model:e=>e?(F("HUGGINGFACE.model",["CohereForAI/c4ai-command-r-plus","meta-llama/Meta-Llama-3-70B-Instruct","HuggingFaceH4/zephyr-orpo-141b-A35b-v0.1","mistralai/Mixtral-8x7B-Instruct-v0.1","NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO","01-ai/Yi-1.5-34B-Chat","mistralai/Mistral-7B-Instruct-v0.2","microsoft/Phi-3-mini-4k-instruct"].includes(e),"Invalid model type of HuggingFace chat"),e):"CohereForAI/c4ai-command-r-plus",systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,ignoreBody:d.ignoreBody},GEMINI:{key:e=>e||"",model:e=>!e||e.length===0?"gemini-1.5-pro":(F("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:d.systemPrompt,systemPromptPath:d.systemPromptPath,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,ignoreBody:d.ignoreBody},ANTHROPIC:{key:e=>e||"",model:e=>!e||e.length===0?"claude-3-haiku-20240307":(F("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),systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,ignoreBody:d.ignoreBody},MISTRAL:{key:e=>e||"",model:e=>!e||e.length===0?"mistral-tiny":(F("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),topP:e=>{if(!e)return 1;F("MISTRAL.topP",/^(1|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 1");const t=Number(e);return F("MISTRAL.topP",t>0,"Must be greater than 0"),F("MISTRAL.topP",t<=1,"Must be less than or equal to 1"),t},systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,timeout:d.timeout,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,ignoreBody:d.ignoreBody},CODESTRAL:{key:e=>e||"",model:e=>!e||e.length===0?"codestral-latest":(F("CODESTRAL.model",["codestral-latest","codestral-2405"].includes(e),"Invalid model type of Codestral"),e),topP:e=>{if(!e)return 1;F("CODESTRAL.topP",/^(1|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 1");const t=Number(e);return F("CODESTRAL.topP",t>0,"Must be greater than 0"),F("CODESTRAL.topP",t<=1,"Must be less than or equal to 1"),t},systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,timeout:d.timeout,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,ignoreBody:d.ignoreBody},OLLAMA:{model:e=>e?(typeof e=="string"?e?.split(","):e).map(r=>r.trim()).filter(r=>!!r&&r.length>0):[],host:e=>e?(F("OLLAMA.host",/^https?:\/\//.test(e),"Must be a valid URL"),e):_t,timeout:e=>{if(!e)return 1e5;F("OLLAMA.timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return F("OLLAMA.timeout",t>=500,"Must be greater than 500ms"),t},systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,temperature:d.temperature,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,ignoreBody:d.ignoreBody},COHERE:{key:e=>e||"",model:e=>!e||e.length===0?"command":(F("COHERE.model",["command","command-nightly","command-light","command-light-nightly"].includes(e),"Invalid model type of Cohere"),e),systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,ignoreBody:d.ignoreBody},GROQ:{key:e=>e||"",model:e=>!e||e.length===0?"gemma2-9b-it":(F("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","llama-guard-3-8b","mixtral-8x7b-32768"].includes(e),"Invalid model type of Groq"),e),systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,timeout:d.timeout,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,ignoreBody:d.ignoreBody},PERPLEXITY:{key:e=>e||"",model:e=>!e||e.length===0?"llama-3.1-sonar-small-128k-chat":(F("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),topP:e=>{if(!e)return 1;F("PERPLEXITY.topP",/^(1|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 1");const t=Number(e);return F("PERPLEXITY.topP",t>0,"Must be greater than 0"),F("PERPLEXITY.topP",t<=1,"Must be less than or equal to 1"),t},systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,timeout:d.timeout,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,ignoreBody:d.ignoreBody},DEEPSEEK:{key:e=>e||"",model:e=>!e||e.length===0?"deepseek-coder":(F("DEEPSEEK.model",["deepseek-coder","deepseek-chat"].includes(e),"Invalid model type of DeepSeek"),e),topP:e=>{if(!e)return 1;F("DEEPSEEK.topP",/^(1|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 1");const t=Number(e);return F("DEEPSEEK.topP",t>0,"Must be greater than 0"),F("DEEPSEEK.topP",t<=1,"Must be less than or equal to 1"),t},systemPrompt:d.systemPrompt,systemPromptPath:d.systemPromptPath,timeout:d.timeout,temperature:d.temperature,maxTokens:d.maxTokens,logging:d.logging,locale:d.locale,generate:d.generate,type:d.type,maxLength:d.maxLength,ignoreBody:d.ignoreBody}},Ge=L.join(Ve.homedir(),".aicommit2"),Aa=(e=[])=>{const t={};for(const r of e)if(r.startsWith("--")){const[n,o]=r.slice(2).split("="),[s,i]=n.split(".");s&&i&&s in ue?(t[s]||(t[s]={}),t[s][i]=o):t[n]=o}return t},Gt=async()=>{if(!await fn(Ge))return Object.create(null);const t=await P.readFile(Ge,"utf8");let r=Rt.parse(t);return je(r,"OLLAMA")&&je(r.OLLAMA,"model")&&(r={...r,OLLAMA:{...r.OLLAMA,model:typeof r.OLLAMA.model=="string"?[r.OLLAMA.model]:r.OLLAMA.model}}),je(r,"exclude")&&(r={...r,exclude:typeof r.exclude=="string"?[r.exclude]:r.exclude}),r},Ht=async(e,t=[])=>{const r=await Gt(),n=Aa(t),o={...e,...n},s={},i=(u,a)=>{const l=o[`${u}.${a}`]??o[u]?.[a],m=r[u]?.[a],c=o[a]??r[a];return l!==void 0?l:m!==void 0?m:c};for(const[u,a]of Object.entries(d)){const l=o[u]??r[u];s[u]=a(l)}for(const[u,a]of Object.entries(ue)){s[u]={};for(const[l,m]of Object.entries(a)){const c=i(u,l);s[u][l]=m(c)}}return s},$a=async e=>{const t=await Gt();for(const[r,n]of e){const[o,s]=r.split(".");if(o in ue){t[o]||(t[o]={});const i=ue[o][s];if(!i)throw new E(`Invalid config property: ${r}`);t[o][s]=i(n)}else{const i=d[r];if(!i)throw new E(`Invalid config property: ${r}`);t[r]=i(n)}}await P.writeFile(Ge,Rt.stringify(t),"utf8")},va=async e=>{const t=await Gt();for(const[r,n]of e){const[o,s]=r.split(".");if(o in ue){t[o]||(t[o]={});const i=o==="OLLAMA"&&s==="model",u=ue[o][s];if(!u||!i)throw new E(`Invalid config property: ${r}. Only supports OLLAMA.model`);const a=t[o][s]||[];t[o][s]=ke([...a,u(n)])}else throw new E(`Invalid config property: ${r}. Only supports OLLAMA.model`)}await P.writeFile(Ge,Rt.stringify(t),"utf8")};class Ba extends j{constructor(t){super(t),this.params=t,this.host=_t,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(`[${en(this.model)}]`),this.errorPrefix=C.red.bold(`[${en(this.model)}]`),this.host=this.params.config.host||_t,this.ollama=new eo({host:this.host})}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>M(t)),I(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})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,generate:i,type:u,maxLength:a}=this.params.config,l={...k,locale:s,maxLength:a,type:u,generate:i,systemPrompt:r,systemPromptPath:n},m=H(l);await this.checkIsAvailableOllama();const c=await this.createChatCompletions(m,`Here are diff: ${t}`);return o&&G(`Ollama_${this.model}`,t,m,c),this.parseMessage(c,u,i)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new E(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async checkIsAvailableOllama(){try{return(await new oe({method:"GET",baseURL:`${this.host}`,timeout:this.params.config.timeout}).execute()).data}catch(t){throw t.code==="ECONNREFUSED"?new E(`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:Te(10,1e3)}})).message.content}}class xa extends j{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 R(this.generateMessage()).pipe(N(t=>M(t)),I(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})),T(this.handleError$))}extractJSONFromError(t){const r=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,n=t.match(r);return n?Object.assign({},...n.map(o=>JSON.parse(o))):{error:{message:"Unknown error"}}}async generateMessage(){const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,temperature:o,logging:s,locale:i,generate:u,type:a,maxLength:l,proxy:m,maxTokens:c,timeout:D}=this.params.config,p={...k,locale:i,maxLength:l,type:a,generate:u,systemPrompt:r,systemPromptPath:n},f=H(p),h=await ga(this.params.config.url,this.params.config.path,this.params.config.key,this.params.config.model,t,D,c,o,this.params.config.topP,f,s,m);return ke(h.map(g=>this.parseMessage(g,a,u)))}}class Pa extends j{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 R(this.generateMessage()).pipe(N(t=>M(t)),I(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})),T(this.handleError$))}extractJSONFromError(t){const r=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,n=t.match(r);return n?Object.assign({},...n.map(o=>JSON.parse(o))):{error:{message:"Unknown error"}}}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:n,logging:o,locale:s,generate:i,type:u,maxLength:a}=this.params.config,l={...k,locale:s,maxLength:a,type:u,generate:i,systemPrompt:r,systemPromptPath:n},m=H(l),c=await this.createChatCompletions(m,t);return o&&G("Perplexity",t,m,c),this.parseMessage(c,u,i)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new E(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async createChatCompletions(t,r){const o=(await new oe({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:this.params.config.topP,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 hn{constructor(t,r){this.config=t,this.stagedDiff=r}createAIRequests$(t){return M(t).pipe(Zt(r=>{switch(r){case"OPENAI":return _.create(xa,{config:this.config.OPENAI,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"GEMINI":return _.create(ju,{config:this.config.GEMINI,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"ANTHROPIC":return _.create(ku,{config:this.config.ANTHROPIC,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"HUGGINGFACE":return _.create(Fa,{config:this.config.HUGGINGFACE,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"MISTRAL":return _.create(Ea,{config:this.config.MISTRAL,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"CODESTRAL":return _.create(Nu,{config:this.config.CODESTRAL,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"OLLAMA":return M(this.config.OLLAMA.model).pipe(Zt(o=>_.create(Ba,{config:this.config.OLLAMA,keyName:o,stagedDiff:this.stagedDiff}).generateCommitMessage$()));case"COHERE":return _.create(Ru,{config:this.config.COHERE,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"GROQ":return _.create(Ca,{config:this.config.GROQ,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"PERPLEXITY":return _.create(Pa,{config:this.config.PERPLEXITY,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"DEEPSEEK":return _.create(_u,{config:this.config.DEEPSEEK,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();default:const n=C.red.bold(`[${r}]`);return O({name:n+" Invalid AI type",value:"Invalid AI type",isError:!0,disabled:!0})}}),T(r=>{const n=C.red.bold("[UNKNOWN]");return O({name:n+` ${r.message||""}`,value:"Unknown error",isError:!0,disabled:!0})}))}}const gn=async()=>{const{stdout:e,failed:t}=await ne("git",["rev-parse","--show-toplevel"],{reject:!1});if(t)throw new E("The current directory must be a Git repository!");return e},He=e=>`:(exclude)${e}`,Cn=["package-lock.json","pnpm-lock.yaml","*.lock","*.lockb","*.gif","*.png"].map(He),Fn=async(e,t)=>{const r=["diff","--cached","--diff-algorithm=minimal"],{stdout:n}=await ne("git",[...r,"--name-only",...Cn,...e?e.map(He):[],...t?t.map(He):[]]);if(!n)return null;const{stdout:o}=await ne("git",[...r,...Cn,...e?e.map(He):[]]);return{files:n.split(`
|
|
104
|
+
`),diff:o}},Sa=e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`;class Fe{constructor(){this.title="aicommit2"}printTitle(){console.log(to.textSync(this.title,{font:"Small"}))}displaySpinner(t){return We(t).start()}stopSpinner(t){t.stop(),t.clear()}printStagedFiles(t){console.log(C.bold.green("\u2714 ")+C.bold(`${Sa(t.files)}:`)),console.log(`${t.files.map(r=>` ${r}`).join(`
|
|
105
105
|
`)}
|
|
106
106
|
`)}printAnalyzed(){console.log(`
|
|
107
107
|
${C.bold.green("\u2714")} ${C.bold("Changes analyzed")}`)}printCommitted(){console.log(`
|
|
@@ -109,14 +109,14 @@ ${C.bold.green("\u2714")} ${C.bold("Successfully committed!")}`)}printCopied(){c
|
|
|
109
109
|
${C.bold.green("\u2714")} ${C.bold("Successfully copied! Press 'Ctrl + V' to paste")}`)}printSavedCommitMessage(){console.log(`
|
|
110
110
|
${C.bold.green("\u2714")} ${C.bold("Saved commit message")}`)}printCancelledCommit(){console.log(`
|
|
111
111
|
${C.bold.yellow("\u26A0")} ${C.yellow("Commit cancelled")}`)}printErrorMessage(t){console.log(`
|
|
112
|
-
${C.bold.red("\u2716")} ${C.red(`${t}`)}`)}moveCursorUp(){const t=
|
|
112
|
+
${C.bold.red("\u2716")} ${C.red(`${t}`)}`)}moveCursorUp(){const t=be.createInterface({input:process.stdin,output:process.stdout});be.moveCursor(process.stdout,0,-1),t.close()}moveCursorDown(){const t=be.createInterface({input:process.stdin,output:process.stdout});be.moveCursor(process.stdout,0,1),t.close()}}const Oa={isLoading:!1,startOption:{text:"AI is analyzing your changes"}},Ut="No commit messages were generated";class Ma{constructor(){this.choices$=new Qt([]),this.loader$=new Qt(Oa),this.destroyed$=new Ln(1)}initPrompt(t=!0){return Ke.registerPrompt("reactiveListPrompt",ro),Ke.prompt({type:"reactiveListPrompt",name:"aicommit2Prompt",message:"Pick a commit message to use: ",emptyMessage:`\u26A0 ${Ut}`,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(Lu))}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:Ut,stopOption:{doneFrame:"\u26A0",color:"yellow"}})}stopLoaderOnSuccess(){this.loader$.next({isLoading:!1,message:"Changes analyzed"})}logEmptyCommitMessage(){console.log(`${C.bold.yellow("\u26A0")} ${C.yellow(`${Ut}`)}`)}get currentChoices(){return this.choices$.getValue().map(t=>t)}}const W=new Fe;var Ia=async(e,t,r,n,o,s,i,u,a)=>(async()=>{W.printTitle(),await gn(),n&&await ne("git",["add","--update"]);const l=await Ht({locale:e?.toString(),generate:t?.toString(),commitType:o?.toString(),systemPrompt:u?.toString()},a);if(l.systemPromptPath)try{K.readFileSync(L.resolve(l.systemPromptPath),"utf-8")}catch{throw new E(`Error reading system prompt file: ${l.systemPromptPath}`)}const m=W.displaySpinner("Detecting staged files"),c=await Fn(r,l.exclude);if(m.stop(),!c)throw new E("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");W.printStagedFiles(c);const D=Object.entries(l).filter(([w])=>jt.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 E("Please set at least one API key via the `aicommit2 config set` command");const f=new hn(l,c),h=new Ma,g=h.initPrompt();h.startLoader();const y=f.createAIRequests$(D).subscribe(w=>h.refreshChoices(w),()=>{},()=>h.checkErrorOnChoices()),A=await g;y.unsubscribe(),h.completeSubject(),W.moveCursorUp();const v=A.aicommit2Prompt?.value;if(!v)throw new E("An error occurred! No selected message");if(i&&(As("copy-paste").copy(v),W.printCopied(),process.exit()),s){const w=We("Committing with the generated message").start();await ne("git",["commit","-m",v,...a]),w.stop(),w.clear(),W.printCommitted(),process.exit()}const Y=await Ke.prompt([{type:"confirm",name:"confirmationPrompt",message:"Use selected message?",default:!0}]),{confirmationPrompt:z}=Y;if(z){const w=We("Committing with the generated message").start();await ne("git",["commit","-m",v,...a]),w.stop(),w.clear(),W.printCommitted(),process.exit()}W.printCancelledCommit(),process.exit()})().catch(l=>{W.printErrorMessage(l.message),pe(l),process.exit(1)}),Ta=nt({name:"config",parameters:["<mode>","<key=value...>"]},e=>{(async()=>{const{mode:t,keyValue:r}=e._;if(t==="get"){const n=await Ht({},[]);for(const o of r)if(je(n,o)){if(jt.includes(o)){console.log(o,n[o]);return}console.log(`${o}=${n[o]}`)}return}if(t==="set"){await $a(r.map(n=>n.split("=")));return}if(t==="add"){await va(r.map(n=>n.split("=")));return}throw new E(`Invalid mode: ${t}`)})().catch(t=>{new Fe().printErrorMessage(t.message),pe(t),process.exit(1)})});const En="prepare-commit-msg",yn=`.git/hooks/${En}`,Ue=Zn(new URL("cli.mjs",import.meta.url)),ka=process.argv[1].replace(/\\/g,"/").endsWith(`/${yn}`),bn=process.platform==="win32",wn=`
|
|
113
113
|
#!/usr/bin/env node
|
|
114
|
-
import(${JSON.stringify(
|
|
115
|
-
`.trim();var
|
|
114
|
+
import(${JSON.stringify(Qn(Ue))})
|
|
115
|
+
`.trim();var La=nt({name:"hook",parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await gn(),{installUninstall:r}=e._,n=L.join(t,yn),o=await fn(n);if(r==="install"){if(o){if(await P.realpath(n).catch(()=>{})===Ue){console.warn("The hook is already installed");return}throw new E(`A different ${En} hook seems to be installed. Please remove it before installing aicommit2.`)}await P.mkdir(L.dirname(n),{recursive:!0}),bn?await P.writeFile(n,wn):(await P.symlink(Ue,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(bn){if(await P.readFile(n,"utf8")!==wn){console.warn("Hook is not installed");return}}else if(await P.realpath(n)!==Ue){console.warn("Hook is not installed");return}await P.rm(n),console.log(`${C.green("\u2714")} Hook uninstalled`);return}throw new E(`Invalid mode: ${r}`)})().catch(t=>{console.error(`${C.red("\u2716")} ${t.message}`),pe(t),process.exit(1)})}),Na=nt({name:"log",parameters:["<removeAll>"]},e=>{(async()=>{const{removeAll:t}=e._;if(t==="removeAll"){await no(Xr,{recursive:!0,force:!0}),console.log(`${C.green("\u2714")} All Log files are removed!`);return}throw new E(`Invalid mode: ${t}`)})().catch(t=>{new Fe().printErrorMessage(t.message),pe(t),process.exit(1)})});const[qt,Ra]=process.argv.slice(2);var _a=()=>(async()=>{if(!qt)throw new E('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(Ra)return;const e=await Fn();if(!e)return;const t=new Fe;t.printTitle();const r=await Ht({});if(r.systemPromptPath)try{await P.readFile(L.resolve(r.systemPromptPath),"utf-8")}catch{throw new E(`Error reading system prompt file: ${r.systemPromptPath}`)}const n=Object.entries(r).filter(([D])=>jt.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 E("Please set at least one API key via the `aicommit2 config set` command");const s=new hn(r,e),i=t.displaySpinner("The AI is analyzing your changes");let u;try{u=await Nn(s.createAIRequests$(n).pipe(Rn(D=>!D.isError),I(D=>D.value),_n()))}finally{i.stop(),i.clear(),t.printAnalyzed()}const l=await P.readFile(qt,"utf8")!=="",m=u.length>1;let c="";l&&(c=`# \u{1F916} AI generated commit${m?"s":""}
|
|
116
116
|
`),m?(l&&(c+=`# Select one of the following messages by uncommenting:
|
|
117
117
|
`),c+=`
|
|
118
118
|
${u.map(D=>`# ${D}`).join(`
|
|
119
119
|
`)}`):(l&&(c+=`# Edit the message below and commit:
|
|
120
120
|
`),c+=`
|
|
121
121
|
${u[0]}
|
|
122
|
-
`),await P.appendFile(
|
|
122
|
+
`),await P.appendFile(qt,c),t.printSavedCommitMessage()})().catch(e=>{new Fe().printErrorMessage(e.message),pe(e),process.exit(1)});const An=process.argv.slice(2);ws({name:"aicommit2",version:Yr,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:[Ta,La,Na],help:{description:xu},ignoreArgv:e=>e==="unknown-flag"||e==="argument"},e=>{if(ka){_a();return}Ia(e.flags.locale,e.flags.generate,e.flags.exclude,e.flags.all,e.flags.type,e.flags.confirm,e.flags.clipboard,e.flags.prompt,An)},An);
|