aicommit2 1.11.1 → 1.12.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 +112 -43
  2. package/dist/cli.mjs +60 -74
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -92,7 +92,7 @@ aicommit2 config set GROQ_KEY=<your key>
92
92
  - [Huggingface **(Unofficial)**](https://github.com/tak-bro/aicommit2?tab=readme-ov-file#how-to-get-cookieunofficial-api)
93
93
  ```shell
94
94
  # Please be cautious of Escape characters(\", \') in browser cookie string
95
- aicommit2 config set HUGGING_COOKIE="<your browser cookie>"
95
+ aicommit2 config set HUGGINGFACE_COOKIE="<your browser cookie>"
96
96
  ```
97
97
 
98
98
  This will create a `.aicommit2` file in your home directory.
@@ -211,11 +211,13 @@ aicommit2 --confirm # or -y
211
211
  aicommit2 --clipboard # or -c
212
212
  ```
213
213
 
214
- ##### `--prompt` or `-p`
215
- - Additional prompt to let users fine-tune provided prompt
214
+ ##### `--promptPath` or `-p`
215
+ - Allow users to specify a custom file path for their own prompt template
216
+ - Enable users to define and use their own prompts instead of relying solely on the default prompt
217
+ - Please see [Custom Prompt Template](#custom-prompt-template)
216
218
 
217
219
  ```sh
218
- aicommit2 --prompt <s> # or -p <s>
220
+ aicommit2 --promptPath <s> # or -p <s>
219
221
  ```
220
222
 
221
223
  ### Git hook
@@ -297,40 +299,40 @@ aicommit2 config set OPENAI_KEY=<your-api-key> generate=3 locale=en
297
299
 
298
300
  ## Options
299
301
 
300
- | Option | Default | Description |
301
- |-------------------|----------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|
302
- | `OPENAI_KEY` | N/A | The OpenAI API key |
303
- | `OPENAI_MODEL` | `gpt-3.5-turbo` | The OpenAI Model to use |
304
- | `OPENAI_URL` | `https://api.openai.com` | The OpenAI URL |
305
- | `OPENAI_PATH` | `/v1/chat/completions` | The OpenAI request pathname |
306
- | `ANTHROPIC_KEY` | N/A | The Anthropic API key |
307
- | `ANTHROPIC_MODEL` | `claude-3-haiku-20240307` | The Anthropic Model to use |
308
- | `GEMINI_KEY` | N/A | The Gemini API key |
309
- | `GEMINI_MODEL` | `gemini-1.5-pro-latest` | The Gemini Model |
310
- | `MISTRAL_KEY` | N/A | The Mistral API key |
311
- | `MISTRAL_MODEL` | `mistral-tiny` | The Mistral Model to use |
312
- | `CODESTRAL_KEY` | N/A | The Codestral API key |
313
- | `CODESTRAL_MODEL` | `codestral-latest` | The Codestral Model to use |
314
- | `COHERE_KEY` | N/A | The Cohere API Key |
315
- | `COHERE_MODEL` | `command` | The identifier of the Cohere model |
316
- | `GROQ_KEY` | N/A | The Groq API Key |
317
- | `GROQ_MODEL` | `gemma-7b-it` | The Groq model name to use |
318
- | `HUGGING_COOKIE` | N/A | The HuggingFace Cookie string |
319
- | `HUGGING_MODEL` | `mistralai/Mixtral-8x7B-Instruct-v0.1` | The HuggingFace Model to use |
320
- | `OLLAMA_MODEL` | N/A | The Ollama Model. It should be downloaded your local |
321
- | `OLLAMA_HOST` | `http://localhost:11434` | The Ollama Host |
322
- | `OLLAMA_TIMEOUT` | `100_000` ms | Request timeout for the Ollama |
323
- | `locale` | `en` | Locale for the generated commit messages |
324
- | `generate` | `1` | Number of commit messages to generate |
325
- | `type` | `conventional` | Type of commit message to generate |
326
- | `proxy` | N/A | Set a HTTP/HTTPS proxy to use for requests(only **OpenAI**) |
327
- | `timeout` | `10_000` ms | Network request timeout |
328
- | `max-length` | `50` | Maximum character length of the generated commit message(Subject) |
329
- | `max-tokens` | `1024` | The maximum number of tokens that the AI models can generate (for **Open AI, Anthropic, Gemini, Mistral, Codestral**) |
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**) |
331
- | `prompt` | N/A | Additional prompt to let users fine-tune provided prompt |
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) |
302
+ | Option | Default | Description |
303
+ |----------------------|----------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|
304
+ | `OPENAI_KEY` | N/A | The OpenAI API key |
305
+ | `OPENAI_MODEL` | `gpt-3.5-turbo` | The OpenAI Model to use |
306
+ | `OPENAI_URL` | `https://api.openai.com` | The OpenAI URL |
307
+ | `OPENAI_PATH` | `/v1/chat/completions` | The OpenAI request pathname |
308
+ | `ANTHROPIC_KEY` | N/A | The Anthropic API key |
309
+ | `ANTHROPIC_MODEL` | `claude-3-haiku-20240307` | The Anthropic Model to use |
310
+ | `GEMINI_KEY` | N/A | The Gemini API key |
311
+ | `GEMINI_MODEL` | `gemini-1.5-pro-latest` | The Gemini Model |
312
+ | `MISTRAL_KEY` | N/A | The Mistral API key |
313
+ | `MISTRAL_MODEL` | `mistral-tiny` | The Mistral Model to use |
314
+ | `CODESTRAL_KEY` | N/A | The Codestral API key |
315
+ | `CODESTRAL_MODEL` | `codestral-latest` | The Codestral Model to use |
316
+ | `COHERE_KEY` | N/A | The Cohere API Key |
317
+ | `COHERE_MODEL` | `command` | The identifier of the Cohere model |
318
+ | `GROQ_KEY` | N/A | The Groq API Key |
319
+ | `GROQ_MODEL` | `gemma-7b-it` | The Groq model name to use |
320
+ | `HUGGINGFACE_COOKIE` | N/A | The HuggingFace Cookie string |
321
+ | `HUGGINGFACE_MODEL` | `mistralai/Mixtral-8x7B-Instruct-v0.1` | The HuggingFace Model to use |
322
+ | `OLLAMA_MODEL` | N/A | The Ollama Model. It should be downloaded your local |
323
+ | `OLLAMA_HOST` | `http://localhost:11434` | The Ollama Host |
324
+ | `OLLAMA_TIMEOUT` | `100_000` ms | Request timeout for the Ollama |
325
+ | `locale` | `en` | Locale for the generated commit messages |
326
+ | `generate` | `1` | Number of commit messages to generate |
327
+ | `type` | `conventional` | Type of commit message to generate |
328
+ | `proxy` | N/A | Set a HTTP/HTTPS proxy to use for requests(only **OpenAI**) |
329
+ | `timeout` | `10_000` ms | Network request timeout |
330
+ | `max-length` | `50` | Maximum character length of the generated commit message(Subject) |
331
+ | `max-tokens` | `1024` | The maximum number of tokens that the AI models can generate (for **Open AI, Anthropic, Gemini, Mistral, Codestral**) |
332
+ | `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**) |
333
+ | `promptPath` | N/A | Allow users to specify a custom file path for their own prompt template |
334
+ | `logging` | `false` | Whether to log AI responses for debugging (true or false) |
335
+ | `ignoreBody` | `false` | Whether the commit message includes body (true or false) |
334
336
 
335
337
  > **Currently, options are set universally. However, there are plans to develop the ability to set individual options in the future.**
336
338
 
@@ -417,10 +419,10 @@ aicommit2 config set type=
417
419
  ##### max-tokens
418
420
  The maximum number of tokens that the AI models can generate.
419
421
 
420
- Default: `200`
422
+ Default: `1024`
421
423
 
422
424
  ```sh
423
- aicommit2 config set max-tokens=1000
425
+ aicommit2 config set max-tokens=3000
424
426
  ```
425
427
 
426
428
  ##### temperature
@@ -432,11 +434,13 @@ Default: `0.7`
432
434
  aicommit2 config set temperature=0
433
435
  ```
434
436
 
435
- ##### prompt
436
- Additional prompt to let users fine-tune provided prompt. Users provide extra instructions to AI and can guide how commit messages should look like.
437
+ ##### promptPath
438
+ - Allow users to specify a custom file path for their own prompt template
439
+ - Enable users to define and use their own prompts instead of relying solely on the default prompt
440
+ - Please see [Custom Prompt Template](#custom-prompt-template)
437
441
 
438
442
  ```sh
439
- aicommit2 config set prompt="Do not mention config changes"
443
+ aicommit2 config set promptPath="/path/to/user/prompt.txt"
440
444
  ```
441
445
 
442
446
  ##### logging
@@ -693,6 +697,71 @@ If it's not the [latest version](https://github.com/tak-bro/aicommit2/releases/l
693
697
  npm update -g aicommit2
694
698
  ```
695
699
 
700
+ ## Custom Prompt Template
701
+
702
+ _aicommit2_ supports custom prompt templates through the `promptPath` option. This feature allows you to define your own prompt structure, giving you more control over the commit message generation process.
703
+
704
+ ### Using the promptPath Option
705
+ To use a custom prompt template, specify the path to your template file when running the tool:
706
+ ```
707
+ aicommit2 config set promptPath="/path/to/user/prompt.txt"
708
+ ```
709
+
710
+ ### Template Format
711
+
712
+ Your custom template can include placeholders for various commit options.
713
+ Use curly braces `{}` to denote these placeholders. The following placeholders are supported:
714
+
715
+ - {locale}: The language for the commit message (string)
716
+ - {maxLength}: The maximum length for the commit message (number)
717
+ - {type}: The type of the commit (CommitType)
718
+ - {generate}: The number of commit messages to generate (number)
719
+
720
+ ### Example Template
721
+
722
+ Here's an example of how your custom template might look:
723
+
724
+ ```
725
+ Generate a {type} commit message in {locale}.
726
+ The message should not exceed {maxLength} characters.
727
+ Please provide {generate} messages.
728
+
729
+ Remember to follow these guidelines:
730
+ 1. Use the imperative mood
731
+ 2. Be concise and clear
732
+ 3. Explain the 'why' behind the change
733
+ ```
734
+
735
+ #### Appended Text
736
+
737
+ Please note that the following text will always be appended to the end of your custom prompt:
738
+
739
+ ```
740
+ Provide {generate} commit messages in the following JSON array format:
741
+ [
742
+ {
743
+ "message": "{type}",
744
+ "body": "Detailed explanation if necessary"
745
+ },
746
+ {
747
+ "message": "Another {type} commit message",
748
+ "body": "Another detailed explanation if necessary"
749
+ }
750
+ ]
751
+ ```
752
+
753
+ This ensures that the output is consistently formatted as a JSON array, regardless of the custom template used.
754
+
755
+ ### Notes
756
+
757
+ If the specified file cannot be read or parsed, _aicommit2_ will fall back to using the default prompt generation logic.
758
+ Ensure your template includes all necessary instructions for generating appropriate commit messages.
759
+ You can still use all other command-line options in conjunction with `promptPath`.
760
+
761
+ By using custom templates, you can tailor the commit message generation to your team's specific needs or coding standards.
762
+
763
+ > NOTE: For the `promptPath` option, set the **template path**, not the template content
764
+
696
765
  ## Loading Multiple Ollama Models
697
766
 
698
767
  <img src="https://github.com/tak-bro/aicommit2/blob/main/img/ollama_parallel.gif?raw=true" alt="OLLAMA_PARALLEL" />
package/dist/cli.mjs CHANGED
@@ -1,31 +1,31 @@
1
1
  #!/usr/bin/env node
2
- import Le from"tty";import{createRequire as An}from"module";import{Buffer as wn}from"node:buffer";import W from"node:path";import Nt,{ChildProcess as vn}from"node:child_process";import I from"node:process";import $n from"child_process";import K 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 Re from"stream";import Ut from"util";import{debuglog as Sn}from"node:util";import Ne from"inquirer";import ke from"ora";import g from"chalk";import{of as O,concatMap as N,from as S,map as P,catchError as _,mergeMap as Kt,BehaviorSubject as qt,ReplaySubject as In,lastValueFrom as Pn,filter as _n,toArray as Tn}from"rxjs";import Ln from"@anthropic-ai/sdk";import{fromPromise as k}from"rxjs/internal/observable/innerFrom";import je 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{Ollama as Un}from"ollama";import x from"fs/promises";import Kn from"http";import qn from"https";import zn from"net";import Yn from"tls";import Wn,{fileURLToPath as Jn,pathToFileURL as Vn}from"url";import Fe 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:ie}=JSON,no=/\B([A-Z])/g,oo=e=>e.replace(no,"-$1").toLowerCase(),{hasOwnProperty:so}=Object.prototype,ae=(e,t)=>so.call(e,t),uo=e=>Array.isArray(e),zt=e=>typeof e=="function"?[e,!1]:uo(e)?[e[0],!0]:zt(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 ${ie(e)}`;if(e.length===0)throw new Error(`${t} cannot be empty`);if(e.length===1)throw new Error(`${t} must be longer than a character`);const r=e.match(co);if(r)throw new Error(`${t} cannot contain ${ie(r?.[0])}`)},lo=e=>{const t={},r=(n,o)=>{if(ae(t,n))throw new Error(`Duplicate flags named ${ie(n)}`);t[n]=o};for(const n in e){if(!ae(e,n))continue;Do(n);const o=e[n],s=[[],...zt(o),o];r(n,s);const u=oo(n);if(n!==u&&r(u,s),"alias"in o&&typeof o.alias=="string"){const{alias:i}=o,c=`Flag alias ${ie(i)} for flag ${ie(n)}`;if(i.length===0)throw new Error(`${c} cannot be empty`);if(i.length>1)throw new Error(`${c} must be a single character`);r(i,s)}}return t},po=(e,t)=>{const r={};for(const n in e){if(!ae(e,n))continue;const[o,,s,u]=t[n];if(o.length===0&&"default"in u){let{default:i}=u;typeof i=="function"&&(i=i()),r[n]=i}else r[n]=s?o:o.pop()}return r},ye="--",fo=/[.:=]/,mo=/^-{1,2}\w/,ho=e=>{if(!mo.test(e))return;const t=!e.startsWith(ye);let r=e.slice(t?1:2),n;const o=r.match(fo);if(o){const{index:s}=o;n=r.slice(s+1),r=r.slice(0,s)}return[r,n,t]},go=(e,{onFlag:t,onArgument:r})=>{let n;const o=(s,u)=>{if(typeof n!="function")return!0;n(s,u),n=void 0};for(let s=0;s<e.length;s+=1){const u=e[s];if(u===ye){o();const c=e.slice(s+1);r?.(c,[s],!0);break}const i=ho(u);if(i){if(o(),!t)continue;const[c,l,d]=i;if(d)for(let a=0;a<c.length;a+=1){o();const D=a===c.length-1;n=t(c[a],D?l:void 0,[s,a+1,D])}else n=t(c,l,[s])}else o(u,[s])&&r?.([u],[s])}o()},Co=(e,t)=>{for(const[r,n,o]of t.reverse()){if(n){const s=e[r];let u=s.slice(0,n);if(o||(u+=s.slice(n+1)),u!=="-"){e[r]=u;continue}}e.splice(r,1)}},Eo=(e,t=process.argv.slice(2),{ignore:r}={})=>{const n=[],o=lo(e),s={},u=[];return u[ye]=[],go(t,{onFlag(i,c,l){const d=ae(o,i);if(!r?.(d?eo:to,i,c)){if(d){const[a,D]=o[i],p=io(D,c),f=(m,h)=>{n.push(l),h&&n.push(h),a.push(ao(D,m||""))};return p===void 0?f:f(p)}ae(s,i)||(s[i]=[]),s[i].push(c===void 0?!0:c),n.push(l)}},onArgument(i,c,l){r?.(ro,t[c[0]])||(u.push(...i),l?(u[ye]=i,t.splice(c[0])):n.push(c))}}),Co(t,n),{flags:po(e,o),unknownFlags:s,_:u}};var Fo=Object.create,be=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,Jt=(e,t,r)=>t in e?be(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ae=(e,t)=>{for(var r in t||(t={}))Wt.call(t,r)&&Jt(e,r,t[r]);if(Yt)for(var r of Yt(t))$o.call(t,r)&&Jt(e,r,t[r]);return e},Ge=(e,t)=>yo(e,Ao(t)),Bo=e=>be(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 o of wo(t))!Wt.call(e,o)&&(r||o!=="default")&&be(e,o,{get:()=>t[o],enumerable:!(n=bo(t,o))||n.enumerable});return e},So=(e,t)=>Mo(Bo(be(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 o=(t=process.stdout.columns)!=null?t:Number.POSITIVE_INFINITY;return typeof e=="function"&&(e=e(o)),e||(e={}),Array.isArray(e)?{columns:e,stdoutColumns:o}:{columns:(r=e.columns)!=null?r:[],stdoutColumns:(n=e.stdoutColumns)!=null?n:o}};$(),$(),$(),$(),$();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 Vt(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 z(e){if(typeof e!="string"||e.length===0||(e=Vt(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(z)),Ro=e=>{let t=[];for(let r of e){let{length:n}=r,o=n-t.length;for(let s=0;s<o;s+=1)t.push(0);for(let s=0;s<n;s+=1){let u=Xt(r[s]);u>t[s]&&(t[s]=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 o=0;o<e.length;o+=1){let s=(r=t[o])!=null?r:"auto";if(typeof s=="number"||s==="auto"||s==="content-width"||typeof s=="string"&&Qt.test(s)){n.push(Ge(Ae({},Zt),{width:s,contentWidth:e[o]}));continue}if(s&&typeof s=="object"){let u=Ge(Ae(Ae({},Zt),s),{contentWidth:e[o]});u.horizontalPadding=u.paddingLeft+u.paddingRight,n.push(u);continue}throw new Error(`Invalid column width: ${JSON.stringify(s)}`)}return n};function 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:o}=r,s=1,u=s+o;if(u>=t){let c=u-t,l=Math.ceil(r.paddingLeft/o*c),d=c-l;r.paddingLeft-=l,r.paddingRight-=d,r.horizontalPadding=r.paddingLeft+r.paddingRight}r.paddingLeftString=r.paddingLeft?" ".repeat(r.paddingLeft):"",r.paddingRightString=r.paddingRight?" ".repeat(r.paddingRight):"";let i=t-r.horizontalPadding;r.width=Math.max(Math.min(r.width,i),s)}}var er=()=>Object.assign([],{columns:0});function jo(e,t){let r=[er()],[n]=r;for(let o of e){let s=o.width+o.horizontalPadding;n.columns+s>t&&(n=er(),r.push(n)),n.push(o),n.columns+=s}for(let o of r){let s=o.reduce((D,p)=>D+p.width+p.horizontalPadding,0),u=t-s;if(u===0)continue;let i=o.filter(D=>"autoOverflow"in D),c=i.filter(D=>D.autoOverflow>0),l=c.reduce((D,p)=>D+p.autoOverflow,0),d=Math.min(l,u);for(let D of c){let p=Math.floor(D.autoOverflow/l*d);D.width+=p,u-=p}let a=Math.floor(u/i.length);for(let D=0;D<i.length;D+=1){let p=i[D];D===i.length-1?p.width+=u:p.width+=a,u-=a}}return r}function Go(e,t,r){let n=No(r,t);return ko(n,e),jo(n,e)}$(),$(),$();var He=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[o,s]of Object.entries(n))t[o]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[o]=t[o],e.set(s[0],s[1]);Object.defineProperty(t,r,{value:n,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",t.color.ansi=tr(),t.color.ansi256=rr(),t.color.ansi16m=nr(),t.bgColor.ansi=tr(He),t.bgColor.ansi256=rr(He),t.bgColor.ansi16m=nr(He),Object.defineProperties(t,{rgbToAnsi256:{value:(r,n,o)=>r===n&&n===o?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(n/255*5)+Math.round(o/255*5),enumerable:!1},hexToRgb:{value:r=>{let n=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(r.toString(16));if(!n)return[0,0,0];let{colorString:o}=n.groups;o.length===3&&(o=o.split("").map(u=>u+u).join(""));let s=Number.parseInt(o,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:r=>t.rgbToAnsi256(...t.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value:r=>{if(r<8)return 30+r;if(r<16)return 90+(r-8);let n,o,s;if(r>=232)n=((r-232)*10+8)/255,o=n,s=n;else{r-=16;let c=r%36;n=Math.floor(r/36)/5,o=Math.floor(c/6)/5,s=c%6/5}let u=Math.max(n,o,s)*2;if(u===0)return 30;let i=30+(Math.round(s)<<2|Math.round(o)<<1|Math.round(n));return u===2&&(i+=60),i},enumerable:!1},rgbToAnsi:{value:(r,n,o)=>t.ansi256ToAnsi(t.rgbToAnsi256(r,n,o)),enumerable:!1},hexToAnsi:{value:r=>t.ansi256ToAnsi(t.hexToAnsi256(r)),enumerable:!1}}),t}var Uo=Ho(),Ko=Uo,we=new Set(["\x1B","\x9B"]),qo=39,Ue="\x07",or="[",zo="]",sr="m",Ke=`${zo}8;;`,ur=e=>`${we.values().next().value}${or}${e}${sr}`,ir=e=>`${we.values().next().value}${Ke}${e}${Ue}`,Yo=e=>e.split(" ").map(t=>z(t)),qe=(e,t,r)=>{let n=[...t],o=!1,s=!1,u=z(Vt(e[e.length-1]));for(let[i,c]of n.entries()){let l=z(c);if(u+l<=r?e[e.length-1]+=c:(e.push(c),u=0),we.has(c)&&(o=!0,s=n.slice(i+1).join("").startsWith(Ke)),o){s?c===Ue&&(o=!1,s=!1):c===sr&&(o=!1);continue}u+=l,u===r&&i<n.length-1&&(e.push(""),u=0)}!u&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Wo=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(z(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},Jo=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",o,s,u=Yo(e),i=[""];for(let[l,d]of e.split(" ").entries()){r.trim!==!1&&(i[i.length-1]=i[i.length-1].trimStart());let a=z(i[i.length-1]);if(l!==0&&(a>=t&&(r.wordWrap===!1||r.trim===!1)&&(i.push(""),a=0),(a>0||r.trim===!1)&&(i[i.length-1]+=" ",a++)),r.hard&&u[l]>t){let D=t-a,p=1+Math.floor((u[l]-D-1)/t);Math.floor((u[l]-1)/t)<p&&i.push(""),qe(i,d,t);continue}if(a+u[l]>t&&a>0&&u[l]>0){if(r.wordWrap===!1&&a<t){qe(i,d,t);continue}i.push("")}if(a+u[l]>t&&r.wordWrap===!1){qe(i,d,t);continue}i[i.length-1]+=d}r.trim!==!1&&(i=i.map(l=>Wo(l)));let c=[...i.join(`
4
- `)];for(let[l,d]of c.entries()){if(n+=d,we.has(d)){let{groups:D}=new RegExp(`(?:\\${or}(?<code>\\d+)m|\\${Ke}(?<uri>.*)${Ue})`).exec(c.slice(l).join(""))||{groups:{}};if(D.code!==void 0){let p=Number.parseFloat(D.code);o=p===qo?void 0:p}else D.uri!==void 0&&(s=D.uri.length===0?void 0:D.uri)}let a=Ko.codes.get(Number(o));c[l+1]===`
5
- `?(s&&(n+=ir("")),o&&a&&(n+=ur(a))):d===`
6
- `&&(o&&a&&(n+=ur(o)),s&&(n+=ir(s)))}return n};function Vo(e,t,r){return String(e).normalize().replace(/\r\n/g,`
2
+ import Le from"tty";import{createRequire as vn}from"module";import k from"fs";import P from"path";import{Buffer as $n}from"node:buffer";import J from"node:path";import kt,{ChildProcess as Bn}from"node:child_process";import I from"node:process";import xn from"child_process";import{fileURLToPath as jt}from"node:url";import On,{constants as Gt}from"node:os";import Ht from"assert";import Ut from"events";import{createWriteStream as Mn,createReadStream as Sn}from"node:fs";import Pn from"buffer";import Re from"stream";import Kt from"util";import{debuglog as In}from"node:util";import Ne from"inquirer";import ke from"ora";import g from"chalk";import{of as O,concatMap as j,from as S,map as _,catchError as T,mergeMap as qt,BehaviorSubject as zt,ReplaySubject as _n,lastValueFrom as Tn,filter as Ln,toArray as Rn}from"rxjs";import Nn from"@anthropic-ai/sdk";import{fromPromise as G}from"rxjs/internal/observable/innerFrom";import je from"os";import{xxh64 as kn}from"@pacote/xxhash";import jn from"axios";import{CohereClient as Gn,CohereTimeoutError as Hn}from"cohere-ai";import{GoogleGenerativeAI as Un}from"@google/generative-ai";import Kn from"groq-sdk";import{Ollama as qn}from"ollama";import x from"fs/promises";import zn from"http";import Yn from"https";import Wn from"net";import Jn from"tls";import Vn,{fileURLToPath as Xn,pathToFileURL as Qn}from"url";import Fe from"readline";import Zn from"figlet";import eo from"inquirer-reactive-list-prompt";import{rm as to}from"node:fs/promises";const ro="known-flag",no="unknown-flag",oo="argument",{stringify:ie}=JSON,so=/\B([A-Z])/g,uo=e=>e.replace(so,"-$1").toLowerCase(),{hasOwnProperty:io}=Object.prototype,ae=(e,t)=>io.call(e,t),ao=e=>Array.isArray(e),Yt=e=>typeof e=="function"?[e,!1]:ao(e)?[e[0],!0]:Yt(e.type),co=(e,t)=>e===Boolean?t!=="false":t,Do=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),lo=/[\s.:=]/,po=e=>{const t=`Flag name ${ie(e)}`;if(e.length===0)throw new Error(`${t} cannot be empty`);if(e.length===1)throw new Error(`${t} must be longer than a character`);const r=e.match(lo);if(r)throw new Error(`${t} cannot contain ${ie(r?.[0])}`)},fo=e=>{const t={},r=(n,o)=>{if(ae(t,n))throw new Error(`Duplicate flags named ${ie(n)}`);t[n]=o};for(const n in e){if(!ae(e,n))continue;po(n);const o=e[n],s=[[],...Yt(o),o];r(n,s);const u=uo(n);if(n!==u&&r(u,s),"alias"in o&&typeof o.alias=="string"){const{alias:i}=o,c=`Flag alias ${ie(i)} for flag ${ie(n)}`;if(i.length===0)throw new Error(`${c} cannot be empty`);if(i.length>1)throw new Error(`${c} must be a single character`);r(i,s)}}return t},mo=(e,t)=>{const r={};for(const n in e){if(!ae(e,n))continue;const[o,,s,u]=t[n];if(o.length===0&&"default"in u){let{default:i}=u;typeof i=="function"&&(i=i()),r[n]=i}else r[n]=s?o:o.pop()}return r},ye="--",ho=/[.:=]/,go=/^-{1,2}\w/,Co=e=>{if(!go.test(e))return;const t=!e.startsWith(ye);let r=e.slice(t?1:2),n;const o=r.match(ho);if(o){const{index:s}=o;n=r.slice(s+1),r=r.slice(0,s)}return[r,n,t]},Eo=(e,{onFlag:t,onArgument:r})=>{let n;const o=(s,u)=>{if(typeof n!="function")return!0;n(s,u),n=void 0};for(let s=0;s<e.length;s+=1){const u=e[s];if(u===ye){o();const c=e.slice(s+1);r?.(c,[s],!0);break}const i=Co(u);if(i){if(o(),!t)continue;const[c,l,d]=i;if(d)for(let a=0;a<c.length;a+=1){o();const D=a===c.length-1;n=t(c[a],D?l:void 0,[s,a+1,D])}else n=t(c,l,[s])}else o(u,[s])&&r?.([u],[s])}o()},Fo=(e,t)=>{for(const[r,n,o]of t.reverse()){if(n){const s=e[r];let u=s.slice(0,n);if(o||(u+=s.slice(n+1)),u!=="-"){e[r]=u;continue}}e.splice(r,1)}},yo=(e,t=process.argv.slice(2),{ignore:r}={})=>{const n=[],o=fo(e),s={},u=[];return u[ye]=[],Eo(t,{onFlag(i,c,l){const d=ae(o,i);if(!r?.(d?ro:no,i,c)){if(d){const[a,D]=o[i],p=co(D,c),f=(h,m)=>{n.push(l),m&&n.push(m),a.push(Do(D,h||""))};return p===void 0?f:f(p)}ae(s,i)||(s[i]=[]),s[i].push(c===void 0?!0:c),n.push(l)}},onArgument(i,c,l){r?.(oo,t[c[0]])||(u.push(...i),l?(u[ye]=i,t.splice(c[0])):n.push(c))}}),Fo(t,n),{flags:mo(e,o),unknownFlags:s,_:u}};var bo=Object.create,be=Object.defineProperty,Ao=Object.defineProperties,wo=Object.getOwnPropertyDescriptor,vo=Object.getOwnPropertyDescriptors,$o=Object.getOwnPropertyNames,Wt=Object.getOwnPropertySymbols,Bo=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty,xo=Object.prototype.propertyIsEnumerable,Vt=(e,t,r)=>t in e?be(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ae=(e,t)=>{for(var r in t||(t={}))Jt.call(t,r)&&Vt(e,r,t[r]);if(Wt)for(var r of Wt(t))xo.call(t,r)&&Vt(e,r,t[r]);return e},Ge=(e,t)=>Ao(e,vo(t)),Oo=e=>be(e,"__esModule",{value:!0}),Mo=(e,t)=>()=>(e&&(t=e(e=0)),t),So=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Po=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $o(t))!Jt.call(e,o)&&(r||o!=="default")&&be(e,o,{get:()=>t[o],enumerable:!(n=wo(t,o))||n.enumerable});return e},Io=(e,t)=>Po(Oo(be(e!=null?bo(Bo(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),B=Mo(()=>{}),_o=So((e,t)=>{B(),t.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});B(),B(),B();var To=e=>{var t,r,n;let o=(t=process.stdout.columns)!=null?t:Number.POSITIVE_INFINITY;return typeof e=="function"&&(e=e(o)),e||(e={}),Array.isArray(e)?{columns:e,stdoutColumns:o}:{columns:(r=e.columns)!=null?r:[],stdoutColumns:(n=e.stdoutColumns)!=null?n:o}};B(),B(),B(),B(),B();function Lo({onlyFirst:e=!1}={}){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}function Xt(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Lo(),"")}B();function Ro(e){return Number.isInteger(e)?e>=4352&&(e<=4447||e===9001||e===9002||11904<=e&&e<=12871&&e!==12351||12880<=e&&e<=19903||19968<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65131||65281<=e&&e<=65376||65504<=e&&e<=65510||110592<=e&&e<=110593||127488<=e&&e<=127569||131072<=e&&e<=262141):!1}var No=Io(_o(),1);function z(e){if(typeof e!="string"||e.length===0||(e=Xt(e),e.length===0))return 0;e=e.replace((0,No.default)()," ");let t=0;for(let r=0;r<e.length;r++){let n=e.codePointAt(r);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&r++,t+=Ro(n)?2:1)}return t}var Qt=e=>Math.max(...e.split(`
3
+ `).map(z)),ko=e=>{let t=[];for(let r of e){let{length:n}=r,o=n-t.length;for(let s=0;s<o;s+=1)t.push(0);for(let s=0;s<n;s+=1){let u=Qt(r[s]);u>t[s]&&(t[s]=u)}}return t};B();var Zt=/^\d+%$/,er={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},jo=(e,t)=>{var r;let n=[];for(let o=0;o<e.length;o+=1){let s=(r=t[o])!=null?r:"auto";if(typeof s=="number"||s==="auto"||s==="content-width"||typeof s=="string"&&Zt.test(s)){n.push(Ge(Ae({},er),{width:s,contentWidth:e[o]}));continue}if(s&&typeof s=="object"){let u=Ge(Ae(Ae({},er),s),{contentWidth:e[o]});u.horizontalPadding=u.paddingLeft+u.paddingRight,n.push(u);continue}throw new Error(`Invalid column width: ${JSON.stringify(s)}`)}return n};function Go(e,t){for(let r of e){let{width:n}=r;if(n==="content-width"&&(r.width=r.contentWidth),n==="auto"){let c=Math.min(20,r.contentWidth);r.width=c,r.autoOverflow=r.contentWidth-c}if(typeof n=="string"&&Zt.test(n)){let c=Number.parseFloat(n.slice(0,-1))/100;r.width=Math.floor(t*c)-(r.paddingLeft+r.paddingRight)}let{horizontalPadding:o}=r,s=1,u=s+o;if(u>=t){let c=u-t,l=Math.ceil(r.paddingLeft/o*c),d=c-l;r.paddingLeft-=l,r.paddingRight-=d,r.horizontalPadding=r.paddingLeft+r.paddingRight}r.paddingLeftString=r.paddingLeft?" ".repeat(r.paddingLeft):"",r.paddingRightString=r.paddingRight?" ".repeat(r.paddingRight):"";let i=t-r.horizontalPadding;r.width=Math.max(Math.min(r.width,i),s)}}var tr=()=>Object.assign([],{columns:0});function Ho(e,t){let r=[tr()],[n]=r;for(let o of e){let s=o.width+o.horizontalPadding;n.columns+s>t&&(n=tr(),r.push(n)),n.push(o),n.columns+=s}for(let o of r){let s=o.reduce((D,p)=>D+p.width+p.horizontalPadding,0),u=t-s;if(u===0)continue;let i=o.filter(D=>"autoOverflow"in D),c=i.filter(D=>D.autoOverflow>0),l=c.reduce((D,p)=>D+p.autoOverflow,0),d=Math.min(l,u);for(let D of c){let p=Math.floor(D.autoOverflow/l*d);D.width+=p,u-=p}let a=Math.floor(u/i.length);for(let D=0;D<i.length;D+=1){let p=i[D];D===i.length-1?p.width+=u:p.width+=a,u-=a}}return r}function Uo(e,t,r){let n=jo(r,t);return Go(n,e),Ho(n,e)}B(),B(),B();var He=10,rr=(e=0)=>t=>`\x1B[${t+e}m`,nr=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,or=(e=0)=>(t,r,n)=>`\x1B[${38+e};2;${t};${r};${n}m`;function Ko(){let e=new Map,t={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};t.color.gray=t.color.blackBright,t.bgColor.bgGray=t.bgColor.bgBlackBright,t.color.grey=t.color.blackBright,t.bgColor.bgGrey=t.bgColor.bgBlackBright;for(let[r,n]of Object.entries(t)){for(let[o,s]of Object.entries(n))t[o]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[o]=t[o],e.set(s[0],s[1]);Object.defineProperty(t,r,{value:n,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",t.color.ansi=rr(),t.color.ansi256=nr(),t.color.ansi16m=or(),t.bgColor.ansi=rr(He),t.bgColor.ansi256=nr(He),t.bgColor.ansi16m=or(He),Object.defineProperties(t,{rgbToAnsi256:{value:(r,n,o)=>r===n&&n===o?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(n/255*5)+Math.round(o/255*5),enumerable:!1},hexToRgb:{value:r=>{let n=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(r.toString(16));if(!n)return[0,0,0];let{colorString:o}=n.groups;o.length===3&&(o=o.split("").map(u=>u+u).join(""));let s=Number.parseInt(o,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:r=>t.rgbToAnsi256(...t.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value:r=>{if(r<8)return 30+r;if(r<16)return 90+(r-8);let n,o,s;if(r>=232)n=((r-232)*10+8)/255,o=n,s=n;else{r-=16;let c=r%36;n=Math.floor(r/36)/5,o=Math.floor(c/6)/5,s=c%6/5}let u=Math.max(n,o,s)*2;if(u===0)return 30;let i=30+(Math.round(s)<<2|Math.round(o)<<1|Math.round(n));return u===2&&(i+=60),i},enumerable:!1},rgbToAnsi:{value:(r,n,o)=>t.ansi256ToAnsi(t.rgbToAnsi256(r,n,o)),enumerable:!1},hexToAnsi:{value:r=>t.ansi256ToAnsi(t.hexToAnsi256(r)),enumerable:!1}}),t}var qo=Ko(),zo=qo,we=new Set(["\x1B","\x9B"]),Yo=39,Ue="\x07",sr="[",Wo="]",ur="m",Ke=`${Wo}8;;`,ir=e=>`${we.values().next().value}${sr}${e}${ur}`,ar=e=>`${we.values().next().value}${Ke}${e}${Ue}`,Jo=e=>e.split(" ").map(t=>z(t)),qe=(e,t,r)=>{let n=[...t],o=!1,s=!1,u=z(Xt(e[e.length-1]));for(let[i,c]of n.entries()){let l=z(c);if(u+l<=r?e[e.length-1]+=c:(e.push(c),u=0),we.has(c)&&(o=!0,s=n.slice(i+1).join("").startsWith(Ke)),o){s?c===Ue&&(o=!1,s=!1):c===ur&&(o=!1);continue}u+=l,u===r&&i<n.length-1&&(e.push(""),u=0)}!u&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Vo=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(z(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},Xo=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",o,s,u=Jo(e),i=[""];for(let[l,d]of e.split(" ").entries()){r.trim!==!1&&(i[i.length-1]=i[i.length-1].trimStart());let a=z(i[i.length-1]);if(l!==0&&(a>=t&&(r.wordWrap===!1||r.trim===!1)&&(i.push(""),a=0),(a>0||r.trim===!1)&&(i[i.length-1]+=" ",a++)),r.hard&&u[l]>t){let D=t-a,p=1+Math.floor((u[l]-D-1)/t);Math.floor((u[l]-1)/t)<p&&i.push(""),qe(i,d,t);continue}if(a+u[l]>t&&a>0&&u[l]>0){if(r.wordWrap===!1&&a<t){qe(i,d,t);continue}i.push("")}if(a+u[l]>t&&r.wordWrap===!1){qe(i,d,t);continue}i[i.length-1]+=d}r.trim!==!1&&(i=i.map(l=>Vo(l)));let c=[...i.join(`
4
+ `)];for(let[l,d]of c.entries()){if(n+=d,we.has(d)){let{groups:D}=new RegExp(`(?:\\${sr}(?<code>\\d+)m|\\${Ke}(?<uri>.*)${Ue})`).exec(c.slice(l).join(""))||{groups:{}};if(D.code!==void 0){let p=Number.parseFloat(D.code);o=p===Yo?void 0:p}else D.uri!==void 0&&(s=D.uri.length===0?void 0:D.uri)}let a=zo.codes.get(Number(o));c[l+1]===`
5
+ `?(s&&(n+=ar("")),o&&a&&(n+=ir(a))):d===`
6
+ `&&(o&&a&&(n+=ir(o)),s&&(n+=ar(s)))}return n};function Qo(e,t,r){return String(e).normalize().replace(/\r\n/g,`
7
7
  `).split(`
8
- `).map(n=>Jo(n,t,r)).join(`
9
- `)}var ar=e=>Array.from({length:e}).fill("");function Xo(e,t){let r=[],n=0;for(let o of e){let s=0,u=o.map(c=>{var l;let d=(l=t[n])!=null?l:"";n+=1,c.preprocess&&(d=c.preprocess(d)),Xt(d)>c.width&&(d=Vo(d,c.width,{hard:!0}));let a=d.split(`
10
- `);if(c.postprocess){let{postprocess:D}=c;a=a.map((p,f)=>D.call(c,p,f))}return c.paddingTop&&a.unshift(...ar(c.paddingTop)),c.paddingBottom&&a.push(...ar(c.paddingBottom)),a.length>s&&(s=a.length),Ge(Ae({},c),{lines:a})}),i=[];for(let c=0;c<s;c+=1){let l=u.map(d=>{var a;let D=(a=d.lines[c])!=null?a:"",p=Number.isFinite(d.width)?" ".repeat(d.width-z(D)):"",f=d.paddingLeftString;return d.align==="right"&&(f+=p),f+=D,d.align==="left"&&(f+=p),f+d.paddingRightString}).join("");i.push(l)}r.push(i.join(`
8
+ `).map(n=>Xo(n,t,r)).join(`
9
+ `)}var cr=e=>Array.from({length:e}).fill("");function Zo(e,t){let r=[],n=0;for(let o of e){let s=0,u=o.map(c=>{var l;let d=(l=t[n])!=null?l:"";n+=1,c.preprocess&&(d=c.preprocess(d)),Qt(d)>c.width&&(d=Qo(d,c.width,{hard:!0}));let a=d.split(`
10
+ `);if(c.postprocess){let{postprocess:D}=c;a=a.map((p,f)=>D.call(c,p,f))}return c.paddingTop&&a.unshift(...cr(c.paddingTop)),c.paddingBottom&&a.push(...cr(c.paddingBottom)),a.length>s&&(s=a.length),Ge(Ae({},c),{lines:a})}),i=[];for(let c=0;c<s;c+=1){let l=u.map(d=>{var a;let D=(a=d.lines[c])!=null?a:"",p=Number.isFinite(d.width)?" ".repeat(d.width-z(D)):"",f=d.paddingLeftString;return d.align==="right"&&(f+=p),f+=D,d.align==="left"&&(f+=p),f+d.paddingRightString}).join("");i.push(l)}r.push(i.join(`
11
11
  `))}return r.join(`
12
- `)}function Qo(e,t){if(!e||e.length===0)return"";let r=Ro(e),n=r.length;if(n===0)return"";let{stdoutColumns:o,columns:s}=Po(t);if(s.length>n)throw new Error(`${s.length} columns defined, but only ${n} columns found`);let u=Go(o,s,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,o]=r.split(" ");es(n);let s=Number.parseInt(o,10);if(Number.isNaN(s))throw new TypeError(`Invalid breakpoint value: ${o}`);let u=e[r];return{operator:n,breakpoint:s,value:u}}).sort((r,n)=>n.breakpoint-r.breakpoint);return r=>{var n;return(n=t.find(({operator:o,breakpoint:s})=>o==="="&&r===s||o===">"&&r>s||o==="<"&&r<s||o===">="&&r>=s||o==="<="&&r<=s))==null?void 0:n.value}}const 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],o="alias"in n;return o&&(t=!0),{name:r,flag:n,flagFormatted:`--${ns(r)}`,aliasesEnabled:t,aliasFormatted:o?`-${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:o}=e,s=o.indexOf("--"),u=s>-1&&o.slice(s+1).some(i=>i.startsWith("<"));n.push(o.map(i=>i!=="--"?i:u?"--":"[--]").join(" "))}if(n.length>1&&r.push(n.join(" ")),"commands"in e&&e.commands?.length&&r.push(`${e.name} <command>`),r.length>0)return{id:"usage",type:"section",data:{title:"Usage:",body:r.join(`
17
- `)}}}}function 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 ds(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 ps=e=>[us,is,as,cs,Ds,ls,ds].map(t=>t(e)).filter(Boolean),fs=Le.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)}
12
+ `)}function es(e,t){if(!e||e.length===0)return"";let r=ko(e),n=r.length;if(n===0)return"";let{stdoutColumns:o,columns:s}=To(t);if(s.length>n)throw new Error(`${s.length} columns defined, but only ${n} columns found`);let u=Uo(o,s,r);return e.map(i=>Zo(u,i)).join(`
13
+ `)}B();var ts=["<",">","=",">=","<="];function rs(e){if(!ts.includes(e))throw new TypeError(`Invalid breakpoint operator: ${e}`)}function ns(e){let t=Object.keys(e).map(r=>{let[n,o]=r.split(" ");rs(n);let s=Number.parseInt(o,10);if(Number.isNaN(s))throw new TypeError(`Invalid breakpoint value: ${o}`);let u=e[r];return{operator:n,breakpoint:s,value:u}}).sort((r,n)=>n.breakpoint-r.breakpoint);return r=>{var n;return(n=t.find(({operator:o,breakpoint:s})=>o==="="&&r===s||o===">"&&r>s||o==="<"&&r<s||o===">="&&r>=s||o==="<="&&r<=s))==null?void 0:n.value}}const os=e=>e.replace(/[\W_]([a-z\d])?/gi,(t,r)=>r?r.toUpperCase():""),ss=e=>e.replace(/\B([A-Z])/g,"-$1").toLowerCase(),us={"> 80":[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"auto"}],"> 40":[{width:"auto",paddingLeft:2,paddingRight:8,preprocess:e=>e.trim()},{width:"100%",paddingLeft:2,paddingBottom:1}],"> 0":{stdoutColumns:1e3,columns:[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"content-width"}]}};function is(e){let t=!1;return{type:"table",data:{tableData:Object.keys(e).sort((r,n)=>r.localeCompare(n)).map(r=>{const n=e[r],o="alias"in n;return o&&(t=!0),{name:r,flag:n,flagFormatted:`--${ss(r)}`,aliasesEnabled:t,aliasFormatted:o?`-${n.alias}`:void 0}}).map(r=>(r.aliasesEnabled=t,[{type:"flagName",data:r},{type:"flagDescription",data:r}])),tableBreakpoints:us}}}const Dr=e=>!e||(e.version??(e.help?e.help.version:void 0)),lr=e=>{const t="parent"in e&&e.parent?.name;return(t?`${t} `:"")+e.name};function as(e){const t=[];e.name&&t.push(lr(e));const r=Dr(e)??("parent"in e&&Dr(e.parent));if(r&&t.push(`v${r}`),t.length!==0)return{id:"name",type:"text",data:`${t.join(" ")}
14
+ `}}function cs(e){const{help:t}=e;if(!(!t||!t.description))return{id:"description",type:"text",data:`${t.description}
15
+ `}}function Ds(e){const t=e.help||{};if("usage"in t)return t.usage?{id:"usage",type:"section",data:{title:"Usage:",body:Array.isArray(t.usage)?t.usage.join(`
16
+ `):t.usage}}:void 0;if(e.name){const r=[],n=[lr(e)];if(e.flags&&Object.keys(e.flags).length>0&&n.push("[flags...]"),e.parameters&&e.parameters.length>0){const{parameters:o}=e,s=o.indexOf("--"),u=s>-1&&o.slice(s+1).some(i=>i.startsWith("<"));n.push(o.map(i=>i!=="--"?i:u?"--":"[--]").join(" "))}if(n.length>1&&r.push(n.join(" ")),"commands"in e&&e.commands?.length&&r.push(`${e.name} <command>`),r.length>0)return{id:"usage",type:"section",data:{title:"Usage:",body:r.join(`
17
+ `)}}}}function ls(e){return!("commands"in e)||!e.commands?.length?void 0:{id:"commands",type:"section",data:{title:"Commands:",body:{type:"table",data:{tableData:e.commands.map(t=>[t.options.name,t.options.help?t.options.help.description:""]),tableOptions:[{width:"content-width",paddingLeft:2,paddingRight:8}]}},indentBody:0}}}function ds(e){if(!(!e.flags||Object.keys(e.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:is(e.flags),indentBody:0}}}function ps(e){const{help:t}=e;if(!t||!t.examples||t.examples.length===0)return;let{examples:r}=t;if(Array.isArray(r)&&(r=r.join(`
18
+ `)),r)return{id:"examples",type:"section",data:{title:"Examples:",body:r}}}function fs(e){if(!("alias"in e)||!e.alias)return;const{alias:t}=e;return{id:"aliases",type:"section",data:{title:"Aliases:",body:Array.isArray(t)?t.join(", "):t}}}const ms=e=>[as,cs,Ds,ls,ds,ps,fs].map(t=>t(e)).filter(Boolean),hs=Le.WriteStream.prototype.hasColors();class gs{text(t){return t}bold(t){return hs?`\x1B[1m${t}\x1B[22m`:t.toLocaleUpperCase()}indentText({text:t,spaces:r}){return t.replace(/^/gm," ".repeat(r))}heading(t){return this.bold(t)}section({title:t,body:r,indentBody:n=2}){return`${(t?`${this.heading(t)}
19
19
  `:"")+(r?this.indentText({text:this.render(r),spaces:n}):"")}
20
- `}table({tableData:t,tableOptions:r,tableBreakpoints:n}){return Qo(t.map(o=>o.map(s=>this.render(s))),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:o,aliasFormatted:s}=t;let u="";if(s?u+=`${s}, `:o&&(u+=" "),u+=n,"placeholder"in r&&typeof r.placeholder=="string")u+=`${this.flagOperator(t)}${r.placeholder}`;else{const i=this.flagParameter("type"in r?r.type:r);i&&(u+=`${this.flagOperator(t)}${i}`)}return u}flagDefault(t){return JSON.stringify(t)}flagDescription({flag:t}){let r="description"in t?t.description??"":"";if("default"in t){let{default:n}=t;typeof n=="function"&&(n=n()),n&&(r+=` (default: ${this.flagDefault(n)})`)}return r}render(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(r=>this.render(r)).join(`
21
- `);if("type"in t&&this[t.type]){const r=this[t.type];if(typeof r=="function")return r.call(this,t.data)}throw new Error(`Invalid node type: ${JSON.stringify(t)}`)}}const ze=/^[\w.-]+$/,{stringify:T}=JSON,hs=/[|\\{}()[\]^$+*?.]/;function Ye(e){const t=[];let r,n;for(const o of e){if(n)throw new Error(`Invalid parameter: Spread parameter ${T(n)} must be last`);const s=o[0],u=o[o.length-1];let i;if(s==="<"&&u===">"&&(i=!0,r))throw new Error(`Invalid parameter: Required parameter ${T(o)} cannot come after optional parameter ${T(r)}`);if(s==="["&&u==="]"&&(i=!1,r=o),i===void 0)throw new Error(`Invalid parameter: ${T(o)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let c=o.slice(1,-1);const l=c.slice(-3)==="...";l&&(n=o,c=c.slice(0,-3));const d=c.match(hs);if(d)throw new Error(`Invalid parameter: ${T(o)}. Invalid character found ${T(d[0])}`);t.push({name:c,required:i,spread:l})}return t}function We(e,t,r,n){for(let o=0;o<t.length;o+=1){const{name:s,required:u,spread:i}=t[o],c=rs(s);if(c in e)throw new Error(`Invalid parameter: ${T(s)} is used more than once.`);const l=i?r.slice(o):r[o];if(i&&(o=t.length),u&&(!l||i&&l.length===0))return console.error(`Error: Missing required parameter ${T(s)}
22
- `),n(),process.exit(1);e[c]=l}}function gs(e){return e===void 0||e!==!1}function lr(e,t,r,n){const o={...t.flags},s=t.version;s&&(o.version={type:Boolean,description:"Show version"});const{help:u}=t,i=gs(u);i&&!("help"in o)&&(o.help={type:Boolean,alias:"h",description:"Show help"});const c=Eo(o,n,{ignore:t.ignoreArgv}),l=()=>{console.log(t.version)};if(s&&c.flags.version===!0)return l(),process.exit(0);const d=new ms,a=i&&u?.render?u.render:f=>d.render(f),D=f=>{const m=ps({...t,...f?{help:f}:{},flags:o});console.log(a(m,d))};if(i&&c.flags.help===!0)return D(),process.exit(0);if(t.parameters){let{parameters:f}=t,m=c._;const h=f.indexOf("--"),C=f.slice(h+1),b=Object.create(null);if(h>-1&&C.length>0){f=f.slice(0,h);const B=c._["--"];m=m.slice(0,-B.length||void 0),We(b,Ye(f),m,D),We(b,Ye(C),B,D)}else We(b,Ye(f),m,D);Object.assign(c._,b)}const p={...c,showVersion:l,showHelp:D};return typeof r=="function"&&r(p),{command:e,...p}}function Cs(e,t){const r=new Map;for(const n of t){const o=[n.options.name],{alias:s}=n.options;s&&(Array.isArray(s)?o.push(...s):o.push(s));for(const u of o){if(r.has(u))throw new Error(`Duplicate command name found: ${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||!ze.test(e.name)))throw new Error(`Invalid script name: ${T(e.name)}`);const n=r[0];if(e.commands&&ze.test(n)){const o=Cs(n,e.commands);if(o)return lr(o.options.name,{...o.options,parent:e},o.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(!ze.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 V={exports:{}},Ve,dr;function ys(){if(dr)return Ve;dr=1,Ve=n,n.sync=o;var e=q;function t(s,u){var i=u.pathExt!==void 0?u.pathExt:process.env.PATHEXT;if(!i||(i=i.split(";"),i.indexOf("")!==-1))return!0;for(var c=0;c<i.length;c++){var l=i[c].toLowerCase();if(l&&s.substr(-l.length).toLowerCase()===l)return!0}return!1}function r(s,u,i){return!s.isSymbolicLink()&&!s.isFile()?!1:t(u,i)}function n(s,u,i){e.stat(s,function(c,l){i(c,c?!1:r(l,s,u))})}function o(s,u){return r(e.statSync(s),s,u)}return Ve}var Xe,pr;function bs(){if(pr)return Xe;pr=1,Xe=t,t.sync=r;var e=q;function t(s,u,i){e.stat(s,function(c,l){i(c,c?!1:n(l,u))})}function r(s,u){return n(e.statSync(s),u)}function n(s,u){return s.isFile()&&o(s,u)}function o(s,u){var i=s.mode,c=s.uid,l=s.gid,d=u.uid!==void 0?u.uid:process.getuid&&process.getuid(),a=u.gid!==void 0?u.gid:process.getgid&&process.getgid(),D=parseInt("100",8),p=parseInt("010",8),f=parseInt("001",8),m=D|p,h=i&f||i&p&&l===a||i&D&&c===d||i&m&&d===0;return h}return Xe}var ve;process.platform==="win32"||w.TESTING_WINDOWS?ve=ys():ve=bs();var As=Qe;Qe.sync=ws;function Qe(e,t,r){if(typeof t=="function"&&(r=t,t={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,o){Qe(e,t||{},function(s,u){s?o(s):n(u)})})}ve(e,t||{},function(n,o){n&&(n.code==="EACCES"||t&&t.ignoreErrors)&&(n=null,o=!1),r(n,o)})}function ws(e,t){try{return ve.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}const X=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",fr=K,vs=X?";":":",mr=As,hr=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),gr=(e,t)=>{const r=t.colon||vs,n=e.match(/\//)||X&&e.match(/\\/)?[""]:[...X?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],o=X?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=X?o.split(r):[""];return X&&e.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:n,pathExt:s,pathExtExe:o}},Cr=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});const{pathEnv:n,pathExt:o,pathExtExe:s}=gr(e,t),u=[],i=l=>new Promise((d,a)=>{if(l===n.length)return t.all&&u.length?d(u):a(hr(e));const D=n[l],p=/^".*"$/.test(D)?D.slice(1,-1):D,f=fr.join(p,e),m=!p&&/^\.[\\\/]/.test(e)?e.slice(0,2)+f:f;d(c(m,l,0))}),c=(l,d,a)=>new Promise((D,p)=>{if(a===o.length)return D(i(d+1));const f=o[a];mr(l+f,{pathExt:s},(m,h)=>{if(!m&&h)if(t.all)u.push(l+f);else return D(l+f);return D(c(l,d,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:o}=gr(e,t),s=[];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),d=!c&&/^\.[\\\/]/.test(e)?e.slice(0,2)+l:l;for(let a=0;a<n.length;a++){const D=d+n[a];try{if(mr.sync(D,{pathExt:o}))if(t.all)s.push(D);else return D}catch{}}}if(t.all&&s.length)return s;if(t.nothrow)return null;throw hr(e)};var Bs=Cr;Cr.sync=$s;var Ze={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"};Ze.exports=Er,Ze.exports.default=Er;var xs=Ze.exports;const Fr=K,Os=Bs,Ms=xs;function yr(e,t){const r=e.options.env||process.env,n=process.cwd(),o=e.options.cwd!=null,s=o&&process.chdir!==void 0&&!process.chdir.disabled;if(s)try{process.chdir(e.options.cwd)}catch{}let u;try{u=Os.sync(e.command,{path:r[Ms({env:r})],pathExt:t?Fr.delimiter:void 0})}catch{}finally{s&&process.chdir(n)}return u&&(u=Fr.resolve(o?e.options.cwd:"",u)),u}function Ss(e){return yr(e)||yr(e,!0)}var Is=Ss,et={};const tt=/([()\][%!^"`<>&|;, *?])/g;function Ps(e){return e=e.replace(tt,"^$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(tt,"^$1"),t&&(e=e.replace(tt,"^$1")),e}et.command=Ps,et.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(" "),o=r.split("/").pop();return o==="env"?n:n?`${o} ${n}`:o};const rt=q,Ns=Rs;function ks(e){const r=Buffer.alloc(150);let n;try{n=rt.openSync(e,"r"),rt.readSync(n,r,0,150,0),rt.closeSync(n)}catch{}return Ns(r.toString())}var js=ks;const Gs=K,br=Is,Ar=et,Hs=js,Us=process.platform==="win32",Ks=/\.(?:com|exe)$/i,qs=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function zs(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=zs(e),r=!Ks.test(t);if(e.options.forceShell||r){const n=qs.test(t);e.command=Gs.normalize(e.command),e.command=Ar.command(e.command),e.args=e.args.map(s=>Ar.argument(s,n));const o=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${o}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function 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 Js=Ws;const nt=process.platform==="win32";function ot(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function Vs(e,t){if(!nt)return;const r=e.emit;e.emit=function(n,o){if(n==="exit"){const s=wr(o,t);if(s)return r.call(e,"error",s)}return r.apply(e,arguments)}}function wr(e,t){return nt&&e===1&&!t.file?ot(t.original,"spawn"):null}function Xs(e,t){return nt&&e===1&&!t.file?ot(t.original,"spawnSync"):null}var Qs={hookChildProcess:Vs,verifyENOENT:wr,verifyENOENTSync:Xs,notFoundError:ot};const vr=$n,st=Js,ut=Qs;function $r(e,t,r){const n=st(e,t,r),o=vr.spawn(n.command,n.args,n.options);return ut.hookChildProcess(o,n),o}function Zs(e,t,r){const n=st(e,t,r),o=vr.spawnSync(n.command,n.args,n.options);return o.error=o.error||ut.verifyENOENTSync(o.status,n),o}V.exports=$r,V.exports.spawn=$r,V.exports.sync=Zs,V.exports._parse=st,V.exports._enoent=ut;var eu=V.exports,tu=J(eu);function ru(e){const t=typeof e=="string"?`
20
+ `}table({tableData:t,tableOptions:r,tableBreakpoints:n}){return es(t.map(o=>o.map(s=>this.render(s))),n?ns(n):r)}flagParameter(t){return t===Boolean?"":t===String?"<string>":t===Number?"<number>":Array.isArray(t)?this.flagParameter(t[0]):"<value>"}flagOperator(t){return" "}flagName(t){const{flag:r,flagFormatted:n,aliasesEnabled:o,aliasFormatted:s}=t;let u="";if(s?u+=`${s}, `:o&&(u+=" "),u+=n,"placeholder"in r&&typeof r.placeholder=="string")u+=`${this.flagOperator(t)}${r.placeholder}`;else{const i=this.flagParameter("type"in r?r.type:r);i&&(u+=`${this.flagOperator(t)}${i}`)}return u}flagDefault(t){return JSON.stringify(t)}flagDescription({flag:t}){let r="description"in t?t.description??"":"";if("default"in t){let{default:n}=t;typeof n=="function"&&(n=n()),n&&(r+=` (default: ${this.flagDefault(n)})`)}return r}render(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(r=>this.render(r)).join(`
21
+ `);if("type"in t&&this[t.type]){const r=this[t.type];if(typeof r=="function")return r.call(this,t.data)}throw new Error(`Invalid node type: ${JSON.stringify(t)}`)}}const ze=/^[\w.-]+$/,{stringify:L}=JSON,Cs=/[|\\{}()[\]^$+*?.]/;function Ye(e){const t=[];let r,n;for(const o of e){if(n)throw new Error(`Invalid parameter: Spread parameter ${L(n)} must be last`);const s=o[0],u=o[o.length-1];let i;if(s==="<"&&u===">"&&(i=!0,r))throw new Error(`Invalid parameter: Required parameter ${L(o)} cannot come after optional parameter ${L(r)}`);if(s==="["&&u==="]"&&(i=!1,r=o),i===void 0)throw new Error(`Invalid parameter: ${L(o)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let c=o.slice(1,-1);const l=c.slice(-3)==="...";l&&(n=o,c=c.slice(0,-3));const d=c.match(Cs);if(d)throw new Error(`Invalid parameter: ${L(o)}. Invalid character found ${L(d[0])}`);t.push({name:c,required:i,spread:l})}return t}function We(e,t,r,n){for(let o=0;o<t.length;o+=1){const{name:s,required:u,spread:i}=t[o],c=os(s);if(c in e)throw new Error(`Invalid parameter: ${L(s)} is used more than once.`);const l=i?r.slice(o):r[o];if(i&&(o=t.length),u&&(!l||i&&l.length===0))return console.error(`Error: Missing required parameter ${L(s)}
22
+ `),n(),process.exit(1);e[c]=l}}function Es(e){return e===void 0||e!==!1}function dr(e,t,r,n){const o={...t.flags},s=t.version;s&&(o.version={type:Boolean,description:"Show version"});const{help:u}=t,i=Es(u);i&&!("help"in o)&&(o.help={type:Boolean,alias:"h",description:"Show help"});const c=yo(o,n,{ignore:t.ignoreArgv}),l=()=>{console.log(t.version)};if(s&&c.flags.version===!0)return l(),process.exit(0);const d=new gs,a=i&&u?.render?u.render:f=>d.render(f),D=f=>{const h=ms({...t,...f?{help:f}:{},flags:o});console.log(a(h,d))};if(i&&c.flags.help===!0)return D(),process.exit(0);if(t.parameters){let{parameters:f}=t,h=c._;const m=f.indexOf("--"),E=f.slice(m+1),b=Object.create(null);if(m>-1&&E.length>0){f=f.slice(0,m);const w=c._["--"];h=h.slice(0,-w.length||void 0),We(b,Ye(f),h,D),We(b,Ye(E),w,D)}else We(b,Ye(f),h,D);Object.assign(c._,b)}const p={...c,showVersion:l,showHelp:D};return typeof r=="function"&&r(p),{command:e,...p}}function Fs(e,t){const r=new Map;for(const n of t){const o=[n.options.name],{alias:s}=n.options;s&&(Array.isArray(s)?o.push(...s):o.push(s));for(const u of o){if(r.has(u))throw new Error(`Duplicate command name found: ${L(u)}`);r.set(u,n)}}return r.get(e)}function ys(e,t,r=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!ze.test(e.name)))throw new Error(`Invalid script name: ${L(e.name)}`);const n=r[0];if(e.commands&&ze.test(n)){const o=Fs(n,e.commands);if(o)return dr(o.options.name,{...o.options,parent:e},o.callback,r.slice(1))}return dr(void 0,e,t,r)}function Je(e,t){if(!e)throw new Error("Command options are required");const{name:r}=e;if(e.name===void 0)throw new Error("Command name is required");if(!ze.test(r))throw new Error(`Invalid command name ${JSON.stringify(r)}. Command names must be one word.`);return{options:e,callback:t}}var bs=vn(import.meta.url),v=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function V(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var X={exports:{}},Ve,pr;function As(){if(pr)return Ve;pr=1,Ve=n,n.sync=o;var e=k;function t(s,u){var i=u.pathExt!==void 0?u.pathExt:process.env.PATHEXT;if(!i||(i=i.split(";"),i.indexOf("")!==-1))return!0;for(var c=0;c<i.length;c++){var l=i[c].toLowerCase();if(l&&s.substr(-l.length).toLowerCase()===l)return!0}return!1}function r(s,u,i){return!s.isSymbolicLink()&&!s.isFile()?!1:t(u,i)}function n(s,u,i){e.stat(s,function(c,l){i(c,c?!1:r(l,s,u))})}function o(s,u){return r(e.statSync(s),s,u)}return Ve}var Xe,fr;function ws(){if(fr)return Xe;fr=1,Xe=t,t.sync=r;var e=k;function t(s,u,i){e.stat(s,function(c,l){i(c,c?!1:n(l,u))})}function r(s,u){return n(e.statSync(s),u)}function n(s,u){return s.isFile()&&o(s,u)}function o(s,u){var i=s.mode,c=s.uid,l=s.gid,d=u.uid!==void 0?u.uid:process.getuid&&process.getuid(),a=u.gid!==void 0?u.gid:process.getgid&&process.getgid(),D=parseInt("100",8),p=parseInt("010",8),f=parseInt("001",8),h=D|p,m=i&f||i&p&&l===a||i&D&&c===d||i&h&&d===0;return m}return Xe}var ve;process.platform==="win32"||v.TESTING_WINDOWS?ve=As():ve=ws();var vs=Qe;Qe.sync=$s;function Qe(e,t,r){if(typeof t=="function"&&(r=t,t={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,o){Qe(e,t||{},function(s,u){s?o(s):n(u)})})}ve(e,t||{},function(n,o){n&&(n.code==="EACCES"||t&&t.ignoreErrors)&&(n=null,o=!1),r(n,o)})}function $s(e,t){try{return ve.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}const Q=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",mr=P,Bs=Q?";":":",hr=vs,gr=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),Cr=(e,t)=>{const r=t.colon||Bs,n=e.match(/\//)||Q&&e.match(/\\/)?[""]:[...Q?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],o=Q?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=Q?o.split(r):[""];return Q&&e.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:n,pathExt:s,pathExtExe:o}},Er=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});const{pathEnv:n,pathExt:o,pathExtExe:s}=Cr(e,t),u=[],i=l=>new Promise((d,a)=>{if(l===n.length)return t.all&&u.length?d(u):a(gr(e));const D=n[l],p=/^".*"$/.test(D)?D.slice(1,-1):D,f=mr.join(p,e),h=!p&&/^\.[\\\/]/.test(e)?e.slice(0,2)+f:f;d(c(h,l,0))}),c=(l,d,a)=>new Promise((D,p)=>{if(a===o.length)return D(i(d+1));const f=o[a];hr(l+f,{pathExt:s},(h,m)=>{if(!h&&m)if(t.all)u.push(l+f);else return D(l+f);return D(c(l,d,a+1))})});return r?i(0).then(l=>r(null,l),r):i(0)},xs=(e,t)=>{t=t||{};const{pathEnv:r,pathExt:n,pathExtExe:o}=Cr(e,t),s=[];for(let u=0;u<r.length;u++){const i=r[u],c=/^".*"$/.test(i)?i.slice(1,-1):i,l=mr.join(c,e),d=!c&&/^\.[\\\/]/.test(e)?e.slice(0,2)+l:l;for(let a=0;a<n.length;a++){const D=d+n[a];try{if(hr.sync(D,{pathExt:o}))if(t.all)s.push(D);else return D}catch{}}}if(t.all&&s.length)return s;if(t.nothrow)return null;throw gr(e)};var Os=Er;Er.sync=xs;var Ze={exports:{}};const Fr=(e={})=>{const t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};Ze.exports=Fr,Ze.exports.default=Fr;var Ms=Ze.exports;const yr=P,Ss=Os,Ps=Ms;function br(e,t){const r=e.options.env||process.env,n=process.cwd(),o=e.options.cwd!=null,s=o&&process.chdir!==void 0&&!process.chdir.disabled;if(s)try{process.chdir(e.options.cwd)}catch{}let u;try{u=Ss.sync(e.command,{path:r[Ps({env:r})],pathExt:t?yr.delimiter:void 0})}catch{}finally{s&&process.chdir(n)}return u&&(u=yr.resolve(o?e.options.cwd:"",u)),u}function Is(e){return br(e)||br(e,!0)}var _s=Is,et={};const tt=/([()\][%!^"`<>&|;, *?])/g;function Ts(e){return e=e.replace(tt,"^$1"),e}function Ls(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(tt,"^$1"),t&&(e=e.replace(tt,"^$1")),e}et.command=Ts,et.argument=Ls;var Rs=/^#!(.*)/;const Ns=Rs;var ks=(e="")=>{const t=e.match(Ns);if(!t)return null;const[r,n]=t[0].replace(/#! ?/,"").split(" "),o=r.split("/").pop();return o==="env"?n:n?`${o} ${n}`:o};const rt=k,js=ks;function Gs(e){const r=Buffer.alloc(150);let n;try{n=rt.openSync(e,"r"),rt.readSync(n,r,0,150,0),rt.closeSync(n)}catch{}return js(r.toString())}var Hs=Gs;const Us=P,Ar=_s,wr=et,Ks=Hs,qs=process.platform==="win32",zs=/\.(?:com|exe)$/i,Ys=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Ws(e){e.file=Ar(e);const t=e.file&&Ks(e.file);return t?(e.args.unshift(e.file),e.command=t,Ar(e)):e.file}function Js(e){if(!qs)return e;const t=Ws(e),r=!zs.test(t);if(e.options.forceShell||r){const n=Ys.test(t);e.command=Us.normalize(e.command),e.command=wr.command(e.command),e.args=e.args.map(s=>wr.argument(s,n));const o=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${o}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function Vs(e,t,r){t&&!Array.isArray(t)&&(r=t,t=null),t=t?t.slice(0):[],r=Object.assign({},r);const n={command:e,args:t,options:r,file:void 0,original:{command:e,args:t}};return r.shell?n:Js(n)}var Xs=Vs;const nt=process.platform==="win32";function ot(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function Qs(e,t){if(!nt)return;const r=e.emit;e.emit=function(n,o){if(n==="exit"){const s=vr(o,t);if(s)return r.call(e,"error",s)}return r.apply(e,arguments)}}function vr(e,t){return nt&&e===1&&!t.file?ot(t.original,"spawn"):null}function Zs(e,t){return nt&&e===1&&!t.file?ot(t.original,"spawnSync"):null}var eu={hookChildProcess:Qs,verifyENOENT:vr,verifyENOENTSync:Zs,notFoundError:ot};const $r=xn,st=Xs,ut=eu;function Br(e,t,r){const n=st(e,t,r),o=$r.spawn(n.command,n.args,n.options);return ut.hookChildProcess(o,n),o}function tu(e,t,r){const n=st(e,t,r),o=$r.spawnSync(n.command,n.args,n.options);return o.error=o.error||ut.verifyENOENTSync(o.status,n),o}X.exports=Br,X.exports.spawn=Br,X.exports.sync=tu,X.exports._parse=st,X.exports._enoent=ut;var ru=X.exports,nu=V(ru);function ou(e){const t=typeof e=="string"?`
23
23
  `:`
24
- `.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=I.cwd(),path:t=I.env[Br()],preferLocal:r=!0,execPath:n=I.execPath,addExecPath:o=!0}={})=>{const s=e instanceof URL?kt(e):e,u=W.resolve(s),i=[];return r&&ou(i,u),o&&su(i,n,u),[...i,t].join(W.delimiter)},ou=(e,t)=>{let r;for(;r!==t;)e.push(W.join(t,"node_modules/.bin")),r=t,t=W.resolve(t,"..")},su=(e,t,r)=>{const n=t instanceof URL?kt(t):t;e.push(W.resolve(r,n,".."))},uu=({env:e=I.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 o=Object.getOwnPropertyDescriptor(e,r),s=Object.getOwnPropertyDescriptor(t,r);!au(o,s)&&n||Object.defineProperty(e,r,s)},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"),du=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),pu=(e,t,r)=>{const n=r===""?"":`with ${r.trim()}() `,o=Du.bind(null,n,t.toString());Object.defineProperty(o,"name",du),Object.defineProperty(e,"toString",{...lu,value:o})};function fu(e,t,{ignoreNonConfigurable:r=!1}={}){const{name:n}=e;for(const o of Reflect.ownKeys(t))iu(e,t,o,r);return cu(e,t),pu(e,t,n),e}const $e=new WeakMap,xr=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let r,n=0;const o=e.displayName||e.name||"<anonymous>",s=function(...u){if($e.set(s,++n),n===1)r=e.apply(this,u),e=null;else if(t.throw===!0)throw new Error(`Function \`${o}\` can only be called once`);return r};return fu(s,e),$e.set(s,n),s};xr.callCount=e=>{if(!$e.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return $e.get(e)};const 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:o=!1,standard:s})=>{const{signals:{[e]:u}}=jt,i=u!==void 0;return{name:e,number:i?u:t,description:r,supported:i,action:n,forced:o,standard:s}},Eu=()=>{const e=Sr();return Object.fromEntries(e.map(Fu))},Fu=({name:e,number:t,description:r,supported:n,action:o,forced:s,standard:u})=>[e,{name:e,number:t,description:r,supported:n,action:o,forced:s,standard:u}],yu=Eu(),bu=()=>{const e=Sr(),t=Mr+1,r=Array.from({length:t},(n,o)=>Au(o,e));return Object.assign({},...r)},Au=(e,t)=>{const r=wu(e,t);if(r===void 0)return{};const{name:n,description:o,supported:s,action:u,forced:i,standard:c}=r;return{[e]:{name:n,number:e,description:o,supported:s,action:u,forced:i,standard:c}}},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:o,exitCode:s,isCanceled:u})=>e?`timed out after ${t} milliseconds`:u?"was canceled":r!==void 0?`failed with ${r}`:n!==void 0?`was killed with ${n} (${o})`:s!==void 0?`failed with exit code ${s}`:"failed",Ir=({stdout:e,stderr:t,all:r,error:n,signal:o,exitCode:s,command:u,escapedCommand:i,timedOut:c,isCanceled:l,killed:d,parsed:{options:{timeout:a,cwd:D=I.cwd()}}})=>{s=s===null?void 0:s,o=o===null?void 0:o;const p=o===void 0?void 0:yu[o].description,f=n&&n.code,h=`Command ${vu({timedOut:c,timeout:a,errorCode:f,signal:o,signalDescription:p,exitCode:s,isCanceled:l})}: ${u}`,C=Object.prototype.toString.call(n)==="[object Error]",b=C?`${h}
26
- ${n.message}`:h,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=s,n.signal=o,n.signalDescription=p,n.stdout=e,n.stderr=t,n.cwd=D,r!==void 0&&(n.all=r),"bufferedData"in n&&delete n.bufferedData,n.failed=!0,n.timedOut=!!c,n.isCanceled=l,n.killed=d&&!c,n},Be=["stdin","stdout","stderr"],$u=e=>Be.some(t=>e[t]!==void 0),Bu=e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return Be.map(n=>e[n]);if($u(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Be.map(n=>`\`${n}\``).join(", ")}`);if(typeof t=="string")return t;if(!Array.isArray(t))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);const r=Math.max(t.length,Be.length);return Array.from({length:r},(n,o)=>t[o])};var Q={exports:{}},xe={exports:{}};xe.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")}(xe)),xe.exports}var F=w.process;const Y=function(e){return e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function"};if(!Y(F))Q.exports=function(){return function(){}};else{var Ou=Gt,ce=xu(),Mu=/^win/i.test(F.platform),Oe=Ht;typeof Oe!="function"&&(Oe=Oe.EventEmitter);var v;F.__signal_exit_emitter__?v=F.__signal_exit_emitter__:(v=F.__signal_exit_emitter__=new Oe,v.count=0,v.emitted={}),v.infinite||(v.setMaxListeners(1/0),v.infinite=!0),Q.exports=function(e,t){if(!Y(w.process))return function(){};Ou.equal(typeof e,"function","a callback must be provided for exit handler"),De===!1&&_r();var r="exit";t&&t.alwaysLast&&(r="afterexit");var n=function(){v.removeListener(r,e),v.listeners("exit").length===0&&v.listeners("afterexit").length===0&&it()};return v.on(r,e),n};var it=function(){!De||!Y(w.process)||(De=!1,ce.forEach(function(t){try{F.removeListener(t,at[t])}catch{}}),F.emit=ct,F.reallyExit=Tr,v.count-=1)};Q.exports.unload=it;var Z=function(t,r,n){v.emitted[t]||(v.emitted[t]=!0,v.emit(t,r,n))},at={};ce.forEach(function(e){at[e]=function(){if(Y(w.process)){var r=F.listeners(e);r.length===v.count&&(it(),Z("exit",null,e),Z("afterexit",null,e),Mu&&e==="SIGHUP"&&(e="SIGINT"),F.kill(F.pid,e))}}}),Q.exports.signals=function(){return ce};var De=!1,_r=function(){De||!Y(w.process)||(De=!0,v.count+=1,ce=ce.filter(function(t){try{return F.on(t,at[t]),!0}catch{return!1}}),F.emit=Iu,F.reallyExit=Su)};Q.exports.load=_r;var Tr=F.reallyExit,Su=function(t){Y(w.process)&&(F.exitCode=t||0,Z("exit",F.exitCode,null),Z("afterexit",F.exitCode,null),Tr.call(F,F.exitCode))},ct=F.emit,Iu=function(t,r){if(t==="exit"&&Y(w.process)){r!==void 0&&(F.exitCode=r);var n=ct.apply(this,arguments);return Z("exit",F.exitCode,null),Z("afterexit",F.exitCode,null),n}else return ct.apply(this,arguments)}}var Pu=Q.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 o=ju(r),s=setTimeout(()=>{e("SIGKILL")},o);s.unref&&s.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 o;const s=new Promise((i,c)=>{o=setTimeout(()=>{Hu(e,r,c)},t)}),u=n.finally(()=>{clearTimeout(o)});return Promise.race([s,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})`)},qu=async(e,{cleanup:t,detached:r},n)=>{if(!t||r)return n;const o=_u(()=>{e.kill()});return n.finally(()=>{o()})};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 zu=e=>e instanceof vn&&typeof e.then=="function",Dt=(e,t,r)=>{if(typeof r=="string")return e[t].pipe(xn(r)),e;if(Rr(r))return e[t].pipe(r),e;if(!zu(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=Dt.bind(void 0,e,"stdout")),e.stderr!==null&&(e.pipeStderr=Dt.bind(void 0,e,"stderr")),e.all!==void 0&&(e.pipeAll=Dt.bind(void 0,e,"all"))};var le={exports:{}};const{PassThrough:Wu}=Re;var Ju=e=>{e={...e};const{array:t}=e;let{encoding:r}=e;const n=r==="buffer";let o=!1;t?o=!(r||n):r=r||"utf8",n&&(r=null);const s=new Wu({objectMode:o});r&&s.setEncoding(r);let u=0;const i=[];return s.on("data",c=>{i.push(c),o?u=i.length:u+=c.length}),s.getBufferedValue=()=>t?i:n?Buffer.concat(i,u):i.join(""),s.getBufferedLength=()=>u,s};const{constants:Vu}=Mn,Xu=Re,{promisify:Qu}=Ut,Zu=Ju,ei=Qu(Xu.pipeline);class Nr extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function lt(e,t){if(!e)throw new Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:r}=t,n=Zu(t);return await new Promise((o,s)=>{const u=i=>{i&&n.getBufferedLength()<=Vu.MAX_LENGTH&&(i.bufferedData=n.getBufferedValue()),s(i)};(async()=>{try{await ei(e,n),o()}catch(i){u(i)}})(),n.on("data",()=>{n.getBufferedLength()>r&&u(new Nr)})}),n.getBufferedValue()}le.exports=lt,le.exports.buffer=(e,t)=>lt(e,{...t,encoding:"buffer"}),le.exports.array=(e,t)=>lt(e,{...t,array:!0}),le.exports.MaxBufferError=Nr;var ti=le.exports,kr=J(ti);const{PassThrough:ri}=Re;var ni=function(){var e=[],t=new ri({objectMode:!0});return t.setMaxListeners(0),t.add=r,t.isEmpty=n,t.on("unpipe",o),Array.prototype.slice.call(arguments).forEach(r),t;function r(s){return Array.isArray(s)?(s.forEach(r),this):(e.push(s),s.once("end",o.bind(null,s)),s.once("error",t.emit.bind(t,"error")),s.pipe(t,{end:!1}),this)}function n(){return e.length==0}function o(s){e=e.filter(function(u){return u!==s}),!e.length&&t.readable&&t.end()}},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}}},pt=(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:o,maxBuffer:s},u)=>{const i=pt(e,{encoding:n,buffer:o,maxBuffer:s}),c=pt(t,{encoding:n,buffer:o,maxBuffer:s}),l=pt(r,{encoding:n,buffer:o,maxBuffer:s*2});try{return await Promise.all([u,i,c,l])}catch(d){return Promise.all([{error:d,signal:d.signal,timedOut:d.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 o=typeof t=="function"?(...s)=>Reflect.apply(n.value,t(),s):n.value.bind(t);Reflect.defineProperty(e,r,{...n,value:o})}},di=e=>new Promise((t,r)=>{e.on("exit",(n,o)=>{t({exitCode:n,signal:o})}),e.on("error",n=>{r(n)}),e.stdin&&e.stdin.on("error",n=>{r(n)})}),Gr=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],pi=/^[\w.-]+$/,fi=/"/g,mi=e=>typeof e!="string"||pi.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,Me=(e,t)=>String(e).padStart(t,"0"),Ei=()=>{const e=new Date;return`${Me(e.getHours(),2)}:${Me(e.getMinutes(),2)}:${Me(e.getSeconds(),2)}.${Me(e.getMilliseconds(),3)}`},Fi=(e,{verbose:t})=>{t&&I.stderr.write(`[${Ei()}] ${e}
28
- `)},yi=1e3*1e3*100,bi=({env:e,extendEnv:t,preferLocal:r,localDir:n,execPath:o})=>{const s=t?{...I.env,...e}:e;return r?uu({env:s,cwd:n,execPath:o}):s},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||I.cwd(),execPath:I.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:Ci,...r},r.env=bi(r),r.stdio=Bu(r),I.platform==="win32"&&W.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:r,parsed:n}},ft=(e,t,r)=>typeof t!="string"&&!wn.isBuffer(t)?r===void 0?void 0:"":e.stripFinalNewline?ru(t):t;function ee(e,t,r){const n=Ai(e,t,r),o=hi(e,t),s=gi(e,t);Fi(s,n.options),Ku(n.options);let u;try{u=Nt.spawn(n.file,n.args,n.options)}catch(p){const f=new Nt.ChildProcess,m=Promise.reject(Ir({error:p,stdout:"",stderr:"",all:"",command:o,escapedCommand:s,parsed:n,timedOut:!1,isCanceled:!1,killed:!1}));return jr(f,m),f}const i=di(u),c=Uu(u,n.options,i),l=qu(u,n.options,c),d={isCanceled:!1};u.kill=Lu.bind(null,u.kill.bind(u)),u.cancel=Gu.bind(null,u,d);const D=xr(async()=>{const[{error:p,exitCode:f,signal:m,timedOut:h},C,b,B]=await ci(u,n.options,l),L=ft(n.options,C),R=ft(n.options,b),se=ft(n.options,B);if(p||f!==0||m!==null){const A=Ir({error:p,exitCode:f,signal:m,stdout:L,stderr:R,all:se,command:o,escapedCommand:s,parsed:n,timedOut:h,isCanceled:d.isCanceled||(n.options.signal?n.options.signal.aborted:!1),killed:u.killed});if(!n.options.reject)return A;throw A}return{command:o,escapedCommand:s,exitCode:0,stdout:L,stderr:R,all:se,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 j{static create(t,r){return new t(r)}}const wi=80,vi={"":"<commit message>",conventional:`<type>(<optional scope>): <description>
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 xr(e={}){const{env:t=process.env,platform:r=process.platform}=e;return r!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"}const su=({cwd:e=I.cwd(),path:t=I.env[xr()],preferLocal:r=!0,execPath:n=I.execPath,addExecPath:o=!0}={})=>{const s=e instanceof URL?jt(e):e,u=J.resolve(s),i=[];return r&&uu(i,u),o&&iu(i,n,u),[...i,t].join(J.delimiter)},uu=(e,t)=>{let r;for(;r!==t;)e.push(J.join(t,"node_modules/.bin")),r=t,t=J.resolve(t,"..")},iu=(e,t,r)=>{const n=t instanceof URL?jt(t):t;e.push(J.resolve(r,n,".."))},au=({env:e=I.env,...t}={})=>{e={...e};const r=xr({env:e});return t.path=e[r],e[r]=su(t),e},cu=(e,t,r,n)=>{if(r==="length"||r==="prototype"||r==="arguments"||r==="caller")return;const o=Object.getOwnPropertyDescriptor(e,r),s=Object.getOwnPropertyDescriptor(t,r);!Du(o,s)&&n||Object.defineProperty(e,r,s)},Du=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},lu=(e,t)=>{const r=Object.getPrototypeOf(t);r!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,r)},du=(e,t)=>`/* Wrapped ${e}*/
25
+ ${t}`,pu=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),fu=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),mu=(e,t,r)=>{const n=r===""?"":`with ${r.trim()}() `,o=du.bind(null,n,t.toString());Object.defineProperty(o,"name",fu),Object.defineProperty(e,"toString",{...pu,value:o})};function hu(e,t,{ignoreNonConfigurable:r=!1}={}){const{name:n}=e;for(const o of Reflect.ownKeys(t))cu(e,t,o,r);return lu(e,t),mu(e,t,n),e}const $e=new WeakMap,Or=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let r,n=0;const o=e.displayName||e.name||"<anonymous>",s=function(...u){if($e.set(s,++n),n===1)r=e.apply(this,u),e=null;else if(t.throw===!0)throw new Error(`Function \`${o}\` can only be called once`);return r};return hu(s,e),$e.set(s,n),s};Or.callCount=e=>{if(!$e.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return $e.get(e)};const gu=()=>{const e=Sr-Mr+1;return Array.from({length:e},Cu)},Cu=(e,t)=>({name:`SIGRT${t+1}`,number:Mr+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),Mr=34,Sr=64,Eu=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}],Pr=()=>{const e=gu();return[...Eu,...e].map(Fu)},Fu=({name:e,number:t,description:r,action:n,forced:o=!1,standard:s})=>{const{signals:{[e]:u}}=Gt,i=u!==void 0;return{name:e,number:i?u:t,description:r,supported:i,action:n,forced:o,standard:s}},yu=()=>{const e=Pr();return Object.fromEntries(e.map(bu))},bu=({name:e,number:t,description:r,supported:n,action:o,forced:s,standard:u})=>[e,{name:e,number:t,description:r,supported:n,action:o,forced:s,standard:u}],Au=yu(),wu=()=>{const e=Pr(),t=Sr+1,r=Array.from({length:t},(n,o)=>vu(o,e));return Object.assign({},...r)},vu=(e,t)=>{const r=$u(e,t);if(r===void 0)return{};const{name:n,description:o,supported:s,action:u,forced:i,standard:c}=r;return{[e]:{name:n,number:e,description:o,supported:s,action:u,forced:i,standard:c}}},$u=(e,t)=>{const r=t.find(({name:n})=>Gt.signals[n]===e);return r!==void 0?r:t.find(n=>n.number===e)};wu();const Bu=({timedOut:e,timeout:t,errorCode:r,signal:n,signalDescription:o,exitCode:s,isCanceled:u})=>e?`timed out after ${t} milliseconds`:u?"was canceled":r!==void 0?`failed with ${r}`:n!==void 0?`was killed with ${n} (${o})`:s!==void 0?`failed with exit code ${s}`:"failed",Ir=({stdout:e,stderr:t,all:r,error:n,signal:o,exitCode:s,command:u,escapedCommand:i,timedOut:c,isCanceled:l,killed:d,parsed:{options:{timeout:a,cwd:D=I.cwd()}}})=>{s=s===null?void 0:s,o=o===null?void 0:o;const p=o===void 0?void 0:Au[o].description,f=n&&n.code,m=`Command ${Bu({timedOut:c,timeout:a,errorCode:f,signal:o,signalDescription:p,exitCode:s,isCanceled:l})}: ${u}`,E=Object.prototype.toString.call(n)==="[object Error]",b=E?`${m}
26
+ ${n.message}`:m,w=[b,t,e].filter(Boolean).join(`
27
+ `);return E?(n.originalMessage=n.message,n.message=w):n=new Error(w),n.shortMessage=b,n.command=u,n.escapedCommand=i,n.exitCode=s,n.signal=o,n.signalDescription=p,n.stdout=e,n.stderr=t,n.cwd=D,r!==void 0&&(n.all=r),"bufferedData"in n&&delete n.bufferedData,n.failed=!0,n.timedOut=!!c,n.isCanceled=l,n.killed=d&&!c,n},Be=["stdin","stdout","stderr"],xu=e=>Be.some(t=>e[t]!==void 0),Ou=e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return Be.map(n=>e[n]);if(xu(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Be.map(n=>`\`${n}\``).join(", ")}`);if(typeof t=="string")return t;if(!Array.isArray(t))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);const r=Math.max(t.length,Be.length);return Array.from({length:r},(n,o)=>t[o])};var Z={exports:{}},xe={exports:{}};xe.exports;var _r;function Mu(){return _r||(_r=1,function(e){e.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"],process.platform!=="win32"&&e.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),process.platform==="linux"&&e.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")}(xe)),xe.exports}var y=v.process;const Y=function(e){return e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function"};if(!Y(y))Z.exports=function(){return function(){}};else{var Su=Ht,ce=Mu(),Pu=/^win/i.test(y.platform),Oe=Ut;typeof Oe!="function"&&(Oe=Oe.EventEmitter);var $;y.__signal_exit_emitter__?$=y.__signal_exit_emitter__:($=y.__signal_exit_emitter__=new Oe,$.count=0,$.emitted={}),$.infinite||($.setMaxListeners(1/0),$.infinite=!0),Z.exports=function(e,t){if(!Y(v.process))return function(){};Su.equal(typeof e,"function","a callback must be provided for exit handler"),De===!1&&Tr();var r="exit";t&&t.alwaysLast&&(r="afterexit");var n=function(){$.removeListener(r,e),$.listeners("exit").length===0&&$.listeners("afterexit").length===0&&it()};return $.on(r,e),n};var it=function(){!De||!Y(v.process)||(De=!1,ce.forEach(function(t){try{y.removeListener(t,at[t])}catch{}}),y.emit=ct,y.reallyExit=Lr,$.count-=1)};Z.exports.unload=it;var ee=function(t,r,n){$.emitted[t]||($.emitted[t]=!0,$.emit(t,r,n))},at={};ce.forEach(function(e){at[e]=function(){if(Y(v.process)){var r=y.listeners(e);r.length===$.count&&(it(),ee("exit",null,e),ee("afterexit",null,e),Pu&&e==="SIGHUP"&&(e="SIGINT"),y.kill(y.pid,e))}}}),Z.exports.signals=function(){return ce};var De=!1,Tr=function(){De||!Y(v.process)||(De=!0,$.count+=1,ce=ce.filter(function(t){try{return y.on(t,at[t]),!0}catch{return!1}}),y.emit=_u,y.reallyExit=Iu)};Z.exports.load=Tr;var Lr=y.reallyExit,Iu=function(t){Y(v.process)&&(y.exitCode=t||0,ee("exit",y.exitCode,null),ee("afterexit",y.exitCode,null),Lr.call(y,y.exitCode))},ct=y.emit,_u=function(t,r){if(t==="exit"&&Y(v.process)){r!==void 0&&(y.exitCode=r);var n=ct.apply(this,arguments);return ee("exit",y.exitCode,null),ee("afterexit",y.exitCode,null),n}else return ct.apply(this,arguments)}}var Tu=Z.exports,Lu=V(Tu);const Ru=1e3*5,Nu=(e,t="SIGTERM",r={})=>{const n=e(t);return ku(e,t,r,n),n},ku=(e,t,r,n)=>{if(!ju(t,r,n))return;const o=Hu(r),s=setTimeout(()=>{e("SIGKILL")},o);s.unref&&s.unref()},ju=(e,{forceKillAfterTimeout:t},r)=>Gu(e)&&t!==!1&&r,Gu=e=>e===On.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",Hu=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return Ru;if(!Number.isFinite(e)||e<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e},Uu=(e,t)=>{e.kill()&&(t.isCanceled=!0)},Ku=(e,t,r)=>{e.kill(t),r(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},qu=(e,{timeout:t,killSignal:r="SIGTERM"},n)=>{if(t===0||t===void 0)return n;let o;const s=new Promise((i,c)=>{o=setTimeout(()=>{Ku(e,r,c)},t)}),u=n.finally(()=>{clearTimeout(o)});return Promise.race([s,u])},zu=({timeout:e})=>{if(e!==void 0&&(!Number.isFinite(e)||e<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`)},Yu=async(e,{cleanup:t,detached:r},n)=>{if(!t||r)return n;const o=Lu(()=>{e.kill()});return n.finally(()=>{o()})};function Rr(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}function Nr(e){return Rr(e)&&e.writable!==!1&&typeof e._write=="function"&&typeof e._writableState=="object"}const Wu=e=>e instanceof Bn&&typeof e.then=="function",Dt=(e,t,r)=>{if(typeof r=="string")return e[t].pipe(Mn(r)),e;if(Nr(r))return e[t].pipe(r),e;if(!Wu(r))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!Nr(r.stdin))throw new TypeError("The target child process's stdin must be available.");return e[t].pipe(r.stdin),r},Ju=e=>{e.stdout!==null&&(e.pipeStdout=Dt.bind(void 0,e,"stdout")),e.stderr!==null&&(e.pipeStderr=Dt.bind(void 0,e,"stderr")),e.all!==void 0&&(e.pipeAll=Dt.bind(void 0,e,"all"))};var le={exports:{}};const{PassThrough:Vu}=Re;var Xu=e=>{e={...e};const{array:t}=e;let{encoding:r}=e;const n=r==="buffer";let o=!1;t?o=!(r||n):r=r||"utf8",n&&(r=null);const s=new Vu({objectMode:o});r&&s.setEncoding(r);let u=0;const i=[];return s.on("data",c=>{i.push(c),o?u=i.length:u+=c.length}),s.getBufferedValue=()=>t?i:n?Buffer.concat(i,u):i.join(""),s.getBufferedLength=()=>u,s};const{constants:Qu}=Pn,Zu=Re,{promisify:ei}=Kt,ti=Xu,ri=ei(Zu.pipeline);class kr extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function lt(e,t){if(!e)throw new Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:r}=t,n=ti(t);return await new Promise((o,s)=>{const u=i=>{i&&n.getBufferedLength()<=Qu.MAX_LENGTH&&(i.bufferedData=n.getBufferedValue()),s(i)};(async()=>{try{await ri(e,n),o()}catch(i){u(i)}})(),n.on("data",()=>{n.getBufferedLength()>r&&u(new kr)})}),n.getBufferedValue()}le.exports=lt,le.exports.buffer=(e,t)=>lt(e,{...t,encoding:"buffer"}),le.exports.array=(e,t)=>lt(e,{...t,array:!0}),le.exports.MaxBufferError=kr;var ni=le.exports,jr=V(ni);const{PassThrough:oi}=Re;var si=function(){var e=[],t=new oi({objectMode:!0});return t.setMaxListeners(0),t.add=r,t.isEmpty=n,t.on("unpipe",o),Array.prototype.slice.call(arguments).forEach(r),t;function r(s){return Array.isArray(s)?(s.forEach(r),this):(e.push(s),s.once("end",o.bind(null,s)),s.once("error",t.emit.bind(t,"error")),s.pipe(t,{end:!1}),this)}function n(){return e.length==0}function o(s){e=e.filter(function(u){return u!==s}),!e.length&&t.readable&&t.end()}},ui=V(si);const ii=e=>{if(e!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},ai=({input:e,inputFile:t})=>typeof t!="string"?e:(ii(e),Sn(t)),ci=(e,t)=>{const r=ai(t);r!==void 0&&(Rr(r)?r.pipe(e.stdin):e.stdin.end(r))},Di=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;const r=ui();return e.stdout&&r.add(e.stdout),e.stderr&&r.add(e.stderr),r},dt=async(e,t)=>{if(!(!e||t===void 0)){e.destroy();try{return await t}catch(r){return r.bufferedData}}},pt=(e,{encoding:t,buffer:r,maxBuffer:n})=>{if(!(!e||!r))return t?jr(e,{encoding:t,maxBuffer:n}):jr.buffer(e,{maxBuffer:n})},li=async({stdout:e,stderr:t,all:r},{encoding:n,buffer:o,maxBuffer:s},u)=>{const i=pt(e,{encoding:n,buffer:o,maxBuffer:s}),c=pt(t,{encoding:n,buffer:o,maxBuffer:s}),l=pt(r,{encoding:n,buffer:o,maxBuffer:s*2});try{return await Promise.all([u,i,c,l])}catch(d){return Promise.all([{error:d,signal:d.signal,timedOut:d.timedOut},dt(e,i),dt(t,c),dt(r,l)])}},di=(async()=>{})().constructor.prototype,pi=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(di,e)]),Gr=(e,t)=>{for(const[r,n]of pi){const o=typeof t=="function"?(...s)=>Reflect.apply(n.value,t(),s):n.value.bind(t);Reflect.defineProperty(e,r,{...n,value:o})}},fi=e=>new Promise((t,r)=>{e.on("exit",(n,o)=>{t({exitCode:n,signal:o})}),e.on("error",n=>{r(n)}),e.stdin&&e.stdin.on("error",n=>{r(n)})}),Hr=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],mi=/^[\w.-]+$/,hi=/"/g,gi=e=>typeof e!="string"||mi.test(e)?e:`"${e.replace(hi,'\\"')}"`,Ci=(e,t)=>Hr(e,t).join(" "),Ei=(e,t)=>Hr(e,t).map(r=>gi(r)).join(" "),Fi=In("execa").enabled,Me=(e,t)=>String(e).padStart(t,"0"),yi=()=>{const e=new Date;return`${Me(e.getHours(),2)}:${Me(e.getMinutes(),2)}:${Me(e.getSeconds(),2)}.${Me(e.getMilliseconds(),3)}`},bi=(e,{verbose:t})=>{t&&I.stderr.write(`[${yi()}] ${e}
28
+ `)},Ai=1e3*1e3*100,wi=({env:e,extendEnv:t,preferLocal:r,localDir:n,execPath:o})=>{const s=t?{...I.env,...e}:e;return r?au({env:s,cwd:n,execPath:o}):s},vi=(e,t,r={})=>{const n=nu._parse(e,t,r);return e=n.command,t=n.args,r=n.options,r={maxBuffer:Ai,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:r.cwd||I.cwd(),execPath:I.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:Fi,...r},r.env=wi(r),r.stdio=Ou(r),I.platform==="win32"&&J.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:r,parsed:n}},ft=(e,t,r)=>typeof t!="string"&&!$n.isBuffer(t)?r===void 0?void 0:"":e.stripFinalNewline?ou(t):t;function te(e,t,r){const n=vi(e,t,r),o=Ci(e,t),s=Ei(e,t);bi(s,n.options),zu(n.options);let u;try{u=kt.spawn(n.file,n.args,n.options)}catch(p){const f=new kt.ChildProcess,h=Promise.reject(Ir({error:p,stdout:"",stderr:"",all:"",command:o,escapedCommand:s,parsed:n,timedOut:!1,isCanceled:!1,killed:!1}));return Gr(f,h),f}const i=fi(u),c=qu(u,n.options,i),l=Yu(u,n.options,c),d={isCanceled:!1};u.kill=Nu.bind(null,u.kill.bind(u)),u.cancel=Uu.bind(null,u,d);const D=Or(async()=>{const[{error:p,exitCode:f,signal:h,timedOut:m},E,b,w]=await li(u,n.options,l),R=ft(n.options,E),N=ft(n.options,b),se=ft(n.options,w);if(p||f!==0||h!==null){const A=Ir({error:p,exitCode:f,signal:h,stdout:R,stderr:N,all:se,command:o,escapedCommand:s,parsed:n,timedOut:m,isCanceled:d.isCanceled||(n.options.signal?n.options.signal.aborted:!1),killed:u.killed});if(!n.options.reject)return A;throw A}return{command:o,escapedCommand:s,exitCode:0,stdout:R,stderr:N,all:se,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return ci(u,n.options),u.all=Di(u,n.options),Ju(u),Gr(u,D),u}class H{static create(t,r){return new t(r)}}const W={locale:"en",maxLength:50,type:"conventional",generate:1,promptPath:""},$i=80,Bi={"":"<commit message>",conventional:`<type>(<optional scope>): <description>
29
29
 
30
30
  [optional body]
31
31
 
@@ -33,43 +33,34 @@ ${n.message}`:h,B=[b,t,e].filter(Boolean).join(`
33
33
 
34
34
  [optional body]
35
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)}`},te=(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
- `),re=(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.`,M={OPEN_AI:"OPENAI_KEY",GEMINI:"GEMINI_KEY",ANTHROPIC:"ANTHROPIC_KEY",HUGGINGFACE:"HUGGINGFACE_COOKIE",MISTRAL:"MISTRAL_KEY",CODESTRAL:"CODESTRAL_KEY",OLLAMA:"OLLAMA_MODEL",COHERE:"COHERE_KEY",GROQ:"GROQ_KEY"},Hr=Object.values(M).map(e=>e);class G{constructor(t){this.handleError$=r=>{let n="An error occurred";return r.message&&(n=r.message),O({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.serviceName="AI",this.errorPrefix="ERROR",this.colors={primary:""}}buildPrompt(t,r,n,o,s,u){return`${te(t,o,s,u)}
59
- ${re(n,s)}
36
+ [optional footer(s)]`},xi={"":"",conventional:"<type>(<optional scope>): <description>",gitmoji:":<emoji>: <description>"};`${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)}`,`${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)}`;const Oi=(e,t)=>e.replace(/{(\w+)}/g,(r,n)=>t[n]?.toString()||W[n]?.toString()),Ur=e=>{const{type:t,maxLength:r,locale:n}=e;return[`Generate a ${t} commit message in ${n}.`,`The message should not exceed ${Math.min(Math.max(r,0),$i)} characters.`,"Remember to follow these guidelines:",`1. Format: ${Bi[t]}`,"2. Use the imperative mood","3. Be concise and clear","4. Explain the 'why' behind the change","5. Avoid overly verbose descriptions or unnecessary details."].filter(Boolean).join(`
37
+ `)},mt=(e,t)=>`Provide ${e} commit messages in the following JSON array format:
38
+ [
39
+ {
40
+ "message": "${xi[t]}",
41
+ "body": "Detailed explanation if necessary"
42
+ },
43
+ {
44
+ "message": "Another ${t} commit message",
45
+ "body": "Another detailed explanation if necessary"
46
+ }
47
+ ]`,re=e=>{const{type:t,generate:r,promptPath:n}=e;if(n)try{const o=k.readFileSync(P.resolve(n),"utf-8");return`${Oi(o,e)}
48
+ ${mt(r,t)}`}catch{return`${Ur(e)}
49
+ ${mt(r,t)}`}return`${Ur(e)}
50
+ ${mt(r,t)}`},M={OPEN_AI:"OPENAI_KEY",GEMINI:"GEMINI_KEY",ANTHROPIC:"ANTHROPIC_KEY",HUGGINGFACE:"HUGGINGFACE_COOKIE",MISTRAL:"MISTRAL_KEY",CODESTRAL:"CODESTRAL_KEY",OLLAMA:"OLLAMA_MODEL",COHERE:"COHERE_KEY",GROQ:"GROQ_KEY"},Kr=Object.values(M).map(e=>e);class U{constructor(t){this.handleError$=r=>{let n="An error occurred";return r.message&&(n=r.message),O({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.serviceName="AI",this.errorPrefix="ERROR",this.colors={primary:""}}buildPrompt(t,r,n,o,s,u){const i={...W,locale:t,maxLength:o,type:s,generate:n,promptPath:u};return`${re(i)}}
60
51
  Here are diff:
61
52
  ${r}`}sanitizeMessage(t,r,n,o){try{const u=JSON.parse(t).map(i=>this.extractMessageAsType(i,r)).map(i=>o?{title:`${i.message}`,value:`${i.message}`}:{title:`${i.message}`,value:i.body?`${i.message}
62
53
 
63
54
  ${i.body}`:`${i.message}`});return u.length>n?u.slice(0,n):u}catch{const u=/\[[\s\S]*?\]/;try{const i=t.match(u);if(!i)return[];const c=i[0],d=JSON.parse(c).map(a=>this.extractMessageAsType(a,r)).map(a=>o?{title:`${a.message}`,value:`${a.message}`}:{title:`${a.message}`,value:a.body?`${a.message}
64
55
 
65
- ${a.body}`:`${a.message}`});return d.length>n?d.slice(0,n):d}catch{return[]}}}extractMessageAsType(t,r){switch(r){case"conventional":const n=/(\w+)(?:\(.*?\))?:\s*(.*)/,o=t.message.match(n),s=o?o[0]:t.message;return{...t,message:this.normalizeCommitMessage(s)};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[,o,s,u]=n,i=o.toLowerCase(),c=u.charAt(0).toLowerCase()+u.slice(1);t=`${i}${s||""}: ${c}`}return t}}var Ur="1.11.1",xi="A Reactive CLI that generates git commit messages with various AI";class y extends Error{}const mt=" ",de=e=>{e instanceof Error&&(e instanceof y||(e.stack&&console.error(g.dim(e.stack.split(`
56
+ ${a.body}`:`${a.message}`});return d.length>n?d.slice(0,n):d}catch{return[]}}}extractMessageAsType(t,r){switch(r){case"conventional":const n=/(\w+)(?:\(.*?\))?:\s*(.*)/,o=t.message.match(n),s=o?o[0]:t.message;return{...t,message:this.normalizeCommitMessage(s)};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[,o,s,u]=n,i=o.toLowerCase(),c=u.charAt(0).toLowerCase()+u.slice(1);t=`${i}${s||""}: ${c}`}return t}}var qr="1.12.0",Mi="A Reactive CLI that generates git commit messages with various AI";class F extends Error{}const ht=" ",de=e=>{e instanceof Error&&(e instanceof F||(e.stack&&console.error(g.dim(e.stack.split(`
66
57
  `).slice(1).join(`
67
58
  `))),console.error(`
68
- ${mt}${g.dim(`aicommit2 v${Ur}`)}`),console.error(`
69
- ${mt}Please open a Bug report with the information above:`),console.error(`${mt}https://github.com/tak-bro/aicommit2/issues/new/choose`)))},Kr=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},pe=(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 o=r?t.length:0;return e.slice(0,n+o).trim()}return e},zr=K.join(je.homedir(),".aicommit2_log"),Si=new Date,H=(e,t,r,n)=>{const o=`[${e} Response]`,s=Ii(Si,t),u=`${zr}/${s}`;if(q.existsSync(u)){const c=q.readFileSync(u,"utf-8");Yr(u,`${o}
59
+ ${ht}${g.dim(`aicommit2 v${qr}`)}`),console.error(`
60
+ ${ht}Please open a Bug report with the information above:`),console.error(`${ht}https://github.com/tak-bro/aicommit2/issues/new/choose`)))},zr=e=>e&&`${e[0].toUpperCase()}${e.slice(1)}`,Yr=(e,t)=>{const r=Math.ceil(e),n=Math.floor(t);return Math.floor(Math.random()*(n-r+1))+r},pe=(e,t)=>e.disabled&&!t.disabled?1:!e.disabled&&t.disabled?-1:0,Si="done",Pi=(e,t,r=!1)=>{const n=e.indexOf(t);if(n!==-1){const o=r?t.length:0;return e.slice(0,n+o).trim()}return e},Wr=P.join(je.homedir(),".aicommit2_log"),Ii=new Date,K=(e,t,r,n)=>{const o=`[${e} Response]`,s=_i(Ii,t),u=`${Wr}/${s}`;if(k.existsSync(u)){const c=k.readFileSync(u,"utf-8");Jr(u,`${o}
70
61
  ${n}
71
62
 
72
- ${c}`);return}const i=Mi(r,"Here are diff");Yr(u,`${o}
63
+ ${c}`);return}const i=Pi(r,"Here are diff");Jr(u,`${o}
73
64
  ${n}
74
65
 
75
66
 
@@ -78,32 +69,27 @@ ${i}
78
69
 
79
70
 
80
71
  [Git Diff]
81
- ${t}`)},Ii=(e,t)=>{const{year:r,month:n,day:o,hours:s,minutes:u,seconds:i}=Pi(e),l=Rn(0).update(t).digest("hex");return`aic2_${r}-${n}-${o}_${s}:${u}:${i}_${l}.log`},Yr=(e,t="")=>{q.mkdirSync(K.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"),o=e.getHours().toString().padStart(2,"0"),s=e.getMinutes().toString().padStart(2,"0"),u=e.getSeconds().toString().padStart(2,"0");return{year:t,month:r,day:n,hours:o,minutes:s,seconds:u}};class _i extends G{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=r.error?.error?.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return O({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#AE5630",secondary:"#fff"},this.serviceName=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 k(this.generateMessage()).pipe(N(t=>S(t)),P(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),_(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,prompt:s,logging:u}=this.params.config,i=this.params.config["max-length"],l=`${te(r,i,o,s)}
82
- ${re(n,o)}`,d={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(d)).content.map(({text:p})=>p).join("");return u&&H("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 Se{constructor(t={}){if(!t.method)throw new Error("method should be defined!");if(!t.baseURL)throw new Error("baseURL should be defined!");this.config={...t},this.axiosInstance=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 G{constructor(t){super(t),this.params=t,this.host="https://codestral.mistral.ai",this.apiKey="",this.handleError$=r=>{const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return O({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#e28c58",secondary:"#fff"},this.serviceName=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 k(this.generateMessage()).pipe(N(t=>S(t)),P(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),_(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,prompt:s,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(r,t,n,i,o,s);this.checkAvailableModels();const l=await this.createChatCompletions(c);return u&&H("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 Se({method:"POST",baseURL:`${this.host}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.CODESTRAL_MODEL,messages:[{role:"user",content:t}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config["max-tokens"],stream:!1,safe_prompt:!1,random_seed: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 Li extends G{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=/"message":\s*"([^"]*)"/,o=r.message.match(n);let s=r?.body?.message;o&&o[1]&&(s=o[1]);const u=`${r.statusCode} ${s}`;return O({name:`${this.errorPrefix} ${u}`,value:s,isError:!0,disabled:!0})},this.colors={primary:"#D18EE2",secondary:"#fff"},this.serviceName=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 k(this.generateMessage()).pipe(N(t=>S(t)),P(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),_(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,prompt:s,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(r,t,n,i,o,s),l=this.params.config["max-tokens"],a=(await this.cohere.generate({prompt:c,maxTokens:l,temperature:this.params.config.temperature,model:this.params.config.COHERE_MODEL})).generations.map(D=>D.text).join("");return u&&H("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 G{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=r.message||r.toString(),o=/(\[.*?\]\s*[^[]*)/g,s=[...n.matchAll(o)],u=[];s.forEach(c=>u.push(c[1]));const i=u[1]||"An error occurred";return O({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 k(this.generateMessage()).pipe(N(t=>S(t)),P(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),_(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,prompt:s,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(r,t,n,i,o,s),l=this.params.config["max-tokens"],p=(await(await this.genAI.getGenerativeModel({model:this.params.config.GEMINI_MODEL,generationConfig:{maxOutputTokens:l,temperature:this.params.config.temperature}}).generateContent(c)).response).text();return u&&H("Gemini",t,c,p),this.sanitizeMessage(p,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}}class Ni extends G{constructor(t){super(t),this.params=t,this.handleError$=r=>{let n="An error occurred";const o=/"message":\s*"([^"]*)"/,s=r.message.match(o);s&&s[1]&&(n=s[1]);const u=`${r.status} ${n}`;return O({name:`${this.errorPrefix} ${u}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#f55036",secondary:"#fff"},this.serviceName=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 k(this.generateMessage()).pipe(N(t=>S(t)),P(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),_(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,prompt:s,logging:u}=this.params.config,i=this.params.config["max-length"],l=`${te(r,i,o,s)}
83
- ${re(n,o)}`,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&&H("Groq",t,l,a),this.sanitizeMessage(a,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){throw t}}}class ki extends G{constructor(t){super(t),this.params=t,this.headers={accept:"*/*","accept-language":"en-US,en;q=0.9","sec-ch-ua":'"Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"Windows"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin",origin:"https://huggingface.co","Referrer-Policy":"strict-origin-when-cross-origin"},this.models=[],this.currentModelId=null,this.currentConversation=void 0,this.currentConversionID=void 0,this.cookie="",this.colors={primary:"#FED21F",secondary:"#000"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[HuggingFace]"),this.errorPrefix=g.red.bold("[HuggingFace]"),this.cookie=this.params.config.HUGGINGFACE_COOKIE}generateCommitMessage$(){return k(this.generateMessage()).pipe(N(t=>S(t)),P(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),_(this.handleError$))}async generateMessage(){try{await this.intialize();const t=this.getSystemPrompt(),r=await this.getNewChat(t),n=`Here are diff: ${this.params.stagedDiff.diff}`,s=await(await this.sendMessage(n,r.id)).completeResponsePromise(),{generate:u,logging:i}=this.params.config;return i&&H("HuggingFace",this.params.stagedDiff.diff,t,s),this.sanitizeMessage(s,this.params.config.type,u,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async intialize(){const t=await this.getRemoteLlms(),r=t.find(n=>n.name?.toLowerCase()===this.params.config.HUGGINGFACE_MODEL.toLowerCase());if(r){this.currentModel=r,this.currentModelId=r.id;return}this.currentModel=t[0],this.currentModelId=t[0].id}async getRemoteLlms(){const t=await fetch("https://huggingface.co/chat/__data.json",{headers:{...this.headers,cookie:this.cookie},body:null,method:"GET"});if(t.status!==200)throw new Error(`Failed to get remote LLMs with status code: ${t.status}`);const n=(await t.json()).nodes[0].data,o=n[n[0].models],s=[],u=i=>i===-1?null:n[i];for(const i of o){const c=n[i];if(n[c.unlisted])continue;const l={id:u(c.id),name:u(c.name),displayName:u(c.displayName),preprompt:u(c.preprompt),promptExamples:[],websiteUrl:u(c.websiteUrl),description:u(c.description),datasetName:u(c.datasetName),datasetUrl:u(c.datasetUrl),modelUrl:u(c.modelUrl),parameters:{}},d=u(c.promptExamples);if(d!==null){const p=d.map(f=>u(f));l.promptExamples=p.map(f=>({title:n[f.title],prompt:n[f.prompt]}))}const a=u(c.parameters),D={};for(const[p,f]of Object.entries(a)){if(f===-1){D[p]=null;continue}if(Array.isArray(n[f])){D[p]=n[f].map(m=>n[m]);continue}D[p]=n[f]}l.parameters=D,s.push(l)}return this.models=s,s}async getNewChat(t){const r={model:this.currentModelId,preprompt:t};let n=0;for(;n<5;){const o=await fetch("https://huggingface.co/chat/conversation",{headers:{...this.headers,"content-type":"application/json",cookie:this.cookie,Referer:"https://huggingface.co/chat/"},body:JSON.stringify(r),method:"POST"}),{conversationId:s}=await o.json();if(s){this.currentConversionID=s;break}else n++}if(!this.currentConversionID)throw new Error("Failed to create new conversion");return await this.getConversationHistory(this.currentConversionID)}async getConversationHistory(t){if(!t)throw new Error("conversationId is required for getConversationHistory");const r=await fetch("https://huggingface.co/chat/conversation/"+t+"/__data.json",{headers:{...this.headers,cookie:this.cookie,Referer:"https://huggingface.co/chat/"},body:null,method:"GET"});if(r.status!=200)throw new Error("Unable get conversation details "+r);{const n=await r.json();return this.metadataParser(n,t)}}metadataParser(t,r){const n={id:"",model:"",systemPrompt:"",title:"",history:[]},o=t.nodes[1].data,s=o[o[0].model],u=o[o[0].preprompt],i=o[o[0].title],c=o[o[0].messages],l=[];for(const d of c){const a=o[d],D=new Date(o[a.createdAt][1]).getTime()/1e3,p=new Date(o[a.updatedAt][1]).getTime()/1e3;l.push({id:o[a.id],role:o[a.from],content:o[a.content],createdAt:D,updatedAt:p})}return n.id=r,n.model=s,n.systemPrompt=u,n.title=i,n.history=l,this.currentConversation=n,n}async sendMessage(t,r){if(t==="")throw new Error("the prompt can not be empty.");if(!r&&!this.currentConversionID?await this.getNewChat():r?(this.currentConversionID=r,await this.getConversationHistory(r)):this.currentConversionID&&await this.getConversationHistory(this.currentConversionID),!this.currentConversation)throw new Error("Failed to create new conversion");const n={inputs:t,id:this.currentConversation.history[this.currentConversation.history.length-1].id,is_retry:!1,is_continue:!1,web_search:!1,tools:{}},o=new FormData;o.append("data",JSON.stringify(n));const s=await fetch("https://huggingface.co/chat/conversation/"+this.currentConversionID,{headers:{...this.headers,cookie:this.cookie,Referer:"https://huggingface.co/chat/conversation/"+this.currentConversionID},body:o,method:"POST"});function u(D){try{const p=D.split(`
84
- `),f=[];for(const m of p)m.trim()&&f.push(JSON.parse(m));return f}catch{return[{}]}}const i=new TextDecoder;let c="";const l=new TransformStream({async transform(D,p){const f=i.decode(D);try{const m=u(f);for(const h of m)h.type==="finalAnswer"?(c=h?.text||"",p.terminate()):h.type==="stream"&&p.enqueue(h?.token||"")}catch{throw new Error("Error during parsing response")}}}),d=s.body?.pipeThrough(l);async function a(){return new Promise(async D=>{if(d){const p=d.getReader();for(;;){const{done:f,value:m}=await p.read();if(f){D(c);break}}}})}return{id:this.currentConversionID,stream:d,completeResponsePromise:a}}async deleteConversation(t){return(await fetch(`https://huggingface.co/chat/conversation/${t}`,{headers:{...this.headers,cookie:this.cookie,Referer:"https://huggingface.co/chat/"},body:null,method:"DELETE"})).json()}getSystemPrompt(){const{locale:t,generate:r,type:n,prompt:o}=this.params.config,s=this.params.config["max-length"];return`${te(t,s,n,o)}
85
- ${re(r,n)}`}}class ji extends G{constructor(t){super(t),this.params=t,this.host="https://api.mistral.ai",this.apiKey="",this.handleError$=r=>{const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return O({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#ff7000",secondary:"#fff"},this.serviceName=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 k(this.generateMessage()).pipe(N(t=>S(t)),P(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),_(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,prompt:s,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(r,t,n,i,o,s);await this.checkAvailableModels();const l=await this.createChatCompletions(c);return u&&H("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 Se({method:"GET",baseURL:`${this.host}/v1/models`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).execute()).data.data.filter(r=>r.object==="model").map(r=>r.id)}async createChatCompletions(t){const n=(await new Se({method:"POST",baseURL:`${this.host}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.MISTRAL_MODEL,messages:[{role:"user",content:t}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config["max-tokens"],stream:!1,safe_prompt:!1,random_seed: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}}const{hasOwnProperty:ht}=Object.prototype,Ie=typeof process<"u"&&process.platform==="win32"?`\r
72
+ ${t}`)},_i=(e,t)=>{const{year:r,month:n,day:o,hours:s,minutes:u,seconds:i}=Ti(e),l=kn(0).update(t).digest("hex");return`aic2_${r}-${n}-${o}_${s}:${u}:${i}_${l}.log`},Jr=(e,t="")=>{k.mkdirSync(P.dirname(e),{recursive:!0}),k.writeFileSync(e,t,"utf-8")},Ti=e=>{const t=e.getFullYear().toString(),r=(e.getMonth()+1).toString().padStart(2,"0"),n=e.getDate().toString().padStart(2,"0"),o=e.getHours().toString().padStart(2,"0"),s=e.getMinutes().toString().padStart(2,"0"),u=e.getSeconds().toString().padStart(2,"0");return{year:t,month:r,day:n,hours:o,minutes:s,seconds:u}};class Li extends U{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=r.error?.error?.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return O({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#AE5630",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Anthropic]"),this.errorPrefix=g.red.bold("[Anthropic]"),this.anthropic=new Nn({apiKey:this.params.config.ANTHROPIC_KEY})}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c={...W,locale:r,maxLength:i,type:o,generate:n,promptPath:s},d=`${re(c)}`,a={max_tokens:this.params.config["max-tokens"],temperature:this.params.config.temperature,system:d,messages:[{role:"user",content:`Here are diff: ${t}`}],model:this.params.config.ANTHROPIC_MODEL},p=(await this.anthropic.messages.create(a)).content.map(({text:f})=>f).join("");return u&&K("Anthropic",t,d,p),this.sanitizeMessage(p,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}}class Se{constructor(t={}){if(!t.method)throw new Error("method should be defined!");if(!t.baseURL)throw new Error("baseURL should be defined!");this.config={...t},this.axiosInstance=jn.create(this.config)}setHeaders(t){return this.config.headers=t,this}setParams(t){return this.config.params=t,this}setBody(t){return this.config.data=t,this}setMethod(t){return this.config.method=t,this}async execute(){try{return await this.axiosInstance.request(this.config)}catch(t){throw t}}}class Ri extends U{constructor(t){super(t),this.params=t,this.host="https://codestral.mistral.ai",this.apiKey="",this.handleError$=r=>{const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return O({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#e28c58",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Codestral]"),this.errorPrefix=g.red.bold("[Codestral]"),this.apiKey=this.params.config.CODESTRAL_KEY}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(r,t,n,i,o,s);this.checkAvailableModels();const l=await this.createChatCompletions(c);return u&&K("Codestral",t,c,l),this.sanitizeMessage(l,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}checkAvailableModels(){if(["codestral-latest","codestral-2405"].includes(this.params.config.CODESTRAL_MODEL))return!0;throw new Error("Invalid model type of Codestral AI")}async createChatCompletions(t){const n=(await new Se({method:"POST",baseURL:`${this.host}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.CODESTRAL_MODEL,messages:[{role:"user",content:t}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config["max-tokens"],stream:!1,safe_prompt:!1,random_seed:Yr(10,1e3)}).execute()).data;if(!n.choices||n.choices.length===0||!n.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return n.choices[0].message.content}}class Ni extends U{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=/"message":\s*"([^"]*)"/,o=r.message.match(n);let s=r?.body?.message;o&&o[1]&&(s=o[1]);const u=`${r.statusCode} ${s}`;return O({name:`${this.errorPrefix} ${u}`,value:s,isError:!0,disabled:!0})},this.colors={primary:"#D18EE2",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Cohere]"),this.errorPrefix=g.red.bold("[Cohere]"),this.cohere=new Gn({token:this.params.config.COHERE_KEY})}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(r,t,n,i,o,s),l=this.params.config["max-tokens"],a=(await this.cohere.generate({prompt:c,maxTokens:l,temperature:this.params.config.temperature,model:this.params.config.COHERE_MODEL})).generations.map(D=>D.text).join("");return u&&K("Cohere",t,c,a),this.sanitizeMessage(a,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r instanceof Hn?new F("Request timed out error!"):r}}}class ki extends U{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=r.message||r.toString(),o=/(\[.*?\]\s*[^[]*)/g,s=[...n.matchAll(o)],u=[];s.forEach(c=>u.push(c[1]));const i=u[1]||"An error occurred";return O({name:`${this.errorPrefix} ${i}`,value:i,isError:!0,disabled:!0})},this.colors={primary:"#0077FF",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Gemini]"),this.errorPrefix=g.red.bold("[Gemini]"),this.genAI=new Un(this.params.config.GEMINI_KEY)}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(r,t,n,i,o,s),l=this.params.config["max-tokens"],p=(await(await this.genAI.getGenerativeModel({model:this.params.config.GEMINI_MODEL,generationConfig:{maxOutputTokens:l,temperature:this.params.config.temperature}}).generateContent(c)).response).text();return u&&K("Gemini",t,c,p),this.sanitizeMessage(p,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}}class ji extends U{constructor(t){super(t),this.params=t,this.handleError$=r=>{let n="An error occurred";const o=/"message":\s*"([^"]*)"/,s=r.message.match(o);s&&s[1]&&(n=s[1]);const u=`${r.status} ${n}`;return O({name:`${this.errorPrefix} ${u}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#f55036",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Groq]"),this.errorPrefix=g.red.bold("[Groq]"),this.groq=new Kn({apiKey:this.params.config.GROQ_KEY})}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c={...W,locale:r,maxLength:i,type:o,generate:n,promptPath:s},d=`${re(c)}`,D=(await this.groq.chat.completions.create({messages:[{role:"system",content:d},{role:"user",content:`Here are diff: ${t}`}],model:this.params.config.GROQ_MODEL},{timeout:this.params.config.timeout})).choices[0].message.content||"";return u&&K("Groq",t,d,D),this.sanitizeMessage(D,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){throw t}}}class Gi extends U{constructor(t){super(t),this.params=t,this.headers={accept:"*/*","accept-language":"en-US,en;q=0.9","sec-ch-ua":'"Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"Windows"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin",origin:"https://huggingface.co","Referrer-Policy":"strict-origin-when-cross-origin"},this.models=[],this.currentModelId=null,this.currentConversation=void 0,this.currentConversionID=void 0,this.cookie="",this.colors={primary:"#FED21F",secondary:"#000"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[HuggingFace]"),this.errorPrefix=g.red.bold("[HuggingFace]"),this.cookie=this.params.config.HUGGINGFACE_COOKIE}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{await this.intialize();const t=this.getSystemPrompt(),r=await this.getNewChat(t),n=`Here are diff: ${this.params.stagedDiff.diff}`,s=await(await this.sendMessage(n,r.id)).completeResponsePromise(),{generate:u,logging:i}=this.params.config;return i&&K("HuggingFace",this.params.stagedDiff.diff,t,s),this.sanitizeMessage(s,this.params.config.type,u,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async intialize(){const t=await this.getRemoteLlms(),r=t.find(n=>n.name?.toLowerCase()===this.params.config.HUGGINGFACE_MODEL.toLowerCase());if(r){this.currentModel=r,this.currentModelId=r.id;return}this.currentModel=t[0],this.currentModelId=t[0].id}async getRemoteLlms(){const t=await fetch("https://huggingface.co/chat/__data.json",{headers:{...this.headers,cookie:this.cookie},body:null,method:"GET"});if(t.status!==200)throw new Error(`Failed to get remote LLMs with status code: ${t.status}`);const n=(await t.json()).nodes[0].data,o=n[n[0].models],s=[],u=i=>i===-1?null:n[i];for(const i of o){const c=n[i];if(n[c.unlisted])continue;const l={id:u(c.id),name:u(c.name),displayName:u(c.displayName),preprompt:u(c.preprompt),promptExamples:[],websiteUrl:u(c.websiteUrl),description:u(c.description),datasetName:u(c.datasetName),datasetUrl:u(c.datasetUrl),modelUrl:u(c.modelUrl),parameters:{}},d=u(c.promptExamples);if(d!==null){const p=d.map(f=>u(f));l.promptExamples=p.map(f=>({title:n[f.title],prompt:n[f.prompt]}))}const a=u(c.parameters),D={};for(const[p,f]of Object.entries(a)){if(f===-1){D[p]=null;continue}if(Array.isArray(n[f])){D[p]=n[f].map(h=>n[h]);continue}D[p]=n[f]}l.parameters=D,s.push(l)}return this.models=s,s}async getNewChat(t){const r={model:this.currentModelId,preprompt:t};let n=0;for(;n<5;){const o=await fetch("https://huggingface.co/chat/conversation",{headers:{...this.headers,"content-type":"application/json",cookie:this.cookie,Referer:"https://huggingface.co/chat/"},body:JSON.stringify(r),method:"POST"}),{conversationId:s}=await o.json();if(s){this.currentConversionID=s;break}else n++}if(!this.currentConversionID)throw new Error("Failed to create new conversion");return await this.getConversationHistory(this.currentConversionID)}async getConversationHistory(t){if(!t)throw new Error("conversationId is required for getConversationHistory");const r=await fetch("https://huggingface.co/chat/conversation/"+t+"/__data.json",{headers:{...this.headers,cookie:this.cookie,Referer:"https://huggingface.co/chat/"},body:null,method:"GET"});if(r.status!=200)throw new Error("Unable get conversation details "+r);{const n=await r.json();return this.metadataParser(n,t)}}metadataParser(t,r){const n={id:"",model:"",systemPrompt:"",title:"",history:[]},o=t.nodes[1].data,s=o[o[0].model],u=o[o[0].preprompt],i=o[o[0].title],c=o[o[0].messages],l=[];for(const d of c){const a=o[d],D=new Date(o[a.createdAt][1]).getTime()/1e3,p=new Date(o[a.updatedAt][1]).getTime()/1e3;l.push({id:o[a.id],role:o[a.from],content:o[a.content],createdAt:D,updatedAt:p})}return n.id=r,n.model=s,n.systemPrompt=u,n.title=i,n.history=l,this.currentConversation=n,n}async sendMessage(t,r){if(t==="")throw new Error("the prompt can not be empty.");if(!r&&!this.currentConversionID?await this.getNewChat():r?(this.currentConversionID=r,await this.getConversationHistory(r)):this.currentConversionID&&await this.getConversationHistory(this.currentConversionID),!this.currentConversation)throw new Error("Failed to create new conversion");const n={inputs:t,id:this.currentConversation.history[this.currentConversation.history.length-1].id,is_retry:!1,is_continue:!1,web_search:!1,tools:{}},o=new FormData;o.append("data",JSON.stringify(n));const s=await fetch("https://huggingface.co/chat/conversation/"+this.currentConversionID,{headers:{...this.headers,cookie:this.cookie,Referer:"https://huggingface.co/chat/conversation/"+this.currentConversionID},body:o,method:"POST"});function u(D){try{const p=D.split(`
73
+ `),f=[];for(const h of p)h.trim()&&f.push(JSON.parse(h));return f}catch{return[{}]}}const i=new TextDecoder;let c="";const l=new TransformStream({async transform(D,p){const f=i.decode(D);try{const h=u(f);for(const m of h)m.type==="finalAnswer"?(c=m?.text||"",p.terminate()):m.type==="stream"&&p.enqueue(m?.token||"")}catch{throw new Error("Error during parsing response")}}}),d=s.body?.pipeThrough(l);async function a(){return new Promise(async(D,p)=>{try{if(!d)p("ModifiedStream undefined");else{const f=d.getReader();for(;;){const{done:h,value:m}=await f.read();if(h){D(c);break}}}}catch(f){p(f)}})}return{id:this.currentConversionID,stream:d,completeResponsePromise:a}}async deleteConversation(t){return(await fetch(`https://huggingface.co/chat/conversation/${t}`,{headers:{...this.headers,cookie:this.cookie,Referer:"https://huggingface.co/chat/"},body:null,method:"DELETE"})).json()}getSystemPrompt(){const{locale:t,generate:r,type:n,promptPath:o}=this.params.config,s=this.params.config["max-length"],u={...W,locale:t,maxLength:s,type:n,generate:r,promptPath:o};return`${re(u)}`}}class Hi extends U{constructor(t){super(t),this.params=t,this.host="https://api.mistral.ai",this.apiKey="",this.handleError$=r=>{const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return O({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#ff7000",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[MistralAI]"),this.errorPrefix=g.red.bold("[MistralAI]"),this.apiKey=this.params.config.MISTRAL_KEY}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(r,t,n,i,o,s);await this.checkAvailableModels();const l=await this.createChatCompletions(c);return u&&K("MistralAI",t,c,l),this.sanitizeMessage(l,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async checkAvailableModels(){if((await this.getAvailableModels()).includes(this.params.config.MISTRAL_MODEL))return!0;throw new Error("Invalid model type of Mistral AI")}async getAvailableModels(){return(await new Se({method:"GET",baseURL:`${this.host}/v1/models`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).execute()).data.data.filter(r=>r.object==="model").map(r=>r.id)}async createChatCompletions(t){const n=(await new Se({method:"POST",baseURL:`${this.host}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.MISTRAL_MODEL,messages:[{role:"user",content:t}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config["max-tokens"],stream:!1,safe_prompt:!1,random_seed:Yr(10,1e3)}).execute()).data;if(!n.choices||n.choices.length===0||!n.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return n.choices[0].message.content}}const{hasOwnProperty:gt}=Object.prototype,Pe=typeof process<"u"&&process.platform==="win32"?`\r
86
74
  `:`
87
- `,gt=(e,t)=>{const r=[];let n="";typeof t=="string"?t={section:t,whitespace:!1}:(t=t||Object.create(null),t.whitespace=t.whitespace===!0);const o=t.whitespace?" = ":"=";for(const s of Object.keys(e)){const u=e[s];if(u&&Array.isArray(u))for(const i of u)n+=ne(s+"[]")+o+ne(i)+Ie;else u&&typeof u=="object"?r.push(s):n+=ne(s)+o+ne(u)+Ie}t.section&&n.length&&(n="["+ne(t.section)+"]"+Ie+n);for(const s of r){const u=Wr(s).join("\\."),i=(t.section?t.section+".":"")+u,{whitespace:c}=t,l=gt(e[s],{section:i,whitespace:c});n.length&&l.length&&(n+=Ie),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,"")),Jr=e=>{const t=Object.create(null);let r=t,n=null;const o=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,s=e.split(/[\r\n]+/g);for(const i of s){if(!i||i.match(/^\s*[;#]/))continue;const c=i.match(o);if(!c)continue;if(c[1]!==void 0){if(n=Pe(c[1]),n==="__proto__"){r=Object.create(null);continue}r=t[n]=t[n]||Object.create(null);continue}const l=Pe(c[2]),d=l.length>2&&l.slice(-2)==="[]",a=d?l.slice(0,-2):l;if(a==="__proto__")continue;const D=c[3]?Pe(c[4]):!0,p=D==="true"||D==="false"||D==="null"?JSON.parse(D):D;d&&(ht.call(r,a)?Array.isArray(r[a])||(r[a]=[r[a]]):r[a]=[]),Array.isArray(r[a])?r[a].push(p):r[a]=p}const u=[];for(const i of Object.keys(t)){if(!ht.call(t,i)||typeof t[i]!="object"||Array.isArray(t[i]))continue;const c=Wr(i);r=t;const l=c.pop(),d=l.replace(/\\\./g,".");for(const a of c)a!=="__proto__"&&((!ht.call(r,a)||typeof r[a]!="object")&&(r[a]=Object.create(null)),r=r[a]);r===t&&d===l||(r[d]=t[i],u.push(i))}for(const i of u)delete t[i];return t},Vr=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),ne=e=>typeof e!="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&Vr(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),Pe=(e,t)=>{if(e=(e||"").trim(),Vr(e)){e.charAt(0)==="'"&&(e=e.slice(1,-1));try{e=JSON.parse(e)}catch{}}else{let r=!1,n="";for(let o=0,s=e.length;o<s;o++){const u=e.charAt(o);if(r)"\\;#".indexOf(u)!==-1?n+=u:n+="\\"+u,r=!1;else{if(";#".indexOf(u)!==-1)break;u==="\\"?r=!0:n+=u}}return r&&(n+="\\"),n.trim()}return e};var Gi={parse:Jr,decode:Jr,stringify:gt,encode:gt,safe:ne,unsafe:Pe},Xr=J(Gi);const Qr=e=>x.lstat(e).then(()=>!0,()=>!1),Hi=["","conventional","gitmoji"],Ct="http://localhost:11434",{hasOwnProperty:Ui}=Object.prototype,Et=(e,t)=>Ui.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",Hi.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)):1024},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"},HUGGINGFACE_COOKIE(e){return e||""},HUGGINGFACE_MODEL(e){return!e||e.length===0?"CohereForAI/c4ai-command-r-plus":(E("HUGGINGFACE_MODEL",["CohereForAI/c4ai-command-r-plus","meta-llama/Meta-Llama-3-70B-Instruct","HuggingFaceH4/zephyr-orpo-141b-A35b-v0.1","mistralai/Mixtral-8x7B-Instruct-v0.1","NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO","01-ai/Yi-1.5-34B-Chat","mistralai/Mistral-7B-Instruct-v0.2","microsoft/Phi-3-mini-4k-instruct"].includes(e),"Invalid model type of HuggingFace chat"),e)},GEMINI_KEY(e){return e||""},GEMINI_MODEL(e){return!e||e.length===0?"gemini-1.5-pro-latest":(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):Ct},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=K.join(je.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 Et(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={},o={...Zr,...en};for(const s of Object.keys(o)){const u=o[s],i=e?.[s]??r[s];if(t)try{n[s]=u(i)}catch{}else n[s]=u(i)}return n},Ki=async e=>{const t=await tn(),r={...Zr,...en};for(const[n,o]of e){if(!Et(r,n))throw new y(`Invalid config property: ${n}`);const s=r[n](o);t[n]=s}await x.writeFile(Ft,Xr.stringify(t),"utf8")};class qi extends G{constructor(t){super(t),this.params=t,this.host=Ct,this.model="",this.handleError$=r=>{if(r.response&&r.response.data?.error)return O({name:`${this.errorPrefix} ${r.response.data?.error}`,value:r.response.data?.error,isError:!0,disabled:!0});const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return O({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#FFF",secondary:"#000"},this.model=this.params.keyName,this.serviceName=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||Ct,this.ollama=new Un({host:this.host})}generateCommitMessage$(){return k(this.generateMessage()).pipe(N(t=>S(t)),P(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),_(this.handleError$))}async generateMessage(){try{await this.checkIsAvailableOllama();const t=await this.createChatCompletions(),{type:r,generate:n,logging:o}=this.params.config,s=this.createSystemPrompt();return o&&H(`Ollama_${this.model}`,this.params.stagedDiff.diff,s,t),this.sanitizeMessage(t,r,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async checkIsAvailableOllama(){try{return(await new Se({method:"GET",baseURL:`${this.host}`,timeout:this.params.config.OLLAMA_TIMEOUT}).execute()).data}catch(t){throw t.code==="ECONNREFUSED"?new 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`${te(this.params.config.locale,this.params.config["max-length"],this.params.config.type,this.params.config.prompt)}
88
- ${re(this.params.config.generate,this.params.config.type)}`}}var bt={},At={exports:{}},fe={exports:{}},wt,rn;function zi(){if(rn)return wt;rn=1;var e=1e3,t=e*60,r=t*60,n=r*24,o=n*7,s=n*365.25;wt=function(d,a){a=a||{};var D=typeof d;if(D==="string"&&d.length>0)return u(d);if(D==="number"&&isFinite(d))return a.long?c(d):i(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))};function u(d){if(d=String(d),!(d.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(d);if(a){var D=parseFloat(a[1]),p=(a[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return D*s;case"weeks":case"week":case"w":return D*o;case"days":case"day":case"d":return D*n;case"hours":case"hour":case"hrs":case"hr":case"h":return D*r;case"minutes":case"minute":case"mins":case"min":case"m":return D*t;case"seconds":case"second":case"secs":case"sec":case"s":return D*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return D;default:return}}}}function i(d){var a=Math.abs(d);return a>=n?Math.round(d/n)+"d":a>=r?Math.round(d/r)+"h":a>=t?Math.round(d/t)+"m":a>=e?Math.round(d/e)+"s":d+"ms"}function c(d){var a=Math.abs(d);return a>=n?l(d,a,n,"day"):a>=r?l(d,a,r,"hour"):a>=t?l(d,a,t,"minute"):a>=e?l(d,a,e,"second"):d+" ms"}function l(d,a,D,p){var f=a>=D*1.5;return Math.round(d/D)+" "+p+(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=s,n.enabled=i,n.humanize=zi(),n.destroy=d,Object.keys(t).forEach(a=>{n[a]=t[a]}),n.names=[],n.skips=[],n.formatters={};function r(a){let D=0;for(let p=0;p<a.length;p++)D=(D<<5)-D+a.charCodeAt(p),D|=0;return n.colors[Math.abs(D)%n.colors.length]}n.selectColor=r;function n(a){let D,p=null,f,m;function h(...C){if(!h.enabled)return;const b=h,B=Number(new Date),L=B-(D||B);b.diff=L,b.prev=D,b.curr=B,D=B,C[0]=n.coerce(C[0]),typeof C[0]!="string"&&C.unshift("%O");let R=0;C[0]=C[0].replace(/%([a-zA-Z%])/g,(A,ue)=>{if(A==="%%")return"%";R++;const Rt=n.formatters[ue];if(typeof Rt=="function"){const bn=C[R];A=Rt.call(b,bn),C.splice(R,1),R--}return A}),n.formatArgs.call(b,C),(b.log||n.log).apply(b,C)}return h.namespace=a,h.useColors=n.useColors(),h.color=n.selectColor(a),h.extend=o,h.destroy=n.destroy,Object.defineProperty(h,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(f!==n.namespaces&&(f=n.namespaces,m=n.enabled(a)),m),set:C=>{p=C}}),typeof n.init=="function"&&n.init(h),h}function o(a,D){const p=n(this.namespace+(typeof D>"u"?":":D)+a);return p.log=this.log,p}function s(a){n.save(a),n.namespaces=a,n.names=[],n.skips=[];let D;const p=(typeof a=="string"?a:"").split(/[\s,]+/),f=p.length;for(D=0;D<f;D++)p[D]&&(a=p[D].replace(/\*/g,".*?"),a[0]==="-"?n.skips.push(new RegExp("^"+a.slice(1)+"$")):n.names.push(new RegExp("^"+a+"$")))}function u(){const a=[...n.names.map(c),...n.skips.map(c).map(D=>"-"+D)].join(",");return n.enable(""),a}function i(a){if(a[a.length-1]==="*")return!0;let D,p;for(D=0,p=n.skips.length;D<p;D++)if(n.skips[D].test(a))return!1;for(D=0,p=n.names.length;D<p;D++)if(n.names[D].test(a))return!0;return!1}function c(a){return a.toString().substring(2,a.toString().length-2).replace(/\.\*\?$/,"*")}function l(a){return a instanceof Error?a.stack||a.message:a}function d(){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}fe.exports;var sn;function Yi(){return sn||(sn=1,function(e,t){t.formatArgs=n,t.save=o,t.load=s,t.useColors=r,t.storage=u(),t.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;c.splice(1,0,l,"color: inherit");let d=0,a=0;c[0].replace(/%[a-zA-Z%]/g,D=>{D!=="%%"&&(d++,D==="%c"&&(a=d))}),c.splice(a,0,l)}t.log=console.debug||console.log||(()=>{});function o(c){try{c?t.storage.setItem("debug",c):t.storage.removeItem("debug")}catch{}}function s(){let c;try{c=t.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c}function u(){try{return localStorage}catch{}}e.exports=on()(t);const{formatters:i}=e.exports;i.j=function(c){try{return JSON.stringify(c)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(fe,fe.exports)),fe.exports}var me={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),o=t.indexOf("--");return n!==-1&&(o===-1||n<o)}),$t}var Bt,an;function Ji(){if(an)return Bt;an=1;const e=je,t=Le,r=Wi(),{env:n}=process;let o;r("no-color")||r("no-colors")||r("color=false")||r("color=never")?o=0:(r("color")||r("colors")||r("color=true")||r("color=always"))&&(o=1),"FORCE_COLOR"in n&&(n.FORCE_COLOR==="true"?o=1:n.FORCE_COLOR==="false"?o=0:o=n.FORCE_COLOR.length===0?1:Math.min(parseInt(n.FORCE_COLOR,10),3));function s(c){return c===0?!1:{level:c,hasBasic:!0,has256:c>=2,has16m:c>=3}}function u(c,l){if(o===0)return 0;if(r("color=16m")||r("color=full")||r("color=truecolor"))return 3;if(r("color=256"))return 2;if(c&&!l&&o===void 0)return 0;const d=o||0;if(n.TERM==="dumb")return d;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:d;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:d}function i(c){const l=u(c,c&&c.isTTY);return s(l)}return Bt={supportsColor:i,stdout:s(u(!0,t.isatty(1))),stderr:s(u(!0,t.isatty(2)))},Bt}me.exports;var cn;function Vi(){return cn||(cn=1,function(e,t){const r=Le,n=Ut;t.init=d,t.log=i,t.formatArgs=s,t.save=c,t.load=l,t.useColors=o,t.destroy=n.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const D=Ji();D&&(D.stderr||D).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}t.inspectOpts=Object.keys(process.env).filter(D=>/^debug_/i.test(D)).reduce((D,p)=>{const f=p.substring(6).toLowerCase().replace(/_([a-z])/g,(h,C)=>C.toUpperCase());let m=process.env[p];return/^(yes|on|true|enabled)$/i.test(m)?m=!0:/^(no|off|false|disabled)$/i.test(m)?m=!1:m==="null"?m=null:m=Number(m),D[f]=m,D},{});function o(){return"colors"in t.inspectOpts?!!t.inspectOpts.colors:r.isatty(process.stderr.fd)}function s(D){const{namespace:p,useColors:f}=this;if(f){const m=this.color,h="\x1B[3"+(m<8?m:"8;5;"+m),C=` ${h};1m${p} \x1B[0m`;D[0]=C+D[0].split(`
75
+ `,Ct=(e,t)=>{const r=[];let n="";typeof t=="string"?t={section:t,whitespace:!1}:(t=t||Object.create(null),t.whitespace=t.whitespace===!0);const o=t.whitespace?" = ":"=";for(const s of Object.keys(e)){const u=e[s];if(u&&Array.isArray(u))for(const i of u)n+=ne(s+"[]")+o+ne(i)+Pe;else u&&typeof u=="object"?r.push(s):n+=ne(s)+o+ne(u)+Pe}t.section&&n.length&&(n="["+ne(t.section)+"]"+Pe+n);for(const s of r){const u=Vr(s).join("\\."),i=(t.section?t.section+".":"")+u,{whitespace:c}=t,l=Ct(e[s],{section:i,whitespace:c});n.length&&l.length&&(n+=Pe),n+=l}return n},Vr=e=>e.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(t=>t.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),Xr=e=>{const t=Object.create(null);let r=t,n=null;const o=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,s=e.split(/[\r\n]+/g);for(const i of s){if(!i||i.match(/^\s*[;#]/))continue;const c=i.match(o);if(!c)continue;if(c[1]!==void 0){if(n=Ie(c[1]),n==="__proto__"){r=Object.create(null);continue}r=t[n]=t[n]||Object.create(null);continue}const l=Ie(c[2]),d=l.length>2&&l.slice(-2)==="[]",a=d?l.slice(0,-2):l;if(a==="__proto__")continue;const D=c[3]?Ie(c[4]):!0,p=D==="true"||D==="false"||D==="null"?JSON.parse(D):D;d&&(gt.call(r,a)?Array.isArray(r[a])||(r[a]=[r[a]]):r[a]=[]),Array.isArray(r[a])?r[a].push(p):r[a]=p}const u=[];for(const i of Object.keys(t)){if(!gt.call(t,i)||typeof t[i]!="object"||Array.isArray(t[i]))continue;const c=Vr(i);r=t;const l=c.pop(),d=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&&d===l||(r[d]=t[i],u.push(i))}for(const i of u)delete t[i];return t},Qr=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),ne=e=>typeof e!="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&Qr(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),Ie=(e,t)=>{if(e=(e||"").trim(),Qr(e)){e.charAt(0)==="'"&&(e=e.slice(1,-1));try{e=JSON.parse(e)}catch{}}else{let r=!1,n="";for(let o=0,s=e.length;o<s;o++){const u=e.charAt(o);if(r)"\\;#".indexOf(u)!==-1?n+=u:n+="\\"+u,r=!1;else{if(";#".indexOf(u)!==-1)break;u==="\\"?r=!0:n+=u}}return r&&(n+="\\"),n.trim()}return e};var Ui={parse:Xr,decode:Xr,stringify:Ct,encode:Ct,safe:ne,unsafe:Ie},Zr=V(Ui);const en=e=>x.lstat(e).then(()=>!0,()=>!1),Ki=["","conventional","gitmoji"],Et="http://localhost:11434",{hasOwnProperty:qi}=Object.prototype,Ft=(e,t)=>qi.call(e,t),C=(e,t,r)=>{if(!t)throw new F(`Invalid config property ${e}: ${r}`)},tn={confirm(e){return e?typeof e=="boolean"?e:(C("confirm",/^(?:true|false)$/.test(e),"Must be a boolean"),e==="true"):!1},promptPath(e){return e||""},locale(e){return e?(C("locale",e,"Cannot be empty"),C("locale",/^[a-z-]+$/i.test(e),"Must be a valid locale (letters and dashes/underscores). You can consult the list of codes in: https://wikipedia.org/wiki/List_of_ISO_639-1_codes"),e):"en"},generate(e){if(!e)return 1;C("generate",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return C("generate",t>0,"Must be greater than 0"),C("generate",t<=5,"Must be less or equal to 5"),t},type(e){return e?(C("type",Ki.includes(e),"Invalid commit type"),e):"conventional"},proxy(e){if(!(!e||e.length===0))return C("proxy",/^https?:\/\//.test(e),"Must be a valid URL"),e},timeout(e){if(!e)return 1e4;C("timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return C("timeout",t>=500,"Must be greater than 500ms"),t},temperature(e){if(!e)return .7;C("temperature",/^(2|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 2");const t=Number(e);return C("temperature",t>0,"Must be greater than 0"),C("temperature",t<=2,"Must be less than or equal to 2"),t},"max-length"(e){if(!e)return 50;C("max-length",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return C("max-length",t>=20,"Must be greater than 20 characters"),t},"max-tokens"(e){return e?(C("max-tokens",/^\d+$/.test(e),"Must be an integer"),Number(e)):1024},logging(e){return e?typeof e=="boolean"?e:(C("logging",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"):!1},ignoreBody(e){return e?typeof e=="boolean"?e:(C("ignoreBody",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"):!1}},rn={OPENAI_KEY(e){return e||""},OPENAI_MODEL(e){return!e||e.length===0?"gpt-3.5-turbo":e},OPENAI_URL(e){return e?(C("OPENAI_URL",/^https?:\/\//.test(e),"Must be a valid URL"),e):"https://api.openai.com"},OPENAI_PATH(e){return e||"/v1/chat/completions"},HUGGINGFACE_COOKIE(e){return e||""},HUGGINGFACE_MODEL(e){return!e||e.length===0?"CohereForAI/c4ai-command-r-plus":(C("HUGGINGFACE_MODEL",["CohereForAI/c4ai-command-r-plus","meta-llama/Meta-Llama-3-70B-Instruct","HuggingFaceH4/zephyr-orpo-141b-A35b-v0.1","mistralai/Mixtral-8x7B-Instruct-v0.1","NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO","01-ai/Yi-1.5-34B-Chat","mistralai/Mistral-7B-Instruct-v0.2","microsoft/Phi-3-mini-4k-instruct"].includes(e),"Invalid model type of HuggingFace chat"),e)},GEMINI_KEY(e){return e||""},GEMINI_MODEL(e){return!e||e.length===0?"gemini-1.5-pro-latest":(C("GEMINI_MODEL",["gemini-1.5-flash-latest","gemini-1.5-pro-latest"].includes(e),"Invalid model type of Gemini"),e)},ANTHROPIC_MODEL(e){return!e||e.length===0?"claude-3-haiku-20240307":(C("ANTHROPIC_MODEL",["claude-2.1","claude-2.0","claude-instant-1.2","claude-3-haiku-20240307","claude-3-sonnet-20240229","claude-3-opus-20240229"].includes(e),"Invalid model type of Anthropic"),e)},ANTHROPIC_KEY(e){return e||""},MISTRAL_KEY(e){return e||""},MISTRAL_MODEL(e){return!e||e.length===0?"mistral-tiny":(C("MISTRAL_MODEL",["open-mistral-7b","mistral-tiny-2312","mistral-tiny","open-mixtral-8x7b","mistral-small-2312","mistral-small","mistral-small-2402","mistral-small-latest","mistral-medium-latest","mistral-medium-2312","mistral-medium","mistral-large-latest","mistral-large-2402","mistral-embed"].includes(e),"Invalid model type of Mistral AI"),e)},CODESTRAL_KEY(e){return e||""},CODESTRAL_MODEL(e){return!e||e.length===0?"codestral-latest":(C("CODESTRAL_MODEL",["codestral-latest","codestral-2405"].includes(e),"Invalid model type of Codestral"),e)},OLLAMA_MODEL(e){return e?(typeof e=="string"?e?.split(","):e).map(r=>r.trim()).filter(r=>!!r&&r.length>0):[]},OLLAMA_HOST(e){return e?(C("OLLAMA_HOST",/^https?:\/\//.test(e),"Must be a valid URL"),e):Et},OLLAMA_TIMEOUT(e){if(!e)return 1e5;C("OLLAMA_TIMEOUT",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return C("OLLAMA_TIMEOUT",t>=500,"Must be greater than 500ms"),t},OLLAMA_STREAM(e){return e?typeof e=="boolean"?e:(C("OLLAMA_STREAM",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"):!1},COHERE_KEY(e){return e||""},COHERE_MODEL(e){return!e||e.length===0?"command":(C("COHERE_MODEL",["command","command-nightly","command-light","command-light-nightly"].includes(e),"Invalid model type of Cohere"),e)},GROQ_KEY(e){return e||""},GROQ_MODEL(e){return!e||e.length===0?"gemma-7b-it":(C("GROQ_MODEL",["llama3-8b-8192","llama3-70b-8192","mixtral-8x7b-32768","gemma-7b-it"].includes(e),"Invalid model type of Groq"),e)}},yt=P.join(je.homedir(),".aicommit2"),nn=async()=>{if(!await en(yt))return Object.create(null);const t=await x.readFile(yt,"utf8");let r=Zr.parse(t);return Ft(r,"OLLAMA_MODEL")&&(r={...r,OLLAMA_MODEL:typeof r.OLLAMA_MODEL=="string"?[r.OLLAMA_MODEL]:r.OLLAMA_MODEL}),r},bt=async(e,t)=>{const r=await nn(),n={},o={...tn,...rn};for(const s of Object.keys(o)){const u=o[s],i=e?.[s]??r[s];if(t)try{n[s]=u(i)}catch{}else n[s]=u(i)}return n},zi=async e=>{const t=await nn(),r={...tn,...rn};for(const[n,o]of e){if(!Ft(r,n))throw new F(`Invalid config property: ${n}`);const s=r[n](o);t[n]=s}await x.writeFile(yt,Zr.stringify(t),"utf8")};class Yi 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 O({name:`${this.errorPrefix} ${r.response.data?.error}`,value:r.response.data?.error,isError:!0,disabled:!0});const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return O({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#FFF",secondary:"#000"},this.model=this.params.keyName,this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[${zr(this.model)}]`),this.errorPrefix=g.red.bold(`[${zr(this.model)}]`),this.host=this.params.config.OLLAMA_HOST||Et,this.ollama=new qn({host:this.host})}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{await this.checkIsAvailableOllama();const t=await this.createChatCompletions(),{type:r,generate:n,logging:o}=this.params.config,s=this.createSystemPrompt();return o&&K(`Ollama_${this.model}`,this.params.stagedDiff.diff,s,t),this.sanitizeMessage(t,r,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async checkIsAvailableOllama(){try{return(await new Se({method:"GET",baseURL:`${this.host}`,timeout:this.params.config.OLLAMA_TIMEOUT}).execute()).data}catch(t){throw t.code==="ECONNREFUSED"?new F(`Error connecting to ${this.host}. Please run Ollama or check host`):t}}async createChatCompletions(){const t=this.createSystemPrompt();return(await this.ollama.chat({model:this.model,messages:[{role:"system",content:t},{role:"user",content:`Here are diff: ${this.params.stagedDiff.diff}`}],stream:!1,options:{temperature:this.params.config.temperature}})).message.content}createSystemPrompt(){const t={...W,locale:this.params.config.locale,maxLength:this.params.config["max-length"],type:this.params.config.type,generate:this.params.config.generate,promptPath:this.params.config.promptPath};return`${re(t)}`}}var At={},wt={exports:{}},fe={exports:{}},vt,on;function Wi(){if(on)return vt;on=1;var e=1e3,t=e*60,r=t*60,n=r*24,o=n*7,s=n*365.25;vt=function(d,a){a=a||{};var D=typeof d;if(D==="string"&&d.length>0)return u(d);if(D==="number"&&isFinite(d))return a.long?c(d):i(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))};function u(d){if(d=String(d),!(d.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(d);if(a){var D=parseFloat(a[1]),p=(a[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return D*s;case"weeks":case"week":case"w":return D*o;case"days":case"day":case"d":return D*n;case"hours":case"hour":case"hrs":case"hr":case"h":return D*r;case"minutes":case"minute":case"mins":case"min":case"m":return D*t;case"seconds":case"second":case"secs":case"sec":case"s":return D*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return D;default:return}}}}function i(d){var a=Math.abs(d);return a>=n?Math.round(d/n)+"d":a>=r?Math.round(d/r)+"h":a>=t?Math.round(d/t)+"m":a>=e?Math.round(d/e)+"s":d+"ms"}function c(d){var a=Math.abs(d);return a>=n?l(d,a,n,"day"):a>=r?l(d,a,r,"hour"):a>=t?l(d,a,t,"minute"):a>=e?l(d,a,e,"second"):d+" ms"}function l(d,a,D,p){var f=a>=D*1.5;return Math.round(d/D)+" "+p+(f?"s":"")}return vt}var $t,sn;function un(){if(sn)return $t;sn=1;function e(t){n.debug=n,n.default=n,n.coerce=l,n.disable=u,n.enable=s,n.enabled=i,n.humanize=Wi(),n.destroy=d,Object.keys(t).forEach(a=>{n[a]=t[a]}),n.names=[],n.skips=[],n.formatters={};function r(a){let D=0;for(let p=0;p<a.length;p++)D=(D<<5)-D+a.charCodeAt(p),D|=0;return n.colors[Math.abs(D)%n.colors.length]}n.selectColor=r;function n(a){let D,p=null,f,h;function m(...E){if(!m.enabled)return;const b=m,w=Number(new Date),R=w-(D||w);b.diff=R,b.prev=D,b.curr=w,D=w,E[0]=n.coerce(E[0]),typeof E[0]!="string"&&E.unshift("%O");let N=0;E[0]=E[0].replace(/%([a-zA-Z%])/g,(A,ue)=>{if(A==="%%")return"%";N++;const Nt=n.formatters[ue];if(typeof Nt=="function"){const wn=E[N];A=Nt.call(b,wn),E.splice(N,1),N--}return A}),n.formatArgs.call(b,E),(b.log||n.log).apply(b,E)}return m.namespace=a,m.useColors=n.useColors(),m.color=n.selectColor(a),m.extend=o,m.destroy=n.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(f!==n.namespaces&&(f=n.namespaces,h=n.enabled(a)),h),set:E=>{p=E}}),typeof n.init=="function"&&n.init(m),m}function o(a,D){const p=n(this.namespace+(typeof D>"u"?":":D)+a);return p.log=this.log,p}function s(a){n.save(a),n.namespaces=a,n.names=[],n.skips=[];let D;const p=(typeof a=="string"?a:"").split(/[\s,]+/),f=p.length;for(D=0;D<f;D++)p[D]&&(a=p[D].replace(/\*/g,".*?"),a[0]==="-"?n.skips.push(new RegExp("^"+a.slice(1)+"$")):n.names.push(new RegExp("^"+a+"$")))}function u(){const a=[...n.names.map(c),...n.skips.map(c).map(D=>"-"+D)].join(",");return n.enable(""),a}function i(a){if(a[a.length-1]==="*")return!0;let D,p;for(D=0,p=n.skips.length;D<p;D++)if(n.skips[D].test(a))return!1;for(D=0,p=n.names.length;D<p;D++)if(n.names[D].test(a))return!0;return!1}function c(a){return a.toString().substring(2,a.toString().length-2).replace(/\.\*\?$/,"*")}function l(a){return a instanceof Error?a.stack||a.message:a}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}return $t=e,$t}fe.exports;var an;function Ji(){return an||(an=1,function(e,t){t.formatArgs=n,t.save=o,t.load=s,t.useColors=r,t.storage=u(),t.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;c.splice(1,0,l,"color: inherit");let d=0,a=0;c[0].replace(/%[a-zA-Z%]/g,D=>{D!=="%%"&&(d++,D==="%c"&&(a=d))}),c.splice(a,0,l)}t.log=console.debug||console.log||(()=>{});function o(c){try{c?t.storage.setItem("debug",c):t.storage.removeItem("debug")}catch{}}function s(){let c;try{c=t.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c}function u(){try{return localStorage}catch{}}e.exports=un()(t);const{formatters:i}=e.exports;i.j=function(c){try{return JSON.stringify(c)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(fe,fe.exports)),fe.exports}var me={exports:{}},Bt,cn;function Vi(){return cn||(cn=1,Bt=(e,t=process.argv)=>{const r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),o=t.indexOf("--");return n!==-1&&(o===-1||n<o)}),Bt}var xt,Dn;function Xi(){if(Dn)return xt;Dn=1;const e=je,t=Le,r=Vi(),{env:n}=process;let o;r("no-color")||r("no-colors")||r("color=false")||r("color=never")?o=0:(r("color")||r("colors")||r("color=true")||r("color=always"))&&(o=1),"FORCE_COLOR"in n&&(n.FORCE_COLOR==="true"?o=1:n.FORCE_COLOR==="false"?o=0:o=n.FORCE_COLOR.length===0?1:Math.min(parseInt(n.FORCE_COLOR,10),3));function s(c){return c===0?!1:{level:c,hasBasic:!0,has256:c>=2,has16m:c>=3}}function u(c,l){if(o===0)return 0;if(r("color=16m")||r("color=full")||r("color=truecolor"))return 3;if(r("color=256"))return 2;if(c&&!l&&o===void 0)return 0;const d=o||0;if(n.TERM==="dumb")return d;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:d;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:d}function i(c){const l=u(c,c&&c.isTTY);return s(l)}return xt={supportsColor:i,stdout:s(u(!0,t.isatty(1))),stderr:s(u(!0,t.isatty(2)))},xt}me.exports;var ln;function Qi(){return ln||(ln=1,function(e,t){const r=Le,n=Kt;t.init=d,t.log=i,t.formatArgs=s,t.save=c,t.load=l,t.useColors=o,t.destroy=n.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const D=Xi();D&&(D.stderr||D).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}t.inspectOpts=Object.keys(process.env).filter(D=>/^debug_/i.test(D)).reduce((D,p)=>{const f=p.substring(6).toLowerCase().replace(/_([a-z])/g,(m,E)=>E.toUpperCase());let h=process.env[p];return/^(yes|on|true|enabled)$/i.test(h)?h=!0:/^(no|off|false|disabled)$/i.test(h)?h=!1:h==="null"?h=null:h=Number(h),D[f]=h,D},{});function o(){return"colors"in t.inspectOpts?!!t.inspectOpts.colors:r.isatty(process.stderr.fd)}function s(D){const{namespace:p,useColors:f}=this;if(f){const h=this.color,m="\x1B[3"+(h<8?h:"8;5;"+h),E=` ${m};1m${p} \x1B[0m`;D[0]=E+D[0].split(`
89
76
  `).join(`
90
- `+C),D.push(h+"m+"+e.exports.humanize(this.diff)+"\x1B[0m")}else D[0]=u()+p+" "+D[0]}function u(){return t.inspectOpts.hideDate?"":new Date().toISOString()+" "}function i(...D){return process.stderr.write(n.formatWithOptions(t.inspectOpts,...D)+`
91
- `)}function c(D){D?process.env.DEBUG=D:delete process.env.DEBUG}function l(){return process.env.DEBUG}function d(D){D.inspectOpts={};const p=Object.keys(t.inspectOpts);for(let f=0;f<p.length;f++)D.inspectOpts[p[f]]=t.inspectOpts[p[f]]}e.exports=on()(t);const{formatters:a}=e.exports;a.o=function(D){return this.inspectOpts.colors=this.useColors,n.inspect(D,this.inspectOpts).split(`
92
- `).map(p=>p.trim()).join(" ")},a.O=function(D){return this.inspectOpts.colors=this.useColors,n.inspect(D,this.inspectOpts)}}(me,me.exports)),me.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?At.exports=Yi():At.exports=Vi();var xt=At.exports,Ot={};Object.defineProperty(Ot,"__esModule",{value:!0});function Xi(e){return function(t,r){return new Promise((n,o)=>{e.call(this,t,r,(s,u)=>{s?o(s):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),he=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(`
93
- `).some(t=>t.indexOf("(https.js:")!==-1||t.indexOf("node:https:")!==-1)}function _e(e,t){return new _e.Agent(e,t)}(function(e){class t extends Qi.EventEmitter{constructor(n,o){super();let s=o;typeof n=="function"?this.callback=n:n&&(s=n),this.timeout=null,s&&typeof s.timeout=="number"&&(this.timeout=s.timeout),this.maxFreeSockets=1,this.maxSockets=1,this.maxTotalSockets=1/0,this.sockets={},this.freeSockets={},this.requests={},this.options={}}get defaultPort(){return typeof this.explicitDefaultPort=="number"?this.explicitDefaultPort:Mt()?443:80}set defaultPort(n){this.explicitDefaultPort=n}get protocol(){return typeof this.explicitProtocol=="string"?this.explicitProtocol:Mt()?"https:":"http:"}set protocol(n){this.explicitProtocol=n}callback(n,o,s){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(n,o){const s=Object.assign({},o);typeof s.secureEndpoint!="boolean"&&(s.secureEndpoint=Mt()),s.host==null&&(s.host="localhost"),s.port==null&&(s.port=s.secureEndpoint?443:80),s.protocol==null&&(s.protocol=s.secureEndpoint?"https:":"http:"),s.host&&s.path&&delete s.path,delete s.agent,delete s.hostname,delete s._defaultAgent,delete s.defaultPort,delete s.createConnection,n._last=!0,n.shouldKeepAlive=!1;let u=!1,i=null;const c=s.timeout||this.timeout,l=p=>{n._hadError||(n.emit("error",p),n._hadError=!0)},d=()=>{i=null,u=!0;const p=new Error(`A "socket" was not created for HTTP request before ${c}ms`);p.code="ETIMEOUT",l(p)},a=p=>{u||(i!==null&&(clearTimeout(i),i=null),l(p))},D=p=>{if(u)return;if(i!=null&&(clearTimeout(i),i=null),ta(p)){he("Callback returned another Agent instance %o",p.constructor.name),p.addRequest(n,s);return}if(p){p.once("free",()=>{this.freeSocket(p,s)}),n.onSocket(p);return}const f=new Error(`no Duplex stream was returned to agent-base for \`${n.method} ${n.path}\``);l(f)};if(typeof this.callback!="function"){l(new Error("`callback` is not defined"));return}this.promisifiedCallback||(this.callback.length>=3?(he("Converting legacy callback function to promise"),this.promisifiedCallback=ea.default(this.callback)):this.promisifiedCallback=this.callback),typeof c=="number"&&c>0&&(i=setTimeout(d,c)),"port"in s&&typeof s.port!="number"&&(s.port=Number(s.port));try{he("Resolving socket for %o request: %o",s.protocol,`${n.method} ${n.path}`),Promise.resolve(this.promisifiedCallback(n,s)).then(D,a)}catch(p){Promise.reject(p).catch(a)}}freeSocket(n,o){he("Freeing socket %o %o",n.constructor.name,o),n.destroy()}destroy(){he("Destroying agent %o",this.constructor.name)}}e.Agent=t,e.prototype=e.Agent.prototype})(_e||(_e={}));var ra=_e,St={},na=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(St,"__esModule",{value:!0});const oa=na(xt),ge=oa.default("https-proxy-agent:parse-proxy-response");function sa(e){return new Promise((t,r)=>{let n=0;const o=[];function s(){const a=e.read();a?d(a):e.once("readable",s)}function u(){e.removeListener("end",c),e.removeListener("error",l),e.removeListener("close",i),e.removeListener("readable",s)}function i(a){ge("onclose had error %o",a)}function c(){ge("onend")}function l(a){u(),ge("onerror %o",a),r(a)}function d(a){o.push(a),n+=a.length;const D=Buffer.concat(o,n);if(D.indexOf(`\r
77
+ `+E),D.push(m+"m+"+e.exports.humanize(this.diff)+"\x1B[0m")}else D[0]=u()+p+" "+D[0]}function u(){return t.inspectOpts.hideDate?"":new Date().toISOString()+" "}function i(...D){return process.stderr.write(n.formatWithOptions(t.inspectOpts,...D)+`
78
+ `)}function c(D){D?process.env.DEBUG=D:delete process.env.DEBUG}function l(){return process.env.DEBUG}function d(D){D.inspectOpts={};const p=Object.keys(t.inspectOpts);for(let f=0;f<p.length;f++)D.inspectOpts[p[f]]=t.inspectOpts[p[f]]}e.exports=un()(t);const{formatters:a}=e.exports;a.o=function(D){return this.inspectOpts.colors=this.useColors,n.inspect(D,this.inspectOpts).split(`
79
+ `).map(p=>p.trim()).join(" ")},a.O=function(D){return this.inspectOpts.colors=this.useColors,n.inspect(D,this.inspectOpts)}}(me,me.exports)),me.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?wt.exports=Ji():wt.exports=Qi();var Ot=wt.exports,Mt={};Object.defineProperty(Mt,"__esModule",{value:!0});function Zi(e){return function(t,r){return new Promise((n,o)=>{e.call(this,t,r,(s,u)=>{s?o(s):n(u)})})}}Mt.default=Zi;var dn=v&&v.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const ea=Ut,ta=dn(Ot),ra=dn(Mt),he=ta.default("agent-base");function na(e){return!!e&&typeof e.addRequest=="function"}function St(){const{stack:e}=new Error;return typeof e!="string"?!1:e.split(`
80
+ `).some(t=>t.indexOf("(https.js:")!==-1||t.indexOf("node:https:")!==-1)}function _e(e,t){return new _e.Agent(e,t)}(function(e){class t extends ea.EventEmitter{constructor(n,o){super();let s=o;typeof n=="function"?this.callback=n:n&&(s=n),this.timeout=null,s&&typeof s.timeout=="number"&&(this.timeout=s.timeout),this.maxFreeSockets=1,this.maxSockets=1,this.maxTotalSockets=1/0,this.sockets={},this.freeSockets={},this.requests={},this.options={}}get defaultPort(){return typeof this.explicitDefaultPort=="number"?this.explicitDefaultPort:St()?443:80}set defaultPort(n){this.explicitDefaultPort=n}get protocol(){return typeof this.explicitProtocol=="string"?this.explicitProtocol:St()?"https:":"http:"}set protocol(n){this.explicitProtocol=n}callback(n,o,s){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(n,o){const s=Object.assign({},o);typeof s.secureEndpoint!="boolean"&&(s.secureEndpoint=St()),s.host==null&&(s.host="localhost"),s.port==null&&(s.port=s.secureEndpoint?443:80),s.protocol==null&&(s.protocol=s.secureEndpoint?"https:":"http:"),s.host&&s.path&&delete s.path,delete s.agent,delete s.hostname,delete s._defaultAgent,delete s.defaultPort,delete s.createConnection,n._last=!0,n.shouldKeepAlive=!1;let u=!1,i=null;const c=s.timeout||this.timeout,l=p=>{n._hadError||(n.emit("error",p),n._hadError=!0)},d=()=>{i=null,u=!0;const p=new Error(`A "socket" was not created for HTTP request before ${c}ms`);p.code="ETIMEOUT",l(p)},a=p=>{u||(i!==null&&(clearTimeout(i),i=null),l(p))},D=p=>{if(u)return;if(i!=null&&(clearTimeout(i),i=null),na(p)){he("Callback returned another Agent instance %o",p.constructor.name),p.addRequest(n,s);return}if(p){p.once("free",()=>{this.freeSocket(p,s)}),n.onSocket(p);return}const f=new Error(`no Duplex stream was returned to agent-base for \`${n.method} ${n.path}\``);l(f)};if(typeof this.callback!="function"){l(new Error("`callback` is not defined"));return}this.promisifiedCallback||(this.callback.length>=3?(he("Converting legacy callback function to promise"),this.promisifiedCallback=ra.default(this.callback)):this.promisifiedCallback=this.callback),typeof c=="number"&&c>0&&(i=setTimeout(d,c)),"port"in s&&typeof s.port!="number"&&(s.port=Number(s.port));try{he("Resolving socket for %o request: %o",s.protocol,`${n.method} ${n.path}`),Promise.resolve(this.promisifiedCallback(n,s)).then(D,a)}catch(p){Promise.reject(p).catch(a)}}freeSocket(n,o){he("Freeing socket %o %o",n.constructor.name,o),n.destroy()}destroy(){he("Destroying agent %o",this.constructor.name)}}e.Agent=t,e.prototype=e.Agent.prototype})(_e||(_e={}));var oa=_e,Pt={},sa=v&&v.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Pt,"__esModule",{value:!0});const ua=sa(Ot),ge=ua.default("https-proxy-agent:parse-proxy-response");function ia(e){return new Promise((t,r)=>{let n=0;const o=[];function s(){const a=e.read();a?d(a):e.once("readable",s)}function u(){e.removeListener("end",c),e.removeListener("error",l),e.removeListener("close",i),e.removeListener("readable",s)}function i(a){ge("onclose had error %o",a)}function c(){ge("onend")}function l(a){u(),ge("onerror %o",a),r(a)}function d(a){o.push(a),n+=a.length;const D=Buffer.concat(o,n);if(D.indexOf(`\r
94
81
  \r
95
82
  `)===-1){ge("have not received end of HTTP headers yet..."),s();return}const f=D.toString("ascii",0,D.indexOf(`\r
96
- `)),m=+f.split(" ")[1];ge("got proxy server response: %o",f),t({statusCode:m,buffered:D})}e.on("error",l),e.on("close",i),e.on("end",c),s()})}St.default=sa;var ua=w&&w.__awaiter||function(e,t,r,n){function o(s){return s instanceof r?s:new r(function(u){u(s)})}return new(r||(r=Promise))(function(s,u){function i(d){try{l(n.next(d))}catch(a){u(a)}}function c(d){try{l(n.throw(d))}catch(a){u(a)}}function l(d){d.done?s(d.value):o(d.value).then(i,c)}l((n=n.apply(e,t||[])).next())})},oe=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(bt,"__esModule",{value:!0});const ln=oe(zn),dn=oe(Yn),ia=oe(Wn),aa=oe(Gt),ca=oe(xt),Da=ra,la=oe(St),Ce=ca.default("https-proxy-agent:agent");class da 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!");Ce("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:o}=this;let s;o?(Ce("Creating `tls.Socket`: %o",n),s=dn.default.connect(n)):(Ce("Creating `net.Socket`: %o",n),s=ln.default.connect(n));const u=Object.assign({},n.headers);let c=`CONNECT ${`${r.host}:${r.port}`} HTTP/1.1\r
97
- `;n.auth&&(u["Proxy-Authorization"]=`Basic ${Buffer.from(n.auth).toString("base64")}`);let{host:l,port:d,secureEndpoint:a}=r;fa(d,a)||(l+=`:${d}`),u.Host=l,u.Connection="close";for(const h of Object.keys(u))c+=`${h}: ${u[h]}\r
98
- `;const D=la.default(s);s.write(`${c}\r
99
- `);const{statusCode:p,buffered:f}=yield D;if(p===200){if(t.once("socket",pa),r.secureEndpoint){Ce("Upgrading socket connection to TLS");const h=r.servername||r.host;return dn.default.connect(Object.assign(Object.assign({},ha(r,"host","hostname","path","port")),{socket:s,servername:h}))}return s}s.destroy();const m=new ln.default.Socket({writable:!1});return m.readable=!0,t.once("socket",h=>{Ce("replaying proxy buffer for failed request"),aa.default(h.listenerCount("data")>0),h.push(f),h.push(null)}),m})}}bt.default=da;function pa(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,o,s,u)=>new Promise((i,c)=>{const l=JSON.stringify(n),a=(e.protocol.includes("https")?qn: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:o,agent:s?Ea(s):void 0},D=>{const p=[];D.on("data",f=>p.push(f)),D.on("end",()=>{i({request:a,response:D,data:Buffer.concat(p).toString()})})});a.on("error",c),a.on("timeout",()=>{a.destroy(),c(new y(`Time out error: request took over ${o}ms. Try increasing the \`timeout\` config`))}),a.write(l),a.end()}),ya=async(e,t,r,n,o,s)=>{const u=new URL(e),{response:i,data:c}=await Fa(u,t,{Authorization:`Bearer ${r}`},n,o,s);if(!i.statusCode||i.statusCode<200||i.statusCode>299){let l=`OpenAI API Error: ${i.statusCode} - ${i.statusMessage}`;throw c&&(l+=`
83
+ `)),h=+f.split(" ")[1];ge("got proxy server response: %o",f),t({statusCode:h,buffered:D})}e.on("error",l),e.on("close",i),e.on("end",c),s()})}Pt.default=ia;var aa=v&&v.__awaiter||function(e,t,r,n){function o(s){return s instanceof r?s:new r(function(u){u(s)})}return new(r||(r=Promise))(function(s,u){function i(d){try{l(n.next(d))}catch(a){u(a)}}function c(d){try{l(n.throw(d))}catch(a){u(a)}}function l(d){d.done?s(d.value):o(d.value).then(i,c)}l((n=n.apply(e,t||[])).next())})},oe=v&&v.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(At,"__esModule",{value:!0});const pn=oe(Wn),fn=oe(Jn),ca=oe(Vn),Da=oe(Ht),la=oe(Ot),da=oa,pa=oe(Pt),Ce=la.default("https-proxy-agent:agent");class fa extends da.Agent{constructor(t){let r;if(typeof t=="string"?r=ca.default.parse(t):r=t,!r)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");Ce("creating new HttpsProxyAgent instance: %o",r),super(r);const n=Object.assign({},r);this.secureProxy=r.secureProxy||ga(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 aa(this,void 0,void 0,function*(){const{proxy:n,secureProxy:o}=this;let s;o?(Ce("Creating `tls.Socket`: %o",n),s=fn.default.connect(n)):(Ce("Creating `net.Socket`: %o",n),s=pn.default.connect(n));const u=Object.assign({},n.headers);let c=`CONNECT ${`${r.host}:${r.port}`} HTTP/1.1\r
84
+ `;n.auth&&(u["Proxy-Authorization"]=`Basic ${Buffer.from(n.auth).toString("base64")}`);let{host:l,port:d,secureEndpoint:a}=r;ha(d,a)||(l+=`:${d}`),u.Host=l,u.Connection="close";for(const m of Object.keys(u))c+=`${m}: ${u[m]}\r
85
+ `;const D=pa.default(s);s.write(`${c}\r
86
+ `);const{statusCode:p,buffered:f}=yield D;if(p===200){if(t.once("socket",ma),r.secureEndpoint){Ce("Upgrading socket connection to TLS");const m=r.servername||r.host;return fn.default.connect(Object.assign(Object.assign({},Ca(r,"host","hostname","path","port")),{socket:s,servername:m}))}return s}s.destroy();const h=new pn.default.Socket({writable:!1});return h.readable=!0,t.once("socket",m=>{Ce("replaying proxy buffer for failed request"),Da.default(m.listenerCount("data")>0),m.push(f),m.push(null)}),h})}}At.default=fa;function ma(e){e.resume()}function ha(e,t){return!!(!t&&e===80||t&&e===443)}function ga(e){return typeof e=="string"?/^https:?$/i.test(e):!1}function Ca(e,...t){const r={};let n;for(n in e)t.includes(n)||(r[n]=e[n]);return r}var Ea=v&&v.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const It=Ea(At);function _t(e){return new It.default(e)}(function(e){e.HttpsProxyAgent=It.default,e.prototype=It.default.prototype})(_t||(_t={}));var Fa=_t,ya=V(Fa);const ba=async(e,t,r,n,o,s,u)=>new Promise((i,c)=>{const l=JSON.stringify(n),a=(e.protocol.includes("https")?Yn:zn).request({port:u||void 0,hostname:e.hostname,path:t,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(l),...r},timeout:o,agent:s?ya(s):void 0},D=>{const p=[];D.on("data",f=>p.push(f)),D.on("end",()=>{i({request:a,response:D,data:Buffer.concat(p).toString()})})});a.on("error",c),a.on("timeout",()=>{a.destroy(),c(new F(`Time out error: request took over ${o}ms. Try increasing the \`timeout\` config`))}),a.write(l),a.end()}),Aa=async(e,t,r,n,o,s)=>{const u=new URL(e),{response:i,data:c}=await ba(u,t,{Authorization:`Bearer ${r}`},n,o,s);if(!i.statusCode||i.statusCode<200||i.statusCode>299){let l=`OpenAI API Error: ${i.statusCode} - ${i.statusMessage}`;throw c&&(l+=`
100
87
 
101
88
  ${c}`),i.statusCode===500&&(l+=`
102
89
 
103
- 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,o,s,u,i,c,l,d,a,D,p,f)=>{try{const m=te(o,i,c,D),C=(await ya(e,t,r,{model:n,messages:[{role:"system",content:`${m}
104
- ${re(u,c)}`},{role:"user",content:`Here are diff: ${s}`}],temperature:a,top_p:1,frequency_penalty:0,presence_penalty:0,max_tokens:d,stream:!1},l,f)).choices.filter(b=>b.message?.content).map(b=>ba(b.message.content)).join();return p&&H("OPEN AI",s,m,C),C}catch(m){const h=m;throw h.code==="ENOTFOUND"?new y(`Error connecting to ${h.hostname} (${h.syscall})`):h}};class wa extends G{constructor(t){super(t),this.params=t,this.handleError$=r=>{let n="An error occurred";if(r.message){n=r.message.split(`
105
- `)[0];const o=this.extractJSONFromError(r.message);n+=`: ${o.error.message}`}return O({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#74AA9C",secondary:"#FFF"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[ChatGPT]"),this.errorPrefix=g.red.bold("[ChatGPT]")}generateCommitMessage$(){return k(this.generateMessage()).pipe(N(t=>S(t)),P(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),_(this.handleError$))}extractJSONFromError(t){const r=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,n=t.match(r);return n?Object.assign({},...n.map(o=>JSON.parse(o))):{error:{message:"Unknown error"}}}async generateMessage(){const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o}=this.params.config,s=this.params.config["max-length"],u=await Aa(this.params.config.OPENAI_URL,this.params.config.OPENAI_PATH,this.params.config.OPENAI_KEY,this.params.config.OPENAI_MODEL,r,t,n,s,o,this.params.config.timeout,this.params.config["max-tokens"],this.params.config.temperature,this.params.config.prompt,this.params.config.logging,this.params.config.proxy);return this.sanitizeMessage(u,this.params.config.type,n,this.params.config.ignoreBody)}}class pn{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 M.OPEN_AI:return j.create(wa,n).generateCommitMessage$();case M.GEMINI:return j.create(Ri,n).generateCommitMessage$();case M.ANTHROPIC:return j.create(_i,n).generateCommitMessage$();case M.HUGGINGFACE:return j.create(ki,n).generateCommitMessage$();case M.MISTRAL:return j.create(ji,n).generateCommitMessage$();case M.CODESTRAL:return j.create(Ti,n).generateCommitMessage$();case M.OLLAMA:return S(this.config.OLLAMA_MODEL).pipe(Kt(s=>{const u={...n,keyName:s};return j.create(qi,u).generateCommitMessage$()}));case M.COHERE:return j.create(Li,n).generateCommitMessage$();case M.GROQ:return j.create(Ni,n).generateCommitMessage$();default:const o=g.red.bold(`[${r}]`);return O({name:o+" Invalid AI type",value:"Invalid AI type",isError:!0,disabled:!0})}}),_(r=>{const n=g.red.bold("[UNKNOWN]");return O({name:n+` ${r.message||""}`,value:"Unknown error",isError:!0,disabled:!0})}))}}const fn=async()=>{const{stdout:e,failed:t}=await ee("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 ee("git",[...t,"--name-only",...mn,...e?e.map(_t):[]]);if(!r)return null;const{stdout:n}=await ee("git",[...t,...mn,...e?e.map(_t):[]]);return{files:r.split(`
106
- `),diff:n}},va=e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`;class Ee{constructor(){this.title="aicommit2"}printTitle(){console.log(Xn.textSync(this.title,{font:"Small"}))}displaySpinner(t){return ke(t).start()}stopSpinner(t){t.stop(),t.clear()}printStagedFiles(t){console.log(g.bold.green("\u2714 ")+g.bold(`${va(t.files)}:`)),console.log(`${t.files.map(r=>` ${r}`).join(`
90
+ Check the API status: https://status.openai.com`),new F(l)}return JSON.parse(c)},wa=e=>e.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1"),va=async(e,t,r,n,o,s,u,i,c,l,d,a,D,p,f)=>{try{const h={...W,locale:o,maxLength:i,type:c,generate:u,promptPath:D},m=re(h),b=(await Aa(e,t,r,{model:n,messages:[{role:"system",content:`${m}`},{role:"user",content:`Here are diff: ${s}`}],temperature:a,top_p:1,frequency_penalty:0,presence_penalty:0,max_tokens:d,stream:!1},l,f)).choices.filter(w=>w.message?.content).map(w=>wa(w.message.content)).join();return p&&K("OPEN AI",s,m,b),b}catch(h){const m=h;throw m.code==="ENOTFOUND"?new F(`Error connecting to ${m.hostname} (${m.syscall})`):m}};class $a extends U{constructor(t){super(t),this.params=t,this.handleError$=r=>{let n="An error occurred";if(r.message){n=r.message.split(`
91
+ `)[0];const o=this.extractJSONFromError(r.message);n+=`: ${o.error.message}`}return O({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#74AA9C",secondary:"#FFF"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[ChatGPT]"),this.errorPrefix=g.red.bold("[ChatGPT]")}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}extractJSONFromError(t){const r=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,n=t.match(r);return n?Object.assign({},...n.map(o=>JSON.parse(o))):{error:{message:"Unknown error"}}}async generateMessage(){const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o}=this.params.config,s=this.params.config["max-length"],u=await va(this.params.config.OPENAI_URL,this.params.config.OPENAI_PATH,this.params.config.OPENAI_KEY,this.params.config.OPENAI_MODEL,r,t,n,s,o,this.params.config.timeout,this.params.config["max-tokens"],this.params.config.temperature,this.params.config.prompt,this.params.config.logging,this.params.config.proxy);return this.sanitizeMessage(u,this.params.config.type,n,this.params.config.ignoreBody)}}class mn{constructor(t,r){this.config=t,this.stagedDiff=r}createAIRequests$(t){return S(t).pipe(qt(r=>{const n={config:this.config,stagedDiff:this.stagedDiff,keyName:r};switch(r){case M.OPEN_AI:return H.create($a,n).generateCommitMessage$();case M.GEMINI:return H.create(ki,n).generateCommitMessage$();case M.ANTHROPIC:return H.create(Li,n).generateCommitMessage$();case M.HUGGINGFACE:return H.create(Gi,n).generateCommitMessage$();case M.MISTRAL:return H.create(Hi,n).generateCommitMessage$();case M.CODESTRAL:return H.create(Ri,n).generateCommitMessage$();case M.OLLAMA:return S(this.config.OLLAMA_MODEL).pipe(qt(s=>{const u={...n,keyName:s};return H.create(Yi,u).generateCommitMessage$()}));case M.COHERE:return H.create(Ni,n).generateCommitMessage$();case M.GROQ:return H.create(ji,n).generateCommitMessage$();default:const o=g.red.bold(`[${r}]`);return O({name:o+" Invalid AI type",value:"Invalid AI type",isError:!0,disabled:!0})}}),T(r=>{const n=g.red.bold("[UNKNOWN]");return O({name:n+` ${r.message||""}`,value:"Unknown error",isError:!0,disabled:!0})}))}}const hn=async()=>{const{stdout:e,failed:t}=await te("git",["rev-parse","--show-toplevel"],{reject:!1});if(t)throw new F("The current directory must be a Git repository!");return e},Tt=e=>`:(exclude)${e}`,gn=["package-lock.json","pnpm-lock.yaml","*.lock","*.gif","*.png"].map(Tt),Cn=async e=>{const t=["diff","--cached","--diff-algorithm=minimal"],{stdout:r}=await te("git",[...t,"--name-only",...gn,...e?e.map(Tt):[]]);if(!r)return null;const{stdout:n}=await te("git",[...t,...gn,...e?e.map(Tt):[]]);return{files:r.split(`
92
+ `),diff:n}},Ba=e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`;class Ee{constructor(){this.title="aicommit2"}printTitle(){console.log(Zn.textSync(this.title,{font:"Small"}))}displaySpinner(t){return ke(t).start()}stopSpinner(t){t.stop(),t.clear()}printStagedFiles(t){console.log(g.bold.green("\u2714 ")+g.bold(`${Ba(t.files)}:`)),console.log(`${t.files.map(r=>` ${r}`).join(`
107
93
  `)}
108
94
  `)}printAnalyzed(){console.log(`
109
95
  ${g.bold.green("\u2714")} ${g.bold("Changes analyzed")}`)}printCommitted(){console.log(`
@@ -111,14 +97,14 @@ ${g.bold.green("\u2714")} ${g.bold("Successfully committed!")}`)}printCopied(){c
111
97
  ${g.bold.green("\u2714")} ${g.bold("Successfully copied! Press 'Ctrl + V' to paste")}`)}printSavedCommitMessage(){console.log(`
112
98
  ${g.bold.green("\u2714")} ${g.bold("Saved commit message")}`)}printCancelledCommit(){console.log(`
113
99
  ${g.bold.yellow("\u26A0")} ${g.yellow("Commit cancelled")}`)}printErrorMessage(t){console.log(`
114
- ${g.bold.red("\u2716")} ${g.red(`${t}`)}`)}moveCursorUp(){const t=Fe.createInterface({input:process.stdin,output:process.stdout});Fe.moveCursor(process.stdout,0,-1),t.close()}moveCursorDown(){const t=Fe.createInterface({input:process.stdin,output:process.stdout});Fe.moveCursor(process.stdout,0,1),t.close()}}const $a={isLoading:!1,startOption:{text:"AI is analyzing your changes"}},Tt="No commit messages were generated";class Ba{constructor(){this.choices$=new qt([]),this.loader$=new qt($a),this.destroyed$=new In(1)}initPrompt(t){return Ne.registerPrompt("reactiveListPrompt",Qn),Ne.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(pe));return}this.checkStreamChoice(t)}checkErrorOnChoices(){if(this.choices$.getValue().map(r=>r).every(r=>r?.isError||r?.disabled)){this.alertNoGeneratedMessage(),this.logEmptyCommitMessage(),process.exit(1);return}this.stopLoaderOnSuccess()}completeSubject(){this.choices$.complete(),this.loader$.complete(),this.destroyed$.next(!0),this.destroyed$.complete()}alertNoGeneratedMessage(){this.loader$.next({isLoading:!1,message: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 o=this.currentChoices.find(s=>{const u=s.id||"",i=/\d/.test(u);return t.id?.includes(u)&&!i});if(o){this.choices$.next([...this.currentChoices.filter(s=>s.id!==o.id),t].sort(pe));return}this.choices$.next([...this.currentChoices,t].sort(pe));return}if(this.currentChoices.find(o=>o?.id===t.id)){this.choices$.next(this.currentChoices.map(o=>o?.id===t.id?t:o).sort(pe));return}this.choices$.next([...this.currentChoices,t].sort(pe))}get currentChoices(){return this.choices$.getValue().map(t=>t)}}const U=new Ee;var xa=async(e,t,r,n,o,s,u,i,c)=>(async()=>{U.printTitle(),await fn(),n&&await ee("git",["add","--update"]);const l=U.displaySpinner("Detecting staged files"),d=await hn(r);if(l.stop(),!d)throw new y("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");U.printStagedFiles(d);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,HUGGINGFACE_MODEL:a.HUGGINGFACE_MODEL,MISTRAL_KEY:a.MISTRAL_KEY||a.MISTRAL_API_KEY,CODESTRAL_KEY:a.CODESTRAL_KEY||a.CODESTRAL_API_KEY,MISTRAL_MODEL:a.MISTRAL_MODEL||a["mistral-model"]||a.mistral_model,proxy:a.https_proxy||a.HTTPS_PROXY||a.http_proxy||a.HTTP_PROXY,temperature:a.temperature,generate:t?.toString()||a.generate,type:o?.toString()||a.type,locale:e?.toString()||a.locale,prompt:i?.toString()||a.prompt}),p=Object.entries(D).filter(([A])=>Hr.includes(A)).filter(([A,ue])=>A===M.OLLAMA?!!ue&&ue.length>0:!!ue).map(([A])=>A);if(p.length===0)throw new y("Please set at least one API key via the `aicommit2 config set` command");const m=new pn(D,d),h=new Ba,C=h.initPrompt(!D.ignoreBody);h.startLoader();const b=m.createAIRequests$(p).subscribe(A=>h.refreshChoices(A),()=>{},()=>h.checkErrorOnChoices()),B=await C;b.unsubscribe(),h.completeSubject(),U.moveCursorUp();const L=B.aicommit2Prompt?.value;if(!L)throw new y("An error occurred! No selected message");if(u&&(Fs("copy-paste").copy(L),U.printCopied(),process.exit()),s){const A=ke("Committing with the generated message").start();await ee("git",["commit","-m",L,...c]),A.stop(),A.clear(),U.printCommitted(),process.exit()}const R=await Ne.prompt([{type:"confirm",name:"confirmationPrompt",message:"Use selected message?",default:!0}]),{confirmationPrompt:se}=R;if(se){const A=ke("Committing with the generated message").start();await ee("git",["commit","-m",L,...c]),A.stop(),A.clear(),U.printCommitted(),process.exit()}U.printCancelledCommit(),process.exit()})().catch(l=>{U.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 o of r)Et(n,o)&&console.log(`${o}=${n[o]}`);return}if(t==="set"){await Ki(r.map(n=>n.split("=")));return}throw new y(`Invalid mode: ${t}`)})().catch(t=>{new Ee().printErrorMessage(t.message),de(t),process.exit(1)})});const gn="prepare-commit-msg",Cn=`.git/hooks/${gn}`,Te=Jn(new URL("cli.mjs",import.meta.url)),Ma=process.argv[1].replace(/\\/g,"/").endsWith(`/${Cn}`),En=process.platform==="win32",Fn=`
100
+ ${g.bold.red("\u2716")} ${g.red(`${t}`)}`)}moveCursorUp(){const t=Fe.createInterface({input:process.stdin,output:process.stdout});Fe.moveCursor(process.stdout,0,-1),t.close()}moveCursorDown(){const t=Fe.createInterface({input:process.stdin,output:process.stdout});Fe.moveCursor(process.stdout,0,1),t.close()}}const xa={isLoading:!1,startOption:{text:"AI is analyzing your changes"}},Lt="No commit messages were generated";class Oa{constructor(){this.choices$=new zt([]),this.loader$=new zt(xa),this.destroyed$=new _n(1)}initPrompt(t){return Ne.registerPrompt("reactiveListPrompt",eo),Ne.prompt({type:"reactiveListPrompt",name:"aicommit2Prompt",message:"Pick a commit message to use: ",emptyMessage:`\u26A0 ${Lt}`,loop:!1,showDescription:t,descPageSize:10,choices$:this.choices$,loader$:this.loader$})}startLoader(){this.loader$.next({isLoading:!0})}refreshChoices(t){const{value:r,isError:n}=t;if(!t||!r)return;if(!t.id){this.choices$.next([...this.currentChoices,t].sort(pe));return}this.checkStreamChoice(t)}checkErrorOnChoices(){if(this.choices$.getValue().map(r=>r).every(r=>r?.isError||r?.disabled)){this.alertNoGeneratedMessage(),this.logEmptyCommitMessage(),process.exit(1);return}this.stopLoaderOnSuccess()}completeSubject(){this.choices$.complete(),this.loader$.complete(),this.destroyed$.next(!0),this.destroyed$.complete()}alertNoGeneratedMessage(){this.loader$.next({isLoading:!1,message:Lt,stopOption:{doneFrame:"\u26A0",color:"yellow"}})}stopLoaderOnSuccess(){this.loader$.next({isLoading:!1,message:"Changes analyzed"})}logEmptyCommitMessage(){console.log(`${g.bold.yellow("\u26A0")} ${g.yellow(`${Lt}`)}`)}checkStreamChoice(t){if(t.description===Si){const o=this.currentChoices.find(s=>{const u=s.id||"",i=/\d/.test(u);return t.id?.includes(u)&&!i});if(o){this.choices$.next([...this.currentChoices.filter(s=>s.id!==o.id),t].sort(pe));return}this.choices$.next([...this.currentChoices,t].sort(pe));return}if(this.currentChoices.find(o=>o?.id===t.id)){this.choices$.next(this.currentChoices.map(o=>o?.id===t.id?t:o).sort(pe));return}this.choices$.next([...this.currentChoices,t].sort(pe))}get currentChoices(){return this.choices$.getValue().map(t=>t)}}const q=new Ee;var Ma=async(e,t,r,n,o,s,u,i,c)=>(async()=>{q.printTitle(),await hn(),n&&await te("git",["add","--update"]);const l=q.displaySpinner("Detecting staged files"),d=await Cn(r);if(l.stop(),!d)throw new F("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");q.printStagedFiles(d);const{env:a}=process,D=await bt({OPENAI_KEY:a.OPENAI_KEY||a.OPENAI_API_KEY,OPENAI_MODEL:a.OPENAI_MODEL||a["openai-model"]||a.openai_model,OPENAI_URL:a.OPENAI_URL||a["openai-url"]||a.OPENAI_URL,GEMINI_KEY:a.GEMINI_KEY||a.GEMINI_API_KEY,GEMINI_MODEL:a.GEMINI_MODEL||a["gemini-model"]||a.gemini_model,ANTHROPIC_KEY:a.ANTHROPIC_KEY||a.ANTHROPIC_API_KEY,ANTHROPIC_MODEL:a.ANTHROPIC_MODEL||a["anthropic-model"]||a.anthropic_model,HUGGINGFACE_MODEL:a.HUGGINGFACE_MODEL,MISTRAL_KEY:a.MISTRAL_KEY||a.MISTRAL_API_KEY,CODESTRAL_KEY:a.CODESTRAL_KEY||a.CODESTRAL_API_KEY,MISTRAL_MODEL:a.MISTRAL_MODEL||a["mistral-model"]||a.mistral_model,proxy:a.https_proxy||a.HTTPS_PROXY||a.http_proxy||a.HTTP_PROXY,temperature:a.temperature,generate:t?.toString()||a.generate,type:o?.toString()||a.type,locale:e?.toString()||a.locale,promptPath:i?.toString()||a.promptPath});if(D.promptPath)try{k.readFileSync(P.resolve(D.promptPath),"utf-8")}catch{throw new F(`Error reading user prompt file: ${D.promptPath}`)}const p=Object.entries(D).filter(([A])=>Kr.includes(A)).filter(([A,ue])=>A===M.OLLAMA?!!ue&&ue.length>0:!!ue).map(([A])=>A);if(p.length===0)throw new F("Please set at least one API key via the `aicommit2 config set` command");const h=new mn(D,d),m=new Oa,E=m.initPrompt(!D.ignoreBody);m.startLoader();const b=h.createAIRequests$(p).subscribe(A=>m.refreshChoices(A),()=>{},()=>m.checkErrorOnChoices()),w=await E;b.unsubscribe(),m.completeSubject(),q.moveCursorUp();const R=w.aicommit2Prompt?.value;if(!R)throw new F("An error occurred! No selected message");if(u&&(bs("copy-paste").copy(R),q.printCopied(),process.exit()),s){const A=ke("Committing with the generated message").start();await te("git",["commit","-m",R,...c]),A.stop(),A.clear(),q.printCommitted(),process.exit()}const N=await Ne.prompt([{type:"confirm",name:"confirmationPrompt",message:"Use selected message?",default:!0}]),{confirmationPrompt:se}=N;if(se){const A=ke("Committing with the generated message").start();await te("git",["commit","-m",R,...c]),A.stop(),A.clear(),q.printCommitted(),process.exit()}q.printCancelledCommit(),process.exit()})().catch(l=>{q.printErrorMessage(l.message),de(l),process.exit(1)}),Sa=Je({name:"config",parameters:["<mode>","<key=value...>"]},e=>{(async()=>{const{mode:t,keyValue:r}=e._;if(t==="get"){const n=await bt({},!0);for(const o of r)Ft(n,o)&&console.log(`${o}=${n[o]}`);return}if(t==="set"){await zi(r.map(n=>n.split("=")));return}throw new F(`Invalid mode: ${t}`)})().catch(t=>{new Ee().printErrorMessage(t.message),de(t),process.exit(1)})});const En="prepare-commit-msg",Fn=`.git/hooks/${En}`,Te=Xn(new URL("cli.mjs",import.meta.url)),Pa=process.argv[1].replace(/\\/g,"/").endsWith(`/${Fn}`),yn=process.platform==="win32",bn=`
115
101
  #!/usr/bin/env node
116
- import(${JSON.stringify(Vn(Te))})
117
- `.trim();var Sa=Je({name:"hook",parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await fn(),{installUninstall:r}=e._,n=K.join(t,Cn),o=await Qr(n);if(r==="install"){if(o){if(await x.realpath(n).catch(()=>{})===Te){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(K.dirname(n),{recursive:!0}),En?await x.writeFile(n,Fn):(await x.symlink(Te,n,"file"),await x.chmod(n,493)),console.log(`${g.green("\u2714")} Hook installed`);return}if(r==="uninstall"){if(!o){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)!==Te){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(zr,{recursive:!0,force:!0}),console.log(`${g.green("\u2714")} All Log files are removed!`);return}throw new y(`Invalid mode: ${t}`)})().catch(t=>{new Ee().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 Ee;t.printTitle();const{env:r}=process,n=await yt({proxy:r.https_proxy||r.HTTPS_PROXY||r.http_proxy||r.HTTP_PROXY}),o=Object.entries(n).filter(([p])=>Hr.includes(p)).filter(([p,f])=>p===M.OLLAMA?!!f&&f.length>0:!!f).map(([p])=>p);if(o.length===0)throw new y("Please set at least one API key via `aicommit2 config set OPENAI_KEY=<your token>`");const u=new pn(n,e),i=t.displaySpinner("The AI is analyzing your changes");let c;try{c=await Pn(u.createAIRequests$(o).pipe(_n(p=>!p.isError),P(p=>p.value),Tn()))}finally{i.stop(),i.clear(),t.printAnalyzed()}const d=await x.readFile(Lt,"utf8")!=="",a=c.length>1;let D="";d&&(D=`# \u{1F916} AI generated commit${a?"s":""}
102
+ import(${JSON.stringify(Qn(Te))})
103
+ `.trim();var Ia=Je({name:"hook",parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await hn(),{installUninstall:r}=e._,n=P.join(t,Fn),o=await en(n);if(r==="install"){if(o){if(await x.realpath(n).catch(()=>{})===Te){console.warn("The hook is already installed");return}throw new F(`A different ${En} hook seems to be installed. Please remove it before installing aicommit2.`)}await x.mkdir(P.dirname(n),{recursive:!0}),yn?await x.writeFile(n,bn):(await x.symlink(Te,n,"file"),await x.chmod(n,493)),console.log(`${g.green("\u2714")} Hook installed`);return}if(r==="uninstall"){if(!o){console.warn("Hook is not installed");return}if(yn){if(await x.readFile(n,"utf8")!==bn){console.warn("Hook is not installed");return}}else if(await x.realpath(n)!==Te){console.warn("Hook is not installed");return}await x.rm(n),console.log(`${g.green("\u2714")} Hook uninstalled`);return}throw new F(`Invalid mode: ${r}`)})().catch(t=>{console.error(`${g.red("\u2716")} ${t.message}`),de(t),process.exit(1)})}),_a=Je({name:"log",parameters:["<removeAll>"]},e=>{(async()=>{const{removeAll:t}=e._;if(t==="removeAll"){await to(Wr,{recursive:!0,force:!0}),console.log(`${g.green("\u2714")} All Log files are removed!`);return}throw new F(`Invalid mode: ${t}`)})().catch(t=>{new Ee().printErrorMessage(t.message),de(t),process.exit(1)})});const[Rt,Ta]=process.argv.slice(2);var La=()=>(async()=>{if(!Rt)throw new F('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(Ta)return;const e=await Cn();if(!e)return;const t=new Ee;t.printTitle();const{env:r}=process,n=await bt({proxy:r.https_proxy||r.HTTPS_PROXY||r.http_proxy||r.HTTP_PROXY}),o=Object.entries(n).filter(([p])=>Kr.includes(p)).filter(([p,f])=>p===M.OLLAMA?!!f&&f.length>0:!!f).map(([p])=>p);if(o.length===0)throw new F("Please set at least one API key via `aicommit2 config set OPENAI_KEY=<your token>`");const u=new mn(n,e),i=t.displaySpinner("The AI is analyzing your changes");let c;try{c=await Tn(u.createAIRequests$(o).pipe(Ln(p=>!p.isError),_(p=>p.value),Rn()))}finally{i.stop(),i.clear(),t.printAnalyzed()}const d=await x.readFile(Rt,"utf8")!=="",a=c.length>1;let D="";d&&(D=`# \u{1F916} AI generated commit${a?"s":""}
118
104
  `),a?(d&&(D+=`# Select one of the following messages by uncommenting:
119
105
  `),D+=`
120
106
  ${c.map(p=>`# ${p}`).join(`
121
107
  `)}`):(d&&(D+=`# Edit the message below and commit:
122
108
  `),D+=`
123
109
  ${c[0]}
124
- `),await x.appendFile(Lt,D),t.printSavedCommitMessage()})().catch(e=>{new Ee().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);
110
+ `),await x.appendFile(Rt,D),t.printSavedCommitMessage()})().catch(e=>{new Ee().printErrorMessage(e.message),de(e),process.exit(1)});const An=process.argv.slice(2);ys({name:"aicommit2",version:qr,flags:{locale:{type:String,description:"Locale to use for the generated commit messages (default: en)",alias:"l"},generate:{type:Number,description:"Number of messages to generate (Warning: generating multiple costs more) (default: 1)",alias:"g"},exclude:{type:[String],description:"Files to exclude from AI analysis",alias:"x"},all:{type:Boolean,description:"Automatically stage changes in tracked files for the commit",alias:"a",default:!1},type:{type:String,description:"Type of commit message to generate",alias:"t"},confirm:{type:Boolean,description:"Skip confirmation when committing after message generation (default: false)",alias:"y",default:!1},clipboard:{type:Boolean,description:"Copy the selected message to the clipboard",alias:"c",default:!1},prompt:{type:String,description:"Additional prompt to let users fine-tune provided prompt",alias:"p"}},commands:[Sa,Ia,_a],help:{description:Mi},ignoreArgv:e=>e==="unknown-flag"||e==="argument"},e=>{if(Pa){La();return}Ma(e.flags.locale,e.flags.generate,e.flags.exclude,e.flags.all,e.flags.type,e.flags.confirm,e.flags.clipboard,e.flags.prompt,An)},An);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicommit2",
3
- "version": "1.11.1",
3
+ "version": "1.12.0",
4
4
  "description": "A Reactive CLI that generates git commit messages with various AI",
5
5
  "keywords": [
6
6
  "cli",