aicommit2 1.8.2 → 1.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -18
- package/dist/cli.mjs +16 -16
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -16,16 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
## Introduction
|
|
18
18
|
|
|
19
|
-
AICommit2 streamlines interactions with various AI, enabling users to request multiple AI simultaneously and select the most suitable message without waiting for all AI responses.
|
|
20
|
-
|
|
21
|
-
## Project Base & Inspiration
|
|
22
|
-
|
|
23
|
-
The core functionalities and architecture of this project are inspired by [AI Commits](https://github.com/Nutlope/aicommits).
|
|
24
|
-
|
|
25
|
-
## Features
|
|
26
|
-
- **Generate Messages**: Quickly generate commit messages based on AI predictions.
|
|
27
|
-
- **Multiple AI Support**: Utilize various AI providers simultaneously.
|
|
28
|
-
- **Local Model**: Integrate with the local Ollama model for offline use.
|
|
19
|
+
AICommit2 streamlines interactions with various AI, enabling users to request multiple AI simultaneously and select the most suitable message without waiting for all AI responses. The core functionalities and architecture of this project are inspired by [AICommits](https://github.com/Nutlope/aicommits).
|
|
29
20
|
|
|
30
21
|
## Supported Providers
|
|
31
22
|
|
|
@@ -101,7 +92,7 @@ aicommit2 config set CLOVAX_COOKIE="<your browser cookie>"
|
|
|
101
92
|
|
|
102
93
|
This will create a `.aicommit2` file in your home directory.
|
|
103
94
|
|
|
104
|
-
4. Run
|
|
95
|
+
4. Run aicommit2 with your staged in git repository:
|
|
105
96
|
```shell
|
|
106
97
|
git add <files...>
|
|
107
98
|
aicommit2
|
|
@@ -109,14 +100,14 @@ aicommit2
|
|
|
109
100
|
|
|
110
101
|
## Using Locally
|
|
111
102
|
|
|
112
|
-
You can also use your model for free with [Ollama](https://ollama.com/).
|
|
103
|
+
You can also use your model for free with [Ollama](https://ollama.com/) and is available to use both Ollama and remote providers simultaneously.
|
|
113
104
|
|
|
114
105
|
1. Install Ollama from [https://ollama.com](https://ollama.com/)
|
|
115
106
|
|
|
116
107
|
2. Start it with your model
|
|
117
108
|
|
|
118
109
|
```shell
|
|
119
|
-
ollama run
|
|
110
|
+
ollama run llama3 # model you want use. ex) llama2, codellama
|
|
120
111
|
```
|
|
121
112
|
|
|
122
113
|
3. Set the model and host
|
|
@@ -129,7 +120,7 @@ aicommit2 config set OLLAMA_TIMEOUT=<timout> # Optional. default is 100000ms (10
|
|
|
129
120
|
|
|
130
121
|
> If you want to use ollama, you must set **OLLAMA_MODEL**.
|
|
131
122
|
|
|
132
|
-
4. Run
|
|
123
|
+
4. Run aicommit2 with your staged in git repository
|
|
133
124
|
```shell
|
|
134
125
|
git add <files...>
|
|
135
126
|
aicommit2
|
|
@@ -537,12 +528,14 @@ The [Huggingface Chat](https://huggingface.co/chat/) Cookie. Please check [how t
|
|
|
537
528
|
Default: `mistralai/Mixtral-8x7B-Instruct-v0.1`
|
|
538
529
|
|
|
539
530
|
Supported:
|
|
531
|
+
- `CohereForAI/c4ai-command-r-plus`
|
|
532
|
+
- `meta-llama/Meta-Llama-3-70B-Instruct`
|
|
533
|
+
- `HuggingFaceH4/zephyr-orpo-141b-A35b-v0.1`
|
|
540
534
|
- `mistralai/Mixtral-8x7B-Instruct-v0.1`
|
|
541
|
-
- `meta-llama/Llama-2-70b-chat-hf`
|
|
542
535
|
- `NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO`
|
|
543
|
-
- `
|
|
536
|
+
- `google/gemma-1.1-7b-it`
|
|
544
537
|
- `mistralai/Mistral-7B-Instruct-v0.2`
|
|
545
|
-
- `
|
|
538
|
+
- `microsoft/Phi-3-mini-4k-instruct`
|
|
546
539
|
|
|
547
540
|
> The models mentioned above are subject to change.
|
|
548
541
|
|
|
@@ -574,7 +567,7 @@ Request timeout for the Ollama. Default OLLAMA_TIMEOUT is **100 seconds** becaus
|
|
|
574
567
|
|
|
575
568
|
Default: `false`
|
|
576
569
|
|
|
577
|
-
Determines whether the application will make stream requests to Ollama. This feature is experimental and may not be fully stable.
|
|
570
|
+
Determines whether the application will make stream requests to Ollama. **Allow this option only when using Ollama alone.** This feature is experimental and may not be fully stable.
|
|
578
571
|
|
|
579
572
|
## Upgrading
|
|
580
573
|
|
package/dist/cli.mjs
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import Le from"tty";import{createRequire as hn}from"module";import{Buffer as gn}from"node:buffer";import W from"node:path";import Nt from"node:child_process";import j from"node:process";import Cn from"child_process";import X from"path";import Re from"fs";import Fn from"node:url";import En,{constants as Tt}from"node:os";import Lt from"assert";import Rt from"events";import yn from"buffer";import ke from"stream";import kt from"util";import je from"inquirer";import Ge from"ora";import g from"chalk";import{of as G,from as S,tap as jt,map as M,concatMap as T,catchError as L,scan as Gt,switchMap as wn,mergeMap as bn,BehaviorSubject as Ut,ReplaySubject as An,lastValueFrom as vn,filter as $n,toArray as Bn}from"rxjs";import ue from"@anthropic-ai/sdk";import{fromPromise as U}from"rxjs/internal/observable/innerFrom";import xn from"http";import On from"https";import"@dqbd/tiktoken";import In from"net";import Sn from"tls";import Mn,{fileURLToPath as Pn,pathToFileURL as _n}from"url";import Ht from"os";import{FormData as Nn,Blob as Tn}from"formdata-node";import B from"fs/promises";import Ln from"axios";import{GoogleGenerativeAI as Rn}from"@google/generative-ai";import{Ollama as kn}from"ollama";import Ce from"readline";import jn from"figlet";import Gn from"inquirer-reactive-list-prompt";const Un="known-flag",Hn="unknown-flag",Kn="argument",{stringify:ie}=JSON,qn=/\B([A-Z])/g,zn=e=>e.replace(qn,"-$1").toLowerCase(),{hasOwnProperty:Yn}=Object.prototype,ae=(e,t)=>Yn.call(e,t),Vn=e=>Array.isArray(e),Kt=e=>typeof e=="function"?[e,!1]:Vn(e)?[e[0],!0]:Kt(e.type),Wn=(e,t)=>e===Boolean?t!=="false":t,Xn=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),Jn=/[\s.:=]/,Zn=e=>{const t=`Flag name ${ie(e)}`;if(e.length===0)throw new Error(`${t} cannot be empty`);if(e.length===1)throw new Error(`${t} must be longer than a character`);const r=e.match(Jn);if(r)throw new Error(`${t} cannot contain ${ie(r?.[0])}`)},Qn=e=>{const t={},r=(n,s)=>{if(ae(t,n))throw new Error(`Duplicate flags named ${ie(n)}`);t[n]=s};for(const n in e){if(!ae(e,n))continue;Zn(n);const s=e[n],o=[[],...Kt(s),s];r(n,o);const u=zn(n);if(n!==u&&r(u,o),"alias"in s&&typeof s.alias=="string"){const{alias:a}=s,i=`Flag alias ${ie(a)} for flag ${ie(n)}`;if(a.length===0)throw new Error(`${i} cannot be empty`);if(a.length>1)throw new Error(`${i} must be a single character`);r(a,o)}}return t},eo=(e,t)=>{const r={};for(const n in e){if(!ae(e,n))continue;const[s,,o,u]=t[n];if(s.length===0&&"default"in u){let{default:a}=u;typeof a=="function"&&(a=a()),r[n]=a}else r[n]=o?s:s.pop()}return r},Fe="--",to=/[.:=]/,ro=/^-{1,2}\w/,no=e=>{if(!ro.test(e))return;const t=!e.startsWith(Fe);let r=e.slice(t?1:2),n;const s=r.match(to);if(s){const{index:o}=s;n=r.slice(o+1),r=r.slice(0,o)}return[r,n,t]},oo=(e,{onFlag:t,onArgument:r})=>{let n;const s=(o,u)=>{if(typeof n!="function")return!0;n(o,u),n=void 0};for(let o=0;o<e.length;o+=1){const u=e[o];if(u===Fe){s();const i=e.slice(o+1);r?.(i,[o],!0);break}const a=no(u);if(a){if(s(),!t)continue;const[i,l,f]=a;if(f)for(let D=0;D<i.length;D+=1){s();const c=D===i.length-1;n=t(i[D],c?l:void 0,[o,D+1,c])}else n=t(i,l,[o])}else s(u,[o])&&r?.([u],[o])}s()},so=(e,t)=>{for(const[r,n,s]of t.reverse()){if(n){const o=e[r];let u=o.slice(0,n);if(s||(u+=o.slice(n+1)),u!=="-"){e[r]=u;continue}}e.splice(r,1)}},uo=(e,t=process.argv.slice(2),{ignore:r}={})=>{const n=[],s=Qn(e),o={},u=[];return u[Fe]=[],oo(t,{onFlag(a,i,l){const f=ae(s,a);if(!r?.(f?Un:Hn,a,i)){if(f){const[D,c]=s[a],p=Wn(c,i),d=(m,h)=>{n.push(l),h&&n.push(h),D.push(Xn(c,m||""))};return p===void 0?d:d(p)}ae(o,a)||(o[a]=[]),o[a].push(i===void 0?!0:i),n.push(l)}},onArgument(a,i,l){r?.(Kn,t[i[0]])||(u.push(...a),l?(u[Fe]=a,t.splice(i[0])):n.push(i))}}),so(t,n),{flags:eo(e,s),unknownFlags:o,_:u}};var io=Object.create,Ee=Object.defineProperty,ao=Object.defineProperties,Do=Object.getOwnPropertyDescriptor,co=Object.getOwnPropertyDescriptors,lo=Object.getOwnPropertyNames,qt=Object.getOwnPropertySymbols,fo=Object.getPrototypeOf,zt=Object.prototype.hasOwnProperty,po=Object.prototype.propertyIsEnumerable,Yt=(e,t,r)=>t in e?Ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ye=(e,t)=>{for(var r in t||(t={}))zt.call(t,r)&&Yt(e,r,t[r]);if(qt)for(var r of qt(t))po.call(t,r)&&Yt(e,r,t[r]);return e},Ue=(e,t)=>ao(e,co(t)),mo=e=>Ee(e,"__esModule",{value:!0}),ho=(e,t)=>()=>(e&&(t=e(e=0)),t),go=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Co=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of lo(t))!zt.call(e,s)&&(r||s!=="default")&&Ee(e,s,{get:()=>t[s],enumerable:!(n=Do(t,s))||n.enumerable});return e},Fo=(e,t)=>Co(mo(Ee(e!=null?io(fo(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),$=ho(()=>{}),Eo=go((e,t)=>{$(),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}});$(),$(),$();var yo=e=>{var t,r,n;let s=(t=process.stdout.columns)!=null?t:Number.POSITIVE_INFINITY;return typeof e=="function"&&(e=e(s)),e||(e={}),Array.isArray(e)?{columns:e,stdoutColumns:s}:{columns:(r=e.columns)!=null?r:[],stdoutColumns:(n=e.stdoutColumns)!=null?n:s}};$(),$(),$(),$(),$();function wo({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 Vt(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(wo(),"")}$();function bo(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 Ao=Fo(Eo(),1);function K(e){if(typeof e!="string"||e.length===0||(e=Vt(e),e.length===0))return 0;e=e.replace((0,Ao.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+=bo(n)?2:1)}return t}var Wt=e=>Math.max(...e.split(`
|
|
3
|
-
`).map(K)),vo=e=>{let t=[];for(let r of e){let{length:n}=r,s=n-t.length;for(let o=0;o<s;o+=1)t.push(0);for(let o=0;o<n;o+=1){let u=Wt(r[o]);u>t[o]&&(t[o]=u)}}return t};$();var Xt=/^\d+%$/,Jt={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},$o=(e,t)=>{var r;let n=[];for(let s=0;s<e.length;s+=1){let o=(r=t[s])!=null?r:"auto";if(typeof o=="number"||o==="auto"||o==="content-width"||typeof o=="string"&&Xt.test(o)){n.push(
|
|
2
|
+
import Le from"tty";import{createRequire as hn}from"module";import{Buffer as gn}from"node:buffer";import W from"node:path";import Nt from"node:child_process";import j from"node:process";import Cn from"child_process";import X from"path";import Re from"fs";import Fn from"node:url";import En,{constants as Tt}from"node:os";import Lt from"assert";import Rt from"events";import yn from"buffer";import ke from"stream";import kt from"util";import je from"inquirer";import Ge from"ora";import g from"chalk";import{of as G,from as S,tap as jt,map as M,concatMap as T,catchError as L,scan as Gt,switchMap as wn,mergeMap as bn,BehaviorSubject as Ht,ReplaySubject as An,lastValueFrom as vn,filter as $n,toArray as Bn}from"rxjs";import ue from"@anthropic-ai/sdk";import{fromPromise as H}from"rxjs/internal/observable/innerFrom";import xn from"http";import On from"https";import"@dqbd/tiktoken";import In from"net";import Sn from"tls";import Mn,{fileURLToPath as Pn,pathToFileURL as _n}from"url";import Ut from"os";import{FormData as Nn,Blob as Tn}from"formdata-node";import B from"fs/promises";import Ln from"axios";import{GoogleGenerativeAI as Rn}from"@google/generative-ai";import{Ollama as kn}from"ollama";import Ce from"readline";import jn from"figlet";import Gn from"inquirer-reactive-list-prompt";const Hn="known-flag",Un="unknown-flag",Kn="argument",{stringify:ie}=JSON,qn=/\B([A-Z])/g,zn=e=>e.replace(qn,"-$1").toLowerCase(),{hasOwnProperty:Yn}=Object.prototype,ae=(e,t)=>Yn.call(e,t),Vn=e=>Array.isArray(e),Kt=e=>typeof e=="function"?[e,!1]:Vn(e)?[e[0],!0]:Kt(e.type),Wn=(e,t)=>e===Boolean?t!=="false":t,Xn=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),Jn=/[\s.:=]/,Zn=e=>{const t=`Flag name ${ie(e)}`;if(e.length===0)throw new Error(`${t} cannot be empty`);if(e.length===1)throw new Error(`${t} must be longer than a character`);const r=e.match(Jn);if(r)throw new Error(`${t} cannot contain ${ie(r?.[0])}`)},Qn=e=>{const t={},r=(n,s)=>{if(ae(t,n))throw new Error(`Duplicate flags named ${ie(n)}`);t[n]=s};for(const n in e){if(!ae(e,n))continue;Zn(n);const s=e[n],o=[[],...Kt(s),s];r(n,o);const u=zn(n);if(n!==u&&r(u,o),"alias"in s&&typeof s.alias=="string"){const{alias:a}=s,i=`Flag alias ${ie(a)} for flag ${ie(n)}`;if(a.length===0)throw new Error(`${i} cannot be empty`);if(a.length>1)throw new Error(`${i} must be a single character`);r(a,o)}}return t},eo=(e,t)=>{const r={};for(const n in e){if(!ae(e,n))continue;const[s,,o,u]=t[n];if(s.length===0&&"default"in u){let{default:a}=u;typeof a=="function"&&(a=a()),r[n]=a}else r[n]=o?s:s.pop()}return r},Fe="--",to=/[.:=]/,ro=/^-{1,2}\w/,no=e=>{if(!ro.test(e))return;const t=!e.startsWith(Fe);let r=e.slice(t?1:2),n;const s=r.match(to);if(s){const{index:o}=s;n=r.slice(o+1),r=r.slice(0,o)}return[r,n,t]},oo=(e,{onFlag:t,onArgument:r})=>{let n;const s=(o,u)=>{if(typeof n!="function")return!0;n(o,u),n=void 0};for(let o=0;o<e.length;o+=1){const u=e[o];if(u===Fe){s();const i=e.slice(o+1);r?.(i,[o],!0);break}const a=no(u);if(a){if(s(),!t)continue;const[i,l,f]=a;if(f)for(let D=0;D<i.length;D+=1){s();const c=D===i.length-1;n=t(i[D],c?l:void 0,[o,D+1,c])}else n=t(i,l,[o])}else s(u,[o])&&r?.([u],[o])}s()},so=(e,t)=>{for(const[r,n,s]of t.reverse()){if(n){const o=e[r];let u=o.slice(0,n);if(s||(u+=o.slice(n+1)),u!=="-"){e[r]=u;continue}}e.splice(r,1)}},uo=(e,t=process.argv.slice(2),{ignore:r}={})=>{const n=[],s=Qn(e),o={},u=[];return u[Fe]=[],oo(t,{onFlag(a,i,l){const f=ae(s,a);if(!r?.(f?Hn:Un,a,i)){if(f){const[D,c]=s[a],p=Wn(c,i),d=(m,h)=>{n.push(l),h&&n.push(h),D.push(Xn(c,m||""))};return p===void 0?d:d(p)}ae(o,a)||(o[a]=[]),o[a].push(i===void 0?!0:i),n.push(l)}},onArgument(a,i,l){r?.(Kn,t[i[0]])||(u.push(...a),l?(u[Fe]=a,t.splice(i[0])):n.push(i))}}),so(t,n),{flags:eo(e,s),unknownFlags:o,_:u}};var io=Object.create,Ee=Object.defineProperty,ao=Object.defineProperties,Do=Object.getOwnPropertyDescriptor,co=Object.getOwnPropertyDescriptors,lo=Object.getOwnPropertyNames,qt=Object.getOwnPropertySymbols,fo=Object.getPrototypeOf,zt=Object.prototype.hasOwnProperty,po=Object.prototype.propertyIsEnumerable,Yt=(e,t,r)=>t in e?Ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ye=(e,t)=>{for(var r in t||(t={}))zt.call(t,r)&&Yt(e,r,t[r]);if(qt)for(var r of qt(t))po.call(t,r)&&Yt(e,r,t[r]);return e},He=(e,t)=>ao(e,co(t)),mo=e=>Ee(e,"__esModule",{value:!0}),ho=(e,t)=>()=>(e&&(t=e(e=0)),t),go=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Co=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of lo(t))!zt.call(e,s)&&(r||s!=="default")&&Ee(e,s,{get:()=>t[s],enumerable:!(n=Do(t,s))||n.enumerable});return e},Fo=(e,t)=>Co(mo(Ee(e!=null?io(fo(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),$=ho(()=>{}),Eo=go((e,t)=>{$(),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}});$(),$(),$();var yo=e=>{var t,r,n;let s=(t=process.stdout.columns)!=null?t:Number.POSITIVE_INFINITY;return typeof e=="function"&&(e=e(s)),e||(e={}),Array.isArray(e)?{columns:e,stdoutColumns:s}:{columns:(r=e.columns)!=null?r:[],stdoutColumns:(n=e.stdoutColumns)!=null?n:s}};$(),$(),$(),$(),$();function wo({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 Vt(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(wo(),"")}$();function bo(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 Ao=Fo(Eo(),1);function K(e){if(typeof e!="string"||e.length===0||(e=Vt(e),e.length===0))return 0;e=e.replace((0,Ao.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+=bo(n)?2:1)}return t}var Wt=e=>Math.max(...e.split(`
|
|
3
|
+
`).map(K)),vo=e=>{let t=[];for(let r of e){let{length:n}=r,s=n-t.length;for(let o=0;o<s;o+=1)t.push(0);for(let o=0;o<n;o+=1){let u=Wt(r[o]);u>t[o]&&(t[o]=u)}}return t};$();var Xt=/^\d+%$/,Jt={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},$o=(e,t)=>{var r;let n=[];for(let s=0;s<e.length;s+=1){let o=(r=t[s])!=null?r:"auto";if(typeof o=="number"||o==="auto"||o==="content-width"||typeof o=="string"&&Xt.test(o)){n.push(He(ye({},Jt),{width:o,contentWidth:e[s]}));continue}if(o&&typeof o=="object"){let u=He(ye(ye({},Jt),o),{contentWidth:e[s]});u.horizontalPadding=u.paddingLeft+u.paddingRight,n.push(u);continue}throw new Error(`Invalid column width: ${JSON.stringify(o)}`)}return n};function Bo(e,t){for(let r of e){let{width:n}=r;if(n==="content-width"&&(r.width=r.contentWidth),n==="auto"){let i=Math.min(20,r.contentWidth);r.width=i,r.autoOverflow=r.contentWidth-i}if(typeof n=="string"&&Xt.test(n)){let i=Number.parseFloat(n.slice(0,-1))/100;r.width=Math.floor(t*i)-(r.paddingLeft+r.paddingRight)}let{horizontalPadding:s}=r,o=1,u=o+s;if(u>=t){let i=u-t,l=Math.ceil(r.paddingLeft/s*i),f=i-l;r.paddingLeft-=l,r.paddingRight-=f,r.horizontalPadding=r.paddingLeft+r.paddingRight}r.paddingLeftString=r.paddingLeft?" ".repeat(r.paddingLeft):"",r.paddingRightString=r.paddingRight?" ".repeat(r.paddingRight):"";let a=t-r.horizontalPadding;r.width=Math.max(Math.min(r.width,a),o)}}var Zt=()=>Object.assign([],{columns:0});function xo(e,t){let r=[Zt()],[n]=r;for(let s of e){let o=s.width+s.horizontalPadding;n.columns+o>t&&(n=Zt(),r.push(n)),n.push(s),n.columns+=o}for(let s of r){let o=s.reduce((c,p)=>c+p.width+p.horizontalPadding,0),u=t-o;if(u===0)continue;let a=s.filter(c=>"autoOverflow"in c),i=a.filter(c=>c.autoOverflow>0),l=i.reduce((c,p)=>c+p.autoOverflow,0),f=Math.min(l,u);for(let c of i){let p=Math.floor(c.autoOverflow/l*f);c.width+=p,u-=p}let D=Math.floor(u/a.length);for(let c=0;c<a.length;c+=1){let p=a[c];c===a.length-1?p.width+=u:p.width+=D,u-=D}}return r}function Oo(e,t,r){let n=$o(r,t);return Bo(n,e),xo(n,e)}$(),$(),$();var Ue=10,Qt=(e=0)=>t=>`\x1B[${t+e}m`,er=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,tr=(e=0)=>(t,r,n)=>`\x1B[${38+e};2;${t};${r};${n}m`;function Io(){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[s,o]of Object.entries(n))t[s]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},n[s]=t[s],e.set(o[0],o[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=Qt(),t.color.ansi256=er(),t.color.ansi16m=tr(),t.bgColor.ansi=Qt(Ue),t.bgColor.ansi256=er(Ue),t.bgColor.ansi16m=tr(Ue),Object.defineProperties(t,{rgbToAnsi256:{value:(r,n,s)=>r===n&&n===s?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(s/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:s}=n.groups;s.length===3&&(s=s.split("").map(u=>u+u).join(""));let o=Number.parseInt(s,16);return[o>>16&255,o>>8&255,o&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,s,o;if(r>=232)n=((r-232)*10+8)/255,s=n,o=n;else{r-=16;let i=r%36;n=Math.floor(r/36)/5,s=Math.floor(i/6)/5,o=i%6/5}let u=Math.max(n,s,o)*2;if(u===0)return 30;let a=30+(Math.round(o)<<2|Math.round(s)<<1|Math.round(n));return u===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(r,n,s)=>t.ansi256ToAnsi(t.rgbToAnsi256(r,n,s)),enumerable:!1},hexToAnsi:{value:r=>t.ansi256ToAnsi(t.hexToAnsi256(r)),enumerable:!1}}),t}var So=Io(),Mo=So,we=new Set(["\x1B","\x9B"]),Po=39,Ke="\x07",rr="[",_o="]",nr="m",qe=`${_o}8;;`,or=e=>`${we.values().next().value}${rr}${e}${nr}`,sr=e=>`${we.values().next().value}${qe}${e}${Ke}`,No=e=>e.split(" ").map(t=>K(t)),ze=(e,t,r)=>{let n=[...t],s=!1,o=!1,u=K(Vt(e[e.length-1]));for(let[a,i]of n.entries()){let l=K(i);if(u+l<=r?e[e.length-1]+=i:(e.push(i),u=0),we.has(i)&&(s=!0,o=n.slice(a+1).join("").startsWith(qe)),s){o?i===Ke&&(s=!1,o=!1):i===nr&&(s=!1);continue}u+=l,u===r&&a<n.length-1&&(e.push(""),u=0)}!u&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},To=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(K(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},Lo=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",s,o,u=No(e),a=[""];for(let[l,f]of e.split(" ").entries()){r.trim!==!1&&(a[a.length-1]=a[a.length-1].trimStart());let D=K(a[a.length-1]);if(l!==0&&(D>=t&&(r.wordWrap===!1||r.trim===!1)&&(a.push(""),D=0),(D>0||r.trim===!1)&&(a[a.length-1]+=" ",D++)),r.hard&&u[l]>t){let c=t-D,p=1+Math.floor((u[l]-c-1)/t);Math.floor((u[l]-1)/t)<p&&a.push(""),ze(a,f,t);continue}if(D+u[l]>t&&D>0&&u[l]>0){if(r.wordWrap===!1&&D<t){ze(a,f,t);continue}a.push("")}if(D+u[l]>t&&r.wordWrap===!1){ze(a,f,t);continue}a[a.length-1]+=f}r.trim!==!1&&(a=a.map(l=>To(l)));let i=[...a.join(`
|
|
4
4
|
`)];for(let[l,f]of i.entries()){if(n+=f,we.has(f)){let{groups:c}=new RegExp(`(?:\\${rr}(?<code>\\d+)m|\\${qe}(?<uri>.*)${Ke})`).exec(i.slice(l).join(""))||{groups:{}};if(c.code!==void 0){let p=Number.parseFloat(c.code);s=p===Po?void 0:p}else c.uri!==void 0&&(o=c.uri.length===0?void 0:c.uri)}let D=Mo.codes.get(Number(s));i[l+1]===`
|
|
5
5
|
`?(o&&(n+=sr("")),s&&D&&(n+=or(D))):f===`
|
|
6
6
|
`&&(s&&D&&(n+=or(s)),o&&(n+=sr(o)))}return n};function Ro(e,t,r){return String(e).normalize().replace(/\r\n/g,`
|
|
7
7
|
`).split(`
|
|
8
8
|
`).map(n=>Lo(n,t,r)).join(`
|
|
9
9
|
`)}var ur=e=>Array.from({length:e}).fill("");function ko(e,t){let r=[],n=0;for(let s of e){let o=0,u=s.map(i=>{var l;let f=(l=t[n])!=null?l:"";n+=1,i.preprocess&&(f=i.preprocess(f)),Wt(f)>i.width&&(f=Ro(f,i.width,{hard:!0}));let D=f.split(`
|
|
10
|
-
`);if(i.postprocess){let{postprocess:c}=i;D=D.map((p,d)=>c.call(i,p,d))}return i.paddingTop&&D.unshift(...ur(i.paddingTop)),i.paddingBottom&&D.push(...ur(i.paddingBottom)),D.length>o&&(o=D.length),
|
|
10
|
+
`);if(i.postprocess){let{postprocess:c}=i;D=D.map((p,d)=>c.call(i,p,d))}return i.paddingTop&&D.unshift(...ur(i.paddingTop)),i.paddingBottom&&D.push(...ur(i.paddingBottom)),D.length>o&&(o=D.length),He(ye({},i),{lines:D})}),a=[];for(let i=0;i<o;i+=1){let l=u.map(f=>{var D;let c=(D=f.lines[i])!=null?D:"",p=Number.isFinite(f.width)?" ".repeat(f.width-K(c)):"",d=f.paddingLeftString;return f.align==="right"&&(d+=p),d+=c,f.align==="left"&&(d+=p),d+f.paddingRightString}).join("");a.push(l)}r.push(a.join(`
|
|
11
11
|
`))}return r.join(`
|
|
12
12
|
`)}function jo(e,t){if(!e||e.length===0)return"";let r=vo(e),n=r.length;if(n===0)return"";let{stdoutColumns:s,columns:o}=yo(t);if(o.length>n)throw new Error(`${o.length} columns defined, but only ${n} columns found`);let u=Oo(s,o,r);return e.map(a=>ko(u,a)).join(`
|
|
13
|
-
`)}$();var Go=["<",">","=",">=","<="];function
|
|
13
|
+
`)}$();var Go=["<",">","=",">=","<="];function Ho(e){if(!Go.includes(e))throw new TypeError(`Invalid breakpoint operator: ${e}`)}function Uo(e){let t=Object.keys(e).map(r=>{let[n,s]=r.split(" ");Ho(n);let o=Number.parseInt(s,10);if(Number.isNaN(o))throw new TypeError(`Invalid breakpoint value: ${s}`);let u=e[r];return{operator:n,breakpoint:o,value:u}}).sort((r,n)=>n.breakpoint-r.breakpoint);return r=>{var n;return(n=t.find(({operator:s,breakpoint:o})=>s==="="&&r===o||s===">"&&r>o||s==="<"&&r<o||s===">="&&r>=o||s==="<="&&r<=o))==null?void 0:n.value}}const Ko=e=>e.replace(/[\W_]([a-z\d])?/gi,(t,r)=>r?r.toUpperCase():""),qo=e=>e.replace(/\B([A-Z])/g,"-$1").toLowerCase(),zo={"> 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 Yo(e){let t=!1;return{type:"table",data:{tableData:Object.keys(e).sort((r,n)=>r.localeCompare(n)).map(r=>{const n=e[r],s="alias"in n;return s&&(t=!0),{name:r,flag:n,flagFormatted:`--${qo(r)}`,aliasesEnabled:t,aliasFormatted:s?`-${n.alias}`:void 0}}).map(r=>(r.aliasesEnabled=t,[{type:"flagName",data:r},{type:"flagDescription",data:r}])),tableBreakpoints:zo}}}const ir=e=>!e||(e.version??(e.help?e.help.version:void 0)),ar=e=>{const t="parent"in e&&e.parent?.name;return(t?`${t} `:"")+e.name};function Vo(e){const t=[];e.name&&t.push(ar(e));const r=ir(e)??("parent"in e&&ir(e.parent));if(r&&t.push(`v${r}`),t.length!==0)return{id:"name",type:"text",data:`${t.join(" ")}
|
|
14
14
|
`}}function Wo(e){const{help:t}=e;if(!(!t||!t.description))return{id:"description",type:"text",data:`${t.description}
|
|
15
15
|
`}}function Xo(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
16
|
`):t.usage}}:void 0;if(e.name){const r=[],n=[ar(e)];if(e.flags&&Object.keys(e.flags).length>0&&n.push("[flags...]"),e.parameters&&e.parameters.length>0){const{parameters:s}=e,o=s.indexOf("--"),u=o>-1&&s.slice(o+1).some(a=>a.startsWith("<"));n.push(s.map(a=>a!=="--"?a:u?"--":"[--]").join(" "))}if(n.length>1&&r.push(n.join(" ")),"commands"in e&&e.commands?.length&&r.push(`${e.name} <command>`),r.length>0)return{id:"usage",type:"section",data:{title:"Usage:",body:r.join(`
|
|
17
17
|
`)}}}}function Jo(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 Zo(e){if(!(!e.flags||Object.keys(e.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:Yo(e.flags),indentBody:0}}}function Qo(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
18
|
`)),r)return{id:"examples",type:"section",data:{title:"Examples:",body:r}}}function es(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 ts=e=>[Vo,Wo,Xo,Jo,Zo,Qo,es].map(t=>t(e)).filter(Boolean),rs=Le.WriteStream.prototype.hasColors();class ns{text(t){return t}bold(t){return rs?`\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 jo(t.map(s=>s.map(o=>this.render(o))),n?
|
|
20
|
+
`}table({tableData:t,tableOptions:r,tableBreakpoints:n}){return jo(t.map(s=>s.map(o=>this.render(o))),n?Uo(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:s,aliasFormatted:o}=t;let u="";if(o?u+=`${o}, `:s&&(u+=" "),u+=n,"placeholder"in r&&typeof r.placeholder=="string")u+=`${this.flagOperator(t)}${r.placeholder}`;else{const a=this.flagParameter("type"in r?r.type:r);a&&(u+=`${this.flagOperator(t)}${a}`)}return u}flagDefault(t){return JSON.stringify(t)}flagDescription({flag:t}){let r="description"in t?t.description??"":"";if("default"in t){let{default:n}=t;typeof n=="function"&&(n=n()),n&&(r+=` (default: ${this.flagDefault(n)})`)}return r}render(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(r=>this.render(r)).join(`
|
|
21
21
|
`);if("type"in t&&this[t.type]){const r=this[t.type];if(typeof r=="function")return r.call(this,t.data)}throw new Error(`Invalid node type: ${JSON.stringify(t)}`)}}const Ye=/^[\w.-]+$/,{stringify:P}=JSON,os=/[|\\{}()[\]^$+*?.]/;function Ve(e){const t=[];let r,n;for(const s of e){if(n)throw new Error(`Invalid parameter: Spread parameter ${P(n)} must be last`);const o=s[0],u=s[s.length-1];let a;if(o==="<"&&u===">"&&(a=!0,r))throw new Error(`Invalid parameter: Required parameter ${P(s)} cannot come after optional parameter ${P(r)}`);if(o==="["&&u==="]"&&(a=!1,r=s),a===void 0)throw new Error(`Invalid parameter: ${P(s)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let i=s.slice(1,-1);const l=i.slice(-3)==="...";l&&(n=s,i=i.slice(0,-3));const f=i.match(os);if(f)throw new Error(`Invalid parameter: ${P(s)}. Invalid character found ${P(f[0])}`);t.push({name:i,required:a,spread:l})}return t}function We(e,t,r,n){for(let s=0;s<t.length;s+=1){const{name:o,required:u,spread:a}=t[s],i=Ko(o);if(i in e)throw new Error(`Invalid parameter: ${P(o)} is used more than once.`);const l=a?r.slice(s):r[s];if(a&&(s=t.length),u&&(!l||a&&l.length===0))return console.error(`Error: Missing required parameter ${P(o)}
|
|
22
|
-
`),n(),process.exit(1);e[i]=l}}function ss(e){return e===void 0||e!==!1}function Dr(e,t,r,n){const s={...t.flags},o=t.version;o&&(s.version={type:Boolean,description:"Show version"});const{help:u}=t,a=ss(u);a&&!("help"in s)&&(s.help={type:Boolean,alias:"h",description:"Show help"});const i=uo(s,n,{ignore:t.ignoreArgv}),l=()=>{console.log(t.version)};if(o&&i.flags.version===!0)return l(),process.exit(0);const f=new ns,D=a&&u?.render?u.render:d=>f.render(d),c=d=>{const m=ts({...t,...d?{help:d}:{},flags:s});console.log(D(m,f))};if(a&&i.flags.help===!0)return c(),process.exit(0);if(t.parameters){let{parameters:d}=t,m=i._;const h=d.indexOf("--"),C=d.slice(h+1),w=Object.create(null);if(h>-1&&C.length>0){d=d.slice(0,h);const I=i._["--"];m=m.slice(0,-I.length||void 0),We(w,Ve(d),m,c),We(w,Ve(C),I,c)}else We(w,Ve(d),m,c);Object.assign(i._,w)}const p={...i,showVersion:l,showHelp:c};return typeof r=="function"&&r(p),{command:e,...p}}function us(e,t){const r=new Map;for(const n of t){const s=[n.options.name],{alias:o}=n.options;o&&(Array.isArray(o)?s.push(...o):s.push(o));for(const u of s){if(r.has(u))throw new Error(`Duplicate command name found: ${P(u)}`);r.set(u,n)}}return r.get(e)}function is(e,t,r=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!Ye.test(e.name)))throw new Error(`Invalid script name: ${P(e.name)}`);const n=r[0];if(e.commands&&Ye.test(n)){const s=us(n,e.commands);if(s)return Dr(s.options.name,{...s.options,parent:e},s.callback,r.slice(1))}return Dr(void 0,e,t,r)}function cr(e,t){if(!e)throw new Error("Command options are required");const{name:r}=e;if(e.name===void 0)throw new Error("Command name is required");if(!Ye.test(r))throw new Error(`Invalid command name ${JSON.stringify(r)}. Command names must be one word.`);return{options:e,callback:t}}var as=hn(import.meta.url),A=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function J(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Z={exports:{}},Xe,lr;function Ds(){if(lr)return Xe;lr=1,Xe=n,n.sync=s;var e=Re;function t(o,u){var a=u.pathExt!==void 0?u.pathExt:process.env.PATHEXT;if(!a||(a=a.split(";"),a.indexOf("")!==-1))return!0;for(var i=0;i<a.length;i++){var l=a[i].toLowerCase();if(l&&o.substr(-l.length).toLowerCase()===l)return!0}return!1}function r(o,u,a){return!o.isSymbolicLink()&&!o.isFile()?!1:t(u,a)}function n(o,u,a){e.stat(o,function(i,l){a(i,i?!1:r(l,o,u))})}function s(o,u){return r(e.statSync(o),o,u)}return Xe}var Je,fr;function cs(){if(fr)return Je;fr=1,Je=t,t.sync=r;var e=Re;function t(o,u,a){e.stat(o,function(i,l){a(i,i?!1:n(l,u))})}function r(o,u){return n(e.statSync(o),u)}function n(o,u){return o.isFile()&&s(o,u)}function s(o,u){var a=o.mode,i=o.uid,l=o.gid,f=u.uid!==void 0?u.uid:process.getuid&&process.getuid(),D=u.gid!==void 0?u.gid:process.getgid&&process.getgid(),c=parseInt("100",8),p=parseInt("010",8),d=parseInt("001",8),m=c|p,h=a&d||a&p&&l===D||a&c&&i===f||a&m&&f===0;return h}return Je}var be;process.platform==="win32"||A.TESTING_WINDOWS?be=Ds():be=cs();var ls=Ze;Ze.sync=fs;function Ze(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,s){Ze(e,t||{},function(o,u){o?s(o):n(u)})})}be(e,t||{},function(n,s){n&&(n.code==="EACCES"||t&&t.ignoreErrors)&&(n=null,s=!1),r(n,s)})}function fs(e,t){try{return be.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}const Q=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",pr=X,ps=Q?";":":",dr=ls,mr=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),hr=(e,t)=>{const r=t.colon||ps,n=e.match(/\//)||Q&&e.match(/\\/)?[""]:[...Q?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],s=Q?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=Q?s.split(r):[""];return Q&&e.indexOf(".")!==-1&&o[0]!==""&&o.unshift(""),{pathEnv:n,pathExt:o,pathExtExe:s}},gr=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});const{pathEnv:n,pathExt:s,pathExtExe:o}=hr(e,t),u=[],a=l=>new Promise((f,D)=>{if(l===n.length)return t.all&&u.length?f(u):D(mr(e));const c=n[l],p=/^".*"$/.test(c)?c.slice(1,-1):c,d=pr.join(p,e),m=!p&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;f(i(m,l,0))}),i=(l,f,D)=>new Promise((c,p)=>{if(D===s.length)return c(a(f+1));const d=s[D];dr(l+d,{pathExt:o},(m,h)=>{if(!m&&h)if(t.all)u.push(l+d);else return c(l+d);return c(i(l,f,D+1))})});return r?a(0).then(l=>r(null,l),r):a(0)},ds=(e,t)=>{t=t||{};const{pathEnv:r,pathExt:n,pathExtExe:s}=hr(e,t),o=[];for(let u=0;u<r.length;u++){const a=r[u],i=/^".*"$/.test(a)?a.slice(1,-1):a,l=pr.join(i,e),f=!i&&/^\.[\\\/]/.test(e)?e.slice(0,2)+l:l;for(let D=0;D<n.length;D++){const c=f+n[D];try{if(dr.sync(c,{pathExt:s}))if(t.all)o.push(c);else return c}catch{}}}if(t.all&&o.length)return o;if(t.nothrow)return null;throw mr(e)};var ms=gr;gr.sync=ds;var Qe={exports:{}};const Cr=(e={})=>{const t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};Qe.exports=Cr,Qe.exports.default=Cr;var hs=Qe.exports;const Fr=X,gs=ms,Cs=hs;function Er(e,t){const r=e.options.env||process.env,n=process.cwd(),s=e.options.cwd!=null,o=s&&process.chdir!==void 0&&!process.chdir.disabled;if(o)try{process.chdir(e.options.cwd)}catch{}let u;try{u=gs.sync(e.command,{path:r[Cs({env:r})],pathExt:t?Fr.delimiter:void 0})}catch{}finally{o&&process.chdir(n)}return u&&(u=Fr.resolve(s?e.options.cwd:"",u)),u}function Fs(e){return Er(e)||Er(e,!0)}var Es=Fs,et={};const tt=/([()\][%!^"`<>&|;, *?])/g;function ys(e){return e=e.replace(tt,"^$1"),e}function ws(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(tt,"^$1"),t&&(e=e.replace(tt,"^$1")),e}et.command=ys,et.argument=ws;var bs=/^#!(.*)/;const As=bs;var vs=(e="")=>{const t=e.match(As);if(!t)return null;const[r,n]=t[0].replace(/#! ?/,"").split(" "),s=r.split("/").pop();return s==="env"?n:n?`${s} ${n}`:s};const rt=Re,$s=vs;function Bs(e){const r=Buffer.alloc(150);let n;try{n=rt.openSync(e,"r"),rt.readSync(n,r,0,150,0),rt.closeSync(n)}catch{}return $s(r.toString())}var xs=Bs;const Os=X,yr=Es,wr=et,Is=xs,Ss=process.platform==="win32",Ms=/\.(?:com|exe)$/i,Ps=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function _s(e){e.file=yr(e);const t=e.file&&Is(e.file);return t?(e.args.unshift(e.file),e.command=t,yr(e)):e.file}function Ns(e){if(!Ss)return e;const t=_s(e),r=!Ms.test(t);if(e.options.forceShell||r){const n=Ps.test(t);e.command=Os.normalize(e.command),e.command=wr.command(e.command),e.args=e.args.map(o=>wr.argument(o,n));const s=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${s}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function Ts(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:Ns(n)}var Ls=Ts;const nt=process.platform==="win32";function ot(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function Rs(e,t){if(!nt)return;const r=e.emit;e.emit=function(n,s){if(n==="exit"){const o=br(s,t);if(o)return r.call(e,"error",o)}return r.apply(e,arguments)}}function br(e,t){return nt&&e===1&&!t.file?ot(t.original,"spawn"):null}function ks(e,t){return nt&&e===1&&!t.file?ot(t.original,"spawnSync"):null}var js={hookChildProcess:Rs,verifyENOENT:br,verifyENOENTSync:ks,notFoundError:ot};const Ar=Cn,st=Ls,ut=js;function vr(e,t,r){const n=st(e,t,r),s=Ar.spawn(n.command,n.args,n.options);return ut.hookChildProcess(s,n),s}function Gs(e,t,r){const n=st(e,t,r),s=Ar.spawnSync(n.command,n.args,n.options);return s.error=s.error||ut.verifyENOENTSync(s.status,n),s}Z.exports=vr,Z.exports.spawn=vr,Z.exports.sync=Gs,Z.exports._parse=st,Z.exports._enoent=ut;var
|
|
22
|
+
`),n(),process.exit(1);e[i]=l}}function ss(e){return e===void 0||e!==!1}function Dr(e,t,r,n){const s={...t.flags},o=t.version;o&&(s.version={type:Boolean,description:"Show version"});const{help:u}=t,a=ss(u);a&&!("help"in s)&&(s.help={type:Boolean,alias:"h",description:"Show help"});const i=uo(s,n,{ignore:t.ignoreArgv}),l=()=>{console.log(t.version)};if(o&&i.flags.version===!0)return l(),process.exit(0);const f=new ns,D=a&&u?.render?u.render:d=>f.render(d),c=d=>{const m=ts({...t,...d?{help:d}:{},flags:s});console.log(D(m,f))};if(a&&i.flags.help===!0)return c(),process.exit(0);if(t.parameters){let{parameters:d}=t,m=i._;const h=d.indexOf("--"),C=d.slice(h+1),w=Object.create(null);if(h>-1&&C.length>0){d=d.slice(0,h);const I=i._["--"];m=m.slice(0,-I.length||void 0),We(w,Ve(d),m,c),We(w,Ve(C),I,c)}else We(w,Ve(d),m,c);Object.assign(i._,w)}const p={...i,showVersion:l,showHelp:c};return typeof r=="function"&&r(p),{command:e,...p}}function us(e,t){const r=new Map;for(const n of t){const s=[n.options.name],{alias:o}=n.options;o&&(Array.isArray(o)?s.push(...o):s.push(o));for(const u of s){if(r.has(u))throw new Error(`Duplicate command name found: ${P(u)}`);r.set(u,n)}}return r.get(e)}function is(e,t,r=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!Ye.test(e.name)))throw new Error(`Invalid script name: ${P(e.name)}`);const n=r[0];if(e.commands&&Ye.test(n)){const s=us(n,e.commands);if(s)return Dr(s.options.name,{...s.options,parent:e},s.callback,r.slice(1))}return Dr(void 0,e,t,r)}function cr(e,t){if(!e)throw new Error("Command options are required");const{name:r}=e;if(e.name===void 0)throw new Error("Command name is required");if(!Ye.test(r))throw new Error(`Invalid command name ${JSON.stringify(r)}. Command names must be one word.`);return{options:e,callback:t}}var as=hn(import.meta.url),A=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function J(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Z={exports:{}},Xe,lr;function Ds(){if(lr)return Xe;lr=1,Xe=n,n.sync=s;var e=Re;function t(o,u){var a=u.pathExt!==void 0?u.pathExt:process.env.PATHEXT;if(!a||(a=a.split(";"),a.indexOf("")!==-1))return!0;for(var i=0;i<a.length;i++){var l=a[i].toLowerCase();if(l&&o.substr(-l.length).toLowerCase()===l)return!0}return!1}function r(o,u,a){return!o.isSymbolicLink()&&!o.isFile()?!1:t(u,a)}function n(o,u,a){e.stat(o,function(i,l){a(i,i?!1:r(l,o,u))})}function s(o,u){return r(e.statSync(o),o,u)}return Xe}var Je,fr;function cs(){if(fr)return Je;fr=1,Je=t,t.sync=r;var e=Re;function t(o,u,a){e.stat(o,function(i,l){a(i,i?!1:n(l,u))})}function r(o,u){return n(e.statSync(o),u)}function n(o,u){return o.isFile()&&s(o,u)}function s(o,u){var a=o.mode,i=o.uid,l=o.gid,f=u.uid!==void 0?u.uid:process.getuid&&process.getuid(),D=u.gid!==void 0?u.gid:process.getgid&&process.getgid(),c=parseInt("100",8),p=parseInt("010",8),d=parseInt("001",8),m=c|p,h=a&d||a&p&&l===D||a&c&&i===f||a&m&&f===0;return h}return Je}var be;process.platform==="win32"||A.TESTING_WINDOWS?be=Ds():be=cs();var ls=Ze;Ze.sync=fs;function Ze(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,s){Ze(e,t||{},function(o,u){o?s(o):n(u)})})}be(e,t||{},function(n,s){n&&(n.code==="EACCES"||t&&t.ignoreErrors)&&(n=null,s=!1),r(n,s)})}function fs(e,t){try{return be.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}const Q=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",pr=X,ps=Q?";":":",dr=ls,mr=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),hr=(e,t)=>{const r=t.colon||ps,n=e.match(/\//)||Q&&e.match(/\\/)?[""]:[...Q?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],s=Q?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=Q?s.split(r):[""];return Q&&e.indexOf(".")!==-1&&o[0]!==""&&o.unshift(""),{pathEnv:n,pathExt:o,pathExtExe:s}},gr=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});const{pathEnv:n,pathExt:s,pathExtExe:o}=hr(e,t),u=[],a=l=>new Promise((f,D)=>{if(l===n.length)return t.all&&u.length?f(u):D(mr(e));const c=n[l],p=/^".*"$/.test(c)?c.slice(1,-1):c,d=pr.join(p,e),m=!p&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;f(i(m,l,0))}),i=(l,f,D)=>new Promise((c,p)=>{if(D===s.length)return c(a(f+1));const d=s[D];dr(l+d,{pathExt:o},(m,h)=>{if(!m&&h)if(t.all)u.push(l+d);else return c(l+d);return c(i(l,f,D+1))})});return r?a(0).then(l=>r(null,l),r):a(0)},ds=(e,t)=>{t=t||{};const{pathEnv:r,pathExt:n,pathExtExe:s}=hr(e,t),o=[];for(let u=0;u<r.length;u++){const a=r[u],i=/^".*"$/.test(a)?a.slice(1,-1):a,l=pr.join(i,e),f=!i&&/^\.[\\\/]/.test(e)?e.slice(0,2)+l:l;for(let D=0;D<n.length;D++){const c=f+n[D];try{if(dr.sync(c,{pathExt:s}))if(t.all)o.push(c);else return c}catch{}}}if(t.all&&o.length)return o;if(t.nothrow)return null;throw mr(e)};var ms=gr;gr.sync=ds;var Qe={exports:{}};const Cr=(e={})=>{const t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};Qe.exports=Cr,Qe.exports.default=Cr;var hs=Qe.exports;const Fr=X,gs=ms,Cs=hs;function Er(e,t){const r=e.options.env||process.env,n=process.cwd(),s=e.options.cwd!=null,o=s&&process.chdir!==void 0&&!process.chdir.disabled;if(o)try{process.chdir(e.options.cwd)}catch{}let u;try{u=gs.sync(e.command,{path:r[Cs({env:r})],pathExt:t?Fr.delimiter:void 0})}catch{}finally{o&&process.chdir(n)}return u&&(u=Fr.resolve(s?e.options.cwd:"",u)),u}function Fs(e){return Er(e)||Er(e,!0)}var Es=Fs,et={};const tt=/([()\][%!^"`<>&|;, *?])/g;function ys(e){return e=e.replace(tt,"^$1"),e}function ws(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(tt,"^$1"),t&&(e=e.replace(tt,"^$1")),e}et.command=ys,et.argument=ws;var bs=/^#!(.*)/;const As=bs;var vs=(e="")=>{const t=e.match(As);if(!t)return null;const[r,n]=t[0].replace(/#! ?/,"").split(" "),s=r.split("/").pop();return s==="env"?n:n?`${s} ${n}`:s};const rt=Re,$s=vs;function Bs(e){const r=Buffer.alloc(150);let n;try{n=rt.openSync(e,"r"),rt.readSync(n,r,0,150,0),rt.closeSync(n)}catch{}return $s(r.toString())}var xs=Bs;const Os=X,yr=Es,wr=et,Is=xs,Ss=process.platform==="win32",Ms=/\.(?:com|exe)$/i,Ps=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function _s(e){e.file=yr(e);const t=e.file&&Is(e.file);return t?(e.args.unshift(e.file),e.command=t,yr(e)):e.file}function Ns(e){if(!Ss)return e;const t=_s(e),r=!Ms.test(t);if(e.options.forceShell||r){const n=Ps.test(t);e.command=Os.normalize(e.command),e.command=wr.command(e.command),e.args=e.args.map(o=>wr.argument(o,n));const s=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${s}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function Ts(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:Ns(n)}var Ls=Ts;const nt=process.platform==="win32";function ot(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function Rs(e,t){if(!nt)return;const r=e.emit;e.emit=function(n,s){if(n==="exit"){const o=br(s,t);if(o)return r.call(e,"error",o)}return r.apply(e,arguments)}}function br(e,t){return nt&&e===1&&!t.file?ot(t.original,"spawn"):null}function ks(e,t){return nt&&e===1&&!t.file?ot(t.original,"spawnSync"):null}var js={hookChildProcess:Rs,verifyENOENT:br,verifyENOENTSync:ks,notFoundError:ot};const Ar=Cn,st=Ls,ut=js;function vr(e,t,r){const n=st(e,t,r),s=Ar.spawn(n.command,n.args,n.options);return ut.hookChildProcess(s,n),s}function Gs(e,t,r){const n=st(e,t,r),s=Ar.spawnSync(n.command,n.args,n.options);return s.error=s.error||ut.verifyENOENTSync(s.status,n),s}Z.exports=vr,Z.exports.spawn=vr,Z.exports.sync=Gs,Z.exports._parse=st,Z.exports._enoent=ut;var Hs=Z.exports,Us=J(Hs);function Ks(e){const t=typeof e=="string"?`
|
|
23
23
|
`:`
|
|
24
24
|
`.charCodeAt(),r=typeof e=="string"?"\r":"\r".charCodeAt();return e[e.length-1]===t&&(e=e.slice(0,-1)),e[e.length-1]===r&&(e=e.slice(0,-1)),e}function $r(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"}function qs(e={}){const{cwd:t=j.cwd(),path:r=j.env[$r()],execPath:n=j.execPath}=e;let s;const o=t instanceof URL?Fn.fileURLToPath(t):t;let u=W.resolve(o);const a=[];for(;s!==u;)a.push(W.join(u,"node_modules/.bin")),s=u,u=W.resolve(u,"..");return a.push(W.resolve(o,n,"..")),[...a,r].join(W.delimiter)}function zs({env:e=j.env,...t}={}){e={...e};const r=$r({env:e});return t.path=e[r],e[r]=qs(t),e}const Ys=(e,t,r,n)=>{if(r==="length"||r==="prototype"||r==="arguments"||r==="caller")return;const s=Object.getOwnPropertyDescriptor(e,r),o=Object.getOwnPropertyDescriptor(t,r);!Vs(s,o)&&n||Object.defineProperty(e,r,o)},Vs=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)},Ws=(e,t)=>{const r=Object.getPrototypeOf(t);r!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,r)},Xs=(e,t)=>`/* Wrapped ${e}*/
|
|
25
25
|
${t}`,Js=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Zs=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Qs=(e,t,r)=>{const n=r===""?"":`with ${r.trim()}() `,s=Xs.bind(null,n,t.toString());Object.defineProperty(s,"name",Zs),Object.defineProperty(e,"toString",{...Js,value:s})};function eu(e,t,{ignoreNonConfigurable:r=!1}={}){const{name:n}=e;for(const s of Reflect.ownKeys(t))Ys(e,t,s,r);return Ws(e,t),Qs(e,t,n),e}const Ae=new WeakMap,Br=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let r,n=0;const s=e.displayName||e.name||"<anonymous>",o=function(...u){if(Ae.set(o,++n),n===1)r=e.apply(this,u),e=null;else if(t.throw===!0)throw new Error(`Function \`${s}\` can only be called once`);return r};return eu(o,e),Ae.set(o,n),o};Br.callCount=e=>{if(!Ae.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return Ae.get(e)};const tu=()=>{const e=Or-xr+1;return Array.from({length:e},ru)},ru=(e,t)=>({name:`SIGRT${t+1}`,number:xr+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),xr=34,Or=64,nu=[{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"}],Ir=()=>{const e=tu();return[...nu,...e].map(ou)},ou=({name:e,number:t,description:r,action:n,forced:s=!1,standard:o})=>{const{signals:{[e]:u}}=Tt,a=u!==void 0;return{name:e,number:a?u:t,description:r,supported:a,action:n,forced:s,standard:o}},su=()=>{const e=Ir();return Object.fromEntries(e.map(uu))},uu=({name:e,number:t,description:r,supported:n,action:s,forced:o,standard:u})=>[e,{name:e,number:t,description:r,supported:n,action:s,forced:o,standard:u}],iu=su(),au=()=>{const e=Ir(),t=Or+1,r=Array.from({length:t},(n,s)=>Du(s,e));return Object.assign({},...r)},Du=(e,t)=>{const r=cu(e,t);if(r===void 0)return{};const{name:n,description:s,supported:o,action:u,forced:a,standard:i}=r;return{[e]:{name:n,number:e,description:s,supported:o,action:u,forced:a,standard:i}}},cu=(e,t)=>{const r=t.find(({name:n})=>Tt.signals[n]===e);return r!==void 0?r:t.find(n=>n.number===e)};au();const lu=({timedOut:e,timeout:t,errorCode:r,signal:n,signalDescription:s,exitCode:o,isCanceled:u})=>e?`timed out after ${t} milliseconds`:u?"was canceled":r!==void 0?`failed with ${r}`:n!==void 0?`was killed with ${n} (${s})`:o!==void 0?`failed with exit code ${o}`:"failed",Sr=({stdout:e,stderr:t,all:r,error:n,signal:s,exitCode:o,command:u,escapedCommand:a,timedOut:i,isCanceled:l,killed:f,parsed:{options:{timeout:D}}})=>{o=o===null?void 0:o,s=s===null?void 0:s;const c=s===void 0?void 0:iu[s].description,p=n&&n.code,m=`Command ${lu({timedOut:i,timeout:D,errorCode:p,signal:s,signalDescription:c,exitCode:o,isCanceled:l})}: ${u}`,h=Object.prototype.toString.call(n)==="[object Error]",C=h?`${m}
|
|
26
26
|
${n.message}`:m,w=[C,t,e].filter(Boolean).join(`
|
|
27
|
-
`);return h?(n.originalMessage=n.message,n.message=w):n=new Error(w),n.shortMessage=C,n.command=u,n.escapedCommand=a,n.exitCode=o,n.signal=s,n.signalDescription=c,n.stdout=e,n.stderr=t,r!==void 0&&(n.all=r),"bufferedData"in n&&delete n.bufferedData,n.failed=!0,n.timedOut=!!i,n.isCanceled=l,n.killed=f&&!i,n},ve=["stdin","stdout","stderr"],fu=e=>ve.some(t=>e[t]!==void 0),pu=e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return ve.map(n=>e[n]);if(fu(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${ve.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,ve.length);return Array.from({length:r},(n,s)=>t[s])};var ee={exports:{}},$e={exports:{}};$e.exports;var Mr;function du(){return Mr||(Mr=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")}($e)),$e.exports}var E=A.process;const q=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(!q(E))ee.exports=function(){return function(){}};else{var mu=Lt,De=du(),hu=/^win/i.test(E.platform),Be=Rt;typeof Be!="function"&&(Be=Be.EventEmitter);var v;E.__signal_exit_emitter__?v=E.__signal_exit_emitter__:(v=E.__signal_exit_emitter__=new Be,v.count=0,v.emitted={}),v.infinite||(v.setMaxListeners(1/0),v.infinite=!0),ee.exports=function(e,t){if(!q(A.process))return function(){};mu.equal(typeof e,"function","a callback must be provided for exit handler"),ce===!1&&Pr();var r="exit";t&&t.alwaysLast&&(r="afterexit");var n=function(){v.removeListener(r,e),v.listeners("exit").length===0&&v.listeners("afterexit").length===0&&it()};return v.on(r,e),n};var it=function(){!ce||!q(A.process)||(ce=!1,De.forEach(function(t){try{E.removeListener(t,at[t])}catch{}}),E.emit=Dt,E.reallyExit=_r,v.count-=1)};ee.exports.unload=it;var te=function(t,r,n){v.emitted[t]||(v.emitted[t]=!0,v.emit(t,r,n))},at={};De.forEach(function(e){at[e]=function(){if(q(A.process)){var r=E.listeners(e);r.length===v.count&&(it(),te("exit",null,e),te("afterexit",null,e),hu&&e==="SIGHUP"&&(e="SIGINT"),E.kill(E.pid,e))}}}),ee.exports.signals=function(){return De};var ce=!1,Pr=function(){ce||!q(A.process)||(ce=!0,v.count+=1,De=De.filter(function(t){try{return E.on(t,at[t]),!0}catch{return!1}}),E.emit=Cu,E.reallyExit=gu)};ee.exports.load=Pr;var _r=E.reallyExit,gu=function(t){q(A.process)&&(E.exitCode=t||0,te("exit",E.exitCode,null),te("afterexit",E.exitCode,null),_r.call(E,E.exitCode))},Dt=E.emit,Cu=function(t,r){if(t==="exit"&&q(A.process)){r!==void 0&&(E.exitCode=r);var n=Dt.apply(this,arguments);return te("exit",E.exitCode,null),te("afterexit",E.exitCode,null),n}else return Dt.apply(this,arguments)}}var Fu=ee.exports,Eu=J(Fu);const yu=1e3*5,wu=(e,t="SIGTERM",r={})=>{const n=e(t);return bu(e,t,r,n),n},bu=(e,t,r,n)=>{if(!Au(t,r,n))return;const s=$u(r),o=setTimeout(()=>{e("SIGKILL")},s);o.unref&&o.unref()},Au=(e,{forceKillAfterTimeout:t},r)=>vu(e)&&t!==!1&&r,vu=e=>e===En.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",$u=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return yu;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},Bu=(e,t)=>{e.kill()&&(t.isCanceled=!0)},xu=(e,t,r)=>{e.kill(t),r(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},Ou=(e,{timeout:t,killSignal:r="SIGTERM"},n)=>{if(t===0||t===void 0)return n;let s;const o=new Promise((a,i)=>{s=setTimeout(()=>{xu(e,r,i)},t)}),u=n.finally(()=>{clearTimeout(s)});return Promise.race([o,u])},Iu=({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})`)},Su=async(e,{cleanup:t,detached:r},n)=>{if(!t||r)return n;const s=Eu(()=>{e.kill()});return n.finally(()=>{s()})};function Mu(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}var le={exports:{}};const{PassThrough:Pu}=ke;var _u=e=>{e={...e};const{array:t}=e;let{encoding:r}=e;const n=r==="buffer";let s=!1;t?s=!(r||n):r=r||"utf8",n&&(r=null);const o=new Pu({objectMode:s});r&&o.setEncoding(r);let u=0;const a=[];return o.on("data",i=>{a.push(i),s?u=a.length:u+=i.length}),o.getBufferedValue=()=>t?a:n?Buffer.concat(a,u):a.join(""),o.getBufferedLength=()=>u,o};const{constants:Nu}=yn,Tu=ke,{promisify:Lu}=kt,Ru=_u,ku=Lu(Tu.pipeline);class Nr extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function ct(e,t){if(!e)throw new Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:r}=t,n=Ru(t);return await new Promise((s,o)=>{const u=a=>{a&&n.getBufferedLength()<=Nu.MAX_LENGTH&&(a.bufferedData=n.getBufferedValue()),o(a)};(async()=>{try{await ku(e,n),s()}catch(a){u(a)}})(),n.on("data",()=>{n.getBufferedLength()>r&&u(new Nr)})}),n.getBufferedValue()}le.exports=ct,le.exports.buffer=(e,t)=>ct(e,{...t,encoding:"buffer"}),le.exports.array=(e,t)=>ct(e,{...t,array:!0}),le.exports.MaxBufferError=Nr;var ju=le.exports,Tr=J(ju);const{PassThrough:Gu}=ke;var
|
|
27
|
+
`);return h?(n.originalMessage=n.message,n.message=w):n=new Error(w),n.shortMessage=C,n.command=u,n.escapedCommand=a,n.exitCode=o,n.signal=s,n.signalDescription=c,n.stdout=e,n.stderr=t,r!==void 0&&(n.all=r),"bufferedData"in n&&delete n.bufferedData,n.failed=!0,n.timedOut=!!i,n.isCanceled=l,n.killed=f&&!i,n},ve=["stdin","stdout","stderr"],fu=e=>ve.some(t=>e[t]!==void 0),pu=e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return ve.map(n=>e[n]);if(fu(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${ve.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,ve.length);return Array.from({length:r},(n,s)=>t[s])};var ee={exports:{}},$e={exports:{}};$e.exports;var Mr;function du(){return Mr||(Mr=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")}($e)),$e.exports}var E=A.process;const q=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(!q(E))ee.exports=function(){return function(){}};else{var mu=Lt,De=du(),hu=/^win/i.test(E.platform),Be=Rt;typeof Be!="function"&&(Be=Be.EventEmitter);var v;E.__signal_exit_emitter__?v=E.__signal_exit_emitter__:(v=E.__signal_exit_emitter__=new Be,v.count=0,v.emitted={}),v.infinite||(v.setMaxListeners(1/0),v.infinite=!0),ee.exports=function(e,t){if(!q(A.process))return function(){};mu.equal(typeof e,"function","a callback must be provided for exit handler"),ce===!1&&Pr();var r="exit";t&&t.alwaysLast&&(r="afterexit");var n=function(){v.removeListener(r,e),v.listeners("exit").length===0&&v.listeners("afterexit").length===0&&it()};return v.on(r,e),n};var it=function(){!ce||!q(A.process)||(ce=!1,De.forEach(function(t){try{E.removeListener(t,at[t])}catch{}}),E.emit=Dt,E.reallyExit=_r,v.count-=1)};ee.exports.unload=it;var te=function(t,r,n){v.emitted[t]||(v.emitted[t]=!0,v.emit(t,r,n))},at={};De.forEach(function(e){at[e]=function(){if(q(A.process)){var r=E.listeners(e);r.length===v.count&&(it(),te("exit",null,e),te("afterexit",null,e),hu&&e==="SIGHUP"&&(e="SIGINT"),E.kill(E.pid,e))}}}),ee.exports.signals=function(){return De};var ce=!1,Pr=function(){ce||!q(A.process)||(ce=!0,v.count+=1,De=De.filter(function(t){try{return E.on(t,at[t]),!0}catch{return!1}}),E.emit=Cu,E.reallyExit=gu)};ee.exports.load=Pr;var _r=E.reallyExit,gu=function(t){q(A.process)&&(E.exitCode=t||0,te("exit",E.exitCode,null),te("afterexit",E.exitCode,null),_r.call(E,E.exitCode))},Dt=E.emit,Cu=function(t,r){if(t==="exit"&&q(A.process)){r!==void 0&&(E.exitCode=r);var n=Dt.apply(this,arguments);return te("exit",E.exitCode,null),te("afterexit",E.exitCode,null),n}else return Dt.apply(this,arguments)}}var Fu=ee.exports,Eu=J(Fu);const yu=1e3*5,wu=(e,t="SIGTERM",r={})=>{const n=e(t);return bu(e,t,r,n),n},bu=(e,t,r,n)=>{if(!Au(t,r,n))return;const s=$u(r),o=setTimeout(()=>{e("SIGKILL")},s);o.unref&&o.unref()},Au=(e,{forceKillAfterTimeout:t},r)=>vu(e)&&t!==!1&&r,vu=e=>e===En.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",$u=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return yu;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},Bu=(e,t)=>{e.kill()&&(t.isCanceled=!0)},xu=(e,t,r)=>{e.kill(t),r(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},Ou=(e,{timeout:t,killSignal:r="SIGTERM"},n)=>{if(t===0||t===void 0)return n;let s;const o=new Promise((a,i)=>{s=setTimeout(()=>{xu(e,r,i)},t)}),u=n.finally(()=>{clearTimeout(s)});return Promise.race([o,u])},Iu=({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})`)},Su=async(e,{cleanup:t,detached:r},n)=>{if(!t||r)return n;const s=Eu(()=>{e.kill()});return n.finally(()=>{s()})};function Mu(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}var le={exports:{}};const{PassThrough:Pu}=ke;var _u=e=>{e={...e};const{array:t}=e;let{encoding:r}=e;const n=r==="buffer";let s=!1;t?s=!(r||n):r=r||"utf8",n&&(r=null);const o=new Pu({objectMode:s});r&&o.setEncoding(r);let u=0;const a=[];return o.on("data",i=>{a.push(i),s?u=a.length:u+=i.length}),o.getBufferedValue=()=>t?a:n?Buffer.concat(a,u):a.join(""),o.getBufferedLength=()=>u,o};const{constants:Nu}=yn,Tu=ke,{promisify:Lu}=kt,Ru=_u,ku=Lu(Tu.pipeline);class Nr extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function ct(e,t){if(!e)throw new Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:r}=t,n=Ru(t);return await new Promise((s,o)=>{const u=a=>{a&&n.getBufferedLength()<=Nu.MAX_LENGTH&&(a.bufferedData=n.getBufferedValue()),o(a)};(async()=>{try{await ku(e,n),s()}catch(a){u(a)}})(),n.on("data",()=>{n.getBufferedLength()>r&&u(new Nr)})}),n.getBufferedValue()}le.exports=ct,le.exports.buffer=(e,t)=>ct(e,{...t,encoding:"buffer"}),le.exports.array=(e,t)=>ct(e,{...t,array:!0}),le.exports.MaxBufferError=Nr;var ju=le.exports,Tr=J(ju);const{PassThrough:Gu}=ke;var Hu=function(){var e=[],t=new Gu({objectMode:!0});return t.setMaxListeners(0),t.add=r,t.isEmpty=n,t.on("unpipe",s),Array.prototype.slice.call(arguments).forEach(r),t;function r(o){return Array.isArray(o)?(o.forEach(r),this):(e.push(o),o.once("end",s.bind(null,o)),o.once("error",t.emit.bind(t,"error")),o.pipe(t,{end:!1}),this)}function n(){return e.length==0}function s(o){e=e.filter(function(u){return u!==o}),!e.length&&t.readable&&t.end()}},Uu=J(Hu);const Ku=(e,t)=>{t!==void 0&&(Mu(t)?t.pipe(e.stdin):e.stdin.end(t))},qu=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;const r=Uu();return e.stdout&&r.add(e.stdout),e.stderr&&r.add(e.stderr),r},lt=async(e,t)=>{if(!(!e||t===void 0)){e.destroy();try{return await t}catch(r){return r.bufferedData}}},ft=(e,{encoding:t,buffer:r,maxBuffer:n})=>{if(!(!e||!r))return t?Tr(e,{encoding:t,maxBuffer:n}):Tr.buffer(e,{maxBuffer:n})},zu=async({stdout:e,stderr:t,all:r},{encoding:n,buffer:s,maxBuffer:o},u)=>{const a=ft(e,{encoding:n,buffer:s,maxBuffer:o}),i=ft(t,{encoding:n,buffer:s,maxBuffer:o}),l=ft(r,{encoding:n,buffer:s,maxBuffer:o*2});try{return await Promise.all([u,a,i,l])}catch(f){return Promise.all([{error:f,signal:f.signal,timedOut:f.timedOut},lt(e,a),lt(t,i),lt(r,l)])}},Yu=(async()=>{})().constructor.prototype,Vu=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(Yu,e)]),Lr=(e,t)=>{for(const[r,n]of Vu){const s=typeof t=="function"?(...o)=>Reflect.apply(n.value,t(),o):n.value.bind(t);Reflect.defineProperty(e,r,{...n,value:s})}return e},Wu=e=>new Promise((t,r)=>{e.on("exit",(n,s)=>{t({exitCode:n,signal:s})}),e.on("error",n=>{r(n)}),e.stdin&&e.stdin.on("error",n=>{r(n)})}),Rr=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],Xu=/^[\w.-]+$/,Ju=/"/g,Zu=e=>typeof e!="string"||Xu.test(e)?e:`"${e.replace(Ju,'\\"')}"`,Qu=(e,t)=>Rr(e,t).join(" "),ei=(e,t)=>Rr(e,t).map(r=>Zu(r)).join(" "),ti=1e3*1e3*100,ri=({env:e,extendEnv:t,preferLocal:r,localDir:n,execPath:s})=>{const o=t?{...j.env,...e}:e;return r?zs({env:o,cwd:n,execPath:s}):o},ni=(e,t,r={})=>{const n=Us._parse(e,t,r);return e=n.command,t=n.args,r=n.options,r={maxBuffer:ti,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:r.cwd||j.cwd(),execPath:j.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...r},r.env=ri(r),r.stdio=pu(r),j.platform==="win32"&&W.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:r,parsed:n}},pt=(e,t,r)=>typeof t!="string"&&!gn.isBuffer(t)?r===void 0?void 0:"":e.stripFinalNewline?Ks(t):t;function re(e,t,r){const n=ni(e,t,r),s=Qu(e,t),o=ei(e,t);Iu(n.options);let u;try{u=Nt.spawn(n.file,n.args,n.options)}catch(p){const d=new Nt.ChildProcess,m=Promise.reject(Sr({error:p,stdout:"",stderr:"",all:"",command:s,escapedCommand:o,parsed:n,timedOut:!1,isCanceled:!1,killed:!1}));return Lr(d,m)}const a=Wu(u),i=Ou(u,n.options,a),l=Su(u,n.options,i),f={isCanceled:!1};u.kill=wu.bind(null,u.kill.bind(u)),u.cancel=Bu.bind(null,u,f);const c=Br(async()=>{const[{error:p,exitCode:d,signal:m,timedOut:h},C,w,I]=await zu(u,n.options,l),_=pt(n.options,C),N=pt(n.options,w),se=pt(n.options,I);if(p||d!==0||m!==null){const b=Sr({error:p,exitCode:d,signal:m,stdout:_,stderr:N,all:se,command:s,escapedCommand:o,parsed:n,timedOut:h,isCanceled:f.isCanceled||(n.options.signal?n.options.signal.aborted:!1),killed:u.killed});if(!n.options.reject)return b;throw b}return{command:s,escapedCommand:o,exitCode:0,stdout:_,stderr:N,all:se,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return Ku(u,n.options.input),u.all=qu(u,n.options),Lr(u,c)}class z{static create(t,r){return new t(r)}}const oi={"":"commit message",conventional:"type(optional scope): description",gitmoji:":emoji: description"},si=e=>`The output response must be in ${e} commit type:
|
|
28
28
|
${oi[e]}`,ui={"":"",gitmoji:"",conventional:`Choose a type from the type-to-description JSON below that best describes the git diff:
|
|
29
29
|
${JSON.stringify({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 our CI configuration files and 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"},null,2)}`},xe=(e,t,r,n)=>["Generate a concise git commit message written in present tense for the following code diff with the given specifications below:",`Message language: ${e}`,`Commit message must be a maximum of ${t} characters.`,"Please exclude anything unnecessary such as translation or explanation.","Your entire response will be passed directly into git commit.",ui[r],si(r),n].filter(Boolean).join(`
|
|
30
|
-
`),ii=e=>/^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\s\w\.\-\p{Extended_Pictographic}]+\))?(!)?: ([\s\w \p{Extended_Pictographic}])+([\s\S]*)/.test(e),ai=e=>/^\:\w+\: (.*)$/.test(e),
|
|
30
|
+
`),ii=e=>/^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\s\w\.\-\p{Extended_Pictographic}]+\))?(!)?: ([\s\w \p{Extended_Pictographic}])+([\s\S]*)/.test(e),ai=e=>/^\:\w+\: (.*)$/.test(e),U={OPEN_AI:"OPENAI_KEY",GEMINI:"GEMINI_KEY",ANTHROPIC:"ANTHROPIC_KEY",HUGGING:"HUGGING_COOKIE",CLOVA_X:"CLOVAX_COOKIE",MISTRAL:"MISTRAL_KEY",OLLAMA:"OLLAMA_MODEL"},kr=Object.values(U).map(e=>e);class Y{constructor(t){this.handleError$=r=>{let n="An error occurred";return r.message&&(n=r.message),G({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.serviceName="AI",this.errorPrefix="ERROR",this.colors={primary:""}}buildPrompt(t,r,n,s,o,u){return`${xe(t,s,o,u)}
|
|
31
31
|
Please just generate ${n} commit messages in numbered list format without any explanation.
|
|
32
32
|
Here are git diff:
|
|
33
33
|
${r}`}extractCommitMessageFromRawText(t,r){switch(t){case"conventional":const n=new RegExp(/(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?: .*$/),s=r.match(n);return s?s[0].replace(/: (\w)/,(a,i)=>`: ${i.toLowerCase()}`):"";case"gitmoji":const o=new RegExp(/\:\w+\: (.*)$/),u=r.match(o);return u?u[0]:"";default:return r}}sanitizeMessage(t,r,n){const s=t.split(`
|
|
34
|
-
`).map(o=>o.trim().replace(/^\d+\.\s/,"")).map(o=>o.replace(/`/g,"")).map(o=>this.extractCommitMessageFromRawText(r,o)).filter(o=>!!o);return s.length>n?s.slice(0,n):s}}var jr="1.8.
|
|
34
|
+
`).map(o=>o.trim().replace(/^\d+\.\s/,"")).map(o=>o.replace(/`/g,"")).map(o=>this.extractCommitMessageFromRawText(r,o)).filter(o=>!!o);return s.length>n?s.slice(0,n):s}}var jr="1.8.3",Di="A Reactive CLI that generates git commit messages with various AI";class y extends Error{}const dt=" ",Oe=e=>{e instanceof Error&&(e instanceof y||(e.stack&&console.error(g.dim(e.stack.split(`
|
|
35
35
|
`).slice(1).join(`
|
|
36
36
|
`))),console.error(`
|
|
37
37
|
${dt}${g.dim(`aicommit2 v${jr}`)}`),console.error(`
|
|
38
|
-
${dt}Please open a Bug report with the information above:`),console.error(`${dt}https://github.com/tak-bro/aicommit2/issues/new/choose`)))};var mt={},ht={exports:{}},fe={exports:{}},gt,Gr;function ci(){if(Gr)return gt;Gr=1;var e=1e3,t=e*60,r=t*60,n=r*24,s=n*7,o=n*365.25;gt=function(f,D){D=D||{};var c=typeof f;if(c==="string"&&f.length>0)return u(f);if(c==="number"&&isFinite(f))return D.long?i(f):a(f);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(f))};function u(f){if(f=String(f),!(f.length>100)){var D=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(f);if(D){var c=parseFloat(D[1]),p=(D[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*s;case"days":case"day":case"d":return c*n;case"hours":case"hour":case"hrs":case"hr":case"h":return c*r;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}}}function a(f){var D=Math.abs(f);return D>=n?Math.round(f/n)+"d":D>=r?Math.round(f/r)+"h":D>=t?Math.round(f/t)+"m":D>=e?Math.round(f/e)+"s":f+"ms"}function i(f){var D=Math.abs(f);return D>=n?l(f,D,n,"day"):D>=r?l(f,D,r,"hour"):D>=t?l(f,D,t,"minute"):D>=e?l(f,D,e,"second"):f+" ms"}function l(f,D,c,p){var d=D>=c*1.5;return Math.round(f/c)+" "+p+(d?"s":"")}return gt}var Ct,
|
|
38
|
+
${dt}Please open a Bug report with the information above:`),console.error(`${dt}https://github.com/tak-bro/aicommit2/issues/new/choose`)))};var mt={},ht={exports:{}},fe={exports:{}},gt,Gr;function ci(){if(Gr)return gt;Gr=1;var e=1e3,t=e*60,r=t*60,n=r*24,s=n*7,o=n*365.25;gt=function(f,D){D=D||{};var c=typeof f;if(c==="string"&&f.length>0)return u(f);if(c==="number"&&isFinite(f))return D.long?i(f):a(f);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(f))};function u(f){if(f=String(f),!(f.length>100)){var D=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(f);if(D){var c=parseFloat(D[1]),p=(D[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*s;case"days":case"day":case"d":return c*n;case"hours":case"hour":case"hrs":case"hr":case"h":return c*r;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}}}function a(f){var D=Math.abs(f);return D>=n?Math.round(f/n)+"d":D>=r?Math.round(f/r)+"h":D>=t?Math.round(f/t)+"m":D>=e?Math.round(f/e)+"s":f+"ms"}function i(f){var D=Math.abs(f);return D>=n?l(f,D,n,"day"):D>=r?l(f,D,r,"hour"):D>=t?l(f,D,t,"minute"):D>=e?l(f,D,e,"second"):f+" ms"}function l(f,D,c,p){var d=D>=c*1.5;return Math.round(f/c)+" "+p+(d?"s":"")}return gt}var Ct,Hr;function Ur(){if(Hr)return Ct;Hr=1;function e(t){n.debug=n,n.default=n,n.coerce=l,n.disable=u,n.enable=o,n.enabled=a,n.humanize=ci(),n.destroy=f,Object.keys(t).forEach(D=>{n[D]=t[D]}),n.names=[],n.skips=[],n.formatters={};function r(D){let c=0;for(let p=0;p<D.length;p++)c=(c<<5)-c+D.charCodeAt(p),c|=0;return n.colors[Math.abs(c)%n.colors.length]}n.selectColor=r;function n(D){let c,p=null,d,m;function h(...C){if(!h.enabled)return;const w=h,I=Number(new Date),_=I-(c||I);w.diff=_,w.prev=c,w.curr=I,c=I,C[0]=n.coerce(C[0]),typeof C[0]!="string"&&C.unshift("%O");let N=0;C[0]=C[0].replace(/%([a-zA-Z%])/g,(b,Te)=>{if(b==="%%")return"%";N++;const _t=n.formatters[Te];if(typeof _t=="function"){const mn=C[N];b=_t.call(w,mn),C.splice(N,1),N--}return b}),n.formatArgs.call(w,C),(w.log||n.log).apply(w,C)}return h.namespace=D,h.useColors=n.useColors(),h.color=n.selectColor(D),h.extend=s,h.destroy=n.destroy,Object.defineProperty(h,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(d!==n.namespaces&&(d=n.namespaces,m=n.enabled(D)),m),set:C=>{p=C}}),typeof n.init=="function"&&n.init(h),h}function s(D,c){const p=n(this.namespace+(typeof c>"u"?":":c)+D);return p.log=this.log,p}function o(D){n.save(D),n.namespaces=D,n.names=[],n.skips=[];let c;const p=(typeof D=="string"?D:"").split(/[\s,]+/),d=p.length;for(c=0;c<d;c++)p[c]&&(D=p[c].replace(/\*/g,".*?"),D[0]==="-"?n.skips.push(new RegExp("^"+D.slice(1)+"$")):n.names.push(new RegExp("^"+D+"$")))}function u(){const D=[...n.names.map(i),...n.skips.map(i).map(c=>"-"+c)].join(",");return n.enable(""),D}function a(D){if(D[D.length-1]==="*")return!0;let c,p;for(c=0,p=n.skips.length;c<p;c++)if(n.skips[c].test(D))return!1;for(c=0,p=n.names.length;c<p;c++)if(n.names[c].test(D))return!0;return!1}function i(D){return D.toString().substring(2,D.toString().length-2).replace(/\.\*\?$/,"*")}function l(D){return D instanceof Error?D.stack||D.message:D}function f(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}return Ct=e,Ct}fe.exports;var Kr;function li(){return Kr||(Kr=1,function(e,t){t.formatArgs=n,t.save=s,t.load=o,t.useColors=r,t.storage=u(),t.destroy=(()=>{let i=!1;return()=>{i||(i=!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(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;i.splice(1,0,l,"color: inherit");let f=0,D=0;i[0].replace(/%[a-zA-Z%]/g,c=>{c!=="%%"&&(f++,c==="%c"&&(D=f))}),i.splice(D,0,l)}t.log=console.debug||console.log||(()=>{});function s(i){try{i?t.storage.setItem("debug",i):t.storage.removeItem("debug")}catch{}}function o(){let i;try{i=t.storage.getItem("debug")}catch{}return!i&&typeof process<"u"&&"env"in process&&(i=process.env.DEBUG),i}function u(){try{return localStorage}catch{}}e.exports=Ur()(t);const{formatters:a}=e.exports;a.j=function(i){try{return JSON.stringify(i)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(fe,fe.exports)),fe.exports}var pe={exports:{}},Ft,qr;function fi(){return qr||(qr=1,Ft=(e,t=process.argv)=>{const r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),s=t.indexOf("--");return n!==-1&&(s===-1||n<s)}),Ft}var Et,zr;function pi(){if(zr)return Et;zr=1;const e=Ut,t=Le,r=fi(),{env:n}=process;let s;r("no-color")||r("no-colors")||r("color=false")||r("color=never")?s=0:(r("color")||r("colors")||r("color=true")||r("color=always"))&&(s=1),"FORCE_COLOR"in n&&(n.FORCE_COLOR==="true"?s=1:n.FORCE_COLOR==="false"?s=0:s=n.FORCE_COLOR.length===0?1:Math.min(parseInt(n.FORCE_COLOR,10),3));function o(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function u(i,l){if(s===0)return 0;if(r("color=16m")||r("color=full")||r("color=truecolor"))return 3;if(r("color=256"))return 2;if(i&&!l&&s===void 0)return 0;const f=s||0;if(n.TERM==="dumb")return f;if(process.platform==="win32"){const D=e.release().split(".");return Number(D[0])>=10&&Number(D[2])>=10586?Number(D[2])>=14931?3:2:1}if("CI"in n)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(D=>D in n)||n.CI_NAME==="codeship"?1:f;if("TEAMCITY_VERSION"in n)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(n.TEAMCITY_VERSION)?1:0;if(n.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in n){const D=parseInt((n.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(n.TERM_PROGRAM){case"iTerm.app":return D>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(n.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(n.TERM)||"COLORTERM"in n?1:f}function a(i){const l=u(i,i&&i.isTTY);return o(l)}return Et={supportsColor:a,stdout:o(u(!0,t.isatty(1))),stderr:o(u(!0,t.isatty(2)))},Et}pe.exports;var Yr;function di(){return Yr||(Yr=1,function(e,t){const r=Le,n=kt;t.init=f,t.log=a,t.formatArgs=o,t.save=i,t.load=l,t.useColors=s,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 c=pi();c&&(c.stderr||c).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(c=>/^debug_/i.test(c)).reduce((c,p)=>{const d=p.substring(6).toLowerCase().replace(/_([a-z])/g,(h,C)=>C.toUpperCase());let m=process.env[p];return/^(yes|on|true|enabled)$/i.test(m)?m=!0:/^(no|off|false|disabled)$/i.test(m)?m=!1:m==="null"?m=null:m=Number(m),c[d]=m,c},{});function s(){return"colors"in t.inspectOpts?!!t.inspectOpts.colors:r.isatty(process.stderr.fd)}function o(c){const{namespace:p,useColors:d}=this;if(d){const m=this.color,h="\x1B[3"+(m<8?m:"8;5;"+m),C=` ${h};1m${p} \x1B[0m`;c[0]=C+c[0].split(`
|
|
39
39
|
`).join(`
|
|
40
40
|
`+C),c.push(h+"m+"+e.exports.humanize(this.diff)+"\x1B[0m")}else c[0]=u()+p+" "+c[0]}function u(){return t.inspectOpts.hideDate?"":new Date().toISOString()+" "}function a(...c){return process.stderr.write(n.format(...c)+`
|
|
41
|
-
`)}function i(c){c?process.env.DEBUG=c:delete process.env.DEBUG}function l(){return process.env.DEBUG}function f(c){c.inspectOpts={};const p=Object.keys(t.inspectOpts);for(let d=0;d<p.length;d++)c.inspectOpts[p[d]]=t.inspectOpts[p[d]]}e.exports=
|
|
41
|
+
`)}function i(c){c?process.env.DEBUG=c:delete process.env.DEBUG}function l(){return process.env.DEBUG}function f(c){c.inspectOpts={};const p=Object.keys(t.inspectOpts);for(let d=0;d<p.length;d++)c.inspectOpts[p[d]]=t.inspectOpts[p[d]]}e.exports=Ur()(t);const{formatters:D}=e.exports;D.o=function(c){return this.inspectOpts.colors=this.useColors,n.inspect(c,this.inspectOpts).split(`
|
|
42
42
|
`).map(p=>p.trim()).join(" ")},D.O=function(c){return this.inspectOpts.colors=this.useColors,n.inspect(c,this.inspectOpts)}}(pe,pe.exports)),pe.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?ht.exports=li():ht.exports=di();var yt=ht.exports,wt={};Object.defineProperty(wt,"__esModule",{value:!0});function mi(e){return function(t,r){return new Promise((n,s)=>{e.call(this,t,r,(o,u)=>{o?s(o):n(u)})})}}wt.default=mi;var Vr=A&&A.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const hi=Rt,gi=Vr(yt),Ci=Vr(wt),de=gi.default("agent-base");function Fi(e){return!!e&&typeof e.addRequest=="function"}function bt(){const{stack:e}=new Error;return typeof e!="string"?!1:e.split(`
|
|
43
43
|
`).some(t=>t.indexOf("(https.js:")!==-1||t.indexOf("node:https:")!==-1)}function Ie(e,t){return new Ie.Agent(e,t)}(function(e){class t extends hi.EventEmitter{constructor(n,s){super();let o=s;typeof n=="function"?this.callback=n:n&&(o=n),this.timeout=null,o&&typeof o.timeout=="number"&&(this.timeout=o.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:bt()?443:80}set defaultPort(n){this.explicitDefaultPort=n}get protocol(){return typeof this.explicitProtocol=="string"?this.explicitProtocol:bt()?"https:":"http:"}set protocol(n){this.explicitProtocol=n}callback(n,s,o){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(n,s){const o=Object.assign({},s);typeof o.secureEndpoint!="boolean"&&(o.secureEndpoint=bt()),o.host==null&&(o.host="localhost"),o.port==null&&(o.port=o.secureEndpoint?443:80),o.protocol==null&&(o.protocol=o.secureEndpoint?"https:":"http:"),o.host&&o.path&&delete o.path,delete o.agent,delete o.hostname,delete o._defaultAgent,delete o.defaultPort,delete o.createConnection,n._last=!0,n.shouldKeepAlive=!1;let u=!1,a=null;const i=o.timeout||this.timeout,l=p=>{n._hadError||(n.emit("error",p),n._hadError=!0)},f=()=>{a=null,u=!0;const p=new Error(`A "socket" was not created for HTTP request before ${i}ms`);p.code="ETIMEOUT",l(p)},D=p=>{u||(a!==null&&(clearTimeout(a),a=null),l(p))},c=p=>{if(u)return;if(a!=null&&(clearTimeout(a),a=null),Fi(p)){de("Callback returned another Agent instance %o",p.constructor.name),p.addRequest(n,o);return}if(p){p.once("free",()=>{this.freeSocket(p,o)}),n.onSocket(p);return}const d=new Error(`no Duplex stream was returned to agent-base for \`${n.method} ${n.path}\``);l(d)};if(typeof this.callback!="function"){l(new Error("`callback` is not defined"));return}this.promisifiedCallback||(this.callback.length>=3?(de("Converting legacy callback function to promise"),this.promisifiedCallback=Ci.default(this.callback)):this.promisifiedCallback=this.callback),typeof i=="number"&&i>0&&(a=setTimeout(f,i)),"port"in o&&typeof o.port!="number"&&(o.port=Number(o.port));try{de("Resolving socket for %o request: %o",o.protocol,`${n.method} ${n.path}`),Promise.resolve(this.promisifiedCallback(n,o)).then(c,D)}catch(p){Promise.reject(p).catch(D)}}freeSocket(n,s){de("Freeing socket %o %o",n.constructor.name,s),n.destroy()}destroy(){de("Destroying agent %o",this.constructor.name)}}e.Agent=t,e.prototype=e.Agent.prototype})(Ie||(Ie={}));var Ei=Ie,At={},yi=A&&A.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(At,"__esModule",{value:!0});const wi=yi(yt),me=wi.default("https-proxy-agent:parse-proxy-response");function bi(e){return new Promise((t,r)=>{let n=0;const s=[];function o(){const D=e.read();D?f(D):e.once("readable",o)}function u(){e.removeListener("end",i),e.removeListener("error",l),e.removeListener("close",a),e.removeListener("readable",o)}function a(D){me("onclose had error %o",D)}function i(){me("onend")}function l(D){u(),me("onerror %o",D),r(D)}function f(D){s.push(D),n+=D.length;const c=Buffer.concat(s,n);if(c.indexOf(`\r
|
|
44
44
|
\r
|
|
@@ -50,14 +50,14 @@ ${dt}Please open a Bug report with the information above:`),console.error(`${dt}
|
|
|
50
50
|
|
|
51
51
|
${i}`),a.statusCode===500&&(l+=`
|
|
52
52
|
|
|
53
|
-
Check the API status: https://status.openai.com`),new y(l)}return JSON.parse(i)},ji=e=>e.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1"),R=e=>Array.from(new Set(e)),Gi=async(e,t,r,n,s,o,u,a,i,l,f,D,c,p)=>{try{const d=await ki(e,t,r,{model:n,messages:[{role:"system",content:xe(s,a,i,c)},{role:"user",content:o}],temperature:D,top_p:1,frequency_penalty:0,presence_penalty:0,max_tokens:f,stream:!1,n:u},l,p);return R(d.choices.filter(m=>m.message?.content).map(m=>ji(m.message.content)).map(m=>{if(i==="conventional"){const h=/: (\w)/;return m.replace(h,(C,w)=>`: ${w.toLowerCase()}`)}return m}).filter(m=>{switch(i){case"gitmoji":return ai(m);case"conventional":return ii(m);case"":default:return!0}}))}catch(d){const m=d;throw m.code==="ENOTFOUND"?new y(`Error connecting to ${m.hostname} (${m.syscall})`):m}},
|
|
53
|
+
Check the API status: https://status.openai.com`),new y(l)}return JSON.parse(i)},ji=e=>e.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1"),R=e=>Array.from(new Set(e)),Gi=async(e,t,r,n,s,o,u,a,i,l,f,D,c,p)=>{try{const d=await ki(e,t,r,{model:n,messages:[{role:"system",content:xe(s,a,i,c)},{role:"user",content:o}],temperature:D,top_p:1,frequency_penalty:0,presence_penalty:0,max_tokens:f,stream:!1,n:u},l,p);return R(d.choices.filter(m=>m.message?.content).map(m=>ji(m.message.content)).map(m=>{if(i==="conventional"){const h=/: (\w)/;return m.replace(h,(C,w)=>`: ${w.toLowerCase()}`)}return m}).filter(m=>{switch(i){case"gitmoji":return ai(m);case"conventional":return ii(m);case"":default:return!0}}))}catch(d){const m=d;throw m.code==="ENOTFOUND"?new y(`Error connecting to ${m.hostname} (${m.syscall})`):m}},Hi=(e,t)=>{const r=Math.ceil(e),n=Math.floor(t);return Math.floor(Math.random()*(n-r+1))+r};async function*Jr(e){const t=await e;for await(const r of t)yield r}const ge=(e,t)=>e.disabled&&!t.disabled?1:!e.disabled&&t.disabled?-1:0,x="done",Zr="undone";class Ui extends Y{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 G({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.generateStreamChoice$=()=>{const r=this.params.stagedDiff.diff,{locale:n,generate:s,type:o,prompt:u}=this.params.config,a=this.params.config["max-length"],i=this.buildPrompt(n,r,s,a,o,u),l=this.anthropic.completions.create({model:this.params.config.ANTHROPIC_MODEL,max_tokens_to_sample:this.params.config["max-tokens"],temperature:this.params.config.temperature,prompt:`${ue.HUMAN_PROMPT} ${i}${ue.AI_PROMPT}`,stream:!0});let f="";return S(Jr(l)).pipe(jt(D=>f+=D.completion),M(D=>{const c=!!D.stop_reason&&D.stop_reason==="stop_sequence";return{id:this.params.keyName,name:`${this.serviceName} ${f}`,value:`${f}`,isError:!1,description:c?x:Zr,disabled:!c}}))},this.colors={primary:"#AE5630",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Anthropic]"),this.errorPrefix=g.red.bold("[Anthropic]"),this.anthropic=new ue({apiKey:this.params.config.ANTHROPIC_KEY})}generateCommitMessage$(){return H(this.generateMessage()).pipe(T(t=>S(t)),M(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),L(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s,prompt:o}=this.params.config,u=this.params.config["max-length"],a=this.buildPrompt(r,t,n,u,s,o),l=(await this.anthropic.completions.create({model:this.params.config.ANTHROPIC_MODEL,max_tokens_to_sample:this.params.config["max-tokens"],temperature:this.params.config.temperature,prompt:`${ue.HUMAN_PROMPT} ${a}${ue.AI_PROMPT}`})).completion;return R(this.sanitizeMessage(l,this.params.config.type,n))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}generateStreamCommitMessage$(){return this.generateStreamChoice$().pipe(Gt((t,r)=>{if(r.description===x){const o=R(this.sanitizeMessage(r.value,this.params.config.type,this.params.config.generate));return!o||o.length===0?[{id:`${this.params.keyName}_${x}_0`,name:`${this.serviceName} Failed to extract messages from response`,value:"Failed to extract messages from response",isError:!0,description:x,disabled:!0}]:o.map((a,i)=>({id:`${this.params.keyName}_${x}_${i}`,name:`${this.serviceName} ${a}`,value:`${a}`,isError:!1,description:x,disabled:!1}))}return t.find(o=>o.id===r.id)?[...t.map(o=>r.id===o.id?r:o)]:[{...r}]},[]),T(t=>t),L(this.handleError$))}}const{hasOwnProperty:Bt}=Object.prototype,Se=typeof process<"u"&&process.platform==="win32"?`\r
|
|
54
54
|
`:`
|
|
55
|
-
`,xt=(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 s=t.whitespace?" = ":"=";for(const o of Object.keys(e)){const u=e[o];if(u&&Array.isArray(u))for(const a of u)n+=oe(o+"[]")+s+oe(a)+Se;else u&&typeof u=="object"?r.push(o):n+=oe(o)+s+oe(u)+Se}t.section&&n.length&&(n="["+oe(t.section)+"]"+Se+n);for(const o of r){const u=Qr(o).join("\\."),a=(t.section?t.section+".":"")+u,{whitespace:i}=t,l=xt(e[o],{section:a,whitespace:i});n.length&&l.length&&(n+=Se),n+=l}return n},Qr=e=>e.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(t=>t.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),en=e=>{const t=Object.create(null);let r=t,n=null;const s=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,o=e.split(/[\r\n]+/g);for(const a of o){if(!a||a.match(/^\s*[;#]/))continue;const i=a.match(s);if(!i)continue;if(i[1]!==void 0){if(n=Me(i[1]),n==="__proto__"){r=Object.create(null);continue}r=t[n]=t[n]||Object.create(null);continue}const l=Me(i[2]),f=l.length>2&&l.slice(-2)==="[]",D=f?l.slice(0,-2):l;if(D==="__proto__")continue;const c=i[3]?Me(i[4]):!0,p=c==="true"||c==="false"||c==="null"?JSON.parse(c):c;f&&(Bt.call(r,D)?Array.isArray(r[D])||(r[D]=[r[D]]):r[D]=[]),Array.isArray(r[D])?r[D].push(p):r[D]=p}const u=[];for(const a of Object.keys(t)){if(!Bt.call(t,a)||typeof t[a]!="object"||Array.isArray(t[a]))continue;const i=Qr(a);r=t;const l=i.pop(),f=l.replace(/\\\./g,".");for(const D of i)D!=="__proto__"&&((!Bt.call(r,D)||typeof r[D]!="object")&&(r[D]=Object.create(null)),r=r[D]);r===t&&f===l||(r[f]=t[a],u.push(a))}for(const a of u)delete t[a];return t},tn=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),oe=e=>typeof e!="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&tn(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),Me=(e,t)=>{if(e=(e||"").trim(),tn(e)){e.charAt(0)==="'"&&(e=e.slice(1,-1));try{e=JSON.parse(e)}catch{}}else{let r=!1,n="";for(let s=0,o=e.length;s<o;s++){const u=e.charAt(s);if(r)"\\;#".indexOf(u)!==-1?n+=u:n+="\\"+u,r=!1;else{if(";#".indexOf(u)!==-1)break;u==="\\"?r=!0:n+=u}}return r&&(n+="\\"),n.trim()}return e};var Ki={parse:en,decode:en,stringify:xt,encode:xt,safe:oe,unsafe:Me},rn=J(Ki);const nn=e=>B.lstat(e).then(()=>!0,()=>!1),qi=["","conventional","gitmoji"],{hasOwnProperty:zi}=Object.prototype,V=(e,t)=>zi.call(e,t),F=(e,t,r)=>{if(!t)throw new y(`Invalid config property ${e}: ${r}`)},Pe={OPENAI_KEY(e){return e||""},OPENAI_MODEL(e){return!e||e.length===0?"gpt-3.5-turbo":e},OPENAI_URL(e){return e?(F("OPENAI_URL",/^https?:\/\//.test(e),"Must be a valid URL"),e):"https://api.openai.com"},OPENAI_PATH(e){return e||"/v1/chat/completions"},HUGGING_COOKIE(e){return e||""},HUGGING_MODEL(e){return!e||e.length===0?"mistralai/Mixtral-8x7B-Instruct-v0.1":(F("HUGGING_MODEL",["mistralai/Mixtral-8x7B-Instruct-v0.1","meta-llama/Llama-2-70b-chat-hf","NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO","codellama/CodeLlama-70b-Instruct-hf","mistralai/Mistral-7B-Instruct-v0.2","openchat/openchat-3.5-0106"].includes(e),"Invalid model type of hugging"),e)},CLOVAX_COOKIE(e){return e||""},GEMINI_KEY(e){return e||""},GEMINI_MODEL(e){return!e||e.length===0?"gemini-pro":(F("GEMINI_MODEL",["gemini-pro"].includes(e),"Invalid model type of Gemini"),e)},ANTHROPIC_MODEL(e){return!e||e.length===0?"claude-2.1":(F("ANTHROPIC_MODEL",["claude-2.1","claude-2.0","claude-instant-1.2"].includes(e),"Invalid model type of Anthropic"),e)},ANTHROPIC_KEY(e){return e||""},MISTRAL_KEY(e){return e||""},MISTRAL_MODEL(e){return!e||e.length===0?"mistral-tiny":(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)},OLLAMA_MODEL(e){return e||""},OLLAMA_HOST(e){return e?(F("OLLAMA_HOST",/^https?:\/\//.test(e),"Must be a valid URL"),e):"http://localhost:11434"},OLLAMA_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},OLLAMA_STREAM(e){return e?typeof e=="boolean"?e:(F("OLLAMA_STREAM",/^(?:true|false)$/.test(e),"Must be a boolean"),e==="true"):!1},confirm(e){return e?typeof e=="boolean"?e:(F("confirm",/^(?:true|false)$/.test(e),"Must be a boolean"),e==="true"):!1},prompt(e){return e||""},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",qi.includes(e),"Invalid commit type"),e):"conventional"},proxy(e){if(!(!e||e.length===0))return F("proxy",/^https?:\/\//.test(e),"Must be a valid URL"),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},"max-length"(e){if(!e)return 50;F("max-length",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return F("max-length",t>=20,"Must be greater than 20 characters"),t},"max-tokens"(e){return e?(F("max-tokens",/^\d+$/.test(e),"Must be an integer"),Number(e)):200}},Ot=X.join(Ht.homedir(),".aicommit2"),on=async()=>{if(!await nn(Ot))return Object.create(null);const t=await B.readFile(Ot,"utf8");return rn.parse(t)},It=async(e,t)=>{const r=await on(),n={};for(const s of Object.keys(Pe)){const o=Pe[s],u=e?.[s]??r[s];if(t)try{n[s]=o(u)}catch{}else n[s]=o(u)}return n},Yi=async e=>{const t=await on();for(const[r,n]of e){if(!V(Pe,r))throw new y(`Invalid config property: ${r}`);const s=Pe[r](n);t[r]=s}await B.writeFile(Ot,rn.stringify(t),"utf8")};class O{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=Ln.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 Vi extends Y{constructor(t){super(t),this.params=t,this.host="https://clova-x.naver.com",this.cookie="",this.colors={primary:"#00db9b",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[CLOVA X]"),this.errorPrefix=g.red.bold("[CLOVA X]"),this.cookie=this.params.config.CLOVAX_COOKIE}generateCommitMessage$(){return U(this.generateMessage()).pipe(T(t=>S(t)),M((t,r)=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),L(this.handleError$))}async generateMessage(){try{const{locale:t,generate:r,type:n,prompt:s}=this.params.config,o=this.params.config["max-length"],u=this.params.stagedDiff.diff,a=this.buildPrompt(t,u,r,o,n,s);await this.getAllConversationIds();const i=await this.sendMessage(a),{conversationId:l,allText:f}=this.parseSendMessageResult(i);return await this.deleteConversation(l),R(this.sanitizeMessage(f,this.params.config.type,r))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async getAllConversationIds(){const r=(await new O({method:"GET",baseURL:`${this.host}/api/v1/conversations`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).setParams({page:0,size:50,sort:"turnUpdatedTime,DESC"}).execute()).data;if(!r||!r.content)throw new Error("No content on conversations ClovaX");return r.content.length===0?[]:r.content.map(s=>s.conversationId||"").filter(s=>!!s)}async sendMessage(t){const r={text:t,action:"new"},n=new Nn;return n.set("form",new Tn([JSON.stringify(r)],{type:"application/json"})),(await new O({method:"POST",baseURL:`${this.host}/api/v1/generate`,timeout:this.params.config.timeout}).setHeaders({"Content-Type":"multipart/form-data","Content-Length":this.getContentLength(n),Cookie:this.cookie}).setBody(n).execute()).data}parseSendMessageResult(t){const r=/data:{(.*)}/g,n=t.match(r);if(!n)throw new Error("Failed to extract object from generated text");const s=n.map(i=>i.trim().replace(/data:/g,""));if(!s||s.length===0)throw new Error("Cannot extract message");let o="",u="",a="";if(s.map(i=>{try{return JSON.parse(i)}catch{return null}}).filter(i=>!!i).forEach(i=>{if(V(i,"conversationId")){o=i.conversationId;return}if(V(i,"text")){u+=i.text;return}if(V(i,"error")){a=`${i.error}: ${i.type||i.message||""}`;return}}),a)throw new Error(a);if(!o)throw new Error("No conversationId!");if(!u)throw new Error("No allText!");return{conversationId:o,allText:u}}async deleteConversation(t){return(await new O({method:"DELETE",baseURL:`${this.host}/api/v1/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).execute()).data}getContentLength(t){return Array.from(t.entries(),([r,n])=>({[r]:{ContentLength:typeof n=="string"?n.length:n.size}}))}}class Wi extends Y{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=r.message||r.toString(),s=/(\[.*?\]\s*[^[]*)/g,o=[...n.matchAll(s)],u=[];o.forEach(i=>u.push(i[1]));const a=u[1]||"An error occurred";return G({name:`${this.errorPrefix} ${a}`,value:a,isError:!0,disabled:!0})},this.colors={primary:"#0077FF",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Gemini]"),this.errorPrefix=g.red.bold("[Gemini]"),this.genAI=new Rn(this.params.config.GEMINI_KEY)}generateCommitMessage$(){return U(this.generateMessage()).pipe(T(t=>S(t)),M(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),L(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s,prompt:o}=this.params.config,u=this.params.config["max-length"],a=this.buildPrompt(r,t,n,u,s,o),i=this.params.config["max-tokens"],c=(await(await this.genAI.getGenerativeModel({model:this.params.config.GEMINI_MODEL,generationConfig:{maxOutputTokens:i,temperature:this.params.config.temperature}}).generateContent(a)).response).text();return R(this.sanitizeMessage(c,this.params.config.type,n))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}}class Xi extends Y{constructor(t){super(t),this.params=t,this.host="https://huggingface.co",this.cookie="",this.colors={primary:"#FED21F",secondary:"#000"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[HuggingFace]"),this.errorPrefix=g.red.bold("[HuggingFace]"),this.cookie=this.params.config.HUGGING_COOKIE}generateCommitMessage$(){return U(this.generateMessage()).pipe(T(t=>S(t)),M((t,r)=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),L(this.handleError$))}async generateMessage(){try{const{locale:t,generate:r,type:n,prompt:s}=this.params.config,o=this.params.config["max-length"],u=this.params.stagedDiff.diff,a=this.buildPrompt(t,u,r,o,n,s);await this.prepareNewConversation();const{conversationId:i}=await this.getNewConversationId();await this.prepareConversationEvent(i);const{lastMessageId:l}=await this.getConversationInfo(i),f=await this.sendMessage(i,a,l);return await this.deleteConversation(i),R(this.sanitizeHuggingMessage(f,this.params.config.type,r))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}sanitizeHuggingMessage(t,r,n){const s=/{[^{}]*}/g,o=t.match(s);if(!o)throw new Error("Failed to extract object from generated text");let u=null;if(o.forEach((a,i)=>{try{const l=JSON.parse(a);V(l,"type")&&l.type==="finalAnswer"&&(u=l)}catch{}}),!u||!V(u,"text"))throw new Error("Cannot parse finalAnswer");return this.sanitizeMessage(u.text,r,n)}async prepareNewConversation(){return(await new O({method:"POST",baseURL:`${this.host}/api/event`}).setHeaders({"content-type":"application/json",Cookie:this.cookie}).setBody({d:"huggingface.co",n:"pageview",r:"https://huggingface.co/chat/",u:"https://huggingface.co/chat/"}).execute()).data}async prepareConversationEvent(t){return(await new O({method:"POST",baseURL:`${this.host}/api/event`}).setHeaders({"content-type":"application/json",Cookie:this.cookie}).setBody({d:"huggingface.co",n:"pageview",r:"https://huggingface.co/chat/",u:`https://huggingface.co/chat/conversation/${t}`}).execute()).data}async getNewConversationId(){const t=await new O({method:"POST",baseURL:`${this.host}/chat/conversation`,timeout:this.params.config.timeout}).setHeaders({"content-type":"application/json",Cookie:this.cookie,Accept:"*/*",Connection:"keep-alive",Host:"huggingface.co",Origin:"https://huggingface.co"}).setBody({model:this.params.config.HUGGING_MODEL,preprompt:""}).execute();if(!t.data||!t.data.conversationId)throw new Error("No conversationId on Hugging service");return t.data}async getConversationInfo(t){const n=(await new O({method:"GET",baseURL:`${this.host}/chat/conversation/${t}/__data.json`,timeout:this.params.config.timeout}).setParams({"x-sveltekit-invalidated":"11"}).setHeaders({"Content-Type":"application/json",Cookie:this.cookie,Accept:"*/*",Connection:"keep-alive",Referer:"https://huggingface.co/chat/"}).execute()).data;if(!n||!n.nodes||n.nodes.length===0)throw new Error("No Nodes on conversation info");if(!n.nodes[1]||!n.nodes[1].data||n.nodes[1].data.length===0||!n.nodes[1].data[3])throw new Error("No data on node");const u=n.nodes[1]?.data[3];return{conversationInfo:n,lastMessageId:u}}async deleteConversation(t){return await new O({method:"DELETE",baseURL:`${this.host}/chat/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).execute(),(await new O({method:"GET",baseURL:`${this.host}/chat/__data.json`,timeout:this.params.config.timeout}).setParams({"x-sveltekit-trailing-slash":"1","x-sveltekit-invalidated":"10"}).setHeaders({"Content-Type":"application/json",Cookie:this.cookie,Accept:"*/*",Connection:"keep-alive",Referer:"https://huggingface.co/chat/"}).execute()).data}async sendMessage(t,r,n){return(await new O({method:"POST",baseURL:`${this.host}/chat/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({"content-type":"application/json",Cookie:this.cookie,authority:"huggingface.co",accept:"*/*",origin:"https://huggingface.co"}).setBody({files:[],id:n,inputs:r,is_continue:!1,is_retry:!1,use_cache:!1}).execute()).data}}class Ji extends Y{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 G({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#FC4A0A",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[MistralAI]"),this.errorPrefix=g.red.bold("[MistralAI]"),this.apiKey=this.params.config.MISTRAL_KEY}generateCommitMessage$(){return U(this.generateMessage()).pipe(T(t=>S(t)),M(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),L(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s,prompt:o}=this.params.config,u=this.params.config["max-length"],a=this.buildPrompt(r,t,n,u,s,o);await this.checkAvailableModels();const i=await this.createChatCompletions(a);return R(this.sanitizeMessage(i,this.params.config.type,n))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async checkAvailableModels(){if((await this.getAvailableModels()).includes(this.params.config.MISTRAL_MODEL))return!0;throw new Error("Invalid model type of Mistral AI")}async getAvailableModels(){return(await new O({method:"GET",baseURL:`${this.host}/v1/models`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).execute()).data.data.filter(r=>r.object==="model").map(r=>r.id)}async createChatCompletions(t){const n=(await new O({method:"POST",baseURL:`${this.host}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.MISTRAL_MODEL,messages:[{role:"user",content:t}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config["max-tokens"],stream:!1,safe_prompt:!1,random_seed:Ui(10,1e3)}).execute()).data;if(!n.choices||n.choices.length===0||!n.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return n.choices[0].message.content}}class Zi extends Y{constructor(t){super(t),this.params=t,this.host="http://localhost:11434",this.model="",this.handleError$=r=>{if(r.response&&r.response.data?.error)return G({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 G({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.generateStreamChoice$=()=>{const n=`${xe(this.params.config.locale,this.params.config["max-length"],this.params.config.type,this.params.config.prompt)}
|
|
55
|
+
`,xt=(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 s=t.whitespace?" = ":"=";for(const o of Object.keys(e)){const u=e[o];if(u&&Array.isArray(u))for(const a of u)n+=oe(o+"[]")+s+oe(a)+Se;else u&&typeof u=="object"?r.push(o):n+=oe(o)+s+oe(u)+Se}t.section&&n.length&&(n="["+oe(t.section)+"]"+Se+n);for(const o of r){const u=Qr(o).join("\\."),a=(t.section?t.section+".":"")+u,{whitespace:i}=t,l=xt(e[o],{section:a,whitespace:i});n.length&&l.length&&(n+=Se),n+=l}return n},Qr=e=>e.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(t=>t.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),en=e=>{const t=Object.create(null);let r=t,n=null;const s=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,o=e.split(/[\r\n]+/g);for(const a of o){if(!a||a.match(/^\s*[;#]/))continue;const i=a.match(s);if(!i)continue;if(i[1]!==void 0){if(n=Me(i[1]),n==="__proto__"){r=Object.create(null);continue}r=t[n]=t[n]||Object.create(null);continue}const l=Me(i[2]),f=l.length>2&&l.slice(-2)==="[]",D=f?l.slice(0,-2):l;if(D==="__proto__")continue;const c=i[3]?Me(i[4]):!0,p=c==="true"||c==="false"||c==="null"?JSON.parse(c):c;f&&(Bt.call(r,D)?Array.isArray(r[D])||(r[D]=[r[D]]):r[D]=[]),Array.isArray(r[D])?r[D].push(p):r[D]=p}const u=[];for(const a of Object.keys(t)){if(!Bt.call(t,a)||typeof t[a]!="object"||Array.isArray(t[a]))continue;const i=Qr(a);r=t;const l=i.pop(),f=l.replace(/\\\./g,".");for(const D of i)D!=="__proto__"&&((!Bt.call(r,D)||typeof r[D]!="object")&&(r[D]=Object.create(null)),r=r[D]);r===t&&f===l||(r[f]=t[a],u.push(a))}for(const a of u)delete t[a];return t},tn=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),oe=e=>typeof e!="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&tn(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),Me=(e,t)=>{if(e=(e||"").trim(),tn(e)){e.charAt(0)==="'"&&(e=e.slice(1,-1));try{e=JSON.parse(e)}catch{}}else{let r=!1,n="";for(let s=0,o=e.length;s<o;s++){const u=e.charAt(s);if(r)"\\;#".indexOf(u)!==-1?n+=u:n+="\\"+u,r=!1;else{if(";#".indexOf(u)!==-1)break;u==="\\"?r=!0:n+=u}}return r&&(n+="\\"),n.trim()}return e};var Ki={parse:en,decode:en,stringify:xt,encode:xt,safe:oe,unsafe:Me},rn=J(Ki);const nn=e=>B.lstat(e).then(()=>!0,()=>!1),qi=["","conventional","gitmoji"],{hasOwnProperty:zi}=Object.prototype,V=(e,t)=>zi.call(e,t),F=(e,t,r)=>{if(!t)throw new y(`Invalid config property ${e}: ${r}`)},Pe={OPENAI_KEY(e){return e||""},OPENAI_MODEL(e){return!e||e.length===0?"gpt-3.5-turbo":e},OPENAI_URL(e){return e?(F("OPENAI_URL",/^https?:\/\//.test(e),"Must be a valid URL"),e):"https://api.openai.com"},OPENAI_PATH(e){return e||"/v1/chat/completions"},HUGGING_COOKIE(e){return e||""},HUGGING_MODEL(e){return!e||e.length===0?"mistralai/Mixtral-8x7B-Instruct-v0.1":(F("HUGGING_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","google/gemma-1.1-7b-it","mistralai/Mistral-7B-Instruct-v0.2","microsoft/Phi-3-mini-4k-instruct"].includes(e),"Invalid model type of hugging"),e)},CLOVAX_COOKIE(e){return e||""},GEMINI_KEY(e){return e||""},GEMINI_MODEL(e){return!e||e.length===0?"gemini-pro":(F("GEMINI_MODEL",["gemini-pro"].includes(e),"Invalid model type of Gemini"),e)},ANTHROPIC_MODEL(e){return!e||e.length===0?"claude-2.1":(F("ANTHROPIC_MODEL",["claude-2.1","claude-2.0","claude-instant-1.2"].includes(e),"Invalid model type of Anthropic"),e)},ANTHROPIC_KEY(e){return e||""},MISTRAL_KEY(e){return e||""},MISTRAL_MODEL(e){return!e||e.length===0?"mistral-tiny":(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)},OLLAMA_MODEL(e){return e||""},OLLAMA_HOST(e){return e?(F("OLLAMA_HOST",/^https?:\/\//.test(e),"Must be a valid URL"),e):"http://localhost:11434"},OLLAMA_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},OLLAMA_STREAM(e){return e?typeof e=="boolean"?e:(F("OLLAMA_STREAM",/^(?:true|false)$/.test(e),"Must be a boolean"),e==="true"):!1},confirm(e){return e?typeof e=="boolean"?e:(F("confirm",/^(?:true|false)$/.test(e),"Must be a boolean"),e==="true"):!1},prompt(e){return e||""},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",qi.includes(e),"Invalid commit type"),e):"conventional"},proxy(e){if(!(!e||e.length===0))return F("proxy",/^https?:\/\//.test(e),"Must be a valid URL"),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},"max-length"(e){if(!e)return 50;F("max-length",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return F("max-length",t>=20,"Must be greater than 20 characters"),t},"max-tokens"(e){return e?(F("max-tokens",/^\d+$/.test(e),"Must be an integer"),Number(e)):200}},Ot=X.join(Ut.homedir(),".aicommit2"),on=async()=>{if(!await nn(Ot))return Object.create(null);const t=await B.readFile(Ot,"utf8");return rn.parse(t)},It=async(e,t)=>{const r=await on(),n={};for(const s of Object.keys(Pe)){const o=Pe[s],u=e?.[s]??r[s];if(t)try{n[s]=o(u)}catch{}else n[s]=o(u)}return n},Yi=async e=>{const t=await on();for(const[r,n]of e){if(!V(Pe,r))throw new y(`Invalid config property: ${r}`);const s=Pe[r](n);t[r]=s}await B.writeFile(Ot,rn.stringify(t),"utf8")};class O{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=Ln.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 Vi extends Y{constructor(t){super(t),this.params=t,this.host="https://clova-x.naver.com",this.cookie="",this.colors={primary:"#00db9b",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[CLOVA X]"),this.errorPrefix=g.red.bold("[CLOVA X]"),this.cookie=this.params.config.CLOVAX_COOKIE}generateCommitMessage$(){return H(this.generateMessage()).pipe(T(t=>S(t)),M((t,r)=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),L(this.handleError$))}async generateMessage(){try{const{locale:t,generate:r,type:n,prompt:s}=this.params.config,o=this.params.config["max-length"],u=this.params.stagedDiff.diff,a=this.buildPrompt(t,u,r,o,n,s);await this.getAllConversationIds();const i=await this.sendMessage(a),{conversationId:l,allText:f}=this.parseSendMessageResult(i);return await this.deleteConversation(l),R(this.sanitizeMessage(f,this.params.config.type,r))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async getAllConversationIds(){const r=(await new O({method:"GET",baseURL:`${this.host}/api/v1/conversations`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).setParams({page:0,size:50,sort:"turnUpdatedTime,DESC"}).execute()).data;if(!r||!r.content)throw new Error("No content on conversations ClovaX");return r.content.length===0?[]:r.content.map(s=>s.conversationId||"").filter(s=>!!s)}async sendMessage(t){const r={text:t,action:"new"},n=new Nn;return n.set("form",new Tn([JSON.stringify(r)],{type:"application/json"})),(await new O({method:"POST",baseURL:`${this.host}/api/v1/generate`,timeout:this.params.config.timeout}).setHeaders({"Content-Type":"multipart/form-data","Content-Length":this.getContentLength(n),Cookie:this.cookie}).setBody(n).execute()).data}parseSendMessageResult(t){const r=/data:{(.*)}/g,n=t.match(r);if(!n)throw new Error("Failed to extract object from generated text");const s=n.map(i=>i.trim().replace(/data:/g,""));if(!s||s.length===0)throw new Error("Cannot extract message");let o="",u="",a="";if(s.map(i=>{try{return JSON.parse(i)}catch{return null}}).filter(i=>!!i).forEach(i=>{if(V(i,"conversationId")){o=i.conversationId;return}if(V(i,"text")){u+=i.text;return}if(V(i,"error")){a=`${i.error}: ${i.type||i.message||""}`;return}}),a)throw new Error(a);if(!o)throw new Error("No conversationId!");if(!u)throw new Error("No allText!");return{conversationId:o,allText:u}}async deleteConversation(t){return(await new O({method:"DELETE",baseURL:`${this.host}/api/v1/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).execute()).data}getContentLength(t){return Array.from(t.entries(),([r,n])=>({[r]:{ContentLength:typeof n=="string"?n.length:n.size}}))}}class Wi extends Y{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=r.message||r.toString(),s=/(\[.*?\]\s*[^[]*)/g,o=[...n.matchAll(s)],u=[];o.forEach(i=>u.push(i[1]));const a=u[1]||"An error occurred";return G({name:`${this.errorPrefix} ${a}`,value:a,isError:!0,disabled:!0})},this.colors={primary:"#0077FF",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Gemini]"),this.errorPrefix=g.red.bold("[Gemini]"),this.genAI=new Rn(this.params.config.GEMINI_KEY)}generateCommitMessage$(){return H(this.generateMessage()).pipe(T(t=>S(t)),M(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),L(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s,prompt:o}=this.params.config,u=this.params.config["max-length"],a=this.buildPrompt(r,t,n,u,s,o),i=this.params.config["max-tokens"],c=(await(await this.genAI.getGenerativeModel({model:this.params.config.GEMINI_MODEL,generationConfig:{maxOutputTokens:i,temperature:this.params.config.temperature}}).generateContent(a)).response).text();return R(this.sanitizeMessage(c,this.params.config.type,n))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}}class Xi extends Y{constructor(t){super(t),this.params=t,this.host="https://huggingface.co",this.cookie="",this.colors={primary:"#FED21F",secondary:"#000"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[HuggingFace]"),this.errorPrefix=g.red.bold("[HuggingFace]"),this.cookie=this.params.config.HUGGING_COOKIE}generateCommitMessage$(){return H(this.generateMessage()).pipe(T(t=>S(t)),M((t,r)=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),L(this.handleError$))}async generateMessage(){try{const{locale:t,generate:r,type:n,prompt:s}=this.params.config,o=this.params.config["max-length"],u=this.params.stagedDiff.diff,a=this.buildPrompt(t,u,r,o,n,s);await this.prepareNewConversation();const{conversationId:i}=await this.getNewConversationId();await this.prepareConversationEvent(i);const{lastMessageId:l}=await this.getConversationInfo(i),f=await this.sendMessage(i,a,l);return await this.deleteConversation(i),R(this.sanitizeHuggingMessage(f,this.params.config.type,r))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}sanitizeHuggingMessage(t,r,n){const s=/{[^{}]*}/g,o=t.match(s);if(!o)throw new Error("Failed to extract object from generated text");let u=null;if(o.forEach((a,i)=>{try{const l=JSON.parse(a);V(l,"type")&&l.type==="finalAnswer"&&(u=l)}catch{}}),!u||!V(u,"text"))throw new Error("Cannot parse finalAnswer");return this.sanitizeMessage(u.text,r,n)}async prepareNewConversation(){return(await new O({method:"POST",baseURL:`${this.host}/api/event`}).setHeaders({"content-type":"application/json",Cookie:this.cookie}).setBody({d:"huggingface.co",n:"pageview",r:"https://huggingface.co/chat/",u:"https://huggingface.co/chat/"}).execute()).data}async prepareConversationEvent(t){return(await new O({method:"POST",baseURL:`${this.host}/api/event`}).setHeaders({"content-type":"application/json",Cookie:this.cookie}).setBody({d:"huggingface.co",n:"pageview",r:"https://huggingface.co/chat/",u:`https://huggingface.co/chat/conversation/${t}`}).execute()).data}async getNewConversationId(){const t=await new O({method:"POST",baseURL:`${this.host}/chat/conversation`,timeout:this.params.config.timeout}).setHeaders({"content-type":"application/json",Cookie:this.cookie,Accept:"*/*",Connection:"keep-alive",Host:"huggingface.co",Origin:"https://huggingface.co"}).setBody({model:this.params.config.HUGGING_MODEL,preprompt:""}).execute();if(!t.data||!t.data.conversationId)throw new Error("No conversationId on Hugging service");return t.data}async getConversationInfo(t){const n=(await new O({method:"GET",baseURL:`${this.host}/chat/conversation/${t}/__data.json`,timeout:this.params.config.timeout}).setParams({"x-sveltekit-invalidated":"11"}).setHeaders({"Content-Type":"application/json",Cookie:this.cookie,Accept:"*/*",Connection:"keep-alive",Referer:"https://huggingface.co/chat/"}).execute()).data;if(!n||!n.nodes||n.nodes.length===0)throw new Error("No Nodes on conversation info");if(!n.nodes[1]||!n.nodes[1].data||n.nodes[1].data.length===0||!n.nodes[1].data[3])throw new Error("No data on node");const u=n.nodes[1]?.data[3];return{conversationInfo:n,lastMessageId:u}}async deleteConversation(t){return await new O({method:"DELETE",baseURL:`${this.host}/chat/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).execute(),(await new O({method:"GET",baseURL:`${this.host}/chat/__data.json`,timeout:this.params.config.timeout}).setParams({"x-sveltekit-trailing-slash":"1","x-sveltekit-invalidated":"10"}).setHeaders({"Content-Type":"application/json",Cookie:this.cookie,Accept:"*/*",Connection:"keep-alive",Referer:"https://huggingface.co/chat/"}).execute()).data}async sendMessage(t,r,n){return(await new O({method:"POST",baseURL:`${this.host}/chat/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({"content-type":"application/json",Cookie:this.cookie,authority:"huggingface.co",accept:"*/*",origin:"https://huggingface.co"}).setBody({files:[],id:n,inputs:r,is_continue:!1,is_retry:!1,use_cache:!1}).execute()).data}}class Ji extends Y{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 G({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#FC4A0A",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[MistralAI]"),this.errorPrefix=g.red.bold("[MistralAI]"),this.apiKey=this.params.config.MISTRAL_KEY}generateCommitMessage$(){return H(this.generateMessage()).pipe(T(t=>S(t)),M(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),L(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s,prompt:o}=this.params.config,u=this.params.config["max-length"],a=this.buildPrompt(r,t,n,u,s,o);await this.checkAvailableModels();const i=await this.createChatCompletions(a);return R(this.sanitizeMessage(i,this.params.config.type,n))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async checkAvailableModels(){if((await this.getAvailableModels()).includes(this.params.config.MISTRAL_MODEL))return!0;throw new Error("Invalid model type of Mistral AI")}async getAvailableModels(){return(await new O({method:"GET",baseURL:`${this.host}/v1/models`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).execute()).data.data.filter(r=>r.object==="model").map(r=>r.id)}async createChatCompletions(t){const n=(await new O({method:"POST",baseURL:`${this.host}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.MISTRAL_MODEL,messages:[{role:"user",content:t}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config["max-tokens"],stream:!1,safe_prompt:!1,random_seed:Hi(10,1e3)}).execute()).data;if(!n.choices||n.choices.length===0||!n.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return n.choices[0].message.content}}class Zi extends Y{constructor(t){super(t),this.params=t,this.host="http://localhost:11434",this.model="",this.handleError$=r=>{if(r.response&&r.response.data?.error)return G({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 G({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.generateStreamChoice$=()=>{const n=`${xe(this.params.config.locale,this.params.config["max-length"],this.params.config.type,this.params.config.prompt)}
|
|
56
56
|
Please just generate ${this.params.config.generate} commit messages in numbered list format without any explanation.`,s=this.ollama.chat({model:this.model,messages:[{role:"system",content:n},{role:"user",content:`Here are git diff:
|
|
57
|
-
${this.params.stagedDiff.diff}`}],stream:!0});let o="";return S(Jr(s)).pipe(jt(u=>o+=u.message.content),M(u=>({id:this.params.keyName,name:`${this.serviceName} ${o}`,value:`${o}`,isError:!1,description:u.done?x:Zr,disabled:!u.done})))},this.colors={primary:"#FFF",secondary:"#000"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Ollama]"),this.errorPrefix=g.red.bold("[Ollama]"),this.model=this.params.config.OLLAMA_MODEL,this.host=this.params.config.OLLAMA_HOST||"http://localhost:11434",this.ollama=new kn({host:this.host})}generateCommitMessage$(){return this.params.config.OLLAMA_STREAM?this.generateStreamCommitMessage$():
|
|
57
|
+
${this.params.stagedDiff.diff}`}],stream:!0});let o="";return S(Jr(s)).pipe(jt(u=>o+=u.message.content),M(u=>({id:this.params.keyName,name:`${this.serviceName} ${o}`,value:`${o}`,isError:!1,description:u.done?x:Zr,disabled:!u.done})))},this.colors={primary:"#FFF",secondary:"#000"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Ollama]"),this.errorPrefix=g.red.bold("[Ollama]"),this.model=this.params.config.OLLAMA_MODEL,this.host=this.params.config.OLLAMA_HOST||"http://localhost:11434",this.ollama=new kn({host:this.host})}generateCommitMessage$(){return this.params.config.OLLAMA_STREAM?this.generateStreamCommitMessage$():H(this.generateMessage()).pipe(T(t=>S(t)),M(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),L(this.handleError$))}generateStreamCommitMessage$(){return H(this.checkIsAvailableOllama()).pipe(wn(()=>this.generateStreamChoice$()),Gt((t,r)=>{if(r.description===x){const o=R(this.sanitizeMessage(r.value,this.params.config.type,this.params.config.generate));return!o||o.length===0?[{id:`${this.params.keyName}_${x}_0`,name:`${this.serviceName} Failed to extract messages from response`,value:"Failed to extract messages from response",isError:!0,description:x,disabled:!0}]:o.map((a,i)=>({id:`${this.params.keyName}_${x}_${i}`,name:`${this.serviceName} ${a}`,value:`${a}`,isError:!1,description:x,disabled:!1}))}return t.find(o=>o.id===r.id)?[...t.map(o=>r.id===o.id?r:o)]:[{...r}]},[]),T(t=>t),L(this.handleError$))}async generateMessage(){try{await this.checkIsAvailableOllama();const t=await this.createChatCompletions();return R(this.sanitizeMessage(t,this.params.config.type,this.params.config.generate))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async checkIsAvailableOllama(){try{return(await new O({method:"GET",baseURL:`${this.host}`,timeout:this.params.config.OLLAMA_TIMEOUT}).execute()).data}catch(t){throw t.code==="ECONNREFUSED"?new y(`Error connecting to ${this.host}. Please run Ollama or check host`):t}}async createChatCompletions(){const r=`${xe(this.params.config.locale,this.params.config["max-length"],this.params.config.type,this.params.config.prompt)}
|
|
58
58
|
Please just generate ${this.params.config.generate} commit messages in numbered list format without explanation.`;return(await this.ollama.chat({model:this.model,messages:[{role:"system",content:r},{role:"user",content:`Here are git diff:
|
|
59
59
|
${this.params.stagedDiff.diff}`}],stream:!1})).message.content}}class Qi extends Y{constructor(t){super(t),this.params=t,this.handleError$=r=>{let n="An error occurred";if(r.message){n=r.message.split(`
|
|
60
|
-
`)[0];const s=this.extractJSONFromError(r.message);n+=`: ${s.error.message}`}return G({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#74AA9C",secondary:"#FFF"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[ChatGPT]"),this.errorPrefix=g.red.bold("[ChatGPT]")}generateCommitMessage$(){return
|
|
60
|
+
`)[0];const s=this.extractJSONFromError(r.message);n+=`: ${s.error.message}`}return G({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#74AA9C",secondary:"#FFF"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[ChatGPT]"),this.errorPrefix=g.red.bold("[ChatGPT]")}generateCommitMessage$(){return H(Gi(this.params.config.OPENAI_URL,this.params.config.OPENAI_PATH,this.params.config.OPENAI_KEY,this.params.config.OPENAI_MODEL,this.params.config.locale,this.params.stagedDiff.diff,this.params.config.generate,this.params.config["max-length"],this.params.config.type,this.params.config.timeout,this.params.config["max-tokens"],this.params.config.temperature,this.params.config.prompt,this.params.config.proxy)).pipe(T(t=>S(t)),M(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),L(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(s=>JSON.parse(s))):{error:{message:"Unknown error"}}}}class sn{constructor(t,r){this.config=t,this.stagedDiff=r}createAIRequests$(t){return S(t).pipe(bn(r=>{const n={config:this.config,stagedDiff:this.stagedDiff,keyName:r};switch(r){case U.OPEN_AI:return z.create(Qi,n).generateCommitMessage$();case U.GEMINI:return z.create(Wi,n).generateCommitMessage$();case U.ANTHROPIC:return z.create(Ui,n).generateCommitMessage$();case U.HUGGING:return z.create(Xi,n).generateCommitMessage$();case U.CLOVA_X:return z.create(Vi,n).generateCommitMessage$();case U.MISTRAL:return z.create(Ji,n).generateCommitMessage$();case U.OLLAMA:return z.create(Zi,n).generateCommitMessage$();default:const s=g.red.bold(`[${r}]`);return G({name:s+" Invalid AI type",value:"Invalid AI type",isError:!0,disabled:!0})}}))}}const un=async()=>{const{stdout:e,failed:t}=await re("git",["rev-parse","--show-toplevel"],{reject:!1});if(t)throw new y("The current directory must be a Git repository!");return e},St=e=>`:(exclude)${e}`,an=["package-lock.json","pnpm-lock.yaml","*.lock"].map(St),Dn=async e=>{const t=["diff","--cached","--diff-algorithm=minimal"],{stdout:r}=await re("git",[...t,"--name-only",...an,...e?e.map(St):[]]);if(!r)return null;const{stdout:n}=await re("git",[...t,...an,...e?e.map(St):[]]);return{files:r.split(`
|
|
61
61
|
`),diff:n}},ea=e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`;class _e{constructor(){this.title="aicommit2"}printTitle(){console.log(jn.textSync(this.title,{font:"Small"}))}displaySpinner(t){return Ge(t).start()}stopSpinner(t){t.stop(),t.clear()}printStagedFiles(t){console.log(g.bold.green("\u2714 ")+g.bold(`${ea(t.files)}:`)),console.log(`${t.files.map(r=>` ${r}`).join(`
|
|
62
62
|
`)}
|
|
63
63
|
`)}printAnalyzed(){console.log(`
|
|
@@ -66,7 +66,7 @@ ${g.bold.green("\u2714")} ${g.bold("Successfully committed!")}`)}printCopied(){c
|
|
|
66
66
|
${g.bold.green("\u2714")} ${g.bold("Successfully copied! Press 'Ctrl + V' to paste")}`)}printSavedCommitMessage(){console.log(`
|
|
67
67
|
${g.bold.green("\u2714")} ${g.bold("Saved commit message")}`)}printCancelledCommit(){console.log(`
|
|
68
68
|
${g.bold.yellow("\u26A0")} ${g.yellow("Commit cancelled")}`)}printErrorMessage(t){console.log(`
|
|
69
|
-
${g.bold.red("\u2716")} ${g.red(`${t}`)}`)}moveCursorUp(){const t=Ce.createInterface({input:process.stdin,output:process.stdout});Ce.moveCursor(process.stdout,0,-1),t.close()}moveCursorDown(){const t=Ce.createInterface({input:process.stdin,output:process.stdout});Ce.moveCursor(process.stdout,0,1),t.close()}}const ta={isLoading:!1,startOption:{text:"AI is analyzing your changes"}},Mt="No commit messages were generated";class ra{constructor(){this.choices$=new
|
|
69
|
+
${g.bold.red("\u2716")} ${g.red(`${t}`)}`)}moveCursorUp(){const t=Ce.createInterface({input:process.stdin,output:process.stdout});Ce.moveCursor(process.stdout,0,-1),t.close()}moveCursorDown(){const t=Ce.createInterface({input:process.stdin,output:process.stdout});Ce.moveCursor(process.stdout,0,1),t.close()}}const ta={isLoading:!1,startOption:{text:"AI is analyzing your changes"}},Mt="No commit messages were generated";class ra{constructor(){this.choices$=new Ht([]),this.loader$=new Ht(ta),this.destroyed$=new An(1)}initPrompt(){return je.registerPrompt("reactiveListPrompt",Gn),je.prompt({type:"reactiveListPrompt",name:"aicommit2Prompt",message:"Pick a commit message to use: ",emptyMessage:`\u26A0 ${Mt}`,choices$:this.choices$,loader$:this.loader$,loop:!1})}startLoader(){this.loader$.next({isLoading:!0})}refreshChoices(t){const{value:r,isError:n}=t;if(!t||!r)return;if(!t.id){this.choices$.next([...this.currentChoices,t].sort(ge));return}this.checkStreamChoice(t)}checkErrorOnChoices(){if(this.choices$.getValue().map(r=>r).every(r=>r?.isError||r?.disabled)){this.alertNoGeneratedMessage(),this.logEmptyCommitMessage(),process.exit(1);return}this.stopLoaderOnSuccess()}completeSubject(){this.choices$.complete(),this.loader$.complete(),this.destroyed$.next(!0),this.destroyed$.complete()}alertNoGeneratedMessage(){this.loader$.next({isLoading:!1,message:Mt,stopOption:{doneFrame:"\u26A0",color:"yellow"}})}stopLoaderOnSuccess(){this.loader$.next({isLoading:!1,message:"Changes analyzed"})}logEmptyCommitMessage(){console.log(`${g.bold.yellow("\u26A0")} ${g.yellow(`${Mt}`)}`)}checkStreamChoice(t){if(t.description===x){const s=this.currentChoices.find(o=>{const u=o.id||"",a=/\d/.test(u);return t.id?.includes(u)&&!a});if(s){this.choices$.next([...this.currentChoices.filter(o=>o.id!==s.id),t].sort(ge));return}this.choices$.next([...this.currentChoices,t].sort(ge));return}if(this.currentChoices.find(s=>s?.id===t.id)){this.choices$.next(this.currentChoices.map(s=>s?.id===t.id?t:s).sort(ge));return}this.choices$.next([...this.currentChoices,t].sort(ge))}get currentChoices(){return this.choices$.getValue().map(t=>t)}}const k=new _e;var na=async(e,t,r,n,s,o,u,a,i)=>(async()=>{k.printTitle(),await un(),n&&await re("git",["add","--update"]);const l=k.displaySpinner("Detecting staged files"),f=await Dn(r);if(l.stop(),!f)throw new y("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");k.printStagedFiles(f);const{env:D}=process,c=await It({OPENAI_KEY:D.OPENAI_KEY||D.OPENAI_API_KEY,OPENAI_MODEL:D.OPENAI_MODEL||D["openai-model"]||D.openai_model,OPENAI_URL:D.OPENAI_URL||D["openai-url"]||D.OPENAI_URL,GEMINI_KEY:D.GEMINI_KEY||D.GEMINI_API_KEY,GEMINI_MODEL:D.GEMINI_MODEL||D["gemini-model"]||D.gemini_model,ANTHROPIC_KEY:D.ANTHROPIC_KEY||D.ANTHROPIC_API_KEY,ANTHROPIC_MODEL:D.ANTHROPIC_MODEL||D["anthropic-model"]||D.anthropic_model,HUGGING_COOKIE:D.HUGGING_COOKIE||D.HUGGING_API_KEY||D.HF_TOKEN,HUGGING_MODEL:D.HUGGING_MODEL||D["hugging-model"],CLOVAX_COOKIE:D.CLOVAX_COOKIE||D.CLOVA_X_COOKIE,proxy:D.https_proxy||D.HTTPS_PROXY||D.http_proxy||D.HTTP_PROXY,temperature:D.temperature,generate:t?.toString()||D.generate,type:s?.toString()||D.type,locale:e?.toString()||D.locale,prompt:a?.toString()||D.prompt}),p=Object.entries(c).filter(([b])=>kr.includes(b)).filter(([b,Te])=>!!Te).map(([b])=>b);if(p.length===0)throw new y("Please set at least one API key via `aicommit2 config set OPENAI_KEY=<your token>`");const m=new sn(c,f),h=new ra,C=h.initPrompt();h.startLoader();const w=m.createAIRequests$(p).subscribe(b=>h.refreshChoices(b),()=>{},()=>h.checkErrorOnChoices()),I=await C;w.unsubscribe(),h.completeSubject(),k.moveCursorUp();const _=I.aicommit2Prompt?.value;if(!_)throw new y("An error occurred! No selected message");if(u&&(as("copy-paste").copy(_),k.printCopied(),process.exit()),o){const b=Ge("Committing with the generated message").start();await re("git",["commit","-m",_,...i]),b.stop(),b.clear(),k.printCommitted(),process.exit()}const N=await je.prompt([{type:"confirm",name:"confirmationPrompt",message:"Use selected message?",default:!0}]),{confirmationPrompt:se}=N;if(se){const b=Ge("Committing with the generated message").start();await re("git",["commit","-m",_,...i]),b.stop(),b.clear(),k.printCommitted(),process.exit()}k.printCancelledCommit(),process.exit()})().catch(l=>{k.printErrorMessage(l.message),Oe(l),process.exit(1)}),oa=cr({name:"config",parameters:["<mode>","<key=value...>"]},e=>{(async()=>{const{mode:t,keyValue:r}=e._;if(t==="get"){const n=await It({},!0);for(const s of r)V(n,s)&&console.log(`${s}=${n[s]}`);return}if(t==="set"){await Yi(r.map(n=>n.split("=")));return}throw new y(`Invalid mode: ${t}`)})().catch(t=>{new _e().printErrorMessage(t.message),Oe(t),process.exit(1)})});const cn="prepare-commit-msg",ln=`.git/hooks/${cn}`,Ne=Pn(new URL("cli.mjs",import.meta.url)),sa=process.argv[1].replace(/\\/g,"/").endsWith(`/${ln}`),fn=process.platform==="win32",pn=`
|
|
70
70
|
#!/usr/bin/env node
|
|
71
71
|
import(${JSON.stringify(_n(Ne))})
|
|
72
72
|
`.trim();var ua=cr({name:"hook",parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await un(),{installUninstall:r}=e._,n=X.join(t,ln),s=await nn(n);if(r==="install"){if(s){if(await B.realpath(n).catch(()=>{})===Ne){console.warn("The hook is already installed");return}throw new y(`A different ${cn} hook seems to be installed. Please remove it before installing aicommit2.`)}await B.mkdir(X.dirname(n),{recursive:!0}),fn?await B.writeFile(n,pn):(await B.symlink(Ne,n,"file"),await B.chmod(n,493)),console.log(`${g.green("\u2714")} Hook installed`);return}if(r==="uninstall"){if(!s){console.warn("Hook is not installed");return}if(fn){if(await B.readFile(n,"utf8")!==pn){console.warn("Hook is not installed");return}}else if(await B.realpath(n)!==Ne){console.warn("Hook is not installed");return}await B.rm(n),console.log(`${g.green("\u2714")} Hook uninstalled`);return}throw new y(`Invalid mode: ${r}`)})().catch(t=>{console.error(`${g.red("\u2716")} ${t.message}`),Oe(t),process.exit(1)})});const[Pt,ia]=process.argv.slice(2);var aa=()=>(async()=>{if(!Pt)throw new y('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(ia)return;const e=await Dn();if(!e)return;const t=new _e;t.printTitle();const{env:r}=process,n=await It({proxy:r.https_proxy||r.HTTPS_PROXY||r.http_proxy||r.HTTP_PROXY}),s=Object.entries(n).filter(([p])=>kr.includes(p)).filter(([p,d])=>!!d).map(([p])=>p);if(s.length===0)throw new y("Please set at least one API key via `aicommit2 config set OPENAI_KEY=<your token>`");const u=new sn(n,e),a=t.displaySpinner("The AI is analyzing your changes");let i;try{i=await vn(u.createAIRequests$(s).pipe($n(p=>!p.isError),M(p=>p.value),Bn()))}finally{a.stop(),a.clear(),t.printAnalyzed()}const f=await B.readFile(Pt,"utf8")!=="",D=i.length>1;let c="";f&&(c=`# \u{1F916} AI generated commit${D?"s":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aicommit2",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.3",
|
|
4
4
|
"description": "A Reactive CLI that generates git commit messages with various AI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"aicommit",
|
|
11
11
|
"aicommits",
|
|
12
12
|
"aicommit2",
|
|
13
|
+
"aicommits2",
|
|
13
14
|
"openai",
|
|
14
15
|
"huggingface",
|
|
15
16
|
"hugging face",
|
|
@@ -20,7 +21,8 @@
|
|
|
20
21
|
"gemini",
|
|
21
22
|
"generative-ai",
|
|
22
23
|
"mistral",
|
|
23
|
-
"ollama"
|
|
24
|
+
"ollama",
|
|
25
|
+
"llama3"
|
|
24
26
|
],
|
|
25
27
|
"license": "MIT",
|
|
26
28
|
"repository": "tak-bro/aicommit2",
|
|
@@ -36,7 +38,7 @@
|
|
|
36
38
|
"dependencies": {
|
|
37
39
|
"@anthropic-ai/sdk": "^0.20.4",
|
|
38
40
|
"@dqbd/tiktoken": "^1.0.2",
|
|
39
|
-
"@google/generative-ai": "^0.
|
|
41
|
+
"@google/generative-ai": "^0.9.0",
|
|
40
42
|
"@inquirer/prompts": "^3.0.0",
|
|
41
43
|
"axios": "^1.6.8",
|
|
42
44
|
"chalk": "^5.3.0",
|