@gilbert_oliveira/commit-wizard 2.0.2 → 2.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.
- package/README.md +13 -14
- package/dist/commit-wizard.d.ts +1 -0
- package/dist/commit-wizard.js +52 -110
- package/package.json +29 -26
- package/{bin → src/bin}/commit-wizard.ts +6 -5
- package/src/core/cache.ts +2 -2
- package/src/core/index.ts +15 -11
- package/src/core/openai.ts +30 -12
- package/src/core/smart-split.ts +72 -48
- package/src/git/index.ts +16 -4
- package/src/ui/index.ts +1 -1
- package/src/ui/smart-split.ts +1 -1
- package/src/utils/polyfill.ts +0 -82
package/dist/commit-wizard.js
CHANGED
|
@@ -1,71 +1,19 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
`).split(
|
|
5
|
-
|
|
6
|
-
`)}function OI(b,I){if(typeof b=="string")return N1.aliases.get(b)===I;for(let $ of b)if($!==void 0&&OI($,I))return!0;return!1}function W4(b,I){if(b===I)return;let $=b.split(`
|
|
7
|
-
`),H=I.split(`
|
|
8
|
-
`),Y=[];for(let X=0;X<Math.max($.length,H.length);X++)$[X]!==H[X]&&Y.push(X);return Y}function P(b){return b===r1}function S1(b,I){let $=b;$.isTTY&&$.setRawMode(I)}class j1{constructor(b,I=!0){E(this,"input"),E(this,"output"),E(this,"_abortSignal"),E(this,"rl"),E(this,"opts"),E(this,"_render"),E(this,"_track",!1),E(this,"_prevFrame",""),E(this,"_subscribers",new Map),E(this,"_cursor",0),E(this,"state","initial"),E(this,"error",""),E(this,"value");let{input:$=i9,output:H=r9,render:Y,signal:X,...G}=b;this.opts=G,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=Y.bind(this),this._track=I,this._abortSignal=X,this.input=$,this.output=H}unsubscribe(){this._subscribers.clear()}setSubscriber(b,I){let $=this._subscribers.get(b)??[];$.push(I),this._subscribers.set(b,$)}on(b,I){this.setSubscriber(b,{cb:I})}once(b,I){this.setSubscriber(b,{cb:I,once:!0})}emit(b,...I){let $=this._subscribers.get(b)??[],H=[];for(let Y of $)Y.cb(...I),Y.once&&H.push(()=>$.splice($.indexOf(Y),1));for(let Y of H)Y()}prompt(){return new Promise((b,I)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),b(r1);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}let $=new t9;$._write=(H,Y,X)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,""),this._cursor=this.rl?.cursor??0,this.emit("value",this.value)),X()},this.input.pipe($),this.rl=UI.createInterface({input:this.input,output:$,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),UI.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),S1(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(y.cursor.show),this.output.off("resize",this.render),S1(this.input,!1),b(this.value)}),this.once("cancel",()=>{this.output.write(y.cursor.show),this.output.off("resize",this.render),S1(this.input,!1),b(r1)})})}onKeypress(b,I){if(this.state==="error"&&(this.state="active"),I?.name&&(!this._track&&N1.aliases.has(I.name)&&this.emit("cursor",N1.aliases.get(I.name)),N1.actions.has(I.name)&&this.emit("cursor",I.name)),b&&(b.toLowerCase()==="y"||b.toLowerCase()==="n")&&this.emit("confirm",b.toLowerCase()==="y"),b==="\t"&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),b&&this.emit("key",b.toLowerCase()),I?.name==="return"){if(this.opts.validate){let $=this.opts.validate(this.value);$&&(this.error=$ instanceof Error?$.message:$,this.state="error",this.rl?.write(this.value))}this.state!=="error"&&(this.state="submit")}OI([b,I?.name,I?.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(`
|
|
9
|
-
`),S1(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let b=KI(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
|
|
10
|
-
`).length-1;this.output.write(y.cursor.move(-999,b*-1))}render(){let b=KI(this._render(this)??"",process.stdout.columns,{hard:!0});if(b!==this._prevFrame){if(this.state==="initial")this.output.write(y.cursor.hide);else{let I=W4(this._prevFrame,b);if(this.restoreCursor(),I&&I?.length===1){let $=I[0];this.output.write(y.cursor.move(0,$)),this.output.write(y.erase.lines(1));let H=b.split(`
|
|
11
|
-
`);this.output.write(H[$]),this._prevFrame=b,this.output.write(y.cursor.move(0,H.length-$-1));return}if(I&&I?.length>1){let $=I[0];this.output.write(y.cursor.move(0,$)),this.output.write(y.erase.down());let H=b.split(`
|
|
12
|
-
`).slice($);this.output.write(H.join(`
|
|
13
|
-
`)),this._prevFrame=b;return}this.output.write(y.erase.down())}this.output.write(b),this.state==="initial"&&(this.state="active"),this._prevFrame=b}}}var y,TI,s9,_I,e9,b4,I4=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},G4,a1=10,VI=(b=0)=>(I)=>`\x1B[${I+b}m`,WI=(b=0)=>(I)=>`\x1B[${38+b};5;${I}m`,zI=(b=0)=>(I,$,H)=>`\x1B[${38+b};2;${I};${$};${H}m`,L,$4,H4,X4,K1,Z4=39,t1="\x07",MI="[",J4="]",AI="m",o1,SI=(b)=>`${K1.values().next().value}${MI}${b}${AI}`,NI=(b)=>`${K1.values().next().value}${o1}${b}${t1}`,q4=(b)=>b.split(" ").map((I)=>b1(I)),i1=(b,I,$)=>{let H=[...I],Y=!1,X=!1,G=b1(LI(b[b.length-1]));for(let[Z,J]of H.entries()){let q=b1(J);if(G+q<=$?b[b.length-1]+=J:(b.push(J),G=0),K1.has(J)&&(Y=!0,X=H.slice(Z+1).join("").startsWith(o1)),Y){X?J===t1&&(Y=!1,X=!1):J===AI&&(Y=!1);continue}G+=q,G===$&&Z<H.length-1&&(b.push(""),G=0)}!G&&b[b.length-1].length>0&&b.length>1&&(b[b.length-2]+=b.pop())},Q4=(b)=>{let I=b.split(" "),$=I.length;for(;$>0&&!(b1(I[$-1])>0);)$--;return $===I.length?b:I.slice(0,$).join(" ")+I.slice($).join("")},U4=(b,I,$={})=>{if($.trim!==!1&&b.trim()==="")return"";let H="",Y,X,G=q4(b),Z=[""];for(let[q,Q]of b.split(" ").entries()){$.trim!==!1&&(Z[Z.length-1]=Z[Z.length-1].trimStart());let W=b1(Z[Z.length-1]);if(q!==0&&(W>=I&&($.wordWrap===!1||$.trim===!1)&&(Z.push(""),W=0),(W>0||$.trim===!1)&&(Z[Z.length-1]+=" ",W++)),$.hard&&G[q]>I){let z=I-W,N=1+Math.floor((G[q]-z-1)/I);Math.floor((G[q]-1)/I)<N&&Z.push(""),i1(Z,Q,I);continue}if(W+G[q]>I&&W>0&&G[q]>0){if($.wordWrap===!1&&W<I){i1(Z,Q,I);continue}Z.push("")}if(W+G[q]>I&&$.wordWrap===!1){i1(Z,Q,I);continue}Z[Z.length-1]+=Q}$.trim!==!1&&(Z=Z.map((q)=>Q4(q)));let J=[...Z.join(`
|
|
14
|
-
`)];for(let[q,Q]of J.entries()){if(H+=Q,K1.has(Q)){let{groups:z}=new RegExp(`(?:\\${MI}(?<code>\\d+)m|\\${o1}(?<uri>.*)${t1})`).exec(J.slice(q).join(""))||{groups:{}};if(z.code!==void 0){let N=Number.parseFloat(z.code);Y=N===Z4?void 0:N}else z.uri!==void 0&&(X=z.uri.length===0?void 0:z.uri)}let W=X4.codes.get(Number(Y));J[q+1]===`
|
|
15
|
-
`?(X&&(H+=NI("")),Y&&W&&(H+=SI(W))):Q===`
|
|
16
|
-
`&&(Y&&W&&(H+=SI(Y)),X&&(H+=NI(X)))}return H},V4,N1,h$,r1,z4,S4=(b,I,$)=>(I in b)?z4(b,I,{enumerable:!0,configurable:!0,writable:!0,value:$}):b[I]=$,E=(b,I,$)=>(S4(b,typeof I!="symbol"?I+"":I,$),$),s1,N4,K4,j4=(b,I,$)=>(I in b)?K4(b,I,{enumerable:!0,configurable:!0,writable:!0,value:$}):b[I]=$,jI=(b,I,$)=>(j4(b,typeof I!="symbol"?I+"":I,$),$),e1,bb;var Ib=S(()=>{y=F(p1(),1),TI=F(l1(),1);s9=o9();_I={exports:{}};(function(b){var I={};b.exports=I,I.eastAsianWidth=function(H){var Y=H.charCodeAt(0),X=H.length==2?H.charCodeAt(1):0,G=Y;return 55296<=Y&&Y<=56319&&56320<=X&&X<=57343&&(Y&=1023,X&=1023,G=Y<<10|X,G+=65536),G==12288||65281<=G&&G<=65376||65504<=G&&G<=65510?"F":G==8361||65377<=G&&G<=65470||65474<=G&&G<=65479||65482<=G&&G<=65487||65490<=G&&G<=65495||65498<=G&&G<=65500||65512<=G&&G<=65518?"H":4352<=G&&G<=4447||4515<=G&&G<=4519||4602<=G&&G<=4607||9001<=G&&G<=9002||11904<=G&&G<=11929||11931<=G&&G<=12019||12032<=G&&G<=12245||12272<=G&&G<=12283||12289<=G&&G<=12350||12353<=G&&G<=12438||12441<=G&&G<=12543||12549<=G&&G<=12589||12593<=G&&G<=12686||12688<=G&&G<=12730||12736<=G&&G<=12771||12784<=G&&G<=12830||12832<=G&&G<=12871||12880<=G&&G<=13054||13056<=G&&G<=19903||19968<=G&&G<=42124||42128<=G&&G<=42182||43360<=G&&G<=43388||44032<=G&&G<=55203||55216<=G&&G<=55238||55243<=G&&G<=55291||63744<=G&&G<=64255||65040<=G&&G<=65049||65072<=G&&G<=65106||65108<=G&&G<=65126||65128<=G&&G<=65131||110592<=G&&G<=110593||127488<=G&&G<=127490||127504<=G&&G<=127546||127552<=G&&G<=127560||127568<=G&&G<=127569||131072<=G&&G<=194367||177984<=G&&G<=196605||196608<=G&&G<=262141?"W":32<=G&&G<=126||162<=G&&G<=163||165<=G&&G<=166||G==172||G==175||10214<=G&&G<=10221||10629<=G&&G<=10630?"Na":G==161||G==164||167<=G&&G<=168||G==170||173<=G&&G<=174||176<=G&&G<=180||182<=G&&G<=186||188<=G&&G<=191||G==198||G==208||215<=G&&G<=216||222<=G&&G<=225||G==230||232<=G&&G<=234||236<=G&&G<=237||G==240||242<=G&&G<=243||247<=G&&G<=250||G==252||G==254||G==257||G==273||G==275||G==283||294<=G&&G<=295||G==299||305<=G&&G<=307||G==312||319<=G&&G<=322||G==324||328<=G&&G<=331||G==333||338<=G&&G<=339||358<=G&&G<=359||G==363||G==462||G==464||G==466||G==468||G==470||G==472||G==474||G==476||G==593||G==609||G==708||G==711||713<=G&&G<=715||G==717||G==720||728<=G&&G<=731||G==733||G==735||768<=G&&G<=879||913<=G&&G<=929||931<=G&&G<=937||945<=G&&G<=961||963<=G&&G<=969||G==1025||1040<=G&&G<=1103||G==1105||G==8208||8211<=G&&G<=8214||8216<=G&&G<=8217||8220<=G&&G<=8221||8224<=G&&G<=8226||8228<=G&&G<=8231||G==8240||8242<=G&&G<=8243||G==8245||G==8251||G==8254||G==8308||G==8319||8321<=G&&G<=8324||G==8364||G==8451||G==8453||G==8457||G==8467||G==8470||8481<=G&&G<=8482||G==8486||G==8491||8531<=G&&G<=8532||8539<=G&&G<=8542||8544<=G&&G<=8555||8560<=G&&G<=8569||G==8585||8592<=G&&G<=8601||8632<=G&&G<=8633||G==8658||G==8660||G==8679||G==8704||8706<=G&&G<=8707||8711<=G&&G<=8712||G==8715||G==8719||G==8721||G==8725||G==8730||8733<=G&&G<=8736||G==8739||G==8741||8743<=G&&G<=8748||G==8750||8756<=G&&G<=8759||8764<=G&&G<=8765||G==8776||G==8780||G==8786||8800<=G&&G<=8801||8804<=G&&G<=8807||8810<=G&&G<=8811||8814<=G&&G<=8815||8834<=G&&G<=8835||8838<=G&&G<=8839||G==8853||G==8857||G==8869||G==8895||G==8978||9312<=G&&G<=9449||9451<=G&&G<=9547||9552<=G&&G<=9587||9600<=G&&G<=9615||9618<=G&&G<=9621||9632<=G&&G<=9633||9635<=G&&G<=9641||9650<=G&&G<=9651||9654<=G&&G<=9655||9660<=G&&G<=9661||9664<=G&&G<=9665||9670<=G&&G<=9672||G==9675||9678<=G&&G<=9681||9698<=G&&G<=9701||G==9711||9733<=G&&G<=9734||G==9737||9742<=G&&G<=9743||9748<=G&&G<=9749||G==9756||G==9758||G==9792||G==9794||9824<=G&&G<=9825||9827<=G&&G<=9829||9831<=G&&G<=9834||9836<=G&&G<=9837||G==9839||9886<=G&&G<=9887||9918<=G&&G<=9919||9924<=G&&G<=9933||9935<=G&&G<=9953||G==9955||9960<=G&&G<=9983||G==10045||G==10071||10102<=G&&G<=10111||11093<=G&&G<=11097||12872<=G&&G<=12879||57344<=G&&G<=63743||65024<=G&&G<=65039||G==65533||127232<=G&&G<=127242||127248<=G&&G<=127277||127280<=G&&G<=127337||127344<=G&&G<=127386||917760<=G&&G<=917999||983040<=G&&G<=1048573||1048576<=G&&G<=1114109?"A":"N"},I.characterLength=function(H){var Y=this.eastAsianWidth(H);return Y=="F"||Y=="W"||Y=="A"?2:1};function $(H){return H.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}I.length=function(H){for(var Y=$(H),X=0,G=0;G<Y.length;G++)X=X+this.characterLength(Y[G]);return X},I.slice=function(H,Y,X){textLen=I.length(H),Y=Y||0,X=X||1,Y<0&&(Y=textLen+Y),X<0&&(X=textLen+X);for(var G="",Z=0,J=$(H),q=0;q<J.length;q++){var Q=J[q],W=I.length(Q);if(Z>=Y-(W==2?1:0))if(Z+W<=X)G+=Q;else break;Z+=W}return G}})(_I);e9=_I.exports,b4=BI(e9),G4=BI(I4);L={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],gray:[90,39],grey:[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],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(L.modifier);$4=Object.keys(L.color),H4=Object.keys(L.bgColor);[...$4];X4=Y4(),K1=new Set(["\x1B","\x9B"]),o1=`${J4}8;;`;V4=["up","down","left","right","space","enter","cancel"],N1={actions:new Set(V4),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]])};h$=globalThis.process.platform.startsWith("win"),r1=Symbol("clack:cancel");z4=Object.defineProperty;s1=class s1 extends j1{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(b){super(b,!1),this.value=!!b.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",(I)=>{this.output.write(y.cursor.move(0,-1)),this.value=I,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};N4=new WeakMap;K4=Object.defineProperty;e1=class e1 extends j1{constructor(b){super(b,!1),jI(this,"options"),jI(this,"cursor",0),this.options=b.options,this.cursor=this.options.findIndex(({value:I})=>I===b.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",(I)=>{switch(I){case"left":case"up":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;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}};bb=class bb extends j1{get valueWithCursor(){if(this.state==="submit")return this.value;if(this.cursor>=this.value.length)return`${this.value}\u2588`;let b=this.value.slice(0,this.cursor),[I,...$]=this.value.slice(this.cursor);return`${b}${TI.default.inverse(I)}${$.join("")}`}get cursor(){return this._cursor}constructor(b){super(b),this.on("finalize",()=>{this.value||(this.value=b.defaultValue)})}}});import{stripVTControlCharacters as Gb}from"util";import v from"process";function T4(){return v.platform!=="win32"?v.env.TERM!=="linux":!!v.env.CI||!!v.env.WT_SESSION||!!v.env.TERMINUS_SUBLIME||v.env.ConEmuTask==="{cmd::Cmder}"||v.env.TERM_PROGRAM==="Terminus-Sublime"||v.env.TERM_PROGRAM==="vscode"||v.env.TERM==="xterm-256color"||v.env.TERM==="alacritty"||v.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var U,EI,L4,B=(b,I)=>L4?b:I,B4,_4,M4,Yb,A4,T,n,$b,Hb,a$,i$,r$,t$,RI,O4,R4,E4,y4,P4,x4,w4,Xb=(b)=>{switch(b){case"initial":case"active":return U.default.cyan(B4);case"cancel":return U.default.red(_4);case"error":return U.default.yellow(M4);case"submit":return U.default.green(Yb)}},k4=(b)=>{let{cursor:I,options:$,style:H}=b,Y=b.maxItems??Number.POSITIVE_INFINITY,X=Math.max(process.stdout.rows-4,0),G=Math.min(X,Math.max(Y,5)),Z=0;I>=Z+G-3?Z=Math.max(Math.min(I-G+3,$.length-G),0):I<Z+2&&(Z=Math.max(I-2,0));let J=G<$.length&&Z>0,q=G<$.length&&Z+G<$.length;return $.slice(Z,Z+G).map((Q,W,z)=>{let N=W===0&&J,j=W===z.length-1&&q;return N||j?U.default.dim("..."):H(Q,W+Z===I)})},yI=(b)=>new bb({validate:b.validate,placeholder:b.placeholder,defaultValue:b.defaultValue,initialValue:b.initialValue,render(){let I=`${U.default.gray(T)}
|
|
17
|
-
${Xb(this.state)} ${b.message}
|
|
18
|
-
`,$=b.placeholder?U.default.inverse(b.placeholder[0])+U.default.dim(b.placeholder.slice(1)):U.default.inverse(U.default.hidden("_")),H=this.value?this.valueWithCursor:$;switch(this.state){case"error":return`${I.trim()}
|
|
19
|
-
${U.default.yellow(T)} ${H}
|
|
20
|
-
${U.default.yellow(n)} ${U.default.yellow(this.error)}
|
|
21
|
-
`;case"submit":return`${I}${U.default.gray(T)} ${U.default.dim(this.value||b.placeholder)}`;case"cancel":return`${I}${U.default.gray(T)} ${U.default.strikethrough(U.default.dim(this.value??""))}${this.value?.trim()?`
|
|
22
|
-
${U.default.gray(T)}`:""}`;default:return`${I}${U.default.cyan(T)} ${H}
|
|
23
|
-
${U.default.cyan(n)}
|
|
24
|
-
`}}}).prompt(),d=(b)=>{let I=b.active??"Yes",$=b.inactive??"No";return new s1({active:I,inactive:$,initialValue:b.initialValue??!0,render(){let H=`${U.default.gray(T)}
|
|
25
|
-
${Xb(this.state)} ${b.message}
|
|
26
|
-
`,Y=this.value?I:$;switch(this.state){case"submit":return`${H}${U.default.gray(T)} ${U.default.dim(Y)}`;case"cancel":return`${H}${U.default.gray(T)} ${U.default.strikethrough(U.default.dim(Y))}
|
|
27
|
-
${U.default.gray(T)}`;default:return`${H}${U.default.cyan(T)} ${this.value?`${U.default.green($b)} ${I}`:`${U.default.dim(Hb)} ${U.default.dim(I)}`} ${U.default.dim("/")} ${this.value?`${U.default.dim(Hb)} ${U.default.dim($)}`:`${U.default.green($b)} ${$}`}
|
|
28
|
-
${U.default.cyan(n)}
|
|
29
|
-
`}}}).prompt()},I1=(b)=>{let I=($,H)=>{let Y=$.label??String($.value);switch(H){case"selected":return`${U.default.dim(Y)}`;case"active":return`${U.default.green($b)} ${Y} ${$.hint?U.default.dim(`(${$.hint})`):""}`;case"cancelled":return`${U.default.strikethrough(U.default.dim(Y))}`;default:return`${U.default.dim(Hb)} ${U.default.dim(Y)}`}};return new e1({options:b.options,initialValue:b.initialValue,render(){let $=`${U.default.gray(T)}
|
|
30
|
-
${Xb(this.state)} ${b.message}
|
|
31
|
-
`;switch(this.state){case"submit":return`${$}${U.default.gray(T)} ${I(this.options[this.cursor],"selected")}`;case"cancel":return`${$}${U.default.gray(T)} ${I(this.options[this.cursor],"cancelled")}
|
|
32
|
-
${U.default.gray(T)}`;default:return`${$}${U.default.cyan(T)} ${k4({cursor:this.cursor,options:this.options,maxItems:b.maxItems,style:(H,Y)=>I(H,Y?"active":"inactive")}).join(`
|
|
33
|
-
${U.default.cyan(T)} `)}
|
|
34
|
-
${U.default.cyan(n)}
|
|
35
|
-
`}}}).prompt()},l=(b="",I="")=>{let $=`
|
|
36
|
-
${b}
|
|
37
|
-
`.split(`
|
|
38
|
-
`),H=Gb(I).length,Y=Math.max($.reduce((G,Z)=>{let J=Gb(Z);return J.length>G?J.length:G},0),H)+2,X=$.map((G)=>`${U.default.gray(T)} ${U.default.dim(G)}${" ".repeat(Y-Gb(G).length)}${U.default.gray(T)}`).join(`
|
|
39
|
-
`);process.stdout.write(`${U.default.gray(T)}
|
|
40
|
-
${U.default.green(Yb)} ${U.default.reset(I)} ${U.default.gray(RI.repeat(Math.max(Y-H-1,1))+O4)}
|
|
41
|
-
${X}
|
|
42
|
-
${U.default.gray(R4+RI.repeat(Y+2)+E4)}
|
|
43
|
-
`)},PI=(b="")=>{process.stdout.write(`${U.default.gray(n)} ${U.default.red(b)}
|
|
44
|
-
|
|
45
|
-
`)},xI=(b="")=>{process.stdout.write(`${U.default.gray(A4)} ${b}
|
|
46
|
-
`)},wI=(b="")=>{process.stdout.write(`${U.default.gray(T)}
|
|
47
|
-
${U.default.gray(n)} ${b}
|
|
48
|
-
|
|
49
|
-
`)},V,o$;var a=S(()=>{Ib();Ib();U=F(l1(),1),EI=F(p1(),1);L4=T4(),B4=B("\u25C6","*"),_4=B("\u25A0","x"),M4=B("\u25B2","x"),Yb=B("\u25C7","o"),A4=B("\u250C","T"),T=B("\u2502","|"),n=B("\u2514","\u2014"),$b=B("\u25CF",">"),Hb=B("\u25CB"," "),a$=B("\u25FB","[\u2022]"),i$=B("\u25FC","[+]"),r$=B("\u25FB","[ ]"),t$=B("\u25AA","\u2022"),RI=B("\u2500","-"),O4=B("\u256E","+"),R4=B("\u251C","+"),E4=B("\u256F","+"),y4=B("\u25CF","\u2022"),P4=B("\u25C6","*"),x4=B("\u25B2","!"),w4=B("\u25A0","x"),V={message:(b="",{symbol:I=U.default.gray(T)}={})=>{let $=[`${U.default.gray(T)}`];if(b){let[H,...Y]=b.split(`
|
|
50
|
-
`);$.push(`${I} ${H}`,...Y.map((X)=>`${U.default.gray(T)} ${X}`))}process.stdout.write(`${$.join(`
|
|
51
|
-
`)}
|
|
52
|
-
`)},info:(b)=>{V.message(b,{symbol:U.default.blue(y4)})},success:(b)=>{V.message(b,{symbol:U.default.green(P4)})},step:(b)=>{V.message(b,{symbol:U.default.green(Yb)})},warn:(b)=>{V.message(b,{symbol:U.default.yellow(x4)})},warning:(b)=>{V.warn(b)},error:(b)=>{V.message(b,{symbol:U.default.red(w4)})}},o$=`${U.default.gray(T)} `});var kI=M((b6,F4)=>{F4.exports={name:"dotenv",version:"17.2.0",description:"Loads environment variables from .env file",main:"lib/main.js",types:"lib/main.d.ts",exports:{".":{types:"./lib/main.d.ts",require:"./lib/main.js",default:"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},scripts:{"dts-check":"tsc --project tests/types/tsconfig.json",lint:"standard",pretest:"npm run lint && npm run dts-check",test:"tap run --allow-empty-coverage --disable-coverage --timeout=60000","test:coverage":"tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",prerelease:"npm test",release:"standard-version"},repository:{type:"git",url:"git://github.com/motdotla/dotenv.git"},homepage:"https://github.com/motdotla/dotenv#readme",funding:"https://dotenvx.com",keywords:["dotenv","env",".env","environment","variables","config","settings"],readmeFilename:"README.md",license:"BSD-2-Clause",devDependencies:{"@types/node":"^18.11.3",decache:"^4.6.2",sinon:"^14.0.1",standard:"^17.0.0","standard-version":"^9.5.0",tap:"^19.2.0",typescript:"^4.8.4"},engines:{node:">=12"},browser:{fs:!1}}});var DI=M((I6,m)=>{var Zb=O("fs"),T1=O("path"),v4=O("os"),C4=O("crypto"),h4=kI(),Jb=h4.version,FI=["\uD83D\uDD10 encrypt with dotenvx: https://dotenvx.com","\uD83D\uDD10 prevent committing .env to code: https://dotenvx.com/precommit","\uD83D\uDD10 prevent building .env in docker: https://dotenvx.com/prebuild","\uD83D\uDEE0\uFE0F run anywhere with `dotenvx run -- yourcommand`","\u2699\uFE0F specify custom .env file path with { path: '/custom/path/.env' }","\u2699\uFE0F enable debug logging with { debug: true }","\u2699\uFE0F override existing env vars with { override: true }","\u2699\uFE0F suppress all logs with { quiet: true }","\u2699\uFE0F write to custom object with { processEnv: myObject }","\u2699\uFE0F load multiple .env files with { path: ['.env.local', '.env'] }"];function m4(){return FI[Math.floor(Math.random()*FI.length)]}function i(b){if(typeof b==="string")return!["false","0","no","off",""].includes(b.toLowerCase());return Boolean(b)}function D4(){return process.stdout.isTTY}function f4(b){return D4()?`\x1B[2m${b}\x1B[0m`:b}var d4=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function c4(b){let I={},$=b.toString();$=$.replace(/\r\n?/mg,`
|
|
53
|
-
`);let H;while((H=d4.exec($))!=null){let Y=H[1],X=H[2]||"";X=X.trim();let G=X[0];if(X=X.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),G==='"')X=X.replace(/\\n/g,`
|
|
54
|
-
`),X=X.replace(/\\r/g,"\r");I[Y]=X}return I}function g4(b){b=b||{};let I=mI(b);b.path=I;let $=_.configDotenv(b);if(!$.parsed){let G=new Error(`MISSING_DATA: Cannot parse ${I} for an unknown reason`);throw G.code="MISSING_DATA",G}let H=hI(b).split(","),Y=H.length,X;for(let G=0;G<Y;G++)try{let Z=H[G].trim(),J=p4($,Z);X=_.decrypt(J.ciphertext,J.key);break}catch(Z){if(G+1>=Y)throw Z}return _.parse(X)}function u4(b){console.error(`[dotenv@${Jb}][WARN] ${b}`)}function G1(b){console.log(`[dotenv@${Jb}][DEBUG] ${b}`)}function CI(b){console.log(`[dotenv@${Jb}] ${b}`)}function hI(b){if(b&&b.DOTENV_KEY&&b.DOTENV_KEY.length>0)return b.DOTENV_KEY;if(process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0)return process.env.DOTENV_KEY;return""}function p4(b,I){let $;try{$=new URL(I)}catch(Z){if(Z.code==="ERR_INVALID_URL"){let J=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw J.code="INVALID_DOTENV_KEY",J}throw Z}let H=$.password;if(!H){let Z=new Error("INVALID_DOTENV_KEY: Missing key part");throw Z.code="INVALID_DOTENV_KEY",Z}let Y=$.searchParams.get("environment");if(!Y){let Z=new Error("INVALID_DOTENV_KEY: Missing environment part");throw Z.code="INVALID_DOTENV_KEY",Z}let X=`DOTENV_VAULT_${Y.toUpperCase()}`,G=b.parsed[X];if(!G){let Z=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${X} in your .env.vault file.`);throw Z.code="NOT_FOUND_DOTENV_ENVIRONMENT",Z}return{ciphertext:G,key:H}}function mI(b){let I=null;if(b&&b.path&&b.path.length>0)if(Array.isArray(b.path)){for(let $ of b.path)if(Zb.existsSync($))I=$.endsWith(".vault")?$:`${$}.vault`}else I=b.path.endsWith(".vault")?b.path:`${b.path}.vault`;else I=T1.resolve(process.cwd(),".env.vault");if(Zb.existsSync(I))return I;return null}function vI(b){return b[0]==="~"?T1.join(v4.homedir(),b.slice(1)):b}function n4(b){let I=i(process.env.DOTENV_CONFIG_DEBUG||b&&b.debug),$=i(process.env.DOTENV_CONFIG_QUIET||b&&b.quiet);if(I||!$)CI("Loading env from encrypted .env.vault");let H=_._parseVault(b),Y=process.env;if(b&&b.processEnv!=null)Y=b.processEnv;return _.populate(Y,H,b),{parsed:H}}function l4(b){let I=T1.resolve(process.cwd(),".env"),$="utf8",H=process.env;if(b&&b.processEnv!=null)H=b.processEnv;let Y=i(H.DOTENV_CONFIG_DEBUG||b&&b.debug),X=i(H.DOTENV_CONFIG_QUIET||b&&b.quiet);if(b&&b.encoding)$=b.encoding;else if(Y)G1("No encoding is specified. UTF-8 is used by default");let G=[I];if(b&&b.path)if(!Array.isArray(b.path))G=[vI(b.path)];else{G=[];for(let Q of b.path)G.push(vI(Q))}let Z,J={};for(let Q of G)try{let W=_.parse(Zb.readFileSync(Q,{encoding:$}));_.populate(J,W,b)}catch(W){if(Y)G1(`Failed to load ${Q} ${W.message}`);Z=W}let q=_.populate(H,J,b);if(Y=i(H.DOTENV_CONFIG_DEBUG||Y),X=i(H.DOTENV_CONFIG_QUIET||X),Y||!X){let Q=Object.keys(q).length,W=[];for(let z of G)try{let N=T1.relative(process.cwd(),z);W.push(N)}catch(N){if(Y)G1(`Failed to load ${z} ${N.message}`);Z=N}CI(`injecting env (${Q}) from ${W.join(",")} ${f4(`(tip: ${m4()})`)}`)}if(Z)return{parsed:J,error:Z};else return{parsed:J}}function a4(b){if(hI(b).length===0)return _.configDotenv(b);let I=mI(b);if(!I)return u4(`You set DOTENV_KEY but you are missing a .env.vault file at ${I}. Did you forget to build it?`),_.configDotenv(b);return _._configVault(b)}function i4(b,I){let $=Buffer.from(I.slice(-64),"hex"),H=Buffer.from(b,"base64"),Y=H.subarray(0,12),X=H.subarray(-16);H=H.subarray(12,-16);try{let G=C4.createDecipheriv("aes-256-gcm",$,Y);return G.setAuthTag(X),`${G.update(H)}${G.final()}`}catch(G){let Z=G instanceof RangeError,J=G.message==="Invalid key length",q=G.message==="Unsupported state or unable to authenticate data";if(Z||J){let Q=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw Q.code="INVALID_DOTENV_KEY",Q}else if(q){let Q=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw Q.code="DECRYPTION_FAILED",Q}else throw G}}function r4(b,I,$={}){let H=Boolean($&&$.debug),Y=Boolean($&&$.override),X={};if(typeof I!=="object"){let G=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw G.code="OBJECT_REQUIRED",G}for(let G of Object.keys(I))if(Object.prototype.hasOwnProperty.call(b,G)){if(Y===!0)b[G]=I[G],X[G]=I[G];if(H)if(Y===!0)G1(`"${G}" is already defined and WAS overwritten`);else G1(`"${G}" is already defined and was NOT overwritten`)}else b[G]=I[G],X[G]=I[G];return X}var _={configDotenv:l4,_configVault:n4,_parseVault:g4,config:a4,decrypt:i4,parse:c4,populate:r4};I6.configDotenv=_.configDotenv;I6._configVault=_._configVault;I6._parseVault=_._parseVault;I6.config=_.config;I6.decrypt=_.decrypt;I6.parse=_.parse;I6.populate=_.populate;m.exports=_});import{existsSync as fI,readFileSync as dI}from"fs";import{join as cI}from"path";function pI(b){let I;try{I=cI(process.cwd(),".commit-wizardrc")}catch{I="/tmp/.commit-wizardrc"}let $=cI(process.env.HOME||process.env.USERPROFILE||"/tmp",".commit-wizardrc"),H={...$3};try{if(fI($)){let X=dI($,"utf-8"),G=JSON.parse(X);H=gI(H,G)}}catch{console.warn("\u26A0\uFE0F Erro ao ler configura\xE7\xE3o global: Erro desconhecido")}let Y=b||I;try{if(fI(Y)){let X=dI(Y,"utf-8"),G=JSON.parse(X);H=gI(H,G)}}catch{console.warn("\u26A0\uFE0F Erro ao ler .commit-wizardrc: Erro desconhecido")}if(H.openai.apiKey=process.env.OPENAI_API_KEY,process.env.COMMIT_WIZARD_DEBUG==="true");if(process.env.COMMIT_WIZARD_DRY_RUN==="true")H.dryRun=!0;return H}function gI(b,I){return{...b,...I,openai:{...b.openai,...I.openai},smartSplit:{...b.smartSplit,...I.smartSplit},cache:{...b.cache,...I.cache}}}function nI(b){let I=[];if(!b.openai.apiKey)I.push("OPENAI_API_KEY n\xE3o encontrada nas vari\xE1veis de ambiente");if(b.openai.maxTokens<10||b.openai.maxTokens>4000)I.push("maxTokens deve estar entre 10 e 4000");if(b.openai.temperature<0||b.openai.temperature>2)I.push("temperature deve estar entre 0 e 2");if(!["pt","en","es","fr","de","it","ja","ko","zh"].includes(b.language))I.push("language deve ser um idioma suportado (pt, en, es, fr, de, it, ja, ko, zh)");if(!["conventional","simple","detailed"].includes(b.commitStyle))I.push("commitStyle deve ser conventional, simple ou detailed");if(b.smartSplit.minGroupSize<1)I.push("smartSplit.minGroupSize deve ser pelo menos 1");if(b.smartSplit.maxGroups<1||b.smartSplit.maxGroups>10)I.push("smartSplit.maxGroups deve estar entre 1 e 10");if(b.smartSplit.confidenceThreshold<0||b.smartSplit.confidenceThreshold>1)I.push("smartSplit.confidenceThreshold deve estar entre 0 e 1");if(b.cache.ttl<1)I.push("cache.ttl deve ser pelo menos 1 minuto");if(b.cache.maxSize<1)I.push("cache.maxSize deve ser pelo menos 1");return I}var uI,$3;var lI=S(()=>{uI=F(DI(),1);uI.default.config();$3={openai:{model:"gpt-4o",maxTokens:150,temperature:0.7,timeout:30000,retries:2},language:"pt",commitStyle:"conventional",autoCommit:!1,splitCommits:!1,dryRun:!1,smartSplit:{enabled:!0,minGroupSize:1,maxGroups:5,confidenceThreshold:0.7},cache:{enabled:!0,ttl:60,maxSize:100}}});var r={};e(r,{isGitRepository:()=>qb,getGitStatus:()=>Qb,getFileDiff:()=>H3,getDiffStats:()=>Ub,executeFileCommit:()=>$1,executeCommit:()=>f});import{execSync as D}from"child_process";function qb(){try{return D("git rev-parse --git-dir",{stdio:"ignore"}),!0}catch{return!1}}function Qb(){try{let I=D("git diff --cached --name-only",{encoding:"utf-8",stdio:"pipe"}).trim().split(`
|
|
55
|
-
`).filter((H)=>H.length>0),$=I.length>0?D("git diff --cached",{encoding:"utf-8",stdio:"pipe"}):"";return{hasStaged:I.length>0,stagedFiles:I,diff:$.trim()}}catch(b){throw new Error(`Erro ao obter status do Git: ${b instanceof Error?b.message:"Erro desconhecido"}`)}}function H3(b){try{return D(`git diff --cached -- "${b}"`,{encoding:"utf-8",stdio:"pipe"})}catch(I){throw new Error(`Erro ao obter diff do arquivo ${b}: ${I instanceof Error?I.message:"Erro desconhecido"}`)}}function f(b){try{return D(`git commit -m "${b.replace(/"/g,"\\\"")}"`,{stdio:"pipe"}),{success:!0,hash:D("git rev-parse HEAD",{encoding:"utf-8",stdio:"pipe"}).trim(),message:b}}catch(I){return{success:!1,error:I instanceof Error?I.message:"Erro desconhecido ao executar commit"}}}function $1(b,I){try{return D(`git commit "${b}" -m "${I.replace(/"/g,"\\\"")}"`,{stdio:"pipe"}),{success:!0,hash:D("git rev-parse HEAD",{encoding:"utf-8",stdio:"pipe"}).trim(),message:I}}catch($){return{success:!1,error:$ instanceof Error?$.message:"Erro desconhecido ao executar commit do arquivo"}}}function Ub(){try{let I=D("git diff --cached --numstat",{encoding:"utf-8",stdio:"pipe"}).trim().split(`
|
|
56
|
-
`).filter((Y)=>Y.length>0),$=0,H=0;return I.forEach((Y)=>{let[X,G]=Y.split("\t");if(X&&X!=="-")$+=parseInt(X)||0;if(G&&G!=="-")H+=parseInt(G)||0}),{added:$,removed:H,files:I.length}}catch{return{added:0,removed:0,files:0}}}var c=()=>{};var oI={};e(oI,{generateWithRetry:()=>L1,generateCommitMessage:()=>tI,extractCommitTypeFromMessage:()=>iI,detectCommitType:()=>rI,buildPrompt:()=>aI});function aI(b,I,$){let H=I.language==="pt"?"portugu\xEAs":"english",Y=Y3(I.commitStyle,I.language),X=6000,G=b.length>6000?b.substring(0,6000)+`
|
|
57
|
-
... (diff truncado)`:b,Z=$.length>10?`${$.length} arquivos: ${$.slice(0,5).join(", ")}...`:$.join(", ");return`Gere mensagem de commit em ${H} (${I.commitStyle}).
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var je=Object.defineProperty;var b=(e,t)=>()=>(e&&(t=e(e=0)),t);var P=(e,t)=>{for(var o in t)je(e,o,{get:t[o],enumerable:!0})};import at from"path";import{fileURLToPath as mt}from"url";var d=b(()=>{"use strict"});import{existsSync as re,readFileSync as ae}from"fs";import{join as ce}from"path";import De from"dotenv";function le(e){let t;try{t=ce(process.cwd(),".commit-wizardrc")}catch{t="/tmp/.commit-wizardrc"}let o=ce(process.env.HOME||process.env.USERPROFILE||"/tmp",".commit-wizardrc"),i={...Te};try{if(re(o)){let s=ae(o,"utf-8"),a=JSON.parse(s);i=me(i,a)}}catch{console.warn("\u26A0\uFE0F Erro ao ler configura\xE7\xE3o global: Erro desconhecido")}let n=e||t;try{if(re(n)){let s=ae(n,"utf-8"),a=JSON.parse(s);i=me(i,a)}}catch{console.warn("\u26A0\uFE0F Erro ao ler .commit-wizardrc: Erro desconhecido")}return i.openai.apiKey=process.env.OPENAI_API_KEY,process.env.COMMIT_WIZARD_DEBUG,process.env.COMMIT_WIZARD_DRY_RUN==="true"&&(i.dryRun=!0),i}function me(e,t){return{...e,...t,openai:{...e.openai,...t.openai},smartSplit:{...e.smartSplit,...t.smartSplit},cache:{...e.cache,...t.cache}}}function ue(e){let t=[];return e.openai.apiKey||t.push("OPENAI_API_KEY n\xE3o encontrada nas vari\xE1veis de ambiente"),(e.openai.maxTokens<10||e.openai.maxTokens>4e3)&&t.push("maxTokens deve estar entre 10 e 4000"),(e.openai.temperature<0||e.openai.temperature>2)&&t.push("temperature deve estar entre 0 e 2"),["pt","en","es","fr","de","it","ja","ko","zh"].includes(e.language)||t.push("language deve ser um idioma suportado (pt, en, es, fr, de, it, ja, ko, zh)"),["conventional","simple","detailed"].includes(e.commitStyle)||t.push("commitStyle deve ser conventional, simple ou detailed"),e.smartSplit.minGroupSize<1&&t.push("smartSplit.minGroupSize deve ser pelo menos 1"),(e.smartSplit.maxGroups<1||e.smartSplit.maxGroups>10)&&t.push("smartSplit.maxGroups deve estar entre 1 e 10"),(e.smartSplit.confidenceThreshold<0||e.smartSplit.confidenceThreshold>1)&&t.push("smartSplit.confidenceThreshold deve estar entre 0 e 1"),e.cache.ttl<1&&t.push("cache.ttl deve ser pelo menos 1 minuto"),e.cache.maxSize<1&&t.push("cache.maxSize deve ser pelo menos 1"),t}var Te,pe=b(()=>{"use strict";d();De.config();Te={openai:{model:"gpt-4o",maxTokens:150,temperature:.7,timeout:3e4,retries:2},language:"pt",commitStyle:"conventional",autoCommit:!1,splitCommits:!1,dryRun:!1,smartSplit:{enabled:!0,minGroupSize:1,maxGroups:5,confidenceThreshold:.7},cache:{enabled:!0,ttl:60,maxSize:100}}});var E={};P(E,{escapeShellArg:()=>T,executeCommit:()=>z,executeFileCommit:()=>j,getDiffStats:()=>J,getFileDiff:()=>qe,getGitStatus:()=>K,isGitRepository:()=>V});import{execSync as A}from"child_process";function T(e){return`'${e.replace(/'/g,`'"'"'`)}'`}function V(){try{return A("git rev-parse --git-dir",{stdio:"ignore"}),!0}catch{return!1}}function K(){try{let t=A("git diff --cached --name-only",{encoding:"utf-8",stdio:"pipe"}).trim().split(`
|
|
3
|
+
`).filter(i=>i.length>0),o=t.length>0?A("git diff --cached",{encoding:"utf-8",stdio:"pipe"}):"";return{hasStaged:t.length>0,stagedFiles:t,diff:o.trim()}}catch(e){throw new Error(`Erro ao obter status do Git: ${e instanceof Error?e.message:"Erro desconhecido"}`)}}function qe(e){try{return A(`git diff --cached -- "${e}"`,{encoding:"utf-8",stdio:"pipe"})}catch(t){throw new Error(`Erro ao obter diff do arquivo ${e}: ${t instanceof Error?t.message:"Erro desconhecido"}`)}}function z(e){try{let t=T(e);return A(`git commit -m ${t}`,{stdio:"pipe"}),{success:!0,hash:A("git rev-parse HEAD",{encoding:"utf-8",stdio:"pipe"}).trim(),message:e}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Erro desconhecido ao executar commit"}}}function j(e,t){try{let o=T(t),i=T(e);return A(`git commit ${i} -m ${o}`,{stdio:"pipe"}),{success:!0,hash:A("git rev-parse HEAD",{encoding:"utf-8",stdio:"pipe"}).trim(),message:t}}catch(o){return{success:!1,error:o instanceof Error?o.message:"Erro desconhecido ao executar commit do arquivo"}}}function J(){try{let t=A("git diff --cached --numstat",{encoding:"utf-8",stdio:"pipe"}).trim().split(`
|
|
4
|
+
`).filter(n=>n.length>0),o=0,i=0;return t.forEach(n=>{let[s,a]=n.split(" ");s&&s!=="-"&&(o+=parseInt(s)||0),a&&a!=="-"&&(i+=parseInt(a)||0)}),{added:o,removed:i,files:t.length}}catch{return{added:0,removed:0,files:0}}}var S=b(()=>{"use strict";d()});var xe={};P(xe,{buildPrompt:()=>de,detectCommitType:()=>ge,extractCommitTypeFromMessage:()=>fe,generateCommitMessage:()=>ye,generateWithRetry:()=>q,processOpenAIMessage:()=>he});function de(e,t,o){let i=t.language==="pt"?"portugu\xEAs":"english",n=ke(t.commitStyle,t.language),s=6e3,a=e.length>s?e.substring(0,s)+`
|
|
5
|
+
... (diff truncado)`:e,c=o.length>10?`${o.length} arquivos: ${o.slice(0,5).join(", ")}...`:o.join(", ");return`Gere mensagem de commit em ${i} (${t.commitStyle}).
|
|
58
6
|
|
|
59
|
-
Arquivos: ${
|
|
7
|
+
Arquivos: ${c}
|
|
60
8
|
|
|
61
|
-
${
|
|
9
|
+
${n}
|
|
62
10
|
|
|
63
11
|
Diff:
|
|
64
12
|
\`\`\`
|
|
65
|
-
${
|
|
13
|
+
${a}
|
|
66
14
|
\`\`\`
|
|
67
15
|
|
|
68
|
-
Mensagem:`}function
|
|
16
|
+
Mensagem:`}function ke(e,t){let o={pt:{conventional:`- Use formato: tipo(escopo): descri\xE7\xE3o
|
|
69
17
|
- Tipos v\xE1lidos: feat, fix, docs, style, refactor, test, chore, build, ci
|
|
70
18
|
- Exemplo: "feat(auth): adicionar valida\xE7\xE3o de email"
|
|
71
19
|
- Mantenha a primeira linha com at\xE9 50 caracteres`,simple:`- Use formato simples e direto
|
|
@@ -83,31 +31,25 @@ Mensagem:`}function Y3(b,I){let $={pt:{conventional:`- Use formato: tipo(escopo)
|
|
|
83
31
|
- Maximum 50 characters`,detailed:`- First line: summary under 50 characters
|
|
84
32
|
- Add explanatory body if needed
|
|
85
33
|
- Use imperative mood
|
|
86
|
-
- Be descriptive but concise`}},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
${
|
|
91
|
-
`);if(h)H.originalMessage=H.message,H.message=u;else H=new Error(u);if(H.shortMessage=R,H.command=G,H.escapedCommand=Z,H.exitCode=X,H.signal=Y,H.signalDescription=N,H.stdout=b,H.stderr=I,H.cwd=z,$!==void 0)H.all=$;if("bufferedData"in H)delete H.bufferedData;return H.failed=!0,H.timedOut=Boolean(J),H.isCanceled=q,H.killed=Q&&!J,H};var Z2=S(()=>{X2()});var R1,JG=(b)=>R1.some((I)=>b[I]!==void 0),J2=(b)=>{if(!b)return;let{stdio:I}=b;if(I===void 0)return R1.map((H)=>b[H]);if(JG(b))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${R1.map((H)=>`\`${H}\``).join(", ")}`);if(typeof I==="string")return I;if(!Array.isArray(I))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof I}\``);let $=Math.max(I.length,R1.length);return Array.from({length:$},(H,Y)=>I[Y])};var q2=S(()=>{R1=["stdin","stdout","stderr"]});var g;var Q2=S(()=>{g=[];g.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")g.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")g.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")});class U2{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Pb[yb])return Pb[yb];qG(Pb,yb,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(b,I){this.listeners[b].push(I)}removeListener(b,I){let $=this.listeners[b],H=$.indexOf(I);if(H===-1)return;if(H===0&&$.length===1)$.length=0;else $.splice(H,1)}emit(b,I,$){if(this.emitted[b])return!1;this.emitted[b]=!0;let H=!1;for(let Y of this.listeners[b])H=Y(I,$)===!0||H;if(b==="exit")H=this.emit("afterExit",I,$)||H;return H}}class wb{}var E1=(b)=>!!b&&typeof b==="object"&&typeof b.removeListener==="function"&&typeof b.emit==="function"&&typeof b.reallyExit==="function"&&typeof b.listeners==="function"&&typeof b.kill==="function"&&typeof b.pid==="number"&&typeof b.on==="function",yb,Pb,qG,QG=(b)=>{return{onExit(I,$){return b.onExit(I,$)},load(){return b.load()},unload(){return b.unload()}}},V2,W2,xb,z2,G8,$8;var S2=S(()=>{Q2();yb=Symbol.for("signal-exit emitter"),Pb=globalThis,qG=Object.defineProperty.bind(Object);V2=class V2 extends wb{onExit(){return()=>{}}load(){}unload(){}};W2=class W2 extends wb{#X=xb.platform==="win32"?"SIGINT":"SIGHUP";#I=new U2;#b;#H;#Y;#$={};#G=!1;constructor(b){super();this.#b=b,this.#$={};for(let I of g)this.#$[I]=()=>{let $=this.#b.listeners(I),{count:H}=this.#I,Y=b;if(typeof Y.__signal_exit_emitter__==="object"&&typeof Y.__signal_exit_emitter__.count==="number")H+=Y.__signal_exit_emitter__.count;if($.length===H){this.unload();let X=this.#I.emit("exit",null,I),G=I==="SIGHUP"?this.#X:I;if(!X)b.kill(b.pid,G)}};this.#Y=b.reallyExit,this.#H=b.emit}onExit(b,I){if(!E1(this.#b))return()=>{};if(this.#G===!1)this.load();let $=I?.alwaysLast?"afterExit":"exit";return this.#I.on($,b),()=>{if(this.#I.removeListener($,b),this.#I.listeners.exit.length===0&&this.#I.listeners.afterExit.length===0)this.unload()}}load(){if(this.#G)return;this.#G=!0,this.#I.count+=1;for(let b of g)try{let I=this.#$[b];if(I)this.#b.on(b,I)}catch(I){}this.#b.emit=(b,...I)=>{return this.#J(b,...I)},this.#b.reallyExit=(b)=>{return this.#Z(b)}}unload(){if(!this.#G)return;this.#G=!1,g.forEach((b)=>{let I=this.#$[b];if(!I)throw new Error("Listener not defined for signal: "+b);try{this.#b.removeListener(b,I)}catch($){}}),this.#b.emit=this.#H,this.#b.reallyExit=this.#Y,this.#I.count-=1}#Z(b){if(!E1(this.#b))return 0;return this.#b.exitCode=b||0,this.#I.emit("exit",this.#b.exitCode,null),this.#Y.call(this.#b,this.#b.exitCode)}#J(b,...I){let $=this.#H;if(b==="exit"&&E1(this.#b)){if(typeof I[0]==="number")this.#b.exitCode=I[0];let H=$.call(this.#b,b,...I);return this.#I.emit("exit",this.#b.exitCode,null),H}else return $.call(this.#b,b,...I)}};xb=globalThis.process,{onExit:z2,load:G8,unload:$8}=QG(E1(xb)?new W2(xb):new V2)});import UG from"os";var VG=5000,N2=(b,I="SIGTERM",$={})=>{let H=b(I);return WG(b,I,$,H),H},WG=(b,I,$,H)=>{if(!zG(I,$,H))return;let Y=NG($),X=setTimeout(()=>{b("SIGKILL")},Y);if(X.unref)X.unref()},zG=(b,{forceKillAfterTimeout:I},$)=>SG(b)&&I!==!1&&$,SG=(b)=>b===UG.constants.signals.SIGTERM||typeof b==="string"&&b.toUpperCase()==="SIGTERM",NG=({forceKillAfterTimeout:b=!0})=>{if(b===!0)return VG;if(!Number.isFinite(b)||b<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${b}\` (${typeof b})`);return b},K2=(b,I)=>{if(b.kill())I.isCanceled=!0},KG=(b,I,$)=>{b.kill(I),$(Object.assign(new Error("Timed out"),{timedOut:!0,signal:I}))},j2=(b,{timeout:I,killSignal:$="SIGTERM"},H)=>{if(I===0||I===void 0)return H;let Y,X=new Promise((Z,J)=>{Y=setTimeout(()=>{KG(b,$,J)},I)}),G=H.finally(()=>{clearTimeout(Y)});return Promise.race([X,G])},T2=({timeout:b})=>{if(b!==void 0&&(!Number.isFinite(b)||b<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${b}\` (${typeof b})`)},L2=async(b,{cleanup:I,detached:$},H)=>{if(!I||$)return H;let Y=z2(()=>{b.kill()});return H.finally(()=>{Y()})};var B2=S(()=>{S2()});function y1(b){return b!==null&&typeof b==="object"&&typeof b.pipe==="function"}function kb(b){return y1(b)&&b.writable!==!1&&typeof b._write==="function"&&typeof b._writableState==="object"}import{createWriteStream as jG}from"fs";import{ChildProcess as TG}from"child_process";var LG=(b)=>b instanceof TG&&typeof b.then==="function",Fb=(b,I,$)=>{if(typeof $==="string")return b[I].pipe(jG($)),b;if(kb($))return b[I].pipe($),b;if(!LG($))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!kb($.stdin))throw new TypeError("The target child process's stdin must be available.");return b[I].pipe($.stdin),$},_2=(b)=>{if(b.stdout!==null)b.pipeStdout=Fb.bind(void 0,b,"stdout");if(b.stderr!==null)b.pipeStderr=Fb.bind(void 0,b,"stderr");if(b.all!==void 0)b.pipeAll=Fb.bind(void 0,b,"all")};var M2=()=>{};var X1=async(b,{init:I,convertChunk:$,getSize:H,truncateChunk:Y,addChunk:X,getFinalChunk:G,finalize:Z},{maxBuffer:J=Number.POSITIVE_INFINITY}={})=>{if(!_G(b))throw new Error("The first argument must be a Readable, a ReadableStream, or an async iterable.");let q=I();q.length=0;try{for await(let Q of b){let W=MG(Q),z=$[W](Q,q);R2({convertedChunk:z,state:q,getSize:H,truncateChunk:Y,addChunk:X,maxBuffer:J})}return BG({state:q,convertChunk:$,getSize:H,truncateChunk:Y,addChunk:X,getFinalChunk:G,maxBuffer:J}),Z(q)}catch(Q){throw Q.bufferedData=Z(q),Q}},BG=({state:b,getSize:I,truncateChunk:$,addChunk:H,getFinalChunk:Y,maxBuffer:X})=>{let G=Y(b);if(G!==void 0)R2({convertedChunk:G,state:b,getSize:I,truncateChunk:$,addChunk:H,maxBuffer:X})},R2=({convertedChunk:b,state:I,getSize:$,truncateChunk:H,addChunk:Y,maxBuffer:X})=>{let G=$(b),Z=I.length+G;if(Z<=X){A2(b,I,Y,Z);return}let J=H(b,X-I.length);if(J!==void 0)A2(J,I,Y,X);throw new vb},A2=(b,I,$,H)=>{I.contents=$(b,I,H),I.length=H},_G=(b)=>typeof b==="object"&&b!==null&&typeof b[Symbol.asyncIterator]==="function",MG=(b)=>{let I=typeof b;if(I==="string")return"string";if(I!=="object"||b===null)return"others";if(globalThis.Buffer?.isBuffer(b))return"buffer";let $=O2.call(b);if($==="[object ArrayBuffer]")return"arrayBuffer";if($==="[object DataView]")return"dataView";if(Number.isInteger(b.byteLength)&&Number.isInteger(b.byteOffset)&&O2.call(b.buffer)==="[object ArrayBuffer]")return"typedArray";return"others"},O2,vb;var Z1=S(()=>{({toString:O2}=Object.prototype);vb=class vb extends Error{name="MaxBufferError";constructor(){super("maxBuffer exceeded")}}});var Cb=(b)=>b,hb=()=>{return},mb=({contents:b})=>b,P1=(b)=>{throw new Error(`Streams in object mode are not supported: ${String(b)}`)},x1=(b)=>b.length;var E2=S(()=>{Z1()});async function Db(b,I){return X1(b,kG,I)}var AG=()=>({contents:new ArrayBuffer(0)}),OG=(b)=>RG.encode(b),RG,y2=(b)=>new Uint8Array(b),P2=(b)=>new Uint8Array(b.buffer,b.byteOffset,b.byteLength),EG=(b,I)=>b.slice(0,I),yG=(b,{contents:I,length:$},H)=>{let Y=k2()?xG(I,H):PG(I,H);return new Uint8Array(Y).set(b,$),Y},PG=(b,I)=>{if(I<=b.byteLength)return b;let $=new ArrayBuffer(w2(I));return new Uint8Array($).set(new Uint8Array(b),0),$},xG=(b,I)=>{if(I<=b.maxByteLength)return b.resize(I),b;let $=new ArrayBuffer(I,{maxByteLength:w2(I)});return new Uint8Array($).set(new Uint8Array(b),0),$},w2=(b)=>x2**Math.ceil(Math.log(b)/Math.log(x2)),x2=2,wG=({contents:b,length:I})=>k2()?b:b.slice(0,I),k2=()=>("resize"in ArrayBuffer.prototype),kG;var fb=S(()=>{Z1();RG=new TextEncoder,kG={init:AG,convertChunk:{string:OG,buffer:y2,arrayBuffer:y2,dataView:P2,typedArray:P2,others:P1},getSize:x1,truncateChunk:EG,addChunk:yG,getFinalChunk:hb,finalize:wG}});async function w1(b,I){if(!("Buffer"in globalThis))throw new Error("getStreamAsBuffer() is only supported in Node.js");try{return F2(await Db(b,I))}catch($){if($.bufferedData!==void 0)$.bufferedData=F2($.bufferedData);throw $}}var F2=(b)=>globalThis.Buffer.from(b);var v2=S(()=>{fb()});async function db(b,I){return X1(b,mG,I)}var FG=()=>({contents:"",textDecoder:new TextDecoder}),k1=(b,{textDecoder:I})=>I.decode(b,{stream:!0}),vG=(b,{contents:I})=>I+b,CG=(b,I)=>b.slice(0,I),hG=({textDecoder:b})=>{let I=b.decode();return I===""?void 0:I},mG;var C2=S(()=>{Z1();mG={init:FG,convertChunk:{string:Cb,buffer:k1,arrayBuffer:k1,dataView:k1,typedArray:k1,others:P1},getSize:x1,truncateChunk:CG,addChunk:vG,getFinalChunk:hG,finalize:mb}});var h2=S(()=>{E2();fb();v2();C2();Z1()});var D2=M((F8,m2)=>{var{PassThrough:DG}=O("stream");m2.exports=function(){var b=[],I=new DG({objectMode:!0});return I.setMaxListeners(0),I.add=$,I.isEmpty=H,I.on("unpipe",Y),Array.prototype.slice.call(arguments).forEach($),I;function $(X){if(Array.isArray(X))return X.forEach($),this;return b.push(X),X.once("end",Y.bind(null,X)),X.once("error",I.emit.bind(I,"error")),X.pipe(I,{end:!1}),this}function H(){return b.length==0}function Y(X){if(b=b.filter(function(G){return G!==X}),!b.length&&I.readable)I.end()}}});import{createReadStream as fG,readFileSync as dG}from"fs";import{setTimeout as cG}from"timers/promises";var f2,d2=(b)=>{if(b!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},gG=({input:b,inputFile:I})=>{if(typeof I!=="string")return b;return d2(b),dG(I)},c2=(b)=>{let I=gG(b);if(y1(I))throw new TypeError("The `input` option cannot be a stream in sync mode");return I},uG=({input:b,inputFile:I})=>{if(typeof I!=="string")return b;return d2(b),fG(I)},g2=(b,I)=>{let $=uG(I);if($===void 0)return;if(y1($))$.pipe(b.stdin);else b.stdin.end($)},u2=(b,{all:I})=>{if(!I||!b.stdout&&!b.stderr)return;let $=f2.default();if(b.stdout)$.add(b.stdout);if(b.stderr)$.add(b.stderr);return $},cb=async(b,I)=>{if(!b||I===void 0)return;await cG(0),b.destroy();try{return await I}catch($){return $.bufferedData}},gb=(b,{encoding:I,buffer:$,maxBuffer:H})=>{if(!b||!$)return;if(I==="utf8"||I==="utf-8")return db(b,{maxBuffer:H});if(I===null||I==="buffer")return w1(b,{maxBuffer:H});return pG(b,H,I)},pG=async(b,I,$)=>{return(await w1(b,{maxBuffer:I})).toString($)},p2=async({stdout:b,stderr:I,all:$},{encoding:H,buffer:Y,maxBuffer:X},G)=>{let Z=gb(b,{encoding:H,buffer:Y,maxBuffer:X}),J=gb(I,{encoding:H,buffer:Y,maxBuffer:X}),q=gb($,{encoding:H,buffer:Y,maxBuffer:X*2});try{return await Promise.all([G,Z,J,q])}catch(Q){return Promise.all([{error:Q,signal:Q.signal,timedOut:Q.timedOut},cb(b,Z),cb(I,J),cb($,q)])}};var n2=S(()=>{h2();f2=F(D2(),1)});var nG,lG,ub=(b,I)=>{for(let[$,H]of lG){let Y=typeof I==="function"?(...X)=>Reflect.apply(H.value,I(),X):H.value.bind(I);Reflect.defineProperty(b,$,{...H,value:Y})}},l2=(b)=>new Promise((I,$)=>{if(b.on("exit",(H,Y)=>{I({exitCode:H,signal:Y})}),b.on("error",(H)=>{$(H)}),b.stdin)b.stdin.on("error",(H)=>{$(H)})});var a2=S(()=>{nG=(async()=>{})().constructor.prototype,lG=["then","catch","finally"].map((b)=>[b,Reflect.getOwnPropertyDescriptor(nG,b)])});import{Buffer as aG}from"buffer";import{ChildProcess as iG}from"child_process";var t2=(b,I=[])=>{if(!Array.isArray(I))return[b];return[b,...I]},rG,tG=(b)=>{if(typeof b!=="string"||rG.test(b))return b;return`"${b.replaceAll('"',"\\\"")}"`},pb=(b,I)=>t2(b,I).join(" "),nb=(b,I)=>t2(b,I).map(($)=>tG($)).join(" "),oG,i2=(b)=>{let I=typeof b;if(I==="string")return b;if(I==="number")return String(b);if(I==="object"&&b!==null&&!(b instanceof iG)&&"stdout"in b){let $=typeof b.stdout;if($==="string")return b.stdout;if(aG.isBuffer(b.stdout))return b.stdout.toString();throw new TypeError(`Unexpected "${$}" stdout in template expression`)}throw new TypeError(`Unexpected "${I}" in template expression`)},r2=(b,I,$)=>$||b.length===0||I.length===0?[...b,...I]:[...b.slice(0,-1),`${b.at(-1)}${I[0]}`,...I.slice(1)],sG=({templates:b,expressions:I,tokens:$,index:H,template:Y})=>{let X=Y??b.raw[H],G=X.split(oG).filter(Boolean),Z=r2($,G,X.startsWith(" "));if(H===I.length)return Z;let J=I[H],q=Array.isArray(J)?J.map((Q)=>i2(Q)):[i2(J)];return r2(Z,q,X.endsWith(" "))},lb=(b,I)=>{let $=[];for(let[H,Y]of b.entries())$=sG({templates:b,expressions:I,tokens:$,index:H,template:Y});return $};var o2=S(()=>{rG=/^[\w.-]+$/,oG=/ +/g});import{debuglog as eG}from"util";import b$ from"process";var s2,F1=(b,I)=>String(b).padStart(I,"0"),I$=()=>{let b=new Date;return`${F1(b.getHours(),2)}:${F1(b.getMinutes(),2)}:${F1(b.getSeconds(),2)}.${F1(b.getMilliseconds(),3)}`},ab=(b,{verbose:I})=>{if(!I)return;b$.stderr.write(`[${I$()}] ${b}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
**Arquivos:** ${b.files.join(", ")}
|
|
102
|
-
**Mensagem:** "${I}"`,"\uD83D\uDE80 Confirmar Commit do Grupo");let $=await d({message:`Fazer commit para "${b.name}"?`});if(P($))return!1;return $}function _$(b,I,$){let H=Math.round(b/I*100),Y="\u2588".repeat(Math.floor(H/10))+"\u2591".repeat(10-Math.floor(H/10));V.info(`\uD83D\uDD04 Progresso: [${Y}] ${H}% (${b}/${I})`),V.info(`\uD83D\uDCCB Processando: ${$}`)}var bI=S(()=>{a()});import M$ from"crypto";class y9{cache=new Map;config;constructor(b){this.config=b}generateHash(b,I){let $={files:b.sort(),diff:I.substring(0,1000),model:this.config.openai.model,temperature:this.config.openai.temperature};return M$.createHash("md5").update(JSON.stringify($)).digest("hex")}get(b,I){if(!this.config.cache.enabled)return{hit:!1};let $=this.generateHash(b,I),H=this.cache.get($);if(!H)return{hit:!1};let Y=Date.now(),X=this.config.cache.ttl*60*1000;if(Y-H.timestamp>X)return this.cache.delete($),{hit:!1};return{hit:!0,groups:H.groups}}set(b,I,$){if(!this.config.cache.enabled)return;if(this.cache.size>=this.config.cache.maxSize)this.cleanup();if(this.cache.size>=this.config.cache.maxSize)return;let H=this.generateHash(b,I),Y={groups:$,timestamp:Date.now(),hash:H};this.cache.set(H,Y)}cleanup(){let b=Date.now(),I=this.config.cache.ttl*60*1000;for(let[$,H]of this.cache.entries())if(b-H.timestamp>I)this.cache.delete($);if(this.cache.size>=this.config.cache.maxSize){let H=Array.from(this.cache.entries()).sort((Y,X)=>Y[1].timestamp-X[1].timestamp).slice(0,Math.ceil(this.config.cache.maxSize*0.5));for(let[Y]of H)this.cache.delete(Y)}}clear(){this.cache.clear()}getStats(){return{size:this.cache.size,maxSize:this.config.cache.maxSize,enabled:this.config.cache.enabled}}}function x9(b){P9=new y9(b)}function w9(){return P9}function k9(b,I){let $=w9();return $?$.get(b,I):{hit:!1}}function F9(b,I,$){let H=w9();if(H)H.set(b,I,$)}var P9=null;var II=()=>{};function A$(b,I){let H=I.length>8000?I.substring(0,8000)+`
|
|
103
|
-
... (diff truncado)`:I,Y=b.length,X=b.reduce((Z,J)=>{let q=J.split(".").pop()||"sem-extensao";return Z[q]=(Z[q]||0)+1,Z},{}),G=Object.entries(X).map(([Z,J])=>`${Z}: ${J}`).join(", ");return`Analise os arquivos modificados e agrupe em commits l\xF3gicos.
|
|
104
|
-
|
|
105
|
-
ARQUIVOS (${Y}): ${b.join(", ")}
|
|
106
|
-
TIPOS: ${G}
|
|
34
|
+
- Be descriptive but concise`}},i=t==="pt"?"pt":"en";return o[i][e]||o[i].conventional}function fe(e){let t={feat:/^(feat|feature)(\([^)]+\))?:/i,fix:/^(fix|bugfix)(\([^)]+\))?:/i,docs:/^(docs|documentation)(\([^)]+\))?:/i,style:/^(style|format)(\([^)]+\))?:/i,refactor:/^(refactor|refactoring)(\([^)]+\))?:/i,test:/^(test|testing)(\([^)]+\))?:/i,chore:/^(chore|maintenance)(\([^)]+\))?:/i,build:/^(build|ci)(\([^)]+\))?:/i,ci:/^(ci|continuous-integration)(\([^)]+\))?:/i};for(let[o,i]of Object.entries(t))if(i.test(e))return o;return null}function ge(e,t){let o=e.toLowerCase(),i=t.join(" ").toLowerCase();return i.includes("test")||i.includes("spec")||o.includes("test(")?"test":i.includes("readme")||i.includes(".md")||i.includes("docs")?"docs":i.includes("package.json")||i.includes("dockerfile")||i.includes(".yml")||i.includes(".yaml")||i.includes("webpack")||i.includes("tsconfig")?"build":i.includes(".css")||i.includes(".scss")||o.includes("style")||o.includes("format")?"style":o.includes("fix")||o.includes("bug")||o.includes("error")||o.includes("issue")?"fix":o.includes("add")||o.includes("new")||o.includes("create")||o.includes("implement")?"feat":o.includes("refactor")||o.includes("restructure")||o.includes("rename")?"refactor":"chore"}function he(e){return e.match(/^```[\s\S]*```$/)&&(e=e.replace(/^```(?:plaintext|javascript|typescript|python|java|html|css|json|xml|yaml|yml|bash|shell|text)?\s*/,"").replace(/\s*```$/,"")),e=e.trim(),e}async function ye(e,t,o){try{if(!t.openai.apiKey)return{success:!1,error:"Chave da OpenAI n\xE3o encontrada. Configure OPENAI_API_KEY nas vari\xE1veis de ambiente."};let i=de(e,t,o),n=await fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${t.openai.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({model:t.openai.model,messages:[{role:"user",content:i}],max_tokens:Math.min(t.openai.maxTokens,150),temperature:t.openai.temperature})});if(!n.ok){let m=await n.json().catch(()=>({}));return{success:!1,error:`Erro da OpenAI (${n.status}): ${m.error?.message||"Erro desconhecido"}`}}let a=(await n.json()).choices?.[0]?.message?.content?.trim();if(!a)return{success:!1,error:"OpenAI retornou resposta vazia"};a=he(a);let c=fe(a),r=ge(e,o);return{success:!0,suggestion:{message:a,type:c||r,confidence:.8}}}catch(i){return{success:!1,error:`Erro ao conectar com OpenAI: ${i instanceof Error?i.message:"Erro desconhecido"}`}}}async function q(e,t,o,i=3){let n="";for(let s=0;s<i;s++){let a=await ye(e,t,o);if(a.success)return a;n=a.error||"Erro desconhecido",s<i-1&&await new Promise(c=>setTimeout(c,Math.pow(2,s)*1e3))}return{success:!1,error:`Falha ap\xF3s ${i} tentativas. \xDAltimo erro: ${n}`}}var W=b(()=>{"use strict";d()});var Q={};P(Q,{askContinueCommits:()=>Y,confirmCommit:()=>He,copyToClipboard:()=>U,editCommitMessage:()=>L,selectFilesForCommit:()=>B,showCancellation:()=>G,showCommitPreview:()=>N,showCommitResult:()=>C});import{text as Ne,select as Le,confirm as k,log as R,note as Ce,cancel as Ue,isCancel as F}from"@clack/prompts";import _e from"clipboardy";async function N(e){Ce(`Tipo: ${e.type}
|
|
35
|
+
Mensagem: "${e.message}"`,"\u{1F4AD} Sugest\xE3o de Commit");let t=await Le({message:"O que voc\xEA gostaria de fazer?",options:[{value:"commit",label:"\u2705 Fazer commit com esta mensagem",hint:"Executar git commit imediatamente"},{value:"edit",label:"\u270F\uFE0F Editar mensagem",hint:"Modificar a mensagem antes de commitar"},{value:"copy",label:"\u{1F4CB} Copiar para clipboard",hint:"Copiar mensagem e sair sem commitar"},{value:"cancel",label:"\u274C Cancelar",hint:"Sair sem fazer nada"}]});return F(t)?{action:"cancel"}:{action:t}}async function L(e){let t=await Ne({message:"Edite a mensagem do commit:",initialValue:e,placeholder:"Digite a mensagem do commit...",validate:i=>{if(!i||i.trim().length===0)return"A mensagem n\xE3o pode estar vazia";if(i.trim().length>72)return"A mensagem est\xE1 muito longa (m\xE1ximo 72 caracteres recomendado)"}});if(F(t))return{action:"cancel"};let o=await k({message:`Confirma a mensagem editada: "${t}"?`});return F(o)||!o?{action:"cancel"}:{action:"commit",message:t}}async function U(e){try{return await _e.write(e),R.success("\u2705 Mensagem copiada para a \xE1rea de transfer\xEAncia!"),!0}catch(t){return R.error(`\u274C Erro ao copiar: ${t instanceof Error?t.message:"Erro desconhecido"}`),!1}}async function He(e){Ce(`"${e}"`,"\u{1F680} Confirmar Commit");let t=await k({message:"Executar o commit agora?"});return F(t)?!1:t}function C(e,t,o){e&&t?(R.success("\u2705 Commit realizado com sucesso!"),R.info(`\u{1F517} Hash: ${t.substring(0,8)}`)):R.error(`\u274C Erro ao realizar commit: ${o||"Erro desconhecido"}`)}async function B(e){R.info("\u{1F4CB} Modo Split: Selecione os arquivos para este commit");let t=[];for(let o of e){let i=await k({message:`Incluir "${o}" neste commit?`});if(F(i))break;i&&t.push(o)}return t}async function Y(e){if(e.length===0)return!1;R.info(`\u{1F4C4} Arquivos restantes: ${e.join(", ")}`);let t=await k({message:"Gerar commit para os arquivos restantes?"});return F(t)?!1:t}function G(){Ue("Opera\xE7\xE3o cancelada pelo usu\xE1rio")}var D=b(()=>{"use strict";d()});var we={};P(we,{chooseSplitMode:()=>X,confirmGroupCommit:()=>Je,showSmartSplitGroups:()=>Ke,showSmartSplitProgress:()=>We});import{select as ve,confirm as Ve,log as Se,note as be,isCancel as Z}from"@clack/prompts";async function X(){let e=await ve({message:"Como voc\xEA gostaria de organizar os commits?",options:[{value:"smart",label:"\u{1F9E0} Smart Split (Recomendado)",hint:"IA analisa contexto e agrupa automaticamente"},{value:"manual",label:"\u270B Split Manual",hint:"Voc\xEA escolhe arquivos manualmente"},{value:"cancel",label:"\u274C Cancelar",hint:"Voltar ao modo normal"}]});return Z(e)?{action:"cancel"}:e==="manual"?{action:"manual"}:e==="smart"?{action:"proceed"}:{action:"cancel"}}async function Ke(e){be(`Identificamos ${e.length} grupo(s) l\xF3gico(s) para seus commits:
|
|
36
|
+
|
|
37
|
+
`+e.map((o,i)=>`${i+1}. **${o.name}**
|
|
38
|
+
\u{1F4C4} ${o.files.join(", ")}
|
|
39
|
+
\u{1F4A1} ${o.description}
|
|
40
|
+
\u{1F3AF} Confian\xE7a: ${Math.round(o.confidence*100)}%`).join(`
|
|
41
|
+
|
|
42
|
+
`),"\u{1F9E0} An\xE1lise de Contexto");let t=await ve({message:"O que voc\xEA gostaria de fazer?",options:[{value:"proceed",label:"\u2705 Prosseguir com esta organiza\xE7\xE3o",hint:"Usar os grupos como sugeridos pela IA"},{value:"manual",label:"\u270B Fazer split manual",hint:"Escolher arquivos manualmente"},{value:"cancel",label:"\u274C Cancelar",hint:"Voltar ao modo normal"}]});return Z(t)?{action:"cancel"}:t==="proceed"?{action:"proceed",groups:e}:{action:t}}async function Je(e,t){be(`**Grupo:** ${e.name}
|
|
43
|
+
**Arquivos:** ${e.files.join(", ")}
|
|
44
|
+
**Mensagem:** "${t}"`,"\u{1F680} Confirmar Commit do Grupo");let o=await Ve({message:`Fazer commit para "${e.name}"?`});return Z(o)?!1:o}function We(e,t,o){let i=Math.round(e/t*100),n="\u2588".repeat(Math.floor(i/10))+"\u2591".repeat(10-Math.floor(i/10));Se.info(`\u{1F504} Progresso: [${n}] ${i}% (${e}/${t})`),Se.info(`\u{1F4CB} Processando: ${o}`)}var ee=b(()=>{"use strict";d()});import Be from"crypto";function Ae(e){$e=new te(e)}function Ee(){return $e}function Me(e,t){let o=Ee();return o?o.get(e,t):{hit:!1}}function ze(e,t,o){let i=Ee();i&&i.set(e,t,o)}var te,$e,ie=b(()=>{"use strict";d();te=class{cache=new Map;config;constructor(t){this.config=t}generateHash(t,o){let i={files:t.sort(),diff:o.substring(0,1e3),model:this.config.openai.model,temperature:this.config.openai.temperature};return Be.createHash("md5").update(JSON.stringify(i)).digest("hex")}get(t,o){if(!this.config.cache.enabled)return{hit:!1};let i=this.generateHash(t,o),n=this.cache.get(i);if(!n)return{hit:!1};let s=Date.now(),a=this.config.cache.ttl*60*1e3;return s-n.timestamp>a?(this.cache.delete(i),{hit:!1}):{hit:!0,groups:n.groups}}set(t,o,i){if(!this.config.cache.enabled||(this.cache.size>=this.config.cache.maxSize&&this.cleanup(),this.cache.size>=this.config.cache.maxSize))return;let n=this.generateHash(t,o),s={groups:i,timestamp:Date.now(),hash:n};this.cache.set(n,s)}cleanup(){let t=Date.now(),o=this.config.cache.ttl*60*1e3;for(let[i,n]of this.cache.entries())t-n.timestamp>o&&this.cache.delete(i);if(this.cache.size>=this.config.cache.maxSize){let n=Array.from(this.cache.entries()).sort((s,a)=>s[1].timestamp-a[1].timestamp).slice(0,Math.ceil(this.config.cache.maxSize*.5));for(let[s]of n)this.cache.delete(s)}}clear(){this.cache.clear()}getStats(){return{size:this.cache.size,maxSize:this.config.cache.maxSize,enabled:this.config.cache.enabled}}},$e=null});import{log as f}from"@clack/prompts";function Ye(e,t){let i=t.length>8e3?t.substring(0,8e3)+`
|
|
45
|
+
... (diff truncado)`:t,n=e.length,s=e.reduce((c,r)=>{let m=r.split(".").pop()||"sem-extensao";return c[m]=(c[m]||0)+1,c},{}),a=Object.entries(s).map(([c,r])=>`${c}: ${r}`).join(", ");return`Analise os arquivos modificados e agrupe em commits l\xF3gicos.
|
|
46
|
+
|
|
47
|
+
ARQUIVOS (${n}): ${e.join(", ")}
|
|
48
|
+
TIPOS: ${a}
|
|
107
49
|
|
|
108
50
|
DIFF RESUMIDO:
|
|
109
51
|
\`\`\`
|
|
110
|
-
${
|
|
52
|
+
${i}
|
|
111
53
|
\`\`\`
|
|
112
54
|
|
|
113
55
|
Agrupe arquivos relacionados. M\xE1ximo 5 grupos. Responda em JSON:
|
|
@@ -121,13 +63,13 @@ Agrupe arquivos relacionados. M\xE1ximo 5 grupos. Responda em JSON:
|
|
|
121
63
|
"confidence": 0.8
|
|
122
64
|
}
|
|
123
65
|
]
|
|
124
|
-
}`}function
|
|
66
|
+
}`}function Qe(e){let t=e.reduce((i,n)=>{let s=n.split("/").slice(0,-1).join("/")||"root";return i[s]||(i[s]=[]),i[s].push(n),i},{});return`Agrupe estes arquivos em commits l\xF3gicos baseado nos diret\xF3rios:
|
|
125
67
|
|
|
126
68
|
ARQUIVOS POR DIRET\xD3RIO:
|
|
127
|
-
${Object.entries(
|
|
69
|
+
${Object.entries(t).map(([i,n])=>`${i}: ${n.length} arquivo(s)`).join(`
|
|
128
70
|
`)}
|
|
129
71
|
|
|
130
|
-
LISTA COMPLETA: ${
|
|
72
|
+
LISTA COMPLETA: ${e.join(", ")}
|
|
131
73
|
|
|
132
74
|
Agrupe por funcionalidade relacionada. M\xE1ximo 5 grupos. JSON:
|
|
133
75
|
{
|
|
@@ -140,35 +82,35 @@ Agrupe por funcionalidade relacionada. M\xE1ximo 5 grupos. JSON:
|
|
|
140
82
|
"confidence": 0.7
|
|
141
83
|
}
|
|
142
84
|
]
|
|
143
|
-
}`}async function
|
|
144
|
-
... (diff truncado)`:
|
|
145
|
-
... (conte\xFAdo truncado)`:
|
|
85
|
+
}`}async function Ze(e,t,o){try{if(!o.openai.apiKey)return{success:!1,error:"Chave da OpenAI n\xE3o encontrada"};let i=Me(e,t);if(i.hit&&i.groups)return{success:!0,groups:i.groups};let s=t.length>6e3,a=s?Qe(e):Ye(e,t);s&&console.warn(`\u26A0\uFE0F Diff muito grande (${t.length} chars), usando an\xE1lise baseada em nomes de arquivos`);let c=await fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${o.openai.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({model:o.openai.model,messages:[{role:"user",content:a}],max_tokens:800,temperature:.3})});if(!c.ok){let p=await c.json().catch(()=>({}));return{success:!1,error:`Erro da OpenAI (${c.status}): ${p.error?.message||"Erro desconhecido"}`}}let m=(await c.json()).choices?.[0]?.message?.content?.trim();if(!m)return{success:!1,error:"OpenAI retornou resposta vazia"};let u=m.match(/\{[\s\S]*\}/);if(!u)return{success:!1,error:"Resposta da OpenAI n\xE3o cont\xE9m JSON v\xE1lido"};let g=JSON.parse(u[0]);if(!g.groups||!Array.isArray(g.groups))return{success:!1,error:"Formato de resposta inv\xE1lido da OpenAI"};let h=g.groups.flatMap(p=>p.files||[]),M=e.filter(p=>!h.includes(p));M.length>0&&(g.groups[0].files=[...g.groups[0].files||[],...M]);let y=g.groups.map(p=>({id:p.id||`group-${Math.random().toString(36).substr(2,9)}`,name:p.name||"Grupo sem nome",description:p.description||"Sem descri\xE7\xE3o",files:p.files||[],diff:"",confidence:p.confidence||.5}));return ze(e,t,y),{success:!0,groups:y}}catch(i){return{success:!1,error:`Erro ao analisar contexto: ${i instanceof Error?i.message:"Erro desconhecido"}`}}}async function Xe(e){let{getFileDiff:t}=await Promise.resolve().then(()=>(S(),E)),o=e.files.map(s=>{try{let a=t(s),c=4e3;return a.length>c?a.substring(0,c)+`
|
|
86
|
+
... (diff truncado)`:a}catch{return""}}).filter(s=>s.length>0);if(o.length===0&&e.files.length>0){let{execSync:s}=await import("child_process"),a=e.files.filter(r=>{try{return s(`test -f "${r}"`,{stdio:"ignore"}),s(`git status --porcelain -- "${r}"`,{encoding:"utf-8",stdio:"pipe"}).trim().startsWith("??")}catch{return!1}});if(a.length>0)return a.map(r=>{try{let m=s(`cat "${r}"`,{encoding:"utf-8",stdio:"pipe"}),u=2e3,g=m.length>u?m.substring(0,u)+`
|
|
87
|
+
... (conte\xFAdo truncado)`:m;return`diff --git a/${r} b/${r}
|
|
146
88
|
new file mode 100644
|
|
147
89
|
index 0000000..${Math.random().toString(36).substr(2,7)}
|
|
148
90
|
--- /dev/null
|
|
149
|
-
+++ b/${
|
|
150
|
-
@@ -0,0 +1,${
|
|
91
|
+
+++ b/${r}
|
|
92
|
+
@@ -0,0 +1,${g.split(`
|
|
151
93
|
`).length} @@
|
|
152
|
-
${
|
|
153
|
-
`).map(
|
|
154
|
-
`)}`}catch{return""}}).filter(
|
|
155
|
-
`);let
|
|
156
|
-
`).includes(
|
|
157
|
-
... (conte\xFAdo truncado)`:
|
|
94
|
+
${g.split(`
|
|
95
|
+
`).map(h=>`+${h}`).join(`
|
|
96
|
+
`)}`}catch{return""}}).filter(r=>r.length>0).join(`
|
|
97
|
+
`);let c=e.files.filter(r=>{try{return s(`test -f "${r}"`,{stdio:"ignore"}),s("git diff --cached --name-only",{encoding:"utf-8",stdio:"pipe"}).trim().split(`
|
|
98
|
+
`).includes(r)}catch{return!1}});if(c.length>0)return c.map(r=>{try{let m=s(`cat "${r}"`,{encoding:"utf-8",stdio:"pipe"}),u=2e3,g=m.length>u?m.substring(0,u)+`
|
|
99
|
+
... (conte\xFAdo truncado)`:m;return`diff --git a/${r} b/${r}
|
|
158
100
|
index 0000000..${Math.random().toString(36).substr(2,7)} 100644
|
|
159
|
-
--- a/${
|
|
160
|
-
+++ b/${
|
|
161
|
-
@@ -1 +1,${
|
|
101
|
+
--- a/${r}
|
|
102
|
+
+++ b/${r}
|
|
103
|
+
@@ -1 +1,${g.split(`
|
|
162
104
|
`).length} @@
|
|
163
|
-
${
|
|
164
|
-
`).map(
|
|
165
|
-
`)}`}catch{return""}}).filter(
|
|
166
|
-
`)}let
|
|
167
|
-
`),
|
|
168
|
-
... (diff total truncado)`:
|
|
169
|
-
\
|
|
170
|
-
`);if(!
|
|
171
|
-
\
|
|
105
|
+
${g.split(`
|
|
106
|
+
`).map(h=>`+${h}`).join(`
|
|
107
|
+
`)}`}catch{return""}}).filter(r=>r.length>0).join(`
|
|
108
|
+
`)}let i=o.join(`
|
|
109
|
+
`),n=8e3;return i.length>n?i.substring(0,n)+`
|
|
110
|
+
... (diff total truncado)`:i}async function oe(e,t,o){o.silent||f.info("\u{1F9E0} Modo Smart Split ativado - Agrupando arquivos por contexto"),o.silent||f.info("\u{1F916} Analisando contexto das mudan\xE7as...");let i=await Ze(e.stagedFiles,e.diff,t);if(!i.success){o.silent||f.error(`\u274C Erro na an\xE1lise de contexto: ${i.error}`);return}if(!i.groups||i.groups.length===0){o.silent||f.error("\u274C Nenhum grupo foi criado pela an\xE1lise");return}if(o.silent||(f.success(`\u2705 ${i.groups.length} grupo(s) identificado(s):`),i.groups.forEach((n,s)=>{f.info(` ${s+1}. ${n.name} (${n.files.length} arquivo(s))`),f.info(` \u{1F4C4} ${n.files.join(", ")}`)})),!o.yes&&!o.silent){let{showSmartSplitGroups:n}=await Promise.resolve().then(()=>(ee(),we)),s=await n(i.groups);if(s.action==="cancel"){o.silent||f.info("\u274C Opera\xE7\xE3o cancelada pelo usu\xE1rio");return}if(s.action==="manual"){let a={...o,split:!0,smartSplit:!1},{main:c}=await Promise.resolve().then(()=>(se(),Fe));await c(a);return}}for(let n=0;n<i.groups.length;n++){let s=i.groups[n];if(!s){o.silent||f.error(`\u274C Grupo ${n+1} \xE9 undefined`);continue}o.silent||f.info(`
|
|
111
|
+
\u{1F504} Processando grupo ${n+1}/${i.groups.length}: ${s.name}`);let a=await Xe(s);if(!a){o.silent||(f.warn(`\u26A0\uFE0F Nenhum diff encontrado para o grupo: ${s.name}`),f.info(` \u{1F4C4} Arquivos: ${s.files.join(", ")}`),f.info(" \u{1F4A1} Poss\xEDvel causa: arquivos novos, deletados/recriados, ou sem mudan\xE7as"));continue}o.silent||f.info(`\u{1F916} Gerando commit para: ${s.name}`);let{generateWithRetry:c}=await Promise.resolve().then(()=>(W(),xe)),r=await c(a,t,s.files);if(!r.success){o.silent||f.error(`\u274C Erro ao gerar commit para ${s.name}: ${r.error}`);continue}if(!r.suggestion){o.silent||f.error(`\u274C Nenhuma sugest\xE3o gerada para ${s.name}`);continue}if(t.dryRun){o.silent||(f.info(`\u{1F50D} Dry Run - Grupo: ${s.name}`),f.info(`\u{1F4C4} Arquivos: ${s.files.join(", ")}`),f.info(`\u{1F4AD} Mensagem: "${r.suggestion.message}"`));continue}if(o.yes){let{executeFileCommit:m}=await Promise.resolve().then(()=>(S(),E)),u;if(s.files.length===1&&s.files[0])u=m(s.files[0],r.suggestion.message||"");else{let{execSync:g}=await import("child_process"),{escapeShellArg:h}=await Promise.resolve().then(()=>(S(),E));try{let M=s.files.map(x=>h(x)).join(" "),y=h(r.suggestion.message||"");g(`git commit ${M} -m ${y}`,{stdio:"pipe"}),u={success:!0,hash:g("git rev-parse HEAD",{encoding:"utf-8",stdio:"pipe"}).trim(),message:r.suggestion.message||""}}catch(M){u={success:!1,error:M instanceof Error?M.message:"Erro desconhecido ao executar commit"}}}C(u.success,u.hash,u.error)}else{let{showCommitPreview:m,editCommitMessage:u,copyToClipboard:g,showCancellation:h}=await Promise.resolve().then(()=>(D(),Q));switch((await m(r.suggestion)).action){case"commit":{let{executeFileCommit:y}=await Promise.resolve().then(()=>(S(),E)),p,x=r.suggestion.message||"Atualiza\xE7\xE3o de arquivos";if(s.files.length===1&&s.files[0])p=y(s.files[0],x);else{let{execSync:I}=await import("child_process"),{escapeShellArg:O}=await Promise.resolve().then(()=>(S(),E));try{let v=s.files.map(H=>O(H)).join(" "),_=O(x);I(`git commit ${v} -m ${_}`,{stdio:"pipe"}),p={success:!0,hash:I("git rev-parse HEAD",{encoding:"utf-8",stdio:"pipe"}).trim(),message:x}}catch(v){p={success:!1,error:v instanceof Error?v.message:"Erro desconhecido ao executar commit"}}}C(p.success,p.hash,p.error);break}case"edit":{let y=await u(r.suggestion.message);if(y.action==="commit"&&y.message){let{executeFileCommit:p}=await Promise.resolve().then(()=>(S(),E)),x;if(s.files.length===1&&s.files[0])x=p(s.files[0],y.message||"");else{let{execSync:I}=await import("child_process"),{escapeShellArg:O}=await Promise.resolve().then(()=>(S(),E));try{let v=s.files.map(H=>O(H)).join(" "),_=O(y.message||"");I(`git commit ${v} -m ${_}`,{stdio:"pipe"}),x={success:!0,hash:I("git rev-parse HEAD",{encoding:"utf-8",stdio:"pipe"}).trim(),message:y.message||""}}catch(v){x={success:!1,error:v instanceof Error?v.message:"Erro desconhecido ao executar commit"}}}C(x.success,x.hash,x.error)}break}case"copy":{await g(r.suggestion.message),o.silent||f.info("\u{1F3AF} Mensagem copiada para clipboard");break}case"cancel":{h();return}}}if(n<i.groups.length-1&&!o.yes){let{askContinueCommits:m}=await Promise.resolve().then(()=>(D(),Q)),u=i.groups.slice(n+1).filter(h=>h!==void 0).map(h=>h.name);if(!await m(u))break}}o.silent||f.success("\u2705 Smart Split conclu\xEDdo!")}var Re=b(()=>{"use strict";d();ie();D()});var Fe={};P(Fe,{main:()=>ne});import{log as l}from"@clack/prompts";async function ne(e={silent:!1,yes:!1,auto:!1,split:!1,smartSplit:!1,dryRun:!1,help:!1,version:!1}){e.silent||l.info("\u{1F680} Commit Wizard iniciado!"),V()||(l.error("\u274C N\xE3o foi encontrado um reposit\xF3rio Git neste diret\xF3rio."),e.silent||l.info("\u{1F4A1} Execute o comando em um diret\xF3rio com reposit\xF3rio Git inicializado."),process.exit(1)),e.silent||l.info("\u2699\uFE0F Carregando configura\xE7\xE3o...");let t=le();Ae(t),e.split&&(t.splitCommits=!0),e.dryRun&&(t.dryRun=!0);let o=ue(t);o.length>0&&(l.error("\u274C Erros na configura\xE7\xE3o:"),o.forEach(a=>l.error(` \u2022 ${a}`)),process.exit(1)),e.silent||l.success(`\u2705 Configura\xE7\xE3o carregada (modelo: ${t.openai.model}, idioma: ${t.language})`),e.silent||l.info("\u{1F4CB} Verificando arquivos staged...");let i=K();i.hasStaged||(l.warn("\u26A0\uFE0F Nenhum arquivo foi encontrado no stage."),e.silent||l.info("\u{1F4A1} Use `git add <arquivo>` para adicionar arquivos ao stage antes de gerar o commit."),process.exit(0));let n=J();if(e.silent||(l.success(`\u2705 Encontrados ${i.stagedFiles.length} arquivo(s) staged:`),i.stagedFiles.forEach(a=>l.info(` \u{1F4C4} ${a}`)),l.info(`\u{1F4CA} Estat\xEDsticas: +${n.added} -${n.removed} linhas`)),t.splitCommits||e.smartSplit){if(e.yes)return await oe(i,t,e);switch((await X()).action){case"proceed":return await oe(i,t,e);case"manual":return await et(i,t,e);case"cancel":G();return}}e.silent||l.info("\u{1F916} Gerando mensagem de commit com IA...");let s=await q(i.diff,t,i.stagedFiles);if(s.success||(l.error(`\u274C Erro ao gerar commit: ${s.error}`),process.exit(1)),s.suggestion||(l.error("\u274C Nenhuma sugest\xE3o foi gerada"),process.exit(1)),e.silent||l.success("\u2728 Mensagem de commit gerada!"),t.dryRun){l.info("\u{1F50D} Modo Dry Run - Mensagem gerada:"),l.info(`"${s.suggestion.message}"`),l.info("\u{1F4A1} Execute sem --dry-run para fazer o commit");return}if(e.yes){let a=z(s.suggestion.message);C(a.success,a.hash,a.error);return}for(;;)switch((await N(s.suggestion)).action){case"commit":{let c=z(s.suggestion.message);C(c.success,c.hash,c.error);return}case"edit":{let c=await L(s.suggestion.message);if(c.action==="cancel"){G();return}if(c.action==="commit"&&c.message){let r=z(c.message);C(r.success,r.hash,r.error);return}break}case"copy":{await U(s.suggestion.message),e.silent||l.info('\u{1F3AF} Voc\xEA pode usar a mensagem copiada com: git commit -m "mensagem"');return}case"cancel":{G();return}}}async function et(e,t,o){o.silent||l.info("\u{1F504} Modo Split ativado - Commits separados por arquivo");let i=[...e.stagedFiles];for(;i.length>0;){let n=o.yes?[i[0]]:await B(i);if(n.length===0){o.silent||l.info("\u274C Nenhum arquivo selecionado");break}let{getFileDiff:s}=await Promise.resolve().then(()=>(S(),E)),a=n.filter(r=>r!==void 0).map(r=>{try{return s(r)}catch(m){return l.error(`\u274C Erro ao obter diff do arquivo ${r}: ${m instanceof Error?m.message:"Erro desconhecido"}`),""}}).filter(r=>r.length>0).join(`
|
|
112
|
+
`);if(!a){o.silent||l.warn("\u26A0\uFE0F Nenhum diff encontrado para os arquivos selecionados"),i=i.filter(r=>!n.includes(r));continue}o.silent||l.info(`\u{1F916} Gerando commit para: ${n.join(", ")}`);let c=await q(a,t,n.filter(r=>r!==void 0));if(!c.success){l.error(`\u274C Erro ao gerar commit: ${c.error}`),i=i.filter(r=>!n.includes(r));continue}if(!c.suggestion){l.error("\u274C Nenhuma sugest\xE3o foi gerada"),i=i.filter(r=>!n.includes(r));continue}if(t.dryRun){l.info(`\u{1F50D} Dry Run - Mensagem para ${n.join(", ")}:`),l.info(`"${c.suggestion.message}"`),i=i.filter(r=>!n.includes(r));continue}if(o.yes){let r=n.length===1&&n[0]?await j(n[0],c.suggestion.message):await z(c.suggestion.message);C(r.success,r.hash,r.error)}else{let r=await N(c.suggestion);if(r.action==="commit"){let m=n.length===1&&n[0]?await j(n[0],c.suggestion.message):await z(c.suggestion.message);C(m.success,m.hash,m.error)}else if(r.action==="edit"){let m=await L(c.suggestion.message);if(m.action==="commit"&&m.message){let u=n.length===1&&n[0]?await j(n[0],m.message):await z(m.message);C(u.success,u.hash,u.error)}}else if(r.action==="copy")await U(c.suggestion.message),o.silent||l.info("\u{1F3AF} Mensagem copiada para clipboard");else if(r.action==="cancel"){G();return}}if(i=i.filter(r=>!n.includes(r)),i.length>0&&!o.yes&&!await Y(i))break}o.silent||l.success("\u2705 Modo Split conclu\xEDdo!")}var se=b(()=>{"use strict";d();pe();S();W();D();ee();Re();ie()});d();se();import{intro as tt,outro as it,log as ot}from"@clack/prompts";d();function Ge(e){return{silent:e.includes("--silent")||e.includes("-s"),yes:e.includes("--yes")||e.includes("-y"),auto:e.includes("--auto")||e.includes("-a"),split:e.includes("--split"),smartSplit:e.includes("--smart-split"),dryRun:e.includes("--dry-run")||e.includes("-n"),help:e.includes("--help")||e.includes("-h"),version:e.includes("--version")||e.includes("-v")}}function Ie(){console.log(`
|
|
113
|
+
\u{1F9D9}\u200D\u2642\uFE0F Commit Wizard - Gerador inteligente de mensagens de commit
|
|
172
114
|
|
|
173
115
|
USAGE:
|
|
174
116
|
commit-wizard [OPTIONS]
|
|
@@ -192,4 +134,4 @@ EXAMPLES:
|
|
|
192
134
|
commit-wizard --auto # Modo totalmente autom\xE1tico
|
|
193
135
|
|
|
194
136
|
Para mais informa\xE7\xF5es, visite: https://github.com/user/commit-wizard
|
|
195
|
-
`)}function
|
|
137
|
+
`)}function Oe(){console.log("commit-wizard v1.0.0")}async function st(){try{let e=Ge(process.argv.slice(2));e.help&&(Ie(),process.exit(0)),e.version&&(Oe(),process.exit(0)),e.auto&&(e.silent=!0,e.yes=!0),e.silent||tt("\u{1F9D9}\u200D\u2642\uFE0F Commit Wizard"),await ne(e),e.silent||it("At\xE9 logo! \u2728")}catch(e){ot.error(`Erro: ${e instanceof Error?e.message:"Erro desconhecido"}`),process.exit(1)}}import.meta.url===`file://${process.argv[1]}`&&st();
|