@jakejarvis/acai 0.1.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 (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +117 -0
  3. package/dist/cli.mjs +111 -0
  4. package/package.json +53 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jake Jarvis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,117 @@
1
+ # acai
2
+
3
+ AI-generated commit messages that match your repo's existing style. Powered by [Claude Code](https://docs.anthropic.com/en/docs/claude-code) or [Codex](https://github.com/openai/codex).
4
+
5
+ `acai` reads your repo's recent commit history and adapts to whatever conventions your team already uses — conventional commits, gitmoji, ticket prefixes, pig latin, etc.
6
+
7
+ > [!NOTE]
8
+ > I vibed this up in a day based on my own needs and desires, but am more than willing to accept feedback and PRs!
9
+
10
+ ## How it works
11
+
12
+ 1. Reads the last ~10 commits from your repo's git log
13
+ 2. Reads your staged diff
14
+ 3. Sends both to your chosen AI provider, asking it to analyze the repo's commit style and generate a message that matches
15
+ 4. Presents the message for your approval — you can accept, edit, revise with feedback, regenerate, or copy to clipboard
16
+
17
+ ## Prerequisites
18
+
19
+ - [Node.js](https://nodejs.org) runtime
20
+ - At least one of the following CLIs installed and signed in:
21
+
22
+ | Provider | Install |
23
+ |----------|---------|
24
+ | [Claude Code](https://code.claude.com/docs/en/overview) (default) | `curl -fsSL https://claude.ai/install.sh \| bash` |
25
+ | [Codex](https://github.com/openai/codex) | `npm i -g @openai/codex` |
26
+
27
+ ## Options
28
+
29
+ | Flag | Env var | Default | Description |
30
+ |------|---------|---------|-------------|
31
+ | `-p, --provider` | `ACAI_PROVIDER` | `claude` | AI provider (`claude`, `codex`) |
32
+ | `-m, --model` | `ACAI_MODEL` | provider default | Model override (`sonnet`, `gpt-5.3-codex`, etc.) |
33
+ | `-y, --yolo` | — | `false` | Stage all changes and commit without confirmation |
34
+
35
+ ## Usage
36
+
37
+ From any git repo with staged (or unstaged) changes:
38
+
39
+ ```bash
40
+ # Run directly with npx (no install needed)
41
+ npx @jakejarvis/acai@latest
42
+
43
+ # Or install globally
44
+ npm install -g @jakejarvis/acai
45
+ acai
46
+
47
+ # Use a different provider
48
+ acai -p codex
49
+
50
+ # Override the model
51
+ acai -m haiku
52
+ acai -p codex -m o4-mini
53
+
54
+ # Stage everything, generate, and commit — no prompts
55
+ acai --yolo
56
+ ```
57
+
58
+ ### The flow
59
+
60
+ ```
61
+ ┌ acai
62
+
63
+ ◇ 3 files staged
64
+
65
+ ◆ Generating commit message…
66
+
67
+ │ feat(auth): add session expiry validation
68
+
69
+ ◆ What do you want to do?
70
+ │ ✓ Commit — accept and commit
71
+ │ ✎ Edit — open in $EDITOR before committing
72
+ │ ↻ Revise — give Claude feedback and regenerate
73
+ │ ⎘ Copy — copy to clipboard, don't commit
74
+ │ ✕ Cancel
75
+
76
+ └ Done.
77
+ ```
78
+
79
+ ### Revision loop
80
+
81
+ Choose **Revise** and tell Claude what to change:
82
+
83
+ ```
84
+ ◆ What should Claude change?
85
+ │ make it shorter, drop the scope
86
+
87
+ ◆ Generating commit message…
88
+
89
+ │ feat: add session expiry validation
90
+ ```
91
+
92
+ You can revise as many times as you like before committing.
93
+
94
+ ### YOLO mode
95
+
96
+ Just want to commit and move on? `acai --yolo` stages all changes, generates a message, and commits — zero interaction required.
97
+
98
+ ### No staged changes?
99
+
100
+ If nothing is staged, the tool will offer to `git add -A` for you.
101
+
102
+ ### How style detection works
103
+
104
+ There's no manual configuration or pattern matching. The tool passes your recent commit log directly to the AI and asks it to infer the conventions. It picks up on:
105
+
106
+ - **Format** — conventional commits, gitmoji, `[tag]` prefixes, ticket IDs, freeform
107
+ - **Tone** — imperative mood vs past tense, formal vs casual
108
+ - **Capitalization** — uppercase vs lowercase subjects
109
+ - **Scope** — whether `(scope)` is used in conventional commits
110
+ - **Body** — whether commits typically include a body or are subject-only
111
+ - **Detail level** — terse one-liners vs detailed descriptions
112
+
113
+ New repo with no history? It defaults to clean, concise conventional commits.
114
+
115
+ ## License
116
+
117
+ MIT
package/dist/cli.mjs ADDED
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env node
2
+ import e,{stdin as t,stdout as n}from"process";import*as r from"readline";import i from"readline";import{ReadStream as a}from"tty";import{existsSync as o,lstatSync as s,mkdtempSync as c,readdirSync as l,rmSync as u,writeFileSync as d}from"fs";import{dirname as f,join as p}from"path";import{parseArgs as m,stripVTControlCharacters as h}from"util";import{spawn as g}from"child_process";import{tmpdir as _}from"os";var v=Object.create,y=Object.defineProperty,b=Object.getOwnPropertyDescriptor,x=Object.getOwnPropertyNames,S=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty,w=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ee=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=x(t),a=0,o=i.length,s;a<o;a++)s=i[a],!C.call(e,s)&&s!==n&&y(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=b(t,s))||r.enumerable});return e},te=(e,t,n)=>(n=e==null?{}:v(S(e)),ee(t||!e||!e.__esModule?y(n,`default`,{value:e,enumerable:!0}):n,e)),ne=w(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c})),re=w(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})),T=te(ne(),1),E=re();function D(e,t,n){if(!n.some(e=>!e.disabled))return e;let r=e+t,i=Math.max(n.length-1,0),a=r<0?i:r>i?0:r;return n[a].disabled?D(a,t<0?-1:1,n):a}const ie=e=>e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109,ae=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,oe=e=>e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101632&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129672||e>=129680&&e<=129725||e>=129727&&e<=129733||e>=129742&&e<=129755||e>=129760&&e<=129768||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141,O=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,k=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,A=/\t{1,1000}/y,se=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,j=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,ce=/\p{M}+/gu,le={limit:1/0,ellipsis:``},ue=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?ue(i,le,n).width:0),o=n.ansiWidth??0,s=n.controlWidth??0,c=n.tabWidth??8,l=n.ambiguousWidth??1,u=n.emojiWidth??2,d=n.fullWidthWidth??2,f=n.regularWidth??1,p=n.wideWidth??2,m=0,h=0,g=e.length,_=0,v=!1,y=g,b=Math.max(0,r-a),x=0,S=0,C=0,w=0;t:for(;;){if(S>x||h>=g&&h>m){let t=e.slice(x,S)||e.slice(m,h);_=0;for(let e of t.replaceAll(ce,``)){let t=e.codePointAt(0)||0;if(w=ae(t)?d:oe(t)?p:l!==f&&ie(t)?l:f,C+w>b&&(y=Math.min(y,Math.max(x,m)+_)),C+w>r){v=!0;break t}_+=e.length,C+=w}x=S=0}if(h>=g)break;if(j.lastIndex=h,j.test(e)){if(_=j.lastIndex-h,w=_*f,C+w>b&&(y=Math.min(y,h+Math.floor((b-C)/f))),C+w>r){v=!0;break}C+=w,x=m,S=h,h=m=j.lastIndex;continue}if(O.lastIndex=h,O.test(e)){if(C+o>b&&(y=Math.min(y,h)),C+o>r){v=!0;break}C+=o,x=m,S=h,h=m=O.lastIndex;continue}if(k.lastIndex=h,k.test(e)){if(_=k.lastIndex-h,w=_*s,C+w>b&&(y=Math.min(y,h+Math.floor((b-C)/s))),C+w>r){v=!0;break}C+=w,x=m,S=h,h=m=k.lastIndex;continue}if(A.lastIndex=h,A.test(e)){if(_=A.lastIndex-h,w=_*c,C+w>b&&(y=Math.min(y,h+Math.floor((b-C)/c))),C+w>r){v=!0;break}C+=w,x=m,S=h,h=m=A.lastIndex;continue}if(se.lastIndex=h,se.test(e)){if(C+u>b&&(y=Math.min(y,h)),C+u>r){v=!0;break}C+=u,x=m,S=h,h=m=se.lastIndex;continue}h+=1}return{width:v?b:C,index:v?y:g,truncated:v,ellipsed:v&&r>=a}},de={limit:1/0,ellipsis:``,ellipsisWidth:0},M=(e,t={})=>ue(e,de,t).width,fe=`]8;;`,pe=RegExp(`(?:\\[(?<code>\\d+)m|\\${fe}(?<uri>.*))`,`y`),me=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},he=e=>`[${e}m`,ge=e=>`${fe}${e}`,_e=e=>e.map(e=>M(e)),ve=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:M(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=M(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(fe,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length>0&&e.length>1&&(e[e.length-2]+=e.pop())},ye=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(M(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},be=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=_e(o),c=[``];for(let[e,r]of o.entries()){n.trim!==!1&&(c[c.length-1]=(c.at(-1)??``).trimStart());let i=M(c.at(-1)??``);if(e!==0&&(i>=t&&(n.wordWrap===!1||n.trim===!1)&&(c.push(``),i=0),(i>0||n.trim===!1)&&(c[c.length-1]+=` `,i++)),n.hard&&s[e]>t){let n=t-i,a=1+Math.floor((s[e]-n-1)/t);Math.floor((s[e]-1)/t)<a&&c.push(``),ve(c,r,t);continue}if(i+s[e]>t&&i>0&&s[e]>0){if(n.wordWrap===!1&&i<t){ve(c,r,t);continue}c.push(``)}if(i+s[e]>t&&n.wordWrap===!1){ve(c,r,t);continue}c[c.length-1]+=r}n.trim!==!1&&(c=c.map(e=>ye(e)));let l=c.join(`
3
+ `),u=l[Symbol.iterator](),d=u.next(),f=u.next(),p=0;for(;!d.done;){let e=d.value,t=f.value;if(r+=e,e===`\x1B`||e===`›`){pe.lastIndex=p+1;let e=pe.exec(l)?.groups;if(e?.code!==void 0){let t=Number.parseFloat(e.code);i=t===39?void 0:t}else e?.uri!==void 0&&(a=e.uri.length===0?void 0:e.uri)}let n=i?me(i):void 0;t===`
4
+ `?(a&&(r+=ge(``)),i&&n&&(r+=he(n))):e===`
5
+ `&&(i&&n&&(r+=he(i)),a&&(r+=ge(a))),p+=e.length,d=f,f=u.next()}return r};function xe(e,t,n){return String(e).normalize().replaceAll(`\r
6
+ `,`
7
+ `).split(`
8
+ `).map(e=>be(e,t,n)).join(`
9
+ `)}const N={actions:new Set([`up`,`down`,`left`,`right`,`space`,`enter`,`cancel`]),aliases:new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`],[``,`cancel`],[`escape`,`cancel`]]),messages:{cancel:`Canceled`,error:`Something went wrong`},withGuide:!0};function Se(e,t){if(typeof e==`string`)return N.aliases.get(e)===t;for(let n of e)if(n!==void 0&&Se(n,t))return!0;return!1}function Ce(e,t){if(e===t)return;let n=e.split(`
10
+ `),r=t.split(`
11
+ `),i=Math.max(n.length,r.length),a=[];for(let e=0;e<i;e++)n[e]!==r[e]&&a.push(e);return{lines:a,numLinesBefore:n.length,numLinesAfter:r.length,numLines:i}}const we=globalThis.process.platform.startsWith(`win`),Te=Symbol(`clack:cancel`);function P(e){return e===Te}function F(e,t){let n=e;n.isTTY&&n.setRawMode(t)}function Ee({input:e=t,output:i=n,overwrite:o=!0,hideCursor:s=!0}={}){let c=r.createInterface({input:e,output:i,prompt:``,tabSize:1});r.emitKeypressEvents(e,c),e instanceof a&&e.isTTY&&e.setRawMode(!0);let l=(t,{name:n,sequence:a})=>{if(Se([String(t),n,a],`cancel`)){s&&i.write(E.cursor.show),process.exit(0);return}if(!o)return;let c=n===`return`?0:-1,u=n===`return`?-1:0;r.moveCursor(i,c,u,()=>{r.clearLine(i,1,()=>{e.once(`keypress`,l)})})};return s&&i.write(E.cursor.hide),e.once(`keypress`,l),()=>{e.off(`keypress`,l),s&&i.write(E.cursor.show),e instanceof a&&e.isTTY&&!we&&e.setRawMode(!1),c.terminal=!1,c.close()}}const I=e=>`columns`in e&&typeof e.columns==`number`?e.columns:80,De=e=>`rows`in e&&typeof e.rows==`number`?e.rows:20;function Oe(e,t,r,i=r){return xe(t,I(e??n)-r.length,{hard:!0,trim:!1}).split(`
12
+ `).map((e,t)=>`${t===0?i:r}${e}`).join(`
13
+ `)}var L=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame=``;_subscribers=new Map;_cursor=0;state=`initial`;error=``;value;userInput=``;constructor(e,r=!0){let{input:i=t,output:a=n,render:o,signal:s,...c}=e;this.opts=c,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=o.bind(this),this._track=r,this._abortSignal=s,this.input=i,this.output=a}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let n=this._subscribers.get(e)??[];n.push(t),this._subscribers.set(e,n)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let n=this._subscribers.get(e)??[],r=[];for(let e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(let e of r)e()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state=`cancel`,this.close(),e(Te);this._abortSignal.addEventListener(`abort`,()=>{this.state=`cancel`,this.close()},{once:!0})}this.rl=i.createInterface({input:this.input,tabSize:2,prompt:``,escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on(`keypress`,this.onKeypress),F(this.input,!0),this.output.on(`resize`,this.render),this.render(),this.once(`submit`,()=>{this.output.write(E.cursor.show),this.output.off(`resize`,this.render),F(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(E.cursor.show),this.output.off(`resize`,this.render),F(this.input,!1),e(Te)})})}_isActionKey(e,t){return e===` `}_setValue(e){this.value=e,this.emit(`value`,this.value)}_setUserInput(e,t){this.userInput=e??``,this.emit(`userInput`,this.userInput),t&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:`u`}),this._setUserInput(``)}onKeypress(e,t){if(this._track&&t.name!==`return`&&(t.name&&this._isActionKey(e,t)&&this.rl?.write(null,{ctrl:!0,name:`h`}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state===`error`&&(this.state=`active`),t?.name&&(!this._track&&N.aliases.has(t.name)&&this.emit(`cursor`,N.aliases.get(t.name)),N.actions.has(t.name)&&this.emit(`cursor`,t.name)),e&&(e.toLowerCase()===`y`||e.toLowerCase()===`n`)&&this.emit(`confirm`,e.toLowerCase()===`y`),this.emit(`key`,e?.toLowerCase(),t),t?.name===`return`){if(this.opts.validate){let e=this.opts.validate(this.value);e&&(this.error=e instanceof Error?e.message:e,this.state=`error`,this.rl?.write(this.userInput))}this.state!==`error`&&(this.state=`submit`)}Se([e,t?.name,t?.sequence],`cancel`)&&(this.state=`cancel`),(this.state===`submit`||this.state===`cancel`)&&this.emit(`finalize`),this.render(),(this.state===`submit`||this.state===`cancel`)&&this.close()}close(){this.input.unpipe(),this.input.removeListener(`keypress`,this.onKeypress),this.output.write(`
14
+ `),F(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=xe(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
15
+ `).length-1;this.output.write(E.cursor.move(-999,e*-1))}render(){let e=xe(this._render(this)??``,process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(E.cursor.hide);else{let t=Ce(this._prevFrame,e),n=De(this.output);if(this.restoreCursor(),t){let r=Math.max(0,t.numLinesAfter-n),i=Math.max(0,t.numLinesBefore-n),a=t.lines.find(e=>e>=r);if(a===void 0){this._prevFrame=e;return}if(t.lines.length===1){this.output.write(E.cursor.move(0,a-i)),this.output.write(E.erase.lines(1));let t=e.split(`
16
+ `);this.output.write(t[a]),this._prevFrame=e,this.output.write(E.cursor.move(0,t.length-a-1));return}else if(t.lines.length>1){if(r<i)a=r;else{let e=a-i;e>0&&this.output.write(E.cursor.move(0,e))}this.output.write(E.erase.down());let t=e.split(`
17
+ `).slice(a);this.output.write(t.join(`
18
+ `)),this._prevFrame=e;return}}this.output.write(E.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},ke=class extends L{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`userInput`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(E.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}},Ae=class extends L{options;cursor=0;#e;getGroupItems(e){return this.options.filter(t=>t.group===e)}isGroupSelected(e){let t=this.getGroupItems(e),n=this.value;return n===void 0?!1:t.every(e=>n.includes(e.value))}toggleValue(){let e=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),e.group===!0){let t=e.value,n=this.getGroupItems(t);this.isGroupSelected(t)?this.value=this.value.filter(e=>n.findIndex(t=>t.value===e)===-1):this.value=[...this.value,...n.map(e=>e.value)],this.value=Array.from(new Set(this.value))}else this.value=this.value.includes(e.value)?this.value.filter(t=>t!==e.value):[...this.value,e.value]}constructor(e){super(e,!1);let{options:t}=e;this.#e=e.selectableGroups!==!1,this.options=Object.entries(t).flatMap(([e,t])=>[{value:e,group:!0,label:e},...t.map(t=>({...t,group:e}))]),this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),this.#e?0:1),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let e=this.options[this.cursor]?.group===!0;!this.#e&&e&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case`down`:case`right`:{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let e=this.options[this.cursor]?.group===!0;!this.#e&&e&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case`space`:this.toggleValue();break}})}},je=class extends L{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(e){super(e,!1),this.options=e.options;let t=this.options.findIndex(({value:t})=>t===e.initialValue),n=t===-1?0:t;this.cursor=this.options[n].disabled?D(n,1,this.options):n,this.changeValue(),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=D(this.cursor,-1,this.options);break;case`down`:case`right`:this.cursor=D(this.cursor,1,this.options);break}this.changeValue()})}},Me=class extends L{get userInputWithCursor(){if(this.state===`submit`)return this.userInput;let e=this.userInput;if(this.cursor>=e.length)return`${this.userInput}\u2588`;let t=e.slice(0,this.cursor),[n,...r]=e.slice(this.cursor);return`${t}${T.default.inverse(n)}${r.join(``)}`}get cursor(){return this._cursor}constructor(e){super({...e,initialUserInput:e.initialUserInput??e.initialValue}),this.on(`userInput`,e=>{this._setValue(e)}),this.on(`finalize`,()=>{this.value||=e.defaultValue,this.value===void 0&&(this.value=``)})}};function Ne(){return e.platform===`win32`?!!e.env.CI||!!e.env.WT_SESSION||!!e.env.TERMINUS_SUBLIME||e.env.ConEmuTask===`{cmd::Cmder}`||e.env.TERM_PROGRAM===`Terminus-Sublime`||e.env.TERM_PROGRAM===`vscode`||e.env.TERM===`xterm-256color`||e.env.TERM===`alacritty`||e.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:e.env.TERM!==`linux`}const Pe=Ne(),Fe=()=>process.env.CI===`true`,R=(e,t)=>Pe?e:t,Ie=R(`◆`,`*`),Le=R(`■`,`x`),Re=R(`▲`,`x`),z=R(`◇`,`o`),ze=R(`┌`,`T`),B=R(`│`,`|`),V=R(`└`,`—`),Be=R(`●`,`>`),H=R(`○`,` `),Ve=R(`◻`,`[•]`),He=R(`◼`,`[+]`),Ue=R(`◻`,`[ ]`),We=R(`●`,`•`),Ge=R(`◆`,`*`),Ke=R(`▲`,`!`),qe=R(`■`,`x`),U=e=>{switch(e){case`initial`:case`active`:return T.default.cyan(Ie);case`cancel`:return T.default.red(Le);case`error`:return T.default.yellow(Re);case`submit`:return T.default.green(z)}},Je=e=>{switch(e){case`initial`:case`active`:return T.default.cyan(B);case`cancel`:return T.default.red(B);case`error`:return T.default.yellow(B);case`submit`:return T.default.green(B)}},Ye=e=>e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109,Xe=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Ze=e=>e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101632&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129672||e>=129680&&e<=129725||e>=129727&&e<=129733||e>=129742&&e<=129755||e>=129760&&e<=129768||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141,W=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,G=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,K=/\t{1,1000}/y,Qe=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,q=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,$e=/\p{M}+/gu,et={limit:1/0,ellipsis:``},tt=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?tt(i,et,n).width:0),o=n.ansiWidth??0,s=n.controlWidth??0,c=n.tabWidth??8,l=n.ambiguousWidth??1,u=n.emojiWidth??2,d=n.fullWidthWidth??2,f=n.regularWidth??1,p=n.wideWidth??2,m=0,h=0,g=e.length,_=0,v=!1,y=g,b=Math.max(0,r-a),x=0,S=0,C=0,w=0;t:for(;;){if(S>x||h>=g&&h>m){let t=e.slice(x,S)||e.slice(m,h);_=0;for(let e of t.replaceAll($e,``)){let t=e.codePointAt(0)||0;if(w=Xe(t)?d:Ze(t)?p:l!==f&&Ye(t)?l:f,C+w>b&&(y=Math.min(y,Math.max(x,m)+_)),C+w>r){v=!0;break t}_+=e.length,C+=w}x=S=0}if(h>=g)break;if(q.lastIndex=h,q.test(e)){if(_=q.lastIndex-h,w=_*f,C+w>b&&(y=Math.min(y,h+Math.floor((b-C)/f))),C+w>r){v=!0;break}C+=w,x=m,S=h,h=m=q.lastIndex;continue}if(W.lastIndex=h,W.test(e)){if(C+o>b&&(y=Math.min(y,h)),C+o>r){v=!0;break}C+=o,x=m,S=h,h=m=W.lastIndex;continue}if(G.lastIndex=h,G.test(e)){if(_=G.lastIndex-h,w=_*s,C+w>b&&(y=Math.min(y,h+Math.floor((b-C)/s))),C+w>r){v=!0;break}C+=w,x=m,S=h,h=m=G.lastIndex;continue}if(K.lastIndex=h,K.test(e)){if(_=K.lastIndex-h,w=_*c,C+w>b&&(y=Math.min(y,h+Math.floor((b-C)/c))),C+w>r){v=!0;break}C+=w,x=m,S=h,h=m=K.lastIndex;continue}if(Qe.lastIndex=h,Qe.test(e)){if(C+u>b&&(y=Math.min(y,h)),C+u>r){v=!0;break}C+=u,x=m,S=h,h=m=Qe.lastIndex;continue}h+=1}return{width:v?b:C,index:v?y:g,truncated:v,ellipsed:v&&r>=a}},nt={limit:1/0,ellipsis:``,ellipsisWidth:0},J=(e,t={})=>tt(e,nt,t).width,rt=`]8;;`,it=RegExp(`(?:\\[(?<code>\\d+)m|\\${rt}(?<uri>.*))`,`y`),at=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},ot=e=>`[${e}m`,st=e=>`${rt}${e}`,ct=e=>e.map(e=>J(e)),lt=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:J(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=J(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(rt,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length>0&&e.length>1&&(e[e.length-2]+=e.pop())},ut=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(J(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},dt=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=ct(o),c=[``];for(let[e,r]of o.entries()){n.trim!==!1&&(c[c.length-1]=(c.at(-1)??``).trimStart());let i=J(c.at(-1)??``);if(e!==0&&(i>=t&&(n.wordWrap===!1||n.trim===!1)&&(c.push(``),i=0),(i>0||n.trim===!1)&&(c[c.length-1]+=` `,i++)),n.hard&&s[e]>t){let n=t-i,a=1+Math.floor((s[e]-n-1)/t);Math.floor((s[e]-1)/t)<a&&c.push(``),lt(c,r,t);continue}if(i+s[e]>t&&i>0&&s[e]>0){if(n.wordWrap===!1&&i<t){lt(c,r,t);continue}c.push(``)}if(i+s[e]>t&&n.wordWrap===!1){lt(c,r,t);continue}c[c.length-1]+=r}n.trim!==!1&&(c=c.map(e=>ut(e)));let l=c.join(`
19
+ `),u=l[Symbol.iterator](),d=u.next(),f=u.next(),p=0;for(;!d.done;){let e=d.value,t=f.value;if(r+=e,e===`\x1B`||e===`›`){it.lastIndex=p+1;let e=it.exec(l)?.groups;if(e?.code!==void 0){let t=Number.parseFloat(e.code);i=t===39?void 0:t}else e?.uri!==void 0&&(a=e.uri.length===0?void 0:e.uri)}let n=i?at(i):void 0;t===`
20
+ `?(a&&(r+=st(``)),i&&n&&(r+=ot(n))):e===`
21
+ `&&(i&&n&&(r+=ot(i)),a&&(r+=st(a))),p+=e.length,d=f,f=u.next()}return r};function ft(e,t,n){return String(e).normalize().replaceAll(`\r
22
+ `,`
23
+ `).split(`
24
+ `).map(e=>dt(e,t,n)).join(`
25
+ `)}const pt=(e,t,n,r,i)=>{let a=t,o=0;for(let t=n;t<r;t++){let n=e[t];if(a-=n.length,o++,a<=i)break}return{lineCount:a,removals:o}},mt=e=>{let{cursor:t,options:n,style:r}=e,i=e.output??process.stdout,a=I(i),o=e.columnPadding??0,s=e.rowPadding??4,c=a-o,l=De(i),u=T.default.dim(`...`),d=e.maxItems??1/0,f=Math.max(l-s,0),p=Math.max(Math.min(d,f),5),m=0;t>=p-3&&(m=Math.max(Math.min(t-p+3,n.length-p),0));let h=p<n.length&&m>0,g=p<n.length&&m+p<n.length,_=Math.min(m+p,n.length),v=[],y=0;h&&y++,g&&y++;let b=m+(h?1:0),x=_-(g?1:0);for(let e=b;e<x;e++){let i=ft(r(n[e],e===t),c,{hard:!0,trim:!1}).split(`
26
+ `);v.push(i),y+=i.length}if(y>f){let e=0,n=0,r=y,i=t-b,a=(e,t)=>pt(v,r,e,t,f);h?({lineCount:r,removals:e}=a(0,i),r>f&&({lineCount:r,removals:n}=a(i+1,v.length))):({lineCount:r,removals:n}=a(i+1,v.length),r>f&&({lineCount:r,removals:e}=a(0,i))),e>0&&(h=!0,v.splice(0,e)),n>0&&(g=!0,v.splice(v.length-n,n))}let S=[];h&&S.push(u);for(let e of v)for(let t of e)S.push(t);return g&&S.push(u),S},ht=e=>{let t=e.active??`Yes`,n=e.inactive??`No`;return new ke({active:t,inactive:n,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let r=e.withGuide??N.withGuide,i=`${r?`${T.default.gray(B)}
27
+ `:``}${U(this.state)} ${e.message}
28
+ `,a=this.value?t:n;switch(this.state){case`submit`:return`${i}${r?`${T.default.gray(B)} `:``}${T.default.dim(a)}`;case`cancel`:return`${i}${r?`${T.default.gray(B)} `:``}${T.default.strikethrough(T.default.dim(a))}${r?`
29
+ ${T.default.gray(B)}`:``}`;default:{let a=r?`${T.default.cyan(B)} `:``,o=r?T.default.cyan(V):``;return`${i}${a}${this.value?`${T.default.green(Be)} ${t}`:`${T.default.dim(H)} ${T.default.dim(t)}`}${e.vertical?r?`
30
+ ${T.default.cyan(B)} `:`
31
+ `:` ${T.default.dim(`/`)} `}${this.value?`${T.default.dim(H)} ${T.default.dim(n)}`:`${T.default.green(Be)} ${n}`}
32
+ ${o}
33
+ `}}}}).prompt()},gt=e=>{let{selectableGroups:t=!0,groupSpacing:n=0}=e,r=(e,r,i=[])=>{let a=e.label??String(e.value),o=typeof e.group==`string`,s=o&&(i[i.indexOf(e)+1]??{group:!0}),c=o&&s&&s.group===!0,l=o?t?`${c?V:B} `:` `:``,u=``;if(n>0&&!o){let e=`
34
+ ${T.default.cyan(B)}`;u=`${e.repeat(n-1)}${e} `}if(r===`active`)return`${u}${T.default.dim(l)}${T.default.cyan(Ve)} ${a}${e.hint?` ${T.default.dim(`(${e.hint})`)}`:``}`;if(r===`group-active`)return`${u}${l}${T.default.cyan(Ve)} ${T.default.dim(a)}`;if(r===`group-active-selected`)return`${u}${l}${T.default.green(He)} ${T.default.dim(a)}`;if(r===`selected`){let n=o||t?T.default.green(He):``;return`${u}${T.default.dim(l)}${n} ${T.default.dim(a)}${e.hint?` ${T.default.dim(`(${e.hint})`)}`:``}`}if(r===`cancelled`)return`${T.default.strikethrough(T.default.dim(a))}`;if(r===`active-selected`)return`${u}${T.default.dim(l)}${T.default.green(He)} ${a}${e.hint?` ${T.default.dim(`(${e.hint})`)}`:``}`;if(r===`submitted`)return`${T.default.dim(a)}`;let d=o||t?T.default.dim(Ue):``;return`${u}${T.default.dim(l)}${d} ${T.default.dim(a)}`},i=e.required??!0;return new Ae({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:i,cursorAt:e.cursorAt,selectableGroups:t,validate(e){if(i&&(e===void 0||e.length===0))return`Please select at least one option.
35
+ ${T.default.reset(T.default.dim(`Press ${T.default.gray(T.default.bgWhite(T.default.inverse(` space `)))} to select, ${T.default.gray(T.default.bgWhite(T.default.inverse(` enter `)))} to submit`))}`},render(){let t=`${T.default.gray(B)}
36
+ ${U(this.state)} ${e.message}
37
+ `,n=this.value??[];switch(this.state){case`submit`:{let e=this.options.filter(({value:e})=>n.includes(e)).map(e=>r(e,`submitted`)),i=e.length===0?``:` ${e.join(T.default.dim(`, `))}`;return`${t}${T.default.gray(B)}${i}`}case`cancel`:{let e=this.options.filter(({value:e})=>n.includes(e)).map(e=>r(e,`cancelled`)).join(T.default.dim(`, `));return`${t}${T.default.gray(B)} ${e.trim()?`${e}
38
+ ${T.default.gray(B)}`:``}`}case`error`:{let e=this.error.split(`
39
+ `).map((e,t)=>t===0?`${T.default.yellow(V)} ${T.default.yellow(e)}`:` ${e}`).join(`
40
+ `);return`${t}${T.default.yellow(B)} ${this.options.map((e,t,i)=>{let a=n.includes(e.value)||e.group===!0&&this.isGroupSelected(`${e.value}`),o=t===this.cursor;return!o&&typeof e.group==`string`&&this.options[this.cursor].value===e.group?r(e,a?`group-active-selected`:`group-active`,i):o&&a?r(e,`active-selected`,i):a?r(e,`selected`,i):r(e,o?`active`:`inactive`,i)}).join(`
41
+ ${T.default.yellow(B)} `)}
42
+ ${e}
43
+ `}default:{let e=this.options.map((e,t,i)=>{let a=n.includes(e.value)||e.group===!0&&this.isGroupSelected(`${e.value}`),o=t===this.cursor,s=!o&&typeof e.group==`string`&&this.options[this.cursor].value===e.group,c=``;return c=s?r(e,a?`group-active-selected`:`group-active`,i):o&&a?r(e,`active-selected`,i):a?r(e,`selected`,i):r(e,o?`active`:`inactive`,i),`${t!==0&&!c.startsWith(`
44
+ `)?` `:``}${c}`}).join(`
45
+ ${T.default.cyan(B)}`),i=e.startsWith(`
46
+ `)?``:` `;return`${t}${T.default.cyan(B)}${i}${e}
47
+ ${T.default.cyan(V)}
48
+ `}}}}).prompt()},Y={message:(e=[],{symbol:t=T.default.gray(B),secondarySymbol:n=T.default.gray(B),output:r=process.stdout,spacing:i=1,withGuide:a}={})=>{let o=[],s=a??N.withGuide,c=s?n:``,l=s?`${t} `:``,u=s?`${n} `:``;for(let e=0;e<i;e++)o.push(c);let d=Array.isArray(e)?e:e.split(`
49
+ `);if(d.length>0){let[e,...r]=d;e.length>0?o.push(`${l}${e}`):o.push(s?t:``);for(let e of r)e.length>0?o.push(`${u}${e}`):o.push(s?n:``)}r.write(`${o.join(`
50
+ `)}
51
+ `)},info:(e,t)=>{Y.message(e,{...t,symbol:T.default.blue(We)})},success:(e,t)=>{Y.message(e,{...t,symbol:T.default.green(Ge)})},step:(e,t)=>{Y.message(e,{...t,symbol:T.default.green(z)})},warn:(e,t)=>{Y.message(e,{...t,symbol:T.default.yellow(Ke)})},warning:(e,t)=>{Y.warn(e,t)},error:(e,t)=>{Y.message(e,{...t,symbol:T.default.red(qe)})}},X=(e=``,t)=>{(t?.output??process.stdout).write(`${T.default.gray(V)} ${T.default.red(e)}
52
+
53
+ `)},_t=(e=``,t)=>{(t?.output??process.stdout).write(`${T.default.gray(ze)} ${e}
54
+ `)},vt=(e=``,t)=>{(t?.output??process.stdout).write(`${T.default.gray(B)}
55
+ ${T.default.gray(V)} ${e}
56
+
57
+ `)},yt=T.default.magenta,bt=({indicator:e=`dots`,onCancel:t,output:n=process.stdout,cancelMessage:r,errorMessage:i,frames:a=Pe?[`◒`,`◐`,`◓`,`◑`]:[`•`,`o`,`O`,`0`],delay:o=Pe?80:120,signal:s,...c}={})=>{let l=Fe(),u,d,f=!1,p=!1,m=``,h,g=performance.now(),_=I(n),v=c?.styleFrame??yt,y=e=>{let n=e>1?i??N.messages.error:r??N.messages.cancel;p=e===1,f&&(D(n,e),p&&typeof t==`function`&&t())},b=()=>y(2),x=()=>y(1),S=()=>{process.on(`uncaughtExceptionMonitor`,b),process.on(`unhandledRejection`,b),process.on(`SIGINT`,x),process.on(`SIGTERM`,x),process.on(`exit`,y),s&&s.addEventListener(`abort`,x)},C=()=>{process.removeListener(`uncaughtExceptionMonitor`,b),process.removeListener(`unhandledRejection`,b),process.removeListener(`SIGINT`,x),process.removeListener(`SIGTERM`,x),process.removeListener(`exit`,y),s&&s.removeEventListener(`abort`,x)},w=()=>{if(h===void 0)return;l&&n.write(`
58
+ `);let e=ft(h,_,{hard:!0,trim:!1}).split(`
59
+ `);e.length>1&&n.write(E.cursor.up(e.length-1)),n.write(E.cursor.to(0)),n.write(E.erase.down())},ee=e=>e.replace(/\.+$/,``),te=e=>{let t=(performance.now()-e)/1e3,n=Math.floor(t/60),r=Math.floor(t%60);return n>0?`[${n}m ${r}s]`:`[${r}s]`},ne=c.withGuide??N.withGuide,re=(t=``)=>{f=!0,u=Ee({output:n}),m=ee(t),g=performance.now(),ne&&n.write(`${T.default.gray(B)}
60
+ `);let r=0,i=0;S(),d=setInterval(()=>{if(l&&m===h)return;w(),h=m;let t=v(a[r]),o;if(l)o=`${t} ${m}...`;else if(e===`timer`)o=`${t} ${m} ${te(g)}`;else{let e=`.`.repeat(Math.floor(i)).slice(0,3);o=`${t} ${m}${e}`}let s=ft(o,_,{hard:!0,trim:!1});n.write(s),r=r+1<a.length?r+1:0,i=i<4?i+.125:0},o)},D=(t=``,r=0,i=!1)=>{if(!f)return;f=!1,clearInterval(d),w();let a=r===0?T.default.green(z):r===1?T.default.red(Le):T.default.red(Re);m=t??m,i||(e===`timer`?n.write(`${a} ${m} ${te(g)}
61
+ `):n.write(`${a} ${m}
62
+ `)),C(),u()};return{start:re,stop:(e=``)=>D(e,0),message:(e=``)=>{m=ee(e??m)},cancel:(e=``)=>D(e,1),error:(e=``)=>D(e,2),clear:()=>D(``,0,!0),get isCancelled(){return p}}},Z=(e,t)=>e.includes(`
63
+ `)?e.split(`
64
+ `).map(e=>t(e)).join(`
65
+ `):t(e),xt=e=>{let t=(e,t)=>{let n=e.label??String(e.value);switch(t){case`disabled`:return`${T.default.gray(H)} ${Z(n,T.default.gray)}${e.hint?` ${T.default.dim(`(${e.hint??`disabled`})`)}`:``}`;case`selected`:return`${Z(n,T.default.dim)}`;case`active`:return`${T.default.green(Be)} ${n}${e.hint?` ${T.default.dim(`(${e.hint})`)}`:``}`;case`cancelled`:return`${Z(n,e=>T.default.strikethrough(T.default.dim(e)))}`;default:return`${T.default.dim(H)} ${Z(n,T.default.dim)}`}};return new je({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let n=e.withGuide??N.withGuide,r=`${U(this.state)} `,i=`${Je(this.state)} `,a=Oe(e.output,e.message,i,r),o=`${n?`${T.default.gray(B)}
66
+ `:``}${a}
67
+ `;switch(this.state){case`submit`:{let r=n?`${T.default.gray(B)} `:``;return`${o}${Oe(e.output,t(this.options[this.cursor],`selected`),r)}`}case`cancel`:{let r=n?`${T.default.gray(B)} `:``;return`${o}${Oe(e.output,t(this.options[this.cursor],`cancelled`),r)}${n?`
68
+ ${T.default.gray(B)}`:``}`}default:{let r=n?`${T.default.cyan(B)} `:``,i=n?T.default.cyan(V):``,a=o.split(`
69
+ `).length,s=n?2:1;return`${o}${r}${mt({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:r.length,rowPadding:a+s,style:(e,n)=>t(e,e.disabled?`disabled`:n?`active`:`inactive`)}).join(`
70
+ ${r}`)}
71
+ ${i}
72
+ `}}}}).prompt()},St=`${T.default.gray(B)} `,Q={message:async(e,{symbol:t=T.default.gray(B)}={})=>{process.stdout.write(`${T.default.gray(B)}
73
+ ${t} `);let n=3;for await(let t of e){t=t.replace(/\n/g,`
74
+ ${St}`),t.includes(`
75
+ `)&&(n=3+h(t.slice(t.lastIndexOf(`
76
+ `))).length);let e=h(t).length;n+e<process.stdout.columns?(n+=e,process.stdout.write(t)):(process.stdout.write(`
77
+ ${St}${t.trimStart()}`),n=3+h(t.trimStart()).length)}process.stdout.write(`
78
+ `)},info:e=>Q.message(e,{symbol:T.default.blue(We)}),success:e=>Q.message(e,{symbol:T.default.green(Ge)}),step:e=>Q.message(e,{symbol:T.default.green(z)}),warn:e=>Q.message(e,{symbol:T.default.yellow(Ke)}),warning:e=>Q.warn(e),error:e=>Q.message(e,{symbol:T.default.red(qe)})},Ct=e=>new Me({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){let t=e?.withGuide??N.withGuide,n=`${`${t?`${T.default.gray(B)}
79
+ `:``}${U(this.state)} `}${e.message}
80
+ `,r=e.placeholder?T.default.inverse(e.placeholder[0])+T.default.dim(e.placeholder.slice(1)):T.default.inverse(T.default.hidden(`_`)),i=this.userInput?this.userInputWithCursor:r,a=this.value??``;switch(this.state){case`error`:{let e=this.error?` ${T.default.yellow(this.error)}`:``,r=t?`${T.default.yellow(B)} `:``,a=t?T.default.yellow(V):``;return`${n.trim()}
81
+ ${r}${i}
82
+ ${a}${e}
83
+ `}case`submit`:{let e=a?` ${T.default.dim(a)}`:``;return`${n}${t?T.default.gray(B):``}${e}`}case`cancel`:{let e=a?` ${T.default.strikethrough(T.default.dim(a))}`:``,r=t?T.default.gray(B):``;return`${n}${r}${e}${a.trim()?`
84
+ ${r}`:``}`}default:return`${n}${t?`${T.default.cyan(B)} `:``}${i}
85
+ ${t?T.default.cyan(V):``}
86
+ `}}}).prompt();function wt(e,t){let n=Et(e,1e4),r=!!e.trim(),i=[`You are a git commit message generator. Your ONLY output is a commit message — nothing else.`,``,`RECENT COMMIT HISTORY FROM THIS REPO:`,"```",r?n:`(no history — new repo)`,"```",``];return r||i.push(`Since this is a new repo with no commit history, use this default style:`,`- Conventional commits format (feat:, fix:, chore:, docs:, refactor:, etc.)`,`- Imperative mood, lowercase after prefix`,`- Subject line followed by an optional body with 1-3 bullet points summarizing key changes`,`- Only include body bullets when the diff warrants it — don't add filler`,``),i.push(`INSTRUCTIONS:`,`1. Study the commit history above carefully. Notice the format, conventions, tone, and style.`,` - Do they use conventional commits (feat:, fix:, etc.)?`,` - Gitmoji? Ticket prefixes? Brackets?`,` - Imperative mood or past tense?`,` - Capitalized or lowercase?`,` - Subject-only, or subject + body?`,` - What level of detail?`,`2. Generate a commit message for the staged changes that **matches the repo's existing style exactly**.`,`3. Do NOT invent issue/ticket numbers unless they appear in the diff.`,`4. If the style uses a subject + body format, separate them with a blank line.`,` Wrap body lines at 72 characters.`,`5. When the repo has no established style, default to conventional commits (feat:, fix:, chore:, etc.)`,` with an optional body of 1-3 concise bullet points. Only include bullets when the changes are`,` complex enough to warrant them — do not pad with filler.`,`6. Disregard generated files (lockfiles, migration files, build output, etc.) when evaluating changes.`,` Focus on the human-authored source changes to determine the commit message.`,`7. NEVER add "Co-authored-by", "Signed-off-by", or any git trailers to the commit message.`),t&&i.push(``,`ADDITIONAL USER INSTRUCTIONS:`,t),i.push(``,`REMINDER: Output ONLY the raw commit message text. No quotes, no markdown fences, no explanation, no preamble.`),i.join(`
87
+ `)}function Tt(e,t,n){let r=Dt(e,15e3);return[`Generate a commit message for these staged changes:`,``,`Files changed:`,n.join(`
88
+ `),``,`Diff stat:`,t,``,`Full diff:`,r].join(`
89
+ `)}function Et(e,t){return e.length<=t?e:`${e.slice(0,t)}\n\n[... truncated ...]`}function Dt(e,t){if(e.length<=t)return e;let n=e.split(/(?=^diff --git )/m),r=``;for(let e of n){if(r.length+e.length>t){let n=e.split(/(?=^@@ )/m);for(let e of n){if(r.length+e.length>t)break;r+=e}break}r+=e}return r.length<e.length&&(r+=`
90
+
91
+ [... diff truncated — stat summary above covers all files ...]`),r}const Ot={claude:{name:`Claude`,bin:`claude`,versionArgs:[`--version`],defaultModel:`sonnet`,buildArgs({userPrompt:e,systemPrompt:t,model:n}){return[`-p`,e,`--output-format`,`json`,`--model`,n,`--tools`,``,`--no-session-persistence`,`--system-prompt`,t]},parseOutput(e){let t;try{t=JSON.parse(e)}catch{throw Error(`Failed to parse Claude response as JSON. Raw output:\n${e.slice(0,500)}`)}if(t.is_error)throw Error(`Claude error: ${t.result}`);let n=(t.result||``).trim();if(!n)throw Error(`Claude returned an empty commit message.`);return n}},codex:{name:`Codex`,bin:`codex`,versionArgs:[`--version`],defaultModel:`gpt-5.1-codex-mini`,buildArgs({userPrompt:e,systemPrompt:t,model:n}){return[`exec`,e,`--model`,n,`-c`,`developer_instructions=${t}`,`-c`,`model_reasoning_effort=medium`,`--ephemeral`,`--sandbox`,`read-only`]},parseOutput(e){let t=e.trim();if(!t)throw Error(`Codex returned an empty commit message.`);return t}}};async function kt(e){if(!await new Promise(t=>{let n=g(e.bin,e.versionArgs,{stdio:[`ignore`,`ignore`,`ignore`]});n.on(`error`,()=>t(!1)),n.on(`close`,e=>t(e===0))}))throw Error(`${e.name} CLI ("${e.bin}") not found. Make sure it is installed and on your PATH.`)}async function At(e,t){let{diff:n,stat:r,files:i,commitLog:a,model:o,instructions:s}=t,c=wt(a,s),l=Tt(n,r,i),u=e.buildArgs({userPrompt:l,systemPrompt:c,model:o}),{stdout:d,stderr:f,code:p}=await new Promise((t,n)=>{let r=g(e.bin,u,{stdio:[`ignore`,`pipe`,`pipe`]}),i=``,a=``;r.stdout.on(`data`,e=>{i+=e}),r.stderr.on(`data`,e=>{a+=e}),r.on(`error`,n),r.on(`close`,e=>t({stdout:i,stderr:a,code:e}))});if(p!==0)throw Error(`${e.name} exited with code ${p}\n${f||d}`);return e.parseOutput(d)}const jt=`claude`,Mt={provider:{type:`string`,short:`p`},model:{type:`string`,short:`m`},yolo:{type:`boolean`,short:`y`},help:{type:`boolean`,short:`h`}};function Nt(){let{values:e}=m({args:process.argv.slice(2),options:Mt,strict:!1});return{provider:e.provider??process.env.ACAI_PROVIDER??jt,model:e.model??process.env.ACAI_MODEL??``,yolo:e.yolo??!1,help:e.help??!1}}function Pt(){let e=Object.keys(Ot).join(`, `);console.log(`
92
+ Usage: acai [options]
93
+
94
+ Options:
95
+ -p, --provider <name> AI provider to use (${e}) (default: ${jt})
96
+ Can also set ACAI_PROVIDER env var
97
+ -m, --model <model> Model to use (default: provider-specific)
98
+ Can also set ACAI_MODEL env var
99
+ -y, --yolo Stage all changes and commit without confirmation
100
+ -h, --help Show this help message
101
+
102
+ Examples:
103
+ acai # use Claude with default model
104
+ acai -p codex # use OpenAI Codex CLI
105
+ acai -p codex -m o4-mini # use Codex with specific model
106
+ acai --model haiku # use Claude with haiku for speed
107
+ acai -m opus # use Claude with opus for max quality
108
+ `.trimStart())}async function $(e,t){let[n,...r]=e;return new Promise(e=>{let i=g(n,r,{cwd:t?.cwd,stdio:[`ignore`,`pipe`,`pipe`]}),a=``;i.stdout.on(`data`,e=>{a+=e}),i.on(`error`,()=>e(null)),i.on(`close`,n=>{e(n===0?t?.raw?a:a.trim():null)})})}async function Ft(e,t){let n=await $(e,t);if(n===null)throw Error(`Command failed: ${e.join(` `)}`);return n}async function It(){if(await $([`git`,`rev-parse`,`--is-inside-work-tree`])!==`true`)throw Error(`Not inside a git repository.`)}async function Lt(){return $([`git`,`diff`,`--cached`])}async function Rt(){return $([`git`,`diff`,`--cached`,`--stat`])}async function zt(){let e=await $([`git`,`diff`,`--cached`,`--name-only`]);return e?e.split(`
109
+ `).filter(Boolean):[]}async function Bt(){let e=await $([`git`,`status`,`--porcelain`,`-z`],{raw:!0});if(!e)return[];let t=[],n=e.split(`\0`);for(let e=0;e<n.length;e++){let r=n[e];if(!r||r.length<4)continue;let i=r[0],a=r[1],o=r.slice(3);i===`R`&&e++,r[0]===`?`&&r[1]===`?`?t.push({path:o,status:`untracked`}):a===`D`?t.push({path:o,status:`deleted`}):(a===`M`||a===`A`)&&t.push({path:o,status:`modified`})}return t}async function Vt(){await Ft([`git`,`add`,`-A`])}async function Ht(e){e.length!==0&&await Ft([`git`,`add`,`--`,...e])}async function Ut(e=10){return $([`git`,`log`,`--format=%s%n%b%n---`,`-n`,String(e),`--no-merges`])}async function Wt(e){let t=c(p(_(),`acai-`)),n=p(t,`commit-msg.txt`);d(n,e,`utf-8`);try{await Ft([`git`,`commit`,`-F`,n])}finally{try{u(t,{recursive:!0})}catch{}}}async function Gt(){let e=Nt();e.help&&(Pt(),process.exit(0));let t=Ot[e.provider];if(!t){let t=Object.keys(Ot).join(`, `);console.error(`Unknown provider "${e.provider}". Available: ${t}`),process.exit(1)}let n=e.model||t.defaultModel;_t(`acai`);let r=bt();try{await It()}catch{X(`Not a git repository.`),process.exit(1)}try{await kt(t)}catch(e){X(e.message),process.exit(1)}let i=await Lt();if(!i){let t=await Bt();if(t.length===0&&(X(`Nothing to commit — working tree clean.`),process.exit(0)),e.yolo)await Vt();else{let e=await ht({message:`Stage all changes?`,initialValue:!0});P(e)&&(X(`Aborted.`),process.exit(0)),e?await Vt():await Kt(t,`Select files to stage`)||(X(`Nothing staged.`),process.exit(0))}i=await Lt(),i||(X(`Still no diff after staging. Nothing to commit.`),process.exit(0))}if(!e.yolo){let e=await Bt();if(e.length>0){let t=await ht({message:`${e.length} other changed file${e.length===1?``:`s`} not staged. Add more?`,initialValue:!1});P(t)&&(X(`Aborted.`),process.exit(0)),t&&(await Kt(e,`Select additional files to stage`),i=await Lt())}}let a=await Rt()||``,o=await zt(),s=o.slice(0,5).join(`, `),c=o.length>5?` and ${o.length-5} more`:``;Y.info(`Staged ${o.length} file${o.length===1?``:`s`}: ${T.default.dim(s+c)}`);let l=await Ut(10)||``,u;for(;;){r.start(`Waiting for ${t.name}`);let s;try{s=await At(t,{diff:i,stat:a,files:o,commitLog:l,model:n,instructions:u})}catch(e){r.stop(`Failed`),X(`Generation failed: ${e.message}`),process.exit(1)}if(r.stop(`Here's what ${t.name} ${T.default.dim(`(${n})`)} came up with:`),Y.message(Jt(s)),e.yolo){await qt(s);break}let c=await xt({message:`What should we do?`,options:[{value:`commit`,label:`✓ Commit`},{value:`edit`,label:`✎ Edit`,hint:`open in editor and commit on save`},{value:`revise`,label:`↻ Revise`,hint:`give ${t.name} feedback and try again`},{value:`copy`,label:`⎘ Copy`,hint:`copy message to clipboard and exit`},{value:`cancel`,label:`✕ Cancel`}]});if((P(c)||c===`cancel`)&&(X(`Aborted.`),process.exit(0)),c===`commit`){await qt(s);break}if(c===`edit`){let e=await Yt(s);if(e?.trim())await qt(e.trim());else{Y.warn(`Empty message after editing — not committing.`);continue}break}if(c===`copy`&&(await Xt(s),vt(`Copied to clipboard.`),process.exit(0)),c===`revise`){let e=await Ct({message:`What should ${t.name} change?`,placeholder:`e.g. make it shorter, mention the API refactor, use past tense…`});if(P(e)||!e)continue;u=`The user wants you to revise the message. Previous attempt was:\n\`\`\`\n${s}\n\`\`\`\nUser feedback: ${e}`}}}async function Kt(e,t){let n={modified:`Modified`,untracked:`Untracked`,deleted:`Deleted`},r={};for(let t of e){let e=n[t.status];r[e]??=[],r[e].push({value:t.path,label:t.path})}let i=await gt({message:t,options:r});return P(i)||i.length===0?!1:(await Ht(i),!0)}async function qt(e){let t=bt();t.start(`Committing`);try{await Wt(e),t.stop(`Committed!`)}catch(e){t.stop(`Failed`),X(`Commit failed: ${e.message}`),process.exit(1)}}function Jt(e){let t=e.split(`
110
+ `),n=t[0],r=t.slice(1).join(`
111
+ `).trim(),i=T.default.bold(T.default.green(n));return r&&(i+=`\n${T.default.dim(r)}`),i}async function Yt(e){let{spawn:t}=await import(`child_process`),{writeFileSync:n,readFileSync:r,mkdtempSync:i,rmSync:a}=await import(`fs`),{join:o}=await import(`path`),{tmpdir:s}=await import(`os`),c=process.env.EDITOR||process.env.VISUAL||`vi`,l=i(o(s(),`acai-`)),u=o(l,`COMMIT_EDITMSG`);n(u,e,`utf-8`);try{return await new Promise((e,n)=>{let r=t(c,[u],{stdio:`inherit`,shell:!0});r.on(`error`,n),r.on(`close`,e)})===0?r(u,`utf-8`):null}finally{try{a(l,{recursive:!0})}catch{}}}async function Xt(e){let{spawn:t}=await import(`child_process`);for(let[n,...r]of[[`pbcopy`],[`xclip`,`-selection`,`clipboard`],[`xsel`,`--clipboard`,`--input`],[`wl-copy`]])if(await new Promise(i=>{let a=t(n,r,{stdio:[`pipe`,`ignore`,`ignore`]});a.on(`error`,()=>i(!1)),a.stdin.write(e),a.stdin.end(),a.on(`close`,e=>i(e===0))}))return;Y.warn(`Couldn't copy to clipboard. Here's the raw message:`),console.log(e)}Gt().catch(e=>{X(e.message),process.exit(1)});export{};
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@jakejarvis/acai",
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "description": "Yet another AI commit message generator",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/jakejarvis/acai.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/jakejarvis/acai/issues"
12
+ },
13
+ "author": {
14
+ "name": "Jake Jarvis",
15
+ "email": "jake@jarv.is",
16
+ "url": "https://jarv.is"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "type": "module",
22
+ "bin": {
23
+ "acai": "./dist/cli.mjs"
24
+ },
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "scripts": {
29
+ "build": "tsdown",
30
+ "lint": "biome check",
31
+ "format": "biome format --write",
32
+ "check-types": "tsc --noEmit",
33
+ "prepublishOnly": "npm run build"
34
+ },
35
+ "devDependencies": {
36
+ "@biomejs/biome": "2.4.4",
37
+ "@clack/prompts": "1.0.1",
38
+ "@types/node": "^25.3.2",
39
+ "picocolors": "1.1.1",
40
+ "tsdown": "^0.20.3",
41
+ "typescript": "^5.9.3"
42
+ },
43
+ "engines": {
44
+ "node": ">=18.19"
45
+ },
46
+ "keywords": [
47
+ "git",
48
+ "commit",
49
+ "ai",
50
+ "claude",
51
+ "codex"
52
+ ]
53
+ }