aicommit2 1.10.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +27 -32
  2. package/dist/cli.mjs +89 -65
  3. package/package.json +2 -5
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <div align="center">
2
2
  <div>
3
- <img src="https://github.com/tak-bro/aicommit2/blob/main/img/demo-min.gif?raw=true" alt="AICommit2"/>
3
+ <img src="https://github.com/tak-bro/aicommit2/blob/main/img/demo_body_min.gif?raw=true" alt="AICommit2"/>
4
4
  <h1 align="center">AICommit2</h1>
5
5
  </div>
6
6
  <p>
@@ -35,7 +35,6 @@ _aicommit2_ streamlines interactions with various AI, enabling users to request
35
35
  - [Cohere](https://cohere.com/)
36
36
  - [Groq](https://groq.com/)
37
37
  - [Huggingface **(Unofficial)**](https://huggingface.co/chat/)
38
- - [Clova X **(Unofficial)**](https://clova-x.naver.com/)
39
38
 
40
39
  ### Local
41
40
 
@@ -96,12 +95,6 @@ aicommit2 config set GROQ_KEY=<your key>
96
95
  aicommit2 config set HUGGING_COOKIE="<your browser cookie>"
97
96
  ```
98
97
 
99
- - [Clova X **(Unofficial)**](https://github.com/tak-bro/aicommit2?tab=readme-ov-file#how-to-get-cookieunofficial-api)
100
- ```shell
101
- # Please be cautious of Escape characters(\", \') in browser cookie string
102
- aicommit2 config set CLOVAX_COOKIE="<your browser cookie>"
103
- ```
104
-
105
98
  This will create a `.aicommit2` file in your home directory.
106
99
 
107
100
  > You may need to create an account and set up billing.
@@ -144,7 +137,7 @@ aicommit2
144
137
 
145
138
  This CLI tool runs `git diff` to grab all your latest code changes, sends them to configured AI, then returns the AI generated commit message.
146
139
 
147
- > If the diff becomes too large, AI will not function properly. If you encounter an error saying the message is too long or it's not a valid commit message, try reducing the commit unit.
140
+ > If the diff becomes too large, AI will not function properly. If you encounter an error saying the message is too long or it's not a valid commit message, **try reducing the commit unit**.
148
141
 
149
142
  ## Usage
150
143
 
@@ -324,11 +317,9 @@ aicommit2 config set OPENAI_KEY=<your-api-key> generate=3 locale=en
324
317
  | `GROQ_MODEL` | `gemma-7b-it` | The Groq model name to use |
325
318
  | `HUGGING_COOKIE` | N/A | The HuggingFace Cookie string |
326
319
  | `HUGGING_MODEL` | `mistralai/Mixtral-8x7B-Instruct-v0.1` | The HuggingFace Model to use |
327
- | `CLOVAX_COOKIE` | N/A | The Clova X Cookie string |
328
320
  | `OLLAMA_MODEL` | N/A | The Ollama Model. It should be downloaded your local |
329
321
  | `OLLAMA_HOST` | `http://localhost:11434` | The Ollama Host |
330
322
  | `OLLAMA_TIMEOUT` | `100_000` ms | Request timeout for the Ollama |
331
- | `OLLAMA_STREAM` | N/A | Whether to make stream requests (**experimental feature**) |
332
323
  | `locale` | `en` | Locale for the generated commit messages |
333
324
  | `generate` | `1` | Number of commit messages to generate |
334
325
  | `type` | `conventional` | Type of commit message to generate |
@@ -339,6 +330,7 @@ aicommit2 config set OPENAI_KEY=<your-api-key> generate=3 locale=en
339
330
  | `temperature` | `0.7` | The temperature (0.0-2.0) is used to control the randomness of the output (for **Open AI, Anthropic, Gemini, Mistral, Codestral**) |
340
331
  | `prompt` | N/A | Additional prompt to let users fine-tune provided prompt |
341
332
  | `logging` | `false` | Whether to log AI responses for debugging (true or false) |
333
+ | `ignoreBody` | `false` | Whether the commit message includes body (true or false) |
342
334
 
343
335
  > **Currently, options are set universally. However, there are plans to develop the ability to set individual options in the future.**
344
336
 
@@ -353,7 +345,6 @@ aicommit2 config set OPENAI_KEY=<your-api-key> generate=3 locale=en
353
345
  | **Cohere** | ✓ | ✓ | ✓ | | | ✓ | ✓ | ✓ | ✓ |
354
346
  | **Groq** | ✓ | ✓ | ✓ | | ✓ | ✓ | | | ✓ |
355
347
  | **Huggingface** | ✓ | ✓ | ✓ | | ✓ | ✓ | | | ✓ |
356
- | **Clova X** | ✓ | ✓ | ✓ | | ✓ | ✓ | | | ✓ |
357
348
  | **Ollama** | ✓ | ✓ | ✓ | | ⚠<br/>(OLLAMA_TIMEOUT) | ✓ | | ✓ | ✓ |
358
349
 
359
350
 
@@ -457,12 +448,36 @@ The log files will be stored in the `~/.aicommit2_log` directory(user's home).
457
448
 
458
449
  ![log-path](https://github.com/tak-bro/aicommit2/blob/main/img/log_path.png?raw=true)
459
450
 
451
+ ```sh
452
+ aicommit2 config set logging="true"
453
+ ```
454
+
460
455
  - You can remove all logs below comamnd.
461
456
 
462
457
  ```sh
463
458
  aicommit2 log removeAll
464
459
  ```
465
460
 
461
+ ##### ignoreBody
462
+
463
+ Default: `false`
464
+
465
+ This option determines whether the commit message includes body. If you don't want to include body in message, you can set it to `true`.
466
+
467
+ ```sh
468
+ aicommit2 config set ignoreBody="true"
469
+ ```
470
+
471
+ ![ignore_body_true](https://github.com/tak-bro/aicommit2/blob/main/img/ignore_body_true.png?raw=true)
472
+
473
+
474
+ ```sh
475
+ aicommit2 config set ignoreBody="false"
476
+ ```
477
+
478
+ ![ignore_body_false](https://github.com/tak-bro/aicommit2/blob/main/img/ignore_body_false.png?raw=true)
479
+
480
+
466
481
  ### Ollama
467
482
 
468
483
  ##### OLLAMA_MODEL
@@ -494,16 +509,6 @@ Request timeout for the Ollama. Default OLLAMA_TIMEOUT is **100 seconds** becaus
494
509
  aicommit2 config set OLLAMA_TIMEOUT=<timout>
495
510
  ```
496
511
 
497
- ##### OLLAMA_STREAM
498
-
499
- <img src="https://github.com/tak-bro/aicommit2/blob/main/img/ollama_stream-min.gif?raw=true" alt="OLLAMA_STREAM" />
500
-
501
- Default: `false`
502
-
503
- Determines whether the application will make stream requests to Ollama. **Allow this option only when using Ollama alone.**
504
-
505
- > This feature is experimental and may not be fully stable.
506
-
507
512
  ### OPEN AI
508
513
 
509
514
  ##### OPENAI_KEY
@@ -597,8 +602,6 @@ Supported:
597
602
  - `mistral-large-latest`
598
603
  - `mistral-large-2402`
599
604
  - `mistral-embed`
600
- - `codestral-latest`
601
- - `codestral-2405`
602
605
 
603
606
  > The models mentioned above are subject to change.
604
607
 
@@ -676,12 +679,6 @@ Supported:
676
679
 
677
680
  > The models mentioned above are subject to change.
678
681
 
679
- ### Clova X
680
-
681
- ##### CLOVAX_COOKIE
682
-
683
- The [Clova X](https://clova-x.naver.com/) Cookie. Please check [how to get cookie](https://github.com/tak-bro/aicommit2?tab=readme-ov-file#how-to-get-cookieunofficial-api)
684
-
685
682
  ## Upgrading
686
683
 
687
684
  Check the installed version with:
@@ -749,8 +746,6 @@ aicommit2
749
746
 
750
747
  ![how-to-get-cookie](https://github.com/tak-bro/aicommit2/assets/7614353/66f2994d-23d9-4c88-a113-f2d3dc5c0669)
751
748
 
752
- ![how-to-get-clova-x-cookie](https://github.com/tak-bro/aicommit2/assets/7614353/dd2202d6-ca1a-4a8a-ba2f-b5703a19c71d)
753
-
754
749
  ## Disclaimer
755
750
 
756
751
  This project utilizes certain functionalities or data from external APIs, but it is important to note that it is not officially affiliated with or endorsed by the providers of those APIs. The use of external APIs is at the sole discretion and risk of the user.
package/dist/cli.mjs CHANGED
@@ -1,81 +1,105 @@
1
1
  #!/usr/bin/env node
2
- import ke from"tty";import{createRequire as Pn}from"module";import{Buffer as _n}from"node:buffer";import te from"node:path";import Gt,{ChildProcess as Ln}from"node:child_process";import H from"node:process";import Tn from"child_process";import Y from"path";import J from"fs";import{fileURLToPath as jt}from"node:url";import Nn,{constants as Ht}from"node:os";import Ut from"assert";import Kt from"events";import{createWriteStream as Rn,createReadStream as kn}from"node:fs";import Gn from"buffer";import Ge from"stream";import qt from"util";import{debuglog as jn}from"node:util";import je from"inquirer";import He from"ora";import g from"chalk";import{of as k,from as O,filter as zt,map as B,tap as Yt,concatMap as L,catchError as T,scan as Wt,switchMap as Hn,mergeMap as Vt,BehaviorSubject as Xt,ReplaySubject as Un,lastValueFrom as Kn,toArray as qn}from"rxjs";import zn from"@anthropic-ai/sdk";import{fromPromise as G}from"rxjs/internal/observable/innerFrom";import Ue from"os";import{xxh64 as Yn}from"@pacote/xxhash";import Wn from"http";import Vn from"https";import"@dqbd/tiktoken";import Xn from"net";import Jn from"tls";import Qn,{fileURLToPath as Zn,pathToFileURL as eo}from"url";import{FormData as to,Blob as ro}from"formdata-node";import S from"fs/promises";import no from"axios";import{CohereClient as oo,CohereTimeoutError as so}from"cohere-ai";import{GoogleGenerativeAI as uo}from"@google/generative-ai";import io from"groq-sdk";import{Ollama as ao}from"ollama";import we from"readline";import co from"figlet";import Do from"inquirer-reactive-list-prompt";import{rm as lo}from"node:fs/promises";const fo="known-flag",po="unknown-flag",mo="argument",{stringify:le}=JSON,ho=/\B([A-Z])/g,go=e=>e.replace(ho,"-$1").toLowerCase(),{hasOwnProperty:Co}=Object.prototype,fe=(e,t)=>Co.call(e,t),Eo=e=>Array.isArray(e),Jt=e=>typeof e=="function"?[e,!1]:Eo(e)?[e[0],!0]:Jt(e.type),Fo=(e,t)=>e===Boolean?t!=="false":t,yo=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),bo=/[\s.:=]/,Ao=e=>{const t=`Flag name ${le(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(bo);if(r)throw new Error(`${t} cannot contain ${le(r?.[0])}`)},wo=e=>{const t={},r=(n,s)=>{if(fe(t,n))throw new Error(`Duplicate flags named ${le(n)}`);t[n]=s};for(const n in e){if(!fe(e,n))continue;Ao(n);const s=e[n],o=[[],...Jt(s),s];r(n,o);const u=go(n);if(n!==u&&r(u,o),"alias"in s&&typeof s.alias=="string"){const{alias:a}=s,i=`Flag alias ${le(a)} for flag ${le(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},$o=(e,t)=>{const r={};for(const n in e){if(!fe(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},$e="--",vo=/[.:=]/,xo=/^-{1,2}\w/,Oo=e=>{if(!xo.test(e))return;const t=!e.startsWith($e);let r=e.slice(t?1:2),n;const s=r.match(vo);if(s){const{index:o}=s;n=r.slice(o+1),r=r.slice(0,o)}return[r,n,t]},Bo=(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===$e){s();const i=e.slice(o+1);r?.(i,[o],!0);break}const a=Oo(u);if(a){if(s(),!t)continue;const[i,l,f]=a;if(f)for(let c=0;c<i.length;c+=1){s();const D=c===i.length-1;n=t(i[c],D?l:void 0,[o,c+1,D])}else n=t(i,l,[o])}else s(u,[o])&&r?.([u],[o])}s()},Mo=(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)}},So=(e,t=process.argv.slice(2),{ignore:r}={})=>{const n=[],s=wo(e),o={},u=[];return u[$e]=[],Bo(t,{onFlag(a,i,l){const f=fe(s,a);if(!r?.(f?fo:po,a,i)){if(f){const[c,D]=s[a],p=Fo(D,i),d=(h,m)=>{n.push(l),m&&n.push(m),c.push(yo(D,h||""))};return p===void 0?d:d(p)}fe(o,a)||(o[a]=[]),o[a].push(i===void 0?!0:i),n.push(l)}},onArgument(a,i,l){r?.(mo,t[i[0]])||(u.push(...a),l?(u[$e]=a,t.splice(i[0])):n.push(i))}}),Mo(t,n),{flags:$o(e,s),unknownFlags:o,_:u}};var Io=Object.create,ve=Object.defineProperty,Po=Object.defineProperties,_o=Object.getOwnPropertyDescriptor,Lo=Object.getOwnPropertyDescriptors,To=Object.getOwnPropertyNames,Qt=Object.getOwnPropertySymbols,No=Object.getPrototypeOf,Zt=Object.prototype.hasOwnProperty,Ro=Object.prototype.propertyIsEnumerable,er=(e,t,r)=>t in e?ve(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,xe=(e,t)=>{for(var r in t||(t={}))Zt.call(t,r)&&er(e,r,t[r]);if(Qt)for(var r of Qt(t))Ro.call(t,r)&&er(e,r,t[r]);return e},Ke=(e,t)=>Po(e,Lo(t)),ko=e=>ve(e,"__esModule",{value:!0}),Go=(e,t)=>()=>(e&&(t=e(e=0)),t),jo=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ho=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of To(t))!Zt.call(e,s)&&(r||s!=="default")&&ve(e,s,{get:()=>t[s],enumerable:!(n=_o(t,s))||n.enumerable});return e},Uo=(e,t)=>Ho(ko(ve(e!=null?Io(No(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),x=Go(()=>{}),Ko=jo((e,t)=>{x(),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}});x(),x(),x();var qo=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}};x(),x(),x(),x(),x();function zo({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 tr(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(zo(),"")}x();function Yo(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 Wo=Uo(Ko(),1);function Q(e){if(typeof e!="string"||e.length===0||(e=tr(e),e.length===0))return 0;e=e.replace((0,Wo.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+=Yo(n)?2:1)}return t}var rr=e=>Math.max(...e.split(`
3
- `).map(Q)),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=rr(r[o]);u>t[o]&&(t[o]=u)}}return t};x();var nr=/^\d+%$/,or={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},Xo=(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"&&nr.test(o)){n.push(Ke(xe({},or),{width:o,contentWidth:e[s]}));continue}if(o&&typeof o=="object"){let u=Ke(xe(xe({},or),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 Jo(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"&&nr.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 sr=()=>Object.assign([],{columns:0});function Qo(e,t){let r=[sr()],[n]=r;for(let s of e){let o=s.width+s.horizontalPadding;n.columns+o>t&&(n=sr(),r.push(n)),n.push(s),n.columns+=o}for(let s of r){let o=s.reduce((D,p)=>D+p.width+p.horizontalPadding,0),u=t-o;if(u===0)continue;let a=s.filter(D=>"autoOverflow"in D),i=a.filter(D=>D.autoOverflow>0),l=i.reduce((D,p)=>D+p.autoOverflow,0),f=Math.min(l,u);for(let D of i){let p=Math.floor(D.autoOverflow/l*f);D.width+=p,u-=p}let c=Math.floor(u/a.length);for(let D=0;D<a.length;D+=1){let p=a[D];D===a.length-1?p.width+=u:p.width+=c,u-=c}}return r}function Zo(e,t,r){let n=Xo(r,t);return Jo(n,e),Qo(n,e)}x(),x(),x();var qe=10,ur=(e=0)=>t=>`\x1B[${t+e}m`,ir=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,ar=(e=0)=>(t,r,n)=>`\x1B[${38+e};2;${t};${r};${n}m`;function es(){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=ur(),t.color.ansi256=ir(),t.color.ansi16m=ar(),t.bgColor.ansi=ur(qe),t.bgColor.ansi256=ir(qe),t.bgColor.ansi16m=ar(qe),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 ts=es(),rs=ts,Oe=new Set(["\x1B","\x9B"]),ns=39,ze="\x07",cr="[",os="]",Dr="m",Ye=`${os}8;;`,lr=e=>`${Oe.values().next().value}${cr}${e}${Dr}`,fr=e=>`${Oe.values().next().value}${Ye}${e}${ze}`,ss=e=>e.split(" ").map(t=>Q(t)),We=(e,t,r)=>{let n=[...t],s=!1,o=!1,u=Q(tr(e[e.length-1]));for(let[a,i]of n.entries()){let l=Q(i);if(u+l<=r?e[e.length-1]+=i:(e.push(i),u=0),Oe.has(i)&&(s=!0,o=n.slice(a+1).join("").startsWith(Ye)),s){o?i===ze&&(s=!1,o=!1):i===Dr&&(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())},us=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(Q(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},is=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",s,o,u=ss(e),a=[""];for(let[l,f]of e.split(" ").entries()){r.trim!==!1&&(a[a.length-1]=a[a.length-1].trimStart());let c=Q(a[a.length-1]);if(l!==0&&(c>=t&&(r.wordWrap===!1||r.trim===!1)&&(a.push(""),c=0),(c>0||r.trim===!1)&&(a[a.length-1]+=" ",c++)),r.hard&&u[l]>t){let D=t-c,p=1+Math.floor((u[l]-D-1)/t);Math.floor((u[l]-1)/t)<p&&a.push(""),We(a,f,t);continue}if(c+u[l]>t&&c>0&&u[l]>0){if(r.wordWrap===!1&&c<t){We(a,f,t);continue}a.push("")}if(c+u[l]>t&&r.wordWrap===!1){We(a,f,t);continue}a[a.length-1]+=f}r.trim!==!1&&(a=a.map(l=>us(l)));let i=[...a.join(`
4
- `)];for(let[l,f]of i.entries()){if(n+=f,Oe.has(f)){let{groups:D}=new RegExp(`(?:\\${cr}(?<code>\\d+)m|\\${Ye}(?<uri>.*)${ze})`).exec(i.slice(l).join(""))||{groups:{}};if(D.code!==void 0){let p=Number.parseFloat(D.code);s=p===ns?void 0:p}else D.uri!==void 0&&(o=D.uri.length===0?void 0:D.uri)}let c=rs.codes.get(Number(s));i[l+1]===`
5
- `?(o&&(n+=fr("")),s&&c&&(n+=lr(c))):f===`
6
- `&&(s&&c&&(n+=lr(s)),o&&(n+=fr(o)))}return n};function as(e,t,r){return String(e).normalize().replace(/\r\n/g,`
2
+ import Re from"tty";import{createRequire as An}from"module";import{Buffer as wn}from"node:buffer";import V from"node:path";import Nt,{ChildProcess as vn}from"node:child_process";import P from"node:process";import $n from"child_process";import z from"path";import q from"fs";import{fileURLToPath as kt}from"node:url";import Bn,{constants as jt}from"node:os";import Gt from"assert";import Ht from"events";import{createWriteStream as xn,createReadStream as On}from"node:fs";import Mn from"buffer";import Ne from"stream";import Ut from"util";import{debuglog as Sn}from"node:util";import ke from"inquirer";import je from"ora";import g from"chalk";import{of as M,concatMap as k,from as S,map as _,catchError as j,mergeMap as Kt,BehaviorSubject as zt,ReplaySubject as In,lastValueFrom as Pn,filter as _n,toArray as Tn}from"rxjs";import Ln from"@anthropic-ai/sdk";import{fromPromise as G}from"rxjs/internal/observable/innerFrom";import Ge from"os";import{xxh64 as Rn}from"@pacote/xxhash";import Nn from"axios";import{CohereClient as kn,CohereTimeoutError as jn}from"cohere-ai";import{GoogleGenerativeAI as Gn}from"@google/generative-ai";import Hn from"groq-sdk";import x from"fs/promises";import{Ollama as Un}from"ollama";import Kn from"http";import zn from"https";import qn from"net";import Yn from"tls";import Wn,{fileURLToPath as Vn,pathToFileURL as Jn}from"url";import be from"readline";import Xn from"figlet";import Qn from"inquirer-reactive-list-prompt";import{rm as Zn}from"node:fs/promises";const eo="known-flag",to="unknown-flag",ro="argument",{stringify:ue}=JSON,no=/\B([A-Z])/g,oo=e=>e.replace(no,"-$1").toLowerCase(),{hasOwnProperty:so}=Object.prototype,ie=(e,t)=>so.call(e,t),uo=e=>Array.isArray(e),qt=e=>typeof e=="function"?[e,!1]:uo(e)?[e[0],!0]:qt(e.type),io=(e,t)=>e===Boolean?t!=="false":t,ao=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),co=/[\s.:=]/,Do=e=>{const t=`Flag name ${ue(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(co);if(r)throw new Error(`${t} cannot contain ${ue(r?.[0])}`)},lo=e=>{const t={},r=(n,s)=>{if(ie(t,n))throw new Error(`Duplicate flags named ${ue(n)}`);t[n]=s};for(const n in e){if(!ie(e,n))continue;Do(n);const s=e[n],o=[[],...qt(s),s];r(n,o);const u=oo(n);if(n!==u&&r(u,o),"alias"in s&&typeof s.alias=="string"){const{alias:i}=s,c=`Flag alias ${ue(i)} for flag ${ue(n)}`;if(i.length===0)throw new Error(`${c} cannot be empty`);if(i.length>1)throw new Error(`${c} must be a single character`);r(i,o)}}return t},po=(e,t)=>{const r={};for(const n in e){if(!ie(e,n))continue;const[s,,o,u]=t[n];if(s.length===0&&"default"in u){let{default:i}=u;typeof i=="function"&&(i=i()),r[n]=i}else r[n]=o?s:s.pop()}return r},Ae="--",fo=/[.:=]/,mo=/^-{1,2}\w/,ho=e=>{if(!mo.test(e))return;const t=!e.startsWith(Ae);let r=e.slice(t?1:2),n;const s=r.match(fo);if(s){const{index:o}=s;n=r.slice(o+1),r=r.slice(0,o)}return[r,n,t]},go=(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===Ae){s();const c=e.slice(o+1);r?.(c,[o],!0);break}const i=ho(u);if(i){if(s(),!t)continue;const[c,l,p]=i;if(p)for(let a=0;a<c.length;a+=1){s();const D=a===c.length-1;n=t(c[a],D?l:void 0,[o,a+1,D])}else n=t(c,l,[o])}else s(u,[o])&&r?.([u],[o])}s()},Co=(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)}},Eo=(e,t=process.argv.slice(2),{ignore:r}={})=>{const n=[],s=lo(e),o={},u=[];return u[Ae]=[],go(t,{onFlag(i,c,l){const p=ie(s,i);if(!r?.(p?eo:to,i,c)){if(p){const[a,D]=s[i],d=io(D,c),f=(h,m)=>{n.push(l),m&&n.push(m),a.push(ao(D,h||""))};return d===void 0?f:f(d)}ie(o,i)||(o[i]=[]),o[i].push(c===void 0?!0:c),n.push(l)}},onArgument(i,c,l){r?.(ro,t[c[0]])||(u.push(...i),l?(u[Ae]=i,t.splice(c[0])):n.push(c))}}),Co(t,n),{flags:po(e,s),unknownFlags:o,_:u}};var Fo=Object.create,we=Object.defineProperty,yo=Object.defineProperties,bo=Object.getOwnPropertyDescriptor,Ao=Object.getOwnPropertyDescriptors,wo=Object.getOwnPropertyNames,Yt=Object.getOwnPropertySymbols,vo=Object.getPrototypeOf,Wt=Object.prototype.hasOwnProperty,$o=Object.prototype.propertyIsEnumerable,Vt=(e,t,r)=>t in e?we(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ve=(e,t)=>{for(var r in t||(t={}))Wt.call(t,r)&&Vt(e,r,t[r]);if(Yt)for(var r of Yt(t))$o.call(t,r)&&Vt(e,r,t[r]);return e},He=(e,t)=>yo(e,Ao(t)),Bo=e=>we(e,"__esModule",{value:!0}),xo=(e,t)=>()=>(e&&(t=e(e=0)),t),Oo=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Mo=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of wo(t))!Wt.call(e,s)&&(r||s!=="default")&&we(e,s,{get:()=>t[s],enumerable:!(n=bo(t,s))||n.enumerable});return e},So=(e,t)=>Mo(Bo(we(e!=null?Fo(vo(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),$=xo(()=>{}),Io=Oo((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 Po=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 _o({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 Jt(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(_o(),"")}$();function To(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 Lo=So(Io(),1);function Y(e){if(typeof e!="string"||e.length===0||(e=Jt(e),e.length===0))return 0;e=e.replace((0,Lo.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+=To(n)?2:1)}return t}var Xt=e=>Math.max(...e.split(`
3
+ `).map(Y)),Ro=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=Xt(r[o]);u>t[o]&&(t[o]=u)}}return t};$();var Qt=/^\d+%$/,Zt={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},No=(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"&&Qt.test(o)){n.push(He(ve({},Zt),{width:o,contentWidth:e[s]}));continue}if(o&&typeof o=="object"){let u=He(ve(ve({},Zt),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 ko(e,t){for(let r of e){let{width:n}=r;if(n==="content-width"&&(r.width=r.contentWidth),n==="auto"){let c=Math.min(20,r.contentWidth);r.width=c,r.autoOverflow=r.contentWidth-c}if(typeof n=="string"&&Qt.test(n)){let c=Number.parseFloat(n.slice(0,-1))/100;r.width=Math.floor(t*c)-(r.paddingLeft+r.paddingRight)}let{horizontalPadding:s}=r,o=1,u=o+s;if(u>=t){let c=u-t,l=Math.ceil(r.paddingLeft/s*c),p=c-l;r.paddingLeft-=l,r.paddingRight-=p,r.horizontalPadding=r.paddingLeft+r.paddingRight}r.paddingLeftString=r.paddingLeft?" ".repeat(r.paddingLeft):"",r.paddingRightString=r.paddingRight?" ".repeat(r.paddingRight):"";let i=t-r.horizontalPadding;r.width=Math.max(Math.min(r.width,i),o)}}var er=()=>Object.assign([],{columns:0});function jo(e,t){let r=[er()],[n]=r;for(let s of e){let o=s.width+s.horizontalPadding;n.columns+o>t&&(n=er(),r.push(n)),n.push(s),n.columns+=o}for(let s of r){let o=s.reduce((D,d)=>D+d.width+d.horizontalPadding,0),u=t-o;if(u===0)continue;let i=s.filter(D=>"autoOverflow"in D),c=i.filter(D=>D.autoOverflow>0),l=c.reduce((D,d)=>D+d.autoOverflow,0),p=Math.min(l,u);for(let D of c){let d=Math.floor(D.autoOverflow/l*p);D.width+=d,u-=d}let a=Math.floor(u/i.length);for(let D=0;D<i.length;D+=1){let d=i[D];D===i.length-1?d.width+=u:d.width+=a,u-=a}}return r}function Go(e,t,r){let n=No(r,t);return ko(n,e),jo(n,e)}$(),$(),$();var Ue=10,tr=(e=0)=>t=>`\x1B[${t+e}m`,rr=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,nr=(e=0)=>(t,r,n)=>`\x1B[${38+e};2;${t};${r};${n}m`;function Ho(){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=tr(),t.color.ansi256=rr(),t.color.ansi16m=nr(),t.bgColor.ansi=tr(Ue),t.bgColor.ansi256=rr(Ue),t.bgColor.ansi16m=nr(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 c=r%36;n=Math.floor(r/36)/5,s=Math.floor(c/6)/5,o=c%6/5}let u=Math.max(n,s,o)*2;if(u===0)return 30;let i=30+(Math.round(o)<<2|Math.round(s)<<1|Math.round(n));return u===2&&(i+=60),i},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 Uo=Ho(),Ko=Uo,$e=new Set(["\x1B","\x9B"]),zo=39,Ke="\x07",or="[",qo="]",sr="m",ze=`${qo}8;;`,ur=e=>`${$e.values().next().value}${or}${e}${sr}`,ir=e=>`${$e.values().next().value}${ze}${e}${Ke}`,Yo=e=>e.split(" ").map(t=>Y(t)),qe=(e,t,r)=>{let n=[...t],s=!1,o=!1,u=Y(Jt(e[e.length-1]));for(let[i,c]of n.entries()){let l=Y(c);if(u+l<=r?e[e.length-1]+=c:(e.push(c),u=0),$e.has(c)&&(s=!0,o=n.slice(i+1).join("").startsWith(ze)),s){o?c===Ke&&(s=!1,o=!1):c===sr&&(s=!1);continue}u+=l,u===r&&i<n.length-1&&(e.push(""),u=0)}!u&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Wo=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(Y(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},Vo=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",s,o,u=Yo(e),i=[""];for(let[l,p]of e.split(" ").entries()){r.trim!==!1&&(i[i.length-1]=i[i.length-1].trimStart());let a=Y(i[i.length-1]);if(l!==0&&(a>=t&&(r.wordWrap===!1||r.trim===!1)&&(i.push(""),a=0),(a>0||r.trim===!1)&&(i[i.length-1]+=" ",a++)),r.hard&&u[l]>t){let D=t-a,d=1+Math.floor((u[l]-D-1)/t);Math.floor((u[l]-1)/t)<d&&i.push(""),qe(i,p,t);continue}if(a+u[l]>t&&a>0&&u[l]>0){if(r.wordWrap===!1&&a<t){qe(i,p,t);continue}i.push("")}if(a+u[l]>t&&r.wordWrap===!1){qe(i,p,t);continue}i[i.length-1]+=p}r.trim!==!1&&(i=i.map(l=>Wo(l)));let c=[...i.join(`
4
+ `)];for(let[l,p]of c.entries()){if(n+=p,$e.has(p)){let{groups:D}=new RegExp(`(?:\\${or}(?<code>\\d+)m|\\${ze}(?<uri>.*)${Ke})`).exec(c.slice(l).join(""))||{groups:{}};if(D.code!==void 0){let d=Number.parseFloat(D.code);s=d===zo?void 0:d}else D.uri!==void 0&&(o=D.uri.length===0?void 0:D.uri)}let a=Ko.codes.get(Number(s));c[l+1]===`
5
+ `?(o&&(n+=ir("")),s&&a&&(n+=ur(a))):p===`
6
+ `&&(s&&a&&(n+=ur(s)),o&&(n+=ir(o)))}return n};function Jo(e,t,r){return String(e).normalize().replace(/\r\n/g,`
7
7
  `).split(`
8
- `).map(n=>is(n,t,r)).join(`
9
- `)}var pr=e=>Array.from({length:e}).fill("");function cs(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)),rr(f)>i.width&&(f=as(f,i.width,{hard:!0}));let c=f.split(`
10
- `);if(i.postprocess){let{postprocess:D}=i;c=c.map((p,d)=>D.call(i,p,d))}return i.paddingTop&&c.unshift(...pr(i.paddingTop)),i.paddingBottom&&c.push(...pr(i.paddingBottom)),c.length>o&&(o=c.length),Ke(xe({},i),{lines:c})}),a=[];for(let i=0;i<o;i+=1){let l=u.map(f=>{var c;let D=(c=f.lines[i])!=null?c:"",p=Number.isFinite(f.width)?" ".repeat(f.width-Q(D)):"",d=f.paddingLeftString;return f.align==="right"&&(d+=p),d+=D,f.align==="left"&&(d+=p),d+f.paddingRightString}).join("");a.push(l)}r.push(a.join(`
8
+ `).map(n=>Vo(n,t,r)).join(`
9
+ `)}var ar=e=>Array.from({length:e}).fill("");function Xo(e,t){let r=[],n=0;for(let s of e){let o=0,u=s.map(c=>{var l;let p=(l=t[n])!=null?l:"";n+=1,c.preprocess&&(p=c.preprocess(p)),Xt(p)>c.width&&(p=Jo(p,c.width,{hard:!0}));let a=p.split(`
10
+ `);if(c.postprocess){let{postprocess:D}=c;a=a.map((d,f)=>D.call(c,d,f))}return c.paddingTop&&a.unshift(...ar(c.paddingTop)),c.paddingBottom&&a.push(...ar(c.paddingBottom)),a.length>o&&(o=a.length),He(ve({},c),{lines:a})}),i=[];for(let c=0;c<o;c+=1){let l=u.map(p=>{var a;let D=(a=p.lines[c])!=null?a:"",d=Number.isFinite(p.width)?" ".repeat(p.width-Y(D)):"",f=p.paddingLeftString;return p.align==="right"&&(f+=d),f+=D,p.align==="left"&&(f+=d),f+p.paddingRightString}).join("");i.push(l)}r.push(i.join(`
11
11
  `))}return r.join(`
12
- `)}function Ds(e,t){if(!e||e.length===0)return"";let r=Vo(e),n=r.length;if(n===0)return"";let{stdoutColumns:s,columns:o}=qo(t);if(o.length>n)throw new Error(`${o.length} columns defined, but only ${n} columns found`);let u=Zo(s,o,r);return e.map(a=>cs(u,a)).join(`
13
- `)}x();var ls=["<",">","=",">=","<="];function fs(e){if(!ls.includes(e))throw new TypeError(`Invalid breakpoint operator: ${e}`)}function ps(e){let t=Object.keys(e).map(r=>{let[n,s]=r.split(" ");fs(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 ds=e=>e.replace(/[\W_]([a-z\d])?/gi,(t,r)=>r?r.toUpperCase():""),ms=e=>e.replace(/\B([A-Z])/g,"-$1").toLowerCase(),hs={"> 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 gs(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:`--${ms(r)}`,aliasesEnabled:t,aliasFormatted:s?`-${n.alias}`:void 0}}).map(r=>(r.aliasesEnabled=t,[{type:"flagName",data:r},{type:"flagDescription",data:r}])),tableBreakpoints:hs}}}const dr=e=>!e||(e.version??(e.help?e.help.version:void 0)),mr=e=>{const t="parent"in e&&e.parent?.name;return(t?`${t} `:"")+e.name};function Cs(e){const t=[];e.name&&t.push(mr(e));const r=dr(e)??("parent"in e&&dr(e.parent));if(r&&t.push(`v${r}`),t.length!==0)return{id:"name",type:"text",data:`${t.join(" ")}
14
- `}}function Es(e){const{help:t}=e;if(!(!t||!t.description))return{id:"description",type:"text",data:`${t.description}
15
- `}}function Fs(e){const t=e.help||{};if("usage"in t)return t.usage?{id:"usage",type:"section",data:{title:"Usage:",body:Array.isArray(t.usage)?t.usage.join(`
16
- `):t.usage}}:void 0;if(e.name){const r=[],n=[mr(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
- `)}}}}function ys(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 bs(e){if(!(!e.flags||Object.keys(e.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:gs(e.flags),indentBody:0}}}function As(e){const{help:t}=e;if(!t||!t.examples||t.examples.length===0)return;let{examples:r}=t;if(Array.isArray(r)&&(r=r.join(`
18
- `)),r)return{id:"examples",type:"section",data:{title:"Examples:",body:r}}}function ws(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 $s=e=>[Cs,Es,Fs,ys,bs,As,ws].map(t=>t(e)).filter(Boolean),vs=ke.WriteStream.prototype.hasColors();class xs{text(t){return t}bold(t){return vs?`\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)}
12
+ `)}function Qo(e,t){if(!e||e.length===0)return"";let r=Ro(e),n=r.length;if(n===0)return"";let{stdoutColumns:s,columns:o}=Po(t);if(o.length>n)throw new Error(`${o.length} columns defined, but only ${n} columns found`);let u=Go(s,o,r);return e.map(i=>Xo(u,i)).join(`
13
+ `)}$();var Zo=["<",">","=",">=","<="];function es(e){if(!Zo.includes(e))throw new TypeError(`Invalid breakpoint operator: ${e}`)}function ts(e){let t=Object.keys(e).map(r=>{let[n,s]=r.split(" ");es(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 rs=e=>e.replace(/[\W_]([a-z\d])?/gi,(t,r)=>r?r.toUpperCase():""),ns=e=>e.replace(/\B([A-Z])/g,"-$1").toLowerCase(),os={"> 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 ss(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:`--${ns(r)}`,aliasesEnabled:t,aliasFormatted:s?`-${n.alias}`:void 0}}).map(r=>(r.aliasesEnabled=t,[{type:"flagName",data:r},{type:"flagDescription",data:r}])),tableBreakpoints:os}}}const cr=e=>!e||(e.version??(e.help?e.help.version:void 0)),Dr=e=>{const t="parent"in e&&e.parent?.name;return(t?`${t} `:"")+e.name};function us(e){const t=[];e.name&&t.push(Dr(e));const r=cr(e)??("parent"in e&&cr(e.parent));if(r&&t.push(`v${r}`),t.length!==0)return{id:"name",type:"text",data:`${t.join(" ")}
14
+ `}}function is(e){const{help:t}=e;if(!(!t||!t.description))return{id:"description",type:"text",data:`${t.description}
15
+ `}}function as(e){const t=e.help||{};if("usage"in t)return t.usage?{id:"usage",type:"section",data:{title:"Usage:",body:Array.isArray(t.usage)?t.usage.join(`
16
+ `):t.usage}}:void 0;if(e.name){const r=[],n=[Dr(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(i=>i.startsWith("<"));n.push(s.map(i=>i!=="--"?i:u?"--":"[--]").join(" "))}if(n.length>1&&r.push(n.join(" ")),"commands"in e&&e.commands?.length&&r.push(`${e.name} <command>`),r.length>0)return{id:"usage",type:"section",data:{title:"Usage:",body:r.join(`
17
+ `)}}}}function cs(e){return!("commands"in e)||!e.commands?.length?void 0:{id:"commands",type:"section",data:{title:"Commands:",body:{type:"table",data:{tableData:e.commands.map(t=>[t.options.name,t.options.help?t.options.help.description:""]),tableOptions:[{width:"content-width",paddingLeft:2,paddingRight:8}]}},indentBody:0}}}function Ds(e){if(!(!e.flags||Object.keys(e.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:ss(e.flags),indentBody:0}}}function ls(e){const{help:t}=e;if(!t||!t.examples||t.examples.length===0)return;let{examples:r}=t;if(Array.isArray(r)&&(r=r.join(`
18
+ `)),r)return{id:"examples",type:"section",data:{title:"Examples:",body:r}}}function ps(e){if(!("alias"in e)||!e.alias)return;const{alias:t}=e;return{id:"aliases",type:"section",data:{title:"Aliases:",body:Array.isArray(t)?t.join(", "):t}}}const ds=e=>[us,is,as,cs,Ds,ls,ps].map(t=>t(e)).filter(Boolean),fs=Re.WriteStream.prototype.hasColors();class ms{text(t){return t}bold(t){return fs?`\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 Ds(t.map(s=>s.map(o=>this.render(o))),n?ps(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
- `);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 Ve=/^[\w.-]+$/,{stringify:U}=JSON,Os=/[|\\{}()[\]^$+*?.]/;function Xe(e){const t=[];let r,n;for(const s of e){if(n)throw new Error(`Invalid parameter: Spread parameter ${U(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 ${U(s)} cannot come after optional parameter ${U(r)}`);if(o==="["&&u==="]"&&(a=!1,r=s),a===void 0)throw new Error(`Invalid parameter: ${U(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: ${U(s)}. Invalid character found ${U(f[0])}`);t.push({name:i,required:a,spread:l})}return t}function Je(e,t,r,n){for(let s=0;s<t.length;s+=1){const{name:o,required:u,spread:a}=t[s],i=ds(o);if(i in e)throw new Error(`Invalid parameter: ${U(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 ${U(o)}
22
- `),n(),process.exit(1);e[i]=l}}function Bs(e){return e===void 0||e!==!1}function hr(e,t,r,n){const s={...t.flags},o=t.version;o&&(s.version={type:Boolean,description:"Show version"});const{help:u}=t,a=Bs(u);a&&!("help"in s)&&(s.help={type:Boolean,alias:"h",description:"Show help"});const i=So(s,n,{ignore:t.ignoreArgv}),l=()=>{console.log(t.version)};if(o&&i.flags.version===!0)return l(),process.exit(0);const f=new xs,c=a&&u?.render?u.render:d=>f.render(d),D=d=>{const h=$s({...t,...d?{help:d}:{},flags:s});console.log(c(h,f))};if(a&&i.flags.help===!0)return D(),process.exit(0);if(t.parameters){let{parameters:d}=t,h=i._;const m=d.indexOf("--"),C=d.slice(m+1),A=Object.create(null);if(m>-1&&C.length>0){d=d.slice(0,m);const F=i._["--"];h=h.slice(0,-F.length||void 0),Je(A,Xe(d),h,D),Je(A,Xe(C),F,D)}else Je(A,Xe(d),h,D);Object.assign(i._,A)}const p={...i,showVersion:l,showHelp:D};return typeof r=="function"&&r(p),{command:e,...p}}function Ms(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: ${U(u)}`);r.set(u,n)}}return r.get(e)}function Ss(e,t,r=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!Ve.test(e.name)))throw new Error(`Invalid script name: ${U(e.name)}`);const n=r[0];if(e.commands&&Ve.test(n)){const s=Ms(n,e.commands);if(s)return hr(s.options.name,{...s.options,parent:e},s.callback,r.slice(1))}return hr(void 0,e,t,r)}function Qe(e,t){if(!e)throw new Error("Command options are required");const{name:r}=e;if(e.name===void 0)throw new Error("Command name is required");if(!Ve.test(r))throw new Error(`Invalid command name ${JSON.stringify(r)}. Command names must be one word.`);return{options:e,callback:t}}var Is=Pn(import.meta.url),$=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function re(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ne={exports:{}},Ze,gr;function Ps(){if(gr)return Ze;gr=1,Ze=n,n.sync=s;var e=J;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 Ze}var et,Cr;function _s(){if(Cr)return et;Cr=1,et=t,t.sync=r;var e=J;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(),c=u.gid!==void 0?u.gid:process.getgid&&process.getgid(),D=parseInt("100",8),p=parseInt("010",8),d=parseInt("001",8),h=D|p,m=a&d||a&p&&l===c||a&D&&i===f||a&h&&f===0;return m}return et}var Be;process.platform==="win32"||$.TESTING_WINDOWS?Be=Ps():Be=_s();var Ls=tt;tt.sync=Ts;function tt(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){tt(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 Ts(e,t){try{return Be.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}const oe=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Er=Y,Ns=oe?";":":",Fr=Ls,yr=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),br=(e,t)=>{const r=t.colon||Ns,n=e.match(/\//)||oe&&e.match(/\\/)?[""]:[...oe?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],s=oe?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=oe?s.split(r):[""];return oe&&e.indexOf(".")!==-1&&o[0]!==""&&o.unshift(""),{pathEnv:n,pathExt:o,pathExtExe:s}},Ar=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});const{pathEnv:n,pathExt:s,pathExtExe:o}=br(e,t),u=[],a=l=>new Promise((f,c)=>{if(l===n.length)return t.all&&u.length?f(u):c(yr(e));const D=n[l],p=/^".*"$/.test(D)?D.slice(1,-1):D,d=Er.join(p,e),h=!p&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;f(i(h,l,0))}),i=(l,f,c)=>new Promise((D,p)=>{if(c===s.length)return D(a(f+1));const d=s[c];Fr(l+d,{pathExt:o},(h,m)=>{if(!h&&m)if(t.all)u.push(l+d);else return D(l+d);return D(i(l,f,c+1))})});return r?a(0).then(l=>r(null,l),r):a(0)},Rs=(e,t)=>{t=t||{};const{pathEnv:r,pathExt:n,pathExtExe:s}=br(e,t),o=[];for(let u=0;u<r.length;u++){const a=r[u],i=/^".*"$/.test(a)?a.slice(1,-1):a,l=Er.join(i,e),f=!i&&/^\.[\\\/]/.test(e)?e.slice(0,2)+l:l;for(let c=0;c<n.length;c++){const D=f+n[c];try{if(Fr.sync(D,{pathExt:s}))if(t.all)o.push(D);else return D}catch{}}}if(t.all&&o.length)return o;if(t.nothrow)return null;throw yr(e)};var ks=Ar;Ar.sync=Rs;var rt={exports:{}};const wr=(e={})=>{const t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};rt.exports=wr,rt.exports.default=wr;var Gs=rt.exports;const $r=Y,js=ks,Hs=Gs;function vr(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=js.sync(e.command,{path:r[Hs({env:r})],pathExt:t?$r.delimiter:void 0})}catch{}finally{o&&process.chdir(n)}return u&&(u=$r.resolve(s?e.options.cwd:"",u)),u}function Us(e){return vr(e)||vr(e,!0)}var Ks=Us,nt={};const ot=/([()\][%!^"`<>&|;, *?])/g;function qs(e){return e=e.replace(ot,"^$1"),e}function zs(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(ot,"^$1"),t&&(e=e.replace(ot,"^$1")),e}nt.command=qs,nt.argument=zs;var Ys=/^#!(.*)/;const Ws=Ys;var Vs=(e="")=>{const t=e.match(Ws);if(!t)return null;const[r,n]=t[0].replace(/#! ?/,"").split(" "),s=r.split("/").pop();return s==="env"?n:n?`${s} ${n}`:s};const st=J,Xs=Vs;function Js(e){const r=Buffer.alloc(150);let n;try{n=st.openSync(e,"r"),st.readSync(n,r,0,150,0),st.closeSync(n)}catch{}return Xs(r.toString())}var Qs=Js;const Zs=Y,xr=Ks,Or=nt,eu=Qs,tu=process.platform==="win32",ru=/\.(?:com|exe)$/i,nu=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function ou(e){e.file=xr(e);const t=e.file&&eu(e.file);return t?(e.args.unshift(e.file),e.command=t,xr(e)):e.file}function su(e){if(!tu)return e;const t=ou(e),r=!ru.test(t);if(e.options.forceShell||r){const n=nu.test(t);e.command=Zs.normalize(e.command),e.command=Or.command(e.command),e.args=e.args.map(o=>Or.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 uu(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:su(n)}var iu=uu;const ut=process.platform==="win32";function it(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 au(e,t){if(!ut)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 ut&&e===1&&!t.file?it(t.original,"spawn"):null}function cu(e,t){return ut&&e===1&&!t.file?it(t.original,"spawnSync"):null}var Du={hookChildProcess:au,verifyENOENT:Br,verifyENOENTSync:cu,notFoundError:it};const Mr=Tn,at=iu,ct=Du;function Sr(e,t,r){const n=at(e,t,r),s=Mr.spawn(n.command,n.args,n.options);return ct.hookChildProcess(s,n),s}function lu(e,t,r){const n=at(e,t,r),s=Mr.spawnSync(n.command,n.args,n.options);return s.error=s.error||ct.verifyENOENTSync(s.status,n),s}ne.exports=Sr,ne.exports.spawn=Sr,ne.exports.sync=lu,ne.exports._parse=at,ne.exports._enoent=ct;var fu=ne.exports,pu=re(fu);function du(e){const t=typeof e=="string"?`
20
+ `}table({tableData:t,tableOptions:r,tableBreakpoints:n}){return Qo(t.map(s=>s.map(o=>this.render(o))),n?ts(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 i=this.flagParameter("type"in r?r.type:r);i&&(u+=`${this.flagOperator(t)}${i}`)}return u}flagDefault(t){return JSON.stringify(t)}flagDescription({flag:t}){let r="description"in t?t.description??"":"";if("default"in t){let{default:n}=t;typeof n=="function"&&(n=n()),n&&(r+=` (default: ${this.flagDefault(n)})`)}return r}render(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(r=>this.render(r)).join(`
21
+ `);if("type"in t&&this[t.type]){const r=this[t.type];if(typeof r=="function")return r.call(this,t.data)}throw new Error(`Invalid node type: ${JSON.stringify(t)}`)}}const Ye=/^[\w.-]+$/,{stringify:T}=JSON,hs=/[|\\{}()[\]^$+*?.]/;function We(e){const t=[];let r,n;for(const s of e){if(n)throw new Error(`Invalid parameter: Spread parameter ${T(n)} must be last`);const o=s[0],u=s[s.length-1];let i;if(o==="<"&&u===">"&&(i=!0,r))throw new Error(`Invalid parameter: Required parameter ${T(s)} cannot come after optional parameter ${T(r)}`);if(o==="["&&u==="]"&&(i=!1,r=s),i===void 0)throw new Error(`Invalid parameter: ${T(s)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let c=s.slice(1,-1);const l=c.slice(-3)==="...";l&&(n=s,c=c.slice(0,-3));const p=c.match(hs);if(p)throw new Error(`Invalid parameter: ${T(s)}. Invalid character found ${T(p[0])}`);t.push({name:c,required:i,spread:l})}return t}function Ve(e,t,r,n){for(let s=0;s<t.length;s+=1){const{name:o,required:u,spread:i}=t[s],c=rs(o);if(c in e)throw new Error(`Invalid parameter: ${T(o)} is used more than once.`);const l=i?r.slice(s):r[s];if(i&&(s=t.length),u&&(!l||i&&l.length===0))return console.error(`Error: Missing required parameter ${T(o)}
22
+ `),n(),process.exit(1);e[c]=l}}function gs(e){return e===void 0||e!==!1}function lr(e,t,r,n){const s={...t.flags},o=t.version;o&&(s.version={type:Boolean,description:"Show version"});const{help:u}=t,i=gs(u);i&&!("help"in s)&&(s.help={type:Boolean,alias:"h",description:"Show help"});const c=Eo(s,n,{ignore:t.ignoreArgv}),l=()=>{console.log(t.version)};if(o&&c.flags.version===!0)return l(),process.exit(0);const p=new ms,a=i&&u?.render?u.render:f=>p.render(f),D=f=>{const h=ds({...t,...f?{help:f}:{},flags:s});console.log(a(h,p))};if(i&&c.flags.help===!0)return D(),process.exit(0);if(t.parameters){let{parameters:f}=t,h=c._;const m=f.indexOf("--"),C=f.slice(m+1),b=Object.create(null);if(m>-1&&C.length>0){f=f.slice(0,m);const B=c._["--"];h=h.slice(0,-B.length||void 0),Ve(b,We(f),h,D),Ve(b,We(C),B,D)}else Ve(b,We(f),h,D);Object.assign(c._,b)}const d={...c,showVersion:l,showHelp:D};return typeof r=="function"&&r(d),{command:e,...d}}function Cs(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: ${T(u)}`);r.set(u,n)}}return r.get(e)}function Es(e,t,r=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!Ye.test(e.name)))throw new Error(`Invalid script name: ${T(e.name)}`);const n=r[0];if(e.commands&&Ye.test(n)){const s=Cs(n,e.commands);if(s)return lr(s.options.name,{...s.options,parent:e},s.callback,r.slice(1))}return lr(void 0,e,t,r)}function Je(e,t){if(!e)throw new Error("Command options are required");const{name:r}=e;if(e.name===void 0)throw new Error("Command name is required");if(!Ye.test(r))throw new Error(`Invalid command name ${JSON.stringify(r)}. Command names must be one word.`);return{options:e,callback:t}}var Fs=An(import.meta.url),w=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 X={exports:{}},Xe,pr;function ys(){if(pr)return Xe;pr=1,Xe=n,n.sync=s;var e=q;function t(o,u){var i=u.pathExt!==void 0?u.pathExt:process.env.PATHEXT;if(!i||(i=i.split(";"),i.indexOf("")!==-1))return!0;for(var c=0;c<i.length;c++){var l=i[c].toLowerCase();if(l&&o.substr(-l.length).toLowerCase()===l)return!0}return!1}function r(o,u,i){return!o.isSymbolicLink()&&!o.isFile()?!1:t(u,i)}function n(o,u,i){e.stat(o,function(c,l){i(c,c?!1:r(l,o,u))})}function s(o,u){return r(e.statSync(o),o,u)}return Xe}var Qe,dr;function bs(){if(dr)return Qe;dr=1,Qe=t,t.sync=r;var e=q;function t(o,u,i){e.stat(o,function(c,l){i(c,c?!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 i=o.mode,c=o.uid,l=o.gid,p=u.uid!==void 0?u.uid:process.getuid&&process.getuid(),a=u.gid!==void 0?u.gid:process.getgid&&process.getgid(),D=parseInt("100",8),d=parseInt("010",8),f=parseInt("001",8),h=D|d,m=i&f||i&d&&l===a||i&D&&c===p||i&h&&p===0;return m}return Qe}var Be;process.platform==="win32"||w.TESTING_WINDOWS?Be=ys():Be=bs();var As=Ze;Ze.sync=ws;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 ws(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",fr=z,vs=Q?";":":",mr=As,hr=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),gr=(e,t)=>{const r=t.colon||vs,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}},Cr=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});const{pathEnv:n,pathExt:s,pathExtExe:o}=gr(e,t),u=[],i=l=>new Promise((p,a)=>{if(l===n.length)return t.all&&u.length?p(u):a(hr(e));const D=n[l],d=/^".*"$/.test(D)?D.slice(1,-1):D,f=fr.join(d,e),h=!d&&/^\.[\\\/]/.test(e)?e.slice(0,2)+f:f;p(c(h,l,0))}),c=(l,p,a)=>new Promise((D,d)=>{if(a===s.length)return D(i(p+1));const f=s[a];mr(l+f,{pathExt:o},(h,m)=>{if(!h&&m)if(t.all)u.push(l+f);else return D(l+f);return D(c(l,p,a+1))})});return r?i(0).then(l=>r(null,l),r):i(0)},$s=(e,t)=>{t=t||{};const{pathEnv:r,pathExt:n,pathExtExe:s}=gr(e,t),o=[];for(let u=0;u<r.length;u++){const i=r[u],c=/^".*"$/.test(i)?i.slice(1,-1):i,l=fr.join(c,e),p=!c&&/^\.[\\\/]/.test(e)?e.slice(0,2)+l:l;for(let a=0;a<n.length;a++){const D=p+n[a];try{if(mr.sync(D,{pathExt:s}))if(t.all)o.push(D);else return D}catch{}}}if(t.all&&o.length)return o;if(t.nothrow)return null;throw hr(e)};var Bs=Cr;Cr.sync=$s;var et={exports:{}};const Er=(e={})=>{const t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};et.exports=Er,et.exports.default=Er;var xs=et.exports;const Fr=z,Os=Bs,Ms=xs;function yr(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=Os.sync(e.command,{path:r[Ms({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 Ss(e){return yr(e)||yr(e,!0)}var Is=Ss,tt={};const rt=/([()\][%!^"`<>&|;, *?])/g;function Ps(e){return e=e.replace(rt,"^$1"),e}function _s(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(rt,"^$1"),t&&(e=e.replace(rt,"^$1")),e}tt.command=Ps,tt.argument=_s;var Ts=/^#!(.*)/;const Ls=Ts;var Rs=(e="")=>{const t=e.match(Ls);if(!t)return null;const[r,n]=t[0].replace(/#! ?/,"").split(" "),s=r.split("/").pop();return s==="env"?n:n?`${s} ${n}`:s};const nt=q,Ns=Rs;function ks(e){const r=Buffer.alloc(150);let n;try{n=nt.openSync(e,"r"),nt.readSync(n,r,0,150,0),nt.closeSync(n)}catch{}return Ns(r.toString())}var js=ks;const Gs=z,br=Is,Ar=tt,Hs=js,Us=process.platform==="win32",Ks=/\.(?:com|exe)$/i,zs=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function qs(e){e.file=br(e);const t=e.file&&Hs(e.file);return t?(e.args.unshift(e.file),e.command=t,br(e)):e.file}function Ys(e){if(!Us)return e;const t=qs(e),r=!Ks.test(t);if(e.options.forceShell||r){const n=zs.test(t);e.command=Gs.normalize(e.command),e.command=Ar.command(e.command),e.args=e.args.map(o=>Ar.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 Ws(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:Ys(n)}var Vs=Ws;const ot=process.platform==="win32";function st(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 Js(e,t){if(!ot)return;const r=e.emit;e.emit=function(n,s){if(n==="exit"){const o=wr(s,t);if(o)return r.call(e,"error",o)}return r.apply(e,arguments)}}function wr(e,t){return ot&&e===1&&!t.file?st(t.original,"spawn"):null}function Xs(e,t){return ot&&e===1&&!t.file?st(t.original,"spawnSync"):null}var Qs={hookChildProcess:Js,verifyENOENT:wr,verifyENOENTSync:Xs,notFoundError:st};const vr=$n,ut=Vs,it=Qs;function $r(e,t,r){const n=ut(e,t,r),s=vr.spawn(n.command,n.args,n.options);return it.hookChildProcess(s,n),s}function Zs(e,t,r){const n=ut(e,t,r),s=vr.spawnSync(n.command,n.args,n.options);return s.error=s.error||it.verifyENOENTSync(s.status,n),s}X.exports=$r,X.exports.spawn=$r,X.exports.sync=Zs,X.exports._parse=ut,X.exports._enoent=it;var eu=X.exports,tu=J(eu);function ru(e){const t=typeof e=="string"?`
23
23
  `:`
24
- `.charCodeAt(),r=typeof e=="string"?"\r":"\r".charCodeAt();return e[e.length-1]===t&&(e=e.slice(0,-1)),e[e.length-1]===r&&(e=e.slice(0,-1)),e}function Ir(e={}){const{env:t=process.env,platform:r=process.platform}=e;return r!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"}const mu=({cwd:e=H.cwd(),path:t=H.env[Ir()],preferLocal:r=!0,execPath:n=H.execPath,addExecPath:s=!0}={})=>{const o=e instanceof URL?jt(e):e,u=te.resolve(o),a=[];return r&&hu(a,u),s&&gu(a,n,u),[...a,t].join(te.delimiter)},hu=(e,t)=>{let r;for(;r!==t;)e.push(te.join(t,"node_modules/.bin")),r=t,t=te.resolve(t,"..")},gu=(e,t,r)=>{const n=t instanceof URL?jt(t):t;e.push(te.resolve(r,n,".."))},Cu=({env:e=H.env,...t}={})=>{e={...e};const r=Ir({env:e});return t.path=e[r],e[r]=mu(t),e},Eu=(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);!Fu(s,o)&&n||Object.defineProperty(e,r,o)},Fu=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)},yu=(e,t)=>{const r=Object.getPrototypeOf(t);r!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,r)},bu=(e,t)=>`/* Wrapped ${e}*/
25
- ${t}`,Au=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wu=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),$u=(e,t,r)=>{const n=r===""?"":`with ${r.trim()}() `,s=bu.bind(null,n,t.toString());Object.defineProperty(s,"name",wu),Object.defineProperty(e,"toString",{...Au,value:s})};function vu(e,t,{ignoreNonConfigurable:r=!1}={}){const{name:n}=e;for(const s of Reflect.ownKeys(t))Eu(e,t,s,r);return yu(e,t),$u(e,t,n),e}const Me=new WeakMap,Pr=(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(Me.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 vu(o,e),Me.set(o,n),o};Pr.callCount=e=>{if(!Me.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return Me.get(e)};const xu=()=>{const e=Lr-_r+1;return Array.from({length:e},Ou)},Ou=(e,t)=>({name:`SIGRT${t+1}`,number:_r+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),_r=34,Lr=64,Bu=[{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"}],Tr=()=>{const e=xu();return[...Bu,...e].map(Mu)},Mu=({name:e,number:t,description:r,action:n,forced:s=!1,standard:o})=>{const{signals:{[e]:u}}=Ht,a=u!==void 0;return{name:e,number:a?u:t,description:r,supported:a,action:n,forced:s,standard:o}},Su=()=>{const e=Tr();return Object.fromEntries(e.map(Iu))},Iu=({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}],Pu=Su(),_u=()=>{const e=Tr(),t=Lr+1,r=Array.from({length:t},(n,s)=>Lu(s,e));return Object.assign({},...r)},Lu=(e,t)=>{const r=Tu(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}}},Tu=(e,t)=>{const r=t.find(({name:n})=>Ht.signals[n]===e);return r!==void 0?r:t.find(n=>n.number===e)};_u();const Nu=({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",Nr=({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:c,cwd:D=H.cwd()}}})=>{o=o===null?void 0:o,s=s===null?void 0:s;const p=s===void 0?void 0:Pu[s].description,d=n&&n.code,m=`Command ${Nu({timedOut:i,timeout:c,errorCode:d,signal:s,signalDescription:p,exitCode:o,isCanceled:l})}: ${u}`,C=Object.prototype.toString.call(n)==="[object Error]",A=C?`${m}
26
- ${n.message}`:m,F=[A,t,e].filter(Boolean).join(`
27
- `);return C?(n.originalMessage=n.message,n.message=F):n=new Error(F),n.shortMessage=A,n.command=u,n.escapedCommand=a,n.exitCode=o,n.signal=s,n.signalDescription=p,n.stdout=e,n.stderr=t,n.cwd=D,r!==void 0&&(n.all=r),"bufferedData"in n&&delete n.bufferedData,n.failed=!0,n.timedOut=!!i,n.isCanceled=l,n.killed=f&&!i,n},Se=["stdin","stdout","stderr"],Ru=e=>Se.some(t=>e[t]!==void 0),ku=e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return Se.map(n=>e[n]);if(Ru(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Se.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,Se.length);return Array.from({length:r},(n,s)=>t[s])};var se={exports:{}},Ie={exports:{}};Ie.exports;var Rr;function Gu(){return Rr||(Rr=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")}(Ie)),Ie.exports}var b=$.process;const Z=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(!Z(b))se.exports=function(){return function(){}};else{var ju=Ut,pe=Gu(),Hu=/^win/i.test(b.platform),Pe=Kt;typeof Pe!="function"&&(Pe=Pe.EventEmitter);var v;b.__signal_exit_emitter__?v=b.__signal_exit_emitter__:(v=b.__signal_exit_emitter__=new Pe,v.count=0,v.emitted={}),v.infinite||(v.setMaxListeners(1/0),v.infinite=!0),se.exports=function(e,t){if(!Z($.process))return function(){};ju.equal(typeof e,"function","a callback must be provided for exit handler"),de===!1&&kr();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&&Dt()};return v.on(r,e),n};var Dt=function(){!de||!Z($.process)||(de=!1,pe.forEach(function(t){try{b.removeListener(t,lt[t])}catch{}}),b.emit=ft,b.reallyExit=Gr,v.count-=1)};se.exports.unload=Dt;var ue=function(t,r,n){v.emitted[t]||(v.emitted[t]=!0,v.emit(t,r,n))},lt={};pe.forEach(function(e){lt[e]=function(){if(Z($.process)){var r=b.listeners(e);r.length===v.count&&(Dt(),ue("exit",null,e),ue("afterexit",null,e),Hu&&e==="SIGHUP"&&(e="SIGINT"),b.kill(b.pid,e))}}}),se.exports.signals=function(){return pe};var de=!1,kr=function(){de||!Z($.process)||(de=!0,v.count+=1,pe=pe.filter(function(t){try{return b.on(t,lt[t]),!0}catch{return!1}}),b.emit=Ku,b.reallyExit=Uu)};se.exports.load=kr;var Gr=b.reallyExit,Uu=function(t){Z($.process)&&(b.exitCode=t||0,ue("exit",b.exitCode,null),ue("afterexit",b.exitCode,null),Gr.call(b,b.exitCode))},ft=b.emit,Ku=function(t,r){if(t==="exit"&&Z($.process)){r!==void 0&&(b.exitCode=r);var n=ft.apply(this,arguments);return ue("exit",b.exitCode,null),ue("afterexit",b.exitCode,null),n}else return ft.apply(this,arguments)}}var qu=se.exports,zu=re(qu);const Yu=1e3*5,Wu=(e,t="SIGTERM",r={})=>{const n=e(t);return Vu(e,t,r,n),n},Vu=(e,t,r,n)=>{if(!Xu(t,r,n))return;const s=Qu(r),o=setTimeout(()=>{e("SIGKILL")},s);o.unref&&o.unref()},Xu=(e,{forceKillAfterTimeout:t},r)=>Ju(e)&&t!==!1&&r,Ju=e=>e===Nn.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",Qu=({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},Zu=(e,t)=>{e.kill()&&(t.isCanceled=!0)},ei=(e,t,r)=>{e.kill(t),r(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},ti=(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(()=>{ei(e,r,i)},t)}),u=n.finally(()=>{clearTimeout(s)});return Promise.race([o,u])},ri=({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})`)},ni=async(e,{cleanup:t,detached:r},n)=>{if(!t||r)return n;const s=zu(()=>{e.kill()});return n.finally(()=>{s()})};function jr(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}function Hr(e){return jr(e)&&e.writable!==!1&&typeof e._write=="function"&&typeof e._writableState=="object"}const oi=e=>e instanceof Ln&&typeof e.then=="function",pt=(e,t,r)=>{if(typeof r=="string")return e[t].pipe(Rn(r)),e;if(Hr(r))return e[t].pipe(r),e;if(!oi(r))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!Hr(r.stdin))throw new TypeError("The target child process's stdin must be available.");return e[t].pipe(r.stdin),r},si=e=>{e.stdout!==null&&(e.pipeStdout=pt.bind(void 0,e,"stdout")),e.stderr!==null&&(e.pipeStderr=pt.bind(void 0,e,"stderr")),e.all!==void 0&&(e.pipeAll=pt.bind(void 0,e,"all"))};var me={exports:{}};const{PassThrough:ui}=Ge;var ii=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 ui({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:ai}=Gn,ci=Ge,{promisify:Di}=qt,li=ii,fi=Di(ci.pipeline);class Ur extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function dt(e,t){if(!e)throw new Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:r}=t,n=li(t);return await new Promise((s,o)=>{const u=a=>{a&&n.getBufferedLength()<=ai.MAX_LENGTH&&(a.bufferedData=n.getBufferedValue()),o(a)};(async()=>{try{await fi(e,n),s()}catch(a){u(a)}})(),n.on("data",()=>{n.getBufferedLength()>r&&u(new Ur)})}),n.getBufferedValue()}me.exports=dt,me.exports.buffer=(e,t)=>dt(e,{...t,encoding:"buffer"}),me.exports.array=(e,t)=>dt(e,{...t,array:!0}),me.exports.MaxBufferError=Ur;var pi=me.exports,Kr=re(pi);const{PassThrough:di}=Ge;var mi=function(){var e=[],t=new di({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()}},hi=re(mi);const gi=e=>{if(e!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},Ci=({input:e,inputFile:t})=>typeof t!="string"?e:(gi(e),kn(t)),Ei=(e,t)=>{const r=Ci(t);r!==void 0&&(jr(r)?r.pipe(e.stdin):e.stdin.end(r))},Fi=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;const r=hi();return e.stdout&&r.add(e.stdout),e.stderr&&r.add(e.stderr),r},mt=async(e,t)=>{if(!(!e||t===void 0)){e.destroy();try{return await t}catch(r){return r.bufferedData}}},ht=(e,{encoding:t,buffer:r,maxBuffer:n})=>{if(!(!e||!r))return t?Kr(e,{encoding:t,maxBuffer:n}):Kr.buffer(e,{maxBuffer:n})},yi=async({stdout:e,stderr:t,all:r},{encoding:n,buffer:s,maxBuffer:o},u)=>{const a=ht(e,{encoding:n,buffer:s,maxBuffer:o}),i=ht(t,{encoding:n,buffer:s,maxBuffer:o}),l=ht(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},mt(e,a),mt(t,i),mt(r,l)])}},bi=(async()=>{})().constructor.prototype,Ai=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(bi,e)]),qr=(e,t)=>{for(const[r,n]of Ai){const s=typeof t=="function"?(...o)=>Reflect.apply(n.value,t(),o):n.value.bind(t);Reflect.defineProperty(e,r,{...n,value:s})}},wi=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)})}),zr=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],$i=/^[\w.-]+$/,vi=/"/g,xi=e=>typeof e!="string"||$i.test(e)?e:`"${e.replace(vi,'\\"')}"`,Oi=(e,t)=>zr(e,t).join(" "),Bi=(e,t)=>zr(e,t).map(r=>xi(r)).join(" "),Mi=jn("execa").enabled,_e=(e,t)=>String(e).padStart(t,"0"),Si=()=>{const e=new Date;return`${_e(e.getHours(),2)}:${_e(e.getMinutes(),2)}:${_e(e.getSeconds(),2)}.${_e(e.getMilliseconds(),3)}`},Ii=(e,{verbose:t})=>{t&&H.stderr.write(`[${Si()}] ${e}
28
- `)},Pi=1e3*1e3*100,_i=({env:e,extendEnv:t,preferLocal:r,localDir:n,execPath:s})=>{const o=t?{...H.env,...e}:e;return r?Cu({env:o,cwd:n,execPath:s}):o},Li=(e,t,r={})=>{const n=pu._parse(e,t,r);return e=n.command,t=n.args,r=n.options,r={maxBuffer:Pi,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:r.cwd||H.cwd(),execPath:H.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:Mi,...r},r.env=_i(r),r.stdio=ku(r),H.platform==="win32"&&te.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:r,parsed:n}},gt=(e,t,r)=>typeof t!="string"&&!_n.isBuffer(t)?r===void 0?void 0:"":e.stripFinalNewline?du(t):t;function ie(e,t,r){const n=Li(e,t,r),s=Oi(e,t),o=Bi(e,t);Ii(o,n.options),ri(n.options);let u;try{u=Gt.spawn(n.file,n.args,n.options)}catch(p){const d=new Gt.ChildProcess,h=Promise.reject(Nr({error:p,stdout:"",stderr:"",all:"",command:s,escapedCommand:o,parsed:n,timedOut:!1,isCanceled:!1,killed:!1}));return qr(d,h),d}const a=wi(u),i=ti(u,n.options,a),l=ni(u,n.options,i),f={isCanceled:!1};u.kill=Wu.bind(null,u.kill.bind(u)),u.cancel=Zu.bind(null,u,f);const D=Pr(async()=>{const[{error:p,exitCode:d,signal:h,timedOut:m},C,A,F]=await yi(u,n.options,l),R=gt(n.options,C),j=gt(n.options,A),X=gt(n.options,F);if(p||d!==0||h!==null){const w=Nr({error:p,exitCode:d,signal:h,stdout:R,stderr:j,all:X,command:s,escapedCommand:o,parsed:n,timedOut:m,isCanceled:f.isCanceled||(n.options.signal?n.options.signal.aborted:!1),killed:u.killed});if(!n.options.reject)return w;throw w}return{command:s,escapedCommand:o,exitCode:0,stdout:R,stderr:j,all:X,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return Ei(u,n.options),u.all=Fi(u,n.options),si(u),qr(u,D),u}class K{static create(t,r){return new t(r)}}const Ti=80,Ni={"":"<commit message>",conventional:"<type>(<optional scope>): <description>",gitmoji:":<emoji>: <description>"},Ri={"":"",conventional:"Example commit message => feat: add new disabled boolean variable to button",gitmoji:"Example commit message => :sparkles: Add a generic preset using configuration"},ki=(e="conventional")=>e===""?"":`The commit message must be in format:
29
- ${Ni[e]}
30
- ${Ri[e]}`,Gi={"":"",gitmoji:`Choose a emoji from the emoji-to-description JSON below that best describes the git diff:
31
- ${JSON.stringify({":tada:":"Initial commit",":sparkles:":"Introduce new features",":bug:":"Fix a bug",":memo:":"Writing docs",":fire:":"Remove code or files",":art:":"Improve structure/format of the code commit",":zap:":"Improve performance",":lock:":"Fix security issues",":ambulance:":"Critical hotfix",":rocket:":"Deploy stuff",":lipstick:":"Add or update UI and style files",":construction:":"Work in progress",":green_heart:":"Fix CI build issues"},null,2)}`,conventional:`Choose a type from the type-to-description JSON below that best describes the git diff.
32
- ${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 CI configuration files, scripts",chore:"Other changes that don't modify src or test files",revert:"Reverts a previous commit",feat:"A new feature",fix:"A bug fix"},null,2)}`},W=(e,t,r,n="")=>["You are the expert programmer, trained to write commit messages. You are going to provide a professional git commit message.","Generate a concise git commit message written in present tense with the given specifications below:",`Message language: ${e}`,`Commit message must be a maximum of ${Math.min(Math.max(t,0),Ti)} characters.`,`${n}`,"Exclude anything unnecessary such as explanation or translation. Your entire response will be passed directly into git commit.",Gi[r],ki(r)].filter(Boolean).join(`
33
- `),ee=e=>`THE RESULT MUST BE ${e} COMMIT MESSAGES AND MUST BE IN NUMBERED LIST FORMAT.`,Yr=e=>/(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?: .*$/.test(e),Wr=e=>/:\w*:/.test(e),I={OPEN_AI:"OPENAI_KEY",GEMINI:"GEMINI_KEY",ANTHROPIC:"ANTHROPIC_KEY",HUGGING:"HUGGING_COOKIE",CLOVA_X:"CLOVAX_COOKIE",MISTRAL:"MISTRAL_KEY",CODESTRAL:"CODESTRAL_KEY",OLLAMA:"OLLAMA_MODEL",COHERE:"COHERE_KEY",GROQ:"GROQ_KEY"},Vr=Object.values(I).map(e=>e);class q{constructor(t){this.handleError$=r=>{let n="An error occurred";return r.message&&(n=r.message),k({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`${W(t,s,o,u)}
34
- ${ee(n)}
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 Br(e={}){const{env:t=process.env,platform:r=process.platform}=e;return r!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"}const nu=({cwd:e=P.cwd(),path:t=P.env[Br()],preferLocal:r=!0,execPath:n=P.execPath,addExecPath:s=!0}={})=>{const o=e instanceof URL?kt(e):e,u=V.resolve(o),i=[];return r&&ou(i,u),s&&su(i,n,u),[...i,t].join(V.delimiter)},ou=(e,t)=>{let r;for(;r!==t;)e.push(V.join(t,"node_modules/.bin")),r=t,t=V.resolve(t,"..")},su=(e,t,r)=>{const n=t instanceof URL?kt(t):t;e.push(V.resolve(r,n,".."))},uu=({env:e=P.env,...t}={})=>{e={...e};const r=Br({env:e});return t.path=e[r],e[r]=nu(t),e},iu=(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);!au(s,o)&&n||Object.defineProperty(e,r,o)},au=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)},cu=(e,t)=>{const r=Object.getPrototypeOf(t);r!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,r)},Du=(e,t)=>`/* Wrapped ${e}*/
25
+ ${t}`,lu=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),pu=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),du=(e,t,r)=>{const n=r===""?"":`with ${r.trim()}() `,s=Du.bind(null,n,t.toString());Object.defineProperty(s,"name",pu),Object.defineProperty(e,"toString",{...lu,value:s})};function fu(e,t,{ignoreNonConfigurable:r=!1}={}){const{name:n}=e;for(const s of Reflect.ownKeys(t))iu(e,t,s,r);return cu(e,t),du(e,t,n),e}const xe=new WeakMap,xr=(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(xe.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 fu(o,e),xe.set(o,n),o};xr.callCount=e=>{if(!xe.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return xe.get(e)};const mu=()=>{const e=Mr-Or+1;return Array.from({length:e},hu)},hu=(e,t)=>({name:`SIGRT${t+1}`,number:Or+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),Or=34,Mr=64,gu=[{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"}],Sr=()=>{const e=mu();return[...gu,...e].map(Cu)},Cu=({name:e,number:t,description:r,action:n,forced:s=!1,standard:o})=>{const{signals:{[e]:u}}=jt,i=u!==void 0;return{name:e,number:i?u:t,description:r,supported:i,action:n,forced:s,standard:o}},Eu=()=>{const e=Sr();return Object.fromEntries(e.map(Fu))},Fu=({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}],yu=Eu(),bu=()=>{const e=Sr(),t=Mr+1,r=Array.from({length:t},(n,s)=>Au(s,e));return Object.assign({},...r)},Au=(e,t)=>{const r=wu(e,t);if(r===void 0)return{};const{name:n,description:s,supported:o,action:u,forced:i,standard:c}=r;return{[e]:{name:n,number:e,description:s,supported:o,action:u,forced:i,standard:c}}},wu=(e,t)=>{const r=t.find(({name:n})=>jt.signals[n]===e);return r!==void 0?r:t.find(n=>n.number===e)};bu();const vu=({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",Ir=({stdout:e,stderr:t,all:r,error:n,signal:s,exitCode:o,command:u,escapedCommand:i,timedOut:c,isCanceled:l,killed:p,parsed:{options:{timeout:a,cwd:D=P.cwd()}}})=>{o=o===null?void 0:o,s=s===null?void 0:s;const d=s===void 0?void 0:yu[s].description,f=n&&n.code,m=`Command ${vu({timedOut:c,timeout:a,errorCode:f,signal:s,signalDescription:d,exitCode:o,isCanceled:l})}: ${u}`,C=Object.prototype.toString.call(n)==="[object Error]",b=C?`${m}
26
+ ${n.message}`:m,B=[b,t,e].filter(Boolean).join(`
27
+ `);return C?(n.originalMessage=n.message,n.message=B):n=new Error(B),n.shortMessage=b,n.command=u,n.escapedCommand=i,n.exitCode=o,n.signal=s,n.signalDescription=d,n.stdout=e,n.stderr=t,n.cwd=D,r!==void 0&&(n.all=r),"bufferedData"in n&&delete n.bufferedData,n.failed=!0,n.timedOut=!!c,n.isCanceled=l,n.killed=p&&!c,n},Oe=["stdin","stdout","stderr"],$u=e=>Oe.some(t=>e[t]!==void 0),Bu=e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return Oe.map(n=>e[n]);if($u(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Oe.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,Oe.length);return Array.from({length:r},(n,s)=>t[s])};var Z={exports:{}},Me={exports:{}};Me.exports;var Pr;function xu(){return Pr||(Pr=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")}(Me)),Me.exports}var F=w.process;const W=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(!W(F))Z.exports=function(){return function(){}};else{var Ou=Gt,ae=xu(),Mu=/^win/i.test(F.platform),Se=Ht;typeof Se!="function"&&(Se=Se.EventEmitter);var v;F.__signal_exit_emitter__?v=F.__signal_exit_emitter__:(v=F.__signal_exit_emitter__=new Se,v.count=0,v.emitted={}),v.infinite||(v.setMaxListeners(1/0),v.infinite=!0),Z.exports=function(e,t){if(!W(w.process))return function(){};Ou.equal(typeof e,"function","a callback must be provided for exit handler"),ce===!1&&_r();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&&at()};return v.on(r,e),n};var at=function(){!ce||!W(w.process)||(ce=!1,ae.forEach(function(t){try{F.removeListener(t,ct[t])}catch{}}),F.emit=Dt,F.reallyExit=Tr,v.count-=1)};Z.exports.unload=at;var ee=function(t,r,n){v.emitted[t]||(v.emitted[t]=!0,v.emit(t,r,n))},ct={};ae.forEach(function(e){ct[e]=function(){if(W(w.process)){var r=F.listeners(e);r.length===v.count&&(at(),ee("exit",null,e),ee("afterexit",null,e),Mu&&e==="SIGHUP"&&(e="SIGINT"),F.kill(F.pid,e))}}}),Z.exports.signals=function(){return ae};var ce=!1,_r=function(){ce||!W(w.process)||(ce=!0,v.count+=1,ae=ae.filter(function(t){try{return F.on(t,ct[t]),!0}catch{return!1}}),F.emit=Iu,F.reallyExit=Su)};Z.exports.load=_r;var Tr=F.reallyExit,Su=function(t){W(w.process)&&(F.exitCode=t||0,ee("exit",F.exitCode,null),ee("afterexit",F.exitCode,null),Tr.call(F,F.exitCode))},Dt=F.emit,Iu=function(t,r){if(t==="exit"&&W(w.process)){r!==void 0&&(F.exitCode=r);var n=Dt.apply(this,arguments);return ee("exit",F.exitCode,null),ee("afterexit",F.exitCode,null),n}else return Dt.apply(this,arguments)}}var Pu=Z.exports,_u=J(Pu);const Tu=1e3*5,Lu=(e,t="SIGTERM",r={})=>{const n=e(t);return Ru(e,t,r,n),n},Ru=(e,t,r,n)=>{if(!Nu(t,r,n))return;const s=ju(r),o=setTimeout(()=>{e("SIGKILL")},s);o.unref&&o.unref()},Nu=(e,{forceKillAfterTimeout:t},r)=>ku(e)&&t!==!1&&r,ku=e=>e===Bn.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",ju=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return Tu;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},Gu=(e,t)=>{e.kill()&&(t.isCanceled=!0)},Hu=(e,t,r)=>{e.kill(t),r(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},Uu=(e,{timeout:t,killSignal:r="SIGTERM"},n)=>{if(t===0||t===void 0)return n;let s;const o=new Promise((i,c)=>{s=setTimeout(()=>{Hu(e,r,c)},t)}),u=n.finally(()=>{clearTimeout(s)});return Promise.race([o,u])},Ku=({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})`)},zu=async(e,{cleanup:t,detached:r},n)=>{if(!t||r)return n;const s=_u(()=>{e.kill()});return n.finally(()=>{s()})};function Lr(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}function Rr(e){return Lr(e)&&e.writable!==!1&&typeof e._write=="function"&&typeof e._writableState=="object"}const qu=e=>e instanceof vn&&typeof e.then=="function",lt=(e,t,r)=>{if(typeof r=="string")return e[t].pipe(xn(r)),e;if(Rr(r))return e[t].pipe(r),e;if(!qu(r))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!Rr(r.stdin))throw new TypeError("The target child process's stdin must be available.");return e[t].pipe(r.stdin),r},Yu=e=>{e.stdout!==null&&(e.pipeStdout=lt.bind(void 0,e,"stdout")),e.stderr!==null&&(e.pipeStderr=lt.bind(void 0,e,"stderr")),e.all!==void 0&&(e.pipeAll=lt.bind(void 0,e,"all"))};var De={exports:{}};const{PassThrough:Wu}=Ne;var Vu=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 Wu({objectMode:s});r&&o.setEncoding(r);let u=0;const i=[];return o.on("data",c=>{i.push(c),s?u=i.length:u+=c.length}),o.getBufferedValue=()=>t?i:n?Buffer.concat(i,u):i.join(""),o.getBufferedLength=()=>u,o};const{constants:Ju}=Mn,Xu=Ne,{promisify:Qu}=Ut,Zu=Vu,ei=Qu(Xu.pipeline);class Nr extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function pt(e,t){if(!e)throw new Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:r}=t,n=Zu(t);return await new Promise((s,o)=>{const u=i=>{i&&n.getBufferedLength()<=Ju.MAX_LENGTH&&(i.bufferedData=n.getBufferedValue()),o(i)};(async()=>{try{await ei(e,n),s()}catch(i){u(i)}})(),n.on("data",()=>{n.getBufferedLength()>r&&u(new Nr)})}),n.getBufferedValue()}De.exports=pt,De.exports.buffer=(e,t)=>pt(e,{...t,encoding:"buffer"}),De.exports.array=(e,t)=>pt(e,{...t,array:!0}),De.exports.MaxBufferError=Nr;var ti=De.exports,kr=J(ti);const{PassThrough:ri}=Ne;var ni=function(){var e=[],t=new ri({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()}},oi=J(ni);const si=e=>{if(e!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},ui=({input:e,inputFile:t})=>typeof t!="string"?e:(si(e),On(t)),ii=(e,t)=>{const r=ui(t);r!==void 0&&(Lr(r)?r.pipe(e.stdin):e.stdin.end(r))},ai=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;const r=oi();return e.stdout&&r.add(e.stdout),e.stderr&&r.add(e.stderr),r},dt=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?kr(e,{encoding:t,maxBuffer:n}):kr.buffer(e,{maxBuffer:n})},ci=async({stdout:e,stderr:t,all:r},{encoding:n,buffer:s,maxBuffer:o},u)=>{const i=ft(e,{encoding:n,buffer:s,maxBuffer:o}),c=ft(t,{encoding:n,buffer:s,maxBuffer:o}),l=ft(r,{encoding:n,buffer:s,maxBuffer:o*2});try{return await Promise.all([u,i,c,l])}catch(p){return Promise.all([{error:p,signal:p.signal,timedOut:p.timedOut},dt(e,i),dt(t,c),dt(r,l)])}},Di=(async()=>{})().constructor.prototype,li=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(Di,e)]),jr=(e,t)=>{for(const[r,n]of li){const s=typeof t=="function"?(...o)=>Reflect.apply(n.value,t(),o):n.value.bind(t);Reflect.defineProperty(e,r,{...n,value:s})}},pi=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)})}),Gr=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],di=/^[\w.-]+$/,fi=/"/g,mi=e=>typeof e!="string"||di.test(e)?e:`"${e.replace(fi,'\\"')}"`,hi=(e,t)=>Gr(e,t).join(" "),gi=(e,t)=>Gr(e,t).map(r=>mi(r)).join(" "),Ci=Sn("execa").enabled,Ie=(e,t)=>String(e).padStart(t,"0"),Ei=()=>{const e=new Date;return`${Ie(e.getHours(),2)}:${Ie(e.getMinutes(),2)}:${Ie(e.getSeconds(),2)}.${Ie(e.getMilliseconds(),3)}`},Fi=(e,{verbose:t})=>{t&&P.stderr.write(`[${Ei()}] ${e}
28
+ `)},yi=1e3*1e3*100,bi=({env:e,extendEnv:t,preferLocal:r,localDir:n,execPath:s})=>{const o=t?{...P.env,...e}:e;return r?uu({env:o,cwd:n,execPath:s}):o},Ai=(e,t,r={})=>{const n=tu._parse(e,t,r);return e=n.command,t=n.args,r=n.options,r={maxBuffer:yi,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:r.cwd||P.cwd(),execPath:P.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:Ci,...r},r.env=bi(r),r.stdio=Bu(r),P.platform==="win32"&&V.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:r,parsed:n}},mt=(e,t,r)=>typeof t!="string"&&!wn.isBuffer(t)?r===void 0?void 0:"":e.stripFinalNewline?ru(t):t;function te(e,t,r){const n=Ai(e,t,r),s=hi(e,t),o=gi(e,t);Fi(o,n.options),Ku(n.options);let u;try{u=Nt.spawn(n.file,n.args,n.options)}catch(d){const f=new Nt.ChildProcess,h=Promise.reject(Ir({error:d,stdout:"",stderr:"",all:"",command:s,escapedCommand:o,parsed:n,timedOut:!1,isCanceled:!1,killed:!1}));return jr(f,h),f}const i=pi(u),c=Uu(u,n.options,i),l=zu(u,n.options,c),p={isCanceled:!1};u.kill=Lu.bind(null,u.kill.bind(u)),u.cancel=Gu.bind(null,u,p);const D=xr(async()=>{const[{error:d,exitCode:f,signal:h,timedOut:m},C,b,B]=await ci(u,n.options,l),R=mt(n.options,C),N=mt(n.options,b),oe=mt(n.options,B);if(d||f!==0||h!==null){const A=Ir({error:d,exitCode:f,signal:h,stdout:R,stderr:N,all:oe,command:s,escapedCommand:o,parsed:n,timedOut:m,isCanceled:p.isCanceled||(n.options.signal?n.options.signal.aborted:!1),killed:u.killed});if(!n.options.reject)return A;throw A}return{command:s,escapedCommand:o,exitCode:0,stdout:R,stderr:N,all:oe,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return ii(u,n.options),u.all=ai(u,n.options),Yu(u),jr(u,D),u}class H{static create(t,r){return new t(r)}}const wi=80,vi={"":"<commit message>",conventional:`<type>(<optional scope>): <description>
29
+
30
+ [optional body]
31
+
32
+ [optional footer(s)]`,gitmoji:`:<emoji>:(<optional scope>): <description>
33
+
34
+ [optional body]
35
+
36
+ [optional footer(s)]`},$i={"":"",conventional:"<type>(<optional scope>): <description>",gitmoji:":<emoji>: <description>"},Bi={"":"",gitmoji:`
37
+ ${JSON.stringify({":art:":"Improve structure / format of the code.",":zap:":"Improve performance.",":fire:":"Remove code or files.",":bug:":"Fix a bug.",":ambulance:":"Critical hotfix.",":sparkles:":"Introduce new features.",":memo:":"Add or update documentation.",":rocket:":"Deploy stuff.",":lipstick:":"Add or update the UI and style files.",":tada:":"Begin a project.",":white_check_mark:":"Add, update, or pass tests.",":lock:":"Fix security or privacy issues.",":closed_lock_with_key:":"Add or update secrets.",":bookmark:":"Release / Version tags.",":rotating_light:":"Fix compiler / linter warnings.",":construction:":"Work in progress.",":green_heart:":"Fix CI Build.",":arrow_down:":"Downgrade dependencies.",":arrow_up:":"Upgrade dependencies.",":pushpin:":"Pin dependencies to specific versions.",":construction_worker:":"Add or update CI build system.",":chart_with_upwards_trend:":"Add or update analytics or track code.",":recycle:":"Refactor code.",":heavy_plus_sign:":"Add a dependency.",":heavy_minus_sign:":"Remove a dependency.",":wrench:":"Add or update configuration files.",":hammer:":"Add or update development scripts.",":globe_with_meridians:":"Internationalization and localization.",":pencil2:":"Fix typos.",":poop:":"Write bad code that needs to be improved.",":rewind:":"Revert changes.",":twisted_rightwards_arrows:":"Merge branches.",":package:":"Add or update compiled files or packages.",":alien:":"Update code due to external API changes.",":truck:":"Move or rename resources (e.g.: files, paths, routes).",":page_facing_up:":"Add or update license.",":boom:":"Introduce breaking changes.",":bento:":"Add or update assets.",":wheelchair:":"Improve accessibility.",":bulb:":"Add or update comments in source code.",":beers:":"Write code drunkenly.",":speech_balloon:":"Add or update text and literals.",":card_file_box:":"Perform database related changes.",":loud_sound:":"Add or update logs.",":mute:":"Remove logs.",":busts_in_silhouette:":"Add or update contributor(s).",":children_crossing:":"Improve user experience / usability.",":building_construction:":"Make architectural changes.",":iphone:":"Work on responsive design.",":clown_face:":"Mock things.",":egg:":"Add or update an easter egg.",":see_no_evil:":"Add or update a .gitignore file.",":camera_flash:":"Add or update snapshots.",":alembic:":"Perform experiments.",":mag:":"Improve SEO.",":label:":"Add or update types.",":seedling:":"Add or update seed files.",":triangular_flag_on_post:":"Add, update, or remove feature flags.",":goal_net:":"Catch errors.",":dizzy:":"Add or update animations and transitions.",":wastebasket:":"Deprecate code that needs to be cleaned up.",":passport_control:":"Work on code related to authorization, roles and permissions.",":adhesive_bandage:":"Simple fix for a non-critical issue.",":monocle_face:":"Data exploration/inspection.",":coffin:":"Remove dead code.",":test_tube:":"Add a failing test.",":necktie:":"Add or update business logic.",":stethoscope:":"Add or update healthcheck.",":bricks:":"Infrastructure related changes.",":technologist:":"Improve developer experience.",":money_with_wings:":"Add sponsorships or money related infrastructure.",":thread:":"Add or update code related to multithreading or concurrency.",":safety_vest:":"Add or update code related to validation."},null,2)}`,conventional:`
38
+ ${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 CI configuration files, scripts",chore:"Other changes that don't modify src or test files",revert:"Reverts a previous commit",feat:"A new feature",fix:"A bug fix"},null,2)}`},le=(e,t,r,n="")=>[`You are an expert programmer trained to write professional git commit messages following the ${r} Commits specification. Generate concise and meaningful git commit messages based on the guidelines below:`,`1. Message language: ${e}`,`2. Format: ${vi[r]}`,`3. Type: Choose the most appropriate type from the following list: ${Bi[r]}`,"4. Scope: Optional, can be anything specifying the place of the commit change","5. Description: A short summary of the code changes",`6. Subject line(first line):
39
+ - Start with a short sentence in imperative mood, present tense
40
+ - Maximum ${Math.min(Math.max(t,0),wi)} characters
41
+ - No capitalization of first letter
42
+ - No period at the end`,`7. Body(if needed):
43
+ - Write 2~5 sentences at most for the detailed explanation
44
+ - Separate from Subject by a blank line
45
+ - Use bullet points for multiple changes`,"8. Footer: Optional, for indicating breaking changes or referencing issues",`${n}`,"Avoid unnecessary explanations or translations. Your response will be used directly in git commit messages, so ensure it follows the specified format precisely."].filter(Boolean).join(`
46
+ `),pe=(e,t)=>`Provide ${e} commit messages in the following JSON array format:
47
+ [
48
+ {
49
+ "message": "${$i[t]}",
50
+ "body": "Detailed explanation if necessary"
51
+ },
52
+ {
53
+ "message": "Another ${t} commit message",
54
+ "body": "Another detailed explanation if necessary"
55
+ }
56
+ ]
57
+
58
+ Note: Your task is to create well-formatted, ${t} commit messages for each requested commit. Ensure that the messages are diverse and showcase different types and formats.`,O={OPEN_AI:"OPENAI_KEY",GEMINI:"GEMINI_KEY",ANTHROPIC:"ANTHROPIC_KEY",HUGGING:"HUGGING_COOKIE",MISTRAL:"MISTRAL_KEY",CODESTRAL:"CODESTRAL_KEY",OLLAMA:"OLLAMA_MODEL",COHERE:"COHERE_KEY",GROQ:"GROQ_KEY"},Hr=Object.values(O).map(e=>e);class U{constructor(t){this.handleError$=r=>{let n="An error occurred";return r.message&&(n=r.message),M({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`${le(t,s,o,u)}
59
+ ${pe(n,o)}
35
60
  Here are diff:
36
- ${r}`}sanitizeMessage(t,r,n){const s=t.split(`
37
- `).map(o=>o.trim().replace(/^\d+\.\s/,"")).map(o=>o.replace(/[`'"*]/g,"")).filter(o=>{switch(r){case"conventional":return Yr(o);case"gitmoji":return Wr(o);default:return!0}}).map(o=>{if(r==="conventional"){const u=/: (\w)/;return o.replace(u,(a,i)=>`: ${i.toLowerCase()}`)}return o}).filter(o=>!!o);return s.length>n?s.slice(0,n):s}}var Xr="1.10.0",ji="A Reactive CLI that generates git commit messages with various AI";class y extends Error{}const Ct=" ",he=e=>{e instanceof Error&&(e instanceof y||(e.stack&&console.error(g.dim(e.stack.split(`
61
+ ${r}`}sanitizeMessage(t,r,n,s){const o=/\[[\s\S]*?\]/;try{const u=t.match(o);if(!u)return[];const i=u[0],l=JSON.parse(i).map(p=>this.extractMessageAsType(p,r)).map(p=>s?{title:`${p.message}`,value:`${p.message}`}:{title:`${p.message}`,value:p.body?`${p.message}
62
+
63
+ ${p.body}`:`${p.message}`});return l.length>n?l.slice(0,n):l}catch{return[]}}extractMessageAsType(t,r){switch(r){case"conventional":const n=/(\w+)(?:\(.*?\))?:\s*(.*)/,s=t.message.match(n),o=s?s[0]:t.message;return{...t,message:this.normalizeCommitMessage(o)};case"gitmoji":const u=/:\w*:\s*(.*)/,i=t.message.match(u);return{...t,message:i?i[0].toLowerCase():t.message};default:return t}}normalizeCommitMessage(t){const r=/^(\w+)(\(.*?\))?:\s(.*)$/,n=t.match(r);if(n){const[,s,o,u]=n,i=s.toLowerCase(),c=u.charAt(0).toLowerCase()+u.slice(1);t=`${i}${o||""}: ${c}`}return t}}var Ur="1.11.0",xi="A Reactive CLI that generates git commit messages with various AI";class y extends Error{}const ht=" ",de=e=>{e instanceof Error&&(e instanceof y||(e.stack&&console.error(g.dim(e.stack.split(`
38
64
  `).slice(1).join(`
39
65
  `))),console.error(`
40
- ${Ct}${g.dim(`aicommit2 v${Xr}`)}`),console.error(`
41
- ${Ct}Please open a Bug report with the information above:`),console.error(`${Ct}https://github.com/tak-bro/aicommit2/issues/new/choose`)))},Jr=e=>e&&`${e[0].toUpperCase()}${e.slice(1)}`,Qr=(e,t)=>{const r=Math.ceil(e),n=Math.floor(t);return Math.floor(Math.random()*(n-r+1))+r};async function*Zr(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,P="done",en="undone",Hi=(e,t,r=!1)=>{const n=e.indexOf(t);if(n!==-1){const s=r?t.length:0;return e.slice(0,n+s).trim()}return e},tn=Y.join(Ue.homedir(),".aicommit2_log"),Ui=new Date,_=(e,t,r,n)=>{const s=`[${e} Response]`,o=Ki(Ui,t),u=`${tn}/${o}`;if(J.existsSync(u)){const i=J.readFileSync(u,"utf-8");rn(u,`${s}
66
+ ${ht}${g.dim(`aicommit2 v${Ur}`)}`),console.error(`
67
+ ${ht}Please open a Bug report with the information above:`),console.error(`${ht}https://github.com/tak-bro/aicommit2/issues/new/choose`)))},Kr=e=>e&&`${e[0].toUpperCase()}${e.slice(1)}`,zr=(e,t)=>{const r=Math.ceil(e),n=Math.floor(t);return Math.floor(Math.random()*(n-r+1))+r},fe=(e,t)=>e.disabled&&!t.disabled?1:!e.disabled&&t.disabled?-1:0,Oi="done",Mi=(e,t,r=!1)=>{const n=e.indexOf(t);if(n!==-1){const s=r?t.length:0;return e.slice(0,n+s).trim()}return e},qr=z.join(Ge.homedir(),".aicommit2_log"),Si=new Date,L=(e,t,r,n)=>{const s=`[${e} Response]`,o=Ii(Si,t),u=`${qr}/${o}`;if(q.existsSync(u)){const c=q.readFileSync(u,"utf-8");Yr(u,`${s}
42
68
  ${n}
43
69
 
44
- ${i}`);return}const a=Hi(r,"Here are diff");rn(u,`${s}
70
+ ${c}`);return}const i=Mi(r,"Here are diff");Yr(u,`${s}
45
71
  ${n}
46
72
 
47
73
 
48
74
  [AICommit2 Prompt]
49
- ${a}
75
+ ${i}
50
76
 
51
77
 
52
78
  [Git Diff]
53
- ${t}`)},Ki=(e,t)=>{const{year:r,month:n,day:s,hours:o,minutes:u,seconds:a}=qi(e),l=Yn(0).update(t).digest("hex");return`aic2_${r}-${n}-${s}_${o}:${u}:${a}_${l}.log`},rn=(e,t="")=>{J.mkdirSync(Y.dirname(e),{recursive:!0}),J.writeFileSync(e,t,"utf-8")},qi=e=>{const t=e.getFullYear().toString(),r=(e.getMonth()+1).toString().padStart(2,"0"),n=e.getDate().toString().padStart(2,"0"),s=e.getHours().toString().padStart(2,"0"),o=e.getMinutes().toString().padStart(2,"0"),u=e.getSeconds().toString().padStart(2,"0");return{year:t,month:r,day:n,hours:s,minutes:o,seconds:u}};var Et={},Ft={exports:{}},Ce={exports:{}},yt,nn;function zi(){if(nn)return yt;nn=1;var e=1e3,t=e*60,r=t*60,n=r*24,s=n*7,o=n*365.25;yt=function(f,c){c=c||{};var D=typeof f;if(D==="string"&&f.length>0)return u(f);if(D==="number"&&isFinite(f))return c.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 c=/^(-?(?:\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(c){var D=parseFloat(c[1]),p=(c[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return D*o;case"weeks":case"week":case"w":return D*s;case"days":case"day":case"d":return D*n;case"hours":case"hour":case"hrs":case"hr":case"h":return D*r;case"minutes":case"minute":case"mins":case"min":case"m":return D*t;case"seconds":case"second":case"secs":case"sec":case"s":return D*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return D;default:return}}}}function a(f){var c=Math.abs(f);return c>=n?Math.round(f/n)+"d":c>=r?Math.round(f/r)+"h":c>=t?Math.round(f/t)+"m":c>=e?Math.round(f/e)+"s":f+"ms"}function i(f){var c=Math.abs(f);return c>=n?l(f,c,n,"day"):c>=r?l(f,c,r,"hour"):c>=t?l(f,c,t,"minute"):c>=e?l(f,c,e,"second"):f+" ms"}function l(f,c,D,p){var d=c>=D*1.5;return Math.round(f/D)+" "+p+(d?"s":"")}return yt}var bt,on;function sn(){if(on)return bt;on=1;function e(t){n.debug=n,n.default=n,n.coerce=l,n.disable=u,n.enable=o,n.enabled=a,n.humanize=zi(),n.destroy=f,Object.keys(t).forEach(c=>{n[c]=t[c]}),n.names=[],n.skips=[],n.formatters={};function r(c){let D=0;for(let p=0;p<c.length;p++)D=(D<<5)-D+c.charCodeAt(p),D|=0;return n.colors[Math.abs(D)%n.colors.length]}n.selectColor=r;function n(c){let D,p=null,d,h;function m(...C){if(!m.enabled)return;const A=m,F=Number(new Date),R=F-(D||F);A.diff=R,A.prev=D,A.curr=F,D=F,C[0]=n.coerce(C[0]),typeof C[0]!="string"&&C.unshift("%O");let j=0;C[0]=C[0].replace(/%([a-zA-Z%])/g,(w,De)=>{if(w==="%%")return"%";j++;const kt=n.formatters[De];if(typeof kt=="function"){const In=C[j];w=kt.call(A,In),C.splice(j,1),j--}return w}),n.formatArgs.call(A,C),(A.log||n.log).apply(A,C)}return m.namespace=c,m.useColors=n.useColors(),m.color=n.selectColor(c),m.extend=s,m.destroy=n.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(d!==n.namespaces&&(d=n.namespaces,h=n.enabled(c)),h),set:C=>{p=C}}),typeof n.init=="function"&&n.init(m),m}function s(c,D){const p=n(this.namespace+(typeof D>"u"?":":D)+c);return p.log=this.log,p}function o(c){n.save(c),n.namespaces=c,n.names=[],n.skips=[];let D;const p=(typeof c=="string"?c:"").split(/[\s,]+/),d=p.length;for(D=0;D<d;D++)p[D]&&(c=p[D].replace(/\*/g,".*?"),c[0]==="-"?n.skips.push(new RegExp("^"+c.slice(1)+"$")):n.names.push(new RegExp("^"+c+"$")))}function u(){const c=[...n.names.map(i),...n.skips.map(i).map(D=>"-"+D)].join(",");return n.enable(""),c}function a(c){if(c[c.length-1]==="*")return!0;let D,p;for(D=0,p=n.skips.length;D<p;D++)if(n.skips[D].test(c))return!1;for(D=0,p=n.names.length;D<p;D++)if(n.names[D].test(c))return!0;return!1}function i(c){return c.toString().substring(2,c.toString().length-2).replace(/\.\*\?$/,"*")}function l(c){return c instanceof Error?c.stack||c.message:c}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 bt=e,bt}Ce.exports;var un;function Yi(){return un||(un=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,c=0;i[0].replace(/%[a-zA-Z%]/g,D=>{D!=="%%"&&(f++,D==="%c"&&(c=f))}),i.splice(c,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=sn()(t);const{formatters:a}=e.exports;a.j=function(i){try{return JSON.stringify(i)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(Ce,Ce.exports)),Ce.exports}var Ee={exports:{}},At,an;function Wi(){return an||(an=1,At=(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)}),At}var wt,cn;function Vi(){if(cn)return wt;cn=1;const e=Ue,t=ke,r=Wi(),{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 c=e.release().split(".");return Number(c[0])>=10&&Number(c[2])>=10586?Number(c[2])>=14931?3:2:1}if("CI"in n)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(c=>c in n)||n.CI_NAME==="codeship"?1: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 c=parseInt((n.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(n.TERM_PROGRAM){case"iTerm.app":return c>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(n.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(n.TERM)||"COLORTERM"in n?1:f}function a(i){const l=u(i,i&&i.isTTY);return o(l)}return wt={supportsColor:a,stdout:o(u(!0,t.isatty(1))),stderr:o(u(!0,t.isatty(2)))},wt}Ee.exports;var Dn;function Xi(){return Dn||(Dn=1,function(e,t){const r=ke,n=qt;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 D=Vi();D&&(D.stderr||D).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}t.inspectOpts=Object.keys(process.env).filter(D=>/^debug_/i.test(D)).reduce((D,p)=>{const d=p.substring(6).toLowerCase().replace(/_([a-z])/g,(m,C)=>C.toUpperCase());let h=process.env[p];return/^(yes|on|true|enabled)$/i.test(h)?h=!0:/^(no|off|false|disabled)$/i.test(h)?h=!1:h==="null"?h=null:h=Number(h),D[d]=h,D},{});function s(){return"colors"in t.inspectOpts?!!t.inspectOpts.colors:r.isatty(process.stderr.fd)}function o(D){const{namespace:p,useColors:d}=this;if(d){const h=this.color,m="\x1B[3"+(h<8?h:"8;5;"+h),C=` ${m};1m${p} \x1B[0m`;D[0]=C+D[0].split(`
79
+ ${t}`)},Ii=(e,t)=>{const{year:r,month:n,day:s,hours:o,minutes:u,seconds:i}=Pi(e),l=Rn(0).update(t).digest("hex");return`aic2_${r}-${n}-${s}_${o}:${u}:${i}_${l}.log`},Yr=(e,t="")=>{q.mkdirSync(z.dirname(e),{recursive:!0}),q.writeFileSync(e,t,"utf-8")},Pi=e=>{const t=e.getFullYear().toString(),r=(e.getMonth()+1).toString().padStart(2,"0"),n=e.getDate().toString().padStart(2,"0"),s=e.getHours().toString().padStart(2,"0"),o=e.getMinutes().toString().padStart(2,"0"),u=e.getSeconds().toString().padStart(2,"0");return{year:t,month:r,day:n,hours:s,minutes:o,seconds:u}};class _i extends U{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=r.error?.error?.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return M({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#AE5630",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Anthropic]"),this.errorPrefix=g.red.bold("[Anthropic]"),this.anthropic=new Ln({apiKey:this.params.config.ANTHROPIC_KEY})}generateCommitMessage$(){return G(this.generateMessage()).pipe(k(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),j(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s,prompt:o,logging:u}=this.params.config,i=this.params.config["max-length"],l=`${le(r,i,s,o)}
80
+ ${pe(n,s)}`,p={max_tokens:this.params.config["max-tokens"],temperature:this.params.config.temperature,system:l,messages:[{role:"user",content:`Here are diff: ${t}`}],model:this.params.config.ANTHROPIC_MODEL},D=(await this.anthropic.messages.create(p)).content.map(({text:d})=>d).join("");return u&&L("Anthropic",t,l,D),this.sanitizeMessage(D,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}}class I{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=Nn.create(this.config)}setHeaders(t){return this.config.headers=t,this}setParams(t){return this.config.params=t,this}setBody(t){return this.config.data=t,this}setMethod(t){return this.config.method=t,this}async execute(){try{return await this.axiosInstance.request(this.config)}catch(t){throw t}}}class Ti extends U{constructor(t){super(t),this.params=t,this.host="https://codestral.mistral.ai",this.apiKey="",this.handleError$=r=>{const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return M({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#e28c58",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Codestral]"),this.errorPrefix=g.red.bold("[Codestral]"),this.apiKey=this.params.config.CODESTRAL_KEY}generateCommitMessage$(){return G(this.generateMessage()).pipe(k(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),j(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s,prompt:o,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(r,t,n,i,s,o);this.checkAvailableModels();const l=await this.createChatCompletions(c);return u&&L("Codestral",t,c,l),this.sanitizeMessage(l,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}checkAvailableModels(){if(["codestral-latest","codestral-2405"].includes(this.params.config.CODESTRAL_MODEL))return!0;throw new Error("Invalid model type of Codestral AI")}async createChatCompletions(t){const n=(await new I({method:"POST",baseURL:`${this.host}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.CODESTRAL_MODEL,messages:[{role:"user",content:t}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config["max-tokens"],stream:!1,safe_prompt:!1,random_seed:zr(10,1e3)}).execute()).data;if(!n.choices||n.choices.length===0||!n.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return n.choices[0].message.content}}class Li extends U{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=/"message":\s*"([^"]*)"/,s=r.message.match(n);let o=r?.body?.message;s&&s[1]&&(o=s[1]);const u=`${r.statusCode} ${o}`;return M({name:`${this.errorPrefix} ${u}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#D18EE2",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Cohere]"),this.errorPrefix=g.red.bold("[Cohere]"),this.cohere=new kn({token:this.params.config.COHERE_KEY})}generateCommitMessage$(){return G(this.generateMessage()).pipe(k(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),j(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s,prompt:o,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(r,t,n,i,s,o),l=this.params.config["max-tokens"],a=(await this.cohere.generate({prompt:c,maxTokens:l,temperature:this.params.config.temperature,model:this.params.config.COHERE_MODEL})).generations.map(D=>D.text).join("");return u&&L("Cohere",t,c,a),this.sanitizeMessage(a,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r instanceof jn?new y("Request timed out error!"):r}}}class Ri extends U{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(c=>u.push(c[1]));const i=u[1]||"An error occurred";return M({name:`${this.errorPrefix} ${i}`,value:i,isError:!0,disabled:!0})},this.colors={primary:"#0077FF",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Gemini]"),this.errorPrefix=g.red.bold("[Gemini]"),this.genAI=new Gn(this.params.config.GEMINI_KEY)}generateCommitMessage$(){return G(this.generateMessage()).pipe(k(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),j(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s,prompt:o,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(r,t,n,i,s,o),l=this.params.config["max-tokens"],d=(await(await this.genAI.getGenerativeModel({model:this.params.config.GEMINI_MODEL,generationConfig:{maxOutputTokens:l,temperature:this.params.config.temperature}}).generateContent(c)).response).text();return u&&L("Gemini",t,c,d),this.sanitizeMessage(d,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}}class Ni extends U{constructor(t){super(t),this.params=t,this.handleError$=r=>{let n="An error occurred";const s=/"message":\s*"([^"]*)"/,o=r.message.match(s);o&&o[1]&&(n=o[1]);const u=`${r.status} ${n}`;return M({name:`${this.errorPrefix} ${u}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#f55036",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Groq]"),this.errorPrefix=g.red.bold("[Groq]"),this.groq=new Hn({apiKey:this.params.config.GROQ_KEY})}generateCommitMessage$(){return G(this.generateMessage()).pipe(k(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),j(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s,prompt:o,logging:u}=this.params.config,i=this.params.config["max-length"],l=`${le(r,i,s,o)}
81
+ ${pe(n,s)}`,a=(await this.groq.chat.completions.create({messages:[{role:"system",content:l},{role:"user",content:`Here are diff: ${t}`}],model:this.params.config.GROQ_MODEL},{timeout:this.params.config.timeout})).choices[0].message.content||"";return u&&L("Groq",t,l,a),this.sanitizeMessage(a,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){throw t}}}const{hasOwnProperty:gt}=Object.prototype,Pe=typeof process<"u"&&process.platform==="win32"?`\r
82
+ `:`
83
+ `,Ct=(e,t)=>{const r=[];let n="";typeof t=="string"?t={section:t,whitespace:!1}:(t=t||Object.create(null),t.whitespace=t.whitespace===!0);const s=t.whitespace?" = ":"=";for(const o of Object.keys(e)){const u=e[o];if(u&&Array.isArray(u))for(const i of u)n+=re(o+"[]")+s+re(i)+Pe;else u&&typeof u=="object"?r.push(o):n+=re(o)+s+re(u)+Pe}t.section&&n.length&&(n="["+re(t.section)+"]"+Pe+n);for(const o of r){const u=Wr(o).join("\\."),i=(t.section?t.section+".":"")+u,{whitespace:c}=t,l=Ct(e[o],{section:i,whitespace:c});n.length&&l.length&&(n+=Pe),n+=l}return n},Wr=e=>e.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(t=>t.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),Vr=e=>{const t=Object.create(null);let r=t,n=null;const s=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,o=e.split(/[\r\n]+/g);for(const i of o){if(!i||i.match(/^\s*[;#]/))continue;const c=i.match(s);if(!c)continue;if(c[1]!==void 0){if(n=_e(c[1]),n==="__proto__"){r=Object.create(null);continue}r=t[n]=t[n]||Object.create(null);continue}const l=_e(c[2]),p=l.length>2&&l.slice(-2)==="[]",a=p?l.slice(0,-2):l;if(a==="__proto__")continue;const D=c[3]?_e(c[4]):!0,d=D==="true"||D==="false"||D==="null"?JSON.parse(D):D;p&&(gt.call(r,a)?Array.isArray(r[a])||(r[a]=[r[a]]):r[a]=[]),Array.isArray(r[a])?r[a].push(d):r[a]=d}const u=[];for(const i of Object.keys(t)){if(!gt.call(t,i)||typeof t[i]!="object"||Array.isArray(t[i]))continue;const c=Wr(i);r=t;const l=c.pop(),p=l.replace(/\\\./g,".");for(const a of c)a!=="__proto__"&&((!gt.call(r,a)||typeof r[a]!="object")&&(r[a]=Object.create(null)),r=r[a]);r===t&&p===l||(r[p]=t[i],u.push(i))}for(const i of u)delete t[i];return t},Jr=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),re=e=>typeof e!="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&Jr(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),_e=(e,t)=>{if(e=(e||"").trim(),Jr(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:Vr,decode:Vr,stringify:Ct,encode:Ct,safe:re,unsafe:_e},Xr=J(ki);const Qr=e=>x.lstat(e).then(()=>!0,()=>!1),ji=["","conventional","gitmoji"],Et="http://localhost:11434",{hasOwnProperty:Gi}=Object.prototype,me=(e,t)=>Gi.call(e,t),E=(e,t,r)=>{if(!t)throw new y(`Invalid config property ${e}: ${r}`)},Zr={confirm(e){return e?typeof e=="boolean"?e:(E("confirm",/^(?:true|false)$/.test(e),"Must be a boolean"),e==="true"):!1},prompt(e){return e||""},locale(e){return e?(E("locale",e,"Cannot be empty"),E("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;E("generate",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return E("generate",t>0,"Must be greater than 0"),E("generate",t<=5,"Must be less or equal to 5"),t},type(e){return e?(E("type",ji.includes(e),"Invalid commit type"),e):"conventional"},proxy(e){if(!(!e||e.length===0))return E("proxy",/^https?:\/\//.test(e),"Must be a valid URL"),e},timeout(e){if(!e)return 1e4;E("timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return E("timeout",t>=500,"Must be greater than 500ms"),t},temperature(e){if(!e)return .7;E("temperature",/^(2|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 2");const t=Number(e);return E("temperature",t>0,"Must be greater than 0"),E("temperature",t<=2,"Must be less than or equal to 2"),t},"max-length"(e){if(!e)return 50;E("max-length",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return E("max-length",t>=20,"Must be greater than 20 characters"),t},"max-tokens"(e){return e?(E("max-tokens",/^\d+$/.test(e),"Must be an integer"),Number(e)):200},logging(e){return e?typeof e=="boolean"?e:(E("logging",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"):!1},ignoreBody(e){return e?typeof e=="boolean"?e:(E("ignoreBody",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"):!1}},en={OPENAI_KEY(e){return e||""},OPENAI_MODEL(e){return!e||e.length===0?"gpt-3.5-turbo":e},OPENAI_URL(e){return e?(E("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":(E("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 HuggingFace chat"),e)},GEMINI_KEY(e){return e||""},GEMINI_MODEL(e){return!e||e.length===0?"gemini-1.5-pro-latest":(E("GEMINI_MODEL",["gemini-1.5-flash-latest","gemini-1.5-pro-latest"].includes(e),"Invalid model type of Gemini"),e)},ANTHROPIC_MODEL(e){return!e||e.length===0?"claude-3-haiku-20240307":(E("ANTHROPIC_MODEL",["claude-2.1","claude-2.0","claude-instant-1.2","claude-3-haiku-20240307","claude-3-sonnet-20240229","claude-3-opus-20240229"].includes(e),"Invalid model type of Anthropic"),e)},ANTHROPIC_KEY(e){return e||""},MISTRAL_KEY(e){return e||""},MISTRAL_MODEL(e){return!e||e.length===0?"mistral-tiny":(E("MISTRAL_MODEL",["open-mistral-7b","mistral-tiny-2312","mistral-tiny","open-mixtral-8x7b","mistral-small-2312","mistral-small","mistral-small-2402","mistral-small-latest","mistral-medium-latest","mistral-medium-2312","mistral-medium","mistral-large-latest","mistral-large-2402","mistral-embed"].includes(e),"Invalid model type of Mistral AI"),e)},CODESTRAL_KEY(e){return e||""},CODESTRAL_MODEL(e){return!e||e.length===0?"codestral-latest":(E("CODESTRAL_MODEL",["codestral-latest","codestral-2405"].includes(e),"Invalid model type of Codestral"),e)},OLLAMA_MODEL(e){return e?(typeof e=="string"?e?.split(","):e).map(r=>r.trim()).filter(r=>!!r&&r.length>0):[]},OLLAMA_HOST(e){return e?(E("OLLAMA_HOST",/^https?:\/\//.test(e),"Must be a valid URL"),e):Et},OLLAMA_TIMEOUT(e){if(!e)return 1e5;E("OLLAMA_TIMEOUT",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return E("OLLAMA_TIMEOUT",t>=500,"Must be greater than 500ms"),t},OLLAMA_STREAM(e){return e?typeof e=="boolean"?e:(E("OLLAMA_STREAM",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"):!1},COHERE_KEY(e){return e||""},COHERE_MODEL(e){return!e||e.length===0?"command":(E("COHERE_MODEL",["command","command-nightly","command-light","command-light-nightly"].includes(e),"Invalid model type of Cohere"),e)},GROQ_KEY(e){return e||""},GROQ_MODEL(e){return!e||e.length===0?"gemma-7b-it":(E("GROQ_MODEL",["llama3-8b-8192","llama3-70b-8192","mixtral-8x7b-32768","gemma-7b-it"].includes(e),"Invalid model type of Groq"),e)}},Ft=z.join(Ge.homedir(),".aicommit2"),tn=async()=>{if(!await Qr(Ft))return Object.create(null);const t=await x.readFile(Ft,"utf8");let r=Xr.parse(t);return me(r,"OLLAMA_MODEL")&&(r={...r,OLLAMA_MODEL:typeof r.OLLAMA_MODEL=="string"?[r.OLLAMA_MODEL]:r.OLLAMA_MODEL}),r},yt=async(e,t)=>{const r=await tn(),n={},s={...Zr,...en};for(const o of Object.keys(s)){const u=s[o],i=e?.[o]??r[o];if(t)try{n[o]=u(i)}catch{}else n[o]=u(i)}return n},Hi=async e=>{const t=await tn(),r={...Zr,...en};for(const[n,s]of e){if(!me(r,n))throw new y(`Invalid config property: ${n}`);const o=r[n](s);t[n]=o}await x.writeFile(Ft,Xr.stringify(t),"utf8")};class Ui extends U{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 G(this.generateMessage()).pipe(k(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),j(this.handleError$))}async generateMessage(){try{const t=this.getFullPrompt();await this.prepareNewConversation();const{conversationId:r}=await this.getNewConversationId();await this.prepareConversationEvent(r);const{lastMessageId:n}=await this.getConversationInfo(r),s=await this.sendMessage(r,t,n);await this.deleteConversation(r);const{generate:o}=this.params.config;return this.sanitizeHuggingMessage(s,this.params.config.type,o)}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;o.forEach((c,l)=>{try{const p=JSON.parse(c);me(p,"type")&&p.type==="finalAnswer"&&(u=p)}catch{}});const i=this.getFullPrompt();if(!u||!me(u,"text"))throw this.params.config.logging&&L("HuggingFace",this.params.stagedDiff.diff,i,t),new Error("Cannot parse finalAnswer");return this.params.config.logging&&L("HuggingFace",this.params.stagedDiff.diff,i,u.text),this.sanitizeMessage(u.text,r,n,this.params.config.ignoreBody)}async prepareNewConversation(){return(await new I({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 I({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 I({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 I({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 I({method:"DELETE",baseURL:`${this.host}/chat/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).execute(),(await new I({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 I({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}getFullPrompt(){const{locale:t,generate:r,type:n,prompt:s}=this.params.config,o=this.params.config["max-length"],u=this.params.stagedDiff.diff;return this.buildPrompt(t,u,r,o,n,s)}}class Ki extends U{constructor(t){super(t),this.params=t,this.host="https://api.mistral.ai",this.apiKey="",this.handleError$=r=>{const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return M({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#ff7000",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[MistralAI]"),this.errorPrefix=g.red.bold("[MistralAI]"),this.apiKey=this.params.config.MISTRAL_KEY}generateCommitMessage$(){return G(this.generateMessage()).pipe(k(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),j(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s,prompt:o,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(r,t,n,i,s,o);await this.checkAvailableModels();const l=await this.createChatCompletions(c);return u&&L("MistralAI",t,c,l),this.sanitizeMessage(l,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new 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 I({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 I({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:zr(10,1e3)}).execute()).data;if(!n.choices||n.choices.length===0||!n.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return n.choices[0].message.content}}class zi extends U{constructor(t){super(t),this.params=t,this.host=Et,this.model="",this.handleError$=r=>{if(r.response&&r.response.data?.error)return M({name:`${this.errorPrefix} ${r.response.data?.error}`,value:r.response.data?.error,isError:!0,disabled:!0});const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return M({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#FFF",secondary:"#000"},this.model=this.params.keyName,this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[${Kr(this.model)}]`),this.errorPrefix=g.red.bold(`[${Kr(this.model)}]`),this.host=this.params.config.OLLAMA_HOST||Et,this.ollama=new Un({host:this.host})}generateCommitMessage$(){return G(this.generateMessage()).pipe(k(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),j(this.handleError$))}async generateMessage(){try{await this.checkIsAvailableOllama();const t=await this.createChatCompletions(),{type:r,generate:n,logging:s}=this.params.config,o=this.createSystemPrompt();return s&&L(`Ollama_${this.model}`,this.params.stagedDiff.diff,o,t),this.sanitizeMessage(t,r,n,this.params.config.ignoreBody)}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 I({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 t=this.createSystemPrompt();return(await this.ollama.chat({model:this.model,messages:[{role:"system",content:t},{role:"user",content:`Here are diff: ${this.params.stagedDiff.diff}`}],stream:!1,options:{temperature:this.params.config.temperature}})).message.content}createSystemPrompt(){return`${le(this.params.config.locale,this.params.config["max-length"],this.params.config.type,this.params.config.prompt)}
84
+ ${pe(this.params.config.generate,this.params.config.type)}`}}var bt={},At={exports:{}},he={exports:{}},wt,rn;function qi(){if(rn)return wt;rn=1;var e=1e3,t=e*60,r=t*60,n=r*24,s=n*7,o=n*365.25;wt=function(p,a){a=a||{};var D=typeof p;if(D==="string"&&p.length>0)return u(p);if(D==="number"&&isFinite(p))return a.long?c(p):i(p);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(p))};function u(p){if(p=String(p),!(p.length>100)){var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(p);if(a){var D=parseFloat(a[1]),d=(a[2]||"ms").toLowerCase();switch(d){case"years":case"year":case"yrs":case"yr":case"y":return D*o;case"weeks":case"week":case"w":return D*s;case"days":case"day":case"d":return D*n;case"hours":case"hour":case"hrs":case"hr":case"h":return D*r;case"minutes":case"minute":case"mins":case"min":case"m":return D*t;case"seconds":case"second":case"secs":case"sec":case"s":return D*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return D;default:return}}}}function i(p){var a=Math.abs(p);return a>=n?Math.round(p/n)+"d":a>=r?Math.round(p/r)+"h":a>=t?Math.round(p/t)+"m":a>=e?Math.round(p/e)+"s":p+"ms"}function c(p){var a=Math.abs(p);return a>=n?l(p,a,n,"day"):a>=r?l(p,a,r,"hour"):a>=t?l(p,a,t,"minute"):a>=e?l(p,a,e,"second"):p+" ms"}function l(p,a,D,d){var f=a>=D*1.5;return Math.round(p/D)+" "+d+(f?"s":"")}return wt}var vt,nn;function on(){if(nn)return vt;nn=1;function e(t){n.debug=n,n.default=n,n.coerce=l,n.disable=u,n.enable=o,n.enabled=i,n.humanize=qi(),n.destroy=p,Object.keys(t).forEach(a=>{n[a]=t[a]}),n.names=[],n.skips=[],n.formatters={};function r(a){let D=0;for(let d=0;d<a.length;d++)D=(D<<5)-D+a.charCodeAt(d),D|=0;return n.colors[Math.abs(D)%n.colors.length]}n.selectColor=r;function n(a){let D,d=null,f,h;function m(...C){if(!m.enabled)return;const b=m,B=Number(new Date),R=B-(D||B);b.diff=R,b.prev=D,b.curr=B,D=B,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,(A,se)=>{if(A==="%%")return"%";N++;const Rt=n.formatters[se];if(typeof Rt=="function"){const bn=C[N];A=Rt.call(b,bn),C.splice(N,1),N--}return A}),n.formatArgs.call(b,C),(b.log||n.log).apply(b,C)}return m.namespace=a,m.useColors=n.useColors(),m.color=n.selectColor(a),m.extend=s,m.destroy=n.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(f!==n.namespaces&&(f=n.namespaces,h=n.enabled(a)),h),set:C=>{d=C}}),typeof n.init=="function"&&n.init(m),m}function s(a,D){const d=n(this.namespace+(typeof D>"u"?":":D)+a);return d.log=this.log,d}function o(a){n.save(a),n.namespaces=a,n.names=[],n.skips=[];let D;const d=(typeof a=="string"?a:"").split(/[\s,]+/),f=d.length;for(D=0;D<f;D++)d[D]&&(a=d[D].replace(/\*/g,".*?"),a[0]==="-"?n.skips.push(new RegExp("^"+a.slice(1)+"$")):n.names.push(new RegExp("^"+a+"$")))}function u(){const a=[...n.names.map(c),...n.skips.map(c).map(D=>"-"+D)].join(",");return n.enable(""),a}function i(a){if(a[a.length-1]==="*")return!0;let D,d;for(D=0,d=n.skips.length;D<d;D++)if(n.skips[D].test(a))return!1;for(D=0,d=n.names.length;D<d;D++)if(n.names[D].test(a))return!0;return!1}function c(a){return a.toString().substring(2,a.toString().length-2).replace(/\.\*\?$/,"*")}function l(a){return a instanceof Error?a.stack||a.message:a}function p(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}return vt=e,vt}he.exports;var sn;function Yi(){return sn||(sn=1,function(e,t){t.formatArgs=n,t.save=s,t.load=o,t.useColors=r,t.storage=u(),t.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;c.splice(1,0,l,"color: inherit");let p=0,a=0;c[0].replace(/%[a-zA-Z%]/g,D=>{D!=="%%"&&(p++,D==="%c"&&(a=p))}),c.splice(a,0,l)}t.log=console.debug||console.log||(()=>{});function s(c){try{c?t.storage.setItem("debug",c):t.storage.removeItem("debug")}catch{}}function o(){let c;try{c=t.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c}function u(){try{return localStorage}catch{}}e.exports=on()(t);const{formatters:i}=e.exports;i.j=function(c){try{return JSON.stringify(c)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(he,he.exports)),he.exports}var ge={exports:{}},$t,un;function Wi(){return un||(un=1,$t=(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)}),$t}var Bt,an;function Vi(){if(an)return Bt;an=1;const e=Ge,t=Re,r=Wi(),{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(c){return c===0?!1:{level:c,hasBasic:!0,has256:c>=2,has16m:c>=3}}function u(c,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(c&&!l&&s===void 0)return 0;const p=s||0;if(n.TERM==="dumb")return p;if(process.platform==="win32"){const a=e.release().split(".");return Number(a[0])>=10&&Number(a[2])>=10586?Number(a[2])>=14931?3:2:1}if("CI"in n)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(a=>a in n)||n.CI_NAME==="codeship"?1:p;if("TEAMCITY_VERSION"in n)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(n.TEAMCITY_VERSION)?1:0;if(n.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in n){const a=parseInt((n.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(n.TERM_PROGRAM){case"iTerm.app":return a>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(n.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(n.TERM)||"COLORTERM"in n?1:p}function i(c){const l=u(c,c&&c.isTTY);return o(l)}return Bt={supportsColor:i,stdout:o(u(!0,t.isatty(1))),stderr:o(u(!0,t.isatty(2)))},Bt}ge.exports;var cn;function Ji(){return cn||(cn=1,function(e,t){const r=Re,n=Ut;t.init=p,t.log=i,t.formatArgs=o,t.save=c,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 D=Vi();D&&(D.stderr||D).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}t.inspectOpts=Object.keys(process.env).filter(D=>/^debug_/i.test(D)).reduce((D,d)=>{const f=d.substring(6).toLowerCase().replace(/_([a-z])/g,(m,C)=>C.toUpperCase());let h=process.env[d];return/^(yes|on|true|enabled)$/i.test(h)?h=!0:/^(no|off|false|disabled)$/i.test(h)?h=!1:h==="null"?h=null:h=Number(h),D[f]=h,D},{});function s(){return"colors"in t.inspectOpts?!!t.inspectOpts.colors:r.isatty(process.stderr.fd)}function o(D){const{namespace:d,useColors:f}=this;if(f){const h=this.color,m="\x1B[3"+(h<8?h:"8;5;"+h),C=` ${m};1m${d} \x1B[0m`;D[0]=C+D[0].split(`
54
85
  `).join(`
55
- `+C),D.push(m+"m+"+e.exports.humanize(this.diff)+"\x1B[0m")}else D[0]=u()+p+" "+D[0]}function u(){return t.inspectOpts.hideDate?"":new Date().toISOString()+" "}function a(...D){return process.stderr.write(n.formatWithOptions(t.inspectOpts,...D)+`
56
- `)}function i(D){D?process.env.DEBUG=D:delete process.env.DEBUG}function l(){return process.env.DEBUG}function f(D){D.inspectOpts={};const p=Object.keys(t.inspectOpts);for(let d=0;d<p.length;d++)D.inspectOpts[p[d]]=t.inspectOpts[p[d]]}e.exports=sn()(t);const{formatters:c}=e.exports;c.o=function(D){return this.inspectOpts.colors=this.useColors,n.inspect(D,this.inspectOpts).split(`
57
- `).map(p=>p.trim()).join(" ")},c.O=function(D){return this.inspectOpts.colors=this.useColors,n.inspect(D,this.inspectOpts)}}(Ee,Ee.exports)),Ee.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Ft.exports=Yi():Ft.exports=Xi();var $t=Ft.exports,vt={};Object.defineProperty(vt,"__esModule",{value:!0});function Ji(e){return function(t,r){return new Promise((n,s)=>{e.call(this,t,r,(o,u)=>{o?s(o):n(u)})})}}vt.default=Ji;var ln=$&&$.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const Qi=Kt,Zi=ln($t),ea=ln(vt),Fe=Zi.default("agent-base");function ta(e){return!!e&&typeof e.addRequest=="function"}function xt(){const{stack:e}=new Error;return typeof e!="string"?!1:e.split(`
58
- `).some(t=>t.indexOf("(https.js:")!==-1||t.indexOf("node:https:")!==-1)}function Le(e,t){return new Le.Agent(e,t)}(function(e){class t extends Qi.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:xt()?443:80}set defaultPort(n){this.explicitDefaultPort=n}get protocol(){return typeof this.explicitProtocol=="string"?this.explicitProtocol:xt()?"https:":"http:"}set protocol(n){this.explicitProtocol=n}callback(n,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=xt()),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)},c=p=>{u||(a!==null&&(clearTimeout(a),a=null),l(p))},D=p=>{if(u)return;if(a!=null&&(clearTimeout(a),a=null),ta(p)){Fe("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?(Fe("Converting legacy callback function to promise"),this.promisifiedCallback=ea.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{Fe("Resolving socket for %o request: %o",o.protocol,`${n.method} ${n.path}`),Promise.resolve(this.promisifiedCallback(n,o)).then(D,c)}catch(p){Promise.reject(p).catch(c)}}freeSocket(n,s){Fe("Freeing socket %o %o",n.constructor.name,s),n.destroy()}destroy(){Fe("Destroying agent %o",this.constructor.name)}}e.Agent=t,e.prototype=e.Agent.prototype})(Le||(Le={}));var ra=Le,Ot={},na=$&&$.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ot,"__esModule",{value:!0});const oa=na($t),ye=oa.default("https-proxy-agent:parse-proxy-response");function sa(e){return new Promise((t,r)=>{let n=0;const s=[];function o(){const c=e.read();c?f(c):e.once("readable",o)}function u(){e.removeListener("end",i),e.removeListener("error",l),e.removeListener("close",a),e.removeListener("readable",o)}function a(c){ye("onclose had error %o",c)}function i(){ye("onend")}function l(c){u(),ye("onerror %o",c),r(c)}function f(c){s.push(c),n+=c.length;const D=Buffer.concat(s,n);if(D.indexOf(`\r
86
+ `+C),D.push(m+"m+"+e.exports.humanize(this.diff)+"\x1B[0m")}else D[0]=u()+d+" "+D[0]}function u(){return t.inspectOpts.hideDate?"":new Date().toISOString()+" "}function i(...D){return process.stderr.write(n.formatWithOptions(t.inspectOpts,...D)+`
87
+ `)}function c(D){D?process.env.DEBUG=D:delete process.env.DEBUG}function l(){return process.env.DEBUG}function p(D){D.inspectOpts={};const d=Object.keys(t.inspectOpts);for(let f=0;f<d.length;f++)D.inspectOpts[d[f]]=t.inspectOpts[d[f]]}e.exports=on()(t);const{formatters:a}=e.exports;a.o=function(D){return this.inspectOpts.colors=this.useColors,n.inspect(D,this.inspectOpts).split(`
88
+ `).map(d=>d.trim()).join(" ")},a.O=function(D){return this.inspectOpts.colors=this.useColors,n.inspect(D,this.inspectOpts)}}(ge,ge.exports)),ge.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?At.exports=Yi():At.exports=Ji();var xt=At.exports,Ot={};Object.defineProperty(Ot,"__esModule",{value:!0});function Xi(e){return function(t,r){return new Promise((n,s)=>{e.call(this,t,r,(o,u)=>{o?s(o):n(u)})})}}Ot.default=Xi;var Dn=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const Qi=Ht,Zi=Dn(xt),ea=Dn(Ot),Ce=Zi.default("agent-base");function ta(e){return!!e&&typeof e.addRequest=="function"}function Mt(){const{stack:e}=new Error;return typeof e!="string"?!1:e.split(`
89
+ `).some(t=>t.indexOf("(https.js:")!==-1||t.indexOf("node:https:")!==-1)}function Te(e,t){return new Te.Agent(e,t)}(function(e){class t extends Qi.EventEmitter{constructor(n,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:Mt()?443:80}set defaultPort(n){this.explicitDefaultPort=n}get protocol(){return typeof this.explicitProtocol=="string"?this.explicitProtocol:Mt()?"https:":"http:"}set protocol(n){this.explicitProtocol=n}callback(n,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=Mt()),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,i=null;const c=o.timeout||this.timeout,l=d=>{n._hadError||(n.emit("error",d),n._hadError=!0)},p=()=>{i=null,u=!0;const d=new Error(`A "socket" was not created for HTTP request before ${c}ms`);d.code="ETIMEOUT",l(d)},a=d=>{u||(i!==null&&(clearTimeout(i),i=null),l(d))},D=d=>{if(u)return;if(i!=null&&(clearTimeout(i),i=null),ta(d)){Ce("Callback returned another Agent instance %o",d.constructor.name),d.addRequest(n,o);return}if(d){d.once("free",()=>{this.freeSocket(d,o)}),n.onSocket(d);return}const f=new Error(`no Duplex stream was returned to agent-base for \`${n.method} ${n.path}\``);l(f)};if(typeof this.callback!="function"){l(new Error("`callback` is not defined"));return}this.promisifiedCallback||(this.callback.length>=3?(Ce("Converting legacy callback function to promise"),this.promisifiedCallback=ea.default(this.callback)):this.promisifiedCallback=this.callback),typeof c=="number"&&c>0&&(i=setTimeout(p,c)),"port"in o&&typeof o.port!="number"&&(o.port=Number(o.port));try{Ce("Resolving socket for %o request: %o",o.protocol,`${n.method} ${n.path}`),Promise.resolve(this.promisifiedCallback(n,o)).then(D,a)}catch(d){Promise.reject(d).catch(a)}}freeSocket(n,s){Ce("Freeing socket %o %o",n.constructor.name,s),n.destroy()}destroy(){Ce("Destroying agent %o",this.constructor.name)}}e.Agent=t,e.prototype=e.Agent.prototype})(Te||(Te={}));var ra=Te,St={},na=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(St,"__esModule",{value:!0});const oa=na(xt),Ee=oa.default("https-proxy-agent:parse-proxy-response");function sa(e){return new Promise((t,r)=>{let n=0;const s=[];function o(){const a=e.read();a?p(a):e.once("readable",o)}function u(){e.removeListener("end",c),e.removeListener("error",l),e.removeListener("close",i),e.removeListener("readable",o)}function i(a){Ee("onclose had error %o",a)}function c(){Ee("onend")}function l(a){u(),Ee("onerror %o",a),r(a)}function p(a){s.push(a),n+=a.length;const D=Buffer.concat(s,n);if(D.indexOf(`\r
59
90
  \r
60
- `)===-1){ye("have not received end of HTTP headers yet..."),o();return}const d=D.toString("ascii",0,D.indexOf(`\r
61
- `)),h=+d.split(" ")[1];ye("got proxy server response: %o",d),t({statusCode:h,buffered:D})}e.on("error",l),e.on("close",a),e.on("end",i),o()})}Ot.default=sa;var ua=$&&$.__awaiter||function(e,t,r,n){function s(o){return o instanceof r?o:new r(function(u){u(o)})}return new(r||(r=Promise))(function(o,u){function a(f){try{l(n.next(f))}catch(c){u(c)}}function i(f){try{l(n.throw(f))}catch(c){u(c)}}function l(f){f.done?o(f.value):s(f.value).then(a,i)}l((n=n.apply(e,t||[])).next())})},ae=$&&$.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Et,"__esModule",{value:!0});const fn=ae(Xn),pn=ae(Jn),ia=ae(Qn),aa=ae(Ut),ca=ae($t),Da=ra,la=ae(Ot),be=ca.default("https-proxy-agent:agent");class fa extends Da.Agent{constructor(t){let r;if(typeof t=="string"?r=ia.default.parse(t):r=t,!r)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");be("creating new HttpsProxyAgent instance: %o",r),super(r);const n=Object.assign({},r);this.secureProxy=r.secureProxy||ma(n.protocol),n.host=n.hostname||n.host,typeof n.port=="string"&&(n.port=parseInt(n.port,10)),!n.port&&n.host&&(n.port=this.secureProxy?443:80),this.secureProxy&&!("ALPNProtocols"in n)&&(n.ALPNProtocols=["http 1.1"]),n.host&&n.path&&(delete n.path,delete n.pathname),this.proxy=n}callback(t,r){return ua(this,void 0,void 0,function*(){const{proxy:n,secureProxy:s}=this;let o;s?(be("Creating `tls.Socket`: %o",n),o=pn.default.connect(n)):(be("Creating `net.Socket`: %o",n),o=fn.default.connect(n));const u=Object.assign({},n.headers);let i=`CONNECT ${`${r.host}:${r.port}`} HTTP/1.1\r
62
- `;n.auth&&(u["Proxy-Authorization"]=`Basic ${Buffer.from(n.auth).toString("base64")}`);let{host:l,port:f,secureEndpoint:c}=r;da(f,c)||(l+=`:${f}`),u.Host=l,u.Connection="close";for(const m of Object.keys(u))i+=`${m}: ${u[m]}\r
63
- `;const D=la.default(o);o.write(`${i}\r
64
- `);const{statusCode:p,buffered:d}=yield D;if(p===200){if(t.once("socket",pa),r.secureEndpoint){be("Upgrading socket connection to TLS");const m=r.servername||r.host;return pn.default.connect(Object.assign(Object.assign({},ha(r,"host","hostname","path","port")),{socket:o,servername:m}))}return o}o.destroy();const h=new fn.default.Socket({writable:!1});return h.readable=!0,t.once("socket",m=>{be("replaying proxy buffer for failed request"),aa.default(m.listenerCount("data")>0),m.push(d),m.push(null)}),h})}}Et.default=fa;function pa(e){e.resume()}function da(e,t){return!!(!t&&e===80||t&&e===443)}function ma(e){return typeof e=="string"?/^https:?$/i.test(e):!1}function ha(e,...t){const r={};let n;for(n in e)t.includes(n)||(r[n]=e[n]);return r}var ga=$&&$.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const Bt=ga(Et);function Mt(e){return new Bt.default(e)}(function(e){e.HttpsProxyAgent=Bt.default,e.prototype=Bt.default.prototype})(Mt||(Mt={}));var Ca=Mt,Ea=re(Ca);const Fa=async(e,t,r,n,s,o,u)=>new Promise((a,i)=>{const l=JSON.stringify(n),c=(e.protocol.includes("https")?Vn:Wn).request({port:u||void 0,hostname:e.hostname,path:t,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(l),...r},timeout:s,agent:o?Ea(o):void 0},D=>{const p=[];D.on("data",d=>p.push(d)),D.on("end",()=>{a({request:c,response:D,data:Buffer.concat(p).toString()})})});c.on("error",i),c.on("timeout",()=>{c.destroy(),i(new y(`Time out error: request took over ${s}ms. Try increasing the \`timeout\` config`))}),c.write(l),c.end()}),ya=async(e,t,r,n,s,o)=>{const u=new URL(e),{response:a,data:i}=await Fa(u,t,{Authorization:`Bearer ${r}`},n,s,o);if(!a.statusCode||a.statusCode<200||a.statusCode>299){let l=`OpenAI API Error: ${a.statusCode} - ${a.statusMessage}`;throw i&&(l+=`
91
+ `)===-1){Ee("have not received end of HTTP headers yet..."),o();return}const f=D.toString("ascii",0,D.indexOf(`\r
92
+ `)),h=+f.split(" ")[1];Ee("got proxy server response: %o",f),t({statusCode:h,buffered:D})}e.on("error",l),e.on("close",i),e.on("end",c),o()})}St.default=sa;var ua=w&&w.__awaiter||function(e,t,r,n){function s(o){return o instanceof r?o:new r(function(u){u(o)})}return new(r||(r=Promise))(function(o,u){function i(p){try{l(n.next(p))}catch(a){u(a)}}function c(p){try{l(n.throw(p))}catch(a){u(a)}}function l(p){p.done?o(p.value):s(p.value).then(i,c)}l((n=n.apply(e,t||[])).next())})},ne=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(bt,"__esModule",{value:!0});const ln=ne(qn),pn=ne(Yn),ia=ne(Wn),aa=ne(Gt),ca=ne(xt),Da=ra,la=ne(St),Fe=ca.default("https-proxy-agent:agent");class pa extends Da.Agent{constructor(t){let r;if(typeof t=="string"?r=ia.default.parse(t):r=t,!r)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");Fe("creating new HttpsProxyAgent instance: %o",r),super(r);const n=Object.assign({},r);this.secureProxy=r.secureProxy||ma(n.protocol),n.host=n.hostname||n.host,typeof n.port=="string"&&(n.port=parseInt(n.port,10)),!n.port&&n.host&&(n.port=this.secureProxy?443:80),this.secureProxy&&!("ALPNProtocols"in n)&&(n.ALPNProtocols=["http 1.1"]),n.host&&n.path&&(delete n.path,delete n.pathname),this.proxy=n}callback(t,r){return ua(this,void 0,void 0,function*(){const{proxy:n,secureProxy:s}=this;let o;s?(Fe("Creating `tls.Socket`: %o",n),o=pn.default.connect(n)):(Fe("Creating `net.Socket`: %o",n),o=ln.default.connect(n));const u=Object.assign({},n.headers);let c=`CONNECT ${`${r.host}:${r.port}`} HTTP/1.1\r
93
+ `;n.auth&&(u["Proxy-Authorization"]=`Basic ${Buffer.from(n.auth).toString("base64")}`);let{host:l,port:p,secureEndpoint:a}=r;fa(p,a)||(l+=`:${p}`),u.Host=l,u.Connection="close";for(const m of Object.keys(u))c+=`${m}: ${u[m]}\r
94
+ `;const D=la.default(o);o.write(`${c}\r
95
+ `);const{statusCode:d,buffered:f}=yield D;if(d===200){if(t.once("socket",da),r.secureEndpoint){Fe("Upgrading socket connection to TLS");const m=r.servername||r.host;return pn.default.connect(Object.assign(Object.assign({},ha(r,"host","hostname","path","port")),{socket:o,servername:m}))}return o}o.destroy();const h=new ln.default.Socket({writable:!1});return h.readable=!0,t.once("socket",m=>{Fe("replaying proxy buffer for failed request"),aa.default(m.listenerCount("data")>0),m.push(f),m.push(null)}),h})}}bt.default=pa;function da(e){e.resume()}function fa(e,t){return!!(!t&&e===80||t&&e===443)}function ma(e){return typeof e=="string"?/^https:?$/i.test(e):!1}function ha(e,...t){const r={};let n;for(n in e)t.includes(n)||(r[n]=e[n]);return r}var ga=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const It=ga(bt);function Pt(e){return new It.default(e)}(function(e){e.HttpsProxyAgent=It.default,e.prototype=It.default.prototype})(Pt||(Pt={}));var Ca=Pt,Ea=J(Ca);const Fa=async(e,t,r,n,s,o,u)=>new Promise((i,c)=>{const l=JSON.stringify(n),a=(e.protocol.includes("https")?zn:Kn).request({port:u||void 0,hostname:e.hostname,path:t,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(l),...r},timeout:s,agent:o?Ea(o):void 0},D=>{const d=[];D.on("data",f=>d.push(f)),D.on("end",()=>{i({request:a,response:D,data:Buffer.concat(d).toString()})})});a.on("error",c),a.on("timeout",()=>{a.destroy(),c(new y(`Time out error: request took over ${s}ms. Try increasing the \`timeout\` config`))}),a.write(l),a.end()}),ya=async(e,t,r,n,s,o)=>{const u=new URL(e),{response:i,data:c}=await Fa(u,t,{Authorization:`Bearer ${r}`},n,s,o);if(!i.statusCode||i.statusCode<200||i.statusCode>299){let l=`OpenAI API Error: ${i.statusCode} - ${i.statusMessage}`;throw c&&(l+=`
65
96
 
66
- ${i}`),a.statusCode===500&&(l+=`
97
+ ${c}`),i.statusCode===500&&(l+=`
67
98
 
68
- Check the API status: https://status.openai.com`),new y(l)}return JSON.parse(i)},dn=e=>e.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1"),N=e=>Array.from(new Set(e)),ba=async(e,t,r,n,s,o,u,a,i,l,f,c,D,p,d)=>{try{const h=W(s,a,i,D),m=await ya(e,t,r,{model:n,messages:[{role:"system",content:h},{role:"user",content:`Here are diff: ${o}`}],temperature:c,top_p:1,frequency_penalty:0,presence_penalty:0,max_tokens:f,stream:!1,n:u},l,d),C=N(m.choices.filter(F=>F.message?.content).map(F=>dn(F.message.content)).map(F=>{if(i==="conventional"){const R=/: (\w)/;return F.replace(R,(j,X)=>`: ${X.toLowerCase()}`)}return F}).filter(F=>{switch(i){case"gitmoji":return Wr(F);case"conventional":return Yr(F);case"":default:return!0}})),A=m.choices.filter(F=>F.message?.content).map(F=>dn(F.message.content)).join();return p&&_("OPEN AI",o,h,A),C}catch(h){const m=h;throw m.code==="ENOTFOUND"?new y(`Error connecting to ${m.hostname} (${m.syscall})`):m}};class Aa extends q{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 k({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"],l=`${W(n,a,o,u)}
69
- ${ee(s)}`,f={max_tokens:this.params.config["max-tokens"],temperature:this.params.config.temperature,system:l,messages:[{role:"user",content:r}],model:this.params.config.ANTHROPIC_MODEL,stream:!0},c=this.anthropic.messages.create(f);let D="";return O(Zr(c)).pipe(zt(p=>["content_block_delta","message_stop"].includes(p.type)),B(p=>p),Yt(p=>{p.type==="content_block_delta"&&(D+=p.delta.text)}),B(p=>{const d=p.type==="message_stop";return{id:this.params.keyName,name:`${this.serviceName} ${D}`,value:`${D}`,isError:!1,description:d?P:en,disabled:!d}}))},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 zn({apiKey:this.params.config.ANTHROPIC_KEY})}generateCommitMessage$(){return G(this.generateMessage()).pipe(L(t=>O(t)),B(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s,prompt:o,logging:u}=this.params.config,a=this.params.config["max-length"],l=`${W(r,a,s,o)}
70
- ${ee(n)}`,f={max_tokens:this.params.config["max-tokens"],temperature:this.params.config.temperature,system:l,messages:[{role:"user",content:`Here are diff: ${t}`}],model:this.params.config.ANTHROPIC_MODEL},D=(await this.anthropic.messages.create(f)).content.map(({text:p})=>p).join("");return u&&_("Anthropic",t,l,D),N(this.sanitizeMessage(D,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(Wt((t,r)=>{if(r.description===P){const o=N(this.sanitizeMessage(r.value,this.params.config.type,this.params.config.generate)),u=this.params.stagedDiff.diff,{locale:a,generate:i,type:l,prompt:f,logging:c}=this.params.config,D=this.params.config["max-length"],d=`${W(a,D,l,f)}
71
- ${ee(i)}`;return c&&_("Anthropic",u,d,r.value),!o||o.length===0?[{id:`${this.params.keyName}_${P}_0`,name:`${this.serviceName} Failed to extract messages from response`,value:"Failed to extract messages from response",isError:!0,description:P,disabled:!0}]:o.map((m,C)=>({id:`${this.params.keyName}_${P}_${C}`,name:`${this.serviceName} ${m}`,value:`${m}`,isError:!1,description:P,disabled:!1}))}return t.find(o=>o.id===r.id)?[...t.map(o=>r.id===o.id?r:o)]:[{...r}]},[]),L(t=>t),T(this.handleError$))}}const{hasOwnProperty:St}=Object.prototype,Te=typeof process<"u"&&process.platform==="win32"?`\r
72
- `:`
73
- `,It=(e,t)=>{const r=[];let n="";typeof t=="string"?t={section:t,whitespace:!1}:(t=t||Object.create(null),t.whitespace=t.whitespace===!0);const 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+=ce(o+"[]")+s+ce(a)+Te;else u&&typeof u=="object"?r.push(o):n+=ce(o)+s+ce(u)+Te}t.section&&n.length&&(n="["+ce(t.section)+"]"+Te+n);for(const o of r){const u=mn(o).join("\\."),a=(t.section?t.section+".":"")+u,{whitespace:i}=t,l=It(e[o],{section:a,whitespace:i});n.length&&l.length&&(n+=Te),n+=l}return n},mn=e=>e.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(t=>t.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),hn=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=Ne(i[1]),n==="__proto__"){r=Object.create(null);continue}r=t[n]=t[n]||Object.create(null);continue}const l=Ne(i[2]),f=l.length>2&&l.slice(-2)==="[]",c=f?l.slice(0,-2):l;if(c==="__proto__")continue;const D=i[3]?Ne(i[4]):!0,p=D==="true"||D==="false"||D==="null"?JSON.parse(D):D;f&&(St.call(r,c)?Array.isArray(r[c])||(r[c]=[r[c]]):r[c]=[]),Array.isArray(r[c])?r[c].push(p):r[c]=p}const u=[];for(const a of Object.keys(t)){if(!St.call(t,a)||typeof t[a]!="object"||Array.isArray(t[a]))continue;const i=mn(a);r=t;const l=i.pop(),f=l.replace(/\\\./g,".");for(const c of i)c!=="__proto__"&&((!St.call(r,c)||typeof r[c]!="object")&&(r[c]=Object.create(null)),r=r[c]);r===t&&f===l||(r[f]=t[a],u.push(a))}for(const a of u)delete t[a];return t},gn=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),ce=e=>typeof e!="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&gn(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),Ne=(e,t)=>{if(e=(e||"").trim(),gn(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 wa={parse:hn,decode:hn,stringify:It,encode:It,safe:ce,unsafe:Ne},Cn=re(wa);const En=e=>S.lstat(e).then(()=>!0,()=>!1),$a=["","conventional","gitmoji"],Pt="http://localhost:11434",{hasOwnProperty:va}=Object.prototype,V=(e,t)=>va.call(e,t),E=(e,t,r)=>{if(!t)throw new y(`Invalid config property ${e}: ${r}`)},Fn={confirm(e){return e?typeof e=="boolean"?e:(E("confirm",/^(?:true|false)$/.test(e),"Must be a boolean"),e==="true"):!1},prompt(e){return e||""},locale(e){return e?(E("locale",e,"Cannot be empty"),E("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;E("generate",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return E("generate",t>0,"Must be greater than 0"),E("generate",t<=5,"Must be less or equal to 5"),t},type(e){return e?(E("type",$a.includes(e),"Invalid commit type"),e):"conventional"},proxy(e){if(!(!e||e.length===0))return E("proxy",/^https?:\/\//.test(e),"Must be a valid URL"),e},timeout(e){if(!e)return 1e4;E("timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return E("timeout",t>=500,"Must be greater than 500ms"),t},temperature(e){if(!e)return .7;E("temperature",/^(2|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 2");const t=Number(e);return E("temperature",t>0,"Must be greater than 0"),E("temperature",t<=2,"Must be less than or equal to 2"),t},"max-length"(e){if(!e)return 50;E("max-length",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return E("max-length",t>=20,"Must be greater than 20 characters"),t},"max-tokens"(e){return e?(E("max-tokens",/^\d+$/.test(e),"Must be an integer"),Number(e)):200},logging(e){return e?typeof e=="boolean"?e:(E("logging",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"):!1}},yn={OPENAI_KEY(e){return e||""},OPENAI_MODEL(e){return!e||e.length===0?"gpt-3.5-turbo":e},OPENAI_URL(e){return e?(E("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":(E("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 HuggingFace chat"),e)},CLOVAX_COOKIE(e){return e||""},GEMINI_KEY(e){return e||""},GEMINI_MODEL(e){return!e||e.length===0?"gemini-1.5-pro-latest":(E("GEMINI_MODEL",["gemini-1.5-flash-latest","gemini-1.5-pro-latest"].includes(e),"Invalid model type of Gemini"),e)},ANTHROPIC_MODEL(e){return!e||e.length===0?"claude-3-haiku-20240307":(E("ANTHROPIC_MODEL",["claude-2.1","claude-2.0","claude-instant-1.2","claude-3-haiku-20240307","claude-3-sonnet-20240229","claude-3-opus-20240229"].includes(e),"Invalid model type of Anthropic"),e)},ANTHROPIC_KEY(e){return e||""},MISTRAL_KEY(e){return e||""},MISTRAL_MODEL(e){return!e||e.length===0?"mistral-tiny":(E("MISTRAL_MODEL",["open-mistral-7b","mistral-tiny-2312","mistral-tiny","open-mixtral-8x7b","mistral-small-2312","mistral-small","mistral-small-2402","mistral-small-latest","mistral-medium-latest","mistral-medium-2312","mistral-medium","mistral-large-latest","mistral-large-2402","mistral-embed"].includes(e),"Invalid model type of Mistral AI"),e)},CODESTRAL_KEY(e){return e||""},CODESTRAL_MODEL(e){return!e||e.length===0?"codestral-latest":(E("CODESTRAL_MODEL",["codestral-latest","codestral-2405"].includes(e),"Invalid model type of Codestral"),e)},OLLAMA_MODEL(e){return e?(typeof e=="string"?e?.split(","):e).map(r=>r.trim()).filter(r=>!!r&&r.length>0):[]},OLLAMA_HOST(e){return e?(E("OLLAMA_HOST",/^https?:\/\//.test(e),"Must be a valid URL"),e):Pt},OLLAMA_TIMEOUT(e){if(!e)return 1e5;E("OLLAMA_TIMEOUT",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return E("OLLAMA_TIMEOUT",t>=500,"Must be greater than 500ms"),t},OLLAMA_STREAM(e){return e?typeof e=="boolean"?e:(E("OLLAMA_STREAM",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"):!1},COHERE_KEY(e){return e||""},COHERE_MODEL(e){return!e||e.length===0?"command":(E("COHERE_MODEL",["command","command-nightly","command-light","command-light-nightly"].includes(e),"Invalid model type of Cohere"),e)},GROQ_KEY(e){return e||""},GROQ_MODEL(e){return!e||e.length===0?"gemma-7b-it":(E("GROQ_MODEL",["llama3-8b-8192","llama3-70b-8192","mixtral-8x7b-32768","gemma-7b-it"].includes(e),"Invalid model type of Groq"),e)}},_t=Y.join(Ue.homedir(),".aicommit2"),bn=async()=>{if(!await En(_t))return Object.create(null);const t=await S.readFile(_t,"utf8");let r=Cn.parse(t);return V(r,"OLLAMA_MODEL")&&(r={...r,OLLAMA_MODEL:typeof r.OLLAMA_MODEL=="string"?[r.OLLAMA_MODEL]:r.OLLAMA_MODEL}),r},Lt=async(e,t)=>{const r=await bn(),n={},s={...Fn,...yn};for(const o of Object.keys(s)){const u=s[o],a=e?.[o]??r[o];if(t)try{n[o]=u(a)}catch{}else n[o]=u(a)}return n},xa=async e=>{const t=await bn(),r={...Fn,...yn};for(const[n,s]of e){if(!V(r,n))throw new y(`Invalid config property: ${n}`);const o=r[n](s);t[n]=o}await S.writeFile(_t,Cn.stringify(t),"utf8")};class M{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=no.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 Oa extends q{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 G(this.generateMessage()).pipe(L(t=>O(t)),B((t,r)=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),T(this.handleError$))}async generateMessage(){try{const{locale:t,generate:r,type:n,prompt:s,logging:o}=this.params.config,u=this.params.config["max-length"],a=this.params.stagedDiff.diff,i=this.buildPrompt(t,a,r,u,n,s);await this.getAllConversationIds();const l=await this.sendMessage(i),{conversationId:f,allText:c}=this.parseSendMessageResult(l);return await this.deleteConversation(f),o&&_("CLOVA X",a,i,c),N(this.sanitizeMessage(c,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 M({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 to;return n.set("form",new ro([JSON.stringify(r)],{type:"application/json"})),(await new M({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 M({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 Ba extends q{constructor(t){super(t),this.params=t,this.host="https://codestral.mistral.ai",this.apiKey="",this.handleError$=r=>{const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return k({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#e28c58",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Codestral]"),this.errorPrefix=g.red.bold("[Codestral]"),this.apiKey=this.params.config.CODESTRAL_KEY}generateCommitMessage$(){return G(this.generateMessage()).pipe(L(t=>O(t)),B(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s,prompt:o,logging:u}=this.params.config,a=this.params.config["max-length"],i=this.buildPrompt(r,t,n,a,s,o);this.checkAvailableModels();const l=await this.createChatCompletions(i);return u&&_("Codestral",t,i,l),N(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}}checkAvailableModels(){if(["codestral-latest","codestral-2405"].includes(this.params.config.CODESTRAL_MODEL))return!0;throw new Error("Invalid model type of Codestral AI")}async createChatCompletions(t){const n=(await new M({method:"POST",baseURL:`${this.host}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.CODESTRAL_MODEL,messages:[{role:"user",content:t}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config["max-tokens"],stream:!1,safe_prompt:!1,random_seed:Qr(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 Ma extends q{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=/"message":\s*"([^"]*)"/,s=r.message.match(n);let o=r?.body?.message;s&&s[1]&&(o=s[1]);const u=`${r.statusCode} ${o}`;return k({name:`${this.errorPrefix} ${u}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#D18EE2",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Cohere]"),this.errorPrefix=g.red.bold("[Cohere]"),this.cohere=new oo({token:this.params.config.COHERE_KEY})}generateCommitMessage$(){return G(this.generateMessage()).pipe(L(t=>O(t)),B(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s,prompt:o,logging:u}=this.params.config,a=this.params.config["max-length"],i=this.buildPrompt(r,t,n,a,s,o),l=this.params.config["max-tokens"],c=(await this.cohere.generate({prompt:i,maxTokens:l,temperature:this.params.config.temperature,model:this.params.config.COHERE_MODEL})).generations.map(D=>D.text).join("");return u&&_("Cohere",t,i,c),N(this.sanitizeMessage(c,this.params.config.type,n))}catch(t){const r=t;throw r instanceof so?new y("Request timed out error!"):r}}}class Sa extends q{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 k({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 uo(this.params.config.GEMINI_KEY)}generateCommitMessage$(){return G(this.generateMessage()).pipe(L(t=>O(t)),B(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s,prompt:o,logging:u}=this.params.config,a=this.params.config["max-length"],i=this.buildPrompt(r,t,n,a,s,o),l=this.params.config["max-tokens"],p=(await(await this.genAI.getGenerativeModel({model:this.params.config.GEMINI_MODEL,generationConfig:{maxOutputTokens:l,temperature:this.params.config.temperature}}).generateContent(i)).response).text();return u&&_("Gemini",t,i,p),N(this.sanitizeMessage(p,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 Ia extends q{constructor(t){super(t),this.params=t,this.handleError$=r=>{let n="An error occurred";const s=/"message":\s*"([^"]*)"/,o=r.message.match(s);o&&o[1]&&(n=o[1]);const u=`${r.status} ${n}`;return k({name:`${this.errorPrefix} ${u}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#f55036",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Groq]"),this.errorPrefix=g.red.bold("[Groq]"),this.groq=new io({apiKey:this.params.config.GROQ_KEY})}generateCommitMessage$(){return G(this.generateMessage()).pipe(L(t=>O(t)),B(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s,prompt:o,logging:u}=this.params.config,a=this.params.config["max-length"],l=`${W(r,a,s,o)}
74
- ${ee(n)}`,c=(await this.groq.chat.completions.create({messages:[{role:"system",content:l},{role:"user",content:`Here are diff: ${t}`}],model:this.params.config.GROQ_MODEL},{timeout:this.params.config.timeout})).choices[0].message.content||"";return u&&_("Groq",t,l,c),N(this.sanitizeMessage(c,this.params.config.type,n))}catch(t){throw t}}}class Pa extends q{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 G(this.generateMessage()).pipe(L(t=>O(t)),B((t,r)=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.getFullPrompt();await this.prepareNewConversation();const{conversationId:r}=await this.getNewConversationId();await this.prepareConversationEvent(r);const{lastMessageId:n}=await this.getConversationInfo(r),s=await this.sendMessage(r,t,n);await this.deleteConversation(r);const{generate:o}=this.params.config;return N(this.sanitizeHuggingMessage(s,this.params.config.type,o))}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;o.forEach((i,l)=>{try{const f=JSON.parse(i);V(f,"type")&&f.type==="finalAnswer"&&(u=f)}catch{}});const a=this.getFullPrompt();if(!u||!V(u,"text"))throw this.params.config.logging&&_("HuggingFace",this.params.stagedDiff.diff,a,t),new Error("Cannot parse finalAnswer");return this.params.config.logging&&_("HuggingFace",this.params.stagedDiff.diff,a,u.text),this.sanitizeMessage(u.text,r,n)}async prepareNewConversation(){return(await new M({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 M({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 M({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 M({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 M({method:"DELETE",baseURL:`${this.host}/chat/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).execute(),(await new M({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 M({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}getFullPrompt(){const{locale:t,generate:r,type:n,prompt:s}=this.params.config,o=this.params.config["max-length"],u=this.params.stagedDiff.diff;return this.buildPrompt(t,u,r,o,n,s)}}class _a extends q{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 k({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#ff7000",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[MistralAI]"),this.errorPrefix=g.red.bold("[MistralAI]"),this.apiKey=this.params.config.MISTRAL_KEY}generateCommitMessage$(){return G(this.generateMessage()).pipe(L(t=>O(t)),B(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s,prompt:o,logging:u}=this.params.config,a=this.params.config["max-length"],i=this.buildPrompt(r,t,n,a,s,o);await this.checkAvailableModels();const l=await this.createChatCompletions(i);return u&&_("MistralAI",t,i,l),N(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}}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 M({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 M({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:Qr(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 La extends q{constructor(t){super(t),this.params=t,this.host=Pt,this.model="",this.handleError$=r=>{if(r.response&&r.response.data?.error)return k({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 k({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.generateStreamChoice$=()=>{const n=`${W(this.params.config.locale,this.params.config["max-length"],this.params.config.type,this.params.config.prompt)}
75
- ${ee(this.params.config.generate)}`,s=this.ollama.chat({model:this.model,messages:[{role:"system",content:n},{role:"user",content:`${this.params.stagedDiff.diff}`}],stream:!0,options:{temperature:this.params.config.temperature}});let o="";return O(Zr(s)).pipe(Yt(u=>o+=u.message.content),B(u=>({id:`Ollama_${this.model}`,name:`${this.serviceName} ${o}`,value:`${o}`,isError:!1,description:u.done?P:en,disabled:!u.done})))},this.colors={primary:"#FFF",secondary:"#000"},this.model=this.params.keyName,this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[${Jr(this.model)}]`),this.errorPrefix=g.red.bold(`[${Jr(this.model)}]`),this.host=this.params.config.OLLAMA_HOST||Pt,this.ollama=new ao({host:this.host})}generateCommitMessage$(){return this.params.config.OLLAMA_STREAM?this.generateStreamCommitMessage$():G(this.generateMessage()).pipe(L(t=>O(t)),B(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),T(this.handleError$))}generateStreamCommitMessage$(){return G(this.checkIsAvailableOllama()).pipe(Hn(()=>this.generateStreamChoice$()),Wt((t,r)=>{if(r.description===P){const{type:o,generate:u,logging:a}=this.params.config;if(a){const f=this.createSystemPrompt();_("Ollama",this.params.stagedDiff.diff,f,r.value)}const i=N(this.sanitizeMessage(r.value,o,u));return!i||i.length===0?[{id:`Ollama_${this.model}_${P}_0`,name:`${this.serviceName} Failed to extract messages from response`,value:"Failed to extract messages from response",isError:!0,description:P,disabled:!0}]:i.map((f,c)=>({id:`Ollama_${this.model}_${P}_${c}`,name:`${this.serviceName} ${f}`,value:`${f}`,isError:!1,description:P,disabled:!1}))}return t.find(o=>o.id===r.id)?[...t.map(o=>r.id===o.id?r:o)]:[{...r}]},[]),L(t=>t),T(this.handleError$))}async generateMessage(){try{await this.checkIsAvailableOllama();const t=await this.createChatCompletions(),{type:r,generate:n,logging:s}=this.params.config,o=this.createSystemPrompt();return s&&_(`Ollama_${this.model}`,this.params.stagedDiff.diff,o,t),N(this.sanitizeMessage(t,r,n))}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 M({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 t=this.createSystemPrompt();return(await this.ollama.chat({model:this.model,messages:[{role:"system",content:t},{role:"user",content:`Here are diff: ${this.params.stagedDiff.diff}`}],stream:!1,options:{temperature:this.params.config.temperature}})).message.content}createSystemPrompt(){return`${W(this.params.config.locale,this.params.config["max-length"],this.params.config.type,this.params.config.prompt)}
76
- ${ee(this.params.config.generate)}`}}class Ta extends q{constructor(t){super(t),this.params=t,this.handleError$=r=>{let n="An error occurred";if(r.message){n=r.message.split(`
77
- `)[0];const s=this.extractJSONFromError(r.message);n+=`: ${s.error.message}`}return k({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#74AA9C",secondary:"#FFF"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[ChatGPT]"),this.errorPrefix=g.red.bold("[ChatGPT]")}generateCommitMessage$(){return G(ba(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.logging,this.params.config.proxy)).pipe(L(t=>O(t)),B(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),T(this.handleError$))}extractJSONFromError(t){const r=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,n=t.match(r);return n?Object.assign({},...n.map(s=>JSON.parse(s))):{error:{message:"Unknown error"}}}}class An{constructor(t,r){this.config=t,this.stagedDiff=r}createAIRequests$(t){return O(t).pipe(Vt(r=>{const n={config:this.config,stagedDiff:this.stagedDiff,keyName:r};switch(r){case I.OPEN_AI:return K.create(Ta,n).generateCommitMessage$();case I.GEMINI:return K.create(Sa,n).generateCommitMessage$();case I.ANTHROPIC:return K.create(Aa,n).generateCommitMessage$();case I.HUGGING:return K.create(Pa,n).generateCommitMessage$();case I.CLOVA_X:return K.create(Oa,n).generateCommitMessage$();case I.MISTRAL:return K.create(_a,n).generateCommitMessage$();case I.CODESTRAL:return K.create(Ba,n).generateCommitMessage$();case I.OLLAMA:return O(this.config.OLLAMA_MODEL).pipe(Vt(o=>{const u={...n,keyName:o};return K.create(La,u).generateCommitMessage$()}));case I.COHERE:return K.create(Ma,n).generateCommitMessage$();case I.GROQ:return K.create(Ia,n).generateCommitMessage$();default:const s=g.red.bold(`[${r}]`);return k({name:s+" Invalid AI type",value:"Invalid AI type",isError:!0,disabled:!0})}}))}}const wn=async()=>{const{stdout:e,failed:t}=await ie("git",["rev-parse","--show-toplevel"],{reject:!1});if(t)throw new y("The current directory must be a Git repository!");return e},Tt=e=>`:(exclude)${e}`,$n=["package-lock.json","pnpm-lock.yaml","*.lock","*.gif","*.png"].map(Tt),vn=async e=>{const t=["diff","--cached","--diff-algorithm=minimal"],{stdout:r}=await ie("git",[...t,"--name-only",...$n,...e?e.map(Tt):[]]);if(!r)return null;const{stdout:n}=await ie("git",[...t,...$n,...e?e.map(Tt):[]]);return{files:r.split(`
78
- `),diff:n}},Na=e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`;class Ae{constructor(){this.title="aicommit2"}printTitle(){console.log(co.textSync(this.title,{font:"Small"}))}displaySpinner(t){return He(t).start()}stopSpinner(t){t.stop(),t.clear()}printStagedFiles(t){console.log(g.bold.green("\u2714 ")+g.bold(`${Na(t.files)}:`)),console.log(`${t.files.map(r=>` ${r}`).join(`
99
+ Check the API status: https://status.openai.com`),new y(l)}return JSON.parse(c)},ba=e=>e.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1"),Aa=async(e,t,r,n,s,o,u,i,c,l,p,a,D,d,f)=>{try{const h=le(s,i,c,D),C=(await ya(e,t,r,{model:n,messages:[{role:"system",content:`${h}
100
+ ${pe(u,c)}`},{role:"user",content:`Here are diff: ${o}`}],temperature:a,top_p:1,frequency_penalty:0,presence_penalty:0,max_tokens:p,stream:!1},l,f)).choices.filter(b=>b.message?.content).map(b=>ba(b.message.content)).join();return d&&L("OPEN AI",o,h,C),C}catch(h){const m=h;throw m.code==="ENOTFOUND"?new y(`Error connecting to ${m.hostname} (${m.syscall})`):m}};class wa extends U{constructor(t){super(t),this.params=t,this.handleError$=r=>{let n="An error occurred";if(r.message){n=r.message.split(`
101
+ `)[0];const s=this.extractJSONFromError(r.message);n+=`: ${s.error.message}`}return M({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#74AA9C",secondary:"#FFF"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[ChatGPT]"),this.errorPrefix=g.red.bold("[ChatGPT]")}generateCommitMessage$(){return G(this.generateMessage()).pipe(k(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),j(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"}}}async generateMessage(){const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s}=this.params.config,o=this.params.config["max-length"],u=await Aa(this.params.config.OPENAI_URL,this.params.config.OPENAI_PATH,this.params.config.OPENAI_KEY,this.params.config.OPENAI_MODEL,r,t,n,o,s,this.params.config.timeout,this.params.config["max-tokens"],this.params.config.temperature,this.params.config.prompt,this.params.config.logging,this.params.config.proxy);return this.sanitizeMessage(u,this.params.config.type,n,this.params.config.ignoreBody)}}class dn{constructor(t,r){this.config=t,this.stagedDiff=r}createAIRequests$(t){return S(t).pipe(Kt(r=>{const n={config:this.config,stagedDiff:this.stagedDiff,keyName:r};switch(r){case O.OPEN_AI:return H.create(wa,n).generateCommitMessage$();case O.GEMINI:return H.create(Ri,n).generateCommitMessage$();case O.ANTHROPIC:return H.create(_i,n).generateCommitMessage$();case O.HUGGING:return H.create(Ui,n).generateCommitMessage$();case O.MISTRAL:return H.create(Ki,n).generateCommitMessage$();case O.CODESTRAL:return H.create(Ti,n).generateCommitMessage$();case O.OLLAMA:return S(this.config.OLLAMA_MODEL).pipe(Kt(o=>{const u={...n,keyName:o};return H.create(zi,u).generateCommitMessage$()}));case O.COHERE:return H.create(Li,n).generateCommitMessage$();case O.GROQ:return H.create(Ni,n).generateCommitMessage$();default:const s=g.red.bold(`[${r}]`);return M({name:s+" Invalid AI type",value:"Invalid AI type",isError:!0,disabled:!0})}}))}}const fn=async()=>{const{stdout:e,failed:t}=await te("git",["rev-parse","--show-toplevel"],{reject:!1});if(t)throw new y("The current directory must be a Git repository!");return e},_t=e=>`:(exclude)${e}`,mn=["package-lock.json","pnpm-lock.yaml","*.lock","*.gif","*.png"].map(_t),hn=async e=>{const t=["diff","--cached","--diff-algorithm=minimal"],{stdout:r}=await te("git",[...t,"--name-only",...mn,...e?e.map(_t):[]]);if(!r)return null;const{stdout:n}=await te("git",[...t,...mn,...e?e.map(_t):[]]);return{files:r.split(`
102
+ `),diff:n}},va=e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`;class ye{constructor(){this.title="aicommit2"}printTitle(){console.log(Xn.textSync(this.title,{font:"Small"}))}displaySpinner(t){return je(t).start()}stopSpinner(t){t.stop(),t.clear()}printStagedFiles(t){console.log(g.bold.green("\u2714 ")+g.bold(`${va(t.files)}:`)),console.log(`${t.files.map(r=>` ${r}`).join(`
79
103
  `)}
80
104
  `)}printAnalyzed(){console.log(`
81
105
  ${g.bold.green("\u2714")} ${g.bold("Changes analyzed")}`)}printCommitted(){console.log(`
@@ -83,14 +107,14 @@ ${g.bold.green("\u2714")} ${g.bold("Successfully committed!")}`)}printCopied(){c
83
107
  ${g.bold.green("\u2714")} ${g.bold("Successfully copied! Press 'Ctrl + V' to paste")}`)}printSavedCommitMessage(){console.log(`
84
108
  ${g.bold.green("\u2714")} ${g.bold("Saved commit message")}`)}printCancelledCommit(){console.log(`
85
109
  ${g.bold.yellow("\u26A0")} ${g.yellow("Commit cancelled")}`)}printErrorMessage(t){console.log(`
86
- ${g.bold.red("\u2716")} ${g.red(`${t}`)}`)}moveCursorUp(){const t=we.createInterface({input:process.stdin,output:process.stdout});we.moveCursor(process.stdout,0,-1),t.close()}moveCursorDown(){const t=we.createInterface({input:process.stdin,output:process.stdout});we.moveCursor(process.stdout,0,1),t.close()}}const Ra={isLoading:!1,startOption:{text:"AI is analyzing your changes"}},Nt="No commit messages were generated";class ka{constructor(){this.choices$=new Xt([]),this.loader$=new Xt(Ra),this.destroyed$=new Un(1)}initPrompt(){return je.registerPrompt("reactiveListPrompt",Do),je.prompt({type:"reactiveListPrompt",name:"aicommit2Prompt",message:"Pick a commit message to use: ",emptyMessage:`\u26A0 ${Nt}`,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:Nt,stopOption:{doneFrame:"\u26A0",color:"yellow"}})}stopLoaderOnSuccess(){this.loader$.next({isLoading:!1,message:"Changes analyzed"})}logEmptyCommitMessage(){console.log(`${g.bold.yellow("\u26A0")} ${g.yellow(`${Nt}`)}`)}checkStreamChoice(t){if(t.description===P){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 z=new Ae;var Ga=async(e,t,r,n,s,o,u,a,i)=>(async()=>{z.printTitle(),await wn(),n&&await ie("git",["add","--update"]);const l=z.displaySpinner("Detecting staged files"),f=await vn(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.");z.printStagedFiles(f);const{env:c}=process,D=await Lt({OPENAI_KEY:c.OPENAI_KEY||c.OPENAI_API_KEY,OPENAI_MODEL:c.OPENAI_MODEL||c["openai-model"]||c.openai_model,OPENAI_URL:c.OPENAI_URL||c["openai-url"]||c.OPENAI_URL,GEMINI_KEY:c.GEMINI_KEY||c.GEMINI_API_KEY,GEMINI_MODEL:c.GEMINI_MODEL||c["gemini-model"]||c.gemini_model,ANTHROPIC_KEY:c.ANTHROPIC_KEY||c.ANTHROPIC_API_KEY,ANTHROPIC_MODEL:c.ANTHROPIC_MODEL||c["anthropic-model"]||c.anthropic_model,HUGGING_COOKIE:c.HUGGING_COOKIE||c.HUGGING_API_KEY||c.HF_TOKEN,HUGGING_MODEL:c.HUGGING_MODEL||c["hugging-model"],MISTRAL_KEY:c.MISTRAL_KEY||c.MISTRAL_API_KEY,CODESTRAL_KEY:c.CODESTRAL_KEY||c.CODESTRAL_API_KEY,MISTRAL_MODEL:c.MISTRAL_MODEL||c["mistral-model"]||c.mistral_model,CLOVAX_COOKIE:c.CLOVAX_COOKIE||c.CLOVA_X_COOKIE,proxy:c.https_proxy||c.HTTPS_PROXY||c.http_proxy||c.HTTP_PROXY,temperature:c.temperature,generate:t?.toString()||c.generate,type:s?.toString()||c.type,locale:e?.toString()||c.locale,prompt:a?.toString()||c.prompt}),p=Object.entries(D).filter(([w])=>Vr.includes(w)).filter(([w,De])=>w===I.OLLAMA?!!De&&De.length>0:!!De).map(([w])=>w);if(p.length===0)throw new y("Please set at least one API key via the `aicommit2 config set` command");const h=new An(D,f),m=new ka,C=m.initPrompt();m.startLoader();const A=h.createAIRequests$(p).subscribe(w=>m.refreshChoices(w),()=>{},()=>m.checkErrorOnChoices()),F=await C;A.unsubscribe(),m.completeSubject(),z.moveCursorUp();const R=F.aicommit2Prompt?.value;if(!R)throw new y("An error occurred! No selected message");if(u&&(Is("copy-paste").copy(R),z.printCopied(),process.exit()),o){const w=He("Committing with the generated message").start();await ie("git",["commit","-m",R,...i]),w.stop(),w.clear(),z.printCommitted(),process.exit()}const j=await je.prompt([{type:"confirm",name:"confirmationPrompt",message:"Use selected message?",default:!0}]),{confirmationPrompt:X}=j;if(X){const w=He("Committing with the generated message").start();await ie("git",["commit","-m",R,...i]),w.stop(),w.clear(),z.printCommitted(),process.exit()}z.printCancelledCommit(),process.exit()})().catch(l=>{z.printErrorMessage(l.message),he(l),process.exit(1)}),ja=Qe({name:"config",parameters:["<mode>","<key=value...>"]},e=>{(async()=>{const{mode:t,keyValue:r}=e._;if(t==="get"){const n=await Lt({},!0);for(const s of r)V(n,s)&&console.log(`${s}=${n[s]}`);return}if(t==="set"){await xa(r.map(n=>n.split("=")));return}throw new y(`Invalid mode: ${t}`)})().catch(t=>{new Ae().printErrorMessage(t.message),he(t),process.exit(1)})});const xn="prepare-commit-msg",On=`.git/hooks/${xn}`,Re=Zn(new URL("cli.mjs",import.meta.url)),Ha=process.argv[1].replace(/\\/g,"/").endsWith(`/${On}`),Bn=process.platform==="win32",Mn=`
110
+ ${g.bold.red("\u2716")} ${g.red(`${t}`)}`)}moveCursorUp(){const t=be.createInterface({input:process.stdin,output:process.stdout});be.moveCursor(process.stdout,0,-1),t.close()}moveCursorDown(){const t=be.createInterface({input:process.stdin,output:process.stdout});be.moveCursor(process.stdout,0,1),t.close()}}const $a={isLoading:!1,startOption:{text:"AI is analyzing your changes"}},Tt="No commit messages were generated";class Ba{constructor(){this.choices$=new zt([]),this.loader$=new zt($a),this.destroyed$=new In(1)}initPrompt(t){return ke.registerPrompt("reactiveListPrompt",Qn),ke.prompt({type:"reactiveListPrompt",name:"aicommit2Prompt",message:"Pick a commit message to use: ",emptyMessage:`\u26A0 ${Tt}`,loop:!1,showDescription:t,descPageSize:10,choices$:this.choices$,loader$:this.loader$})}startLoader(){this.loader$.next({isLoading:!0})}refreshChoices(t){const{value:r,isError:n}=t;if(!t||!r)return;if(!t.id){this.choices$.next([...this.currentChoices,t].sort(fe));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:Tt,stopOption:{doneFrame:"\u26A0",color:"yellow"}})}stopLoaderOnSuccess(){this.loader$.next({isLoading:!1,message:"Changes analyzed"})}logEmptyCommitMessage(){console.log(`${g.bold.yellow("\u26A0")} ${g.yellow(`${Tt}`)}`)}checkStreamChoice(t){if(t.description===Oi){const s=this.currentChoices.find(o=>{const u=o.id||"",i=/\d/.test(u);return t.id?.includes(u)&&!i});if(s){this.choices$.next([...this.currentChoices.filter(o=>o.id!==s.id),t].sort(fe));return}this.choices$.next([...this.currentChoices,t].sort(fe));return}if(this.currentChoices.find(s=>s?.id===t.id)){this.choices$.next(this.currentChoices.map(s=>s?.id===t.id?t:s).sort(fe));return}this.choices$.next([...this.currentChoices,t].sort(fe))}get currentChoices(){return this.choices$.getValue().map(t=>t)}}const K=new ye;var xa=async(e,t,r,n,s,o,u,i,c)=>(async()=>{K.printTitle(),await fn(),n&&await te("git",["add","--update"]);const l=K.displaySpinner("Detecting staged files"),p=await hn(r);if(l.stop(),!p)throw new y("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");K.printStagedFiles(p);const{env:a}=process,D=await yt({OPENAI_KEY:a.OPENAI_KEY||a.OPENAI_API_KEY,OPENAI_MODEL:a.OPENAI_MODEL||a["openai-model"]||a.openai_model,OPENAI_URL:a.OPENAI_URL||a["openai-url"]||a.OPENAI_URL,GEMINI_KEY:a.GEMINI_KEY||a.GEMINI_API_KEY,GEMINI_MODEL:a.GEMINI_MODEL||a["gemini-model"]||a.gemini_model,ANTHROPIC_KEY:a.ANTHROPIC_KEY||a.ANTHROPIC_API_KEY,ANTHROPIC_MODEL:a.ANTHROPIC_MODEL||a["anthropic-model"]||a.anthropic_model,HUGGING_COOKIE:a.HUGGING_COOKIE||a.HUGGING_API_KEY||a.HF_TOKEN,HUGGING_MODEL:a.HUGGING_MODEL||a["hugging-model"],MISTRAL_KEY:a.MISTRAL_KEY||a.MISTRAL_API_KEY,CODESTRAL_KEY:a.CODESTRAL_KEY||a.CODESTRAL_API_KEY,MISTRAL_MODEL:a.MISTRAL_MODEL||a["mistral-model"]||a.mistral_model,proxy:a.https_proxy||a.HTTPS_PROXY||a.http_proxy||a.HTTP_PROXY,temperature:a.temperature,generate:t?.toString()||a.generate,type:s?.toString()||a.type,locale:e?.toString()||a.locale,prompt:i?.toString()||a.prompt}),d=Object.entries(D).filter(([A])=>Hr.includes(A)).filter(([A,se])=>A===O.OLLAMA?!!se&&se.length>0:!!se).map(([A])=>A);if(d.length===0)throw new y("Please set at least one API key via the `aicommit2 config set` command");const h=new dn(D,p),m=new Ba,C=m.initPrompt(!D.ignoreBody);m.startLoader();const b=h.createAIRequests$(d).subscribe(A=>m.refreshChoices(A),()=>{},()=>m.checkErrorOnChoices()),B=await C;b.unsubscribe(),m.completeSubject(),K.moveCursorUp();const R=B.aicommit2Prompt?.value;if(!R)throw new y("An error occurred! No selected message");if(u&&(Fs("copy-paste").copy(R),K.printCopied(),process.exit()),o){const A=je("Committing with the generated message").start();await te("git",["commit","-m",R,...c]),A.stop(),A.clear(),K.printCommitted(),process.exit()}const N=await ke.prompt([{type:"confirm",name:"confirmationPrompt",message:"Use selected message?",default:!0}]),{confirmationPrompt:oe}=N;if(oe){const A=je("Committing with the generated message").start();await te("git",["commit","-m",R,...c]),A.stop(),A.clear(),K.printCommitted(),process.exit()}K.printCancelledCommit(),process.exit()})().catch(l=>{K.printErrorMessage(l.message),de(l),process.exit(1)}),Oa=Je({name:"config",parameters:["<mode>","<key=value...>"]},e=>{(async()=>{const{mode:t,keyValue:r}=e._;if(t==="get"){const n=await yt({},!0);for(const s of r)me(n,s)&&console.log(`${s}=${n[s]}`);return}if(t==="set"){await Hi(r.map(n=>n.split("=")));return}throw new y(`Invalid mode: ${t}`)})().catch(t=>{new ye().printErrorMessage(t.message),de(t),process.exit(1)})});const gn="prepare-commit-msg",Cn=`.git/hooks/${gn}`,Le=Vn(new URL("cli.mjs",import.meta.url)),Ma=process.argv[1].replace(/\\/g,"/").endsWith(`/${Cn}`),En=process.platform==="win32",Fn=`
87
111
  #!/usr/bin/env node
88
- import(${JSON.stringify(eo(Re))})
89
- `.trim();var Ua=Qe({name:"hook",parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await wn(),{installUninstall:r}=e._,n=Y.join(t,On),s=await En(n);if(r==="install"){if(s){if(await S.realpath(n).catch(()=>{})===Re){console.warn("The hook is already installed");return}throw new y(`A different ${xn} hook seems to be installed. Please remove it before installing aicommit2.`)}await S.mkdir(Y.dirname(n),{recursive:!0}),Bn?await S.writeFile(n,Mn):(await S.symlink(Re,n,"file"),await S.chmod(n,493)),console.log(`${g.green("\u2714")} Hook installed`);return}if(r==="uninstall"){if(!s){console.warn("Hook is not installed");return}if(Bn){if(await S.readFile(n,"utf8")!==Mn){console.warn("Hook is not installed");return}}else if(await S.realpath(n)!==Re){console.warn("Hook is not installed");return}await S.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}`),he(t),process.exit(1)})}),Ka=Qe({name:"log",parameters:["<removeAll>"]},e=>{(async()=>{const{removeAll:t}=e._;if(t==="removeAll"){await lo(tn,{recursive:!0,force:!0}),console.log(`${g.green("\u2714")} All Log files are removed!`);return}throw new y(`Invalid mode: ${t}`)})().catch(t=>{new Ae().printErrorMessage(t.message),he(t),process.exit(1)})});const[Rt,qa]=process.argv.slice(2);var za=()=>(async()=>{if(!Rt)throw new y('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(qa)return;const e=await vn();if(!e)return;const t=new Ae;t.printTitle();const{env:r}=process,n=await Lt({proxy:r.https_proxy||r.HTTPS_PROXY||r.http_proxy||r.HTTP_PROXY}),s=Object.entries(n).filter(([p])=>Vr.includes(p)).filter(([p,d])=>p===I.OLLAMA?!!d&&d.length>0:!!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 An(n,e),a=t.displaySpinner("The AI is analyzing your changes");let i;try{i=await Kn(u.createAIRequests$(s).pipe(zt(p=>!p.isError),B(p=>p.value),qn()))}finally{a.stop(),a.clear(),t.printAnalyzed()}const f=await S.readFile(Rt,"utf8")!=="",c=i.length>1;let D="";f&&(D=`# \u{1F916} AI generated commit${c?"s":""}
90
- `),c?(f&&(D+=`# Select one of the following messages by uncommenting:
112
+ import(${JSON.stringify(Jn(Le))})
113
+ `.trim();var Sa=Je({name:"hook",parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await fn(),{installUninstall:r}=e._,n=z.join(t,Cn),s=await Qr(n);if(r==="install"){if(s){if(await x.realpath(n).catch(()=>{})===Le){console.warn("The hook is already installed");return}throw new y(`A different ${gn} hook seems to be installed. Please remove it before installing aicommit2.`)}await x.mkdir(z.dirname(n),{recursive:!0}),En?await x.writeFile(n,Fn):(await x.symlink(Le,n,"file"),await x.chmod(n,493)),console.log(`${g.green("\u2714")} Hook installed`);return}if(r==="uninstall"){if(!s){console.warn("Hook is not installed");return}if(En){if(await x.readFile(n,"utf8")!==Fn){console.warn("Hook is not installed");return}}else if(await x.realpath(n)!==Le){console.warn("Hook is not installed");return}await x.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}`),de(t),process.exit(1)})}),Ia=Je({name:"log",parameters:["<removeAll>"]},e=>{(async()=>{const{removeAll:t}=e._;if(t==="removeAll"){await Zn(qr,{recursive:!0,force:!0}),console.log(`${g.green("\u2714")} All Log files are removed!`);return}throw new y(`Invalid mode: ${t}`)})().catch(t=>{new ye().printErrorMessage(t.message),de(t),process.exit(1)})});const[Lt,Pa]=process.argv.slice(2);var _a=()=>(async()=>{if(!Lt)throw new y('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(Pa)return;const e=await hn();if(!e)return;const t=new ye;t.printTitle();const{env:r}=process,n=await yt({proxy:r.https_proxy||r.HTTPS_PROXY||r.http_proxy||r.HTTP_PROXY}),s=Object.entries(n).filter(([d])=>Hr.includes(d)).filter(([d,f])=>d===O.OLLAMA?!!f&&f.length>0:!!f).map(([d])=>d);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 dn(n,e),i=t.displaySpinner("The AI is analyzing your changes");let c;try{c=await Pn(u.createAIRequests$(s).pipe(_n(d=>!d.isError),_(d=>d.value),Tn()))}finally{i.stop(),i.clear(),t.printAnalyzed()}const p=await x.readFile(Lt,"utf8")!=="",a=c.length>1;let D="";p&&(D=`# \u{1F916} AI generated commit${a?"s":""}
114
+ `),a?(p&&(D+=`# Select one of the following messages by uncommenting:
91
115
  `),D+=`
92
- ${i.map(p=>`# ${p}`).join(`
93
- `)}`):(f&&(D+=`# Edit the message below and commit:
116
+ ${c.map(d=>`# ${d}`).join(`
117
+ `)}`):(p&&(D+=`# Edit the message below and commit:
94
118
  `),D+=`
95
- ${i[0]}
96
- `),await S.appendFile(Rt,D),t.printSavedCommitMessage()})().catch(e=>{new Ae().printErrorMessage(e.message),he(e),process.exit(1)});const Sn=process.argv.slice(2);Ss({name:"aicommit2",version:Xr,flags:{locale:{type:String,description:"Locale to use for the generated commit messages (default: en)",alias:"l"},generate:{type:Number,description:"Number of messages to generate (Warning: generating multiple costs more) (default: 1)",alias:"g"},exclude:{type:[String],description:"Files to exclude from AI analysis",alias:"x"},all:{type:Boolean,description:"Automatically stage changes in tracked files for the commit",alias:"a",default:!1},type:{type:String,description:"Type of commit message to generate",alias:"t",default:"conventional"},confirm:{type:Boolean,description:"Skip confirmation when committing after message generation (default: false)",alias:"y",default:!1},clipboard:{type:Boolean,description:"Copy the selected message to the clipboard",alias:"c",default:!1},prompt:{type:String,description:"Additional prompt to let users fine-tune provided prompt",alias:"p"}},commands:[ja,Ua,Ka],help:{description:ji},ignoreArgv:e=>e==="unknown-flag"||e==="argument"},e=>{if(Ha){za();return}Ga(e.flags.locale,e.flags.generate,e.flags.exclude,e.flags.all,e.flags.type,e.flags.confirm,e.flags.clipboard,e.flags.prompt,Sn)},Sn);
119
+ ${c[0]}
120
+ `),await x.appendFile(Lt,D),t.printSavedCommitMessage()})().catch(e=>{new ye().printErrorMessage(e.message),de(e),process.exit(1)});const yn=process.argv.slice(2);Es({name:"aicommit2",version:Ur,flags:{locale:{type:String,description:"Locale to use for the generated commit messages (default: en)",alias:"l"},generate:{type:Number,description:"Number of messages to generate (Warning: generating multiple costs more) (default: 1)",alias:"g"},exclude:{type:[String],description:"Files to exclude from AI analysis",alias:"x"},all:{type:Boolean,description:"Automatically stage changes in tracked files for the commit",alias:"a",default:!1},type:{type:String,description:"Type of commit message to generate",alias:"t"},confirm:{type:Boolean,description:"Skip confirmation when committing after message generation (default: false)",alias:"y",default:!1},clipboard:{type:Boolean,description:"Copy the selected message to the clipboard",alias:"c",default:!1},prompt:{type:String,description:"Additional prompt to let users fine-tune provided prompt",alias:"p"}},commands:[Oa,Sa,Ia],help:{description:xi},ignoreArgv:e=>e==="unknown-flag"||e==="argument"},e=>{if(Ma){_a();return}xa(e.flags.locale,e.flags.generate,e.flags.exclude,e.flags.all,e.flags.type,e.flags.confirm,e.flags.clipboard,e.flags.prompt,yn)},yn);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicommit2",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "description": "A Reactive CLI that generates git commit messages with various AI",
5
5
  "keywords": [
6
6
  "cli",
@@ -17,11 +17,8 @@
17
17
  "openai",
18
18
  "huggingface",
19
19
  "hugging face",
20
- "clovax",
21
- "clova x",
22
20
  "anthropic",
23
21
  "claude",
24
- "claude2",
25
22
  "claude3",
26
23
  "gemini",
27
24
  "gemini-pro",
@@ -59,7 +56,7 @@
59
56
  "formdata-node": "^6.0.3",
60
57
  "groq-sdk": "^0.4.0",
61
58
  "inquirer": "9.2.8",
62
- "inquirer-reactive-list-prompt": "^1.0.5",
59
+ "inquirer-reactive-list-prompt": "^1.0.8",
63
60
  "ollama": "^0.5.0",
64
61
  "ora": "^8.0.1",
65
62
  "readline": "^1.3.0",