@r5n/sisyphus 0.4.4 → 0.4.5

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/dist/cli.js CHANGED
@@ -1,995 +1,208 @@
1
- // @bun
2
- var qo=Object.create;var{getPrototypeOf:Lo,defineProperty:$t,getOwnPropertyNames:No}=Object;var Uo=Object.prototype.hasOwnProperty;var me=(e,t,n)=>{n=e!=null?qo(Lo(e)):{};let o=t||!e||!e.__esModule?$t(n,"default",{value:e,enumerable:!0}):n;for(let i of No(e))if(!Uo.call(o,i))$t(o,i,{get:()=>e[i],enumerable:!0});return o};var dn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Wo=(e,t)=>{for(var n in t)$t(e,n,{get:t[n],enumerable:!0,configurable:!0,set:(o)=>t[n]=()=>o})};var O=(e,t)=>()=>(e&&(t=e(e=0)),t);var Je=import.meta.require;function vt(e){return(t)=>zo?`${e}${t}${yn.reset}`:t}function gn({bright:e=!1,color:t}){let n=Bun.color(t,"ansi");if(!n||typeof n!=="string")return"";return e&&n in hn?hn[n]:n}var zo,Jo,Ko,yn,hn,Zo,Vo,f;var xt=O(()=>{zo=!process.env.NO_COLOR&&(process.env.FORCE_COLOR||(process.stdout?.isTTY??!1)),Jo=["blue","cyan","gray","green","magenta","red","white","yellow"],Ko=["bold","dim","italic","underline","reset"],yn={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",reset:"\x1B[0m",underline:"\x1B[4m"},hn={"\x1B[30m":"\x1B[90m","\x1B[31m":"\x1B[91m","\x1B[32m":"\x1B[92m","\x1B[33m":"\x1B[93m","\x1B[34m":"\x1B[94m","\x1B[35m":"\x1B[95m","\x1B[36m":"\x1B[96m","\x1B[37m":"\x1B[97m"};Zo=Jo.reduce((e,t)=>{let n=gn({color:t});if(n)e[t]=vt(n);let o=gn({bright:!0,color:t});if(o)e[`${t}Bright`]=vt(o);return e},{}),Vo=Ko.reduce((e,t)=>{return e[t]=vt(yn[t]),e},{}),f={...Zo,...Vo}});function Xo({prefix:e,level:t,message:n}){let o="";try{let s=new Date().toISOString().split("T")[1];if(s)o=s.split(".")[0]||""}catch{o="00:00:00"}let i=e?`[${e}] `:"";return`${f.dim(o)} ${t} ${i}${n}`}var Yo,v=({prefix:e="",level:t=process.env.DEBUG?0:1}={})=>{let n={};for(let o of Yo)n[o.method]=t<=o.level?(...i)=>{let r=i.map((s)=>String(s??"")).join(" ");o.console(Xo({level:o.color(o.label),message:r,prefix:e}))}:()=>{};return n.child=(o)=>v({level:t,prefix:`${e}:${o}`}),n},Ct;var bn=O(()=>{xt();Yo=[{color:f.dim,console:console.log,label:"DEBUG",level:0,method:"debug"},{color:f.cyan,console:console.info,label:"INFO ",level:1,method:"info"},{color:f.yellow,console:console.warn,label:"WARN ",level:2,method:"warn"},{color:f.red,console:console.error,label:"ERROR",level:3,method:"error"}],Ct=v()});var I=O(()=>{xt();bn()});var p;var St=O(()=>{I();p={arrow:f.yellow,bold:f.bold,boolean:f.cyan,bullet:f.yellow,busy:f.yellow,command:f.green,dim:f.dim,error:f.red,flag:f.yellow,info:f.cyan,number:f.magenta,offline:f.red,online:f.green,separator:f.dim,string:f.green,success:f.green,value:f.cyan,warning:f.yellow}});var Rt=dn((Tc,wn)=>{var kt={to(e,t){if(!t)return`\x1B[${e+1}G`;return`\x1B[${t+1};${e+1}H`},move(e,t){let n="";if(e<0)n+=`\x1B[${-e}D`;else if(e>0)n+=`\x1B[${e}C`;if(t<0)n+=`\x1B[${-t}A`;else if(t>0)n+=`\x1B[${t}B`;return n},up:(e=1)=>`\x1B[${e}A`,down:(e=1)=>`\x1B[${e}B`,forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},Qo={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},Fo={screen:"\x1B[2J",up:(e=1)=>"\x1B[1J".repeat(e),down:(e=1)=>"\x1B[J".repeat(e),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(e){let t="";for(let n=0;n<e;n++)t+=this.line+(n<e-1?kt.up():"");if(e)t+=kt.left;return t}};wn.exports={cursor:kt,scroll:Qo,erase:Fo,beep:"\x07"}});var It=dn((qc,jt)=>{var Ze=process||{},$n=Ze.argv||[],Ke=Ze.env||{},Do=!(!!Ke.NO_COLOR||$n.includes("--no-color"))&&(!!Ke.FORCE_COLOR||$n.includes("--color")||Ze.platform==="win32"||(Ze.stdout||{}).isTTY&&Ke.TERM!=="dumb"||!!Ke.CI),ei=(e,t,n=e)=>(o)=>{let i=""+o,r=i.indexOf(t,e.length);return~r?e+ti(i,t,n,r)+t:e+i+t},ti=(e,t,n,o)=>{let i="",r=0;do i+=e.substring(r,o)+n,r=o+t.length,o=e.indexOf(t,r);while(~o);return i+e.substring(r)},vn=(e=Do)=>{let t=e?ei:()=>String;return{isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};jt.exports=vn();jt.exports.createColors=vn});import{stdin as Pn,stdout as An}from"process";import*as ce from"readline";import xn from"readline";import{Writable as ni}from"stream";function si({onlyFirst:e=!1}={}){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}function Mn(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(oi,"")}function On(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Pe(e,t={}){if(typeof e!="string"||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=Mn(e),e.length===0))return 0;e=e.replace(ci()," ");let n=t.ambiguousIsNarrow?1:2,o=0;for(let i of e){let r=i.codePointAt(0);if(r<=31||r>=127&&r<=159||r>=768&&r<=879)continue;switch(ri.eastAsianWidth(i)){case"F":case"W":o+=2;break;case"A":o+=n;break;default:o+=1}}return o}function mi(){let e=new Map;for(let[t,n]of Object.entries(H)){for(let[o,i]of Object.entries(n))H[o]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},n[o]=H[o],e.set(i[0],i[1]);Object.defineProperty(H,t,{value:n,enumerable:!1})}return Object.defineProperty(H,"codes",{value:e,enumerable:!1}),H.color.close="\x1B[39m",H.bgColor.close="\x1B[49m",H.color.ansi=Cn(),H.color.ansi256=Sn(),H.color.ansi16m=kn(),H.bgColor.ansi=Cn(_t),H.bgColor.ansi256=Sn(_t),H.bgColor.ansi16m=kn(_t),Object.defineProperties(H,{rgbToAnsi256:{value:(t,n,o)=>t===n&&n===o?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(o/255*5),enumerable:!1},hexToRgb:{value:(t)=>{let n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!n)return[0,0,0];let[o]=n;o.length===3&&(o=[...o].map((r)=>r+r).join(""));let i=Number.parseInt(o,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:(t)=>H.rgbToAnsi256(...H.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value:(t)=>{if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,o,i;if(t>=232)n=((t-232)*10+8)/255,o=n,i=n;else{t-=16;let a=t%36;n=Math.floor(t/36)/5,o=Math.floor(a/6)/5,i=a%6/5}let r=Math.max(n,o,i)*2;if(r===0)return 30;let s=30+(Math.round(i)<<2|Math.round(o)<<1|Math.round(n));return r===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(t,n,o)=>H.ansi256ToAnsi(H.rgbToAnsi256(t,n,o)),enumerable:!1},hexToAnsi:{value:(t)=>H.ansi256ToAnsi(H.hexToAnsi256(t)),enumerable:!1}}),H}function In(e,t,n){return String(e).normalize().replace(/\r\n/g,`
1
+ #!/usr/bin/env bun
2
+ var rt=Object.create;var{getPrototypeOf:it,defineProperty:_o,getOwnPropertyNames:st}=Object;var tt=Object.prototype.hasOwnProperty;var F=(n,o,i)=>{i=n!=null?rt(it(n)):{};let s=o||!n||!n.__esModule?_o(i,"default",{value:n,enumerable:!0}):i;for(let t of st(n))if(!tt.call(s,t))_o(s,t,{get:()=>n[t],enumerable:!0});return s};var Tr=(n,o)=>()=>(o||n((o={exports:{}}).exports,o),o.exports);var An=(n,o)=>{for(var i in o)_o(n,i,{get:o[i],enumerable:!0,configurable:!0,set:(s)=>o[i]=()=>s})};var T=(n,o)=>()=>(n&&(o=n(n=0)),o);var Co=import.meta.require;function To(n){return(o)=>et?`${n}${o}${Mr.reset}`:o}function Ar({bright:n=!1,color:o}){let i=Bun.color(o,"ansi");if(!i||typeof i!=="string")return"";return n&&i in Br?Br[i]:i}var et,at,ct,Mr,Br,pt,lt,h;var Bo=T(()=>{et=!process.env.NO_COLOR&&(process.env.FORCE_COLOR||(process.stdout?.isTTY??!1)),at=["blue","cyan","gray","green","magenta","red","white","yellow"],ct=["bold","dim","italic","underline","reset"],Mr={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",reset:"\x1B[0m",underline:"\x1B[4m"},Br={"\x1B[30m":"\x1B[90m","\x1B[31m":"\x1B[91m","\x1B[32m":"\x1B[92m","\x1B[33m":"\x1B[93m","\x1B[34m":"\x1B[94m","\x1B[35m":"\x1B[95m","\x1B[36m":"\x1B[96m","\x1B[37m":"\x1B[97m"};pt=at.reduce((n,o)=>{let i=Ar({color:o});if(i)n[o]=To(i);let s=Ar({bright:!0,color:o});if(s)n[`${o}Bright`]=To(s);return n},{}),lt=ct.reduce((n,o)=>{return n[o]=To(Mr[o]),n},{}),h={...pt,...lt}});function mt({prefix:n,level:o,message:i}){let s="";try{let r=new Date().toISOString().split("T")[1];if(r)s=r.split(".")[0]||""}catch{s="00:00:00"}let t=n?`[${n}] `:"";return`${h.dim(s)} ${o} ${t}${i}`}var ft,R=({prefix:n="",level:o=process.env.DEBUG?0:1}={})=>{let i={};for(let s of ft)i[s.method]=o<=s.level?(...t)=>{let e=t.map((r)=>String(r??"")).join(" ");s.console(mt({level:s.color(s.label),message:e,prefix:n}))}:()=>{};return i.child=(s)=>R({level:o,prefix:`${n}:${s}`}),i},Ao;var Lr=T(()=>{Bo();ft=[{color:h.dim,console:console.log,label:"DEBUG",level:0,method:"debug"},{color:h.cyan,console:console.info,label:"INFO ",level:1,method:"info"},{color:h.yellow,console:console.warn,label:"WARN ",level:2,method:"warn"},{color:h.red,console:console.error,label:"ERROR",level:3,method:"error"}],Ao=R()});var _=T(()=>{Bo();Lr()});var l;var Mo=T(()=>{_();l={arrow:h.yellow,bold:h.bold,boolean:h.cyan,bullet:h.yellow,busy:h.yellow,command:h.green,dim:h.dim,error:h.red,flag:h.yellow,info:h.cyan,number:h.magenta,offline:h.red,online:h.green,separator:h.dim,string:h.green,success:h.green,value:h.cyan,warning:h.yellow}});var Mn=Tr((Bp,Lo)=>{var Fn=process||{},Nr=Fn.argv||[],Vn=Fn.env||{},ut=!(!!Vn.NO_COLOR||Nr.includes("--no-color"))&&(!!Vn.FORCE_COLOR||Nr.includes("--color")||Fn.platform==="win32"||(Fn.stdout||{}).isTTY&&Vn.TERM!=="dumb"||!!Vn.CI),gt=(n,o,i=n)=>(s)=>{let t=""+s,e=t.indexOf(o,n.length);return~e?n+ht(t,o,i,e)+o:n+t+o},ht=(n,o,i,s)=>{let t="",e=0;do t+=n.substring(e,s)+i,e=s+o.length,s=n.indexOf(o,e);while(~s);return t+n.substring(e)},Hr=(n=ut)=>{let o=n?gt:()=>String;return{isColorSupported:n,reset:o("\x1B[0m","\x1B[0m"),bold:o("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:o("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:o("\x1B[3m","\x1B[23m"),underline:o("\x1B[4m","\x1B[24m"),inverse:o("\x1B[7m","\x1B[27m"),hidden:o("\x1B[8m","\x1B[28m"),strikethrough:o("\x1B[9m","\x1B[29m"),black:o("\x1B[30m","\x1B[39m"),red:o("\x1B[31m","\x1B[39m"),green:o("\x1B[32m","\x1B[39m"),yellow:o("\x1B[33m","\x1B[39m"),blue:o("\x1B[34m","\x1B[39m"),magenta:o("\x1B[35m","\x1B[39m"),cyan:o("\x1B[36m","\x1B[39m"),white:o("\x1B[37m","\x1B[39m"),gray:o("\x1B[90m","\x1B[39m"),bgBlack:o("\x1B[40m","\x1B[49m"),bgRed:o("\x1B[41m","\x1B[49m"),bgGreen:o("\x1B[42m","\x1B[49m"),bgYellow:o("\x1B[43m","\x1B[49m"),bgBlue:o("\x1B[44m","\x1B[49m"),bgMagenta:o("\x1B[45m","\x1B[49m"),bgCyan:o("\x1B[46m","\x1B[49m"),bgWhite:o("\x1B[47m","\x1B[49m"),blackBright:o("\x1B[90m","\x1B[39m"),redBright:o("\x1B[91m","\x1B[39m"),greenBright:o("\x1B[92m","\x1B[39m"),yellowBright:o("\x1B[93m","\x1B[39m"),blueBright:o("\x1B[94m","\x1B[39m"),magentaBright:o("\x1B[95m","\x1B[39m"),cyanBright:o("\x1B[96m","\x1B[39m"),whiteBright:o("\x1B[97m","\x1B[39m"),bgBlackBright:o("\x1B[100m","\x1B[49m"),bgRedBright:o("\x1B[101m","\x1B[49m"),bgGreenBright:o("\x1B[102m","\x1B[49m"),bgYellowBright:o("\x1B[103m","\x1B[49m"),bgBlueBright:o("\x1B[104m","\x1B[49m"),bgMagentaBright:o("\x1B[105m","\x1B[49m"),bgCyanBright:o("\x1B[106m","\x1B[49m"),bgWhiteBright:o("\x1B[107m","\x1B[49m")}};Lo.exports=Hr();Lo.exports.createColors=Hr});var Ln=Tr((Ap,Gr)=>{var No={to(n,o){if(!o)return`\x1B[${n+1}G`;return`\x1B[${o+1};${n+1}H`},move(n,o){let i="";if(n<0)i+=`\x1B[${-n}D`;else if(n>0)i+=`\x1B[${n}C`;if(o<0)i+=`\x1B[${-o}A`;else if(o>0)i+=`\x1B[${o}B`;return i},up:(n=1)=>`\x1B[${n}A`,down:(n=1)=>`\x1B[${n}B`,forward:(n=1)=>`\x1B[${n}C`,backward:(n=1)=>`\x1B[${n}D`,nextLine:(n=1)=>"\x1B[E".repeat(n),prevLine:(n=1)=>"\x1B[F".repeat(n),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},dt={up:(n=1)=>"\x1B[S".repeat(n),down:(n=1)=>"\x1B[T".repeat(n)},yt={screen:"\x1B[2J",up:(n=1)=>"\x1B[1J".repeat(n),down:(n=1)=>"\x1B[J".repeat(n),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(n){let o="";for(let i=0;i<n;i++)o+=this.line+(i<n-1?No.up():"");if(n)o+=No.left;return o}};Gr.exports={cursor:No,scroll:dt,erase:yt,beep:"\x07"}});import{stdout as bt,stdin as wt}from"process";import $t from"readline";function Jr(n,o,i){return String(n).normalize().replaceAll(`\r
3
+ `,`
3
4
  `).split(`
4
- `).map((o)=>yi(o,t,n)).join(`
5
- `)}function Mt(e,t){if(typeof e=="string")return Ye.aliases.get(e)===t;for(let n of e)if(n!==void 0&&Mt(n,t))return!0;return!1}function wi(e,t){if(e===t)return;let n=e.split(`
6
- `),o=t.split(`
7
- `),i=[];for(let r=0;r<Math.max(n.length,o.length);r++)n[r]!==o[r]&&i.push(r);return i}function oe(e){return e===Pt}function Ve(e,t){let n=e;n.isTTY&&n.setRawMode(t)}function qn({input:e=Pn,output:t=An,overwrite:n=!0,hideCursor:o=!0}={}){let i=ce.createInterface({input:e,output:t,prompt:"",tabSize:1});ce.emitKeypressEvents(e,i),e.isTTY&&e.setRawMode(!0);let r=(s,{name:a,sequence:c})=>{let l=String(s);if(Mt([l,a,c],"cancel")){o&&t.write(W.cursor.show),process.exit(0);return}if(!n)return;ce.moveCursor(t,a==="return"?0:-1,a==="return"?-1:0,()=>{ce.clearLine(t,1,()=>{e.once("keypress",r)})})};return o&&t.write(W.cursor.hide),e.once("keypress",r),()=>{e.off("keypress",r),o&&t.write(W.cursor.show),e.isTTY&&!$i&&e.setRawMode(!1),i.terminal=!1,i.close()}}class Ae{constructor(e,t=!0){Z(this,"input"),Z(this,"output"),Z(this,"_abortSignal"),Z(this,"rl"),Z(this,"opts"),Z(this,"_render"),Z(this,"_track",!1),Z(this,"_prevFrame",""),Z(this,"_subscribers",new Map),Z(this,"_cursor",0),Z(this,"state","initial"),Z(this,"error",""),Z(this,"value");let{input:n=Pn,output:o=An,render:i,signal:r,...s}=e;this.opts=s,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=t,this._abortSignal=r,this.input=n,this.output=o}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let n=this._subscribers.get(e)??[];n.push(t),this._subscribers.set(e,n)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let n=this._subscribers.get(e)??[],o=[];for(let i of n)i.cb(...t),i.once&&o.push(()=>n.splice(n.indexOf(i),1));for(let i of o)i()}prompt(){return new Promise((e,t)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(Pt);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}let n=new ni;n._write=(o,i,r)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,""),this._cursor=this.rl?.cursor??0,this.emit("value",this.value)),r()},this.input.pipe(n),this.rl=xn.createInterface({input:this.input,output:n,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),xn.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),Ve(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(W.cursor.show),this.output.off("resize",this.render),Ve(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(W.cursor.show),this.output.off("resize",this.render),Ve(this.input,!1),e(Pt)})})}onKeypress(e,t){if(this.state==="error"&&(this.state="active"),t?.name&&(!this._track&&Ye.aliases.has(t.name)&&this.emit("cursor",Ye.aliases.get(t.name)),Ye.actions.has(t.name)&&this.emit("cursor",t.name)),e&&(e.toLowerCase()==="y"||e.toLowerCase()==="n")&&this.emit("confirm",e.toLowerCase()==="y"),e==="\t"&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),e&&this.emit("key",e.toLowerCase()),t?.name==="return"){if(this.opts.validate){let n=this.opts.validate(this.value);n&&(this.error=n instanceof Error?n.message:n,this.state="error",this.rl?.write(this.value))}this.state!=="error"&&(this.state="submit")}Mt([e,t?.name,t?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
8
- `),Ve(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=In(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
9
- `).length-1;this.output.write(W.cursor.move(-999,e*-1))}render(){let e=In(this._render(this)??"",process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(W.cursor.hide);else{let t=wi(this._prevFrame,e);if(this.restoreCursor(),t&&t?.length===1){let n=t[0];this.output.write(W.cursor.move(0,n)),this.output.write(W.erase.lines(1));let o=e.split(`
10
- `);this.output.write(o[n]),this._prevFrame=e,this.output.write(W.cursor.move(0,o.length-n-1));return}if(t&&t?.length>1){let n=t[0];this.output.write(W.cursor.move(0,n)),this.output.write(W.erase.down());let o=e.split(`
11
- `).slice(n);this.output.write(o.join(`
12
- `)),this._prevFrame=e;return}this.output.write(W.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}}var W,Bn,oi,Gn,ii,ri,ai=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},ci,_t=10,Cn=(e=0)=>(t)=>`\x1B[${t+e}m`,Sn=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,kn=(e=0)=>(t,n,o)=>`\x1B[${38+e};2;${t};${n};${o}m`,H,li,pi,ui,Xe,fi=39,At="\x07",Hn="[",di="]",Tn="m",Bt,Rn=(e)=>`${Xe.values().next().value}${Hn}${e}${Tn}`,jn=(e)=>`${Xe.values().next().value}${Bt}${e}${At}`,hi=(e)=>e.split(" ").map((t)=>Pe(t)),Et=(e,t,n)=>{let o=[...t],i=!1,r=!1,s=Pe(Mn(e[e.length-1]));for(let[a,c]of o.entries()){let l=Pe(c);if(s+l<=n?e[e.length-1]+=c:(e.push(c),s=0),Xe.has(c)&&(i=!0,r=o.slice(a+1).join("").startsWith(Bt)),i){r?c===At&&(i=!1,r=!1):c===Tn&&(i=!1);continue}s+=l,s===n&&a<o.length-1&&(e.push(""),s=0)}!s&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},gi=(e)=>{let t=e.split(" "),n=t.length;for(;n>0&&!(Pe(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},yi=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let o="",i,r,s=hi(e),a=[""];for(let[l,m]of e.split(" ").entries()){n.trim!==!1&&(a[a.length-1]=a[a.length-1].trimStart());let u=Pe(a[a.length-1]);if(l!==0&&(u>=t&&(n.wordWrap===!1||n.trim===!1)&&(a.push(""),u=0),(u>0||n.trim===!1)&&(a[a.length-1]+=" ",u++)),n.hard&&s[l]>t){let g=t-u,w=1+Math.floor((s[l]-g-1)/t);Math.floor((s[l]-1)/t)<w&&a.push(""),Et(a,m,t);continue}if(u+s[l]>t&&u>0&&s[l]>0){if(n.wordWrap===!1&&u<t){Et(a,m,t);continue}a.push("")}if(u+s[l]>t&&n.wordWrap===!1){Et(a,m,t);continue}a[a.length-1]+=m}n.trim!==!1&&(a=a.map((l)=>gi(l)));let c=[...a.join(`
13
- `)];for(let[l,m]of c.entries()){if(o+=m,Xe.has(m)){let{groups:g}=new RegExp(`(?:\\${Hn}(?<code>\\d+)m|\\${Bt}(?<uri>.*)${At})`).exec(c.slice(l).join(""))||{groups:{}};if(g.code!==void 0){let w=Number.parseFloat(g.code);i=w===fi?void 0:w}else g.uri!==void 0&&(r=g.uri.length===0?void 0:g.uri)}let u=ui.codes.get(Number(i));c[l+1]===`
14
- `?(r&&(o+=jn("")),i&&u&&(o+=Rn(u))):m===`
15
- `&&(i&&u&&(o+=Rn(i)),r&&(o+=jn(r)))}return o},bi,Ye,$i,Pt,vi,xi=(e,t,n)=>(t in e)?vi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Z=(e,t,n)=>(xi(e,typeof t!="symbol"?t+"":t,n),n),Ot,Ci,Si,ki=(e,t,n)=>(t in e)?Si(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_n=(e,t,n)=>(ki(e,typeof t!="symbol"?t+"":t,n),n),Ln,Ri,ji=(e,t,n)=>(t in e)?Ri(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,En=(e,t,n)=>(ji(e,typeof t!="symbol"?t+"":t,n),n),Gt,Ht;var Tt=O(()=>{W=me(Rt(),1),Bn=me(It(),1);oi=si();Gn={exports:{}};(function(e){var t={};e.exports=t,t.eastAsianWidth=function(o){var i=o.charCodeAt(0),r=o.length==2?o.charCodeAt(1):0,s=i;return 55296<=i&&i<=56319&&56320<=r&&r<=57343&&(i&=1023,r&=1023,s=i<<10|r,s+=65536),s==12288||65281<=s&&s<=65376||65504<=s&&s<=65510?"F":s==8361||65377<=s&&s<=65470||65474<=s&&s<=65479||65482<=s&&s<=65487||65490<=s&&s<=65495||65498<=s&&s<=65500||65512<=s&&s<=65518?"H":4352<=s&&s<=4447||4515<=s&&s<=4519||4602<=s&&s<=4607||9001<=s&&s<=9002||11904<=s&&s<=11929||11931<=s&&s<=12019||12032<=s&&s<=12245||12272<=s&&s<=12283||12289<=s&&s<=12350||12353<=s&&s<=12438||12441<=s&&s<=12543||12549<=s&&s<=12589||12593<=s&&s<=12686||12688<=s&&s<=12730||12736<=s&&s<=12771||12784<=s&&s<=12830||12832<=s&&s<=12871||12880<=s&&s<=13054||13056<=s&&s<=19903||19968<=s&&s<=42124||42128<=s&&s<=42182||43360<=s&&s<=43388||44032<=s&&s<=55203||55216<=s&&s<=55238||55243<=s&&s<=55291||63744<=s&&s<=64255||65040<=s&&s<=65049||65072<=s&&s<=65106||65108<=s&&s<=65126||65128<=s&&s<=65131||110592<=s&&s<=110593||127488<=s&&s<=127490||127504<=s&&s<=127546||127552<=s&&s<=127560||127568<=s&&s<=127569||131072<=s&&s<=194367||177984<=s&&s<=196605||196608<=s&&s<=262141?"W":32<=s&&s<=126||162<=s&&s<=163||165<=s&&s<=166||s==172||s==175||10214<=s&&s<=10221||10629<=s&&s<=10630?"Na":s==161||s==164||167<=s&&s<=168||s==170||173<=s&&s<=174||176<=s&&s<=180||182<=s&&s<=186||188<=s&&s<=191||s==198||s==208||215<=s&&s<=216||222<=s&&s<=225||s==230||232<=s&&s<=234||236<=s&&s<=237||s==240||242<=s&&s<=243||247<=s&&s<=250||s==252||s==254||s==257||s==273||s==275||s==283||294<=s&&s<=295||s==299||305<=s&&s<=307||s==312||319<=s&&s<=322||s==324||328<=s&&s<=331||s==333||338<=s&&s<=339||358<=s&&s<=359||s==363||s==462||s==464||s==466||s==468||s==470||s==472||s==474||s==476||s==593||s==609||s==708||s==711||713<=s&&s<=715||s==717||s==720||728<=s&&s<=731||s==733||s==735||768<=s&&s<=879||913<=s&&s<=929||931<=s&&s<=937||945<=s&&s<=961||963<=s&&s<=969||s==1025||1040<=s&&s<=1103||s==1105||s==8208||8211<=s&&s<=8214||8216<=s&&s<=8217||8220<=s&&s<=8221||8224<=s&&s<=8226||8228<=s&&s<=8231||s==8240||8242<=s&&s<=8243||s==8245||s==8251||s==8254||s==8308||s==8319||8321<=s&&s<=8324||s==8364||s==8451||s==8453||s==8457||s==8467||s==8470||8481<=s&&s<=8482||s==8486||s==8491||8531<=s&&s<=8532||8539<=s&&s<=8542||8544<=s&&s<=8555||8560<=s&&s<=8569||s==8585||8592<=s&&s<=8601||8632<=s&&s<=8633||s==8658||s==8660||s==8679||s==8704||8706<=s&&s<=8707||8711<=s&&s<=8712||s==8715||s==8719||s==8721||s==8725||s==8730||8733<=s&&s<=8736||s==8739||s==8741||8743<=s&&s<=8748||s==8750||8756<=s&&s<=8759||8764<=s&&s<=8765||s==8776||s==8780||s==8786||8800<=s&&s<=8801||8804<=s&&s<=8807||8810<=s&&s<=8811||8814<=s&&s<=8815||8834<=s&&s<=8835||8838<=s&&s<=8839||s==8853||s==8857||s==8869||s==8895||s==8978||9312<=s&&s<=9449||9451<=s&&s<=9547||9552<=s&&s<=9587||9600<=s&&s<=9615||9618<=s&&s<=9621||9632<=s&&s<=9633||9635<=s&&s<=9641||9650<=s&&s<=9651||9654<=s&&s<=9655||9660<=s&&s<=9661||9664<=s&&s<=9665||9670<=s&&s<=9672||s==9675||9678<=s&&s<=9681||9698<=s&&s<=9701||s==9711||9733<=s&&s<=9734||s==9737||9742<=s&&s<=9743||9748<=s&&s<=9749||s==9756||s==9758||s==9792||s==9794||9824<=s&&s<=9825||9827<=s&&s<=9829||9831<=s&&s<=9834||9836<=s&&s<=9837||s==9839||9886<=s&&s<=9887||9918<=s&&s<=9919||9924<=s&&s<=9933||9935<=s&&s<=9953||s==9955||9960<=s&&s<=9983||s==10045||s==10071||10102<=s&&s<=10111||11093<=s&&s<=11097||12872<=s&&s<=12879||57344<=s&&s<=63743||65024<=s&&s<=65039||s==65533||127232<=s&&s<=127242||127248<=s&&s<=127277||127280<=s&&s<=127337||127344<=s&&s<=127386||917760<=s&&s<=917999||983040<=s&&s<=1048573||1048576<=s&&s<=1114109?"A":"N"},t.characterLength=function(o){var i=this.eastAsianWidth(o);return i=="F"||i=="W"||i=="A"?2:1};function n(o){return o.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(o){for(var i=n(o),r=0,s=0;s<i.length;s++)r=r+this.characterLength(i[s]);return r},t.slice=function(o,i,r){textLen=t.length(o),i=i||0,r=r||1,i<0&&(i=textLen+i),r<0&&(r=textLen+r);for(var s="",a=0,c=n(o),l=0;l<c.length;l++){var m=c[l],u=t.length(m);if(a>=i-(u==2?1:0))if(a+u<=r)s+=m;else break;a+=u}return s}})(Gn);ii=Gn.exports,ri=On(ii),ci=On(ai);H={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(H.modifier);li=Object.keys(H.color),pi=Object.keys(H.bgColor);[...li];ui=mi(),Xe=new Set(["\x1B","\x9B"]),Bt=`${di}8;;`;bi=["up","down","left","right","space","enter","cancel"],Ye={actions:new Set(bi),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]])};$i=globalThis.process.platform.startsWith("win"),Pt=Symbol("clack:cancel");vi=Object.defineProperty;Ot=class Ot extends Ae{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",(t)=>{this.output.write(W.cursor.move(0,-1)),this.value=t,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};Ci=new WeakMap;Si=Object.defineProperty,Ln=class extends Ae{constructor(e){super(e,!1),_n(this,"options"),_n(this,"cursor",0),this.options=e.options,this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0),this.on("key",(t)=>{t==="a"&&this.toggleAll()}),this.on("cursor",(t)=>{switch(t){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;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let e=this.value.length===this.options.length;this.value=e?[]:this.options.map((t)=>t.value)}toggleValue(){let e=this.value.includes(this._value);this.value=e?this.value.filter((t)=>t!==this._value):[...this.value,this._value]}},Ri=Object.defineProperty;Gt=class Gt extends Ae{constructor(e){super(e,!1),En(this,"options"),En(this,"cursor",0),this.options=e.options,this.cursor=this.options.findIndex(({value:t})=>t===e.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",(t)=>{switch(t){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}};Ht=class Ht extends Ae{get valueWithCursor(){if(this.state==="submit")return this.value;if(this.cursor>=this.value.length)return`${this.value}\u2588`;let e=this.value.slice(0,this.cursor),[t,...n]=this.value.slice(this.cursor);return`${e}${Bn.default.inverse(t)}${n.join("")}`}get cursor(){return this._cursor}constructor(e){super(e),this.on("finalize",()=>{this.value||(this.value=e.defaultValue)})}}});import{stripVTControlCharacters as qt}from"util";import Q from"process";function Ii(){return Q.platform!=="win32"?Q.env.TERM!=="linux":!!Q.env.CI||!!Q.env.WT_SESSION||!!Q.env.TERMINUS_SUBLIME||Q.env.ConEmuTask==="{cmd::Cmder}"||Q.env.TERM_PROGRAM==="Terminus-Sublime"||Q.env.TERM_PROGRAM==="vscode"||Q.env.TERM==="xterm-256color"||Q.env.TERM==="alacritty"||Q.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var h,Qe,Lt,U=(e,t)=>Lt?e:t,_i,Wn,zn,Fe,Ei,_,le,Nt,Ut,Pi,Nn,Ai,Fc,Un,Bi,Mi,Oi,Gi,Hi,Ti,qi,De=(e)=>{switch(e){case"initial":case"active":return h.default.cyan(_i);case"cancel":return h.default.red(Wn);case"error":return h.default.yellow(zn);case"submit":return h.default.green(Fe)}},Wt=(e)=>{let{cursor:t,options:n,style:o}=e,i=e.maxItems??Number.POSITIVE_INFINITY,r=Math.max(process.stdout.rows-4,0),s=Math.min(r,Math.max(i,5)),a=0;t>=a+s-3?a=Math.max(Math.min(t-s+3,n.length-s),0):t<a+2&&(a=Math.max(t-2,0));let c=s<n.length&&a>0,l=s<n.length&&a+s<n.length;return n.slice(a,a+s).map((m,u,g)=>{let w=u===0&&c,d=u===g.length-1&&l;return w||d?h.default.dim("..."):o(m,u+a===t)})},L=(e)=>new Ht({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,render(){let t=`${h.default.gray(_)}
16
- ${De(this.state)} ${e.message}
17
- `,n=e.placeholder?h.default.inverse(e.placeholder[0])+h.default.dim(e.placeholder.slice(1)):h.default.inverse(h.default.hidden("_")),o=this.value?this.valueWithCursor:n;switch(this.state){case"error":return`${t.trim()}
18
- ${h.default.yellow(_)} ${o}
19
- ${h.default.yellow(le)} ${h.default.yellow(this.error)}
20
- `;case"submit":return`${t}${h.default.gray(_)} ${h.default.dim(this.value||e.placeholder)}`;case"cancel":return`${t}${h.default.gray(_)} ${h.default.strikethrough(h.default.dim(this.value??""))}${this.value?.trim()?`
21
- ${h.default.gray(_)}`:""}`;default:return`${t}${h.default.cyan(_)} ${o}
22
- ${h.default.cyan(le)}
23
- `}}}).prompt(),A=(e)=>{let t=e.active??"Yes",n=e.inactive??"No";return new Ot({active:t,inactive:n,initialValue:e.initialValue??!0,render(){let o=`${h.default.gray(_)}
24
- ${De(this.state)} ${e.message}
25
- `,i=this.value?t:n;switch(this.state){case"submit":return`${o}${h.default.gray(_)} ${h.default.dim(i)}`;case"cancel":return`${o}${h.default.gray(_)} ${h.default.strikethrough(h.default.dim(i))}
26
- ${h.default.gray(_)}`;default:return`${o}${h.default.cyan(_)} ${this.value?`${h.default.green(Nt)} ${t}`:`${h.default.dim(Ut)} ${h.default.dim(t)}`} ${h.default.dim("/")} ${this.value?`${h.default.dim(Ut)} ${h.default.dim(n)}`:`${h.default.green(Nt)} ${n}`}
27
- ${h.default.cyan(le)}
28
- `}}}).prompt()},V=(e)=>{let t=(n,o)=>{let i=n.label??String(n.value);switch(o){case"selected":return`${h.default.dim(i)}`;case"active":return`${h.default.green(Nt)} ${i} ${n.hint?h.default.dim(`(${n.hint})`):""}`;case"cancelled":return`${h.default.strikethrough(h.default.dim(i))}`;default:return`${h.default.dim(Ut)} ${h.default.dim(i)}`}};return new Gt({options:e.options,initialValue:e.initialValue,render(){let n=`${h.default.gray(_)}
29
- ${De(this.state)} ${e.message}
30
- `;switch(this.state){case"submit":return`${n}${h.default.gray(_)} ${t(this.options[this.cursor],"selected")}`;case"cancel":return`${n}${h.default.gray(_)} ${t(this.options[this.cursor],"cancelled")}
31
- ${h.default.gray(_)}`;default:return`${n}${h.default.cyan(_)} ${Wt({cursor:this.cursor,options:this.options,maxItems:e.maxItems,style:(o,i)=>t(o,i?"active":"inactive")}).join(`
32
- ${h.default.cyan(_)} `)}
33
- ${h.default.cyan(le)}
34
- `}}}).prompt()},F=(e)=>{let t=(n,o)=>{let i=n.label??String(n.value);return o==="active"?`${h.default.cyan(Pi)} ${i} ${n.hint?h.default.dim(`(${n.hint})`):""}`:o==="selected"?`${h.default.green(Nn)} ${h.default.dim(i)} ${n.hint?h.default.dim(`(${n.hint})`):""}`:o==="cancelled"?`${h.default.strikethrough(h.default.dim(i))}`:o==="active-selected"?`${h.default.green(Nn)} ${i} ${n.hint?h.default.dim(`(${n.hint})`):""}`:o==="submitted"?`${h.default.dim(i)}`:`${h.default.dim(Ai)} ${h.default.dim(i)}`};return new Ln({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(n){if(this.required&&n.length===0)return`Please select at least one option.
35
- ${h.default.reset(h.default.dim(`Press ${h.default.gray(h.default.bgWhite(h.default.inverse(" space ")))} to select, ${h.default.gray(h.default.bgWhite(h.default.inverse(" enter ")))} to submit`))}`},render(){let n=`${h.default.gray(_)}
36
- ${De(this.state)} ${e.message}
37
- `,o=(i,r)=>{let s=this.value.includes(i.value);return r&&s?t(i,"active-selected"):s?t(i,"selected"):t(i,r?"active":"inactive")};switch(this.state){case"submit":return`${n}${h.default.gray(_)} ${this.options.filter(({value:i})=>this.value.includes(i)).map((i)=>t(i,"submitted")).join(h.default.dim(", "))||h.default.dim("none")}`;case"cancel":{let i=this.options.filter(({value:r})=>this.value.includes(r)).map((r)=>t(r,"cancelled")).join(h.default.dim(", "));return`${n}${h.default.gray(_)} ${i.trim()?`${i}
38
- ${h.default.gray(_)}`:""}`}case"error":{let i=this.error.split(`
39
- `).map((r,s)=>s===0?`${h.default.yellow(le)} ${h.default.yellow(r)}`:` ${r}`).join(`
40
- `);return`${n+h.default.yellow(_)} ${Wt({options:this.options,cursor:this.cursor,maxItems:e.maxItems,style:o}).join(`
41
- ${h.default.yellow(_)} `)}
42
- ${i}
43
- `}default:return`${n}${h.default.cyan(_)} ${Wt({options:this.options,cursor:this.cursor,maxItems:e.maxItems,style:o}).join(`
44
- ${h.default.cyan(_)} `)}
45
- ${h.default.cyan(le)}
46
- `}}}).prompt()},P=(e="",t="")=>{let n=`
47
- ${e}
5
+ `).map((s)=>Tt(s,o,i)).join(`
6
+ `)}function Xr(n,o){if(typeof n=="string")return jn.aliases.get(n)===o;for(let i of n)if(i!==void 0&&Xr(i,o))return!0;return!1}function At(n,o){if(n===o)return;let i=n.split(`
7
+ `),s=o.split(`
8
+ `),t=[];for(let e=0;e<Math.max(i.length,s.length);e++)i[e]!==s[e]&&t.push(e);return t}function Hn(n){return n===qo}function ro(n,o){let i=n;i.isTTY&&i.setRawMode(o)}class ko{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(n,o=!0){let{input:i=wt,output:s=bt,render:t,signal:e,...r}=n;this.opts=r,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=t.bind(this),this._track=o,this._abortSignal=e,this.input=i,this.output=s}unsubscribe(){this._subscribers.clear()}setSubscriber(n,o){let i=this._subscribers.get(n)??[];i.push(o),this._subscribers.set(n,i)}on(n,o){this.setSubscriber(n,{cb:o})}once(n,o){this.setSubscriber(n,{cb:o,once:!0})}emit(n,...o){let i=this._subscribers.get(n)??[],s=[];for(let t of i)t.cb(...o),t.once&&s.push(()=>i.splice(i.indexOf(t),1));for(let t of s)t()}prompt(){return new Promise((n)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),n(qo);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=$t.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),ro(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(V.cursor.show),this.output.off("resize",this.render),ro(this.input,!1),n(this.value)}),this.once("cancel",()=>{this.output.write(V.cursor.show),this.output.off("resize",this.render),ro(this.input,!1),n(qo)})})}_isActionKey(n,o){return n==="\t"}_setValue(n){this.value=n,this.emit("value",this.value)}_setUserInput(n,o){this.userInput=n??"",this.emit("userInput",this.userInput),o&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(n,o){if(this._track&&o.name!=="return"&&(o.name&&this._isActionKey(n,o)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),o?.name&&(!this._track&&jn.aliases.has(o.name)&&this.emit("cursor",jn.aliases.get(o.name)),jn.actions.has(o.name)&&this.emit("cursor",o.name)),n&&(n.toLowerCase()==="y"||n.toLowerCase()==="n")&&this.emit("confirm",n.toLowerCase()==="y"),this.emit("key",n?.toLowerCase(),o),o?.name==="return"){if(this.opts.validate){let i=this.opts.validate(this.value);i&&(this.error=i instanceof Error?i.message:i,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}Xr([n,o?.name,o?.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
+ `),ro(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let n=Jr(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
10
+ `).length-1;this.output.write(V.cursor.move(-999,n*-1))}render(){let n=Jr(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(n!==this._prevFrame){if(this.state==="initial")this.output.write(V.cursor.hide);else{let o=At(this._prevFrame,n);if(this.restoreCursor(),o&&o?.length===1){let i=o[0];this.output.write(V.cursor.move(0,i)),this.output.write(V.erase.lines(1));let s=n.split(`
11
+ `);this.output.write(s[i]),this._prevFrame=n,this.output.write(V.cursor.move(0,s.length-i-1));return}if(o&&o?.length>1){let i=o[0];this.output.write(V.cursor.move(0,i)),this.output.write(V.erase.down());let s=n.split(`
12
+ `).slice(i);this.output.write(s.join(`
13
+ `)),this._prevFrame=n;return}this.output.write(V.erase.down())}this.output.write(n),this.state==="initial"&&(this.state="active"),this._prevFrame=n}}}function Mt(n,o){if(n===void 0||o.length===0)return 0;let i=o.findIndex((s)=>s.value===n);return i!==-1?i:0}function Lt(n,o){return(o.label??String(o.value)).toLowerCase().includes(n.toLowerCase())}function Nt(n,o){if(o)return n?o:o[0]}var io,V,xt=(n)=>n===161||n===164||n===167||n===168||n===170||n===173||n===174||n>=176&&n<=180||n>=182&&n<=186||n>=188&&n<=191||n===198||n===208||n===215||n===216||n>=222&&n<=225||n===230||n>=232&&n<=234||n===236||n===237||n===240||n===242||n===243||n>=247&&n<=250||n===252||n===254||n===257||n===273||n===275||n===283||n===294||n===295||n===299||n>=305&&n<=307||n===312||n>=319&&n<=322||n===324||n>=328&&n<=331||n===333||n===338||n===339||n===358||n===359||n===363||n===462||n===464||n===466||n===468||n===470||n===472||n===474||n===476||n===593||n===609||n===708||n===711||n>=713&&n<=715||n===717||n===720||n>=728&&n<=731||n===733||n===735||n>=768&&n<=879||n>=913&&n<=929||n>=931&&n<=937||n>=945&&n<=961||n>=963&&n<=969||n===1025||n>=1040&&n<=1103||n===1105||n===8208||n>=8211&&n<=8214||n===8216||n===8217||n===8220||n===8221||n>=8224&&n<=8226||n>=8228&&n<=8231||n===8240||n===8242||n===8243||n===8245||n===8251||n===8254||n===8308||n===8319||n>=8321&&n<=8324||n===8364||n===8451||n===8453||n===8457||n===8467||n===8470||n===8481||n===8482||n===8486||n===8491||n===8531||n===8532||n>=8539&&n<=8542||n>=8544&&n<=8555||n>=8560&&n<=8569||n===8585||n>=8592&&n<=8601||n===8632||n===8633||n===8658||n===8660||n===8679||n===8704||n===8706||n===8707||n===8711||n===8712||n===8715||n===8719||n===8721||n===8725||n===8730||n>=8733&&n<=8736||n===8739||n===8741||n>=8743&&n<=8748||n===8750||n>=8756&&n<=8759||n===8764||n===8765||n===8776||n===8780||n===8786||n===8800||n===8801||n>=8804&&n<=8807||n===8810||n===8811||n===8814||n===8815||n===8834||n===8835||n===8838||n===8839||n===8853||n===8857||n===8869||n===8895||n===8978||n>=9312&&n<=9449||n>=9451&&n<=9547||n>=9552&&n<=9587||n>=9600&&n<=9615||n>=9618&&n<=9621||n===9632||n===9633||n>=9635&&n<=9641||n===9650||n===9651||n===9654||n===9655||n===9660||n===9661||n===9664||n===9665||n>=9670&&n<=9672||n===9675||n>=9678&&n<=9681||n>=9698&&n<=9701||n===9711||n===9733||n===9734||n===9737||n===9742||n===9743||n===9756||n===9758||n===9792||n===9794||n===9824||n===9825||n>=9827&&n<=9829||n>=9831&&n<=9834||n===9836||n===9837||n===9839||n===9886||n===9887||n===9919||n>=9926&&n<=9933||n>=9935&&n<=9939||n>=9941&&n<=9953||n===9955||n===9960||n===9961||n>=9963&&n<=9969||n===9972||n>=9974&&n<=9977||n===9979||n===9980||n===9982||n===9983||n===10045||n>=10102&&n<=10111||n>=11094&&n<=11097||n>=12872&&n<=12879||n>=57344&&n<=63743||n>=65024&&n<=65039||n===65533||n>=127232&&n<=127242||n>=127248&&n<=127277||n>=127280&&n<=127337||n>=127344&&n<=127373||n===127375||n===127376||n>=127387&&n<=127404||n>=917760&&n<=917999||n>=983040&&n<=1048573||n>=1048576&&n<=1114109,St=(n)=>n===12288||n>=65281&&n<=65376||n>=65504&&n<=65510,vt=(n)=>n>=4352&&n<=4447||n===8986||n===8987||n===9001||n===9002||n>=9193&&n<=9196||n===9200||n===9203||n===9725||n===9726||n===9748||n===9749||n>=9800&&n<=9811||n===9855||n===9875||n===9889||n===9898||n===9899||n===9917||n===9918||n===9924||n===9925||n===9934||n===9940||n===9962||n===9970||n===9971||n===9973||n===9978||n===9981||n===9989||n===9994||n===9995||n===10024||n===10060||n===10062||n>=10067&&n<=10069||n===10071||n>=10133&&n<=10135||n===10160||n===10175||n===11035||n===11036||n===11088||n===11093||n>=11904&&n<=11929||n>=11931&&n<=12019||n>=12032&&n<=12245||n>=12272&&n<=12287||n>=12289&&n<=12350||n>=12353&&n<=12438||n>=12441&&n<=12543||n>=12549&&n<=12591||n>=12593&&n<=12686||n>=12688&&n<=12771||n>=12783&&n<=12830||n>=12832&&n<=12871||n>=12880&&n<=19903||n>=19968&&n<=42124||n>=42128&&n<=42182||n>=43360&&n<=43388||n>=44032&&n<=55203||n>=63744&&n<=64255||n>=65040&&n<=65049||n>=65072&&n<=65106||n>=65108&&n<=65126||n>=65128&&n<=65131||n>=94176&&n<=94180||n===94192||n===94193||n>=94208&&n<=100343||n>=100352&&n<=101589||n>=101632&&n<=101640||n>=110576&&n<=110579||n>=110581&&n<=110587||n===110589||n===110590||n>=110592&&n<=110882||n===110898||n>=110928&&n<=110930||n===110933||n>=110948&&n<=110951||n>=110960&&n<=111355||n===126980||n===127183||n===127374||n>=127377&&n<=127386||n>=127488&&n<=127490||n>=127504&&n<=127547||n>=127552&&n<=127560||n===127568||n===127569||n>=127584&&n<=127589||n>=127744&&n<=127776||n>=127789&&n<=127797||n>=127799&&n<=127868||n>=127870&&n<=127891||n>=127904&&n<=127946||n>=127951&&n<=127955||n>=127968&&n<=127984||n===127988||n>=127992&&n<=128062||n===128064||n>=128066&&n<=128252||n>=128255&&n<=128317||n>=128331&&n<=128334||n>=128336&&n<=128359||n===128378||n===128405||n===128406||n===128420||n>=128507&&n<=128591||n>=128640&&n<=128709||n===128716||n>=128720&&n<=128722||n>=128725&&n<=128727||n>=128732&&n<=128735||n===128747||n===128748||n>=128756&&n<=128764||n>=128992&&n<=129003||n===129008||n>=129292&&n<=129338||n>=129340&&n<=129349||n>=129351&&n<=129535||n>=129648&&n<=129660||n>=129664&&n<=129672||n>=129680&&n<=129725||n>=129727&&n<=129733||n>=129742&&n<=129755||n>=129760&&n<=129768||n>=129776&&n<=129784||n>=131072&&n<=196605||n>=196608&&n<=262141,Ho,Dn,no,Go,oo,jt,Rt,kr=(n,o={},i={})=>{let s=o.limit??1/0,t=o.ellipsis??"",e=o?.ellipsisWidth??(t?kr(t,Rt,i).width:0),r=i.ansiWidth??0,a=i.controlWidth??0,c=i.tabWidth??8,p=i.ambiguousWidth??1,f=i.emojiWidth??2,m=i.fullWidthWidth??2,d=i.regularWidth??1,w=i.wideWidth??2,u=0,g=0,y=n.length,x=0,j=!1,L=y,S=Math.max(0,s-e),v=0,I=0,E=0,C=0;n:for(;;){if(I>v||g>=y&&g>u){let an=n.slice(v,I)||n.slice(u,g);x=0;for(let Cr of an.replaceAll(jt,"")){let Oo=Cr.codePointAt(0)||0;if(St(Oo)?C=m:vt(Oo)?C=w:p!==d&&xt(Oo)?C=p:C=d,E+C>S&&(L=Math.min(L,Math.max(v,u)+x)),E+C>s){j=!0;break n}x+=Cr.length,E+=C}v=I=0}if(g>=y)break;if(oo.lastIndex=g,oo.test(n)){if(x=oo.lastIndex-g,C=x*d,E+C>S&&(L=Math.min(L,g+Math.floor((S-E)/d))),E+C>s){j=!0;break}E+=C,v=u,I=g,g=u=oo.lastIndex;continue}if(Ho.lastIndex=g,Ho.test(n)){if(E+r>S&&(L=Math.min(L,g)),E+r>s){j=!0;break}E+=r,v=u,I=g,g=u=Ho.lastIndex;continue}if(Dn.lastIndex=g,Dn.test(n)){if(x=Dn.lastIndex-g,C=x*a,E+C>S&&(L=Math.min(L,g+Math.floor((S-E)/a))),E+C>s){j=!0;break}E+=C,v=u,I=g,g=u=Dn.lastIndex;continue}if(no.lastIndex=g,no.test(n)){if(x=no.lastIndex-g,C=x*c,E+C>S&&(L=Math.min(L,g+Math.floor((S-E)/c))),E+C>s){j=!0;break}E+=C,v=u,I=g,g=u=no.lastIndex;continue}if(Go.lastIndex=g,Go.test(n)){if(E+f>S&&(L=Math.min(L,g)),E+f>s){j=!0;break}E+=f,v=u,I=g,g=u=Go.lastIndex;continue}g+=1}return{width:j?S:E,index:j?L:y,truncated:j,ellipsed:j&&s>=e}},Et,Nn=(n,o={})=>kr(n,Et,o).width,so="\x1B",Yr="\x9B",It=39,zo="\x07",Wr="[",Pt="]",Kr="m",Jo,Ur,Ot=(n)=>{if(n>=30&&n<=37||n>=90&&n<=97)return 39;if(n>=40&&n<=47||n>=100&&n<=107)return 49;if(n===1||n===2)return 22;if(n===3)return 23;if(n===4)return 24;if(n===7)return 27;if(n===8)return 28;if(n===9)return 29;if(n===0)return 0},qr=(n)=>`${so}${Wr}${n}${Kr}`,zr=(n)=>`${so}${Jo}${n}${zo}`,_t=(n)=>n.map((o)=>Nn(o)),Uo=(n,o,i)=>{let s=o[Symbol.iterator](),t=!1,e=!1,r=n.at(-1),a=r===void 0?0:Nn(r),c=s.next(),p=s.next(),f=0;for(;!c.done;){let m=c.value,d=Nn(m);a+d<=i?n[n.length-1]+=m:(n.push(m),a=0),(m===so||m===Yr)&&(t=!0,e=o.startsWith(Jo,f+1)),t?e?m===zo&&(t=!1,e=!1):m===Kr&&(t=!1):(a+=d,a===i&&!p.done&&(n.push(""),a=0)),c=p,p=s.next(),f+=m.length}r=n.at(-1),!a&&r!==void 0&&r.length>0&&n.length>1&&(n[n.length-2]+=n.pop())},Ct=(n)=>{let o=n.split(" "),i=o.length;for(;i>0&&!(Nn(o[i-1])>0);)i--;return i===o.length?n:o.slice(0,i).join(" ")+o.slice(i).join("")},Tt=(n,o,i={})=>{if(i.trim!==!1&&n.trim()==="")return"";let s="",t,e,r=n.split(" "),a=_t(r),c=[""];for(let[u,g]of r.entries()){i.trim!==!1&&(c[c.length-1]=(c.at(-1)??"").trimStart());let y=Nn(c.at(-1)??"");if(u!==0&&(y>=o&&(i.wordWrap===!1||i.trim===!1)&&(c.push(""),y=0),(y>0||i.trim===!1)&&(c[c.length-1]+=" ",y++)),i.hard&&a[u]>o){let x=o-y,j=1+Math.floor((a[u]-x-1)/o);Math.floor((a[u]-1)/o)<j&&c.push(""),Uo(c,g,o);continue}if(y+a[u]>o&&y>0&&a[u]>0){if(i.wordWrap===!1&&y<o){Uo(c,g,o);continue}c.push("")}if(y+a[u]>o&&i.wordWrap===!1){Uo(c,g,o);continue}c[c.length-1]+=g}i.trim!==!1&&(c=c.map((u)=>Ct(u)));let p=c.join(`
14
+ `),f=p[Symbol.iterator](),m=f.next(),d=f.next(),w=0;for(;!m.done;){let u=m.value,g=d.value;if(s+=u,u===so||u===Yr){Ur.lastIndex=w+1;let x=Ur.exec(p)?.groups;if(x?.code!==void 0){let j=Number.parseFloat(x.code);t=j===It?void 0:j}else x?.uri!==void 0&&(e=x.uri.length===0?void 0:x.uri)}let y=t?Ot(t):void 0;g===`
15
+ `?(e&&(s+=zr("")),t&&y&&(s+=qr(y))):u===`
16
+ `&&(t&&y&&(s+=qr(t)),e&&(s+=zr(e))),w+=u.length,m=d,d=f.next()}return s},Bt,jn,Np,qo,Zr,Qr;var Yo=T(()=>{io=F(Mn(),1),V=F(Ln(),1),Ho=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,Dn=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,no=/\t{1,1000}/y,Go=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,oo=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,jt=/\p{M}+/gu,Rt={limit:1/0,ellipsis:""},Et={limit:1/0,ellipsis:"",ellipsisWidth:0},Jo=`${Pt}8;;`,Ur=new RegExp(`(?:\\${Wr}(?<code>\\d+)m|\\${Jo}(?<uri>.*)${zo})`,"y");Bt=["up","down","left","right","space","enter","cancel"],jn={actions:new Set(Bt),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"}};Np=globalThis.process.platform.startsWith("win"),qo=Symbol("clack:cancel");Zr=class Zr extends ko{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#n=0;#r="";#i;#o;get cursor(){return this.#n}get userInputWithCursor(){if(!this.userInput)return io.default.inverse(io.default.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}\u2588`;let n=this.userInput.slice(0,this._cursor),[o,...i]=this.userInput.slice(this._cursor);return`${n}${io.default.inverse(o)}${i.join("")}`}get options(){return typeof this.#o=="function"?this.#o():this.#o}constructor(n){super(n),this.#o=n.options;let o=this.options;this.filteredOptions=[...o],this.multiple=n.multiple===!0,this.#i=n.filter??Lt;let i;if(n.initialValue&&Array.isArray(n.initialValue)?this.multiple?i=n.initialValue:i=n.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(i=[this.options[0].value]),i)for(let s of i){let t=o.findIndex((e)=>e.value===s);t!==-1&&(this.toggleSelected(s),this.#n=t)}this.focusedValue=this.options[this.#n]?.value,this.on("key",(s,t)=>this.#s(s,t)),this.on("userInput",(s)=>this.#t(s))}_isActionKey(n,o){return n==="\t"||this.multiple&&this.isNavigating&&o.name==="space"&&n!==void 0&&n!==""}#s(n,o){let i=o.name==="up",s=o.name==="down",t=o.name==="return";i||s?(this.#n=Math.max(0,Math.min(this.#n+(i?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#n]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):t?this.value=Nt(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(o.name==="tab"||this.isNavigating&&o.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(n){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(n)?this.selectedValues=this.selectedValues.filter((o)=>o!==n):this.selectedValues=[...this.selectedValues,n]:this.selectedValues=[n])}#t(n){if(n!==this.#r){this.#r=n;let o=this.options;n?this.filteredOptions=o.filter((i)=>this.#i(n,i)):this.filteredOptions=[...o],this.#n=Mt(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#n]?.value,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};Qr=class Qr extends ko{options;cursor=0;#n;getGroupItems(n){return this.options.filter((o)=>o.group===n)}isGroupSelected(n){let o=this.getGroupItems(n),i=this.value;return i===void 0?!1:o.every((s)=>i.includes(s.value))}toggleValue(){let n=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),n.group===!0){let o=n.value,i=this.getGroupItems(o);this.isGroupSelected(o)?this.value=this.value.filter((s)=>i.findIndex((t)=>t.value===s)===-1):this.value=[...this.value,...i.map((s)=>s.value)],this.value=Array.from(new Set(this.value))}else{let o=this.value.includes(n.value);this.value=o?this.value.filter((i)=>i!==n.value):[...this.value,n.value]}}constructor(n){super(n,!1);let{options:o}=n;this.#n=n.selectableGroups!==!1,this.options=Object.entries(o).flatMap(([i,s])=>[{value:i,group:!0,label:i},...s.map((t)=>({...t,group:i}))]),this.value=[...n.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:i})=>i===n.cursorAt),this.#n?0:1),this.on("cursor",(i)=>{switch(i){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let s=this.options[this.cursor]?.group===!0;!this.#n&&s&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let s=this.options[this.cursor]?.group===!0;!this.#n&&s&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}}});import D from"process";function Ht(){return D.platform!=="win32"?D.env.TERM!=="linux":!!D.env.CI||!!D.env.WT_SESSION||!!D.env.TERMINUS_SUBLIME||D.env.ConEmuTask==="{cmd::Cmder}"||D.env.TERM_PROGRAM==="Terminus-Sublime"||D.env.TERM_PROGRAM==="vscode"||D.env.TERM==="xterm-256color"||D.env.TERM==="alacritty"||D.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var Wo,Vr,Gt,A=(n,o)=>Gt?n:o,Vp,Fp,Dp,nl,ol,Ut,rl,il,sl,tl,el,al,cl,pl,ll,fl,ml,ul,gl,hl,dl,yl,bl,wl,$l,qt="\x07",zt="[",Jt="]",kt,xl,Sl,vl,jl;var Ko=T(()=>{Yo();Yo();Wo=F(Mn(),1),Vr=F(Ln(),1);Gt=Ht(),Vp=A("\u25C6","*"),Fp=A("\u25A0","x"),Dp=A("\u25B2","x"),nl=A("\u25C7","o"),ol=A("\u250C","T"),Ut=A("\u2502","|"),rl=A("\u2514","\u2014"),il=A("\u2510","T"),sl=A("\u2518","\u2014"),tl=A("\u25CF",">"),el=A("\u25CB"," "),al=A("\u25FB","[\u2022]"),cl=A("\u25FC","[+]"),pl=A("\u25FB","[ ]"),ll=A("\u25AA","\u2022"),fl=A("\u2500","-"),ml=A("\u256E","+"),ul=A("\u251C","+"),gl=A("\u256F","+"),hl=A("\u2570","+"),dl=A("\u256D","+"),yl=A("\u25CF","\u2022"),bl=A("\u25C6","*"),wl=A("\u25B2","!"),$l=A("\u25A0","x"),kt=`${Jt}8;;`,xl=new RegExp(`(?:\\${zt}(?<code>\\d+)m|\\${kt}(?<uri>.*)${qt})`,"y"),Sl=Wo.default.magenta,vl={light:A("\u2500","-"),heavy:A("\u2501","="),block:A("\u2588","#")},jl=`${Wo.default.gray(Ut)} `});function Fr(n,o){let i=Yt[n]||"Unknown error";return o?`${i}: ${o}`:i}var Yt;var Xo=T(()=>{Yt={"core.auth.failed":"Authentication failed","core.auth.invalid_token":"Token is invalid or expired","core.fs.cannot_read":"Cannot read file","core.fs.cannot_write":"Cannot write to file","core.fs.directory_not_found":"Directory not found","core.fs.file_not_found":"File not found","core.git.dirty_working_dir":"Working directory has uncommitted changes","core.git.no_commits":"No commits found","core.git.not_repository":"Not a git repository","core.git.operation_failed":"Git operation failed","core.invalid_argument":"Invalid argument","core.invalid_config":"Invalid configuration","core.network.request_failed":"Network request failed","core.operation_cancelled":"Operation cancelled","core.operation_failed":"Operation failed","core.permission_denied":"Permission denied"}});function Dr(n={}){let{errorPrefix:o="\u2717"}=n;return function(s){if(Hn(s))Rn.info("Operation cancelled"),process.exit(0);if(s instanceof Y){if(Rn.error(`${o} ${s.message}`),s.code)Rn.error(` Error code: ${s.code}`)}else if(s instanceof Error)Rn.error(`${o} ${s.message}`);else Rn.error(`${o} An unexpected error occurred`),Rn.error(String(s));process.exit(1)}}var Rn,Y;var ni=T(()=>{Ko();_();Xo();Rn=R({prefix:"cli-core"}).child("error");Y=class Y extends Error{code;context;constructor(n,o,i){let s=n.includes(".")&&!n.includes(" ")?Fr(n,i):n;super(s);this.code=o;this.context=i;this.name="CLIError"}}});var cn,Wt=(n,o)=>{let i=n.length,s=o.length,t=1<<i-1,e=-1,r=0,a=i,c=i;while(c--)cn[n.charCodeAt(c)]|=1<<c;for(c=0;c<s;c++){let p=cn[o.charCodeAt(c)],f=p|r;if(p|=(p&e)+e^e,r|=~(p|e),e&=p,r&t)a++;if(e&t)a--;r=r<<1|1,e=e<<1|~(f|r),r&=f}c=i;while(c--)cn[n.charCodeAt(c)]=0;return a},Kt=(n,o)=>{let i=o.length,s=n.length,t=[],e=[],r=Math.ceil(i/32),a=Math.ceil(s/32);for(let u=0;u<r;u++)e[u]=-1,t[u]=0;let c=0;for(;c<a-1;c++){let u=0,g=-1,y=c*32,x=Math.min(32,s)+y;for(let j=y;j<x;j++)cn[n.charCodeAt(j)]|=1<<j;for(let j=0;j<i;j++){let L=cn[o.charCodeAt(j)],S=e[j/32|0]>>>j&1,v=t[j/32|0]>>>j&1,I=L|u,E=((L|v)&g)+g^g|L|v,C=u|~(E|g),an=g&E;if(C>>>31^S)e[j/32|0]^=1<<j;if(an>>>31^v)t[j/32|0]^=1<<j;C=C<<1|S,an=an<<1|v,g=an|~(I|C),u=C&I}for(let j=y;j<x;j++)cn[n.charCodeAt(j)]=0}let p=0,f=-1,m=c*32,d=Math.min(32,s-m)+m;for(let u=m;u<d;u++)cn[n.charCodeAt(u)]|=1<<u;let w=s;for(let u=0;u<i;u++){let g=cn[o.charCodeAt(u)],y=e[u/32|0]>>>u&1,x=t[u/32|0]>>>u&1,j=g|p,L=((g|x)&f)+f^f|g|x,S=p|~(L|f),v=f&L;if(w+=S>>>s-1&1,w-=v>>>s-1&1,S>>>31^y)e[u/32|0]^=1<<u;if(v>>>31^x)t[u/32|0]^=1<<u;S=S<<1|y,v=v<<1|x,f=v|~(j|S),p=S&j}for(let u=m;u<d;u++)cn[n.charCodeAt(u)]=0;return w},oi=(n,o)=>{if(n.length<o.length){let i=o;o=n,n=i}if(o.length===0)return n.length;if(n.length<=32)return Wt(n,o);return Kt(n,o)};var ri=T(()=>{cn=new Uint32Array(65536)});function to(n,o,i=Qt){let s=o.map((e)=>({distance:oi(n.toLowerCase(),e.toLowerCase()),option:e})),t=Math.max(Zt,n.length*Xt);return s.filter(({distance:e})=>e<=t).sort((e,r)=>e.distance-r.distance).slice(0,i).map(({option:e})=>e)}function eo(n,o){return o[n.toLowerCase()]||null}var Xt=0.5,Zt=3,Qt=3;var ii=T(()=>{ri()});async function Zo(n,o={}){let{fallback:i,logLevel:s="warn",message:t="Operation failed gracefully"}=o;try{return await n()}catch(e){let r=e instanceof Error?e.message:String(e);if(si[s](`${t}: ${r}`),i)try{await i()}catch(a){si.error(`Fallback also failed: ${a instanceof Error?a.message:String(a)}`)}return}}var si;var ti=T(()=>{_();si=R({prefix:"cli-core"}).child("graceful")});function ao(n){let o=[];if(o.push(l.bold(`${n.name} - ${n.description}`)),o.push(""),o.push(l.bold("USAGE")),o.push(` ${n.usage}`),o.push(""),n.options?.length){o.push(l.bold("OPTIONS"));for(let i of n.options){let s=[i.description];if(i.default!==void 0)s.push(l.dim(`(default: ${i.default})`));if(i.required)s.push(l.error("(required)"));o.push(` ${l.flag(i.flags.padEnd(26))} ${s.join(" ")}`)}o.push("")}if(n.examples?.length){o.push(l.bold("EXAMPLES"));for(let i of n.examples)o.push(l.dim(` # ${i.description}`)),o.push(` ${l.value(i.command)}`),o.push("")}if(n.notes?.length){o.push(l.bold("NOTES"));for(let i of n.notes)o.push(` - ${i}`);o.push("")}if(n.sections?.length)for(let i of n.sections){o.push(l.bold(i.title));for(let s of i.content)o.push(` ${s}`);o.push("")}if(o[o.length-1]==="")o.pop();return o.join(`
17
+ `)}function co(n,o,i,s){let t=[];t.push(l.bold(n)),t.push(""),t.push(l.bold("USAGE")),t.push(` ${o}`),t.push(""),t.push(l.bold("COMMANDS"));let e=Math.max(...i.map((r)=>r.name.length));for(let r of i)t.push(` ${l.command(r.name.padEnd(e+2))} ${r.description}`);if(s)t.push(""),t.push(s);return t.join(`
18
+ `)}var ei=T(()=>{Mo()});var ai=T(()=>{_()});var ci=T(()=>{Ko()});async function pi(n,o={}){let i={...Vt,...o},s=Error("Operation failed");for(let t=1;t<=i.maxAttempts;t++)try{return await n()}catch(e){if(s=e instanceof Error?e:Error(String(e)),!i.retryableErrors.some((c)=>s.message.toLowerCase().includes(c.toLowerCase()))||t===i.maxAttempts)throw s;i.onRetry(t,s);let a=Math.min(i.initialDelay*i.backoffMultiplier**(t-1),i.maxDelay);await new Promise((c)=>setTimeout(c,a))}throw s}var Vt;var li=T(()=>{_();Vt={backoffMultiplier:2,initialDelay:1000,maxAttempts:3,maxDelay:30000,onRetry:(n,o)=>{Ao.warn(`Retry attempt ${n}: ${o.message}`)},retryableErrors:["ECONNREFUSED","ECONNRESET","ETIMEDOUT","ENOTFOUND","rate limit","429","503","502","504","npm ERR!","EPUBLISHCONFLICT"]}});var fi=()=>{};import{existsSync as Ft}from"fs";import{readFile as Dt}from"fs/promises";import{homedir as ne}from"os";import{join as ui}from"path";async function ie(){try{if(Ft(Qo)){let n=await Dt(Qo,"utf-8");return JSON.parse(n)}}catch{}return{}}async function se(n){try{await Bun.write(Qo,JSON.stringify(n,null,2))}catch{}}async function te(n){try{let o=await fetch(`https://registry.npmjs.org/${n}/latest`,{signal:AbortSignal.timeout(5000)});if(!o.ok)return null;return(await o.json()).version}catch{return null}}function mi(n,o){let i=n.split(".").map(Number),s=o.split(".").map(Number);for(let t=0;t<Math.max(i.length,s.length);t++){let e=i[t]||0,r=s[t]||0;if(e>r)return 1;if(e<r)return-1}return 0}async function ee(n){let{packageName:o,currentVersion:i,checkInterval:s=oe,silent:t=!1}=n;if(process.env.CI||process.env.CONTINUOUS_INTEGRATION||process.env.R5N_NO_UPDATE_CHECK==="1")return null;try{let e=await ie(),r=e[o],a=Date.now();if(r&&a-r.lastChecked<s)return{currentVersion:i,lastChecked:r.lastChecked,latestVersion:r.latestVersion,name:o,updateAvailable:mi(r.latestVersion,i)>0};let c=await te(o);if(!c)return null;if(e[o]={lastChecked:a,latestVersion:c},!t)se(e).catch(()=>{});return{currentVersion:i,lastChecked:a,latestVersion:c,name:o,updateAvailable:mi(c,i)>0}}catch{return null}}function gi(n,o){ee({currentVersion:o,packageName:n}).then((i)=>{if(i?.updateAvailable)console.error(`
19
+ \u26A0\uFE0F Update available: ${i.latestVersion} (current: ${i.currentVersion})`),console.error(` Run: bun install -g ${n}
20
+ `)}).catch(()=>{})}var oe=86400000,re,Qo;var hi=T(()=>{re=ui(ne(),".r5n","cache"),Qo=ui(re,"update-check.json")});var En=(n)=>{return n.map=(o)=>En((i)=>o(n(i))),n.or=(o)=>En((i)=>{try{return n(i)}catch(s){return o(i)}}),n},Vo=()=>"bad banditype"(),Fo=(n)=>En((o)=>typeof o===typeof n?o:Vo()),rn=()=>Fo(""),Do=()=>Fo(!0),Gn=()=>Fo(),di=(n)=>En((o)=>o instanceof n?o:Vo()),sn=(n)=>di(Object).map((o)=>{let i={};for(let s in n){let t=n[s](o[s]);t!==void 0&&(i[s]=t)}return i}),Un=(n)=>di(Array).map((o)=>o.map(n));var yi=()=>{};function po(n,o){return En((i)=>{try{return n(i)}catch{try{return o(i)}catch{throw Error("No matching schema in union")}}})}function pn(n,o){return(i)=>{if(i===void 0)return o;return n(i)}}function bi(n){return{parse(o){try{return n(o)}catch(i){throw Error(i instanceof Error?i.message:"Validation failed")}},safeParse(o){try{return{data:n(o),success:!0}}catch(i){return{error:i instanceof Error?i:Error("Validation failed"),success:!1}}},validator:n}}var wi=T(()=>{yi()});var M=T(()=>{Mo();ni();Xo();ii();ti();ei();ai();ci();li();fi();hi();wi()});import{stdin as _i,stdout as Ci}from"process";import*as ln from"readline";import xi from"readline";import{Writable as ce}from"stream";function pe({onlyFirst:n=!1}={}){let o=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(o,n?void 0:"g")}function Bi(n){if(typeof n!="string")throw TypeError(`Expected a \`string\`, got \`${typeof n}\``);return n.replace(le,"")}function Ai(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function qn(n,o={}){if(typeof n!="string"||n.length===0||(o={ambiguousIsNarrow:!0,...o},n=Bi(n),n.length===0))return 0;n=n.replace(ge()," ");let i=o.ambiguousIsNarrow?1:2,s=0;for(let t of n){let e=t.codePointAt(0);if(e<=31||e>=127&&e<=159||e>=768&&e<=879)continue;switch(me.eastAsianWidth(t)){case"F":case"W":s+=2;break;case"A":s+=i;break;default:s+=1}}return s}function ye(){let n=new Map;for(let[o,i]of Object.entries(G)){for(let[s,t]of Object.entries(i))G[s]={open:`\x1B[${t[0]}m`,close:`\x1B[${t[1]}m`},i[s]=G[s],n.set(t[0],t[1]);Object.defineProperty(G,o,{value:i,enumerable:!1})}return Object.defineProperty(G,"codes",{value:n,enumerable:!1}),G.color.close="\x1B[39m",G.bgColor.close="\x1B[49m",G.color.ansi=Si(),G.color.ansi256=vi(),G.color.ansi16m=ji(),G.bgColor.ansi=Si(nr),G.bgColor.ansi256=vi(nr),G.bgColor.ansi16m=ji(nr),Object.defineProperties(G,{rgbToAnsi256:{value:(o,i,s)=>o===i&&i===s?o<8?16:o>248?231:Math.round((o-8)/247*24)+232:16+36*Math.round(o/255*5)+6*Math.round(i/255*5)+Math.round(s/255*5),enumerable:!1},hexToRgb:{value:(o)=>{let i=/[a-f\d]{6}|[a-f\d]{3}/i.exec(o.toString(16));if(!i)return[0,0,0];let[s]=i;s.length===3&&(s=[...s].map((e)=>e+e).join(""));let t=Number.parseInt(s,16);return[t>>16&255,t>>8&255,t&255]},enumerable:!1},hexToAnsi256:{value:(o)=>G.rgbToAnsi256(...G.hexToRgb(o)),enumerable:!1},ansi256ToAnsi:{value:(o)=>{if(o<8)return 30+o;if(o<16)return 90+(o-8);let i,s,t;if(o>=232)i=((o-232)*10+8)/255,s=i,t=i;else{o-=16;let a=o%36;i=Math.floor(o/36)/5,s=Math.floor(a/6)/5,t=a%6/5}let e=Math.max(i,s,t)*2;if(e===0)return 30;let r=30+(Math.round(t)<<2|Math.round(s)<<1|Math.round(i));return e===2&&(r+=60),r},enumerable:!1},rgbToAnsi:{value:(o,i,s)=>G.ansi256ToAnsi(G.rgbToAnsi256(o,i,s)),enumerable:!1},hexToAnsi:{value:(o)=>G.ansi256ToAnsi(G.hexToAnsi256(o)),enumerable:!1}}),G}function Ii(n,o,i){return String(n).normalize().replace(/\r\n/g,`
21
+ `).split(`
22
+ `).map((s)=>ve(s,o,i)).join(`
23
+ `)}function tr(n,o){if(typeof n=="string")return fo.aliases.get(n)===o;for(let i of n)if(i!==void 0&&tr(i,o))return!0;return!1}function Re(n,o){if(n===o)return;let i=n.split(`
24
+ `),s=o.split(`
25
+ `),t=[];for(let e=0;e<Math.max(i.length,s.length);e++)i[e]!==s[e]&&t.push(e);return t}function yn(n){return n===rr}function lo(n,o){let i=n;i.isTTY&&i.setRawMode(o)}function Hi({input:n=_i,output:o=Ci,overwrite:i=!0,hideCursor:s=!0}={}){let t=ln.createInterface({input:n,output:o,prompt:"",tabSize:1});ln.emitKeypressEvents(n,t),n.isTTY&&n.setRawMode(!0);let e=(r,{name:a,sequence:c})=>{let p=String(r);if(tr([p,a,c],"cancel")){s&&o.write(W.cursor.show),process.exit(0);return}if(!i)return;ln.moveCursor(o,a==="return"?0:-1,a==="return"?-1:0,()=>{ln.clearLine(o,1,()=>{n.once("keypress",e)})})};return s&&o.write(W.cursor.hide),n.once("keypress",e),()=>{n.off("keypress",e),s&&o.write(W.cursor.show),n.isTTY&&!Ee&&n.setRawMode(!1),t.terminal=!1,t.close()}}class zn{constructor(n,o=!0){Z(this,"input"),Z(this,"output"),Z(this,"_abortSignal"),Z(this,"rl"),Z(this,"opts"),Z(this,"_render"),Z(this,"_track",!1),Z(this,"_prevFrame",""),Z(this,"_subscribers",new Map),Z(this,"_cursor",0),Z(this,"state","initial"),Z(this,"error",""),Z(this,"value");let{input:i=_i,output:s=Ci,render:t,signal:e,...r}=n;this.opts=r,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=t.bind(this),this._track=o,this._abortSignal=e,this.input=i,this.output=s}unsubscribe(){this._subscribers.clear()}setSubscriber(n,o){let i=this._subscribers.get(n)??[];i.push(o),this._subscribers.set(n,i)}on(n,o){this.setSubscriber(n,{cb:o})}once(n,o){this.setSubscriber(n,{cb:o,once:!0})}emit(n,...o){let i=this._subscribers.get(n)??[],s=[];for(let t of i)t.cb(...o),t.once&&s.push(()=>i.splice(i.indexOf(t),1));for(let t of s)t()}prompt(){return new Promise((n,o)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),n(rr);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}let i=new ce;i._write=(s,t,e)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,""),this._cursor=this.rl?.cursor??0,this.emit("value",this.value)),e()},this.input.pipe(i),this.rl=xi.createInterface({input:this.input,output:i,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),xi.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),lo(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(W.cursor.show),this.output.off("resize",this.render),lo(this.input,!1),n(this.value)}),this.once("cancel",()=>{this.output.write(W.cursor.show),this.output.off("resize",this.render),lo(this.input,!1),n(rr)})})}onKeypress(n,o){if(this.state==="error"&&(this.state="active"),o?.name&&(!this._track&&fo.aliases.has(o.name)&&this.emit("cursor",fo.aliases.get(o.name)),fo.actions.has(o.name)&&this.emit("cursor",o.name)),n&&(n.toLowerCase()==="y"||n.toLowerCase()==="n")&&this.emit("confirm",n.toLowerCase()==="y"),n==="\t"&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),n&&this.emit("key",n.toLowerCase()),o?.name==="return"){if(this.opts.validate){let i=this.opts.validate(this.value);i&&(this.error=i instanceof Error?i.message:i,this.state="error",this.rl?.write(this.value))}this.state!=="error"&&(this.state="submit")}tr([n,o?.name,o?.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(`
26
+ `),lo(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let n=Ii(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
27
+ `).length-1;this.output.write(W.cursor.move(-999,n*-1))}render(){let n=Ii(this._render(this)??"",process.stdout.columns,{hard:!0});if(n!==this._prevFrame){if(this.state==="initial")this.output.write(W.cursor.hide);else{let o=Re(this._prevFrame,n);if(this.restoreCursor(),o&&o?.length===1){let i=o[0];this.output.write(W.cursor.move(0,i)),this.output.write(W.erase.lines(1));let s=n.split(`
28
+ `);this.output.write(s[i]),this._prevFrame=n,this.output.write(W.cursor.move(0,s.length-i-1));return}if(o&&o?.length>1){let i=o[0];this.output.write(W.cursor.move(0,i)),this.output.write(W.erase.down());let s=n.split(`
29
+ `).slice(i);this.output.write(s.join(`
30
+ `)),this._prevFrame=n;return}this.output.write(W.erase.down())}this.output.write(n),this.state==="initial"&&(this.state="active"),this._prevFrame=n}}}var W,Ti,le,Mi,fe,me,ue=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},ge,nr=10,Si=(n=0)=>(o)=>`\x1B[${o+n}m`,vi=(n=0)=>(o)=>`\x1B[${38+n};5;${o}m`,ji=(n=0)=>(o,i,s)=>`\x1B[${38+n};2;${o};${i};${s}m`,G,he,de,be,mo,we=39,ir="\x07",Li="[",$e="]",Ni="m",sr,Ri=(n)=>`${mo.values().next().value}${Li}${n}${Ni}`,Ei=(n)=>`${mo.values().next().value}${sr}${n}${ir}`,xe=(n)=>n.split(" ").map((o)=>qn(o)),or=(n,o,i)=>{let s=[...o],t=!1,e=!1,r=qn(Bi(n[n.length-1]));for(let[a,c]of s.entries()){let p=qn(c);if(r+p<=i?n[n.length-1]+=c:(n.push(c),r=0),mo.has(c)&&(t=!0,e=s.slice(a+1).join("").startsWith(sr)),t){e?c===ir&&(t=!1,e=!1):c===Ni&&(t=!1);continue}r+=p,r===i&&a<s.length-1&&(n.push(""),r=0)}!r&&n[n.length-1].length>0&&n.length>1&&(n[n.length-2]+=n.pop())},Se=(n)=>{let o=n.split(" "),i=o.length;for(;i>0&&!(qn(o[i-1])>0);)i--;return i===o.length?n:o.slice(0,i).join(" ")+o.slice(i).join("")},ve=(n,o,i={})=>{if(i.trim!==!1&&n.trim()==="")return"";let s="",t,e,r=xe(n),a=[""];for(let[p,f]of n.split(" ").entries()){i.trim!==!1&&(a[a.length-1]=a[a.length-1].trimStart());let m=qn(a[a.length-1]);if(p!==0&&(m>=o&&(i.wordWrap===!1||i.trim===!1)&&(a.push(""),m=0),(m>0||i.trim===!1)&&(a[a.length-1]+=" ",m++)),i.hard&&r[p]>o){let d=o-m,w=1+Math.floor((r[p]-d-1)/o);Math.floor((r[p]-1)/o)<w&&a.push(""),or(a,f,o);continue}if(m+r[p]>o&&m>0&&r[p]>0){if(i.wordWrap===!1&&m<o){or(a,f,o);continue}a.push("")}if(m+r[p]>o&&i.wordWrap===!1){or(a,f,o);continue}a[a.length-1]+=f}i.trim!==!1&&(a=a.map((p)=>Se(p)));let c=[...a.join(`
31
+ `)];for(let[p,f]of c.entries()){if(s+=f,mo.has(f)){let{groups:d}=new RegExp(`(?:\\${Li}(?<code>\\d+)m|\\${sr}(?<uri>.*)${ir})`).exec(c.slice(p).join(""))||{groups:{}};if(d.code!==void 0){let w=Number.parseFloat(d.code);t=w===we?void 0:w}else d.uri!==void 0&&(e=d.uri.length===0?void 0:d.uri)}let m=be.codes.get(Number(t));c[p+1]===`
32
+ `?(e&&(s+=Ei("")),t&&m&&(s+=Ri(m))):f===`
33
+ `&&(t&&m&&(s+=Ri(t)),e&&(s+=Ei(e)))}return s},je,fo,Ee,rr,Ie,Pe=(n,o,i)=>(o in n)?Ie(n,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[o]=i,Z=(n,o,i)=>(Pe(n,typeof o!="symbol"?o+"":o,i),i),er,Oe,_e,Ce=(n,o,i)=>(o in n)?_e(n,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[o]=i,Pi=(n,o,i)=>(Ce(n,typeof o!="symbol"?o+"":o,i),i),Gi,Te,Be=(n,o,i)=>(o in n)?Te(n,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[o]=i,Oi=(n,o,i)=>(Be(n,typeof o!="symbol"?o+"":o,i),i),ar,cr;var pr=T(()=>{W=F(Ln(),1),Ti=F(Mn(),1);le=pe();Mi={exports:{}};(function(n){var o={};n.exports=o,o.eastAsianWidth=function(s){var t=s.charCodeAt(0),e=s.length==2?s.charCodeAt(1):0,r=t;return 55296<=t&&t<=56319&&56320<=e&&e<=57343&&(t&=1023,e&=1023,r=t<<10|e,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?"F":r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?"H":4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?"W":32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?"Na":r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?"A":"N"},o.characterLength=function(s){var t=this.eastAsianWidth(s);return t=="F"||t=="W"||t=="A"?2:1};function i(s){return s.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}o.length=function(s){for(var t=i(s),e=0,r=0;r<t.length;r++)e=e+this.characterLength(t[r]);return e},o.slice=function(s,t,e){textLen=o.length(s),t=t||0,e=e||1,t<0&&(t=textLen+t),e<0&&(e=textLen+e);for(var r="",a=0,c=i(s),p=0;p<c.length;p++){var f=c[p],m=o.length(f);if(a>=t-(m==2?1:0))if(a+m<=e)r+=f;else break;a+=m}return r}})(Mi);fe=Mi.exports,me=Ai(fe),ge=Ai(ue);G={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(G.modifier);he=Object.keys(G.color),de=Object.keys(G.bgColor);[...he,...de];be=ye(),mo=new Set(["\x1B","\x9B"]),sr=`${$e}8;;`;je=["up","down","left","right","space","enter","cancel"],fo={actions:new Set(je),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]])};Ee=globalThis.process.platform.startsWith("win"),rr=Symbol("clack:cancel");Ie=Object.defineProperty;er=class er extends zn{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(n){super(n,!1),this.value=!!n.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",(o)=>{this.output.write(W.cursor.move(0,-1)),this.value=o,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};Oe=new WeakMap;_e=Object.defineProperty,Gi=class extends zn{constructor(n){super(n,!1),Pi(this,"options"),Pi(this,"cursor",0),this.options=n.options,this.value=[...n.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:o})=>o===n.cursorAt),0),this.on("key",(o)=>{o==="a"&&this.toggleAll()}),this.on("cursor",(o)=>{switch(o){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;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let n=this.value.length===this.options.length;this.value=n?[]:this.options.map((o)=>o.value)}toggleValue(){let n=this.value.includes(this._value);this.value=n?this.value.filter((o)=>o!==this._value):[...this.value,this._value]}},Te=Object.defineProperty;ar=class ar extends zn{constructor(n){super(n,!1),Oi(this,"options"),Oi(this,"cursor",0),this.options=n.options,this.cursor=this.options.findIndex(({value:o})=>o===n.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",(o)=>{switch(o){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}};cr=class cr extends zn{get valueWithCursor(){if(this.state==="submit")return this.value;if(this.cursor>=this.value.length)return`${this.value}\u2588`;let n=this.value.slice(0,this.cursor),[o,...i]=this.value.slice(this.cursor);return`${n}${Ti.default.inverse(o)}${i.join("")}`}get cursor(){return this._cursor}constructor(n){super(n),this.on("finalize",()=>{this.value||(this.value=n.defaultValue)})}}});import{stripVTControlCharacters as lr}from"util";import nn from"process";function Ae(){return nn.platform!=="win32"?nn.env.TERM!=="linux":!!nn.env.CI||!!nn.env.WT_SESSION||!!nn.env.TERMINUS_SUBLIME||nn.env.ConEmuTask==="{cmd::Cmder}"||nn.env.TERM_PROGRAM==="Terminus-Sublime"||nn.env.TERM_PROGRAM==="vscode"||nn.env.TERM==="xterm-256color"||nn.env.TERM==="alacritty"||nn.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var b,uo,fr,z=(n,o)=>fr?n:o,Me,zi,Ji,go,Le,O,fn,mr,ur,Ne,Ui,He,Wf,qi,Ge,Ue,qe,ze,Je,ke,Ye,ho=(n)=>{switch(n){case"initial":case"active":return b.default.cyan(Me);case"cancel":return b.default.red(zi);case"error":return b.default.yellow(Ji);case"submit":return b.default.green(go)}},gr=(n)=>{let{cursor:o,options:i,style:s}=n,t=n.maxItems??Number.POSITIVE_INFINITY,e=Math.max(process.stdout.rows-4,0),r=Math.min(e,Math.max(t,5)),a=0;o>=a+r-3?a=Math.max(Math.min(o-r+3,i.length-r),0):o<a+2&&(a=Math.max(o-2,0));let c=r<i.length&&a>0,p=r<i.length&&a+r<i.length;return i.slice(a,a+r).map((f,m,d)=>{let w=m===0&&c,u=m===d.length-1&&p;return w||u?b.default.dim("..."):s(f,m+a===o)})},k=(n)=>new cr({validate:n.validate,placeholder:n.placeholder,defaultValue:n.defaultValue,initialValue:n.initialValue,render(){let o=`${b.default.gray(O)}
34
+ ${ho(this.state)} ${n.message}
35
+ `,i=n.placeholder?b.default.inverse(n.placeholder[0])+b.default.dim(n.placeholder.slice(1)):b.default.inverse(b.default.hidden("_")),s=this.value?this.valueWithCursor:i;switch(this.state){case"error":return`${o.trim()}
36
+ ${b.default.yellow(O)} ${s}
37
+ ${b.default.yellow(fn)} ${b.default.yellow(this.error)}
38
+ `;case"submit":return`${o}${b.default.gray(O)} ${b.default.dim(this.value||n.placeholder)}`;case"cancel":return`${o}${b.default.gray(O)} ${b.default.strikethrough(b.default.dim(this.value??""))}${this.value?.trim()?`
39
+ ${b.default.gray(O)}`:""}`;default:return`${o}${b.default.cyan(O)} ${s}
40
+ ${b.default.cyan(fn)}
41
+ `}}}).prompt(),N=(n)=>{let o=n.active??"Yes",i=n.inactive??"No";return new er({active:o,inactive:i,initialValue:n.initialValue??!0,render(){let s=`${b.default.gray(O)}
42
+ ${ho(this.state)} ${n.message}
43
+ `,t=this.value?o:i;switch(this.state){case"submit":return`${s}${b.default.gray(O)} ${b.default.dim(t)}`;case"cancel":return`${s}${b.default.gray(O)} ${b.default.strikethrough(b.default.dim(t))}
44
+ ${b.default.gray(O)}`;default:return`${s}${b.default.cyan(O)} ${this.value?`${b.default.green(mr)} ${o}`:`${b.default.dim(ur)} ${b.default.dim(o)}`} ${b.default.dim("/")} ${this.value?`${b.default.dim(ur)} ${b.default.dim(i)}`:`${b.default.green(mr)} ${i}`}
45
+ ${b.default.cyan(fn)}
46
+ `}}}).prompt()},tn=(n)=>{let o=(i,s)=>{let t=i.label??String(i.value);switch(s){case"selected":return`${b.default.dim(t)}`;case"active":return`${b.default.green(mr)} ${t} ${i.hint?b.default.dim(`(${i.hint})`):""}`;case"cancelled":return`${b.default.strikethrough(b.default.dim(t))}`;default:return`${b.default.dim(ur)} ${b.default.dim(t)}`}};return new ar({options:n.options,initialValue:n.initialValue,render(){let i=`${b.default.gray(O)}
47
+ ${ho(this.state)} ${n.message}
48
+ `;switch(this.state){case"submit":return`${i}${b.default.gray(O)} ${o(this.options[this.cursor],"selected")}`;case"cancel":return`${i}${b.default.gray(O)} ${o(this.options[this.cursor],"cancelled")}
49
+ ${b.default.gray(O)}`;default:return`${i}${b.default.cyan(O)} ${gr({cursor:this.cursor,options:this.options,maxItems:n.maxItems,style:(s,t)=>o(s,t?"active":"inactive")}).join(`
50
+ ${b.default.cyan(O)} `)}
51
+ ${b.default.cyan(fn)}
52
+ `}}}).prompt()},In=(n)=>{let o=(i,s)=>{let t=i.label??String(i.value);return s==="active"?`${b.default.cyan(Ne)} ${t} ${i.hint?b.default.dim(`(${i.hint})`):""}`:s==="selected"?`${b.default.green(Ui)} ${b.default.dim(t)} ${i.hint?b.default.dim(`(${i.hint})`):""}`:s==="cancelled"?`${b.default.strikethrough(b.default.dim(t))}`:s==="active-selected"?`${b.default.green(Ui)} ${t} ${i.hint?b.default.dim(`(${i.hint})`):""}`:s==="submitted"?`${b.default.dim(t)}`:`${b.default.dim(He)} ${b.default.dim(t)}`};return new Gi({options:n.options,initialValues:n.initialValues,required:n.required??!0,cursorAt:n.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option.
53
+ ${b.default.reset(b.default.dim(`Press ${b.default.gray(b.default.bgWhite(b.default.inverse(" space ")))} to select, ${b.default.gray(b.default.bgWhite(b.default.inverse(" enter ")))} to submit`))}`},render(){let i=`${b.default.gray(O)}
54
+ ${ho(this.state)} ${n.message}
55
+ `,s=(t,e)=>{let r=this.value.includes(t.value);return e&&r?o(t,"active-selected"):r?o(t,"selected"):o(t,e?"active":"inactive")};switch(this.state){case"submit":return`${i}${b.default.gray(O)} ${this.options.filter(({value:t})=>this.value.includes(t)).map((t)=>o(t,"submitted")).join(b.default.dim(", "))||b.default.dim("none")}`;case"cancel":{let t=this.options.filter(({value:e})=>this.value.includes(e)).map((e)=>o(e,"cancelled")).join(b.default.dim(", "));return`${i}${b.default.gray(O)} ${t.trim()?`${t}
56
+ ${b.default.gray(O)}`:""}`}case"error":{let t=this.error.split(`
57
+ `).map((e,r)=>r===0?`${b.default.yellow(fn)} ${b.default.yellow(e)}`:` ${e}`).join(`
58
+ `);return`${i+b.default.yellow(O)} ${gr({options:this.options,cursor:this.cursor,maxItems:n.maxItems,style:s}).join(`
59
+ ${b.default.yellow(O)} `)}
60
+ ${t}
61
+ `}default:return`${i}${b.default.cyan(O)} ${gr({options:this.options,cursor:this.cursor,maxItems:n.maxItems,style:s}).join(`
62
+ ${b.default.cyan(O)} `)}
63
+ ${b.default.cyan(fn)}
64
+ `}}}).prompt()},B=(n="",o="")=>{let i=`
65
+ ${n}
48
66
  `.split(`
49
- `),o=qt(t).length,i=Math.max(n.reduce((s,a)=>{let c=qt(a);return c.length>s?c.length:s},0),o)+2,r=n.map((s)=>`${h.default.gray(_)} ${h.default.dim(s)}${" ".repeat(i-qt(s).length)}${h.default.gray(_)}`).join(`
50
- `);process.stdout.write(`${h.default.gray(_)}
51
- ${h.default.green(Fe)} ${h.default.reset(t)} ${h.default.gray(Un.repeat(Math.max(i-o-1,1))+Bi)}
52
- ${r}
53
- ${h.default.gray(Mi+Un.repeat(i+2)+Oi)}
54
- `)},Jn=(e="")=>{process.stdout.write(`${h.default.gray(le)} ${h.default.red(e)}
55
-
56
- `)},ee=(e="")=>{process.stdout.write(`${h.default.gray(Ei)} ${e}
57
- `)},T=(e="")=>{process.stdout.write(`${h.default.gray(_)}
58
- ${h.default.gray(le)} ${e}
59
-
60
- `)},$,Dc,xe=({indicator:e="dots"}={})=>{let t=Lt?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],n=Lt?80:120,o=process.env.CI==="true",i,r,s=!1,a="",c,l=performance.now(),m=(C)=>{let S=C>1?"Something went wrong":"Canceled";s&&N(S,C)},u=()=>m(2),g=()=>m(1),w=()=>{process.on("uncaughtExceptionMonitor",u),process.on("unhandledRejection",u),process.on("SIGINT",g),process.on("SIGTERM",g),process.on("exit",m)},d=()=>{process.removeListener("uncaughtExceptionMonitor",u),process.removeListener("unhandledRejection",u),process.removeListener("SIGINT",g),process.removeListener("SIGTERM",g),process.removeListener("exit",m)},y=()=>{if(c===void 0)return;o&&process.stdout.write(`
61
- `);let C=c.split(`
62
- `);process.stdout.write(Qe.cursor.move(-999,C.length-1)),process.stdout.write(Qe.erase.down(C.length))},b=(C)=>C.replace(/\.+$/,""),x=(C)=>{let S=(performance.now()-C)/1000,R=Math.floor(S/60),q=Math.floor(S%60);return R>0?`[${R}m ${q}s]`:`[${q}s]`},k=(C="")=>{s=!0,i=qn(),a=b(C),l=performance.now(),process.stdout.write(`${h.default.gray(_)}
63
- `);let S=0,R=0;w(),r=setInterval(()=>{if(o&&a===c)return;y(),c=a;let q=h.default.magenta(t[S]);if(o)process.stdout.write(`${q} ${a}...`);else if(e==="timer")process.stdout.write(`${q} ${a} ${x(l)}`);else{let Y=".".repeat(Math.floor(R)).slice(0,3);process.stdout.write(`${q} ${a}${Y}`)}S=S+1<t.length?S+1:0,R=R<t.length?R+0.125:0},n)},N=(C="",S=0)=>{s=!1,clearInterval(r),y();let R=S===0?h.default.green(Fe):S===1?h.default.red(Wn):h.default.red(zn);a=b(C??a),e==="timer"?process.stdout.write(`${R} ${a} ${x(l)}
64
- `):process.stdout.write(`${R} ${a}
65
- `),d(),i()};return{start:k,stop:N,message:(C="")=>{a=b(C??a)}}},zt=async(e,t)=>{let n={},o=Object.keys(e);for(let i of o){let r=e[i],s=await r({results:n})?.catch((a)=>{throw a});if(typeof t?.onCancel=="function"&&oe(s)){n[i]="canceled",t.onCancel({results:n});continue}n[i]=s}return n};var M=O(()=>{Tt();Tt();h=me(It(),1),Qe=me(Rt(),1);Lt=Ii(),_i=U("\u25C6","*"),Wn=U("\u25A0","x"),zn=U("\u25B2","x"),Fe=U("\u25C7","o"),Ei=U("\u250C","T"),_=U("\u2502","|"),le=U("\u2514","\u2014"),Nt=U("\u25CF",">"),Ut=U("\u25CB"," "),Pi=U("\u25FB","[\u2022]"),Nn=U("\u25FC","[+]"),Ai=U("\u25FB","[ ]"),Fc=U("\u25AA","\u2022"),Un=U("\u2500","-"),Bi=U("\u256E","+"),Mi=U("\u251C","+"),Oi=U("\u256F","+"),Gi=U("\u25CF","\u2022"),Hi=U("\u25C6","*"),Ti=U("\u25B2","!"),qi=U("\u25A0","x"),$={message:(e="",{symbol:t=h.default.gray(_)}={})=>{let n=[`${h.default.gray(_)}`];if(e){let[o,...i]=e.split(`
66
- `);n.push(`${t} ${o}`,...i.map((r)=>`${h.default.gray(_)} ${r}`))}process.stdout.write(`${n.join(`
67
+ `),s=lr(o).length,t=Math.max(i.reduce((r,a)=>{let c=lr(a);return c.length>r?c.length:r},0),s)+2,e=i.map((r)=>`${b.default.gray(O)} ${b.default.dim(r)}${" ".repeat(t-lr(r).length)}${b.default.gray(O)}`).join(`
68
+ `);process.stdout.write(`${b.default.gray(O)}
69
+ ${b.default.green(go)} ${b.default.reset(o)} ${b.default.gray(qi.repeat(Math.max(t-s-1,1))+Ge)}
70
+ ${e}
71
+ ${b.default.gray(Ue+qi.repeat(t+2)+qe)}
72
+ `)},ki=(n="")=>{process.stdout.write(`${b.default.gray(fn)} ${b.default.red(n)}
73
+
74
+ `)},mn=(n="")=>{process.stdout.write(`${b.default.gray(Le)} ${n}
75
+ `)},J=(n="")=>{process.stdout.write(`${b.default.gray(O)}
76
+ ${b.default.gray(fn)} ${n}
77
+
78
+ `)},$,Kf,Pn=({indicator:n="dots"}={})=>{let o=fr?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],i=fr?80:120,s=process.env.CI==="true",t,e,r=!1,a="",c,p=performance.now(),f=(S)=>{let v=S>1?"Something went wrong":"Canceled";r&&L(v,S)},m=()=>f(2),d=()=>f(1),w=()=>{process.on("uncaughtExceptionMonitor",m),process.on("unhandledRejection",m),process.on("SIGINT",d),process.on("SIGTERM",d),process.on("exit",f)},u=()=>{process.removeListener("uncaughtExceptionMonitor",m),process.removeListener("unhandledRejection",m),process.removeListener("SIGINT",d),process.removeListener("SIGTERM",d),process.removeListener("exit",f)},g=()=>{if(c===void 0)return;s&&process.stdout.write(`
79
+ `);let S=c.split(`
80
+ `);process.stdout.write(uo.cursor.move(-999,S.length-1)),process.stdout.write(uo.erase.down(S.length))},y=(S)=>S.replace(/\.+$/,""),x=(S)=>{let v=(performance.now()-S)/1000,I=Math.floor(v/60),E=Math.floor(v%60);return I>0?`[${I}m ${E}s]`:`[${E}s]`},j=(S="")=>{r=!0,t=Hi(),a=y(S),p=performance.now(),process.stdout.write(`${b.default.gray(O)}
81
+ `);let v=0,I=0;w(),e=setInterval(()=>{if(s&&a===c)return;g(),c=a;let E=b.default.magenta(o[v]);if(s)process.stdout.write(`${E} ${a}...`);else if(n==="timer")process.stdout.write(`${E} ${a} ${x(p)}`);else{let C=".".repeat(Math.floor(I)).slice(0,3);process.stdout.write(`${E} ${a}${C}`)}v=v+1<o.length?v+1:0,I=I<o.length?I+0.125:0},i)},L=(S="",v=0)=>{r=!1,clearInterval(e),g();let I=v===0?b.default.green(go):v===1?b.default.red(zi):b.default.red(Ji);a=y(S??a),n==="timer"?process.stdout.write(`${I} ${a} ${x(p)}
82
+ `):process.stdout.write(`${I} ${a}
83
+ `),u(),t()};return{start:j,stop:L,message:(S="")=>{a=y(S??a)}}},hr=async(n,o)=>{let i={},s=Object.keys(n);for(let t of s){let e=n[t],r=await e({results:i})?.catch((a)=>{throw a});if(typeof o?.onCancel=="function"&&yn(r)){i[t]="canceled",o.onCancel({results:i});continue}i[t]=r}return i};var U=T(()=>{pr();pr();b=F(Mn(),1),uo=F(Ln(),1);fr=Ae(),Me=z("\u25C6","*"),zi=z("\u25A0","x"),Ji=z("\u25B2","x"),go=z("\u25C7","o"),Le=z("\u250C","T"),O=z("\u2502","|"),fn=z("\u2514","\u2014"),mr=z("\u25CF",">"),ur=z("\u25CB"," "),Ne=z("\u25FB","[\u2022]"),Ui=z("\u25FC","[+]"),He=z("\u25FB","[ ]"),Wf=z("\u25AA","\u2022"),qi=z("\u2500","-"),Ge=z("\u256E","+"),Ue=z("\u251C","+"),qe=z("\u256F","+"),ze=z("\u25CF","\u2022"),Je=z("\u25C6","*"),ke=z("\u25B2","!"),Ye=z("\u25A0","x"),$={message:(n="",{symbol:o=b.default.gray(O)}={})=>{let i=[`${b.default.gray(O)}`];if(n){let[s,...t]=n.split(`
84
+ `);i.push(`${o} ${s}`,...t.map((e)=>`${b.default.gray(O)} ${e}`))}process.stdout.write(`${i.join(`
67
85
  `)}
68
- `)},info:(e)=>{$.message(e,{symbol:h.default.blue(Gi)})},success:(e)=>{$.message(e,{symbol:h.default.green(Hi)})},step:(e)=>{$.message(e,{symbol:h.default.green(Fe)})},warn:(e)=>{$.message(e,{symbol:h.default.yellow(Ti)})},warning:(e)=>{$.warn(e)},error:(e)=>{$.message(e,{symbol:h.default.red(qi)})}},Dc=`${h.default.gray(_)} `});function Kn(e,t){let n=Li[e]||"Unknown error";return t?`${n}: ${t}`:n}var Li;var Jt=O(()=>{Li={"core.auth.failed":"Authentication failed","core.auth.invalid_token":"Token is invalid or expired","core.fs.cannot_read":"Cannot read file","core.fs.cannot_write":"Cannot write to file","core.fs.directory_not_found":"Directory not found","core.fs.file_not_found":"File not found","core.git.dirty_working_dir":"Working directory has uncommitted changes","core.git.no_commits":"No commits found","core.git.not_repository":"Not a git repository","core.git.operation_failed":"Git operation failed","core.invalid_argument":"Invalid argument","core.invalid_config":"Invalid configuration","core.network.request_failed":"Network request failed","core.operation_cancelled":"Operation cancelled","core.operation_failed":"Operation failed","core.permission_denied":"Permission denied","hydra.config.invalid_format":"Invalid configuration format","hydra.config.missing_required":"Missing required configuration","hydra.config.not_found":"Configuration file not found","hydra.runner.creation_failed":"Runner creation failed","hydra.runner.not_found":"Runner not found","hydra.runner.removal_failed":"Runner removal failed","hydra.token.decryption_failed":"Token decryption failed","hydra.token.encryption_failed":"Token encryption failed","sisyphus.publish.failed":"Publishing failed","sisyphus.release.no_changes":"No changes to release","sisyphus.stone.invalid":"Invalid stone format","sisyphus.stone.not_found":"No stones found","sisyphus.version.conflict":"Version conflict detected","sisyphus.version.invalid_format":"Invalid version format"}});function Zn(e={}){let{errorPrefix:t="\u2717"}=e;return function n(o){if(oe(o))Ce.info("Operation cancelled"),process.exit(0);if(o instanceof te){if(Ce.error(`${t} ${o.message}`),o.code)Ce.error(` Error code: ${o.code}`)}else if(o instanceof Error)Ce.error(`${t} ${o.message}`);else Ce.error(`${t} An unexpected error occurred`),Ce.error(String(o));process.exit(1)}}var Ce,te;var Vn=O(()=>{M();I();Jt();Ce=v({prefix:"cli-core"}).child("error");te=class te extends Error{code;context;constructor(e,t,n){let o=e.includes(".")&&!e.includes(" ")?Kn(e,n):e;super(o);this.code=t;this.context=n;this.name="CLIError"}}});var ie,Ni=(e,t)=>{let n=e.length,o=t.length,i=1<<n-1,r=-1,s=0,a=n,c=n;while(c--)ie[e.charCodeAt(c)]|=1<<c;for(c=0;c<o;c++){let l=ie[t.charCodeAt(c)],m=l|s;if(l|=(l&r)+r^r,s|=~(l|r),r&=l,s&i)a++;if(r&i)a--;s=s<<1|1,r=r<<1|~(m|s),s&=m}c=n;while(c--)ie[e.charCodeAt(c)]=0;return a},Ui=(e,t)=>{let n=t.length,o=e.length,i=[],r=[],s=Math.ceil(n/32),a=Math.ceil(o/32);for(let d=0;d<s;d++)r[d]=-1,i[d]=0;let c=0;for(;c<a-1;c++){let d=0,y=-1,b=c*32,x=Math.min(32,o)+b;for(let k=b;k<x;k++)ie[e.charCodeAt(k)]|=1<<k;for(let k=0;k<n;k++){let N=ie[t.charCodeAt(k)],C=r[k/32|0]>>>k&1,S=i[k/32|0]>>>k&1,R=N|d,q=((N|S)&y)+y^y|N|S,Y=d|~(q|y),se=y&q;if(Y>>>31^C)r[k/32|0]^=1<<k;if(se>>>31^S)i[k/32|0]^=1<<k;Y=Y<<1|C,se=se<<1|S,y=se|~(R|Y),d=Y&R}for(let k=b;k<x;k++)ie[e.charCodeAt(k)]=0}let l=0,m=-1,u=c*32,g=Math.min(32,o-u)+u;for(let d=u;d<g;d++)ie[e.charCodeAt(d)]|=1<<d;let w=o;for(let d=0;d<n;d++){let y=ie[t.charCodeAt(d)],b=r[d/32|0]>>>d&1,x=i[d/32|0]>>>d&1,k=y|l,N=((y|x)&m)+m^m|y|x,C=l|~(N|m),S=m&N;if(w+=C>>>o-1&1,w-=S>>>o-1&1,C>>>31^b)r[d/32|0]^=1<<d;if(S>>>31^x)i[d/32|0]^=1<<d;C=C<<1|b,S=S<<1|x,m=S|~(k|C),l=C&k}for(let d=u;d<g;d++)ie[e.charCodeAt(d)]=0;return w},Yn=(e,t)=>{if(e.length<t.length){let n=t;t=e,e=n}if(t.length===0)return e.length;if(e.length<=32)return Ni(e,t);return Ui(e,t)};var Xn=O(()=>{ie=new Uint32Array(65536)});function et(e,t,n=3){return t.map((r)=>({distance:Yn(e.toLowerCase(),r.toLowerCase()),option:r})).filter(({distance:r})=>r<=Math.max(3,e.length/2)).sort((r,s)=>r.distance-s.distance).slice(0,n).map(({option:r})=>r)}function tt(e,t){return t[e.toLowerCase()]||null}var Qn=O(()=>{Xn()});async function Kt(e,t={}){let{fallback:n,logLevel:o="warn",message:i="Operation failed gracefully"}=t;try{return await e()}catch(r){let s=r instanceof Error?r.message:String(r);if(Fn[o](`${i}: ${s}`),n)try{await n()}catch(a){Fn.error(`Fallback also failed: ${a instanceof Error?a.message:String(a)}`)}return}}var Fn;var Dn=O(()=>{I();Fn=v({prefix:"cli-core"}).child("graceful")});function nt(e){let t=[];if(t.push(p.bold(`${e.name} - ${e.description}`)),t.push(""),t.push(p.bold("USAGE")),t.push(` ${e.usage}`),t.push(""),e.options&&e.options.length>0){t.push(p.bold("OPTIONS"));for(let n of e.options){let o=n.type?n.type==="boolean"?p.boolean("[boolean]"):n.type==="string"?p.string("[string]"):n.type==="number"?p.number("[number]"):`[${n.type}]`:"",i=n.default!==void 0?p.dim(`(default: ${n.default})`):"",r=n.required?p.error("(required)"):"",s=[n.description,o,i,r].filter(Boolean);t.push(` ${p.flag(n.flags.padEnd(26))} ${s.join(" ")}`)}t.push("")}if(e.examples&&e.examples.length>0){t.push(p.bold("EXAMPLES"));for(let n of e.examples)t.push(p.dim(` # ${n.description}`)),t.push(` ${p.value(n.command)}`),t.push("")}if(e.sections&&e.sections.length>0)for(let n of e.sections){if(t.push(p.bold(n.title)),typeof n.content==="string")t.push(n.content);else t.push(...n.content);t.push("")}if(e.notes&&e.notes.length>0){t.push(p.bold("NOTES"));for(let n of e.notes)t.push(` - ${n}`);t.push("")}if(t[t.length-1]==="")t.pop();return t.join(`
69
- `)}function st(e,t,n,o){let i=[];i.push(p.bold(e)),i.push(""),i.push(p.bold("USAGE")),i.push(` ${t}`),i.push(""),i.push(p.bold("COMMANDS"));let r=Math.max(...n.map((s)=>s.name.length));for(let s of n)i.push(` ${p.command(s.name.padEnd(r+2))} ${s.description}`);if(o)i.push(""),i.push(o);return i.join(`
70
- `)}var es=O(()=>{St()});var ts=O(()=>{I()});async function ns(e,t={}){let n={...Wi,...t},o=new Error("Operation failed");for(let i=1;i<=n.maxAttempts;i++)try{return await e()}catch(r){if(o=r instanceof Error?r:new Error(String(r)),!n.retryableErrors.some((c)=>o.message.toLowerCase().includes(c.toLowerCase()))||i===n.maxAttempts)throw o;n.onRetry(i,o);let a=Math.min(n.initialDelay*n.backoffMultiplier**(i-1),n.maxDelay);await new Promise((c)=>setTimeout(c,a))}throw o}var Wi;var ss=O(()=>{I();Wi={backoffMultiplier:2,initialDelay:1000,maxAttempts:3,maxDelay:30000,onRetry:(e,t)=>{Ct.warn(`Retry attempt ${e}: ${t.message}`)},retryableErrors:["ECONNREFUSED","ECONNRESET","ETIMEDOUT","ENOTFOUND","rate limit","429","503","502","504","npm ERR!","EPUBLISHCONFLICT"]}});import{existsSync as zi}from"fs";import{readFile as Ji}from"fs/promises";import{homedir as Ki}from"os";import{join as is}from"path";async function Yi(){try{if(zi(Zt)){let e=await Ji(Zt,"utf-8");return JSON.parse(e)}}catch{}return{}}async function Xi(e){try{await Bun.write(Zt,JSON.stringify(e,null,2))}catch{}}async function Qi(e){try{let t=await fetch(`https://registry.npmjs.org/${e}/latest`,{signal:AbortSignal.timeout(5000)});if(!t.ok)return null;return(await t.json()).version}catch{return null}}async function Fi(e){let{packageName:t,currentVersion:n,checkInterval:o=Zi,silent:i=!1}=e;if(process.env.CI||process.env.CONTINUOUS_INTEGRATION)return null;if(process.env.R5N_NO_UPDATE_CHECK==="1")return null;try{let r=await Yi(),s=r[t],a=Date.now();if(s&&a-s.lastChecked<o)return{currentVersion:n,lastChecked:s.lastChecked,latestVersion:s.latestVersion,name:t,updateAvailable:os(s.latestVersion,n)>0};let c=await Qi(t);if(!c)return null;if(r[t]={lastChecked:a,latestVersion:c},!i)Xi(r).catch(()=>{});return{currentVersion:n,lastChecked:a,latestVersion:c,name:t,updateAvailable:os(c,n)>0}}catch{return null}}function Di(e){let{name:t,currentVersion:n,latestVersion:o}=e;return["","\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510","\u2502 \u2502",`\u2502 Update available for ${(t.split("/").pop()||t).padEnd(29)} \u2502`,`\u2502 ${n.padEnd(15)} \u2192 ${o.padEnd(32)} \u2502`,"\u2502 \u2502",`\u2502 Run: bun update -g ${t.padEnd(30)} \u2502`,"\u2502 \u2502","\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518",""].join(`
71
- `)}async function rs(e,t){let n=await Fi({currentVersion:t,packageName:e,silent:!1});if(n?.updateAvailable&&process.stdout.isTTY)setTimeout(()=>{console.log(Di(n))},100)}function os(e,t){let n=e.split(".").map(Number),o=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,o.length);i++){let r=n[i]||0,s=o[i]||0;if(r>s)return 1;if(r<s)return-1}return 0}var Zi=86400000,Vi,Zt;var as=O(()=>{Vi=is(Ki(),".r5n","cache"),Zt=is(Vi,"update-check.json")});var Se=(e)=>{return e.map=(t)=>Se((n)=>t(e(n))),e.or=(t)=>Se((n)=>{try{return e(n)}catch(o){return t(n)}}),e},Vt=()=>"bad banditype"(),Yt=(e)=>Se((t)=>typeof t===typeof e?t:Vt()),re=()=>Yt(""),cs=()=>Yt(!0),ot=()=>Yt(),ls=(e)=>Se((t)=>t instanceof e?t:Vt()),ne=(e)=>ls(Object).map((t)=>{let n={};for(let o in e){let i=e[o](t[o]);i!==void 0&&(n[o]=i)}return n}),Be=(e)=>ls(Array).map((t)=>t.map(e));function Xt(e,t){return Se((n)=>{try{return e(n)}catch{try{return t(n)}catch{throw new Error("No matching schema in union")}}})}function ue(e,t){return(n)=>{if(n===void 0)return t;return e(n)}}function ps(e){return{parse(t){try{return e(t)}catch(n){throw new Error(n instanceof Error?n.message:"Validation failed")}},safeParse(t){try{return{data:e(t),success:!0}}catch(n){return{error:n instanceof Error?n:new Error("Validation failed"),success:!1}}},validator:e}}function it(){return Xt(ot(),re())}function er(){return Xt(ot(),cs())}function Qt(e){return ue(re(),e)}function Me(e){return ue(it(),e)}function ae(e){return ue(er(),e)}function fe(e){return Xt(ot(),e)}var ms=()=>{};var us=()=>{};var E=O(()=>{St();Vn();Jt();Qn();Dn();es();ts();ss();as();ms();us()});import{join as nr}from"path";async function sr(e){let t=ds.get(e);if(t)return t;try{let n=e;if(e.startsWith("@sisyphus/"))n=e;else if(e.startsWith("./")||e.startsWith("../"))n=nr(process.cwd(),e);else if(!e.includes("/"))n=`sisyphus-plugin-${e}`;rt.info(`Loading plugin: ${e}`);let o=await import(n),i=o.default||o;if(!i.name)throw new Error(`Plugin ${e} must export a 'name' property`);return ds.set(e,i),rt.info(`Loaded plugin: ${i.name} ${i.version?`v${i.version}`:""}`),i}catch(n){throw rt.error(`Failed to load plugin ${e}:`,n),new Error(`Failed to load plugin ${e}: ${n}`)}}async function hs(e){let t=[];for(let n of e)try{let o=await sr(n);t.push(o)}catch(o){rt.warn(`Skipping plugin ${n} due to error:`,o)}return t}var rt,ds;var gs=O(()=>{E();rt=v({prefix:"sisyphus:plugins"}),ds=new Map});async function ys(e,t,...n){for(let o of e)if(o.hooks?.[t])try{ke.info(`Running ${t} hook for plugin: ${o.name}`),await o.hooks[t](...n)}catch(i){throw ke.error(`Error in ${t} hook for plugin ${o.name}:`,i),new Error(`Plugin ${o.name} failed in ${t}: ${i}`)}}async function bs(e,t,n){let o=t;for(let i of e)if(i.hooks?.modifyChangelog)try{ke.info(`Running modifyChangelog hook for plugin: ${i.name}`),o=await i.hooks.modifyChangelog(o,n)}catch(r){ke.error(`Error in modifyChangelog hook for plugin ${i.name}:`,r)}return o}async function ws(e,t){let n=t;for(let o of e)if(o.hooks?.modifyConfig)try{ke.info(`Running modifyConfig hook for plugin: ${o.name}`),n=await o.hooks.modifyConfig(n)}catch(i){ke.error(`Error in modifyConfig hook for plugin ${o.name}:`,i)}return n}var ke;var $s=O(()=>{E();ke=v({prefix:"sisyphus:plugins"})});var or,ir,rr,ar,cr,Ft;var vs=O(()=>{E();or=ne({commit:re(),date:re()}),ir=ne({author:Me("r5n-bot"),email:it(),message:Me("release(\uD83C\uDF89): <packageName@version>")}),rr=ne({commitAndPush:ae(!1),github:ae(!1),npm:ae(!1),tags:ae(!1)}),ar=ne({append:ae(!0),filename:Me("CHANGELOG.md"),generate:ae(!0),root:ae(!1),template:it()}),cr=ne({post:fe(ne({})),pre:fe(ne({}))}),Ft=ps(ne({$schema:Qt("https://raw.githubusercontent.com/r5n-labs/clis/refs/heads/develop/packages/cli/sisyphus/schema.json"),changelog:fe(ar),commit:fe(ir),configPath:Me(".sisyphus"),ignore:ue(Be(re()),[]),lastStone:or,plugins:ue(Be(re()),[]),release:fe(rr),scripts:fe(cr),single:ae(!1),stones:ue(Be(re()),[]),tag:Qt("latest")}))});var{$:Cs}=globalThis.Bun;async function lr(e,t){let n=t.scripts?.pre?.[e];if(!n)return;he.info(`Running pre-${e} script: ${n}`);try{await Cs`${n}`.quiet(),he.info(`Pre-${e} script completed`)}catch(o){throw he.error(`Pre-${e} script failed:`,o),new Error(`Pre-${e} script failed: ${o}`)}}async function xs(e,t){let n=t.scripts?.post?.[e];if(!n)return;he.info(`Running post-${e} script: ${n}`);try{await Cs`${n}`.quiet(),he.info(`Post-${e} script completed`)}catch(o){he.error(`Post-${e} script failed:`,o),he.warn(`Continuing despite post-${e} script failure`)}}async function Ss(e,t,n){await lr(e,t);try{let o=await n();return await xs(e,t),o}catch(o){throw await xs(e,t),o}}var he;var ks=O(()=>{E();he=v({prefix:"sisyphus:scripts"})});var Re=()=>{};function ge(e){let t=e.match(/^([~^]?)(\d+)\.(\d+)\.(\d+)(.*)$/);if(!t)return null;let[,n="",o="0",i="0",r="0"]=t;return{major:Number.parseInt(o,10),minor:Number.parseInt(i,10),patch:Number.parseInt(r,10),prefix:n||"",version:`${o}.${i}.${r}`}}function Dt(e,t){let n=ge(e),o=ge(t);if(!n||!o)return!1;if(!o.prefix)return n.version===o.version;if(o.prefix==="^"){if(o.major>0)return n.major===o.major&&(n.minor>o.minor||n.minor===o.minor&&n.patch>=o.patch);if(o.minor>0)return n.major===0&&n.minor===o.minor&&n.patch>=o.patch;return n.major===0&&n.minor===0&&n.patch===o.patch}if(o.prefix==="~")return n.major===o.major&&n.minor===o.minor&&n.patch>=o.patch;return!1}function en(e,t,n){let o=ge(e),i=ge(t);if(!o||!i)return pr.warn(`Could not parse version constraint: ${e} -> ${t}`),t;if(n?.preserveConstraintType&&o.prefix)return`${o.prefix}${t}`;if(i.major>o.major)return i.major===0?t:`^${t}`;if(i.minor>o.minor)return o.prefix==="^"?`^${t}`:t;return o.prefix?`${o.prefix}${t}`:t}function Rs(e){let t=ge(e);return t?t.version:e}function js(e,t){return!Dt(t,e)}function Is(e,t,n){let o={...e};for(let[i,r]of Object.entries(t))if(i in o&&o[i])o[i]=en(o[i],r,n);return o}var pr;var _s=O(()=>{I();pr=v({prefix:"sisyphus"}).child("version-constraints")});var rn={};Wo(rn,{versionBumper:()=>z,updateVersionConstraint:()=>en,updateSisyphusConfig:()=>on,updateDependencyVersions:()=>Is,satisfiesConstraint:()=>Dt,runWithScripts:()=>Ss,runPluginHook:()=>ys,parseVersionConstraint:()=>ge,modifyConfigWithPlugins:()=>ws,modifyChangelogWithPlugins:()=>bs,lineSplitter:()=>tn,isInteractive:()=>nn,isBreakingChange:()=>js,handleCancel:()=>je,getStones:()=>D,getSisyphusConfig:()=>j,getPlugins:()=>mr,getPackages:()=>G,getPackageUpdateLabel:()=>Oe,getMinimumVersion:()=>Rs,ensureDryRunInTest:()=>sn,bumpTypeOrder:()=>ye,bumpTypeAnnotation:()=>be,SNAPSHOT_DATE_REGEX:()=>Ps,SNAPSHOT_DATE_LENGTH:()=>As,ISO_DATE_SEPARATOR:()=>Es,DEFAULT_SNAPSHOT_TAG:()=>Bs});var{$:ct}=globalThis.Bun;function nn({stream:e=process.stdout}={}){return Boolean(e?.isTTY&&process.env.TERM!=="dumb"&&!("CI"in process.env))}function je(e){if(typeof e==="function")e();else Jn(e||"Operation cancelled by user");process.exit(0)}function sn(e){return e}async function j({overwrite:e,tag:t,dryRun:n,silent:o,configPath:i=".sisyphus",...r}={}){let s=i.startsWith("/")?`${i}/config.json`:`./${i}/config.json`,c=await Bun.file(s).exists(),l=c&&e,m=i.includes("/.sisyphus-test-"),u="";if(!m){if(u=Bun.spawnSync(["git","rev-parse","HEAD"]).stdout.toString().trim(),u.length===0)throw new Error("Couldn't find git repository. Have you initialized git repository?")}else u="test-commit-hash";let g;if(c)try{let y=await Bun.file(s).json(),b=Ft.safeParse(y);if(!b.success)throw lt.error("Configuration validation failed:",y,b),b.error instanceof Error?new Error(`Invalid configuration file: ${b.error.message}`):b.error;g=b.data}catch(y){if(y instanceof Error)throw new Error(`Invalid configuration file: ${y.message}`);throw new Error("Failed to parse configuration file")}else g=Ft.parse({$schema:"https://raw.githubusercontent.com/r5n-labs/clis/refs/heads/develop/packages/cli/sisyphus/schema.json",ignore:[],lastStone:{commit:u,date:new Date().toISOString().split(Es)[0]||""},stones:[],tag:t||"latest"});let w={...g,...r},d=`${JSON.stringify(w,null,2)}
72
- `;if(n){if(!o)lt.info(`${f.bold(f.yellow("[dry-run]"))}
73
- ${f.italic(".sisyphus/config.json")}:
74
- ${d}`);return{...g,...r}}if(l)try{await ct`rm -rf ${i}`.quiet()}catch{}if(c&&!e)return w;return await ct`mkdir -p ${i}`.quiet(),await Bun.write(s,d),w}async function mr(e){if(at)return at;let t=e||await j();return at=await hs(t.plugins||[]),at}async function on({dryRun:e,silent:t,configPath:n,...o}){let i=await j({configPath:n}),r=`./${n||i.configPath||".sisyphus"}/config.json`,s=`${JSON.stringify({...i,...o},null,2)}
75
- `;if(e){if(!t)lt.info(`${f.bold(f.yellow("[dry-run]"))}
76
- ${f.italic(r)} would be updated to
77
- ${s}`);return}await Bun.write(r,s),P(`${f.green("Sisyphus config updated!")}`)}function Oe({name:e,version:t,bump:n,tag:o}){return`${e}@${t} => ${f.green(z({bump:n,tag:o,version:t}))} ${be[n]}`}function ur({baseVersion:e,bump:t}){let[n="0",o="0",i="0"]=e.split(".");switch(t){case"major":return`${Number.parseInt(n,10)+1}.0.0`;case"minor":return`${n}.${Number.parseInt(o,10)+1}.0`;case"dependency":case"patch":return`${n}.${o}.${Number.parseInt(i,10)+1}`;default:return`${n}.${o}.${i}`}}function z({version:e="",bump:t,tag:n}){let[o="0.0.0",i=""]=e.split("-"),[r="",s="0"]=i.split(".");if(t==="snapshot"){let a=new Date().toISOString().replace(Ps,"").slice(0,As);return`0.0.0-${n||Bs}-${a}`}if(n&&!t){let a=n===r?Number.parseInt(s,10)+1:1;return`${o}-${n}.${a}`}if(n||t==="dependency"&&r){let a=n===r?Number.parseInt(s,10)+1:1;return`${o}-${n||r}.${a}`}return ur({baseVersion:o,bump:t})}async function D({dryRun:e,silent:t,configPath:n,testModeEnabled:o}={}){let i=o,r=await j({configPath:n,dryRun:e,silent:t}),s=i&&n?`${n}/stones`:`./${n||r.configPath||".sisyphus"}/stones`;try{let c=(await ct`ls ${s} 2>/dev/null || true`.quiet()).stdout.toString().trim();if(!c)return[];return c.split(`
78
- `).filter(Boolean).map((m)=>m.replace(".md",""))}catch(a){if(!e)await ct`mkdir -p ${s}`.quiet();return[]}}async function G({filter:e,single:t,includePrivate:n}={}){let o=process.cwd(),i=await Bun.file("package.json").json();if(t)return dr(i);let r=i?.workspaces||[];if(r.length===0)throw new Error(`Seems like package.json doesn't have \`workspaces\` field or it's empty. Are you sure you are in the root of the workspace? (cwd: ${o})
79
-
80
- If you want to run Sisyphus in single-mode/root package, use --single flag or set \`"single": true\` in .sisyphus/config.json.`);let{packages:s,privatePackageCount:a}=await fr({cwd:o,includePrivate:n,workspaces:r}),c=Object.keys(s);return{packageNames:e?c.filter((l)=>l.includes(e)):c,packages:s,privatePackageCount:a}}async function fr({workspaces:e,cwd:t,includePrivate:n}){let o={},i={},r=0;for(let s of e){let a=new Bun.Glob(`${s}/package.json`).scanSync({cwd:t});for(let c of a){let{name:l,version:m,private:u,dependencies:g={},devDependencies:w={}}=await Bun.file(c).json();if(u&&!n){lt.debug(`Skipping private package: ${l}`),r++;continue}let y=Object.entries({...g,...w}).map(([b,x])=>x.startsWith("workspace")?b:"").filter(Boolean);for(let b of y)if(i[b]||=[],!i[b].includes(l))i[b].push(l);o[l]={bump:"dependency",dependencyOf:[],file:c,name:l,version:m||"0.0.0"}}}for(let[s,a]of Object.entries(i))if(o[s])o[s].dependencyOf=a;return{packages:o,privatePackageCount:r}}function dr({name:e,version:t}){return{packageNames:[e],packages:{[e]:{bump:"dependency",dependencyOf:[],file:"package.json",name:e,version:t||"0.0.0"}},privatePackageCount:0}}var lt,tn="***",Es=".",Ps,As=14,Bs="nightly",ye,be,at=null;var B=O(()=>{M();I();gs();$s();vs();ks();Re();_s();lt=v({prefix:"sisyphus"}).child("helpers"),Ps=/[.ZT:-]/g,ye=["dependency","patch","minor","major","snapshot"],be={dependency:"\uD83D\uDCE6",patch:"\uD83D\uDC1B",minor:"\u2728",major:"\uD83D\uDEA8",snapshot:"\uD83D\uDCF8"}});E();I();var de="0.4.4";E();E();var fs=Zn({errorPrefix:"\u2717"});M();E();I();B();import{parseArgs as hr}from"util";var Os=v({prefix:"changeset"}),Ms=".changesets";async function Gs(){let e=await Cr();ee("\uD83D\uDE80 Create a new changeset");try{let{packages:t,packageNames:n}=await G({includePrivate:!1});if(n.length===0)throw new te("No public packages found","NO_PUBLIC_PACKAGES");let o=n.map((r)=>({name:r,version:t[r]?.version||"0.0.0"})),i=await gr(o,e.all);if(i.changes.length===0){T("\u274C No packages selected");return}if(e.dryRun){wr(i),T("\u2728 Dry run complete - no files created");return}await $r(i),T("\u2728 Changeset created successfully!")}catch(t){throw Os.error("Failed to create changeset:",t),t}}async function gr(e,t){let n=await yr(e,t);if(n.length===0)return{changes:[],summary:""};let o=[];for(let a of n){let c=await br(a);if(c)o.push({packageName:a.name,versionType:c})}let i=await L({message:"Write a summary for this change",placeholder:"Fixed critical bug in authentication flow",validate:(a)=>{if(!a||a.trim().length===0)return"Summary is required";if(a.length>100)return"Summary should be less than 100 characters";return}});if(typeof i==="symbol")throw new te("Changeset creation cancelled","CANCELLED");let r=await A({initialValue:!1,message:"Do you want to add a longer description?"}),s;if(r){let a=await L({message:"Write a detailed description (optional)",placeholder:"This change fixes the issue where users could not..."});if(typeof a!=="symbol"&&a.trim().length>0)s=a}return{changes:o,description:s,summary:i}}async function yr(e,t){if(t)return e;let n=e.map((i)=>({hint:i.version,label:i.name,value:i})),o=await F({message:"Which packages have changed?",options:n,required:!1});if(typeof o==="symbol")throw new te("Package selection cancelled","CANCELLED");return o}async function br(e){let t=await V({message:`How should ${e.name} be updated?`,options:[{hint:"Bug fixes and small changes",label:"Patch",value:"patch"},{hint:"New features, backwards compatible",label:"Minor",value:"minor"},{hint:"Breaking changes",label:"Major",value:"major"},{hint:"Don't update this package",label:"Skip",value:"skip"}]});if(typeof t==="symbol")throw new te("Version selection cancelled","CANCELLED");return t==="skip"?null:t}function wr(e){if(console.log(`
81
- \uD83D\uDCC4 Changeset Preview:`),console.log("\u2500".repeat(50)),console.log(`Summary: ${e.summary}`),e.description)console.log(`
86
+ `)},info:(n)=>{$.message(n,{symbol:b.default.blue(ze)})},success:(n)=>{$.message(n,{symbol:b.default.green(Je)})},step:(n)=>{$.message(n,{symbol:b.default.green(go)})},warn:(n)=>{$.message(n,{symbol:b.default.yellow(ke)})},warning:(n)=>{$.warn(n)},error:(n)=>{$.message(n,{symbol:b.default.red(Ye)})}},Kf=`${b.default.gray(O)} `});var dr=()=>po(Gn(),rn()),yo=(n)=>pn(dr(),n),un=(n)=>pn(po(Gn(),Do()),n),On=(n)=>po(Gn(),n),We,Ke,Xe,Ze,Qe,yr;var Yi=T(()=>{M();We=sn({commit:rn(),date:rn()}),Ke=sn({author:yo("r5n-bot"),email:dr(),message:yo("release(\uD83C\uDF89): <packageName@version>")}),Xe=sn({commitAndPush:un(!1),github:un(!1),npm:un(!1),tags:un(!1)}),Ze=sn({append:un(!0),filename:yo("CHANGELOG.md"),generate:un(!0),root:un(!1),template:dr()}),Qe=sn({post:On(sn({})),pre:On(sn({}))}),yr=bi(sn({$schema:pn(rn(),"https://raw.githubusercontent.com/r5n-labs/clis/refs/heads/develop/packages/cli/sisyphus/schema.json"),changelog:On(Ze),commit:On(Ke),configPath:yo(".sisyphus"),ignore:pn(Un(rn()),[]),lastStone:We,plugins:pn(Un(rn()),[]),release:On(Xe),scripts:On(Qe),single:un(!1),stones:pn(Un(rn()),[]),tag:pn(rn(),"latest")}))});var _n=()=>{};function bn(n){let o=n.match(/^([~^]?)(\d+)\.(\d+)\.(\d+)(.*)$/);if(!o)return null;let[,i="",s="0",t="0",e="0"]=o;return{major:Number.parseInt(s,10),minor:Number.parseInt(t,10),patch:Number.parseInt(e,10),prefix:i||"",version:`${s}.${t}.${e}`}}function br(n,o){let i=bn(n),s=bn(o);if(!i||!s)return!1;if(!s.prefix)return i.version===s.version;if(s.prefix==="^"){if(s.major>0)return i.major===s.major&&(i.minor>s.minor||i.minor===s.minor&&i.patch>=s.patch);if(s.minor>0)return i.major===0&&i.minor===s.minor&&i.patch>=s.patch;return i.major===0&&i.minor===0&&i.patch===s.patch}if(s.prefix==="~")return i.major===s.major&&i.minor===s.minor&&i.patch>=s.patch;return!1}function wr(n,o,i){let s=bn(n),t=bn(o);if(!s||!t)return Ve.warn(`Could not parse version constraint: ${n} -> ${o}`),o;if(i?.preserveConstraintType&&s.prefix)return`${s.prefix}${o}`;if(t.major>s.major)return t.major===0?o:`^${o}`;if(t.minor>s.minor)return s.prefix==="^"?`^${o}`:o;return s.prefix?`${s.prefix}${o}`:o}function Wi(n){let o=bn(n);return o?o.version:n}function Ki(n,o){return!br(o,n)}function Xi(n,o,i){let s={...n};for(let[t,e]of Object.entries(o))if(t in s&&s[t])s[t]=wr(s[t],e,i);return s}var Ve;var Zi=T(()=>{_();Ve=R({prefix:"sisyphus"}).child("version-constraints")});var jr={};An(jr,{versionBumper:()=>K,updateVersionConstraint:()=>wr,updateSisyphusConfig:()=>vr,updateDependencyVersions:()=>Xi,satisfiesConstraint:()=>br,parseVersionConstraint:()=>bn,lineSplitter:()=>$r,isInteractive:()=>xr,isBreakingChange:()=>Ki,handleCancel:()=>Cn,getStones:()=>on,getSisyphusConfig:()=>P,getPackages:()=>q,getPackageUpdateLabel:()=>Jn,getMinimumVersion:()=>Wi,ensureDryRunInTest:()=>Sr,bumpTypeOrder:()=>wn,bumpTypeAnnotation:()=>$n,SNAPSHOT_DATE_REGEX:()=>Vi,SNAPSHOT_DATE_LENGTH:()=>Fi,ISO_DATE_SEPARATOR:()=>Qi,DEFAULT_SNAPSHOT_TAG:()=>Di});var{$:bo}=globalThis.Bun;function xr({stream:n=process.stdout}={}){return Boolean(n?.isTTY&&process.env.TERM!=="dumb"&&!("CI"in process.env))}function Cn(n){if(typeof n==="function")n();else ki(n||"Operation cancelled by user");process.exit(0)}function Sr(n){return n}async function P({overwrite:n,tag:o,dryRun:i,silent:s,configPath:t=".sisyphus",...e}={}){let r=t.startsWith("/")?`${t}/config.json`:`./${t}/config.json`,c=await Bun.file(r).exists(),p=c&&n,f=t.includes("/.sisyphus-test-"),m="";if(!f){if(m=Bun.spawnSync(["git","rev-parse","HEAD"]).stdout.toString().trim(),m.length===0)throw Error("Couldn't find git repository. Have you initialized git repository?")}else m="test-commit-hash";let d;if(c)try{let g=await Bun.file(r).json(),y=yr.safeParse(g);if(!y.success)throw wo.error("Configuration validation failed:",g,y),y.error instanceof Error?Error(`Invalid configuration file: ${y.error.message}`):y.error;d=y.data}catch(g){if(g instanceof Error)throw Error(`Invalid configuration file: ${g.message}`);throw Error("Failed to parse configuration file")}else d=yr.parse({$schema:"https://raw.githubusercontent.com/r5n-labs/clis/refs/heads/develop/packages/cli/sisyphus/schema.json",ignore:[],lastStone:{commit:m,date:new Date().toISOString().split(Qi)[0]||""},plugins:[],stones:[],tag:o||"latest"});let w={...d,...e},u=`${JSON.stringify(w,null,2)}
87
+ `;if(i){if(!s)wo.info(`${h.bold(h.yellow("[dry-run]"))}
88
+ ${h.italic(".sisyphus/config.json")}:
89
+ ${u}`);return{...d,...e}}if(p)try{await bo`rm -rf ${t}`.quiet()}catch{}if(c&&!n)return w;return await bo`mkdir -p ${t}`.quiet(),await Bun.write(r,u),w}async function vr({dryRun:n,silent:o,configPath:i,...s}){let t=await P({configPath:i}),e=`./${i||t.configPath||".sisyphus"}/config.json`,r=`${JSON.stringify({...t,...s},null,2)}
90
+ `;if(n){if(!o)wo.info(`${h.bold(h.yellow("[dry-run]"))}
91
+ ${h.italic(e)} would be updated to
92
+ ${r}`);return}await Bun.write(e,r),B(`${h.green("Sisyphus config updated!")}`)}function Jn({name:n,version:o,bump:i,tag:s}){return`${n}@${o} => ${h.green(K({bump:i,tag:s,version:o}))} ${$n[i]}`}function Fe({baseVersion:n,bump:o}){let[i="0",s="0",t="0"]=n.split(".");switch(o){case"major":return`${Number.parseInt(i,10)+1}.0.0`;case"minor":return`${i}.${Number.parseInt(s,10)+1}.0`;case"dependency":case"patch":return`${i}.${s}.${Number.parseInt(t,10)+1}`;default:return`${i}.${s}.${t}`}}function K({version:n="",bump:o,tag:i}){let[s="0.0.0",t=""]=n.split("-"),[e="",r="0"]=t.split(".");if(o==="snapshot"){let a=new Date().toISOString().replace(Vi,"").slice(0,Fi);return`0.0.0-${i||Di}-${a}`}if(i&&!o){let a=i===e?Number.parseInt(r,10)+1:1;return`${s}-${i}.${a}`}if(i||o==="dependency"&&e){let a=i===e?Number.parseInt(r,10)+1:1;return`${s}-${i||e}.${a}`}return Fe({baseVersion:s,bump:o})}async function on({dryRun:n,silent:o,configPath:i,testModeEnabled:s}={}){let t=s,e=await P({configPath:i,dryRun:n,silent:o}),r=t&&i?`${i}/stones`:`./${i||e.configPath||".sisyphus"}/stones`;try{let c=(await bo`ls ${r} 2>/dev/null || true`.quiet()).stdout.toString().trim();if(!c)return[];return c.split(`
93
+ `).filter(Boolean).map((f)=>f.replace(".md",""))}catch(a){if(!n)await bo`mkdir -p ${r}`.quiet();return[]}}async function q({filter:n,single:o,includePrivate:i}={}){let s=process.cwd(),t=await Bun.file("package.json").json();if(o)return na(t);let e=t?.workspaces,r=Array.isArray(e)?e:e?.packages||[];if(r.length===0)throw Error(`Seems like package.json doesn't have \`workspaces\` field or it's empty. Are you sure you are in the root of the workspace? (cwd: ${s})
94
+
95
+ If you want to run Sisyphus in single-mode/root package, use --single flag or set \`"single": true\` in .sisyphus/config.json.`);let{packages:a,privatePackageCount:c}=await De({cwd:s,includePrivate:i,workspaces:r}),p=Object.keys(a);return{packageNames:n?p.filter((f)=>f.includes(n)):p,packages:a,privatePackageCount:c}}async function De({workspaces:n,cwd:o,includePrivate:i}){let s={},t={},e=0;for(let r of n){let a=new Bun.Glob(`${r}/package.json`).scanSync({cwd:o});for(let c of a){let{name:p,version:f,private:m,dependencies:d={},devDependencies:w={}}=await Bun.file(c).json();if(m&&!i){wo.debug(`Skipping private package: ${p}`),e++;continue}let g=Object.entries({...d,...w}).map(([y,x])=>x.startsWith("workspace")?y:"").filter(Boolean);for(let y of g)if(t[y]||=[],!t[y].includes(p))t[y].push(p);s[p]={bump:"dependency",dependencyOf:[],file:c,name:p,version:f||"0.0.0"}}}for(let[r,a]of Object.entries(t))if(s[r])s[r].dependencyOf=a;return{packages:s,privatePackageCount:e}}function na({name:n,version:o}){return{packageNames:[n],packages:{[n]:{bump:"dependency",dependencyOf:[],file:"package.json",name:n,version:o||"0.0.0"}},privatePackageCount:0}}var wo,$r="***",Qi=".",Vi,Fi=14,Di="nightly",wn,$n;var H=T(()=>{U();_();Yi();_n();Zi();wo=R({prefix:"sisyphus"}).child("helpers"),Vi=/[.ZT:-]/g,wn=["dependency","patch","minor","major","snapshot"],$n={dependency:"\uD83D\uDCE6",patch:"\uD83D\uDC1B",minor:"\u2728",major:"\uD83D\uDEA8",snapshot:"\uD83D\uDCF8"}});var cs={};An(cs,{validateGitWorkingDirectory:()=>va,validateGitRepository:()=>ja,getCurrentGitCommit:()=>Ra});var{$:xo}=globalThis.Bun;async function va(){try{let{exitCode:n}=await xo`git diff --quiet`.nothrow(),{exitCode:o}=await xo`git diff --cached --quiet`.nothrow();if(n!==0||o!==0)throw new Y("Git working directory has uncommitted changes. Please commit or stash your changes before running this command.","GIT_DIRTY_WORKING_DIR")}catch(n){if(n instanceof Y)throw n;throw new Y("Failed to validate git working directory. Are you in a git repository?","GIT_VALIDATION_FAILED")}}async function ja(){try{await xo`git rev-parse --git-dir`.quiet()}catch{throw new Y("Not a git repository. Please initialize git repository first with 'git init'.","NOT_GIT_REPO")}}async function Ra(){try{let o=(await xo`git rev-parse HEAD`.quiet()).stdout.toString().trim();if(!o)throw new Y("Could not get current git commit","GIT_NO_COMMIT");return o}catch(n){if(n instanceof Y)throw n;throw new Y("Failed to get current git commit","GIT_COMMIT_FAILED")}}var ps=T(()=>{M()});var fs={};An(fs,{updateLockfile:()=>Ia,detectPackageManager:()=>ls});import{existsSync as So}from"fs";var{$:Ea}=globalThis.Bun;async function ls(n=process.cwd()){if(So(`${n}/bun.lock`))return"bun";if(So(`${n}/pnpm-lock.yaml`))return"pnpm";if(So(`${n}/yarn.lock`))return"yarn";if(So(`${n}/package-lock.json`))return"npm";return null}async function Ia(n={}){let{cwd:o=process.cwd(),dryRun:i=!1}=n,s=await ls(o);if(!s){Yn.warn("No lockfile detected, skipping lockfile update");return}if(i){Yn.info(`[dry-run] Would run: ${s} install`);return}Yn.info(`Updating lockfile with ${s}...`);try{await Ea`${s} install`.cwd(o).quiet(),Yn.info("Lockfile updated successfully")}catch(t){throw Yn.error(`Failed to update lockfile: ${t instanceof Error?t.message:String(t)}`),t}}var Yn;var ms=T(()=>{_();Yn=R({prefix:"lockfile-updater"})});var gs={};An(gs,{createStoneParser:()=>Aa,StoneParseError:()=>Q});function Oa(n,o){let i=o[0];if(!i)throw new Q("Stone file is empty",n);let s=i.replace(/^#+\s*/,"").trim();if(!s)throw new Q("Stone message cannot be empty",n);return s}function _a(n){let o=n.find((i)=>i.trim().startsWith("_")&&i.trim().endsWith("_"));return o?o.replace(/_/g,"").trim():void 0}function us(n){return n.split("|").map((o)=>o.trim()).filter(Boolean)}function Ca(n,o){let i=n.toLowerCase().trim(),s={dependency:"dependency",major:"major",minor:"minor",patch:"patch",snapshot:"snapshot"},t=s[i];if(!t)throw new Q(`Invalid bump type "${n}". Must be one of: ${Object.keys(s).join(", ")}`,o);return t}function Ta(n,o,i){let s=o.findIndex((p)=>{let f=p.trim();return f.includes("|")&&/:\s*-+\s*:/.test(f)});if(s===-1)throw new Q("Missing table separator (e.g., | :---: |)",n);let t=o[s-1],e=o[s+1];if(!t)throw new Q("Missing table header line",n);if(!e)throw new Q("Missing table data line",n);let r=us(t),a=us(e);if(r.length===0)throw new Q("Table header is empty",n);if(r.length!==a.length)throw new Q(`Table column mismatch: ${r.length} headers, ${a.length} data cells`,n);let c=[];for(let p=0;p<r.length;p++){let f=Ca(r[p]||"",n),m=a[p]||"";if(!m)continue;let d=m.split(",").map((w)=>w.trim()).filter(Boolean);for(let w of d){let u=i[w];if(!u){Pa.warn(`Package "${w}" in stone "${n}" not found in workspace, skipping`);continue}c.push({...u,bump:f})}}if(c.length===0)throw new Q("No valid packages found in stone",n);return c}function Ba(n,o,i){let s=o.split(`
96
+ `),t=Oa(n,s),e=_a(s),r=Ta(n,s,i);return{message:t,name:n,packages:r,tag:e}}function Aa(n){return async(o,i)=>{let s=`${n}/${o}.md`;try{let t=await Bun.file(s).text();return Ba(o,t,i)}catch(t){if(t instanceof Q)throw t;throw new Q("Could not read stone file",o,t)}}}var Pa,Q;var hs=T(()=>{_();Pa=R({prefix:"stone-parser"});Q=class Q extends Error{stoneName;cause;constructor(n,o,i){super(`Failed to parse stone "${o}": ${n}`);this.stoneName=o;this.cause=i;this.name="StoneParseError"}}});var ds={};An(ds,{createFileTransaction:()=>Ma});function Ma(){let n={changes:new Map,committed:!1};return{clear:()=>{if(n.committed)throw Error("Cannot clear committed transaction");n.changes.clear()},commit:async()=>{if(n.committed)throw Error("Transaction already committed");if(n.changes.size===0){gn.info("No changes to commit"),n.committed=!0;return}gn.info(`Committing ${n.changes.size} file changes`);let r=new Map;try{for(let[a]of n.changes)try{let c=await Bun.file(a).text();r.set(a,c)}catch{gn.debug(`File ${a} does not exist, creating new file`)}for(let a of n.changes.values())await Bun.write(a.path,a.content),gn.debug(`Wrote ${a.path}`);n.committed=!0,gn.info("Transaction committed successfully")}catch(a){gn.error("Transaction failed, attempting rollback");for(let[c,p]of r)try{await Bun.write(c,p),gn.debug(`Restored ${c} from backup`)}catch(f){gn.error(`Failed to restore ${c}: ${f}`)}throw Error(`Transaction failed: ${a instanceof Error?a.message:String(a)}`)}},getQueuedChanges:()=>{return Array.from(n.changes.entries()).map(([r,a])=>({content:a.content,path:r}))},hasChanges:()=>{return n.changes.size>0},queue:(r,a)=>{if(n.committed)throw Error("Cannot queue changes after transaction is committed");n.changes.set(r,{content:a,path:r})}}}var gn;var ys=T(()=>{_();gn=R({prefix:"file-transaction"})});M();_();var dn="0.4.5";M();M();var $i=Dr({errorPrefix:"\u2717"});U();M();_();H();import{parseArgs as oa}from"util";var os=R({prefix:"changeset"}),ns=".changesets";async function rs(){let n=await pa();mn("\uD83D\uDE80 Create a new changeset");try{let{packages:o,packageNames:i}=await q({includePrivate:!1});if(i.length===0)throw new Y("No public packages found","NO_PUBLIC_PACKAGES");let s=i.map((e)=>({name:e,version:o[e]?.version||"0.0.0"})),t=await ra(s,n.all);if(t.changes.length===0){J("\u274C No packages selected");return}if(n.dryRun){ta(t),J("\u2728 Dry run complete - no files created");return}await ea(t),J("\u2728 Changeset created successfully!")}catch(o){throw os.error("Failed to create changeset:",o),o}}async function ra(n,o){let i=await ia(n,o);if(i.length===0)return{changes:[],summary:""};let s=[];for(let a of i){let c=await sa(a);if(c)s.push({packageName:a.name,versionType:c})}let t=await k({message:"Write a summary for this change",placeholder:"Fixed critical bug in authentication flow",validate:(a)=>{if(!a||a.trim().length===0)return"Summary is required";if(a.length>100)return"Summary should be less than 100 characters";return}});if(typeof t==="symbol")throw new Y("Changeset creation cancelled","CANCELLED");let e=await N({initialValue:!1,message:"Do you want to add a longer description?"}),r;if(e){let a=await k({message:"Write a detailed description (optional)",placeholder:"This change fixes the issue where users could not..."});if(typeof a!=="symbol"&&a.trim().length>0)r=a}return{changes:s,description:r,summary:t}}async function ia(n,o){if(o)return n;let i=n.map((t)=>({hint:t.version,label:t.name,value:t})),s=await In({message:"Which packages have changed?",options:i,required:!1});if(typeof s==="symbol")throw new Y("Package selection cancelled","CANCELLED");return s}async function sa(n){let o=await tn({message:`How should ${n.name} be updated?`,options:[{hint:"Bug fixes and small changes",label:"Patch",value:"patch"},{hint:"New features, backwards compatible",label:"Minor",value:"minor"},{hint:"Breaking changes",label:"Major",value:"major"},{hint:"Don't update this package",label:"Skip",value:"skip"}]});if(typeof o==="symbol")throw new Y("Version selection cancelled","CANCELLED");return o==="skip"?null:o}function ta(n){if(console.log(`
97
+ \uD83D\uDCC4 Changeset Preview:`),console.log("\u2500".repeat(50)),console.log(`Summary: ${n.summary}`),n.description)console.log(`
82
98
  Description:
83
- ${e.description}`);console.log(`
84
- Changes:`);for(let t of e.changes)console.log(` ${t.packageName}: ${t.versionType}`);console.log("\u2500".repeat(50))}async function $r(e){let t=await import("fs/promises"),n=await import("path");await t.mkdir(Ms,{recursive:!0});let i=`${vr()}.md`,r=n.join(Ms,i),s=xr(e);await t.writeFile(r,s,"utf-8"),Os.info(`Created changeset: ${i}`)}function vr(){let e=Date.now().toString(36),t=Math.random().toString(36).substring(2,8);return`${e}-${t}`}function xr(e){let t=[];t.push("---");for(let n of e.changes)t.push(`"${n.packageName}": ${n.versionType}`);if(t.push("---"),t.push(""),t.push(e.summary),e.description)t.push(""),t.push(e.description);return t.push(""),t.join(`
85
- `)}async function Cr(){let{values:e}=hr({allowPositionals:!0,args:Bun.argv,options:{all:{default:!1,short:"a",type:"boolean"},dryRun:{default:!1,short:"d",type:"boolean"}},strict:!0});return{all:e.all,dryRun:e.dryRun}}M();E();I();B();M();I();B();import{parseArgs as Hr}from"util";var{$:J}=globalThis.Bun;E();I();B();var Ge=v({prefix:"sisyphus"}).child("changelog");async function Ts({changelogRoot:e,commit:t,dryRun:n=!1,stones:o}){let i=[""],{lastStone:{commit:r=""}}=await j(),s=Sr({stones:o});for(let[a,{bump:c,path:l,changelog:m}]of s.entries()){let u=[...m,Hs({commit:t,lastCommit:r})],g=await Bun.file(l).exists(),[w,...d]=g?(await Bun.file(l).text()).split(`
86
- `):[`# ${a}`],y=[w,...u,...d];if(n)Ge.info(`${f.bold(f.yellow("[dry-run]"))}
87
- ${y.join(`
88
- `)}`);else if(!await Kt(async()=>{return Ge.info(`Writing changelog to ${l}`),await Bun.write(l,`${y.join(`
99
+ ${n.description}`);console.log(`
100
+ Changes:`);for(let o of n.changes)console.log(` ${o.packageName}: ${o.versionType}`);console.log("\u2500".repeat(50))}async function ea(n){let o=await import("fs/promises"),i=await import("path");await o.mkdir(ns,{recursive:!0});let t=`${aa()}.md`,e=i.join(ns,t),r=ca(n);await o.writeFile(e,r,"utf-8"),os.info(`Created changeset: ${t}`)}function aa(){let n=Date.now().toString(36),o=Math.random().toString(36).substring(2,8);return`${n}-${o}`}function ca(n){let o=[];o.push("---");for(let i of n.changes)o.push(`"${i.packageName}": ${i.versionType}`);if(o.push("---"),o.push(""),o.push(n.summary),n.description)o.push(""),o.push(n.description);return o.push(""),o.join(`
101
+ `)}async function pa(){let{values:n}=oa({allowPositionals:!0,args:Bun.argv,options:{all:{default:!1,short:"a",type:"boolean"},dryRun:{default:!1,short:"d",type:"boolean"}},strict:!0});return{all:n.all,dryRun:n.dryRun}}U();M();_();H();U();_();H();import{parseArgs as La}from"util";var{$:X}=globalThis.Bun;M();_();H();var kn=R({prefix:"sisyphus"}).child("changelog");async function ss({changelogRoot:n,commit:o,dryRun:i=!1,stones:s}){let t=[""],{lastStone:{commit:e=""}}=await P(),r=la({stones:s});for(let[a,{bump:c,path:p,changelog:f}]of r.entries()){let m=[...f,is({commit:o,lastCommit:e})],d=await Bun.file(p).exists(),[w,...u]=d?(await Bun.file(p).text()).split(`
102
+ `):[`# ${a}`],g=[w,...m,...u];if(i)kn.info(`${h.bold(h.yellow("[dry-run]"))}
103
+ ${g.join(`
104
+ `)}`);else if(!await Zo(async()=>{return kn.info(`Writing changelog to ${p}`),await Bun.write(p,`${g.join(`
89
105
  `).trimEnd()}
90
- `),!0},{logLevel:"error",message:`Failed to write changelog to ${l}`}))continue;let[b="",,,x=""]=m;if(!i.includes(x))i.unshift(x);i.push(`### ${be[c]} ${a}@${b.slice(7)}`)}if(e){let a=Bun.file("CHANGELOG.md"),c=await a.exists(),[l,...m]=c?(await a.text()).split(`
91
- `):["# Changelog"],u=[l,"",...i,...m,Hs({commit:t,lastCommit:r,root:!0})];if(n)Ge.info(`${f.bold(f.yellow("[dry-run]"))}
106
+ `),!0},{logLevel:"error",message:`Failed to write changelog to ${p}`}))continue;let[y="",,,x=""]=f;if(!t.includes(x))t.unshift(x);t.push(`### ${$n[c]} ${a}@${y.slice(7)}`)}if(n){let a=Bun.file("CHANGELOG.md"),c=await a.exists(),[p,...f]=c?(await a.text()).split(`
107
+ `):["# Changelog"],m=[p,"",...t,...f,is({commit:o,lastCommit:e,root:!0})];if(i)kn.info(`${h.bold(h.yellow("[dry-run]"))}
92
108
  Root changelog:
93
- ${u.join(`
94
- `)}`);else await Kt(async()=>{Ge.info(`Writing root changelog to ${a.name}`),await Bun.write(a,u.join(`
95
- `))},{logLevel:"error",message:"Failed to write root changelog"})}}function Sr({stones:e}){let t=new Map;for(let{tag:n,packages:o,message:i}of e)for(let{file:r,name:s,version:a,bump:c}of o){let l=z({bump:c,tag:n,version:a}),{bump:m,path:u,changelog:g}=t.get(s)??{bump:c,changelog:[],path:r.replace("package.json","CHANGELOG.md")},[w="",,,d=""]=g,y=[w.replace("### ","")||"0.0.0",l].sort(Bun.semver.order)[1];t.set(s,{bump:m,changelog:[`### ${be[c]} ${y}`,"",g.length>0?"__Stones:__":"__Stone:__",`_${i}${d?`, ${d.replace(/_/g,"")}_`:"_"}`],path:u})}return t}var an="#@!";function Hs({root:e,lastCommit:t,commit:n}){let o=(()=>{try{return Bun.spawnSync(["git","remote","get-url","origin"]).stdout.toString().trim().split(":")[1]?.replaceAll(".git","")||""}catch{return""}})(),r=(()=>{try{return Bun.spawnSync(["git","log",`--pretty=format:%H${an}%s${an}%cn`,`${t}..${n}`]).stdout.toString()}catch{return Ge.warn("Could not get git commit history"),""}})().split(`
96
- `).map((s)=>{if(s.length===0)return;let[a="",c="",l=""]=s.split(an);return`- ${o?`[${a.slice(0,7)} ${c}](https://github.com/${o}/commit/${a})`:c} (by [@${l}](https://github.com/${l}))`}).filter(Boolean);return r.length>0?`
97
- <details><summary>${r.length} ${e?"Commits in this release":"Commits since last stone"}:</summary>
98
- ${r.join(`
109
+ ${m.join(`
110
+ `)}`);else await Zo(async()=>{kn.info(`Writing root changelog to ${a.name}`),await Bun.write(a,m.join(`
111
+ `))},{logLevel:"error",message:"Failed to write root changelog"})}}function la({stones:n}){let o=new Map;for(let{tag:i,packages:s,message:t}of n)for(let{file:e,name:r,version:a,bump:c}of s){let p=K({bump:c,tag:i,version:a}),{bump:f,path:m,changelog:d}=o.get(r)??{bump:c,changelog:[],path:e.replace("package.json","CHANGELOG.md")},[w="",,,u=""]=d,g=[w.replace("### ","")||"0.0.0",p].sort(Bun.semver.order)[1];o.set(r,{bump:f,changelog:[`### ${$n[c]} ${g}`,"",d.length>0?"__Stones:__":"__Stone:__",`_${t}${u?`, ${u.replace(/_/g,"")}_`:"_"}`],path:m})}return o}var Rr="#@!";function is({root:n,lastCommit:o,commit:i}){let s=(()=>{try{return Bun.spawnSync(["git","remote","get-url","origin"]).stdout.toString().trim().split(":")[1]?.replaceAll(".git","")||""}catch{return""}})(),e=(()=>{try{return Bun.spawnSync(["git","log",`--pretty=format:%H${Rr}%s${Rr}%cn`,`${o}..${i}`]).stdout.toString()}catch{return kn.warn("Could not get git commit history"),""}})().split(`
112
+ `).map((r)=>{if(r.length===0)return;let[a="",c="",p=""]=r.split(Rr);return`- ${s?`[${a.slice(0,7)} ${c}](https://github.com/${s}/commit/${a})`:c} (by [@${p}](https://github.com/${p}))`}).filter(Boolean);return e.length>0?`
113
+ <details><summary>${e.length} ${n?"Commits in this release":"Commits since last stone"}:</summary>
114
+ ${e.join(`
99
115
  `)}
100
- </details>`:""}M();I();var kr=/github\.com[:/]([^/]+)\/([^/]+)/;async function Rr(){if(process.env.GITHUB_REPOSITORY){let[e,t]=process.env.GITHUB_REPOSITORY.split("/");return{owner:e,repo:t}}try{let e=await Bun.file("package.json").json(),t=e.repository?.url||e.repository;if(typeof t==="string"){let n=t.replace("git+","").replace(".git","").replace("git@github.com:","https://github.com/"),[,o,i]=n.match(kr)||[];return{owner:o,repo:i}}}catch{}throw new Error("Could not determine GitHub repository. Please set GITHUB_REPOSITORY environment variable or ensure package.json has a valid repository URL.")}async function qs({token:e,tag:t,name:n,body:o}){let{owner:i,repo:r}=await Rr();if(!(i&&r))throw new Error("Could not determine GitHub repository. Please set GITHUB_REPOSITORY environment variable or ensure package.json has a valid repository URL.");let s=`https://api.github.com/repos/${i}/${r}/releases`;try{let a=await fetch(s,{body:JSON.stringify({body:`${n}
101
-
102
- ${o||""}`,draft:!1,name:n,prerelease:t.includes("-"),tag_name:t}),headers:{Accept:"application/vnd.github.v3+json",Authorization:`Bearer ${e}`,"Content-Type":"application/json"},method:"POST"});if(!a.ok){let c=await a.text();throw new Error(`GitHub API returned ${a.status}: ${c}`)}return a.json()}catch(a){if(a instanceof Error)throw new Error(`Failed to create GitHub release: ${a.message}`);throw a}}async function Ls({dryRun:e,github:t,githubToken:n,packages:o,rootTag:i,withTags:r}){if(e){$.info("Skipping git operations in dry run mode");return}if(jr(r,o),Ir(i),t)await _r({githubToken:n,packages:o,rootTag:i,withTags:r})}function jr(e,t){if(!e)return;for(let{name:n,version:o}of Object.values(t)){let i=`${n}@${o}`;if(Bun.spawnSync(["git","tag",i,"-m",`Release ${i}`,"-f"]).exitCode!==0)$.error(`Failed to create git tag ${i}`)}}function Ir(e){if(!e)return;let t=Bun.spawnSync(["git","tag",e,"-m","Release","-f"]);if(t.exitCode!==0)$.error(`Failed to create root tag ${e}: ${t.stderr?Buffer.from(t.stderr).toString():"Unknown error"}`)}async function _r({githubToken:e,packages:t,rootTag:n,withTags:o}){let i=e||process.env.GITHUB_TOKEN;if(!i)return P(f.reset(f.bold(`${f.redBright("No Github token found.")}
103
- Please provide one by using ${f.cyanBright("--githubToken")} flag or by setting ${f.green("GITHUB_TOKEN")} environment variable.`)));try{await Er(i,o,t),await Pr(i,n,t)}catch(r){return $.error(`Failed to create GitHub release:
104
- ${r instanceof Error?r.message:r}`),P(f.reset(f.bold(f.redBright("Failed to create GitHub release. Check your token and permissions."))))}}async function Er(e,t,n){if(!t)return;for(let o of Object.values(n)){let i=`${o.name}@${o.version}`;await qs({body:`Release of ${o.name} version ${o.version}`,name:`Release ${i}`,tag:i,token:e}),P(f.green(`\u2713 Created GitHub release for ${i}`))}}async function Pr(e,t,n){if(!t)return;let o=Object.values(n).map((i)=>`- ${i.name}@${i.version}`).join(`
105
- `);await qs({body:`Packages included:
106
- ${o}`,name:`Release ${t}`,tag:t,token:e}),P(f.green(`\u2713 Created GitHub root release ${t}`))}M();E();I();B();var{$:Ar}=globalThis.Bun;async function Ns({packages:e,dryRun:t,npmToken:n}){let o=n||process.env.NPM_CONFIG_TOKEN||process.env.NPM_TOKEN;if(!(o||t))return P(f.reset(f.bold(`${f.redBright("No NPM token found.")}
107
- Please provide one by using ${f.cyanBright("--npmToken")} flag or by setting one of ${f.green("NPM_CONFIG_TOKEN")} or ${f.green("NPM_TOKEN")} environment variables.`)));await Br({dryRun:t,packages:e,token:o})}async function Br({packages:e,dryRun:t,token:n}){let o=await Mr();for(let{name:i,version:r,tag:s,file:a}of Object.values(e)){let c=xe();c.start(`${t?f.yellow("[dry-run]: Test "):""}Publishing ${f.magenta(i)}@${f.cyanBright(r)}...`),await Or({cwd:a.replace("package.json","")});let l=await(async()=>{try{let m=Gr({dryRun:t,otp:o,tag:s});return await ns(async()=>{let{stdout:u,exitCode:g}=Bun.spawnSync(m,{cwd:a.replace("package.json",""),env:{...process.env,NPM_CONFIG_TOKEN:n,NPM_TOKEN:n},stderr:"inherit"});if(g!==0)throw new Error(`npm publish failed with exit code ${g}`);return u},{onRetry:(u,g)=>{c.stop(),c.start(`${t?f.yellow("[dry-run]: Test "):""}Retrying publish ${f.magenta(i)}@${f.cyanBright(r)} (attempt ${u})...`)}}),`${f.green("Successfully published")} ${f.magenta(i)}@${f.cyanBright(r)}`}catch(m){return $.error(m instanceof Error?m.message:String(m)),`${f.bold(`${f.redBright("Failed")} ${f.magenta(i)}@${f.cyanBright(r)}`)}`}})();c.stop(`${t?f.yellow("[dry-run]: Test "):""}${l}`)}}async function Mr(){if(!nn())return"";let e=await L({message:"Provide your NPM one-time password"});return oe(e)?"":e}async function Or({cwd:e}){try{let t=await Ar`cd ${e} && bun run build`.quiet();if(t.exitCode!==0)throw new Error(`Build failed with exit code ${t.exitCode}`)}catch(t){try{if(!(await Bun.file(`${e}/package.json`).json()).scripts?.build)return}catch{}$.warn(`${t instanceof Error?t.message:String(t)}:
108
- Error during build step. If you don't have a build step, you can ignore this message.`)}}function Gr({dryRun:e,tag:t,otp:n}){return["npm","publish","--access","public"].concat(t?["--tag",t]:[]).concat(e?["--dry-run"]:[]).concat(n?["--otp",n]:[])}var X=v({prefix:"sisyphus"}).child("roll");function Tr(){let{values:e}=Hr({allowPositionals:!0,args:Bun.argv,options:{changelog:{short:"c",type:"boolean"},changelogRoot:{short:"r",type:"boolean"},dryRun:{default:!1,short:"d",type:"boolean"},github:{short:"g",type:"boolean"},githubToken:{type:"string"},npm:{short:"n",type:"boolean"},npmToken:{type:"string"},rootTag:{type:"string"},withTags:{short:"t",type:"boolean"}},strict:!0});return e}async function Us(){let e=Tr(),{dryRun:t,changelog:n,changelogRoot:o,github:i,githubToken:r,npm:s,npmToken:a,rootTag:c,withTags:l}=e,m=await j(),u=Bun.spawnSync(["git","rev-parse","HEAD"]).stdout.toString().trim(),g=await(async()=>{try{return await He()}catch{return[]}})();if(g.length===0)return P(f.reset(f.bold(`${f.redBright("No stones found.")}
109
- ${f.reset(`Run ${f.green("bunx @r5n/sisyphus")}${f.yellow(" version")} and create some first.`)}`)));if(typeof n==="boolean"?n:m.changelog?.generate)await Ts({changelogRoot:typeof o==="boolean"?o:m.changelog?.root,commit:u,dryRun:t,stones:g});let w=await qr({dryRun:t,stones:g});if(typeof s==="boolean"?s:m.release?.npm)await Ns({dryRun:t,npmToken:a,packages:w});let d=new Date().toISOString().split(".")[0]||"";if(await Ls({dryRun:t,github:typeof i==="boolean"?i:m.release?.github,githubToken:r,packages:w,rootTag:c,withTags:typeof l==="boolean"?l:m.release?.tags}),await on({dryRun:t,lastStone:{commit:u,date:d},stones:[]}),!t)await J`rm -rf .sisyphus/stones`.quiet();if(m.release?.commitAndPush){let y=Object.values(w).map((N)=>`${N.name}@${N.version}`).join(", "),b=m.commit?.message?m.commit.message.replace("{message}",y):`release(\uD83C\uDF89): ${y}`,{stdout:x}=await J`git config --local user.name`.quiet(),{stdout:k}=await J`git config --local user.email`.quiet();console.log(`git config --local user.name "${x.toString().trim()}"`,`git config --local user.email "${k.toString().trim()}"`);try{await J`bun lint`.quiet()}catch(N){X.warn("Linting failed, continuing with commit")}try{await J`git config --local user.name "Sisyphus"`,await J`git config --local user.email "1390689+r5n-sisyphus@users.noreply.github.com"`;let{exitCode:N}=await J`git diff --cached --quiet`.nothrow(),{exitCode:C}=await J`git ls-files --others --exclude-standard`.nothrow();if(N!==0||C!==0){await J`git add -A`,await J`git commit -m "${b}"`;let{exitCode:S}=await J`git push`.nothrow();if(S!==0)X.warn("Failed to push changes. This might be due to branch protection or lack of push permissions."),X.info("The release was successful, but changes were not pushed to the repository.")}else X.info("No changes to commit after release")}catch(N){X.error(`Failed during git operations: ${N}`)}finally{try{await J`git config user.name "${x.toString().trim()}"`,await J`git config user.email "${k.toString().trim()}"`}catch{}}}}async function He({dryRun:e,silent:t,configPath:n,testModeEnabled:o}={}){let i=o,r=await D({configPath:n,dryRun:e,silent:t}),{packages:s}=await G({single:i}),a=n||".sisyphus";if(i&&r.length===0&&n)try{let l=`${n}/stones`,u=(await J`ls ${l} 2>/dev/null || true`.quiet()).stdout.toString().trim(),g=u?u.split(`
110
- `).filter(Boolean).map((w)=>w.replace(".md","")):[];if(g.length>0)return X.info(`Found ${g.length} stones in test environment`),[{message:"Test stone config",name:g[0],packages:[{bump:"major",file:`${n}/workspace/packages/test-pkg/package.json`,name:"@test/pkg",version:"1.0.0"}],tag:"latest"}]}catch(l){X.error(`Test directory read error: ${l}`)}let c=[];for(let l of r)try{let u=(await Bun.file(`${a}/stones/${l}.md`).text()).split(`
111
- `),[g]=u,w=g?.replace(/^#+\s*/,"")||"",d=u.findIndex((R)=>R.includes("|")&&R.includes(":---:"));if(d===-1){X.error(`Failed to parse stone ${l} - could not find table format`);continue}let y=u[d-1],b=u[d+1];if(!y||!b){X.error(`Failed to parse stone ${l} - invalid table structure`);continue}let x=y.split("|").map((R)=>R.trim()).filter(Boolean),k=b.split("|").map((R)=>R.trim()).filter(Boolean),N=[];for(let R=0;R<x.length;R++){let q=x[R],Y=k[R];if(Y){let se=Y.split(",").map((ze)=>ze.trim());for(let ze of se)if(s[ze])N.push({...s[ze],bump:q})}}let C=u.find((R)=>R.trim().startsWith("_")&&R.trim().endsWith("_")),S=C?C.replace(/_/g,"").trim():"";c.push({message:w.trim(),name:l,packages:N,tag:S})}catch(m){X.error(`Error processing stone ${l}
112
- ${m instanceof Error?m.message:String(m)}`)}return c}async function qr({stones:e,dryRun:t=!1}){let n=[],o={};for(let{tag:r,packages:s,message:a}of e){n.push(a);for(let c of s){o[c.name]||=c;let l=o[c.name]||c;if(r)l.tag=r;l.bump=ye.indexOf(c.bump)>ye.indexOf(l.bump)?c.bump:l.bump,o[c.name]=l}}let i=Object.values(o).reduce((r,s)=>{return r[s.name]={...s,version:s.tag?z({tag:s.tag,version:z({bump:s.bump,version:s.version})}):z({bump:s.bump,version:s.version})},r},{});if(t)X.info(`${f.bold(f.yellow("[dry-run]"))}
116
+ </details>`:""}U();_();var fa=/github\.com[:/]([^/]+)\/([^/]+)/;async function ma(){if(process.env.GITHUB_REPOSITORY){let[n,o]=process.env.GITHUB_REPOSITORY.split("/");return{owner:n,repo:o}}try{let n=await Bun.file("package.json").json(),o=n.repository?.url||n.repository;if(typeof o==="string"){let i=o.replace("git+","").replace(".git","").replace("git@github.com:","https://github.com/"),[,s,t]=i.match(fa)||[];return{owner:s,repo:t}}}catch{}throw Error("Could not determine GitHub repository. Please set GITHUB_REPOSITORY environment variable or ensure package.json has a valid repository URL.")}async function ts({token:n,tag:o,name:i,body:s}){let{owner:t,repo:e}=await ma();if(!(t&&e))throw Error("Could not determine GitHub repository. Please set GITHUB_REPOSITORY environment variable or ensure package.json has a valid repository URL.");let r=`https://api.github.com/repos/${t}/${e}/releases`;try{let a=await fetch(r,{body:JSON.stringify({body:`${i}
117
+
118
+ ${s||""}`,draft:!1,name:i,prerelease:o.includes("-"),tag_name:o}),headers:{Accept:"application/vnd.github.v3+json",Authorization:`Bearer ${n}`,"Content-Type":"application/json"},method:"POST"});if(!a.ok){let c=await a.text();throw Error(`GitHub API returned ${a.status}: ${c}`)}return a.json()}catch(a){if(a instanceof Error)throw Error(`Failed to create GitHub release: ${a.message}`);throw a}}async function es({dryRun:n,github:o,githubToken:i,packages:s,rootTag:t,withTags:e}){if(n){$.info("Skipping git operations in dry run mode");return}if(ua(e,s),ga(t),o)await ha({githubToken:i,packages:s,rootTag:t,withTags:e})}function ua(n,o){if(!n)return;for(let{name:i,version:s}of Object.values(o)){let t=`${i}@${s}`;if(Bun.spawnSync(["git","tag",t,"-m",`Release ${t}`,"-f"]).exitCode!==0)$.error(`Failed to create git tag ${t}`)}}function ga(n){if(!n)return;let o=Bun.spawnSync(["git","tag",n,"-m","Release","-f"]);if(o.exitCode!==0)$.error(`Failed to create root tag ${n}: ${o.stderr?Buffer.from(o.stderr).toString():"Unknown error"}`)}async function ha({githubToken:n,packages:o,rootTag:i,withTags:s}){let t=n||process.env.GITHUB_TOKEN;if(!t)return B(h.reset(h.bold(`${h.redBright("No Github token found.")}
119
+ Please provide one by using ${h.cyanBright("--githubToken")} flag or by setting ${h.green("GITHUB_TOKEN")} environment variable.`)));try{await da(t,s,o),await ya(t,i,o)}catch(e){return $.error(`Failed to create GitHub release:
120
+ ${e instanceof Error?e.message:e}`),B(h.reset(h.bold(h.redBright("Failed to create GitHub release. Check your token and permissions."))))}}async function da(n,o,i){if(!o)return;for(let s of Object.values(i)){let t=`${s.name}@${s.version}`;await ts({body:`Release of ${s.name} version ${s.version}`,name:`Release ${t}`,tag:t,token:n}),B(h.green(`\u2713 Created GitHub release for ${t}`))}}async function ya(n,o,i){if(!o)return;let s=Object.values(i).map((t)=>`- ${t.name}@${t.version}`).join(`
121
+ `);await ts({body:`Packages included:
122
+ ${s}`,name:`Release ${o}`,tag:o,token:n}),B(h.green(`\u2713 Created GitHub root release ${o}`))}U();M();_();H();var{$:ba}=globalThis.Bun;async function as({packages:n,dryRun:o,npmToken:i}){let s=i||process.env.NPM_CONFIG_TOKEN||process.env.NPM_TOKEN;if(!(s||o))return B(h.reset(h.bold(`${h.redBright("No NPM token found.")}
123
+ Please provide one by using ${h.cyanBright("--npmToken")} flag or by setting one of ${h.green("NPM_CONFIG_TOKEN")} or ${h.green("NPM_TOKEN")} environment variables.`)));await wa({dryRun:o,packages:n,token:s})}async function wa({packages:n,dryRun:o,token:i}){let s=await $a();for(let{name:t,version:e,tag:r,file:a}of Object.values(n)){let c=Pn();c.start(`${o?h.yellow("[dry-run]: Test "):""}Publishing ${h.magenta(t)}@${h.cyanBright(e)}...`),await xa({cwd:a.replace("package.json","")});let p=await(async()=>{try{let f=Sa({dryRun:o,otp:s,tag:r});return await pi(async()=>{let{stdout:m,exitCode:d}=Bun.spawnSync(f,{cwd:a.replace("package.json",""),env:{...process.env,NPM_CONFIG_TOKEN:i,NPM_TOKEN:i},stderr:"inherit"});if(d!==0)throw Error(`npm publish failed with exit code ${d}`);return m},{onRetry:(m,d)=>{c.stop(),c.start(`${o?h.yellow("[dry-run]: Test "):""}Retrying publish ${h.magenta(t)}@${h.cyanBright(e)} (attempt ${m})...`)}}),`${h.green("Successfully published")} ${h.magenta(t)}@${h.cyanBright(e)}`}catch(f){return $.error(f instanceof Error?f.message:String(f)),`${h.bold(`${h.redBright("Failed")} ${h.magenta(t)}@${h.cyanBright(e)}`)}`}})();c.stop(`${o?h.yellow("[dry-run]: Test "):""}${p}`)}}async function $a(){if(!xr())return"";let n=await k({message:"Provide your NPM one-time password"});return yn(n)?"":n}async function xa({cwd:n}){try{let o=await ba`cd ${n} && bun run build`.quiet();if(o.exitCode!==0)throw Error(`Build failed with exit code ${o.exitCode}`)}catch(o){try{if(!(await Bun.file(`${n}/package.json`).json()).scripts?.build)return}catch{}$.warn(`${o instanceof Error?o.message:String(o)}:
124
+ Error during build step. If you don't have a build step, you can ignore this message.`)}}function Sa({dryRun:n,tag:o,otp:i}){return["npm","publish","--access","public"].concat(o?["--tag",o]:[]).concat(n?["--dry-run"]:[]).concat(i?["--otp",i]:[])}var en=R({prefix:"sisyphus"}).child("roll");function Na(){let{values:n}=La({allowPositionals:!0,args:Bun.argv,options:{changelog:{short:"c",type:"boolean"},changelogRoot:{short:"r",type:"boolean"},"dry-run":{default:!1,short:"d",type:"boolean"},github:{short:"g",type:"boolean"},githubToken:{type:"string"},npm:{short:"n",type:"boolean"},npmToken:{type:"string"},rootTag:{type:"string"},withTags:{short:"t",type:"boolean"}},strict:!0});return{changelog:n.changelog,changelogRoot:n.changelogRoot,dryRun:n["dry-run"],github:n.github,githubToken:n.githubToken,npm:n.npm,npmToken:n.npmToken,rootTag:n.rootTag,withTags:n.withTags}}async function bs(){let{validateGitWorkingDirectory:n}=await Promise.resolve().then(() => (ps(),cs));await n();let o=Na(),{dryRun:i,changelog:s,changelogRoot:t,github:e,githubToken:r,npm:a,npmToken:c,rootTag:p,withTags:f}=o,m=await P(),d=Bun.spawnSync(["git","rev-parse","HEAD"]).stdout.toString().trim(),w=await(async()=>{try{return await Wn()}catch{return[]}})();if(w.length===0)return B(h.reset(h.bold(`${h.redBright("No stones found.")}
125
+ ${h.reset(`Run ${h.green("bunx @r5n/sisyphus")}${h.yellow(" version")} and create some first.`)}`)));if(typeof s==="boolean"?s:m.changelog?.generate)await ss({changelogRoot:typeof t==="boolean"?t:m.changelog?.root,commit:d,dryRun:i,stones:w});let u=await Ha({dryRun:i,stones:w});if(!i){let{updateLockfile:j}=await Promise.resolve().then(() => (ms(),fs));await j({dryRun:i})}if(typeof a==="boolean"?a:m.release?.npm)await as({dryRun:i,npmToken:c,packages:u});let g=new Date().toISOString().split(".")[0]||"";await es({dryRun:i,github:typeof e==="boolean"?e:m.release?.github,githubToken:r,packages:u,rootTag:p,withTags:typeof f==="boolean"?f:m.release?.tags});let y={commit:d,date:g},x=await P();if(x.lastStone.commit===d&&x.stones.length===0){en.warn("This commit has already been released. Skipping duplicate release.");return}if(await vr({dryRun:i,lastStone:y,stones:[]}),!i)await X`rm -rf .sisyphus/stones`.quiet();if(m.release?.commitAndPush){let j=Object.values(u).map((I)=>`${I.name}@${I.version}`).join(", "),L=m.commit?.message?m.commit.message.replace("{message}",j):`release(\uD83C\uDF89): ${j}`,{stdout:S}=await X`git config --local user.name`.quiet(),{stdout:v}=await X`git config --local user.email`.quiet();console.log(`git config --local user.name "${S.toString().trim()}"`,`git config --local user.email "${v.toString().trim()}"`);try{await X`bun lint`.quiet()}catch(I){en.warn("Linting failed, continuing with commit")}try{await X`git config --local user.name "Sisyphus"`,await X`git config --local user.email "1390689+r5n-sisyphus@users.noreply.github.com"`;let{exitCode:I}=await X`git diff --cached --quiet`.nothrow(),{exitCode:E}=await X`git ls-files --others --exclude-standard`.nothrow();if(I!==0||E!==0){await X`git add -A`,await X`git commit -m "${L}"`;let{exitCode:C}=await X`git push`.nothrow();if(C!==0)en.warn("Failed to push changes. This might be due to branch protection or lack of push permissions."),en.info("The release was successful, but changes were not pushed to the repository.")}else en.info("No changes to commit after release")}catch(I){en.error(`Failed during git operations: ${I}`)}finally{try{await X`git config user.name "${S.toString().trim()}"`,await X`git config user.email "${v.toString().trim()}"`}catch{}}}}async function Wn({dryRun:n,silent:o,configPath:i,testModeEnabled:s}={}){let t=s,e=await on({configPath:i,dryRun:n,silent:o}),{packages:r}=await q({single:t}),a=i||".sisyphus";if(t&&e.length===0&&i)try{let m=`${i}/stones`,w=(await X`ls ${m} 2>/dev/null || true`.quiet()).stdout.toString().trim(),u=w?w.split(`
126
+ `).filter(Boolean).map((g)=>g.replace(".md","")):[];if(u.length>0)return en.info(`Found ${u.length} stones in test environment`),[{message:"Test stone config",name:u[0],packages:[{bump:"major",file:`${i}/workspace/packages/test-pkg/package.json`,name:"@test/pkg",version:"1.0.0"}],tag:"latest"}]}catch(m){en.error(`Test directory read error: ${m}`)}let{createStoneParser:c}=await Promise.resolve().then(() => (hs(),gs)),p=c(`${a}/stones`),f=[];for(let m of e)try{let d=await p(m,r);f.push({message:d.message,name:d.name,packages:d.packages,tag:d.tag})}catch(d){en.error(`Error processing stone ${m}
127
+ ${d instanceof Error?d.message:String(d)}`)}return f}async function Ha({stones:n,dryRun:o=!1}){let i=[],s={};for(let{tag:e,packages:r,message:a}of n){i.push(a);for(let c of r){s[c.name]||=c;let p=s[c.name]||c;if(e)p.tag=e;p.bump=wn.indexOf(c.bump)>wn.indexOf(p.bump)?c.bump:p.bump,s[c.name]=p}}let t=Object.values(s).reduce((e,r)=>{return e[r.name]={...r,version:r.tag?K({tag:r.tag,version:K({bump:r.bump,version:r.version})}):K({bump:r.bump,version:r.version})},e},{});if(o)en.info(`${h.bold(h.yellow("[dry-run]"))}
113
128
  Config for next release:
114
- Stones: ${n.join(", ")}
115
- ${JSON.stringify(i,null,2)}`);else{let r={};for(let[a,c]of Object.entries(i))try{let l=await Bun.file(c.file).json();r[a]={...c,version:l.version}}catch(l){X.error(`Could not read current version for ${a}: ${l}`)}let{updateDependencyVersions:s}=await Promise.resolve().then(() => (B(),rn));for(let{version:a,file:c,name:l}of Object.values(i)){let m=await Bun.file(c).json();m.version=a;for(let[u,g]of Object.entries(i)){if(u===l)continue;let w=await Bun.file(g.file).json(),d=!1;if(w.dependencies?.[l])w.dependencies=s(w.dependencies,{[l]:a},{preserveConstraintType:!0}),d=!0;if(w.devDependencies?.[l])w.devDependencies=s(w.devDependencies,{[l]:a},{preserveConstraintType:!0}),d=!0;if(w.peerDependencies?.[l])w.peerDependencies=s(w.peerDependencies,{[l]:a},{preserveConstraintType:!0}),d=!0;if(d)await Bun.write(g.file,`${JSON.stringify(w,null,2)}
116
- `)}await Bun.write(c,`${JSON.stringify(m,null,2)}
117
- `)}}return i}var Ws=v({prefix:"sisyphus"}).child("check");async function zs(){let e=await import("util").then((d)=>d.parseArgs),{values:t}=e({allowPositionals:!0,args:Bun.argv,options:{debug:{type:"boolean"},"include-private":{type:"boolean"},json:{type:"boolean"}},strict:!1}),{json:n=!1,debug:o=!1,"include-private":i=!1}=t,r=Boolean(n);await j({dryRun:!0,silent:r});let{packages:s,packageNames:a,privatePackageCount:c}=await G({includePrivate:Boolean(i)}),{packages:l,packageNames:[m=""]}=await G({single:!0}),u=await He({dryRun:!0,silent:r});if(o)Ws.info("DEBUG: Stone configs:",JSON.stringify(u,null,2)),Ws.info("DEBUG: Packages:",JSON.stringify(s,null,2));if(r){let d={packages:a.map((y)=>({name:y,version:s[y]?.version})),privatePackageCount:c,root:{name:m,version:l[m]?.version},stones:u.map((y)=>({message:y.message,name:y.name,packages:y.packages.map((b)=>({bump:b.bump,name:b.name,newVersion:z({bump:b.bump,tag:y.tag,version:b.version}),version:b.version})),tag:y.tag}))};console.log(JSON.stringify(d,null,2));return}let g=u.length>0?`${p.bold(p.success("Stones:"))}
118
- ${u.map((d)=>`${p.arrow("\u2192")} ${p.bold("Stone:")} ${p.number(d.name)}
119
- ${p.bold("Packages:")}
120
- ${d.packages.map((y)=>` ${be[y.bump]} ${p.value(y.name)}@${p.success(z({bump:y.bump,tag:d.tag,version:y.version}))} ${p.dim(`(${y.bump})`)}`).join(`
129
+ Stones: ${i.join(", ")}
130
+ ${JSON.stringify(t,null,2)}`);else{let{updateDependencyVersions:e}=await Promise.resolve().then(() => (H(),jr)),{createFileTransaction:r}=await Promise.resolve().then(() => (ys(),ds)),a=r(),c=new Map;for(let p of Object.values(t)){let f=await Bun.file(p.file).json();c.set(p.file,f)}for(let{version:p,file:f}of Object.values(t)){let m=c.get(f);if(!m)continue;m.version=p,c.set(f,m)}for(let{version:p,name:f}of Object.values(t))for(let[m,d]of Object.entries(t)){if(m===f)continue;let w=c.get(d.file);if(!w)continue;let u=!1;if(w.dependencies?.[f])w.dependencies=e(w.dependencies,{[f]:p},{preserveConstraintType:!0}),u=!0;if(w.devDependencies?.[f])w.devDependencies=e(w.devDependencies,{[f]:p},{preserveConstraintType:!0}),u=!0;if(w.peerDependencies?.[f])w.peerDependencies=e(w.peerDependencies,{[f]:p},{preserveConstraintType:!0}),u=!0;if(u)c.set(d.file,w)}for(let[p,f]of c)a.queue(p,`${JSON.stringify(f,null,2)}
131
+ `);await a.commit()}return t}var ws=R({prefix:"sisyphus"}).child("check");async function $s(){let n=await import("util").then((u)=>u.parseArgs),{values:o}=n({allowPositionals:!0,args:Bun.argv,options:{debug:{type:"boolean"},"include-private":{type:"boolean"},json:{type:"boolean"}},strict:!1}),{json:i=!1,debug:s=!1,"include-private":t=!1}=o,e=Boolean(i);await P({dryRun:!0,silent:e});let{packages:r,packageNames:a,privatePackageCount:c}=await q({includePrivate:Boolean(t)}),{packages:p,packageNames:[f=""]}=await q({single:!0}),m=await Wn({dryRun:!0,silent:e});if(s)ws.info("DEBUG: Stone configs:",JSON.stringify(m,null,2)),ws.info("DEBUG: Packages:",JSON.stringify(r,null,2));if(e){let u={packages:a.map((g)=>({name:g,version:r[g]?.version})),privatePackageCount:c,root:{name:f,version:p[f]?.version},stones:m.map((g)=>({message:g.message,name:g.name,packages:g.packages.map((y)=>({bump:y.bump,name:y.name,newVersion:K({bump:y.bump,tag:g.tag,version:y.version}),version:y.version})),tag:g.tag}))};console.log(JSON.stringify(u,null,2));return}let d=m.length>0?`${l.bold(l.success("Stones:"))}
132
+ ${m.map((u)=>`${l.arrow("\u2192")} ${l.bold("Stone:")} ${l.number(u.name)}
133
+ ${l.bold("Packages:")}
134
+ ${u.packages.map((g)=>` ${$n[g.bump]} ${l.value(g.name)}@${l.success(K({bump:g.bump,tag:u.tag,version:g.version}))} ${l.dim(`(${g.bump})`)}`).join(`
121
135
  `)}`).join(`
122
136
 
123
- `)}`:"",w=l[m]?.version?`@${l[m]?.version}`:"";if(!r){let d=c>0&&!i?`
124
- ${p.dim(`(${c} private package${c>1?"s":""} excluded)`)}`:"";$.step(`${p.bold(p.success("Root package:"))} ${p.value(m)}${p.dim(w)}
125
- ${p.bold(p.success("Packages:"))}${d}
126
- ${a.map((y)=>{let b=s[y]?.version?`@${s[y]?.version}`:"";return` ${p.bullet("\u2022")} ${p.value(y)}${p.dim(b)}`}).join(`
137
+ `)}`:"",w=p[f]?.version?`@${p[f]?.version}`:"";if(!e){let u=c>0&&!t?`
138
+ ${l.dim(`(${c} private package${c>1?"s":""} excluded)`)}`:"";$.step(`${l.bold(l.success("Root package:"))} ${l.value(f)}${l.dim(w)}
139
+ ${l.bold(l.success("Packages:"))}${u}
140
+ ${a.map((g)=>{let y=r[g]?.version?`@${r[g]?.version}`:"";return` ${l.bullet("\u2022")} ${l.value(g)}${l.dim(y)}`}).join(`
127
141
  `)}
128
142
 
129
- ${g}`),P(p.success("Sisyphus check complete."))}}M();E();I();B();import{parseArgs as Lr}from"util";var Js=v({prefix:"sisyphus"}).child("graph");function Nr(){let{values:e}=Lr({args:process.argv.slice(3),options:{depth:{short:"d",type:"string"},filter:{short:"f",type:"string"},json:{short:"j",type:"boolean"},"show-versions":{short:"v",type:"boolean"}}});return{depth:e.depth?Number.parseInt(e.depth,10):void 0,filter:e.filter,json:e.json,showVersions:e["show-versions"]}}async function Ks(){try{let e=Nr(),{packages:t}=await G(),n=Ur(t);if(e.json){let i=Array.from(n.values());console.log(JSON.stringify(i,null,2));return}let o=n;if(e.filter)o=zr(n,e.filter,e.depth);Jr(o,e.showVersions)}catch(e){Js.error("Failed to generate dependency graph:",e),process.exit(1)}}function Ur(e){let t=new Map;for(let[n,o]of Object.entries(e))t.set(n,{dependencies:[],dependents:o.dependencyOf||[],level:0,name:n,version:o.version});for(let n of t.values())for(let o of n.dependents){let i=t.get(o);if(i)i.dependencies.push(n.name)}return Wr(t),t}function Wr(e){let t=Array.from(e.values()).filter((i)=>i.dependencies.length===0),n=new Set,o=t.map((i)=>({level:0,node:i}));while(o.length>0){let i=o.shift();if(!i)continue;let{node:r,level:s}=i;if(n.has(r.name))continue;n.add(r.name),r.level=s;for(let a of r.dependents){let c=e.get(a);if(c&&!n.has(a))o.push({level:s+1,node:c})}}}function zr(e,t,n){let o=new Map,i=Array.from(e.values()).find((a)=>a.name.includes(t));if(!i)return Js.warn(`No packages found matching filter: ${t}`),o;let r=[{currentDepth:0,node:i}],s=new Set;while(r.length>0){let a=r.shift();if(!a)continue;let{node:c,currentDepth:l}=a;if(s.has(c.name))continue;if(n!==void 0&&l>n)continue;if(s.add(c.name),o.set(c.name,c),!n||l<n)for(let m of[...c.dependencies,...c.dependents]){let u=e.get(m);if(u&&!s.has(m))r.push({currentDepth:l+1,node:u})}}return o}function Jr(e,t){let n=Array.from(e.values()),o=Math.max(...n.map((r)=>r.level));$.info(`Package Dependency Graph (${e.size} packages)`),console.log();for(let r=0;r<=o;r++){let s=n.filter((a)=>a.level===r);if(s.length===0)continue;console.log(p.dim(`Level ${r}:`));for(let a of s){let l=t?` ${p.dim(`(${a.version})`)}`:"";if(console.log(` ${p.value(a.name)}${l}`),a.dependents.length>0){let m=a.dependents.map((u)=>{return e.get(u)?p.success(u):p.dim(u)}).join(", ");console.log(` ${p.dim("\u2192")} ${m}`)}}console.log()}let i=Kr(e);if(i.length>0){console.log(p.warning("\u26A0\uFE0F Circular dependencies detected:"));for(let r of i)console.log(` ${r.join(" \u2192 ")} \u2192 ${r[0]}`);console.log()}}function Kr(e){let t=[],n=new Set,o=new Set;function i(r,s){if(o.has(r)){let c=s.indexOf(r);if(c!==-1){let l=s.slice(c),m=[...l].sort().join(",");if(!t.some((u)=>[...u].sort().join(",")===m))t.push(l)}return}if(n.has(r))return;n.add(r),o.add(r);let a=e.get(r);if(a)for(let c of a.dependencies)i(c,[...s,c]);o.delete(r)}for(let r of e.keys())if(!n.has(r))i(r,[r]);return t}E();var Zs={changeset:{description:"Create a new changeset interactively",examples:[{command:"sisyphus changeset",description:"Create changeset interactively"},{command:"sisyphus changeset --all",description:"Pre-select all packages"},{command:"sisyphus changeset --dry-run",description:"Preview without creating file"}],name:"sisyphus changeset",notes:["Changesets are stored in .changesets directory","Each changeset describes version bumps for one or more packages","Use semantic versioning: patch for fixes, minor for features, major for breaking changes"],options:[{description:"Select all packages",flags:"-a, --all",type:"boolean"},{description:"Preview without creating file",flags:"-d, --dry-run",type:"boolean"}],usage:"sisyphus changeset [options]"},check:{description:"Check current state and pending changes",examples:[{command:"sisyphus check",description:"Show pending stones and current state"},{command:"sisyphus check --verbose",description:"Show detailed change information"},{command:"sisyphus check --json",description:"Output in JSON format"},{command:"sisyphus check --include-private",description:"Include private packages"}],name:"sisyphus check",options:[{description:"Show detailed information",flags:"-v, --verbose",type:"boolean"},{description:"Output in JSON format",flags:"-j, --json",type:"boolean"},{description:"Show debug information",flags:"-d, --debug",type:"boolean"},{description:"Include private packages in the output",flags:"--include-private",type:"boolean"}],usage:"sisyphus check [options]"},graph:{description:"Visualize monorepo package dependencies",examples:[{command:"sisyphus graph",description:"Show full dependency graph"},{command:"sisyphus graph --filter @org/core",description:"Focus on specific package and its connections"},{command:"sisyphus graph --depth 1",description:"Limit depth to direct dependencies only"},{command:"sisyphus graph --show-versions",description:"Show with version numbers"},{command:"sisyphus graph --json > dependencies.json",description:"Export as JSON for further processing"}],name:"sisyphus graph",options:[{description:"Output in JSON format",flags:"-j, --json",type:"boolean"},{description:"Filter to specific package",flags:"-f, --filter",type:"string"},{description:"Limit depth of dependency tree",flags:"-d, --depth",type:"number"},{description:"Display package versions",flags:"-v, --show-versions",type:"boolean"}],usage:"sisyphus graph [options]"},init:{description:"Initialize Sisyphus in your project",examples:[{command:"sisyphus init",description:"Initialize Sisyphus interactively"},{command:"sisyphus init --force",description:"Reinitialize configuration"}],name:"sisyphus init",options:[{description:"Overwrite existing configuration",flags:"-f, --force",type:"boolean"}],usage:"sisyphus init [options]"},insights:{description:"Monorepo health analysis and insights",examples:[{command:"sisyphus insights",description:"Show overall monorepo health"},{command:"sisyphus insights --package @myorg/core",description:"Analyze specific package"},{command:"sisyphus insights --json",description:"Export insights as JSON"},{command:"sisyphus insights --include-private",description:"Include private packages in analysis"}],name:"sisyphus insights",options:[{description:"Analyze specific package",flags:"-p, --package",type:"string"},{description:"Output in JSON format",flags:"-j, --json",type:"boolean"},{description:"Include private packages in analysis",flags:"--include-private",type:"boolean"}],sections:[{content:[" - Package change frequency and staleness"," - Dependency health and circular dependencies"," - Release velocity and patterns"," - High-impact packages (many dependents)"," - Version mismatch detection"],title:"METRICS"}],usage:"sisyphus insights [options]"},metrics:{description:"View release metrics and statistics",examples:[{command:"sisyphus metrics",description:"Show metrics for last 30 days"},{command:"sisyphus metrics --days 90",description:"Show metrics for last 90 days"},{command:"sisyphus metrics --detailed",description:"Show detailed metrics"},{command:"sisyphus metrics --package @org/core",description:"Filter to specific package"},{command:"sisyphus metrics --json > metrics.json",description:"Export as JSON"}],name:"sisyphus metrics",options:[{description:"Output in JSON format",flags:"-j, --json",type:"boolean"},{description:"Number of days to analyze",flags:"-d, --days",type:"number"},{description:"Filter to specific package",flags:"-p, --package",type:"string"},{description:"Show detailed package metrics",flags:"-v, --detailed",type:"boolean"}],usage:"sisyphus metrics [options]"},migrate:{description:"Migrate from changesets, lerna, or standard-version",examples:[{command:"sisyphus migrate",description:"Auto-detect and migrate from changesets"},{command:"sisyphus migrate --clean",description:"Migrate and clean up changesets"},{command:"sisyphus migrate --dry-run",description:"Preview migration without making changes"}],name:"sisyphus migrate",notes:["Automatically detects changesets in .changeset directory","Converts YAML frontmatter to stone format","Preserves commit messages and summaries","Creates sequentially numbered stones"],options:[{description:"Source format (auto-detect if not specified)",flags:"-s, --source",type:"string"},{description:"Remove source files after migration",flags:"-c, --clean",type:"boolean"},{description:"Preview migration without changes",flags:"-d, --dry-run",type:"boolean"}],usage:"sisyphus migrate [options]"},pr:{description:"Create a stone from a pull/merge request",examples:[{command:"sisyphus pr",description:"Create stone from current branch's PR (requires gh CLI)"},{command:"sisyphus pr --url https://github.com/owner/repo/pull/123",description:"Create stone from specific GitHub PR"},{command:"sisyphus pr --url https://gitlab.com/owner/repo/-/merge_requests/123",description:"Create stone from GitLab MR"},{command:"sisyphus pr --dryRun",description:"Preview without creating stone"}],name:"sisyphus pr",notes:["Automatically detects bump type from PR labels and title","Labels: breaking-change \u2192 major, feature \u2192 minor, bug/fix \u2192 patch","Determines affected packages from changed files","Requires GitHub CLI (gh) for GitHub integration"],options:[{description:"PR/MR URL to process",flags:"-u, --url",type:"string"},{description:"Force GitHub mode",flags:"--github",type:"boolean"},{description:"Force GitLab mode",flags:"--gitlab",type:"boolean"},{description:"Preview changes without creating stone",flags:"-d, --dryRun",type:"boolean"},{description:"Skip confirmation prompt",flags:"-y, --yes",type:"boolean"}],usage:"sisyphus pr [options]"},prerelease:{description:"Manage prerelease versions (alpha, beta, rc)",examples:[{command:"sisyphus prerelease --type beta",description:"Create a new beta prerelease"},{command:"sisyphus prerelease --promote",description:"Promote prereleases (interactive UI)"},{command:'sisyphus prerelease --type alpha --filter "@org/core"',description:"Create alpha for specific packages"},{command:"sisyphus prerelease --type beta --bump minor --yes",description:"Non-interactive prerelease creation"}],name:"sisyphus prerelease",notes:["Use --promote to advance versions (alpha \u2192 beta \u2192 rc \u2192 stable)","RC and Next are treated as equivalent, both graduate to stable","You can skip tiers (e.g., alpha \u2192 rc or alpha \u2192 stable)"],options:[{description:"Prerelease type (alpha/beta/rc/etc)",flags:"-t, --type",type:"string"},{description:"Bump type (major/minor/patch)",flags:"-b, --bump",type:"string"},{description:"Promote existing prereleases",flags:"-p, --promote",type:"boolean"},{description:"Filter packages",flags:"-f, --filter",type:"string"},{description:"Preview changes",flags:"-d, --dryRun",type:"boolean"},{description:"Skip confirmation",flags:"-y, --yes",type:"boolean"}],usage:"sisyphus prerelease [options]"},preview:{description:"Preview what versions will be after rolling stones",examples:[{command:"sisyphus preview",description:"Preview release changes"},{command:"sisyphus preview --verbose",description:"Show detailed preview"},{command:"sisyphus preview --json",description:"Get preview as JSON"},{command:"sisyphus preview --include-private",description:"Include private packages in preview"}],name:"sisyphus preview",options:[{description:"Output in JSON format",flags:"-j, --json",type:"boolean"},{description:"Show additional information",flags:"-v, --verbose",type:"boolean"},{description:"Include private packages in preview",flags:"--include-private",type:"boolean"}],usage:"sisyphus preview [options]"},roll:{description:"Roll the stones and release packages",examples:[{command:"sisyphus roll",description:"Release packages with accumulated changes"},{command:"sisyphus roll --dry-run",description:"Preview release without publishing"},{command:"sisyphus roll --tag next",description:"Release with 'next' tag"}],name:"sisyphus roll",options:[{description:"Preview changes without releasing",flags:"-d, --dry-run",type:"boolean"},{description:"NPM dist-tag to use",flags:"-t, --tag",type:"string"}],usage:"sisyphus roll [options]"},solo:{description:"Single maintainer workflow (version + roll)",examples:[{command:"sisyphus solo",description:"Analyze commits and release immediately"},{command:"sisyphus solo --dry-run",description:"Preview what would be released"},{command:"sisyphus solo --tag next",description:"Release with 'next' tag"}],name:"sisyphus solo",notes:["Combines 'version --from-commits' and 'roll' in one command","Perfect for single maintainer projects","Skips stone accumulation phase","Uses conventional commits for version determination"],options:[{description:"NPM dist-tag to use",flags:"-t, --tag",type:"string"},{description:"Preview without releasing",flags:"-d, --dry-run",type:"boolean"}],usage:"sisyphus solo [options]"},stone:{description:"Manage pending stones",examples:[{command:"sisyphus stone list",description:"List all pending stones"},{command:"sisyphus stone delete stone-123",description:"Delete a specific stone"},{command:"sisyphus stone show stone-123",description:"Show stone details"},{command:"sisyphus stone merge",description:"Merge stones interactively"}],name:"sisyphus stone",notes:["Use 'sisyphus stone <command> --help' for more information about a command."],sections:[{content:[" list View all pending stones with details"," delete <id> Remove a specific stone by ID"," show <id> Display full content of a stone"," edit <id> Modify stone content or versions"," merge Combine stones with conflict resolution"],title:"COMMANDS"}],usage:"sisyphus stone <command> [options]"},version:{description:"Create a new version stone for next release",examples:[{command:"sisyphus version",description:"Create version stone interactively"},{command:"sisyphus version --from-commits",description:"Generate stones from conventional commits"},{command:"sisyphus version --dryRun",description:"Preview version changes"},{command:"sisyphus version --bump minor --filter @org/core",description:"Create with specific bump"},{command:"sisyphus version --include-private",description:"Include private packages in versioning"}],name:"sisyphus version",options:[{description:"Bump type (major/minor/patch)",flags:"-b, --bump",type:"string"},{description:"Preview changes without creating stone",flags:"-d, --dryRun",type:"boolean"},{description:"Filter packages",flags:"-f, --filter",type:"string"},{description:"Generate from conventional commits",flags:"--from-commits",type:"boolean"},{description:"Include private packages in versioning",flags:"--include-private",type:"boolean"},{description:"Create snapshot versions",flags:"-s, --snapshot",type:"boolean"},{description:"Release tag",flags:"-t, --tag",type:"string"},{description:"Skip confirmation prompt",flags:"-y, --yes",type:"boolean"}],usage:"sisyphus version [options]"}};function mt(e){if(e&&Zs[e]){console.log(nt(Zs[e]));return}let t=[{description:"Initialize Sisyphus in your project",name:"init"},{description:"Check current state and pending changes",name:"check"},{description:"Create a new changeset interactively",name:"changeset"},{description:"Visualize monorepo package dependencies",name:"graph"},{description:"Analyze monorepo health and dependencies",name:"insights"},{description:"View release metrics and statistics",name:"metrics"},{description:"Migrate from changesets/lerna/standard-version",name:"migrate"},{description:"Create stones from pull requests",name:"pr"},{description:"Manage prerelease versions (alpha, beta, rc)",name:"prerelease"},{description:"Preview what versions will be after rolling",name:"preview"},{description:"Roll the stones and release packages",name:"roll"},{description:"Single-step release (version + roll)",name:"solo"},{description:"Manage pending stones (list, delete, edit, merge)",name:"stone"},{description:"Create a new version stone for next release",name:"version"},{description:"Show this help message",name:"help"}];console.log(st(`Sisyphus@${de} - The rock-solid versioning system`,"sisyphus <command> [options]",t,"Use sisyphus <command> --help for more information about a command."))}M();I();import{parseArgs as Vr}from"util";M();I();B();Re();async function Vs({single:e,tag:t,ignore:n}){let o=await zt({commitAndPush:()=>A({active:"Yes, commit and push the release",inactive:"Skip commit",initialValue:!1,message:"Should `roll` command commit and push the release?"}),commitConfig:()=>A({active:"Yes, configure commit",inactive:"Skip commit config",initialValue:!1,message:"Configure commit for release? Default commit message is `release(\uD83C\uDF89): <packageName@version>`"}),commitAuthor:({results:{commitConfig:i}})=>i?L({message:"Commit author",placeholder:"r5n-bot"}):void 0,commitEmail:({results:{commitConfig:i}})=>i?L({message:"Commit author email",placeholder:"r5n-bot@users.noreply.github.com"}):void 0,commitMessage:({results:{commitConfig:i}})=>i?L({message:"Commit message",placeholder:"release(\uD83C\uDF89): <packageName@version>"}):void 0,generateChangelog:()=>A({active:"Yes, Generate changelog",inactive:"Skip changelog",initialValue:!0,message:"Generate changelog for release?"}),releaseOnGitHub:()=>A({active:"Yes, create a GitHub release",inactive:"Skip GitHub release",initialValue:!1,message:"Create a release on GitHub when releasing packages?"}),releaseOnNPM:()=>A({active:"Yes, publish packages to NPM",inactive:"Skip NPM release",initialValue:!1,message:"Publish packages to NPM when releasing packages?"}),releaseTags:()=>A({active:"Yes, create tags for the release",inactive:"Skip tags",initialValue:!1,message:"Create tags for the release?"}),rootChangelog:({results:{generateChangelog:i}})=>i?A({active:"Yes, generate combined changelog",inactive:"Skip root changelog",initialValue:!0,message:"Generate combined changelog for monorepo?"}):void 0,single:()=>A({active:"Yes, setup for root package",inactive:"No, setup for monorepo workspace packages",initialValue:e,message:"Setup Sisyphus for only root package?"}),tag:()=>L({initialValue:t,message:"Tag used when versioning packages. Leave `latest` if you are not sure or want to release packages with latest tag.",placeholder:"latest"})},{onCancel:()=>je()});return{commitAndPush:!!o.commitAndPush,commitAuthor:o.commitAuthor||"",commitConfig:!!o.commitConfig,commitEmail:o.commitEmail||"",commitMessage:o.commitMessage||"",generateChangelog:o.generateChangelog,releaseOnGitHub:!!o.releaseOnGitHub,releaseOnNPM:!!o.releaseOnNPM,releaseTags:!!o.releaseTags,rootChangelog:!!o.rootChangelog,single:o.single,tag:o.tag}}async function Ys({bump:e,packages:t,packageNames:n,tag:o}){let i=Zr({packageNames:n,packages:t,tag:o}),r=`
130
- - ${f.dim(f.italic(`Press ${f.underline(f.bold(f.whiteBright("a")))} to select/unselect all, ${f.underline(f.bold(f.whiteBright("SPACE")))} to select/unselect, ${f.underline(f.bold(f.whiteBright("ARROWS")))} to move, ${f.underline(f.bold(f.whiteBright("ENTER")))} to confirm`))}
131
- `,s=e?[e]:["major","minor","patch"];$.info(r);let{message:a,majorPackages:c,minorPackages:l,patchPackages:m}=await zt({majorPackages:()=>s.includes("major")?i({bump:"major"}):void 0,minorPackages:({results:{majorPackages:u}})=>s.includes("minor")?i({bump:"minor",filterPackages:u||[]}):void 0,patchPackages:({results:{majorPackages:u,minorPackages:g}})=>s.includes("patch")?i({bump:"patch",filterPackages:(u||[]).concat(g||[])}):void 0,message:()=>L({message:`Name of the stone. ${f.dim(f.italic("Default prefix or message can be configured in config."))}`,placeholder:"New feature"})},{onCancel:()=>je()});return{majorPackages:c||[],message:a,minorPackages:l||[],patchPackages:m||[]}}function Zr({packageNames:e,tag:t,packages:n}){return({bump:o,filterPackages:i=[]})=>{let r=e.filter((a)=>!i?.includes(a)).map((a)=>({label:Oe({bump:o,name:a,tag:t,version:n[a]?.version||"0.0.0"}),value:a})),s={major:f.red,minor:f.yellow,patch:f.green};return r.length>0?F({initialValues:void 0,message:`Select packages for ${f.bold(s[o](o))} bump.`,options:r,required:!1}):void 0}}B();async function Xs(){let{values:{nonInteractive:e,overwrite:t,tag:n,single:o,ignore:i}}=Vr({allowPositionals:!0,args:Bun.argv,options:{ignore:{default:[],multiple:!0,short:"i",type:"string"},nonInteractive:{default:!1,short:"n",type:"boolean"},overwrite:{default:!1,short:"o",type:"boolean"},single:{default:!1,short:"s",type:"boolean"},tag:{default:"latest",short:"t",type:"string"}},strict:!0});if(e)await j({ignore:i,overwrite:t,single:o,tag:n});else{let{commitAndPush:r,commitAuthor:s,commitConfig:a,commitEmail:c,commitMessage:l,generateChangelog:m,releaseOnGitHub:u,releaseOnNPM:g,releaseTags:w,rootChangelog:d,single:y,tag:b}=await Vs({ignore:i,single:o,tag:n}),x={ignore:i,single:y,tag:b};if(a)x.commit={author:s,email:c,message:l};if(u||g||r)x.release={commitAndPush:r,github:u,npm:g,tags:w};if(m)x.changelog={generate:m,root:d};await j({overwrite:t,...x})}P(`${f.magenta(`${f.bold("Sisyphus ")}${f.underline(f.italic(`v${de}`))}`)}${f.green(" is setup to roll stones.")}
143
+ ${d}`),B(l.success("Sisyphus check complete."))}}U();M();_();H();import{parseArgs as Ga}from"util";var xs=R({prefix:"sisyphus"}).child("graph");function Ua(){let{values:n}=Ga({args:process.argv.slice(3),options:{depth:{short:"d",type:"string"},filter:{short:"f",type:"string"},json:{short:"j",type:"boolean"},"show-versions":{short:"v",type:"boolean"}}});return{depth:n.depth?Number.parseInt(n.depth,10):void 0,filter:n.filter,json:n.json,showVersions:n["show-versions"]}}async function Ss(){try{let n=Ua(),{packages:o}=await q(),i=qa(o);if(n.json){let t=Array.from(i.values());console.log(JSON.stringify(t,null,2));return}let s=i;if(n.filter)s=Ja(i,n.filter,n.depth);ka(s,n.showVersions)}catch(n){xs.error("Failed to generate dependency graph:",n),process.exit(1)}}function qa(n){let o=new Map;for(let[i,s]of Object.entries(n))o.set(i,{dependencies:[],dependents:s.dependencyOf||[],level:0,name:i,version:s.version});for(let i of o.values())for(let s of i.dependents){let t=o.get(s);if(t)t.dependencies.push(i.name)}return za(o),o}function za(n){let o=Array.from(n.values()).filter((t)=>t.dependencies.length===0),i=new Set,s=o.map((t)=>({level:0,node:t}));while(s.length>0){let t=s.shift();if(!t)continue;let{node:e,level:r}=t;if(i.has(e.name))continue;i.add(e.name),e.level=r;for(let a of e.dependents){let c=n.get(a);if(c&&!i.has(a))s.push({level:r+1,node:c})}}}function Ja(n,o,i){let s=new Map,t=Array.from(n.values()).find((a)=>a.name.includes(o));if(!t)return xs.warn(`No packages found matching filter: ${o}`),s;let e=[{currentDepth:0,node:t}],r=new Set;while(e.length>0){let a=e.shift();if(!a)continue;let{node:c,currentDepth:p}=a;if(r.has(c.name))continue;if(i!==void 0&&p>i)continue;if(r.add(c.name),s.set(c.name,c),!i||p<i)for(let f of[...c.dependencies,...c.dependents]){let m=n.get(f);if(m&&!r.has(f))e.push({currentDepth:p+1,node:m})}}return s}function ka(n,o){let i=Array.from(n.values()),s=Math.max(...i.map((e)=>e.level));$.info(`Package Dependency Graph (${n.size} packages)`),console.log();for(let e=0;e<=s;e++){let r=i.filter((a)=>a.level===e);if(r.length===0)continue;console.log(l.dim(`Level ${e}:`));for(let a of r){let p=o?` ${l.dim(`(${a.version})`)}`:"";if(console.log(` ${l.value(a.name)}${p}`),a.dependents.length>0){let f=a.dependents.map((m)=>{return n.get(m)?l.success(m):l.dim(m)}).join(", ");console.log(` ${l.dim("\u2192")} ${f}`)}}console.log()}let t=Ya(n);if(t.length>0){console.log(l.warning("\u26A0\uFE0F Circular dependencies detected:"));for(let e of t)console.log(` ${e.join(" \u2192 ")} \u2192 ${e[0]}`);console.log()}}function Ya(n){let o=[],i=new Set,s=new Set;function t(e,r){if(s.has(e)){let c=r.indexOf(e);if(c!==-1){let p=r.slice(c),f=[...p].sort().join(",");if(!o.some((m)=>[...m].sort().join(",")===f))o.push(p)}return}if(i.has(e))return;i.add(e),s.add(e);let a=n.get(e);if(a)for(let c of a.dependencies)t(c,[...r,c]);s.delete(e)}for(let e of n.keys())if(!i.has(e))t(e,[e]);return o}M();var vs={changeset:{description:"Create a new changeset interactively",examples:[{command:"sisyphus changeset",description:"Create changeset interactively"},{command:"sisyphus changeset --all",description:"Pre-select all packages"},{command:"sisyphus changeset --dry-run",description:"Preview without creating file"}],name:"sisyphus changeset",notes:["Changesets are stored in .changesets directory","Each changeset describes version bumps for one or more packages","Use semantic versioning: patch for fixes, minor for features, major for breaking changes"],options:[{description:"Select all packages",flags:"-a, --all",type:"boolean"},{description:"Preview without creating file",flags:"-d, --dry-run",type:"boolean"}],usage:"sisyphus changeset [options]"},check:{description:"Check current state and pending changes",examples:[{command:"sisyphus check",description:"Show pending stones and current state"},{command:"sisyphus check --verbose",description:"Show detailed change information"},{command:"sisyphus check --json",description:"Output in JSON format"},{command:"sisyphus check --include-private",description:"Include private packages"}],name:"sisyphus check",options:[{description:"Show detailed information",flags:"-v, --verbose",type:"boolean"},{description:"Output in JSON format",flags:"-j, --json",type:"boolean"},{description:"Show debug information",flags:"-d, --debug",type:"boolean"},{description:"Include private packages in the output",flags:"--include-private",type:"boolean"}],usage:"sisyphus check [options]"},graph:{description:"Visualize monorepo package dependencies",examples:[{command:"sisyphus graph",description:"Show full dependency graph"},{command:"sisyphus graph --filter @org/core",description:"Focus on specific package and its connections"},{command:"sisyphus graph --depth 1",description:"Limit depth to direct dependencies only"},{command:"sisyphus graph --show-versions",description:"Show with version numbers"},{command:"sisyphus graph --json > dependencies.json",description:"Export as JSON for further processing"}],name:"sisyphus graph",options:[{description:"Output in JSON format",flags:"-j, --json",type:"boolean"},{description:"Filter to specific package",flags:"-f, --filter",type:"string"},{description:"Limit depth of dependency tree",flags:"-d, --depth",type:"number"},{description:"Display package versions",flags:"-v, --show-versions",type:"boolean"}],usage:"sisyphus graph [options]"},init:{description:"Initialize Sisyphus in your project",examples:[{command:"sisyphus init",description:"Initialize Sisyphus interactively"},{command:"sisyphus init --force",description:"Reinitialize configuration"}],name:"sisyphus init",options:[{description:"Overwrite existing configuration",flags:"-f, --force",type:"boolean"}],usage:"sisyphus init [options]"},insights:{description:"Monorepo health analysis and insights",examples:[{command:"sisyphus insights",description:"Show overall monorepo health"},{command:"sisyphus insights --package @myorg/core",description:"Analyze specific package"},{command:"sisyphus insights --json",description:"Export insights as JSON"},{command:"sisyphus insights --include-private",description:"Include private packages in analysis"}],name:"sisyphus insights",options:[{description:"Analyze specific package",flags:"-p, --package",type:"string"},{description:"Output in JSON format",flags:"-j, --json",type:"boolean"},{description:"Include private packages in analysis",flags:"--include-private",type:"boolean"}],sections:[{content:[" - Package change frequency and staleness"," - Dependency health and circular dependencies"," - Release velocity and patterns"," - High-impact packages (many dependents)"," - Version mismatch detection"],title:"METRICS"}],usage:"sisyphus insights [options]"},metrics:{description:"View release metrics and statistics",examples:[{command:"sisyphus metrics",description:"Show metrics for last 30 days"},{command:"sisyphus metrics --days 90",description:"Show metrics for last 90 days"},{command:"sisyphus metrics --detailed",description:"Show detailed metrics"},{command:"sisyphus metrics --package @org/core",description:"Filter to specific package"},{command:"sisyphus metrics --json > metrics.json",description:"Export as JSON"}],name:"sisyphus metrics",options:[{description:"Output in JSON format",flags:"-j, --json",type:"boolean"},{description:"Number of days to analyze",flags:"-d, --days",type:"number"},{description:"Filter to specific package",flags:"-p, --package",type:"string"},{description:"Show detailed package metrics",flags:"-v, --detailed",type:"boolean"}],usage:"sisyphus metrics [options]"},migrate:{description:"Migrate from changesets, lerna, or standard-version",examples:[{command:"sisyphus migrate",description:"Auto-detect and migrate from changesets"},{command:"sisyphus migrate --clean",description:"Migrate and clean up changesets"},{command:"sisyphus migrate --dry-run",description:"Preview migration without making changes"}],name:"sisyphus migrate",notes:["Automatically detects changesets in .changeset directory","Converts YAML frontmatter to stone format","Preserves commit messages and summaries","Creates sequentially numbered stones"],options:[{description:"Source format (auto-detect if not specified)",flags:"-s, --source",type:"string"},{description:"Remove source files after migration",flags:"-c, --clean",type:"boolean"},{description:"Preview migration without changes",flags:"-d, --dry-run",type:"boolean"}],usage:"sisyphus migrate [options]"},pr:{description:"Create a stone from a pull/merge request",examples:[{command:"sisyphus pr",description:"Create stone from current branch's PR (requires gh CLI)"},{command:"sisyphus pr --url https://github.com/owner/repo/pull/123",description:"Create stone from specific GitHub PR"},{command:"sisyphus pr --url https://gitlab.com/owner/repo/-/merge_requests/123",description:"Create stone from GitLab MR"},{command:"sisyphus pr --dryRun",description:"Preview without creating stone"}],name:"sisyphus pr",notes:["Automatically detects bump type from PR labels and title","Labels: breaking-change \u2192 major, feature \u2192 minor, bug/fix \u2192 patch","Determines affected packages from changed files","Requires GitHub CLI (gh) for GitHub integration"],options:[{description:"PR/MR URL to process",flags:"-u, --url",type:"string"},{description:"Force GitHub mode",flags:"--github",type:"boolean"},{description:"Force GitLab mode",flags:"--gitlab",type:"boolean"},{description:"Preview changes without creating stone",flags:"-d, --dryRun",type:"boolean"},{description:"Skip confirmation prompt",flags:"-y, --yes",type:"boolean"}],usage:"sisyphus pr [options]"},prerelease:{description:"Manage prerelease versions (alpha, beta, rc)",examples:[{command:"sisyphus prerelease --type beta",description:"Create a new beta prerelease"},{command:"sisyphus prerelease --promote",description:"Promote prereleases (interactive UI)"},{command:'sisyphus prerelease --type alpha --filter "@org/core"',description:"Create alpha for specific packages"},{command:"sisyphus prerelease --type beta --bump minor --yes",description:"Non-interactive prerelease creation"}],name:"sisyphus prerelease",notes:["Use --promote to advance versions (alpha \u2192 beta \u2192 rc \u2192 stable)","RC and Next are treated as equivalent, both graduate to stable","You can skip tiers (e.g., alpha \u2192 rc or alpha \u2192 stable)"],options:[{description:"Prerelease type (alpha/beta/rc/etc)",flags:"-t, --type",type:"string"},{description:"Bump type (major/minor/patch)",flags:"-b, --bump",type:"string"},{description:"Promote existing prereleases",flags:"-p, --promote",type:"boolean"},{description:"Filter packages",flags:"-f, --filter",type:"string"},{description:"Preview changes",flags:"-d, --dryRun",type:"boolean"},{description:"Skip confirmation",flags:"-y, --yes",type:"boolean"}],usage:"sisyphus prerelease [options]"},preview:{description:"Preview what versions will be after rolling stones",examples:[{command:"sisyphus preview",description:"Preview release changes"},{command:"sisyphus preview --verbose",description:"Show detailed preview"},{command:"sisyphus preview --json",description:"Get preview as JSON"},{command:"sisyphus preview --include-private",description:"Include private packages in preview"}],name:"sisyphus preview",options:[{description:"Output in JSON format",flags:"-j, --json",type:"boolean"},{description:"Show additional information",flags:"-v, --verbose",type:"boolean"},{description:"Include private packages in preview",flags:"--include-private",type:"boolean"}],usage:"sisyphus preview [options]"},roll:{description:"Roll the stones and release packages",examples:[{command:"sisyphus roll",description:"Release packages with accumulated changes"},{command:"sisyphus roll --dry-run",description:"Preview release without publishing"},{command:"sisyphus roll --tag next",description:"Release with 'next' tag"}],name:"sisyphus roll",options:[{description:"Preview changes without releasing",flags:"-d, --dry-run",type:"boolean"},{description:"NPM dist-tag to use",flags:"-t, --tag",type:"string"}],usage:"sisyphus roll [options]"},solo:{description:"Single maintainer workflow (version + roll)",examples:[{command:"sisyphus solo",description:"Analyze commits and release immediately"},{command:"sisyphus solo --dry-run",description:"Preview what would be released"},{command:"sisyphus solo --tag next",description:"Release with 'next' tag"}],name:"sisyphus solo",notes:["Combines 'version --from-commits' and 'roll' in one command","Perfect for single maintainer projects","Skips stone accumulation phase","Uses conventional commits for version determination"],options:[{description:"NPM dist-tag to use",flags:"-t, --tag",type:"string"},{description:"Preview without releasing",flags:"-d, --dry-run",type:"boolean"}],usage:"sisyphus solo [options]"},stone:{description:"Manage pending stones",examples:[{command:"sisyphus stone list",description:"List all pending stones"},{command:"sisyphus stone delete stone-123",description:"Delete a specific stone"},{command:"sisyphus stone show stone-123",description:"Show stone details"},{command:"sisyphus stone merge",description:"Merge stones interactively"}],name:"sisyphus stone",notes:["Use 'sisyphus stone <command> --help' for more information about a command."],sections:[{content:[" list View all pending stones with details"," delete <id> Remove a specific stone by ID"," show <id> Display full content of a stone"," edit <id> Modify stone content or versions"," merge Combine stones with conflict resolution"],title:"COMMANDS"}],usage:"sisyphus stone <command> [options]"},version:{description:"Create a new version stone for next release",examples:[{command:"sisyphus version",description:"Create version stone interactively"},{command:"sisyphus version --from-commits",description:"Generate stones from conventional commits"},{command:"sisyphus version --dryRun",description:"Preview version changes"},{command:"sisyphus version --bump minor --filter @org/core",description:"Create with specific bump"},{command:"sisyphus version --include-private",description:"Include private packages in versioning"}],name:"sisyphus version",options:[{description:"Bump type (major/minor/patch)",flags:"-b, --bump",type:"string"},{description:"Preview changes without creating stone",flags:"-d, --dryRun",type:"boolean"},{description:"Filter packages",flags:"-f, --filter",type:"string"},{description:"Generate from conventional commits",flags:"--from-commits",type:"boolean"},{description:"Include private packages in versioning",flags:"--include-private",type:"boolean"},{description:"Create snapshot versions",flags:"-s, --snapshot",type:"boolean"},{description:"Release tag",flags:"-t, --tag",type:"string"},{description:"Skip confirmation prompt",flags:"-y, --yes",type:"boolean"}],usage:"sisyphus version [options]"}};function vo(n){if(n&&vs[n]){console.log(ao(vs[n]));return}let o=[{description:"Initialize Sisyphus in your project",name:"init"},{description:"Check current state and pending changes",name:"check"},{description:"Create a new changeset interactively",name:"changeset"},{description:"Visualize monorepo package dependencies",name:"graph"},{description:"Analyze monorepo health and dependencies",name:"insights"},{description:"View release metrics and statistics",name:"metrics"},{description:"Migrate from changesets/lerna/standard-version",name:"migrate"},{description:"Create stones from pull requests",name:"pr"},{description:"Manage prerelease versions (alpha, beta, rc)",name:"prerelease"},{description:"Preview what versions will be after rolling",name:"preview"},{description:"Roll the stones and release packages",name:"roll"},{description:"Single-step release (version + roll)",name:"solo"},{description:"Manage pending stones (list, delete, edit, merge)",name:"stone"},{description:"Create a new version stone for next release",name:"version"},{description:"Show this help message",name:"help"}];console.log(co(`Sisyphus@${dn} - The rock-solid versioning system`,"sisyphus <command> [options]",o,"Use sisyphus <command> --help for more information about a command."))}U();_();import{parseArgs as Ka}from"util";U();_();H();_n();async function js({single:n,tag:o,ignore:i}){let s=await hr({commitAndPush:()=>N({active:"Yes, commit and push the release",inactive:"Skip commit",initialValue:!1,message:"Should `roll` command commit and push the release?"}),commitConfig:()=>N({active:"Yes, configure commit",inactive:"Skip commit config",initialValue:!1,message:"Configure commit for release? Default commit message is `release(\uD83C\uDF89): <packageName@version>`"}),commitAuthor:({results:{commitConfig:t}})=>t?k({message:"Commit author",placeholder:"r5n-bot"}):void 0,commitEmail:({results:{commitConfig:t}})=>t?k({message:"Commit author email",placeholder:"r5n-bot@users.noreply.github.com"}):void 0,commitMessage:({results:{commitConfig:t}})=>t?k({message:"Commit message",placeholder:"release(\uD83C\uDF89): <packageName@version>"}):void 0,generateChangelog:()=>N({active:"Yes, Generate changelog",inactive:"Skip changelog",initialValue:!0,message:"Generate changelog for release?"}),releaseOnGitHub:()=>N({active:"Yes, create a GitHub release",inactive:"Skip GitHub release",initialValue:!1,message:"Create a release on GitHub when releasing packages?"}),releaseOnNPM:()=>N({active:"Yes, publish packages to NPM",inactive:"Skip NPM release",initialValue:!1,message:"Publish packages to NPM when releasing packages?"}),releaseTags:()=>N({active:"Yes, create tags for the release",inactive:"Skip tags",initialValue:!1,message:"Create tags for the release?"}),rootChangelog:({results:{generateChangelog:t}})=>t?N({active:"Yes, generate combined changelog",inactive:"Skip root changelog",initialValue:!0,message:"Generate combined changelog for monorepo?"}):void 0,single:()=>N({active:"Yes, setup for root package",inactive:"No, setup for monorepo workspace packages",initialValue:n,message:"Setup Sisyphus for only root package?"}),tag:()=>k({initialValue:o,message:"Tag used when versioning packages. Leave `latest` if you are not sure or want to release packages with latest tag.",placeholder:"latest"})},{onCancel:()=>Cn()});return{commitAndPush:!!s.commitAndPush,commitAuthor:s.commitAuthor||"",commitConfig:!!s.commitConfig,commitEmail:s.commitEmail||"",commitMessage:s.commitMessage||"",generateChangelog:s.generateChangelog,releaseOnGitHub:!!s.releaseOnGitHub,releaseOnNPM:!!s.releaseOnNPM,releaseTags:!!s.releaseTags,rootChangelog:!!s.rootChangelog,single:s.single,tag:s.tag}}async function Rs({bump:n,packages:o,packageNames:i,tag:s}){let t=Wa({packageNames:i,packages:o,tag:s}),e=`
144
+ - ${h.dim(h.italic(`Press ${h.underline(h.bold(h.whiteBright("a")))} to select/unselect all, ${h.underline(h.bold(h.whiteBright("SPACE")))} to select/unselect, ${h.underline(h.bold(h.whiteBright("ARROWS")))} to move, ${h.underline(h.bold(h.whiteBright("ENTER")))} to confirm`))}
145
+ `,r=n?[n]:["major","minor","patch"];$.info(e);let{message:a,majorPackages:c,minorPackages:p,patchPackages:f}=await hr({majorPackages:()=>r.includes("major")?t({bump:"major"}):void 0,minorPackages:({results:{majorPackages:m}})=>r.includes("minor")?t({bump:"minor",filterPackages:m||[]}):void 0,patchPackages:({results:{majorPackages:m,minorPackages:d}})=>r.includes("patch")?t({bump:"patch",filterPackages:(m||[]).concat(d||[])}):void 0,message:()=>k({message:`Name of the stone. ${h.dim(h.italic("Default prefix or message can be configured in config."))}`,placeholder:"New feature"})},{onCancel:()=>Cn()});return{majorPackages:c||[],message:a,minorPackages:p||[],patchPackages:f||[]}}function Wa({packageNames:n,tag:o,packages:i}){return({bump:s,filterPackages:t=[]})=>{let e=n.filter((a)=>!t?.includes(a)).map((a)=>({label:Jn({bump:s,name:a,tag:o,version:i[a]?.version||"0.0.0"}),value:a})),r={major:h.red,minor:h.yellow,patch:h.green};return e.length>0?In({initialValues:void 0,message:`Select packages for ${h.bold(r[s](s))} bump.`,options:e,required:!1}):void 0}}H();async function Es(){let{values:{nonInteractive:n,overwrite:o,tag:i,single:s,ignore:t}}=Ka({allowPositionals:!0,args:Bun.argv,options:{ignore:{default:[],multiple:!0,short:"i",type:"string"},nonInteractive:{default:!1,short:"n",type:"boolean"},overwrite:{default:!1,short:"o",type:"boolean"},single:{default:!1,short:"s",type:"boolean"},tag:{default:"latest",short:"t",type:"string"}},strict:!0});if(n)await P({ignore:t,overwrite:o,single:s,tag:i});else{let{commitAndPush:e,commitAuthor:r,commitConfig:a,commitEmail:c,commitMessage:p,generateChangelog:f,releaseOnGitHub:m,releaseOnNPM:d,releaseTags:w,rootChangelog:u,single:g,tag:y}=await js({ignore:t,single:s,tag:i}),x={ignore:t,single:g,tag:y};if(a)x.commit={author:r,email:c,message:p};if(m||d||e)x.release={commitAndPush:e,github:m,npm:d,tags:w};if(f)x.changelog={generate:f,root:u};await P({overwrite:o,...x})}B(`${h.magenta(`${h.bold("Sisyphus ")}${h.underline(h.italic(`v${dn}`))}`)}${h.green(" is setup to roll stones.")}
132
146
 
133
- You can now start by creating a new stone by running ${f.reset(f.green("bunx @r5n/sisyphus"))}${f.blue(" version")}
147
+ You can now start by creating a new stone by running ${h.reset(h.green("bunx @r5n/sisyphus"))}${h.blue(" version")}
134
148
  and following the prompts.
135
149
 
136
- After you finished, you can release it by running ${f.reset(f.green("bunx @r5n/sisyphus"))}${f.blue(" roll")}
137
- `)}M();E();B();import{parseArgs as Yr}from"util";var{$:we}=globalThis.Bun;var cn=v({prefix:"sisyphus:insights"});async function Qs(){let{values:e}=Yr({args:process.argv.slice(3),options:{"include-private":{type:"boolean"},json:{short:"j",type:"boolean"},package:{short:"p",type:"string"}}}),{package:t,"include-private":n=!1}=e;ee(`${p.command("sisyphus insights")} - Monorepo health report`);try{let o=await G({includePrivate:Boolean(n)}),i=Object.values(o.packages);if(t){let r=o.packages[t];if(!r)T(p.error(`Package ${t} not found`)),process.exit(1);let s=await Bun.file(r.file).json(),a={...r,packageJson:s};await Qr(a,o)}else await Xr(i,o.packages)}catch(o){cn.error("Failed to generate insights",o),T(p.error(`Failed to generate insights: ${o}`)),process.exit(1)}}async function Xr(e,t){let n=await Promise.all(e.map(async(i)=>{try{let r=await Bun.file(i.file).json();return{...i,packageJson:r}}catch(r){return cn.warn(`Failed to load package.json for ${i.name}:`,r),{...i,packageJson:{dependencies:{},devDependencies:{}}}}})),o=await Fr(n,t);if(P(`\uD83D\uDCE6 Total Packages: ${p.value(String(o.totalPackages))}
138
- `+`\uD83D\uDD04 Circular Dependencies: ${o.circularDeps>0?p.error(String(o.circularDeps)):p.success("0")}
139
- `+`\uD83D\uDCC8 Most Changed: ${p.value(o.mostChanged.name)} (${o.mostChanged.commits} commits)
140
- `+`\uD83D\uDC0C Stale Packages: ${o.stalePackages.length>0?p.warning(String(o.stalePackages.length)):p.success("0")}
141
- `+`\uD83C\uDFAF High Impact Changes: ${p.value(String(o.highImpactPackages))}
142
- `+`\uD83D\uDE80 Release Velocity: ${p.value(o.releaseVelocity)}`,p.bold("\uD83D\uDCCA Monorepo Health Report")),o.dependencyIssues.length>0)P(o.dependencyIssues.map((i)=>`${p.dim("\u2022")} ${i}`).join(`
143
- `),p.warning("\u26A0\uFE0F Dependency Issues"));if(o.stalePackages.length>0)P(o.stalePackages.map((i)=>`${p.dim("\u2022")} ${i.name} - ${i.daysSinceUpdate} days since last update`).join(`
144
- `),p.warning("\uD83D\uDC0C Stale Packages"));T(p.success("Analysis complete"))}async function Qr(e,t){let n={};for(let[i,r]of Object.entries(t.packages))try{let s=await Bun.file(r.file).json();n[i]={...r,packageJson:s}}catch(s){cn.warn(`Failed to load package.json for ${i}:`,s),n[i]={...r,packageJson:{dependencies:{},devDependencies:{}}}}let o=await Dr(e,n);if(P(`Current: ${p.value(o.version)}
145
- Path: ${p.dim(o.path)}
146
- Dependencies: ${p.value(String(o.dependencies))}
147
- Dependents: ${p.value(String(o.dependents))} internal${o.externalDependents?`, ${p.info(o.externalDependents)} external`:""}
148
- Last Modified: ${p.dim(o.lastModified||"Unknown")}
149
- Change Frequency: ${p.value(o.changeFrequency||"Low")}
150
- Breaking Changes: ${p.value(String(o.breakingChanges))} in last year`,p.bold(`\uD83D\uDCE6 ${e.name}`)),o.dependencyTree.length>0)P(Ds(o.dependencyTree),p.info("\uD83C\uDF33 Dependency Tree"));if(o.internalDependents.length>0)P(o.internalDependents.map((i)=>`${p.dim("\u2022")} ${i}`).join(`
151
- `),p.info("\uD83D\uDC65 Used By"));T(p.success("Analysis complete"))}async function Fr(e,t){let n=await ea(e),o=await ta(e),i=await na(),r=sa(e),s=oa(e,t);return{circularDeps:r.length,dependencyIssues:s,highImpactPackages:e.filter((a)=>a.dependencyOf?.length>5).length,mostChanged:n,releaseVelocity:i,stalePackages:o,totalPackages:e.length}}async function Dr(e,t){let n=await ia(e.file),o=await ra(e.file),i=await aa(e.name),r=Object.keys(e.packageJson?.dependencies||{}).length,s=Object.values(t).filter((c)=>c.dependencyOf?.includes(e.name)).map((c)=>c.name),a=Fs(e,t,3);return{breakingChanges:i,changeFrequency:o,dependencies:r,dependencyTree:a,dependents:s.length,externalDependents:await ca(e.name),internalDependents:s,lastModified:n,name:e.name,path:e.file,version:e.version||e.packageJson?.version||"0.0.0"}}async function ea(e){let t={commits:0,name:"None"};for(let n of e)try{let o=n.file.substring(0,n.file.lastIndexOf("/")),i=await we`cd ${o} && git rev-list --count HEAD -- .`.text(),r=Number.parseInt(i.trim(),10);if(r>t.commits)t={commits:r,name:n.name}}catch{}return t}async function ta(e,t=180){let n=[];for(let o of e)try{let i=o.file.substring(0,o.file.lastIndexOf("/")),r=await we`cd ${i} && git log -1 --format=%ct -- .`.text(),s=Number.parseInt(r.trim(),10),a=Math.floor((Date.now()/1000-s)/86400);if(a>t)n.push({daysSinceUpdate:a,name:o.name})}catch{}return n}async function na(){try{let t=(await we`git tag -l "v*" --sort=-creatordate | head -10`.text()).trim().split(`
152
- `).filter(Boolean);if(t.length<2)return"N/A";let n=[];for(let r of t.slice(0,5)){let s=await we`git log -1 --format=%ct ${r}`.text();n.push(Number.parseInt(s.trim(),10))}let o=0;for(let r=1;r<n.length;r++){let s=n[r-1],a=n[r];if(s&&a)o+=(s-a)/86400}let i=Math.round(o/(n.length-1));if(i<7)return`${i} days (rapid)`;if(i<14)return`${i} days (fast)`;if(i<30)return`${i} days (regular)`;return`${i} days (slow)`}catch{return"N/A"}}function sa(e){return[]}function oa(e,t){let n=[],o=new Map;for(let i of e){let r={...i.packageJson?.dependencies||{},...i.packageJson?.devDependencies||{}};for(let[s,a]of Object.entries(r)){if(!o.has(s))o.set(s,new Set);o.get(s)?.add(a)}}for(let[i,r]of o)if(r.size>1)n.push(`${i} has ${r.size} different versions across packages`);return n}async function ia(e){try{let t=e.substring(0,e.lastIndexOf("/")),n=await we`cd ${t} && git log -1 --format=%ct -- .`.text();return new Date(Number.parseInt(n.trim(),10)*1000).toLocaleDateString()}catch{return"Unknown"}}async function ra(e){try{let t=e.substring(0,e.lastIndexOf("/")),n=await we`cd ${t} && git rev-list --count HEAD --since="6 months ago" -- .`.text(),o=Number.parseInt(n.trim(),10);if(o>50)return"High";if(o>20)return"Medium";if(o>5)return"Low";return"Very Low"}catch{return"Unknown"}}async function aa(e){try{let t=await we`git log --grep="BREAKING" --grep="breaking change" -i --oneline -- "*${e}*" | wc -l`.text();return Number.parseInt(t.trim(),10)}catch{return 0}}async function ca(e){return""}function Fs(e,t,n,o=0){if(o>=n)return[];let i=[],r=Object.keys(e.packageJson?.dependencies||{});for(let s of r)if(t[s])i.push({children:Fs(t[s],t,n,o+1),name:s,version:t[s].version});return i}function Ds(e,t=""){let n="";for(let o=0;o<e.length;o++){let i=o===e.length-1,r=i?"\u2514\u2500":"\u251C\u2500",s=t+(i?" ":"\u2502 ");if(n+=`${t}${r} ${e[o].name}@${e[o].version}
153
- `,e[o].children?.length>0)n+=Ds(e[o].children,s)}return n.trimEnd()}M();E();I();B();import{parseArgs as la}from"util";var{$:pa}=globalThis.Bun;var eo=v({prefix:"sisyphus"}).child("metrics");function ma(){let{values:e}=la({args:process.argv.slice(3),options:{days:{short:"d",type:"string"},detailed:{short:"v",type:"boolean"},json:{short:"j",type:"boolean"},package:{short:"p",type:"string"}}});return{days:e.days?Number.parseInt(e.days,10):30,detailed:e.detailed,json:e.json,package:e.package}}async function to(){try{let e=ma(),{packages:t}=await G(),n=await ua(e.days||30),o=await fa(t,n,e.package);if(e.json){console.log(JSON.stringify({packageMetrics:o,releases:n},null,2));return}if(da(n,o,e),e.detailed)ha(o,e)}catch(e){eo.error("Failed to generate metrics:",e),process.exit(1)}}async function ua(e){let t=new Date;t.setDate(t.getDate()-e);try{let n=await pa`git log --tags --simplify-by-decoration --pretty="format:%ci %h %d" --since="${t.toISOString()}"`.text(),o=[],i=n.trim().split(`
154
- `).filter(Boolean);for(let r of i){let s=r.match(/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) ([a-f0-9]+) \(tag: ([^)]+)\)/);if(s){let[,a="",c="",l=""]=s,m=new Date(a),u=l.match(/@[^@]+@[\d.]+(-\w+\.\d+)?/g);if(u){let g={},w=[];for(let d of u){let[y,b]=d.split("@").filter(Boolean);if(y&&b)w.push(`@${y}`),g[`@${y}`]={from:"unknown",to:b}}o.push({commitHash:c,date:m,packages:w,tag:l,versions:g})}}}return o}catch{return eo.warn("Could not fetch git history, using empty release history"),[]}}async function fa(e,t,n){let o=new Map;for(let[i]of Object.entries(e)){if(n&&!i.includes(n))continue;o.set(i,{majorReleases:0,minorReleases:0,name:i,patchReleases:0,releaseFrequency:"Never",totalReleases:0,versionHistory:[]})}for(let i of t)for(let r of i.packages){let s=o.get(r);if(!s)continue;s.totalReleases++,s.lastRelease=i.date;let a=i.versions[r];if(a?.to){s.versionHistory.push({date:i.date,version:a.to});let c=a.to.match(/(\d+)\.(\d+)\.(\d+)/);if(c){let[,,l,m]=c;if(m!=="0")s.patchReleases++;else if(l!=="0")s.minorReleases++;else s.majorReleases++}}}for(let i of o.values())if(i.totalReleases>1&&i.versionHistory.length>1){let r=i.versionHistory[i.versionHistory.length-1]?.date?.getTime()||0,s=i.versionHistory[0]?.date?.getTime()||0,a=Math.floor((s-r)/86400000),c=Math.floor(a/(i.totalReleases-1));if(c===0)i.releaseFrequency="Daily";else if(c<=7)i.releaseFrequency=`Every ${c} days`;else if(c<=30)i.releaseFrequency=`Every ${Math.floor(c/7)} weeks`;else i.releaseFrequency=`Every ${Math.floor(c/30)} months`}else if(i.totalReleases===1)i.releaseFrequency="Single release";return Array.from(o.values()).sort((i,r)=>r.totalReleases-i.totalReleases)}function da(e,t,n){let o=e.length,i=t.filter((a)=>a.totalReleases>0).length,r=t.length;if($.info(`Release Metrics - Last ${n.days} days`),console.log(),console.log(p.bold("\uD83D\uDCCA Overview")),console.log(` Total releases: ${p.value(String(o))}`),console.log(` Active packages: ${p.value(`${i}/${r}`)}`),e.length>0){let[a]=e;console.log(` Last release: ${p.dim(ln(a?.date))}`)}console.log();let s=t.filter((a)=>a.totalReleases>0).slice(0,5);if(s.length>0){console.log(p.bold("\uD83C\uDFC6 Most Active Packages"));for(let a of s){let c="\u2588".repeat(Math.min(20,a.totalReleases)),l=a.lastRelease?` (${no(a.lastRelease)})`:"";console.log(` ${p.value(a.name.padEnd(25))} ${p.dim(c)} ${a.totalReleases} releases${p.dim(l)}`)}console.log()}if(e.length>0){console.log(p.bold("\uD83D\uDCC5 Recent Releases"));let a=e.slice(0,5);for(let c of a){let l=c.packages.slice(0,3).join(", "),m=c.packages.length>3?` +${c.packages.length-3} more`:"";console.log(` ${p.dim(ln(c.date))} - ${l}${p.dim(m)}`)}console.log()}}function ha(e,t){console.log(p.bold("\uD83D\uDCE6 Package Details")),console.log();for(let n of e){if(n.totalReleases===0)continue;if(console.log(`${p.bold(n.name)}`),console.log(` Releases: ${n.totalReleases} (${n.majorReleases} major, ${n.minorReleases} minor, ${n.patchReleases} patch)`),console.log(` Frequency: ${n.releaseFrequency}`),console.log(` Last release: ${n.lastRelease?ln(n.lastRelease):"Never"}`),n.versionHistory.length>0){console.log(" Recent versions:");let o=n.versionHistory.slice(0,3);for(let{version:i,date:r}of o)console.log(` ${p.value(i)} - ${p.dim(no(r))}`)}console.log()}}function ln(e){if(!e)return"Never";return e.toLocaleDateString("en-US",{day:"numeric",hour:"2-digit",minute:"2-digit",month:"short",year:"numeric"})}function no(e){let n=new Date().getTime()-e.getTime(),o=Math.floor(n/86400000);if(o===0)return"today";if(o===1)return"yesterday";if(o<7)return`${o} days ago`;if(o<30)return`${Math.floor(o/7)} weeks ago`;if(o<365)return`${Math.floor(o/30)} months ago`;return`${Math.floor(o/365)} years ago`}M();E();B();import{randomUUID as ga}from"crypto";import{join as $e,relative as ya}from"path";var{$:pn}=globalThis.Bun;var mn=v({prefix:"sisyphus:migrate"});async function so(){let e=mn.child("run");ee(`${p.command("sisyphus migrate")} - Migrate from changesets to stones`);let t=process.cwd(),n=$e(t,".changeset");if(!await Bun.file(n).exists())e.warn("No .changeset directory found"),T(p.error("No changesets found to migrate")),process.exit(1);let o=xe();o.start("Analyzing changesets...");try{let i=await ba(n);if(i.length===0){o.stop("No changesets found"),T(p.warning("No changesets to migrate"));return}o.stop(`Found ${p.value(String(i.length))} changeset(s)`);let r=[];for(let w of i){let d=await wa(w);if(d){r.push(d);let y=ya(t,w);P(`${p.dim("File:")} ${y}
155
- ${p.dim("Packages:")} ${Object.entries(d.packages).map(([b,x])=>`${b} (${x})`).join(", ")}
156
- ${p.dim("Summary:")} ${d.summary.slice(0,80)}${d.summary.length>80?"...":""}`,p.info("Changeset found"))}}if(r.length===0){T(p.warning("No valid changesets found to migrate"));return}if(!await A({initialValue:!0,message:`Migrate ${r.length} changeset(s) to stones?`})){T(p.dim("Migration cancelled"));return}o.start("Migrating changesets to stones...");let a=$e(t,".sisyphus"),c=$e(a,"stones");if(!await Bun.file(a).exists())await pn`mkdir -p ${c}`,await Bun.write($e(a,"config.json"),JSON.stringify({stones:[]},null,2));else if(!await Bun.file(c).exists())await pn`mkdir -p ${c}`;let m=(await D()).length,u=[];for(let w of r){m++;let d=`${String(m).padStart(4,"0")}-${ga().slice(0,8)}`,y=$a(w),b=$e(c,`${d}.md`);await Bun.write(b,y.content),u.push(d),e.info(`Created stone: ${d}`)}if(o.stop(`Created ${p.value(String(u.length))} stone(s)`),u.length>0){let w=$e(a,"config.json"),d=await Bun.file(w).json();d.stones=[...d.stones||[],...u],await Bun.write(w,JSON.stringify(d,null,2))}if(await A({initialValue:!0,message:"Remove .changeset directory?"}))o.start("Cleaning up changesets..."),await pn`rm -rf ${n}`,o.stop("Changesets cleaned up"),e.info("Removed .changeset directory");T(p.success("Migration completed successfully!"))}catch(i){o.stop("Migration failed"),e.error("Migration failed",i),T(p.error(`Migration failed: ${i}`)),process.exit(1)}}async function ba(e){let t=[];try{let n=await Array.fromAsync(new Bun.Glob("*.md").scan(e));for(let o of n)if(o!=="README.md")t.push($e(e,o))}catch(n){mn.error("Failed to scan changeset directory",n)}return t}async function wa(e){try{let n=(await Bun.file(e).text()).split(`
157
- `),o=!1,i=[],r=[];for(let c of n)if(c.trim()==="---")if(!o)o=!0;else o=!1;else if(o)i.push(c);else if(!o&&i.length>0)r.push(c);let s={};for(let c of i){let l=c.match(/^"(.+)":\s*(major|minor|patch)$/);if(l){if(l[1]&&l[2])s[l[1]]=l[2]}}let a=r.join(`
158
- `).trim();if(Object.keys(s).length===0)return null;return{packages:s,summary:a}}catch(t){return mn.error(`Failed to parse changeset: ${e}`,t),null}}function $a(e){let t=[],n=[],o=[];for(let[m,u]of Object.entries(e.packages)){let g=m.startsWith("@")?m:`@${m}`;switch(u){case"major":t.push(g);break;case"minor":n.push(g);break;case"patch":o.push(g);break}}let i=e.summary.split(`
159
- `)[0],s=`### ${i||"Migrated from changesets"}
160
-
161
- `;if(e.summary&&e.summary!==i){let m=e.summary.split(`
150
+ After you finished, you can release it by running ${h.reset(h.green("bunx @r5n/sisyphus"))}${h.blue(" roll")}
151
+ `)}U();M();H();import{parseArgs as Xa}from"util";var{$:xn}=globalThis.Bun;var Er=R({prefix:"sisyphus:insights"});async function Is(){let{values:n}=Xa({args:process.argv.slice(3),options:{"include-private":{type:"boolean"},json:{short:"j",type:"boolean"},package:{short:"p",type:"string"}}}),{package:o,"include-private":i=!1}=n;mn(`${l.command("sisyphus insights")} - Monorepo health report`);try{let s=await q({includePrivate:Boolean(i)}),t=Object.values(s.packages);if(o){let e=s.packages[o];if(!e)J(l.error(`Package ${o} not found`)),process.exit(1);let r=await Bun.file(e.file).json(),a={...e,packageJson:r};await Qa(a,s)}else await Za(t,s.packages)}catch(s){Er.error("Failed to generate insights",s),J(l.error(`Failed to generate insights: ${s}`)),process.exit(1)}}async function Za(n,o){let i=await Promise.all(n.map(async(t)=>{try{let e=await Bun.file(t.file).json();return{...t,packageJson:e}}catch(e){return Er.warn(`Failed to load package.json for ${t.name}:`,e),{...t,packageJson:{dependencies:{},devDependencies:{}}}}})),s=await Va(i,o);if(B(`\uD83D\uDCE6 Total Packages: ${l.value(String(s.totalPackages))}
152
+ `+`\uD83D\uDD04 Circular Dependencies: ${s.circularDeps>0?l.error(String(s.circularDeps)):l.success("0")}
153
+ `+`\uD83D\uDCC8 Most Changed: ${l.value(s.mostChanged.name)} (${s.mostChanged.commits} commits)
154
+ `+`\uD83D\uDC0C Stale Packages: ${s.stalePackages.length>0?l.warning(String(s.stalePackages.length)):l.success("0")}
155
+ `+`\uD83C\uDFAF High Impact Changes: ${l.value(String(s.highImpactPackages))}
156
+ `+`\uD83D\uDE80 Release Velocity: ${l.value(s.releaseVelocity)}`,l.bold("\uD83D\uDCCA Monorepo Health Report")),s.dependencyIssues.length>0)B(s.dependencyIssues.map((t)=>`${l.dim("\u2022")} ${t}`).join(`
157
+ `),l.warning("\u26A0\uFE0F Dependency Issues"));if(s.stalePackages.length>0)B(s.stalePackages.map((t)=>`${l.dim("\u2022")} ${t.name} - ${t.daysSinceUpdate} days since last update`).join(`
158
+ `),l.warning("\uD83D\uDC0C Stale Packages"));J(l.success("Analysis complete"))}async function Qa(n,o){let i={};for(let[t,e]of Object.entries(o.packages))try{let r=await Bun.file(e.file).json();i[t]={...e,packageJson:r}}catch(r){Er.warn(`Failed to load package.json for ${t}:`,r),i[t]={...e,packageJson:{dependencies:{},devDependencies:{}}}}let s=await Fa(n,i);if(B(`Current: ${l.value(s.version)}
159
+ Path: ${l.dim(s.path)}
160
+ Dependencies: ${l.value(String(s.dependencies))}
161
+ Dependents: ${l.value(String(s.dependents))} internal${s.externalDependents?`, ${l.info(s.externalDependents)} external`:""}
162
+ Last Modified: ${l.dim(s.lastModified||"Unknown")}
163
+ Change Frequency: ${l.value(s.changeFrequency||"Low")}
164
+ Breaking Changes: ${l.value(String(s.breakingChanges))} in last year`,l.bold(`\uD83D\uDCE6 ${n.name}`)),s.dependencyTree.length>0)B(Os(s.dependencyTree),l.info("\uD83C\uDF33 Dependency Tree"));if(s.internalDependents.length>0)B(s.internalDependents.map((t)=>`${l.dim("\u2022")} ${t}`).join(`
165
+ `),l.info("\uD83D\uDC65 Used By"));J(l.success("Analysis complete"))}async function Va(n,o){let i=await Da(n),s=await nc(n),t=await oc(),e=rc(n),r=ic(n,o);return{circularDeps:e.length,dependencyIssues:r,highImpactPackages:n.filter((a)=>a.dependencyOf?.length>5).length,mostChanged:i,releaseVelocity:t,stalePackages:s,totalPackages:n.length}}async function Fa(n,o){let i=await sc(n.file),s=await tc(n.file),t=await ec(n.name),e=Object.keys(n.packageJson?.dependencies||{}).length,r=Object.values(o).filter((c)=>c.dependencyOf?.includes(n.name)).map((c)=>c.name),a=Ps(n,o,3);return{breakingChanges:t,changeFrequency:s,dependencies:e,dependencyTree:a,dependents:r.length,externalDependents:await ac(n.name),internalDependents:r,lastModified:i,name:n.name,path:n.file,version:n.version||n.packageJson?.version||"0.0.0"}}async function Da(n){let o={commits:0,name:"None"};for(let i of n)try{let s=i.file.substring(0,i.file.lastIndexOf("/")),t=await xn`cd ${s} && git rev-list --count HEAD -- .`.text(),e=Number.parseInt(t.trim(),10);if(e>o.commits)o={commits:e,name:i.name}}catch{}return o}async function nc(n,o=180){let i=[];for(let s of n)try{let t=s.file.substring(0,s.file.lastIndexOf("/")),e=await xn`cd ${t} && git log -1 --format=%ct -- .`.text(),r=Number.parseInt(e.trim(),10),a=Math.floor((Date.now()/1000-r)/86400);if(a>o)i.push({daysSinceUpdate:a,name:s.name})}catch{}return i}async function oc(){try{let o=(await xn`git tag -l "v*" --sort=-creatordate | head -10`.text()).trim().split(`
166
+ `).filter(Boolean);if(o.length<2)return"N/A";let i=[];for(let e of o.slice(0,5)){let r=await xn`git log -1 --format=%ct ${e}`.text();i.push(Number.parseInt(r.trim(),10))}let s=0;for(let e=1;e<i.length;e++){let r=i[e-1],a=i[e];if(r&&a)s+=(r-a)/86400}let t=Math.round(s/(i.length-1));if(t<7)return`${t} days (rapid)`;if(t<14)return`${t} days (fast)`;if(t<30)return`${t} days (regular)`;return`${t} days (slow)`}catch{return"N/A"}}function rc(n){return[]}function ic(n,o){let i=[],s=new Map;for(let t of n){let e={...t.packageJson?.dependencies||{},...t.packageJson?.devDependencies||{}};for(let[r,a]of Object.entries(e)){if(!s.has(r))s.set(r,new Set);s.get(r)?.add(a)}}for(let[t,e]of s)if(e.size>1)i.push(`${t} has ${e.size} different versions across packages`);return i}async function sc(n){try{let o=n.substring(0,n.lastIndexOf("/")),i=await xn`cd ${o} && git log -1 --format=%ct -- .`.text();return new Date(Number.parseInt(i.trim(),10)*1000).toLocaleDateString()}catch{return"Unknown"}}async function tc(n){try{let o=n.substring(0,n.lastIndexOf("/")),i=await xn`cd ${o} && git rev-list --count HEAD --since="6 months ago" -- .`.text(),s=Number.parseInt(i.trim(),10);if(s>50)return"High";if(s>20)return"Medium";if(s>5)return"Low";return"Very Low"}catch{return"Unknown"}}async function ec(n){try{let o=await xn`git log --grep="BREAKING" --grep="breaking change" -i --oneline -- "*${n}*" | wc -l`.text();return Number.parseInt(o.trim(),10)}catch{return 0}}async function ac(n){return""}function Ps(n,o,i,s=0){if(s>=i)return[];let t=[],e=Object.keys(n.packageJson?.dependencies||{});for(let r of e)if(o[r])t.push({children:Ps(o[r],o,i,s+1),name:r,version:o[r].version});return t}function Os(n,o=""){let i="";for(let s=0;s<n.length;s++){let t=s===n.length-1,e=t?"\u2514\u2500":"\u251C\u2500",r=o+(t?" ":"\u2502 ");if(i+=`${o}${e} ${n[s].name}@${n[s].version}
167
+ `,n[s].children?.length>0)i+=Os(n[s].children,r)}return i.trimEnd()}U();M();_();H();import{parseArgs as cc}from"util";var{$:pc}=globalThis.Bun;var _s=R({prefix:"sisyphus"}).child("metrics");function lc(){let{values:n}=cc({args:process.argv.slice(3),options:{days:{short:"d",type:"string"},detailed:{short:"v",type:"boolean"},json:{short:"j",type:"boolean"},package:{short:"p",type:"string"}}});return{days:n.days?Number.parseInt(n.days,10):30,detailed:n.detailed,json:n.json,package:n.package}}async function Cs(){try{let n=lc(),{packages:o}=await q(),i=await fc(n.days||30),s=await mc(o,i,n.package);if(n.json){console.log(JSON.stringify({packageMetrics:s,releases:i},null,2));return}if(uc(i,s,n),n.detailed)gc(s,n)}catch(n){_s.error("Failed to generate metrics:",n),process.exit(1)}}async function fc(n){let o=new Date;o.setDate(o.getDate()-n);try{let i=await pc`git log --tags --simplify-by-decoration --pretty="format:%ci %h %d" --since="${o.toISOString()}"`.text(),s=[],t=i.trim().split(`
168
+ `).filter(Boolean);for(let e of t){let r=e.match(/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) ([a-f0-9]+) \(tag: ([^)]+)\)/);if(r){let[,a="",c="",p=""]=r,f=new Date(a),m=p.match(/@[^@]+@[\d.]+(-\w+\.\d+)?/g);if(m){let d={},w=[];for(let u of m){let[g,y]=u.split("@").filter(Boolean);if(g&&y)w.push(`@${g}`),d[`@${g}`]={from:"unknown",to:y}}s.push({commitHash:c,date:f,packages:w,tag:p,versions:d})}}}return s}catch{return _s.warn("Could not fetch git history, using empty release history"),[]}}async function mc(n,o,i){let s=new Map;for(let[t]of Object.entries(n)){if(i&&!t.includes(i))continue;s.set(t,{majorReleases:0,minorReleases:0,name:t,patchReleases:0,releaseFrequency:"Never",totalReleases:0,versionHistory:[]})}for(let t of o)for(let e of t.packages){let r=s.get(e);if(!r)continue;r.totalReleases++,r.lastRelease=t.date;let a=t.versions[e];if(a?.to){r.versionHistory.push({date:t.date,version:a.to});let c=a.to.match(/(\d+)\.(\d+)\.(\d+)/);if(c){let[,,p,f]=c;if(f!=="0")r.patchReleases++;else if(p!=="0")r.minorReleases++;else r.majorReleases++}}}for(let t of s.values())if(t.totalReleases>1&&t.versionHistory.length>1){let e=t.versionHistory[t.versionHistory.length-1]?.date?.getTime()||0,r=t.versionHistory[0]?.date?.getTime()||0,a=Math.floor((r-e)/86400000),c=Math.floor(a/(t.totalReleases-1));if(c===0)t.releaseFrequency="Daily";else if(c<=7)t.releaseFrequency=`Every ${c} days`;else if(c<=30)t.releaseFrequency=`Every ${Math.floor(c/7)} weeks`;else t.releaseFrequency=`Every ${Math.floor(c/30)} months`}else if(t.totalReleases===1)t.releaseFrequency="Single release";return Array.from(s.values()).sort((t,e)=>e.totalReleases-t.totalReleases)}function uc(n,o,i){let s=n.length,t=o.filter((a)=>a.totalReleases>0).length,e=o.length;if($.info(`Release Metrics - Last ${i.days} days`),console.log(),console.log(l.bold("\uD83D\uDCCA Overview")),console.log(` Total releases: ${l.value(String(s))}`),console.log(` Active packages: ${l.value(`${t}/${e}`)}`),n.length>0){let[a]=n;console.log(` Last release: ${l.dim(Ir(a?.date))}`)}console.log();let r=o.filter((a)=>a.totalReleases>0).slice(0,5);if(r.length>0){console.log(l.bold("\uD83C\uDFC6 Most Active Packages"));for(let a of r){let c="\u2588".repeat(Math.min(20,a.totalReleases)),p=a.lastRelease?` (${Ts(a.lastRelease)})`:"";console.log(` ${l.value(a.name.padEnd(25))} ${l.dim(c)} ${a.totalReleases} releases${l.dim(p)}`)}console.log()}if(n.length>0){console.log(l.bold("\uD83D\uDCC5 Recent Releases"));let a=n.slice(0,5);for(let c of a){let p=c.packages.slice(0,3).join(", "),f=c.packages.length>3?` +${c.packages.length-3} more`:"";console.log(` ${l.dim(Ir(c.date))} - ${p}${l.dim(f)}`)}console.log()}}function gc(n,o){console.log(l.bold("\uD83D\uDCE6 Package Details")),console.log();for(let i of n){if(i.totalReleases===0)continue;if(console.log(`${l.bold(i.name)}`),console.log(` Releases: ${i.totalReleases} (${i.majorReleases} major, ${i.minorReleases} minor, ${i.patchReleases} patch)`),console.log(` Frequency: ${i.releaseFrequency}`),console.log(` Last release: ${i.lastRelease?Ir(i.lastRelease):"Never"}`),i.versionHistory.length>0){console.log(" Recent versions:");let s=i.versionHistory.slice(0,3);for(let{version:t,date:e}of s)console.log(` ${l.value(t)} - ${l.dim(Ts(e))}`)}console.log()}}function Ir(n){if(!n)return"Never";return n.toLocaleDateString("en-US",{day:"numeric",hour:"2-digit",minute:"2-digit",month:"short",year:"numeric"})}function Ts(n){let i=new Date().getTime()-n.getTime(),s=Math.floor(i/86400000);if(s===0)return"today";if(s===1)return"yesterday";if(s<7)return`${s} days ago`;if(s<30)return`${Math.floor(s/7)} weeks ago`;if(s<365)return`${Math.floor(s/30)} months ago`;return`${Math.floor(s/365)} years ago`}U();M();H();import{randomUUID as hc}from"crypto";import{join as Sn,relative as dc}from"path";var{$:Pr}=globalThis.Bun;var Or=R({prefix:"sisyphus:migrate"});async function Bs(){let n=Or.child("run");mn(`${l.command("sisyphus migrate")} - Migrate from changesets to stones`);let o=process.cwd(),i=Sn(o,".changeset");if(!await Bun.file(i).exists())n.warn("No .changeset directory found"),J(l.error("No changesets found to migrate")),process.exit(1);let s=Pn();s.start("Analyzing changesets...");try{let t=await yc(i);if(t.length===0){s.stop("No changesets found"),J(l.warning("No changesets to migrate"));return}s.stop(`Found ${l.value(String(t.length))} changeset(s)`);let e=[];for(let w of t){let u=await bc(w);if(u){e.push(u);let g=dc(o,w);B(`${l.dim("File:")} ${g}
169
+ ${l.dim("Packages:")} ${Object.entries(u.packages).map(([y,x])=>`${y} (${x})`).join(", ")}
170
+ ${l.dim("Summary:")} ${u.summary.slice(0,80)}${u.summary.length>80?"...":""}`,l.info("Changeset found"))}}if(e.length===0){J(l.warning("No valid changesets found to migrate"));return}if(!await N({initialValue:!0,message:`Migrate ${e.length} changeset(s) to stones?`})){J(l.dim("Migration cancelled"));return}s.start("Migrating changesets to stones...");let a=Sn(o,".sisyphus"),c=Sn(a,"stones");if(!await Bun.file(a).exists())await Pr`mkdir -p ${c}`,await Bun.write(Sn(a,"config.json"),JSON.stringify({stones:[]},null,2));else if(!await Bun.file(c).exists())await Pr`mkdir -p ${c}`;let f=(await on()).length,m=[];for(let w of e){f++;let u=`${String(f).padStart(4,"0")}-${hc().slice(0,8)}`,g=wc(w),y=Sn(c,`${u}.md`);await Bun.write(y,g.content),m.push(u),n.info(`Created stone: ${u}`)}if(s.stop(`Created ${l.value(String(m.length))} stone(s)`),m.length>0){let w=Sn(a,"config.json"),u=await Bun.file(w).json();u.stones=[...u.stones||[],...m],await Bun.write(w,JSON.stringify(u,null,2))}if(await N({initialValue:!0,message:"Remove .changeset directory?"}))s.start("Cleaning up changesets..."),await Pr`rm -rf ${i}`,s.stop("Changesets cleaned up"),n.info("Removed .changeset directory");J(l.success("Migration completed successfully!"))}catch(t){s.stop("Migration failed"),n.error("Migration failed",t),J(l.error(`Migration failed: ${t}`)),process.exit(1)}}async function yc(n){let o=[];try{let i=await Array.fromAsync(new Bun.Glob("*.md").scan(n));for(let s of i)if(s!=="README.md")o.push(Sn(n,s))}catch(i){Or.error("Failed to scan changeset directory",i)}return o}async function bc(n){try{let i=(await Bun.file(n).text()).split(`
171
+ `),s=!1,t=[],e=[];for(let c of i)if(c.trim()==="---")if(!s)s=!0;else s=!1;else if(s)t.push(c);else if(!s&&t.length>0)e.push(c);let r={};for(let c of t){let p=c.match(/^"(.+)":\s*(major|minor|patch)$/);if(p){if(p[1]&&p[2])r[p[1]]=p[2]}}let a=e.join(`
172
+ `).trim();if(Object.keys(r).length===0)return null;return{packages:r,summary:a}}catch(o){return Or.error(`Failed to parse changeset: ${n}`,o),null}}function wc(n){let o=[],i=[],s=[];for(let[f,m]of Object.entries(n.packages)){let d=f.startsWith("@")?f:`@${f}`;switch(m){case"major":o.push(d);break;case"minor":i.push(d);break;case"patch":s.push(d);break}}let t=n.summary.split(`
173
+ `)[0],r=`### ${t||"Migrated from changesets"}
174
+
175
+ `;if(n.summary&&n.summary!==t){let f=n.summary.split(`
162
176
  `).slice(1).join(`
163
- `).trim();if(m)s+=`${m}
164
-
165
- `}s+=`***
166
-
167
- `;let a=[],c=[],l=[];if(t.length>0)a.push("major"),c.push(t.join(", ")),l.push(":---:");if(n.length>0)a.push("minor"),c.push(n.join(", ")),l.push(":---:");if(o.length>0)a.push("patch"),c.push(o.join(", ")),l.push(":---:");return s+=`| ${a.join(" | ")} |
168
- `,s+=`| ${l.join(" | ")} |
169
- `,s+=`| ${c.join(" | ")} |
170
- `,{content:s}}M();E();I();B();import{parseArgs as Sa}from"util";B();Re();import{randomUUID as va}from"crypto";var xa=["major","minor","patch","dependency","snapshot"];function Ca({message:e,tag:t,packages:n}){let o=n.reduce((r,s)=>{return r[s.bump]=r[s.bump]||[],r[s.bump].push(s.name),r},{}),i=xa.filter((r)=>o[r]?.length>0);return[`### ${e}`,t?`_${t}_`:"",tn,"",`| ${i.join(" | ")} |`,`| ${i.map(()=>":---:").join(" | ")} |`,`| ${i.map((r)=>o[r]?.join(", ")||"").join(" | ")} |`,""]}function ve(e){let t=e.split(`
171
- `).filter((r)=>r.trim()),n={commitMessage:"",dependency:[],description:"",major:[],minor:[],patch:[],snapshot:[],tag:""},o=t.findIndex((r)=>r.includes("---"));if(t[0]?.startsWith("###"))n.commitMessage=t[0].replace(/^#+\s*/,"");if(o>1){let r=[];for(let s=1;s<o;s++){let a=t[s];if(a?.startsWith("_")&&a.endsWith("_"))n.tag=a.slice(1,-1);else if(a)r.push(a)}n.description=r.join(`
172
- `).trim()}let i=t.findIndex((r)=>r.includes("|")&&!r.includes("---"));if(i!==-1&&t[i]){let s=t[i].split("|").map((c)=>c.trim()).filter((c)=>c),a=t[i+2];if(a){let c=a.split("|").map((l)=>l.trim()).filter((l)=>l);s.forEach((l,m)=>{let u=c[m]?.split(",").map((w)=>w.trim()).filter((w)=>w)||[],g=l.toLowerCase();if(g==="major")n.major=u;else if(g==="minor")n.minor=u;else if(g==="patch")n.patch=u;else if(g==="dependency")n.dependency=u;else if(g==="snapshot")n.snapshot=u})}}return n}async function pe({majorPackages:e,message:t,minorPackages:n,packages:o,patchPackages:i,tag:r,configPath:s}){let c=`${`${(await D({configPath:s})).length+1}`.padStart(4,"0")}-${va().slice(0,8)}`,l=[...e,...n,...i],m=l.flatMap((d)=>o[d]?.dependencyOf||[]),g=[{packages:e,type:"major"},{packages:n,type:"minor"},{packages:i,type:"patch"},{packages:m.filter((d)=>!l.includes(d)),type:"dependency"}].flatMap(({packages:d,type:y})=>d.map((b)=>{let x=o[b];if(!x)throw new Error(`Package ${b} not found`);return{...x,bump:y,tag:r}})).filter(Boolean),w=Ca({message:t,packages:g,tag:r});return{packages:g,stoneContent:w,stoneName:c}}var Te=v({prefix:"sisyphus"}).child("pr"),ka=/github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)/,Ra=/gitlab\.com\/(.+)\/-\/merge_requests\/(\d+)/,ja={"breaking-change":"major",bug:"patch",chore:"patch",documentation:"patch",enhancement:"minor",feature:"minor",fix:"patch"};function Ia(){let{values:e}=Sa({args:process.argv.slice(3),options:{dryRun:{short:"d",type:"boolean"},github:{type:"boolean"},gitlab:{type:"boolean"},url:{short:"u",type:"string"},yes:{short:"y",type:"boolean"}}});return e}async function oo(){try{let e=Ia(),{packages:t,packageNames:n}=await G(),o;if(e.url)o=await _a(e.url);else o=await Ea(e);if(!o){$.error("Could not determine PR information. Please provide a PR URL with --url");return}if($.info(`Processing PR #${o.number}: ${o.title}`),console.log(),console.log(` Author: ${p.value(o.author)}`),console.log(` Branch: ${p.value(o.branch)}`),o.labels.length>0)console.log(` Labels: ${o.labels.map((y)=>p.dim(y)).join(", ")}`);console.log();let i;for(let y of o.labels){let b=y.toLowerCase();for(let[x,k]of Object.entries(ja))if(b.includes(x)){if(i=k,k==="major")break}if(i==="major")break}if(!i){let y=o.title.toLowerCase();if(y.includes("breaking")||y.includes("!:"))i="major";else if(y.includes("feat")||y.includes("feature"))i="minor";else if(y.includes("fix")||y.includes("bug"))i="patch"}if(!i&&!e.yes){let y=await L({message:"Could not determine bump type from PR. What type of change is this? (major/minor/patch)",placeholder:"patch"});if(!y||!["major","minor","patch"].includes(y)){$.info("Invalid bump type. Cancelled.");return}i=y}else if(!i)i="patch";$.info(`Detected bump type: ${p.bold(i)}`);let r=await Ba(o.branch),s=await Ma(r,t,n);if(s.length===0){$.warn("No packages affected by this PR");return}console.log(),console.log(p.bold("Affected packages:"));for(let y of s){let b=t[y];if(!b)continue;let x=b.version,k=Oa(x,i);console.log(` ${p.value(y)}: ${x} \u2192 ${p.success(k)}`)}console.log();let a=`${o.title} (#${o.number})`,c;if(!e.yes){let y=await L({initialValue:a,message:"Commit message for this stone",placeholder:a});if(!y){$.info("Cancelled");return}c=y}else c=a;let l=i==="major"?s:[],m=i==="minor"?s:[],u=i==="patch"?s:[],{stoneContent:g,stoneName:w}=await pe({majorPackages:l,message:c,minorPackages:m,packages:t,patchPackages:u,tag:void 0});if(e.dryRun){$.info("Dry run - no changes made"),console.log(p.dim("Stone content:")),console.log(g.join(`
173
- `));return}if(!e.yes){if(!await A({initialValue:!0,message:"Create stone from this PR?"})){$.info("Cancelled");return}}let d=await j();d.stones.push(w),await Bun.write(`.sisyphus/stones/${w}.md`,g.join(`
174
- `)),await Bun.write(".sisyphus/config.json",`${JSON.stringify(d,null,2)}
175
- `),$.success(`Created stone from PR: ${p.bold(w)}`),$.info(`Review the stone with ${p.value(`sisyphus stone show ${w}`)}`)}catch(e){Te.error("Failed to process PR:",e),process.exit(1)}}async function _a(e){let t=e.match(ka);if(t){let[,o="",i="",r=""]=t;return await Pa(o,i,r)}let n=e.match(Ra);if(n){let[,o="",i=""]=n;return await Aa(o,i)}throw new Error("Unsupported PR URL format")}async function Ea(e){try{if((await Bun.$`git remote get-url origin`.text()).includes("github.com")||e.github)try{let n=await Bun.$`gh pr view --json number,title,body,labels,author,headRefName`.json();return{author:n.author?.login||"unknown",branch:n.headRefName,description:n.body||"",labels:n.labels?.map((o)=>o.name)||[],number:String(n.number),title:n.title}}catch{Te.debug("GitHub CLI not available or no PR found")}return null}catch(t){return Te.debug("Could not detect current PR:",t),null}}async function Pa(e,t,n){try{let o=await Bun.$`gh api repos/${e}/${t}/pulls/${n}`.json();return{author:o.user?.login||"unknown",branch:o.head.ref,description:o.body||"",labels:o.labels?.map((i)=>i.name)||[],number:String(o.number),title:o.title}}catch(o){throw new Error(`Failed to fetch GitHub PR: ${o}`)}}async function Aa(e,t){throw new Error("GitLab integration requires API token configuration")}async function Ba(e){try{let n=(await Bun.$`git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'`.text()).trim()||"main";return(e?await Bun.$`git diff --name-only ${n}...${e}`.text():await Bun.$`git diff --name-only ${n}...HEAD`.text()).trim().split(`
176
- `).filter(Boolean)}catch(t){return Te.warn("Could not get changed files, using current uncommitted changes"),(await Bun.$`git status --porcelain`.text()).trim().split(`
177
- `).map((o)=>o.substring(3)).filter(Boolean)}}async function Ma(e,t,n){let o=new Set,i=new Map;for(let[r,s]of Object.entries(t))if(s.relativePath)i.set(s.relativePath,r);for(let r of e)for(let[s,a]of i)if(r.startsWith(`${s}/`))o.add(a);if(o.size===0&&e.length>0){if(e.filter((s)=>!s.includes("/")||s.startsWith(".")).length>0)return Te.info("Root files changed, considering all packages affected"),n}return Array.from(o)}function Oa(e,t){let n=e.split("."),o=Number.parseInt(n[0]||"0",10),i=Number.parseInt(n[1]||"0",10),r=Number.parseInt(n[2]||"0",10);switch(t){case"major":return`${o+1}.0.0`;case"minor":return`${o}.${i+1}.0`;case"patch":return`${o}.${i}.${r+1}`;default:return e}}M();E();I();B();Re();import{parseArgs as Ga}from"util";var Ha=v({prefix:"sisyphus"}).child("prerelease"),Ta=["alpha","beta","rc","canary","dev","next"];function qa(){let{values:e}=Ga({args:process.argv.slice(3),options:{bump:{short:"b",type:"string"},dryRun:{short:"d",type:"boolean"},filter:{short:"f",type:"string"},promote:{short:"p",type:"boolean"},type:{short:"t",type:"string"},yes:{short:"y",type:"boolean"}}});return e}async function io(){try{let e=qa(),{packages:t,packageNames:n}=await G({filter:e.filter});if(e.promote)await Na(e,t,n);else await La(e,t,n)}catch(e){Ha.error("Prerelease operation failed:",e),process.exit(1)}}async function La(e,t,n){let o=e.type||await V({message:"Select prerelease type",options:Ta.map((b)=>({hint:Ua(b),label:b,value:b}))});if(!o||typeof o!=="string"){$.info("Cancelled");return}let i=e.filter,r=i?n.filter((b)=>b.includes(i)):n;if(r.length===0){$.error(`No packages found matching filter: ${e.filter}`);return}let s=e.filter?r:await Wa(r,t);if(s.length===0){$.info("No packages selected");return}let a;if(e.bump){let x={major:"major",minor:"minor",patch:"patch"}[e.bump.toLowerCase()];if(!x){$.error(`Invalid bump type: ${e.bump}. Must be major, minor, or patch.`);return}a=x}else{let b=await V({message:"What type of change is this prerelease for?",options:[{label:"Major - Breaking changes",value:"major"},{label:"Minor - New features",value:"minor"},{label:"Patch - Bug fixes",value:"patch"}]});if(!b){$.info("Cancelled");return}a=b}let c=`chore: prepare ${o} release`,l;if(e.yes)l=c;else{let b=await L({message:"Commit message for this prerelease",placeholder:c});if(!b||typeof b!=="string"){$.info("Cancelled");return}l=b}let m=[],u=[],g=[];for(let b of s)switch(a){case"major":m.push(b);break;case"minor":u.push(b);break;case"patch":g.push(b);break}let{stoneContent:w,stoneName:d}=await pe({majorPackages:m,message:l,minorPackages:u,packages:t,patchPackages:g,tag:o});$.step("Preview of prerelease changes:"),console.log();for(let b of s){let x=t[b],k=z({bump:a,tag:o,version:x.version});console.log(` ${p.value(b)}: ${x.version} \u2192 ${p.bold(k)}`)}if(console.log(),e.dryRun){$.info("Dry run - no changes made"),console.log(p.dim("Stone content:")),console.log(w.join(`
178
- `));return}if(!e.yes){if(!await A({initialValue:!0,message:"Create this prerelease stone?"})){$.info("Cancelled");return}}let y=await j();y.stones.push(d),await Bun.write(`.sisyphus/stones/${d}.md`,w.join(`
179
- `)),await Bun.write(".sisyphus/config.json",`${JSON.stringify(y,null,2)}
180
- `),$.success(`Created ${o} prerelease stone: ${p.bold(d)}`),$.info(`Run ${p.value("sisyphus roll")} to publish the prerelease`)}async function Na(e,t,n){let o=n.filter((d)=>{return t[d].version.includes("-")});if(o.length===0){$.info("No packages with prerelease versions found");return}$.info(`Found ${p.bold(String(o.length))} packages with prerelease versions`),console.log();let i=new Map;for(let d of o){let b=t[d].version.match(/-(\w+)\./);if(b){let x=b[1];if(!i.has(x))i.set(x,[]);i.get(x)?.push(d)}}for(let[d,y]of i){console.log(`${p.bold(d)} packages:`);for(let b of y)console.log(` ${p.value(b)}: ${t[b].version}`);console.log()}let r=Array.from(i.keys()),s=[];if(r.includes("alpha"))s.push({label:"Promote alpha \u2192 beta",value:"alpha-to-beta"},{label:"Promote alpha \u2192 rc",value:"alpha-to-rc"},{label:"Promote alpha \u2192 stable",value:"alpha-to-stable"});if(r.includes("beta"))s.push({label:"Promote beta \u2192 rc",value:"beta-to-rc"},{label:"Promote beta \u2192 stable",value:"beta-to-stable"});if(r.includes("rc")||r.includes("next"))s.push({label:"Graduate to stable release",value:"to-stable"});s.push({label:"Increment current prerelease version",value:"increment"});let a=await V({message:"How would you like to promote these prereleases?",options:s});if(!a){$.info("Cancelled");return}let c,l=o,m;switch(a){case"alpha-to-beta":c="beta",l=i.get("alpha")||[],m="chore: promote alpha to beta";break;case"alpha-to-rc":c="rc",l=i.get("alpha")||[],m="chore: promote alpha to rc";break;case"alpha-to-stable":c=void 0,l=i.get("alpha")||[],m="chore: promote alpha to stable release";break;case"beta-to-rc":c="rc",l=i.get("beta")||[],m="chore: promote beta to rc";break;case"beta-to-stable":c=void 0,l=i.get("beta")||[],m="chore: promote beta to stable release";break;case"to-stable":c=void 0,l=[...i.get("rc")||[],...i.get("next")||[]],m="chore: graduate to stable release";break;case"increment":if(r.length>1){let d=await V({message:"Which prerelease type would you like to increment?",options:r.map((y)=>({label:y,value:y}))});if(!d){$.info("Cancelled");return}c=d,l=i.get(c)||[]}else c=r[0],l=c?i.get(c)||[]:[];m=`chore: increment ${c} version`;break;default:$.error("Unknown promotion strategy");return}if(l.length===0){$.info("No packages to promote");return}$.step("Preview of promotion:"),console.log();for(let d of l){let y=t[d].version,b;if(c===void 0)b=y.split("-")[0];else if(a==="increment")b=z({bump:"patch",tag:c,version:y});else b=`${y.split("-")[0]}-${c}.0`;console.log(` ${p.value(d)}: ${y} \u2192 ${p.bold(b)}`)}if(console.log(),!e.yes){if(!await A({initialValue:!0,message:"Continue with this promotion?"})){$.info("Cancelled");return}}let{stoneContent:u,stoneName:g}=await pe({majorPackages:[],message:m,minorPackages:[],packages:t,patchPackages:l,tag:c});if(e.dryRun){$.info("Dry run - no changes made"),console.log(u.join(`
181
- `));return}let w=await j();w.stones.push(g),await Bun.write(`.sisyphus/stones/${g}.md`,u.join(`
177
+ `).trim();if(f)r+=`${f}
178
+
179
+ `}r+=`***
180
+
181
+ `;let a=[],c=[],p=[];if(o.length>0)a.push("major"),c.push(o.join(", ")),p.push(":---:");if(i.length>0)a.push("minor"),c.push(i.join(", ")),p.push(":---:");if(s.length>0)a.push("patch"),c.push(s.join(", ")),p.push(":---:");return r+=`| ${a.join(" | ")} |
182
+ `,r+=`| ${p.join(" | ")} |
183
+ `,r+=`| ${c.join(" | ")} |
184
+ `,{content:r}}U();M();_();H();import{parseArgs as vc}from"util";H();_n();import{randomUUID as $c}from"crypto";var xc=["major","minor","patch","dependency","snapshot"];function Sc({message:n,tag:o,packages:i}){let s=i.reduce((e,r)=>{return e[r.bump]=e[r.bump]||[],e[r.bump].push(r.name),e},{}),t=xc.filter((e)=>s[e]?.length>0);return[`### ${n}`,o?`_${o}_`:"",$r,"",`| ${t.join(" | ")} |`,`| ${t.map(()=>":---:").join(" | ")} |`,`| ${t.map((e)=>s[e]?.join(", ")||"").join(" | ")} |`,""]}function vn(n){let o=n.split(`
185
+ `).filter((e)=>e.trim()),i={commitMessage:"",dependency:[],description:"",major:[],minor:[],patch:[],snapshot:[],tag:""},s=o.findIndex((e)=>e.includes("---"));if(o[0]?.startsWith("###"))i.commitMessage=o[0].replace(/^#+\s*/,"");if(s>1){let e=[];for(let r=1;r<s;r++){let a=o[r];if(a?.startsWith("_")&&a.endsWith("_"))i.tag=a.slice(1,-1);else if(a)e.push(a)}i.description=e.join(`
186
+ `).trim()}let t=o.findIndex((e)=>e.includes("|")&&!e.includes("---"));if(t!==-1&&o[t]){let r=o[t].split("|").map((c)=>c.trim()).filter((c)=>c),a=o[t+2];if(a){let c=a.split("|").map((p)=>p.trim()).filter((p)=>p);r.forEach((p,f)=>{let m=c[f]?.split(",").map((w)=>w.trim()).filter((w)=>w)||[],d=p.toLowerCase();if(d==="major")i.major=m;else if(d==="minor")i.minor=m;else if(d==="patch")i.patch=m;else if(d==="dependency")i.dependency=m;else if(d==="snapshot")i.snapshot=m})}}return i}async function hn({majorPackages:n,message:o,minorPackages:i,packages:s,patchPackages:t,tag:e,configPath:r}){let c=`${`${(await on({configPath:r})).length+1}`.padStart(4,"0")}-${$c().slice(0,8)}`,p=[...n,...i,...t],f=p.flatMap((u)=>s[u]?.dependencyOf||[]),d=[{packages:n,type:"major"},{packages:i,type:"minor"},{packages:t,type:"patch"},{packages:f.filter((u)=>!p.includes(u)),type:"dependency"}].flatMap(({packages:u,type:g})=>u.map((y)=>{let x=s[y];if(!x)throw Error(`Package ${y} not found`);return{...x,bump:g,tag:e}})).filter(Boolean),w=Sc({message:o,packages:d,tag:e});return{packages:d,stoneContent:w,stoneName:c}}var Kn=R({prefix:"sisyphus"}).child("pr"),jc=/github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)/,Rc=/gitlab\.com\/(.+)\/-\/merge_requests\/(\d+)/,Ec={"breaking-change":"major",bug:"patch",chore:"patch",documentation:"patch",enhancement:"minor",feature:"minor",fix:"patch"};function Ic(){let{values:n}=vc({args:process.argv.slice(3),options:{dryRun:{short:"d",type:"boolean"},github:{type:"boolean"},gitlab:{type:"boolean"},url:{short:"u",type:"string"},yes:{short:"y",type:"boolean"}}});return n}async function As(){try{let n=Ic(),{packages:o,packageNames:i}=await q(),s;if(n.url)s=await Pc(n.url);else s=await Oc(n);if(!s){$.error("Could not determine PR information. Please provide a PR URL with --url");return}if($.info(`Processing PR #${s.number}: ${s.title}`),console.log(),console.log(` Author: ${l.value(s.author)}`),console.log(` Branch: ${l.value(s.branch)}`),s.labels.length>0)console.log(` Labels: ${s.labels.map((g)=>l.dim(g)).join(", ")}`);console.log();let t;for(let g of s.labels){let y=g.toLowerCase();for(let[x,j]of Object.entries(Ec))if(y.includes(x)){if(t=j,j==="major")break}if(t==="major")break}if(!t){let g=s.title.toLowerCase();if(g.includes("breaking")||g.includes("!:"))t="major";else if(g.includes("feat")||g.includes("feature"))t="minor";else if(g.includes("fix")||g.includes("bug"))t="patch"}if(!t&&!n.yes){let g=await k({message:"Could not determine bump type from PR. What type of change is this? (major/minor/patch)",placeholder:"patch"});if(!g||!["major","minor","patch"].includes(g)){$.info("Invalid bump type. Cancelled.");return}t=g}else if(!t)t="patch";$.info(`Detected bump type: ${l.bold(t)}`);let e=await Tc(s.branch),r=await Bc(e,o,i);if(r.length===0){$.warn("No packages affected by this PR");return}console.log(),console.log(l.bold("Affected packages:"));for(let g of r){let y=o[g];if(!y)continue;let x=y.version,j=Ac(x,t);console.log(` ${l.value(g)}: ${x} \u2192 ${l.success(j)}`)}console.log();let a=`${s.title} (#${s.number})`,c;if(!n.yes){let g=await k({initialValue:a,message:"Commit message for this stone",placeholder:a});if(!g){$.info("Cancelled");return}c=g}else c=a;let p=t==="major"?r:[],f=t==="minor"?r:[],m=t==="patch"?r:[],{stoneContent:d,stoneName:w}=await hn({majorPackages:p,message:c,minorPackages:f,packages:o,patchPackages:m,tag:void 0});if(n.dryRun){$.info("Dry run - no changes made"),console.log(l.dim("Stone content:")),console.log(d.join(`
187
+ `));return}if(!n.yes){if(!await N({initialValue:!0,message:"Create stone from this PR?"})){$.info("Cancelled");return}}let u=await P();u.stones.push(w),await Bun.write(`.sisyphus/stones/${w}.md`,d.join(`
188
+ `)),await Bun.write(".sisyphus/config.json",`${JSON.stringify(u,null,2)}
189
+ `),$.success(`Created stone from PR: ${l.bold(w)}`),$.info(`Review the stone with ${l.value(`sisyphus stone show ${w}`)}`)}catch(n){Kn.error("Failed to process PR:",n),process.exit(1)}}async function Pc(n){let o=n.match(jc);if(o){let[,s="",t="",e=""]=o;return await _c(s,t,e)}let i=n.match(Rc);if(i){let[,s="",t=""]=i;return await Cc(s,t)}throw Error("Unsupported PR URL format")}async function Oc(n){try{if((await Bun.$`git remote get-url origin`.text()).includes("github.com")||n.github)try{let i=await Bun.$`gh pr view --json number,title,body,labels,author,headRefName`.json();return{author:i.author?.login||"unknown",branch:i.headRefName,description:i.body||"",labels:i.labels?.map((s)=>s.name)||[],number:String(i.number),title:i.title}}catch{Kn.debug("GitHub CLI not available or no PR found")}return null}catch(o){return Kn.debug("Could not detect current PR:",o),null}}async function _c(n,o,i){try{let s=await Bun.$`gh api repos/${n}/${o}/pulls/${i}`.json();return{author:s.user?.login||"unknown",branch:s.head.ref,description:s.body||"",labels:s.labels?.map((t)=>t.name)||[],number:String(s.number),title:s.title}}catch(s){throw Error(`Failed to fetch GitHub PR: ${s}`)}}async function Cc(n,o){throw Error("GitLab integration requires API token configuration")}async function Tc(n){try{let i=(await Bun.$`git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'`.text()).trim()||"main";return(n?await Bun.$`git diff --name-only ${i}...${n}`.text():await Bun.$`git diff --name-only ${i}...HEAD`.text()).trim().split(`
190
+ `).filter(Boolean)}catch(o){return Kn.warn("Could not get changed files, using current uncommitted changes"),(await Bun.$`git status --porcelain`.text()).trim().split(`
191
+ `).map((s)=>s.substring(3)).filter(Boolean)}}async function Bc(n,o,i){let s=new Set,t=new Map;for(let[e,r]of Object.entries(o))if(r.relativePath)t.set(r.relativePath,e);for(let e of n)for(let[r,a]of t)if(e.startsWith(`${r}/`))s.add(a);if(s.size===0&&n.length>0){if(n.filter((r)=>!r.includes("/")||r.startsWith(".")).length>0)return Kn.info("Root files changed, considering all packages affected"),i}return Array.from(s)}function Ac(n,o){let i=n.split("."),s=Number.parseInt(i[0]||"0",10),t=Number.parseInt(i[1]||"0",10),e=Number.parseInt(i[2]||"0",10);switch(o){case"major":return`${s+1}.0.0`;case"minor":return`${s}.${t+1}.0`;case"patch":return`${s}.${t}.${e+1}`;default:return n}}U();M();_();H();_n();import{parseArgs as Mc}from"util";var Lc=R({prefix:"sisyphus"}).child("prerelease"),Nc=["alpha","beta","rc","canary","dev","next"];function Hc(){let{values:n}=Mc({args:process.argv.slice(3),options:{bump:{short:"b",type:"string"},dryRun:{short:"d",type:"boolean"},filter:{short:"f",type:"string"},promote:{short:"p",type:"boolean"},type:{short:"t",type:"string"},yes:{short:"y",type:"boolean"}}});return n}async function Ms(){try{let n=Hc(),{packages:o,packageNames:i}=await q({filter:n.filter});if(n.promote)await Uc(n,o,i);else await Gc(n,o,i)}catch(n){Lc.error("Prerelease operation failed:",n),process.exit(1)}}async function Gc(n,o,i){let s=n.type||await tn({message:"Select prerelease type",options:Nc.map((y)=>({hint:qc(y),label:y,value:y}))});if(!s||typeof s!=="string"){$.info("Cancelled");return}let t=n.filter,e=t?i.filter((y)=>y.includes(t)):i;if(e.length===0){$.error(`No packages found matching filter: ${n.filter}`);return}let r=n.filter?e:await zc(e,o);if(r.length===0){$.info("No packages selected");return}let a;if(n.bump){let x={major:"major",minor:"minor",patch:"patch"}[n.bump.toLowerCase()];if(!x){$.error(`Invalid bump type: ${n.bump}. Must be major, minor, or patch.`);return}a=x}else{let y=await tn({message:"What type of change is this prerelease for?",options:[{label:"Major - Breaking changes",value:"major"},{label:"Minor - New features",value:"minor"},{label:"Patch - Bug fixes",value:"patch"}]});if(!y){$.info("Cancelled");return}a=y}let c=`chore: prepare ${s} release`,p;if(n.yes)p=c;else{let y=await k({message:"Commit message for this prerelease",placeholder:c});if(!y||typeof y!=="string"){$.info("Cancelled");return}p=y}let f=[],m=[],d=[];for(let y of r)switch(a){case"major":f.push(y);break;case"minor":m.push(y);break;case"patch":d.push(y);break}let{stoneContent:w,stoneName:u}=await hn({majorPackages:f,message:p,minorPackages:m,packages:o,patchPackages:d,tag:s});$.step("Preview of prerelease changes:"),console.log();for(let y of r){let x=o[y],j=K({bump:a,tag:s,version:x.version});console.log(` ${l.value(y)}: ${x.version} \u2192 ${l.bold(j)}`)}if(console.log(),n.dryRun){$.info("Dry run - no changes made"),console.log(l.dim("Stone content:")),console.log(w.join(`
192
+ `));return}if(!n.yes){if(!await N({initialValue:!0,message:"Create this prerelease stone?"})){$.info("Cancelled");return}}let g=await P();g.stones.push(u),await Bun.write(`.sisyphus/stones/${u}.md`,w.join(`
193
+ `)),await Bun.write(".sisyphus/config.json",`${JSON.stringify(g,null,2)}
194
+ `),$.success(`Created ${s} prerelease stone: ${l.bold(u)}`),$.info(`Run ${l.value("sisyphus roll")} to publish the prerelease`)}async function Uc(n,o,i){let s=i.filter((u)=>{return o[u].version.includes("-")});if(s.length===0){$.info("No packages with prerelease versions found");return}$.info(`Found ${l.bold(String(s.length))} packages with prerelease versions`),console.log();let t=new Map;for(let u of s){let y=o[u].version.match(/-(\w+)\./);if(y){let x=y[1];if(!t.has(x))t.set(x,[]);t.get(x)?.push(u)}}for(let[u,g]of t){console.log(`${l.bold(u)} packages:`);for(let y of g)console.log(` ${l.value(y)}: ${o[y].version}`);console.log()}let e=Array.from(t.keys()),r=[];if(e.includes("alpha"))r.push({label:"Promote alpha \u2192 beta",value:"alpha-to-beta"},{label:"Promote alpha \u2192 rc",value:"alpha-to-rc"},{label:"Promote alpha \u2192 stable",value:"alpha-to-stable"});if(e.includes("beta"))r.push({label:"Promote beta \u2192 rc",value:"beta-to-rc"},{label:"Promote beta \u2192 stable",value:"beta-to-stable"});if(e.includes("rc")||e.includes("next"))r.push({label:"Graduate to stable release",value:"to-stable"});r.push({label:"Increment current prerelease version",value:"increment"});let a=await tn({message:"How would you like to promote these prereleases?",options:r});if(!a){$.info("Cancelled");return}let c,p=s,f;switch(a){case"alpha-to-beta":c="beta",p=t.get("alpha")||[],f="chore: promote alpha to beta";break;case"alpha-to-rc":c="rc",p=t.get("alpha")||[],f="chore: promote alpha to rc";break;case"alpha-to-stable":c=void 0,p=t.get("alpha")||[],f="chore: promote alpha to stable release";break;case"beta-to-rc":c="rc",p=t.get("beta")||[],f="chore: promote beta to rc";break;case"beta-to-stable":c=void 0,p=t.get("beta")||[],f="chore: promote beta to stable release";break;case"to-stable":c=void 0,p=[...t.get("rc")||[],...t.get("next")||[]],f="chore: graduate to stable release";break;case"increment":if(e.length>1){let u=await tn({message:"Which prerelease type would you like to increment?",options:e.map((g)=>({label:g,value:g}))});if(!u){$.info("Cancelled");return}c=u,p=t.get(c)||[]}else c=e[0],p=c?t.get(c)||[]:[];f=`chore: increment ${c} version`;break;default:$.error("Unknown promotion strategy");return}if(p.length===0){$.info("No packages to promote");return}$.step("Preview of promotion:"),console.log();for(let u of p){let g=o[u].version,y;if(c===void 0)y=g.split("-")[0];else if(a==="increment")y=K({bump:"patch",tag:c,version:g});else y=`${g.split("-")[0]}-${c}.0`;console.log(` ${l.value(u)}: ${g} \u2192 ${l.bold(y)}`)}if(console.log(),!n.yes){if(!await N({initialValue:!0,message:"Continue with this promotion?"})){$.info("Cancelled");return}}let{stoneContent:m,stoneName:d}=await hn({majorPackages:[],message:f,minorPackages:[],packages:o,patchPackages:p,tag:c});if(n.dryRun){$.info("Dry run - no changes made"),console.log(m.join(`
195
+ `));return}let w=await P();w.stones.push(d),await Bun.write(`.sisyphus/stones/${d}.md`,m.join(`
182
196
  `)),await Bun.write(".sisyphus/config.json",`${JSON.stringify(w,null,2)}
183
- `),$.success(`Created promotion stone: ${p.bold(g)}`),$.info(`Run ${p.value("sisyphus roll")} to publish the promotion`)}function Ua(e){switch(e){case"alpha":return"Early development, unstable";case"beta":return"Feature complete, testing";case"rc":return"Release candidate, final testing";case"canary":return"Latest commit builds";case"dev":return"Development builds";case"next":return"Next version preview";default:return""}}async function Wa(e,t){if(await V({message:"Select packages for prerelease",options:[{label:"All packages",value:"all"},{label:"Select specific packages",value:"select"}]})==="all")return e;$.info("Select packages (space to select, enter to confirm)");let o=[];for(let i of e)if(await A({initialValue:!1,message:`Include ${i} (${t[i].version})?`}))o.push(i);return o}M();E();I();B();import{parseArgs as za}from"util";var Ja=v({prefix:"sisyphus"}).child("preview");async function ro(){let{values:e}=za({args:process.argv.slice(3),options:{"include-private":{type:"boolean"},json:{short:"j",type:"boolean"},verbose:{short:"v",type:"boolean"}}}),{json:t,verbose:n,"include-private":o=!1}=e;try{let i=await j(),r=await He();if(r.length===0){if(t)console.log(JSON.stringify({message:"No pending stones found"}));else $.info("No pending stones found. Nothing to preview.");return}let{packages:s}=await G({includePrivate:Boolean(o)}),a={},c=[];for(let{tag:m,packages:u,message:g}of r){c.push(g);for(let w of u){if(!a[w.name])a[w.name]={...w};let d=a[w.name];if(!d)continue;if(m)d.tag=m;d.bump=ye.indexOf(w.bump)>ye.indexOf(d.bump)?w.bump:d.bump,a[w.name]=d}}let l=Object.entries(a).map(([m,u])=>{let g=s[m]?.version||"0.0.0",[w="0",d="0",y="0"]=g.split("."),b=g;switch(u.bump){case"major":b=`${Number.parseInt(w,10)+1}.0.0`;break;case"minor":b=`${w}.${Number.parseInt(d,10)+1}.0`;break;case"patch":case"dependency":b=`${w}.${d}.${Number.parseInt(y,10)+1}`;break;case"snapshot":{let x=new Date().toISOString().replace(/[.ZT:-]/g,"").slice(0,14);b=`0.0.0-${u.tag||"nightly"}-${x}`;break}}if(u.tag&&u.bump!=="snapshot")b=`${b}-${u.tag}.0`;return{bump:u.bump,currentVersion:g,name:m,newVersion:b,tag:u.tag}});if(t){console.log(JSON.stringify({messages:c,stones:r.length,updates:l},null,2));return}$.info(`Preview of release with ${p.bold(String(r.length))} stone${r.length>1?"s":""}`),console.log(),console.log(p.bold("Commit Messages:")),c.forEach((m)=>{console.log(` ${p.bullet("\u2022")} ${m}`)}),console.log(),console.log(p.bold("Version Updates:"));for(let m of l){let u=m.bump==="major"?p.error:m.bump==="minor"?p.warning:p.success;console.log(` ${p.value(m.name)}`),console.log(` ${p.dim("Current:")} ${m.currentVersion}`),console.log(` ${p.dim("New:")} ${p.bold(m.newVersion)}`),console.log(` ${p.dim("Bump:")} ${u(m.bump)}${m.tag?` (${p.value(m.tag)})`:""}`),console.log()}if(n)console.log(p.bold("Additional Information:")),console.log(` ${p.dim("Config path:")} ${i.configPath||".sisyphus"}`),console.log(` ${p.dim("Total packages:")} ${Object.keys(s).length}`),console.log(` ${p.dim("Packages to update:")} ${l.length}`)}catch(i){Ja.error("Failed to preview release:",i),process.exit(1)}}M();E();I();I();var{$:un}=globalThis.Bun;var qe=v({prefix:"git-hooks"});class ao{hooksDir=".git/hooks";async installHooks(e){try{if(await un`mkdir -p ${this.hooksDir}`.quiet(),e.enableCommitMsg)await this.createCommitMsgHook(e);if(e.enablePreCommit)await this.createPreCommitHook(e);if(e.enablePrePush)await this.createPrePushHook(e);if(e.enablePostCommit)await this.createPostCommitHook(e);qe.info("Git hooks installed successfully")}catch(t){throw qe.error("Failed to install git hooks:",t),t}}async createCommitMsgHook(e){let t=`#!/usr/bin/env bun
184
-
185
- import { readFileSync } from "fs";
186
- import { exit } from "process";
187
-
188
- const COMMIT_MSG_FILE = process.argv[2];
189
- const commitMessage = readFileSync(COMMIT_MSG_FILE, "utf8").trim();
190
-
191
- const config = ${JSON.stringify(e,null,2)};
192
-
193
- function parseCommitMessage(message) {
194
- const pattern = /^(\\w+)(\\(.+\\))?!?: (.+)$/;
195
- const match = message.match(pattern);
196
-
197
- if (!match) {
198
- return null;
199
- }
200
-
201
- const [, type, scopeMatch, subject] = match;
202
- const scope = scopeMatch ? scopeMatch.slice(1, -1) : undefined;
203
- const isBreaking = message.includes("!:") || message.includes("BREAKING CHANGE:");
204
-
205
- const lines = message.split("\\n");
206
- const body = lines.slice(1).join("\\n").trim() || undefined;
207
-
208
- return {
209
- type,
210
- scope,
211
- subject,
212
- body,
213
- isBreaking
214
- };
215
- }
216
-
217
- function validateCommitMessage(message, config) {
218
- const errors = [];
219
-
220
- // Skip merge commits and revert commits
221
- if (message.startsWith("Merge ") || message.startsWith("Revert ")) {
222
- return { valid: true, errors: [] };
223
- }
224
-
225
- const parsed = parseCommitMessage(message);
226
-
227
- if (!parsed) {
228
- errors.push(\`Commit message does not match pattern: \${config.commitMsgPattern}\`);
229
- return { valid: false, errors };
230
- }
231
-
232
- // Validate type
233
- if (!config.commitTypes.includes(parsed.type)) {
234
- errors.push(\`Invalid commit type "\${parsed.type}". Allowed: \${config.commitTypes.join(", ")}\`);
235
- }
236
-
237
- // Validate scope
238
- if (config.requireScope && !parsed.scope) {
239
- errors.push("Commit scope is required");
240
- }
241
-
242
- if (config.allowedScopes && parsed.scope && !config.allowedScopes.includes(parsed.scope)) {
243
- errors.push(\`Invalid scope "\${parsed.scope}". Allowed: \${config.allowedScopes.join(", ")}\`);
244
- }
245
-
246
- // Validate subject length
247
- if (parsed.subject.length > config.maxSubjectLength) {
248
- errors.push(\`Subject line too long (\${parsed.subject.length} > \${config.maxSubjectLength})\`);
249
- }
250
-
251
- // Validate body
252
- if (config.requireBody && !parsed.body) {
253
- errors.push("Commit body is required");
254
- }
255
-
256
- // Validate breaking changes
257
- if (config.requireBreakingChange && parsed.type === "feat" && !parsed.isBreaking) {
258
- errors.push("Breaking change notation required for new features");
259
- }
260
-
261
- return { valid: errors.length === 0, errors };
262
- }
263
-
264
- const validation = validateCommitMessage(commitMessage, config);
265
-
266
- if (!validation.valid) {
267
- console.error("\u274C Commit message validation failed:");
268
- for (const error of validation.errors) {
269
- console.error(\` - \${error}\`);
270
- }
271
- console.error("");
272
- console.error("Example valid commit:");
273
- console.error(" feat(scope): add new feature");
274
- console.error(" feat(scope)!: add breaking change");
275
- console.error("");
276
- exit(1);
277
- }
278
-
279
- console.log("\u2705 Commit message is valid");
280
- exit(0);
281
- `;await this.writeHook("commit-msg",t)}async createPreCommitHook(e){await this.writeHook("pre-commit",`#!/usr/bin/env bun
282
-
283
- import { spawn } from "bun";
284
- import { exit } from "process";
285
-
286
- console.log("\uD83D\uDD0D Running pre-commit checks...");
287
-
288
- async function runCommand(cmd, args = []) {
289
- const proc = spawn(cmd, args);
290
- const result = await proc.exited;
291
-
292
- if (result !== 0) {
293
- console.error(\`\u274C Command failed: \${cmd} \${args.join(" ")}\`);
294
- return false;
295
- }
296
-
297
- return true;
298
- }
299
-
300
- async function runPreCommitChecks() {
301
- const checks = [
302
- { name: "Linting", cmd: "bun", args: ["lint"] },
303
- { name: "Type checking", cmd: "bun", args: ["type-check"] },
304
- { name: "Testing", cmd: "bun", args: ["test"] }
305
- ];
306
-
307
- for (const check of checks) {
308
- console.log(\`Running \${check.name}...\`);
309
-
310
- const success = await runCommand(check.cmd, check.args);
311
-
312
- if (!success) {
313
- console.error(\`\u274C \${check.name} failed\`);
314
- exit(1);
315
- }
316
-
317
- console.log(\`\u2705 \${check.name} passed\`);
318
- }
319
- }
320
-
321
- await runPreCommitChecks();
322
- console.log("\u2705 All pre-commit checks passed");
323
- exit(0);
324
- `)}async createPrePushHook(e){await this.writeHook("pre-push",`#!/usr/bin/env bun
325
-
326
- import { spawn } from "bun";
327
- import { exit } from "process";
328
-
329
- console.log("\uD83D\uDE80 Running pre-push checks...");
330
-
331
- async function runCommand(cmd, args = []) {
332
- const proc = spawn(cmd, args);
333
- const result = await proc.exited;
334
-
335
- if (result !== 0) {
336
- console.error(\`\u274C Command failed: \${cmd} \${args.join(" ")}\`);
337
- return false;
338
- }
339
-
340
- return true;
341
- }
342
-
343
- async function runPrePushChecks() {
344
- console.log("Checking workspace health...");
345
-
346
- const success = await runCommand("sisyphus", ["insights", "workspace-health"]);
347
-
348
- if (!success) {
349
- console.error("\u274C Workspace health check failed");
350
- exit(1);
351
- }
352
-
353
- console.log("\u2705 Workspace health check passed");
354
- }
355
-
356
- await runPrePushChecks();
357
- console.log("\u2705 All pre-push checks passed");
358
- exit(0);
359
- `)}async createPostCommitHook(e){await this.writeHook("post-commit",`#!/usr/bin/env bun
360
-
361
- import { readFileSync } from "fs";
362
- import { spawn } from "bun";
363
-
364
- console.log("\uD83D\uDCDD Running post-commit actions...");
365
-
366
- async function runCommand(cmd, args = []) {
367
- const proc = spawn(cmd, args);
368
- await proc.exited;
369
- }
370
-
371
- async function runPostCommitActions() {
372
- // Check if this commit might affect version dependencies
373
- try {
374
- await runCommand("sisyphus", ["insights", "dependency-impact", "--since=HEAD~1"]);
375
- } catch (error) {
376
- console.log("Could not analyze dependency impact");
377
- }
378
-
379
- // Update any workspace caches
380
- try {
381
- await runCommand("bun", ["install", "--frozen-lockfile"]);
382
- } catch (error) {
383
- console.log("Could not update lockfile");
384
- }
385
- }
386
-
387
- await runPostCommitActions();
388
- console.log("\u2705 Post-commit actions completed");
389
- `)}async writeHook(e,t){let n=`${this.hooksDir}/${e}`;await Bun.write(n,t),await un`chmod +x ${n}`.quiet(),qe.info(`Created ${e} hook`)}async uninstallHooks(){let e=["commit-msg","pre-commit","pre-push","post-commit"];for(let t of e){let n=`${this.hooksDir}/${t}`;try{await un`rm -f ${n}`.quiet(),qe.info(`Removed ${t} hook`)}catch(o){qe.warn(`Could not remove ${t} hook: ${o}`)}}}parseCommitMessage(e){let t=/^(\w+)(\(.+\))?!?: (.+)$/,n=e.match(t);if(!n)return null;let[,o,i,r]=n,s=i?i.slice(1,-1):void 0,a=e.includes("!:")||e.includes("BREAKING CHANGE:"),l=e.split(`
390
- `).slice(1).join(`
391
- `).trim()||void 0,m=l?.match(/BREAKING CHANGE: (.+)/),u=m?m[1]:void 0;return{body:l,footer:u,isBreaking:a,scope:s||"",subject:r||"",type:o||""}}validateCommitMessage(e,t){let n=[];if(e.startsWith("Merge ")||e.startsWith("Revert "))return{errors:[],valid:!0};let o=this.parseCommitMessage(e);if(!o)return n.push(`Commit message does not match pattern: ${t.commitMsgPattern}`),{errors:n,valid:!1};if(!t.commitTypes.includes(o.type))n.push(`Invalid commit type "${o.type}". Allowed: ${t.commitTypes.join(", ")}`);if(t.requireScope&&!o.scope)n.push("Commit scope is required");if(t.allowedScopes&&o.scope&&!t.allowedScopes.includes(o.scope))n.push(`Invalid scope "${o.scope}". Allowed: ${t.allowedScopes.join(", ")}`);if(o.subject.length>t.maxSubjectLength)n.push(`Subject line too long (${o.subject.length} > ${t.maxSubjectLength})`);if(t.requireBody&&!o.body)n.push("Commit body is required");if(t.requireBreakingChange&&o.type==="feat"&&!o.isBreaking)n.push("Breaking change notation required for new features");return{errors:n,valid:n.length===0}}getDefaultConfig(){return{allowedScopes:["core","hydra","sisyphus","tools","docs","deps"],commitMsgPattern:"type(scope): subject",commitTypes:["feat","fix","docs","style","refactor","test","chore","perf","ci","build","revert"],enableCommitMsg:!0,enablePostCommit:!1,enablePreCommit:!0,enablePrePush:!0,maxSubjectLength:72,requireBody:!1,requireBreakingChange:!1,requireScope:!1}}}var co=new ao;I();var ut=v({prefix:"gitlab-ci"});class lo{async generateBasicCI(e){return`# GitLab CI/CD Configuration for ${e.name}
392
-
393
- image: ${e.image}
394
-
395
- variables:
396
- NODE_VERSION: "${e.nodeVersion}"
397
- NPM_CONFIG_CACHE: ".npm"
398
- BILD_CACHE: ".bun"
399
-
400
- stages:
401
- ${e.stages.map((t)=>` - ${t}`).join(`
402
- `)}
403
-
404
- cache:
405
- key: \${CI_COMMIT_REF_SLUG}
406
- paths:
407
- - .npm/
408
- - .bun/
409
- - node_modules/
410
-
411
- before_script:
412
- - curl -fsSL https://bun.sh/install | bash
413
- - export PATH="$HOME/.bun/bin:$PATH"
414
- - bun --version
415
- - ${e.installCommand}
416
-
417
- # Install dependencies
418
- install:
419
- stage: install
420
- script:
421
- - ${e.installCommand}
422
- artifacts:
423
- paths:
424
- - node_modules/
425
- expire_in: 1 hour
426
- only:
427
- - branches
428
- - tags
429
-
430
- # Lint and type check
431
- lint:
432
- stage: lint
433
- script:
434
- - bun lint
435
- - bun type-check
436
- dependencies:
437
- - install
438
- only:
439
- - branches
440
- - tags
441
-
442
- ${e.buildCommand?`# Build packages
443
- build:
444
- stage: build
445
- script:
446
- - ${e.buildCommand}
447
- artifacts:
448
- paths:
449
- - dist/
450
- - build/
451
- expire_in: 1 hour
452
- dependencies:
453
- - install
454
- only:
455
- - branches
456
- - tags`:""}
457
-
458
- ${e.testCommand?`# Run tests
459
- test:
460
- stage: test
461
- script:
462
- - ${e.testCommand}
463
- dependencies:
464
- - install
465
- ${e.buildCommand?"- build":""}
466
- coverage: '/Lines\\s*:\\s*(\\d+\\.?\\d*)%/'
467
- artifacts:
468
- reports:
469
- coverage_report:
470
- coverage_format: cobertura
471
- path: coverage/cobertura-coverage.xml
472
- only:
473
- - branches
474
- - tags`:""}
475
-
476
- # Version analysis
477
- version-check:
478
- stage: version
479
- script:
480
- - sisyphus graph --since=last-stone --format=json > version-changes.json
481
- - sisyphus insights dependency-impact > dependency-impact.md
482
- artifacts:
483
- paths:
484
- - version-changes.json
485
- - dependency-impact.md
486
- expire_in: 1 week
487
- dependencies:
488
- - install
489
- only:
490
- - main
491
- - master
492
-
493
- # Release packages
494
- release:
495
- stage: release
496
- script:
497
- - |
498
- if sisyphus graph --since=last-stone --dry-run | grep -q "No changes"; then
499
- echo "No changes detected, skipping release"
500
- exit 0
501
- fi
502
- - sisyphus stone create --message="Automated release from GitLab CI" --auto-bump
503
- ${e.publishCommand?`- ${e.publishCommand}`:""}
504
- dependencies:
505
- - install
506
- ${e.buildCommand?"- build":""}
507
- ${e.testCommand?"- test":""}
508
- only:
509
- - main
510
- - master
511
- when: ${e.publishCondition||"on_success"}
512
- environment:
513
- name: production
514
- url: \${CI_PROJECT_URL}`}async generateMonorepoCI(e){return`# GitLab CI/CD Configuration for Monorepo
515
-
516
- image: ${e.image}
517
-
518
- variables:
519
- NODE_VERSION: "${e.nodeVersion}"
520
- NPM_CONFIG_CACHE: ".npm"
521
- BUN_CACHE: ".bun"
522
-
523
- stages:
524
- - install
525
- - lint
526
- - test
527
- - build
528
- - version
529
- - release
530
-
531
- cache:
532
- key: \${CI_COMMIT_REF_SLUG}-\${CI_PROJECT_PATH}
533
- paths:
534
- - .npm/
535
- - .bun/
536
- - node_modules/
537
- - packages/*/node_modules/
538
-
539
- before_script:
540
- - curl -fsSL https://bun.sh/install | bash
541
- - export PATH="$HOME/.bun/bin:$PATH"
542
- - bun --version
543
-
544
- # Install all dependencies
545
- install:
546
- stage: install
547
- script:
548
- - ${e.installCommand}
549
- artifacts:
550
- paths:
551
- - node_modules/
552
- - packages/*/node_modules/
553
- expire_in: 2 hours
554
- only:
555
- - branches
556
- - tags
557
-
558
- # Lint all packages
559
- lint:
560
- stage: lint
561
- script:
562
- - bun lint
563
- - bun type-check
564
- dependencies:
565
- - install
566
- only:
567
- - branches
568
- - tags
569
-
570
- # Test all packages
571
- test:
572
- stage: test
573
- parallel:
574
- matrix:
575
- - PACKAGE: ["core", "hydra", "sisyphus"]
576
- script:
577
- - cd packages/\${PACKAGE}
578
- - ${e.testCommand||"bun test"}
579
- dependencies:
580
- - install
581
- coverage: '/Lines\\s*:\\s*(\\d+\\.?\\d*)%/'
582
- artifacts:
583
- reports:
584
- coverage_report:
585
- coverage_format: cobertura
586
- path: packages/\${PACKAGE}/coverage/cobertura-coverage.xml
587
- only:
588
- - branches
589
- - tags
590
-
591
- # Build all packages
592
- build:
593
- stage: build
594
- script:
595
- - ${e.buildCommand||"bun build"}
596
- artifacts:
597
- paths:
598
- - packages/*/dist/
599
- - packages/*/build/
600
- expire_in: 1 hour
601
- dependencies:
602
- - install
603
- only:
604
- - branches
605
- - tags
606
-
607
- # Analyze changes and dependencies
608
- version-analysis:
609
- stage: version
610
- script:
611
- - sisyphus graph --since=last-stone --format=json > version-changes.json
612
- - sisyphus insights dependency-impact > dependency-impact.md
613
- - sisyphus insights workspace-health > workspace-health.md
614
- artifacts:
615
- paths:
616
- - version-changes.json
617
- - dependency-impact.md
618
- - workspace-health.md
619
- expire_in: 1 week
620
- dependencies:
621
- - install
622
- only:
623
- - main
624
- - master
625
-
626
- # Release changed packages
627
- release:
628
- stage: release
629
- script:
630
- - |
631
- if sisyphus graph --since=last-stone --dry-run | grep -q "No changes"; then
632
- echo "No changes detected, skipping release"
633
- exit 0
634
- fi
635
- - |
636
- echo "Creating automated release stone..."
637
- sisyphus stone create \\
638
- --message="Automated release from GitLab CI (\${CI_COMMIT_SHORT_SHA})" \\
639
- --auto-bump
640
- ${e.publishCommand?`- ${e.publishCommand}`:""}
641
- dependencies:
642
- - install
643
- - build
644
- - test
645
- only:
646
- - main
647
- - master
648
- when: ${e.publishCondition||"on_success"}
649
- environment:
650
- name: production
651
- url: \${CI_PROJECT_URL}`}async generateManualReleaseCI(){return`# Manual Release Pipeline
652
-
653
- manual-release:
654
- stage: release
655
- script:
656
- - echo "Starting manual release process..."
657
- - |
658
- if [ -n "\${VERSION_TYPE}" ]; then
659
- sisyphus stone create \\
660
- --message="\${RELEASE_MESSAGE:-Manual release}" \\
661
- --bump="\${VERSION_TYPE}" \\
662
- --auto-bump
663
- else
664
- sisyphus stone create \\
665
- --message="\${RELEASE_MESSAGE:-Manual release}" \\
666
- --interactive
667
- fi
668
- - sisyphus stone publish
669
- dependencies:
670
- - install
671
- - build
672
- - test
673
- when: manual
674
- allow_failure: false
675
- environment:
676
- name: production
677
- url: \${CI_PROJECT_URL}
678
- variables:
679
- VERSION_TYPE: ""
680
- RELEASE_MESSAGE: ""
681
- only:
682
- - main
683
- - master`}async generateScheduledCI(){return`# Scheduled maintenance pipeline
684
-
685
- dependency-update:
686
- stage: maintenance
687
- script:
688
- - echo "Checking for dependency updates..."
689
- - bun update
690
- - |
691
- if git diff --quiet package.json bun.lock; then
692
- echo "No dependency updates available"
693
- exit 0
694
- fi
695
- - git config --global user.name "GitLab CI"
696
- - git config --global user.email "ci@gitlab.com"
697
- - git add package.json bun.lock
698
- - git commit -m "chore: update dependencies"
699
- - sisyphus insights dependency-impact > dependency-impact.md
700
- - |
701
- echo "Dependency changes detected. Creating MR..."
702
- # Would typically create MR via GitLab API
703
- dependencies:
704
- - install
705
- only:
706
- schedules:
707
- - weekly
708
- when: always
709
- allow_failure: true
710
-
711
- health-check:
712
- stage: maintenance
713
- script:
714
- - sisyphus insights workspace-health
715
- - sisyphus graph --validate
716
- dependencies:
717
- - install
718
- only:
719
- schedules:
720
- - daily
721
- when: always
722
- allow_failure: true`}async createGitLabCI(e,t){let n=`${e}/.gitlab-ci.yml`;try{let o=await this.generateMonorepoCI(t);await Bun.write(n,o),ut.info("Created GitLab CI configuration: .gitlab-ci.yml");let i=await this.generateManualReleaseCI();await Bun.write(`${e}/.gitlab/ci/manual-release.yml`,i),ut.info("Created manual release CI: .gitlab/ci/manual-release.yml");let r=await this.generateScheduledCI();await Bun.write(`${e}/.gitlab/ci/scheduled.yml`,r),ut.info("Created scheduled CI: .gitlab/ci/scheduled.yml")}catch(o){throw ut.error("Failed to create GitLab CI files:",o),o}}getDefaultConfig(){return{buildCommand:"bun build",image:"oven/bun:latest",installCommand:"bun install",name:"Monorepo CI/CD",nodeVersion:"20",publishCommand:"sisyphus stone publish",publishCondition:"on_success",stages:["install","lint","test","build","version","release"],testCommand:"bun test"}}}var po=new lo;I();var{$:Ka}=globalThis.Bun;var Le=v({prefix:"workflow-templates"});class mo{async generateCIWorkflow(e){let t=e.nodeVersions.map((n)=>`'${n}'`).join(", ");return`name: ${e.name}
723
-
724
- on:
725
- ${e.triggers.map((n)=>` ${n}:`).join(`
726
- `)}
727
-
728
- jobs:
729
- test:
730
- runs-on: ubuntu-latest
731
- strategy:
732
- matrix:
733
- node-version: [${t}]
734
-
735
- steps:
736
- - name: Checkout code
737
- uses: actions/checkout@v4
738
- with:
739
- fetch-depth: 0
740
-
741
- - name: Setup Node.js \${{ matrix.node-version }}
742
- uses: actions/setup-node@v4
743
- with:
744
- node-version: \${{ matrix.node-version }}
745
- cache: 'bun'
746
-
747
- - name: Install Bun
748
- uses: oven-sh/setup-bun@v1
749
- with:
750
- bun-version: latest
751
-
752
- - name: Install dependencies
753
- run: ${e.installCommand}
754
- ${e.workingDirectory?`working-directory: ${e.workingDirectory}`:""}
755
-
756
- ${e.buildCommand?`- name: Build packages
757
- run: ${e.buildCommand}
758
- ${e.workingDirectory?`working-directory: ${e.workingDirectory}`:""}`:""}
759
-
760
- ${e.testCommand?`- name: Run tests
761
- run: ${e.testCommand}
762
- ${e.workingDirectory?`working-directory: ${e.workingDirectory}`:""}`:""}
763
-
764
- - name: Type check
765
- run: bun type-check
766
- ${e.workingDirectory?`working-directory: ${e.workingDirectory}`:""}
767
-
768
- - name: Lint code
769
- run: bun lint
770
- ${e.workingDirectory?`working-directory: ${e.workingDirectory}`:""}`}async generateReleaseWorkflow(e){return`name: Release
771
-
772
- on:
773
- push:
774
- branches: [main, master]
775
- workflow_dispatch:
776
-
777
- concurrency:
778
- group: release-\${{ github.ref }}
779
- cancel-in-progress: false
780
-
781
- jobs:
782
- release:
783
- runs-on: ubuntu-latest
784
- permissions:
785
- contents: write
786
- id-token: write
787
- packages: write
788
-
789
- steps:
790
- - name: Checkout code
791
- uses: actions/checkout@v4
792
- with:
793
- fetch-depth: 0
794
- token: \${{ secrets.GITHUB_TOKEN }}
795
-
796
- - name: Setup Node.js
797
- uses: actions/setup-node@v4
798
- with:
799
- node-version: '${e.nodeVersions[0]||"20"}'
800
- cache: 'bun'
801
- registry-url: 'https://registry.npmjs.org'
802
-
803
- - name: Install Bun
804
- uses: oven-sh/setup-bun@v1
805
- with:
806
- bun-version: latest
807
-
808
- - name: Install dependencies
809
- run: ${e.installCommand}
810
- ${e.workingDirectory?`working-directory: ${e.workingDirectory}`:""}
811
-
812
- ${e.buildCommand?`- name: Build packages
813
- run: ${e.buildCommand}
814
- ${e.workingDirectory?`working-directory: ${e.workingDirectory}`:""}`:""}
815
-
816
- ${e.testCommand?`- name: Run tests
817
- run: ${e.testCommand}
818
- ${e.workingDirectory?`working-directory: ${e.workingDirectory}`:""}`:""}
819
-
820
- - name: Check for changes
821
- id: changes
822
- run: |
823
- if sisyphus graph --since=last-stone --dry-run | grep -q "No changes"; then
824
- echo "has-changes=false" >> $GITHUB_OUTPUT
825
- else
826
- echo "has-changes=true" >> $GITHUB_OUTPUT
827
- fi
828
- ${e.workingDirectory?`working-directory: ${e.workingDirectory}`:""}
829
-
830
- - name: Create stone
831
- if: steps.changes.outputs.has-changes == 'true'
832
- run: |
833
- sisyphus stone create --message="Automated release from CI" --auto-bump
834
- ${e.workingDirectory?`working-directory: ${e.workingDirectory}`:""}
835
- env:
836
- NODE_AUTH_TOKEN: \${{ secrets.NPM_TOKEN }}
837
-
838
- ${e.publishCommand&&e.publishCondition?`- name: Publish packages
839
- if: ${e.publishCondition}
840
- run: ${e.publishCommand}
841
- ${e.workingDirectory?`working-directory: ${e.workingDirectory}`:""}
842
- env:
843
- NODE_AUTH_TOKEN: \${{ secrets.NPM_TOKEN }}`:""}`}async generateVersioningWorkflow(e){return`name: Version Management
844
-
845
- on:
846
- workflow_dispatch:
847
- inputs:
848
- version-type:
849
- description: 'Version bump type'
850
- required: true
851
- default: 'patch'
852
- type: choice
853
- options:
854
- - patch
855
- - minor
856
- - major
857
- - snapshot
858
- message:
859
- description: 'Release message'
860
- required: true
861
- default: 'Manual release'
862
- packages:
863
- description: 'Specific packages (comma-separated, optional)'
864
- required: false
865
-
866
- jobs:
867
- version:
868
- runs-on: ubuntu-latest
869
- permissions:
870
- contents: write
871
- packages: write
872
-
873
- steps:
874
- - name: Checkout code
875
- uses: actions/checkout@v4
876
- with:
877
- fetch-depth: 0
878
- token: \${{ secrets.GITHUB_TOKEN }}
879
-
880
- - name: Setup Node.js
881
- uses: actions/setup-node@v4
882
- with:
883
- node-version: '${e.nodeVersions[0]||"20"}'
884
- cache: 'bun'
885
-
886
- - name: Install Bun
887
- uses: oven-sh/setup-bun@v1
888
- with:
889
- bun-version: latest
890
-
891
- - name: Install dependencies
892
- run: ${e.installCommand}
893
- ${e.workingDirectory?`working-directory: ${e.workingDirectory}`:""}
894
-
895
- - name: Configure Git
896
- run: |
897
- git config --global user.name "github-actions[bot]"
898
- git config --global user.email "github-actions[bot]@users.noreply.github.com"
899
-
900
- - name: Create versioned stone
901
- run: |
902
- if [ -n "\${{ github.event.inputs.packages }}" ]; then
903
- sisyphus stone create \\
904
- --message="\${{ github.event.inputs.message }}" \\
905
- --bump="\${{ github.event.inputs.version-type }}" \\
906
- --packages="\${{ github.event.inputs.packages }}"
907
- else
908
- sisyphus stone create \\
909
- --message="\${{ github.event.inputs.message }}" \\
910
- --bump="\${{ github.event.inputs.version-type }}" \\
911
- --auto-bump
912
- fi
913
- ${e.workingDirectory?`working-directory: ${e.workingDirectory}`:""}`}async generateDependencyUpdateWorkflow(){return`name: Dependency Updates
914
-
915
- on:
916
- schedule:
917
- - cron: '0 2 * * 1' # Weekly on Monday at 2 AM
918
- workflow_dispatch:
919
-
920
- jobs:
921
- update-dependencies:
922
- runs-on: ubuntu-latest
923
- permissions:
924
- contents: write
925
- pull-requests: write
926
-
927
- steps:
928
- - name: Checkout code
929
- uses: actions/checkout@v4
930
- with:
931
- fetch-depth: 0
932
- token: \${{ secrets.GITHUB_TOKEN }}
933
-
934
- - name: Setup Node.js
935
- uses: actions/setup-node@v4
936
- with:
937
- node-version: '20'
938
- cache: 'bun'
939
-
940
- - name: Install Bun
941
- uses: oven-sh/setup-bun@v1
942
- with:
943
- bun-version: latest
944
-
945
- - name: Update dependencies
946
- run: |
947
- bun update
948
-
949
- - name: Check for dependency changes
950
- id: changes
951
- run: |
952
- if git diff --quiet package.json bun.lock; then
953
- echo "has-changes=false" >> $GITHUB_OUTPUT
954
- else
955
- echo "has-changes=true" >> $GITHUB_OUTPUT
956
- fi
957
-
958
- - name: Analyze dependency impact
959
- if: steps.changes.outputs.has-changes == 'true'
960
- run: |
961
- sisyphus insights dependency-impact > dependency-impact.md
962
- echo "IMPACT<<EOF" >> $GITHUB_ENV
963
- cat dependency-impact.md >> $GITHUB_ENV
964
- echo "EOF" >> $GITHUB_ENV
965
-
966
- - name: Create Pull Request
967
- if: steps.changes.outputs.has-changes == 'true'
968
- uses: peter-evans/create-pull-request@v5
969
- with:
970
- token: \${{ secrets.GITHUB_TOKEN }}
971
- commit-message: "chore: update dependencies"
972
- title: "\uD83D\uDD27 Automated dependency updates"
973
- body: |
974
- ## Dependency Impact Analysis
975
-
976
- \${{ env.IMPACT }}
977
-
978
- This PR contains automated dependency updates.
979
-
980
- - Review the dependency impact analysis above
981
- - Ensure all tests pass
982
- - Merge when ready to publish updated packages
983
- branch: dependency-updates
984
- delete-branch: true`}async createWorkflowFiles(e,t){let n=`${e}/.github/workflows`;try{await Ka`mkdir -p ${n}`.quiet();let o=await this.generateCIWorkflow(t);await Bun.write(`${n}/ci.yml`,o),Le.info("Created CI workflow: .github/workflows/ci.yml");let i=await this.generateReleaseWorkflow(t);await Bun.write(`${n}/release.yml`,i),Le.info("Created release workflow: .github/workflows/release.yml");let r=await this.generateVersioningWorkflow(t);await Bun.write(`${n}/version.yml`,r),Le.info("Created versioning workflow: .github/workflows/version.yml");let s=await this.generateDependencyUpdateWorkflow();await Bun.write(`${n}/dependencies.yml`,s),Le.info("Created dependency update workflow: .github/workflows/dependencies.yml")}catch(o){throw Le.error("Failed to create workflow files:",o),o}}getDefaultConfig(){return{buildCommand:"bun build",installCommand:"bun install",name:"CI/CD",nodeVersions:["18","20","22"],publishCommand:"sisyphus stone publish",publishCondition:"success()",testCommand:"bun test",triggers:["push","pull_request"]}}}var uo=new mo;I();B();var{$:Za}=globalThis.Bun;var ft=v({prefix:"workspace-resolver"});class fo{packages={};packageJsonCache=new Map;async initialize(){let{packages:e}=await G({includePrivate:!0});this.packages=e;for(let[t,n]of Object.entries(e))try{let o=await Bun.file(n.file).json();this.packageJsonCache.set(t,o)}catch(o){ft.warn(`Failed to load package.json for ${t}: ${o}`)}ft.info(`Initialized workspace resolver with ${Object.keys(e).length} packages`)}async resolveWorkspaceDependencies(){let e=[];for(let[t,n]of Object.entries(this.packages)){let o=this.packageJsonCache.get(t);if(!o)continue;let i=await this.resolvePackageDependencies(t,o);e.push(i)}return e}async resolvePackageDependencies(e,t){let n=await this.resolveDependencyGroup(e,t.dependencies||{},"dependencies"),o=await this.resolveDependencyGroup(e,t.devDependencies||{},"devDependencies"),i=await this.resolveDependencyGroup(e,t.peerDependencies||{},"peerDependencies"),r=this.detectConflicts(e,[...n,...o]),s=this.generateSuggestions(e,n,o,r);return{conflicts:r,dependencies:n,devDependencies:o,package:e,peerDependencies:i,suggestions:s}}async resolveDependencyGroup(e,t,n){let o=[];for(let[i,r]of Object.entries(t)){let s=await this.resolveDependency(e,i,r);o.push(s)}return o}async resolveDependency(e,t,n){if(n.startsWith("workspace:"))return this.resolveWorkspaceDependency(e,t,n);if(n.startsWith("file:")||n.startsWith("link:"))return this.resolveLocalDependency(e,t,n);return this.resolveRegistryDependency(e,t,n)}resolveWorkspaceDependency(e,t,n){let o=this.packages[t];if(!o)return{name:t,resolvedVersion:"not-found",satisfies:!1,source:"workspace",version:n};let i=n.replace("workspace:",""),r=o.version,s=this.satisfiesVersion(r,i);return{location:o.file,name:t,resolvedVersion:r,satisfies:s,source:"workspace",version:n}}resolveLocalDependency(e,t,n){return{location:n.replace(/^(file:|link:)/,""),name:t,resolvedVersion:"local",satisfies:!0,source:"local",version:n}}async resolveRegistryDependency(e,t,n){try{let i=(await Za`npm view ${t} version`.quiet()).stdout.toString().trim(),r=this.satisfiesVersion(i,n);return{name:t,resolvedVersion:i,satisfies:r,source:"registry",version:n}}catch(o){return ft.debug(`Failed to resolve registry dependency ${t}: ${o}`),{name:t,resolvedVersion:"unknown",satisfies:!1,source:"registry",version:n}}}satisfiesVersion(e,t){if(t==="*"||t==="latest")return!0;if(t.startsWith("workspace:"))return!0;try{return (()=>{throw new Error("Cannot require module "+"semver");})().satisfies(e,t)}catch{return e===t}}detectConflicts(e,t){let n=[],o=new Map;for(let i of t){if(!o.has(i.name))o.set(i.name,[]);o.get(i.name)?.push(i)}for(let[i,r]of o)if(r.length>1){let s=r.map((c)=>c.version),a=[...new Set(s)];if(a.length>1)n.push({dependency:i,description:`Multiple versions of ${i} specified: ${a.join(", ")}`,packages:[e],resolution:`Align to single version: ${a[0]}`,severity:"warning",versions:a})}return n}generateSuggestions(e,t,n,o){let i=[];for(let r of[...t,...n]){if(!r.satisfies)i.push({dependency:r.name,from:r.version,impact:"unknown",package:e,reason:`Version mismatch: ${r.version} vs ${r.resolvedVersion}`,to:r.resolvedVersion,type:"upgrade"});if(r.source==="workspace"&&r.resolvedVersion==="not-found")i.push({dependency:r.name,from:r.version,impact:"breaking",package:e,reason:`Workspace dependency ${r.name} not found`,to:"",type:"remove"})}for(let r of o)i.push({dependency:r.dependency,from:r.versions.join(", "),impact:"non-breaking",package:e,reason:r.description,to:r.resolution||r.versions[0]||"",type:"align"});return i}async validateWorkspace(){let e=await this.resolveWorkspaceDependencies(),t=[],n=[],o=[];for(let i of e){for(let r of i.conflicts)if(r.severity==="error")t.push(`${i.package}: ${r.description}`);else n.push(`${i.package}: ${r.description}`);o.push(...i.suggestions)}return{errors:t,suggestions:o,valid:t.length===0,warnings:n}}async fixWorkspaceIssues(e){let t=new Map;for(let n of e){if(!t.has(n.package))t.set(n.package,[]);t.get(n.package)?.push(n)}for(let[n,o]of t)await this.applyPackageFixes(n,o)}async applyPackageFixes(e,t){let n=this.packages[e];if(!n)return;let o=this.packageJsonCache.get(e);if(!o)return;let i=!1;for(let r of t)switch(r.type){case"upgrade":case"align":if(o.dependencies?.[r.dependency])o.dependencies[r.dependency]=r.to,i=!0;if(o.devDependencies?.[r.dependency])o.devDependencies[r.dependency]=r.to,i=!0;break;case"remove":if(o.dependencies?.[r.dependency])delete o.dependencies[r.dependency],i=!0;if(o.devDependencies?.[r.dependency])delete o.devDependencies[r.dependency],i=!0;break}if(i)await Bun.write(n.file,JSON.stringify(o,null,2)),ft.info(`Applied ${t.length} fixes to ${e}`)}}var dt=new fo;var K=v({prefix:"setup"});async function ho(){ee("\uD83D\uDD27 Sisyphus Workspace Setup");let e=await V({message:"What would you like to set up?",options:[{label:"GitHub Actions workflows",value:"github"},{label:"GitLab CI configuration",value:"gitlab"},{label:"Git hooks for commit conventions",value:"hooks"},{label:"Workspace dependency resolution",value:"workspace"},{label:"Complete setup (all of the above)",value:"complete"}]});if(typeof e==="symbol")throw new te("Setup cancelled","CANCELLED");switch(e){case"github":await go();break;case"gitlab":await yo();break;case"hooks":await bo();break;case"workspace":await wo();break;case"complete":await Va();break}T("\u2705 Setup completed successfully!")}async function go(){K.info("Setting up GitHub Actions workflows...");let e=await L({defaultValue:"CI/CD",message:"Workflow name",placeholder:"CI/CD"});if(typeof e==="symbol")return;let t=await F({message:"Select workflow triggers",options:[{label:"Push to main branches",value:"push"},{label:"Pull requests",value:"pull_request"},{label:"Manual trigger",value:"workflow_dispatch"},{label:"Scheduled (daily)",value:"schedule"}],required:!0});if(typeof t==="symbol")return;let n=await F({message:"Select Node.js versions to test",options:[{label:"Node.js 18",value:"18"},{label:"Node.js 20",value:"20"},{label:"Node.js 22",value:"22"}],required:!0});if(typeof n==="symbol")return;let o={buildCommand:"bun build",installCommand:"bun install",name:e,nodeVersions:n,publishCommand:"sisyphus stone publish",testCommand:"bun test",triggers:t};await uo.createWorkflowFiles(process.cwd(),o),K.info("GitHub Actions workflows created successfully")}async function yo(){K.info("Setting up GitLab CI configuration...");let e=await L({defaultValue:"Monorepo CI/CD",message:"CI/CD pipeline name",placeholder:"Monorepo CI/CD"});if(typeof e==="symbol")return;let t=await V({message:"Select Docker image",options:[{label:"oven/bun:latest (recommended)",value:"oven/bun:latest"},{label:"node:20",value:"node:20"},{label:"node:18",value:"node:18"},{label:"Custom",value:"custom"}]});if(typeof t==="symbol")return;let n=t;if(t==="custom"){let i=await L({message:"Enter custom Docker image",placeholder:"my-registry/my-image:tag"});if(typeof i==="symbol")return;n=i}let o={buildCommand:"bun build",image:n,installCommand:"bun install",name:e,nodeVersion:"20",publishCommand:"sisyphus stone publish",stages:["install","lint","test","build","version","release"],testCommand:"bun test"};await po.createGitLabCI(process.cwd(),o),K.info("GitLab CI configuration created successfully")}async function bo(){K.info("Setting up Git hooks...");let e=await F({message:"Select hooks to install",options:[{label:"commit-msg (validate commit messages)",value:"commit-msg"},{label:"pre-commit (run linting and tests)",value:"pre-commit"},{label:"pre-push (workspace health check)",value:"pre-push"},{label:"post-commit (dependency analysis)",value:"post-commit"}],required:!0});if(typeof e==="symbol")return;let t=await F({message:"Select allowed commit types",options:[{label:"feat (new features)",value:"feat"},{label:"fix (bug fixes)",value:"fix"},{label:"docs (documentation)",value:"docs"},{label:"style (formatting)",value:"style"},{label:"refactor (code refactoring)",value:"refactor"},{label:"test (testing)",value:"test"},{label:"chore (maintenance)",value:"chore"},{label:"perf (performance)",value:"perf"},{label:"ci (CI/CD)",value:"ci"},{label:"build (build system)",value:"build"}],required:!0});if(typeof t==="symbol")return;let n=await A({initialValue:!1,message:"Require commit scope (e.g., feat(core): add feature)?"});if(typeof n==="symbol")return;let o={allowedScopes:["core","hydra","sisyphus","tools","docs","deps"],commitMsgPattern:"type(scope): subject",commitTypes:t,enableCommitMsg:e.includes("commit-msg"),enablePostCommit:e.includes("post-commit"),enablePreCommit:e.includes("pre-commit"),enablePrePush:e.includes("pre-push"),maxSubjectLength:72,requireBody:!1,requireBreakingChange:!1,requireScope:n};await co.installHooks(o),K.info("Git hooks installed successfully")}async function wo(){K.info("Setting up workspace dependency resolution..."),await dt.initialize();let e=await dt.validateWorkspace();if(e.valid)K.info("\u2705 Workspace is already properly configured");else{K.warn(`Found ${e.errors.length} errors and ${e.warnings.length} warnings`);for(let t of e.errors)K.error(t);for(let t of e.warnings)K.warn(t);if(e.suggestions.length>0){if(await A({initialValue:!0,message:`Found ${e.suggestions.length} suggested fixes. Apply them?`}))await dt.fixWorkspaceIssues(e.suggestions),K.info("\u2705 Workspace issues have been fixed")}}}async function Va(){K.info("Running complete workspace setup..."),await go(),await yo(),await bo(),await wo(),K.info("\uD83C\uDF89 Complete setup finished!")}M();E();B();import{parseArgs as Ya}from"util";var{$:ht}=globalThis.Bun;var Xa=v({prefix:"sisyphus:solo"});async function $o(){let{values:e}=Ya({args:process.argv.slice(3),options:{"dry-run":{short:"d",type:"boolean"},tag:{short:"t",type:"string"}}}),{"dry-run":t,tag:n}=e;ee(`${p.command("sisyphus solo")} - Single maintainer workflow`);let o=xe();o.start("Creating version from commits and rolling immediately...");try{let i=await ht`git describe --tags --abbrev=0 2>/dev/null || echo ""`.text(),r=await ht`git rev-list ${i?`${i.trim()}..HEAD`:"HEAD"} --count`.text();if(Number.parseInt(r.trim(),10)===0){o.stop("No commits to release"),T(p.dim("Already up to date"));return}o.message("Analyzing commits...");let s=["bunx","@r5n/sisyphus","version","--from-commits","--yes"];if(t)s.push("--dry-run");if(await ht`${s}`,((await j()).stones||[]).length===0&&!t){o.stop("No releasable changes found"),T(p.dim("No version bumps needed"));return}o.message(t?"Previewing release...":"Rolling stones...");let l=["bunx","@r5n/sisyphus","roll"];if(t)l.push("--dry-run");if(n)l.push("--tag",n);await ht`${l}`,o.stop("Release complete!"),T(p.success("Published successfully"))}catch(i){o.stop("Solo release failed"),Xa.error("Failed to complete solo workflow",i),T(p.error(`Solo release failed: ${i}`)),process.exit(1)}}E();I();M();E();I();B();import{existsSync as Qa}from"fs";import{unlink as Fa}from"fs/promises";import{join as Da}from"path";import{parseArgs as ec}from"util";var Ne=v({prefix:"sisyphus"}).child("stone:delete");async function vo(e){if(!e)Ne.error("Stone ID is required"),Ne.error("Usage: sisyphus stone delete <id>"),process.exit(1);let{values:t}=ec({args:process.argv.slice(5),options:{force:{short:"f",type:"boolean"}}}),{force:n}=t;try{let i=(await j()).stonesPath||".sisyphus/stones",r=Da(i,`${e}.md`);if(!Qa(r))Ne.error(`Stone '${e}' not found`),Ne.info("Run 'sisyphus stone list' to see available stones"),process.exit(1);if(!n){if(!await A({initialValue:!1,message:`Delete stone '${e}'?`})){$.info("Deletion cancelled");return}}await Fa(r),$.success(`Stone '${p.bold(e)}' deleted`)}catch(o){Ne.error(`Failed to delete stone '${e}':`,o),process.exit(1)}}M();E();I();B();import{existsSync as tc}from"fs";import{readFile as nc,writeFile as sc}from"fs/promises";import{join as oc}from"path";import{parseArgs as ic}from"util";var Ie=v({prefix:"sisyphus"}).child("stone:edit");async function xo(e){if(!e)Ie.error("Stone ID is required"),Ie.error("Usage: sisyphus stone edit <id>"),process.exit(1);let{values:t}=ic({args:process.argv.slice(5),options:{interactive:{short:"i",type:"boolean"},message:{short:"m",type:"string"}}}),{message:n,interactive:o}=t;try{let r=(await j()).stonesPath||".sisyphus/stones",s=oc(r,`${e}.md`);if(!tc(s))Ie.error(`Stone '${e}' not found`),Ie.info("Run 'sisyphus stone list' to see available stones"),process.exit(1);let a=await nc(s,"utf-8");if(n){let c=a.split(`
985
- `);c[0]=`### ${n}`,await sc(s,c.join(`
986
- `)),$.success(`Updated commit message for stone '${p.bold(e)}'`);return}if(o){$.info("Interactive stone editing coming soon"),$.info("For now, you can manually edit:"),$.info(p.dim(s));return}Ie.error("Please specify --message or --interactive"),process.exit(1)}catch(i){Ie.error(`Failed to edit stone '${e}':`,i),process.exit(1)}}E();var Co={delete:{description:"Remove a specific stone before rolling",examples:[{command:"sisyphus stone delete stone-123",description:"Delete a stone by ID"},{command:"sisyphus stone delete stone-123 --force",description:"Delete without confirmation"}],name:"sisyphus stone delete",options:[{description:"Skip confirmation prompt",flags:"-f, --force",type:"boolean"}],usage:"sisyphus stone delete <id> [options]"},edit:{description:"Modify stone content or version bumps",examples:[{command:"sisyphus stone edit stone-123 --interactive",description:"Edit stone interactively"},{command:'sisyphus stone edit stone-123 --message "feat: better description"',description:"Update commit message"}],name:"sisyphus stone edit",options:[{description:"New commit message",flags:"-m, --message",type:"string"},{description:"Edit in interactive mode",flags:"-i, --interactive",type:"boolean"}],usage:"sisyphus stone edit <id> [options]"},list:{description:"View all pending stones with details",examples:[{command:"sisyphus stone list",description:"List all pending stones"},{command:"sisyphus stone list --verbose",description:"Show full stone content"},{command:"sisyphus stone list --json",description:"Output as JSON for scripting"}],name:"sisyphus stone list",options:[{description:"Output in JSON format",flags:"-j, --json",type:"boolean"},{description:"Show full stone content",flags:"-v, --verbose",type:"boolean"}],usage:"sisyphus stone list [options]"},merge:{description:"Combine multiple stones with smart conflict resolution",examples:[{command:"sisyphus stone merge",description:"Merge stones interactively"},{command:"sisyphus stone merge --ids stone-123 stone-456",description:"Merge specific stones"},{command:"sisyphus stone merge --strategy highest",description:"Merge with automatic conflict resolution"},{command:'sisyphus stone merge --strategy interactive --message "feat: combined changes"',description:"Merge with interactive conflict resolution"}],name:"sisyphus stone merge",notes:["Detects when same package has different bump types across stones","Default strategy uses highest bump type (major > minor > patch)","Interactive strategy lets you choose resolution for each conflict"],options:[{description:"Stone IDs to merge (multiple)",flags:"-i, --ids",type:"string"},{description:"Commit message for merged stone",flags:"-m, --message",type:"string"},{description:"Skip confirmation",flags:"-f, --force",type:"boolean"},{description:"Conflict resolution (highest/interactive)",flags:"-s, --strategy",type:"string"}],usage:"sisyphus stone merge [options]"},show:{description:"Display full content of a specific stone",examples:[{command:"sisyphus stone show stone-123",description:"Show stone content"},{command:"sisyphus stone show stone-123 --json",description:"Output as JSON"}],name:"sisyphus stone show",options:[{description:"Output in JSON format",flags:"-j, --json",type:"boolean"}],usage:"sisyphus stone show <id> [options]"}};function gt(e){if(e&&Co[e]){console.log(nt(Co[e]));return}console.log(st("Sisyphus Stone Management","sisyphus stone <command> [options]",[{description:"View all pending stones with details",name:"list"},{description:"Remove a specific stone by ID",name:"delete"},{description:"Display full content of a stone",name:"show"},{description:"Modify stone content or versions",name:"edit"},{description:"Combine multiple stones into one",name:"merge"},{description:"Show this help message",name:"help"}],"Use sisyphus stone <command> --help for more information about a command."))}M();E();I();B();import{readFile as rc}from"fs/promises";import{join as ac}from"path";import{parseArgs as cc}from"util";var So=v({prefix:"sisyphus"}).child("stone:list");async function ko(){let{values:e}=cc({args:process.argv.slice(4),options:{json:{short:"j",type:"boolean"},verbose:{short:"v",type:"boolean"}}}),{json:t,verbose:n}=e;try{let i=(await j()).stonesPath||".sisyphus/stones",r=await D();if(r.length===0){if(t)console.log(JSON.stringify([]));else $.info("No pending stones found");return}let s=[];for(let a of r){let c=ac(i,`${a}.md`);try{let l=await rc(c,"utf-8"),m=ve(l);s.push({id:a,path:c,...m})}catch(l){So.warn(`Failed to read stone ${a}:`,l)}}if(t){console.log(JSON.stringify(s,null,2));return}$.info(`Found ${p.bold(String(s.length))} pending stone${s.length>1?"s":""}`),console.log();for(let[a,c]of s.entries()){if(console.log(`${p.bullet("\u2022")} ${p.bold(c.id)}`),console.log(` ${p.dim("Message:")} ${c.commitMessage}`),c.tag)console.log(` ${p.dim("Tag:")} ${p.value(c.tag)}`);if(c.major.length>0)console.log(` ${p.error("Major:")} ${c.major.join(", ")}`);if(c.minor.length>0)console.log(` ${p.warning("Minor:")} ${c.minor.join(", ")}`);if(c.patch.length>0)console.log(` ${p.success("Patch:")} ${c.patch.join(", ")}`);if(n&&c.description)console.log(` ${p.dim("Description:")}`),c.description.split(`
987
- `).forEach((l)=>{console.log(` ${p.dim(l)}`)});if(a<s.length-1)console.log()}}catch(o){So.error("Failed to list stones:",o),process.exit(1)}}M();E();I();B();import{readFile as _o,unlink as Eo,writeFile as lc}from"fs/promises";import{join as fn}from"path";import{parseArgs as pc}from"util";M();E();Re();var yt={major:4,minor:3,patch:2,dependency:1,snapshot:5};function Ro(e){let t=new Map;for(let o of e){for(let i of o.major){let r={bumpType:"major",name:i,stoneId:o.id,tag:o.tag};t.set(i,[...t.get(i)||[],r])}for(let i of o.minor){let r={bumpType:"minor",name:i,stoneId:o.id,tag:o.tag};t.set(i,[...t.get(i)||[],r])}for(let i of o.patch){let r={bumpType:"patch",name:i,stoneId:o.id,tag:o.tag};t.set(i,[...t.get(i)||[],r])}}let n=[];for(let[o,i]of t)if(i.length>1){let r=new Set(i.map((a)=>a.bumpType)),s=new Set(i.map((a)=>a.tag).filter(Boolean));if(r.size>1||s.size>1)n.push({conflicts:i,packageName:o})}return n}async function jo(e,t="highest"){let n=[];for(let o of e){if(t==="highest"){let i=o.conflicts.reduce((r,s)=>yt[s.bumpType]>yt[r.bumpType]?s:r);o.resolution={chosenBumpType:i.bumpType,chosenStoneId:i.stoneId,reason:"Highest bump type selected"}}else{let i=o.conflicts.map((s)=>({label:`${s.bumpType} from ${s.stoneId}${s.tag?` (${s.tag})`:""}`,value:s}));console.log(`
988
- ${p.warning("Conflict detected")} for ${p.value(o.packageName)}:`);for(let s of o.conflicts)console.log(` ${p.dim("\u2022")} ${s.bumpType} from ${s.stoneId}${s.tag?` (${s.tag})`:""}`);let r=await V({message:"How should this conflict be resolved?",options:[{label:"Use highest bump type",value:"highest"},...i]});if(r&&r==="highest"){let s=o.conflicts.reduce((a,c)=>yt[c.bumpType]>yt[a.bumpType]?c:a);o.resolution={chosenBumpType:s.bumpType,chosenStoneId:s.stoneId,reason:"Highest bump type selected"}}else if(r&&typeof r==="object"){let s=r;o.resolution={chosenBumpType:s.bumpType,chosenStoneId:s.stoneId,reason:"Manually selected"}}}n.push(o)}return n}function Io(e,t){let n={major:new Set,minor:new Set,patch:new Set,tags:{}},o=new Map;for(let i of t)if(i.resolution){let{chosenBumpType:r}=i.resolution,s=i.conflicts.find((a)=>a.stoneId===i.resolution?.chosenStoneId);o.set(i.packageName,{bumpType:r,tag:s?.tag})}for(let i of e){for(let r of i.major){let s=o.get(r);if(s){switch(s.bumpType){case"major":n.major.add(r);break;case"minor":n.minor.add(r);break;case"patch":n.patch.add(r);break}if(s.tag)n.tags[r]=s.tag}else n.major.add(r)}for(let r of i.minor)if(!o.has(r))n.minor.add(r);for(let r of i.patch)if(!o.has(r))n.patch.add(r)}return{major:Array.from(n.major),minor:Array.from(n.minor),patch:Array.from(n.patch),tags:n.tags}}var Po=v({prefix:"sisyphus"}).child("stone:merge");async function Ao(e){let{values:t}=pc({allowPositionals:!0,args:process.argv.slice(4),options:{force:{short:"f",type:"boolean"},ids:{multiple:!0,short:"i",type:"string"},message:{short:"m",type:"string"},strategy:{short:"s",type:"string"}}}),{ids:n,message:o,force:i,strategy:r}=t;try{let a=(await j()).stonesPath||".sisyphus/stones",c=await D();if(c.length<2){$.info("Need at least 2 stones to merge");return}let l=[];if(n&&n.length>=2){for(let C of n)if(c.includes(C)){let S=fn(a,`${C}.md`),R=await _o(S,"utf-8"),q=ve(R);l.push({id:C,path:S,...q})}if(l.length<2)Po.error("Could not find all specified stones"),process.exit(1)}else{let C=[];for(let R of c){let q=fn(a,`${R}.md`),Y=await _o(q,"utf-8"),se=ve(Y);C.push({label:`${R} - ${se.commitMessage}`,value:{id:R,path:q,...se}})}let S=await F({message:"Select stones to merge",options:C,required:!0});if(!S||Array.isArray(S)&&S.length<2){$.info("Need to select at least 2 stones");return}l=S}let m=o||await L({message:"Commit message for merged stone",placeholder:"feat: combined changes"});if(!m||typeof m!=="string"){$.info("Merge cancelled");return}let u=Ro(l),g;if(u.length>0){P(`Found ${p.value(String(u.length))} package conflict(s):
989
- `+u.map((R)=>` ${p.dim("\u2022")} ${R.packageName}`).join(`
990
- `),p.warning("Conflicts detected"));let S=await jo(u,r==="highest"||r==="interactive"?r:"highest");if(g=Io(l,S),S.length>0){let R=S.filter((q)=>q.resolution).map((q)=>` ${p.dim("\u2022")} ${q.packageName}: ${q.resolution?.chosenBumpType} (${q.resolution?.reason})`).join(`
991
- `);P(R,p.success("Conflicts resolved"))}}else{let C={major:[],minor:[],patch:[]};for(let S of l)C.major.push(...S.major),C.minor.push(...S.minor),C.patch.push(...S.patch);g={major:[...new Set(C.major)],minor:[...new Set(C.minor)],patch:[...new Set(C.patch)],tags:{}}}let w=[];for(let C of l)if(C.description)w.push(C.description);let y=`merged-${Date.now()}`,b=fn(a,`${y}.md`),x=`### ${m}
992
- `,k=[...new Set(Object.values(g.tags))];if(k.length===1)x+=`_${k[0]}_
197
+ `),$.success(`Created promotion stone: ${l.bold(d)}`),$.info(`Run ${l.value("sisyphus roll")} to publish the promotion`)}function qc(n){switch(n){case"alpha":return"Early development, unstable";case"beta":return"Feature complete, testing";case"rc":return"Release candidate, final testing";case"canary":return"Latest commit builds";case"dev":return"Development builds";case"next":return"Next version preview";default:return""}}async function zc(n,o){if(await tn({message:"Select packages for prerelease",options:[{label:"All packages",value:"all"},{label:"Select specific packages",value:"select"}]})==="all")return n;$.info("Select packages (space to select, enter to confirm)");let s=[];for(let t of n)if(await N({initialValue:!1,message:`Include ${t} (${o[t].version})?`}))s.push(t);return s}U();M();_();H();import{parseArgs as Jc}from"util";var kc=R({prefix:"sisyphus"}).child("preview");async function Ls(){let{values:n}=Jc({args:process.argv.slice(3),options:{"include-private":{type:"boolean"},json:{short:"j",type:"boolean"},verbose:{short:"v",type:"boolean"}}}),{json:o,verbose:i,"include-private":s=!1}=n;try{let t=await P(),e=await Wn();if(e.length===0){if(o)console.log(JSON.stringify({message:"No pending stones found"}));else $.info("No pending stones found. Nothing to preview.");return}let{packages:r}=await q({includePrivate:Boolean(s)}),a={},c=[];for(let{tag:f,packages:m,message:d}of e){c.push(d);for(let w of m){if(!a[w.name])a[w.name]={...w};let u=a[w.name];if(!u)continue;if(f)u.tag=f;u.bump=wn.indexOf(w.bump)>wn.indexOf(u.bump)?w.bump:u.bump,a[w.name]=u}}let p=Object.entries(a).map(([f,m])=>{let d=r[f]?.version||"0.0.0",[w="0",u="0",g="0"]=d.split("."),y=d;switch(m.bump){case"major":y=`${Number.parseInt(w,10)+1}.0.0`;break;case"minor":y=`${w}.${Number.parseInt(u,10)+1}.0`;break;case"patch":case"dependency":y=`${w}.${u}.${Number.parseInt(g,10)+1}`;break;case"snapshot":{let x=new Date().toISOString().replace(/[.ZT:-]/g,"").slice(0,14);y=`0.0.0-${m.tag||"nightly"}-${x}`;break}}if(m.tag&&m.bump!=="snapshot")y=`${y}-${m.tag}.0`;return{bump:m.bump,currentVersion:d,name:f,newVersion:y,tag:m.tag}});if(o){console.log(JSON.stringify({messages:c,stones:e.length,updates:p},null,2));return}$.info(`Preview of release with ${l.bold(String(e.length))} stone${e.length>1?"s":""}`),console.log(),console.log(l.bold("Commit Messages:")),c.forEach((f)=>{console.log(` ${l.bullet("\u2022")} ${f}`)}),console.log(),console.log(l.bold("Version Updates:"));for(let f of p){let m=f.bump==="major"?l.error:f.bump==="minor"?l.warning:l.success;console.log(` ${l.value(f.name)}`),console.log(` ${l.dim("Current:")} ${f.currentVersion}`),console.log(` ${l.dim("New:")} ${l.bold(f.newVersion)}`),console.log(` ${l.dim("Bump:")} ${m(f.bump)}${f.tag?` (${l.value(f.tag)})`:""}`),console.log()}if(i)console.log(l.bold("Additional Information:")),console.log(` ${l.dim("Config path:")} ${t.configPath||".sisyphus"}`),console.log(` ${l.dim("Total packages:")} ${Object.keys(r).length}`),console.log(` ${l.dim("Packages to update:")} ${p.length}`)}catch(t){kc.error("Failed to preview release:",t),process.exit(1)}}U();M();H();import{parseArgs as Yc}from"util";var{$:jo}=globalThis.Bun;var Wc=R({prefix:"sisyphus:solo"});async function Ns(){let{values:n}=Yc({args:process.argv.slice(3),options:{"dry-run":{short:"d",type:"boolean"},tag:{short:"t",type:"string"}}}),{"dry-run":o,tag:i}=n;mn(`${l.command("sisyphus solo")} - Single maintainer workflow`);let s=Pn();s.start("Creating version from commits and rolling immediately...");try{let t=await jo`git describe --tags --abbrev=0 2>/dev/null || echo ""`.text(),e=await jo`git rev-list ${t?`${t.trim()}..HEAD`:"HEAD"} --count`.text();if(Number.parseInt(e.trim(),10)===0){s.stop("No commits to release"),J(l.dim("Already up to date"));return}s.message("Analyzing commits...");let r=["bunx","@r5n/sisyphus","version","--from-commits","--yes"];if(o)r.push("--dry-run");if(await jo`${r}`,((await P()).stones||[]).length===0&&!o){s.stop("No releasable changes found"),J(l.dim("No version bumps needed"));return}s.message(o?"Previewing release...":"Rolling stones...");let p=["bunx","@r5n/sisyphus","roll"];if(o)p.push("--dry-run");if(i)p.push("--tag",i);await jo`${p}`,s.stop("Release complete!"),J(l.success("Published successfully"))}catch(t){s.stop("Solo release failed"),Wc.error("Failed to complete solo workflow",t),J(l.error(`Solo release failed: ${t}`)),process.exit(1)}}M();_();U();M();_();H();import{existsSync as Kc}from"fs";import{unlink as Xc}from"fs/promises";import{join as Zc}from"path";import{parseArgs as Qc}from"util";var Xn=R({prefix:"sisyphus"}).child("stone:delete");async function Hs(n){if(!n)Xn.error("Stone ID is required"),Xn.error("Usage: sisyphus stone delete <id>"),process.exit(1);let{values:o}=Qc({args:process.argv.slice(5),options:{force:{short:"f",type:"boolean"}}}),{force:i}=o;try{let t=(await P()).stonesPath||".sisyphus/stones",e=Zc(t,`${n}.md`);if(!Kc(e))Xn.error(`Stone '${n}' not found`),Xn.info("Run 'sisyphus stone list' to see available stones"),process.exit(1);if(!i){if(!await N({initialValue:!1,message:`Delete stone '${n}'?`})){$.info("Deletion cancelled");return}}await Xc(e),$.success(`Stone '${l.bold(n)}' deleted`)}catch(s){Xn.error(`Failed to delete stone '${n}':`,s),process.exit(1)}}U();M();_();H();import{existsSync as Vc}from"fs";import{readFile as Fc,writeFile as Dc}from"fs/promises";import{join as np}from"path";import{parseArgs as op}from"util";var Tn=R({prefix:"sisyphus"}).child("stone:edit");async function Gs(n){if(!n)Tn.error("Stone ID is required"),Tn.error("Usage: sisyphus stone edit <id>"),process.exit(1);let{values:o}=op({args:process.argv.slice(5),options:{interactive:{short:"i",type:"boolean"},message:{short:"m",type:"string"}}}),{message:i,interactive:s}=o;try{let e=(await P()).stonesPath||".sisyphus/stones",r=np(e,`${n}.md`);if(!Vc(r))Tn.error(`Stone '${n}' not found`),Tn.info("Run 'sisyphus stone list' to see available stones"),process.exit(1);let a=await Fc(r,"utf-8");if(i){let c=a.split(`
198
+ `);c[0]=`### ${i}`,await Dc(r,c.join(`
199
+ `)),$.success(`Updated commit message for stone '${l.bold(n)}'`);return}if(s){$.info("Interactive stone editing coming soon"),$.info("For now, you can manually edit:"),$.info(l.dim(r));return}Tn.error("Please specify --message or --interactive"),process.exit(1)}catch(t){Tn.error(`Failed to edit stone '${n}':`,t),process.exit(1)}}M();var Us={delete:{description:"Remove a specific stone before rolling",examples:[{command:"sisyphus stone delete stone-123",description:"Delete a stone by ID"},{command:"sisyphus stone delete stone-123 --force",description:"Delete without confirmation"}],name:"sisyphus stone delete",options:[{description:"Skip confirmation prompt",flags:"-f, --force",type:"boolean"}],usage:"sisyphus stone delete <id> [options]"},edit:{description:"Modify stone content or version bumps",examples:[{command:"sisyphus stone edit stone-123 --interactive",description:"Edit stone interactively"},{command:'sisyphus stone edit stone-123 --message "feat: better description"',description:"Update commit message"}],name:"sisyphus stone edit",options:[{description:"New commit message",flags:"-m, --message",type:"string"},{description:"Edit in interactive mode",flags:"-i, --interactive",type:"boolean"}],usage:"sisyphus stone edit <id> [options]"},list:{description:"View all pending stones with details",examples:[{command:"sisyphus stone list",description:"List all pending stones"},{command:"sisyphus stone list --verbose",description:"Show full stone content"},{command:"sisyphus stone list --json",description:"Output as JSON for scripting"}],name:"sisyphus stone list",options:[{description:"Output in JSON format",flags:"-j, --json",type:"boolean"},{description:"Show full stone content",flags:"-v, --verbose",type:"boolean"}],usage:"sisyphus stone list [options]"},merge:{description:"Combine multiple stones with smart conflict resolution",examples:[{command:"sisyphus stone merge",description:"Merge stones interactively"},{command:"sisyphus stone merge --ids stone-123 stone-456",description:"Merge specific stones"},{command:"sisyphus stone merge --strategy highest",description:"Merge with automatic conflict resolution"},{command:'sisyphus stone merge --strategy interactive --message "feat: combined changes"',description:"Merge with interactive conflict resolution"}],name:"sisyphus stone merge",notes:["Detects when same package has different bump types across stones","Default strategy uses highest bump type (major > minor > patch)","Interactive strategy lets you choose resolution for each conflict"],options:[{description:"Stone IDs to merge (multiple)",flags:"-i, --ids",type:"string"},{description:"Commit message for merged stone",flags:"-m, --message",type:"string"},{description:"Skip confirmation",flags:"-f, --force",type:"boolean"},{description:"Conflict resolution (highest/interactive)",flags:"-s, --strategy",type:"string"}],usage:"sisyphus stone merge [options]"},show:{description:"Display full content of a specific stone",examples:[{command:"sisyphus stone show stone-123",description:"Show stone content"},{command:"sisyphus stone show stone-123 --json",description:"Output as JSON"}],name:"sisyphus stone show",options:[{description:"Output in JSON format",flags:"-j, --json",type:"boolean"}],usage:"sisyphus stone show <id> [options]"}};function Ro(n){if(n&&Us[n]){console.log(ao(Us[n]));return}console.log(co("Sisyphus Stone Management","sisyphus stone <command> [options]",[{description:"View all pending stones with details",name:"list"},{description:"Remove a specific stone by ID",name:"delete"},{description:"Display full content of a stone",name:"show"},{description:"Modify stone content or versions",name:"edit"},{description:"Combine multiple stones into one",name:"merge"},{description:"Show this help message",name:"help"}],"Use sisyphus stone <command> --help for more information about a command."))}U();M();_();H();import{readFile as rp}from"fs/promises";import{join as ip}from"path";import{parseArgs as sp}from"util";var qs=R({prefix:"sisyphus"}).child("stone:list");async function zs(){let{values:n}=sp({args:process.argv.slice(4),options:{json:{short:"j",type:"boolean"},verbose:{short:"v",type:"boolean"}}}),{json:o,verbose:i}=n;try{let t=(await P()).stonesPath||".sisyphus/stones",e=await on();if(e.length===0){if(o)console.log(JSON.stringify([]));else $.info("No pending stones found");return}let r=[];for(let a of e){let c=ip(t,`${a}.md`);try{let p=await rp(c,"utf-8"),f=vn(p);r.push({id:a,path:c,...f})}catch(p){qs.warn(`Failed to read stone ${a}:`,p)}}if(o){console.log(JSON.stringify(r,null,2));return}$.info(`Found ${l.bold(String(r.length))} pending stone${r.length>1?"s":""}`),console.log();for(let[a,c]of r.entries()){if(console.log(`${l.bullet("\u2022")} ${l.bold(c.id)}`),console.log(` ${l.dim("Message:")} ${c.commitMessage}`),c.tag)console.log(` ${l.dim("Tag:")} ${l.value(c.tag)}`);if(c.major.length>0)console.log(` ${l.error("Major:")} ${c.major.join(", ")}`);if(c.minor.length>0)console.log(` ${l.warning("Minor:")} ${c.minor.join(", ")}`);if(c.patch.length>0)console.log(` ${l.success("Patch:")} ${c.patch.join(", ")}`);if(i&&c.description)console.log(` ${l.dim("Description:")}`),c.description.split(`
200
+ `).forEach((p)=>{console.log(` ${l.dim(p)}`)});if(a<r.length-1)console.log()}}catch(s){qs.error("Failed to list stones:",s),process.exit(1)}}U();M();_();H();import{readFile as Ws,unlink as Ks,writeFile as tp}from"fs/promises";import{join as _r}from"path";import{parseArgs as ep}from"util";U();M();_n();var Eo={major:4,minor:3,patch:2,dependency:1,snapshot:5};function Js(n){let o=new Map;for(let s of n){for(let t of s.major){let e={bumpType:"major",name:t,stoneId:s.id,tag:s.tag};o.set(t,[...o.get(t)||[],e])}for(let t of s.minor){let e={bumpType:"minor",name:t,stoneId:s.id,tag:s.tag};o.set(t,[...o.get(t)||[],e])}for(let t of s.patch){let e={bumpType:"patch",name:t,stoneId:s.id,tag:s.tag};o.set(t,[...o.get(t)||[],e])}}let i=[];for(let[s,t]of o)if(t.length>1){let e=new Set(t.map((a)=>a.bumpType)),r=new Set(t.map((a)=>a.tag).filter(Boolean));if(e.size>1||r.size>1)i.push({conflicts:t,packageName:s})}return i}async function ks(n,o="highest"){let i=[];for(let s of n){if(o==="highest"){let t=s.conflicts.reduce((e,r)=>Eo[r.bumpType]>Eo[e.bumpType]?r:e);s.resolution={chosenBumpType:t.bumpType,chosenStoneId:t.stoneId,reason:"Highest bump type selected"}}else{let t=s.conflicts.map((r)=>({label:`${r.bumpType} from ${r.stoneId}${r.tag?` (${r.tag})`:""}`,value:r}));console.log(`
201
+ ${l.warning("Conflict detected")} for ${l.value(s.packageName)}:`);for(let r of s.conflicts)console.log(` ${l.dim("\u2022")} ${r.bumpType} from ${r.stoneId}${r.tag?` (${r.tag})`:""}`);let e=await tn({message:"How should this conflict be resolved?",options:[{label:"Use highest bump type",value:"highest"},...t]});if(e&&e==="highest"){let r=s.conflicts.reduce((a,c)=>Eo[c.bumpType]>Eo[a.bumpType]?c:a);s.resolution={chosenBumpType:r.bumpType,chosenStoneId:r.stoneId,reason:"Highest bump type selected"}}else if(e&&typeof e==="object"){let r=e;s.resolution={chosenBumpType:r.bumpType,chosenStoneId:r.stoneId,reason:"Manually selected"}}}i.push(s)}return i}function Ys(n,o){let i={major:new Set,minor:new Set,patch:new Set,tags:{}},s=new Map;for(let t of o)if(t.resolution){let{chosenBumpType:e}=t.resolution,r=t.conflicts.find((a)=>a.stoneId===t.resolution?.chosenStoneId);s.set(t.packageName,{bumpType:e,tag:r?.tag})}for(let t of n){for(let e of t.major){let r=s.get(e);if(r){switch(r.bumpType){case"major":i.major.add(e);break;case"minor":i.minor.add(e);break;case"patch":i.patch.add(e);break}if(r.tag)i.tags[e]=r.tag}else i.major.add(e)}for(let e of t.minor)if(!s.has(e))i.minor.add(e);for(let e of t.patch)if(!s.has(e))i.patch.add(e)}return{major:Array.from(i.major),minor:Array.from(i.minor),patch:Array.from(i.patch),tags:i.tags}}var Xs=R({prefix:"sisyphus"}).child("stone:merge");async function Zs(n){let{values:o}=ep({allowPositionals:!0,args:process.argv.slice(4),options:{force:{short:"f",type:"boolean"},ids:{multiple:!0,short:"i",type:"string"},message:{short:"m",type:"string"},strategy:{short:"s",type:"string"}}}),{ids:i,message:s,force:t,strategy:e}=o;try{let a=(await P()).stonesPath||".sisyphus/stones",c=await on();if(c.length<2){$.info("Need at least 2 stones to merge");return}let p=[];if(i&&i.length>=2){for(let S of i)if(c.includes(S)){let v=_r(a,`${S}.md`),I=await Ws(v,"utf-8"),E=vn(I);p.push({id:S,path:v,...E})}if(p.length<2)Xs.error("Could not find all specified stones"),process.exit(1)}else{let S=[];for(let I of c){let E=_r(a,`${I}.md`),C=await Ws(E,"utf-8"),an=vn(C);S.push({label:`${I} - ${an.commitMessage}`,value:{id:I,path:E,...an}})}let v=await In({message:"Select stones to merge",options:S,required:!0});if(!v||Array.isArray(v)&&v.length<2){$.info("Need to select at least 2 stones");return}p=v}let f=s||await k({message:"Commit message for merged stone",placeholder:"feat: combined changes"});if(!f||typeof f!=="string"){$.info("Merge cancelled");return}let m=Js(p),d;if(m.length>0){B(`Found ${l.value(String(m.length))} package conflict(s):
202
+ `+m.map((I)=>` ${l.dim("\u2022")} ${I.packageName}`).join(`
203
+ `),l.warning("Conflicts detected"));let v=await ks(m,e==="highest"||e==="interactive"?e:"highest");if(d=Ys(p,v),v.length>0){let I=v.filter((E)=>E.resolution).map((E)=>` ${l.dim("\u2022")} ${E.packageName}: ${E.resolution?.chosenBumpType} (${E.resolution?.reason})`).join(`
204
+ `);B(I,l.success("Conflicts resolved"))}}else{let S={major:[],minor:[],patch:[]};for(let v of p)S.major.push(...v.major),S.minor.push(...v.minor),S.patch.push(...v.patch);d={major:[...new Set(S.major)],minor:[...new Set(S.minor)],patch:[...new Set(S.patch)],tags:{}}}let w=[];for(let S of p)if(S.description)w.push(S.description);let g=`merged-${Date.now()}`,y=_r(a,`${g}.md`),x=`### ${f}
205
+ `,j=[...new Set(Object.values(d.tags))];if(j.length===1)x+=`_${j[0]}_
993
206
  `;if(w.length>0)x+=`
994
207
  ${w.join(`
995
208
 
@@ -997,24 +210,24 @@ ${w.join(`
997
210
  `;if(x+=`
998
211
  ---
999
212
 
1000
- `,g.major.length>0||g.minor.length>0||g.patch.length>0){let C=[],S=[];if(g.major.length>0)C.push("major"),S.push(g.major.join(", "));if(g.minor.length>0)C.push("minor"),S.push(g.minor.join(", "));if(g.patch.length>0)C.push("patch"),S.push(g.patch.join(", "));x+=`| ${C.join(" | ")} |
1001
- `,x+=`| ${C.map(()=>":---:").join(" | ")} |
1002
- `,x+=`| ${S.join(" | ")} |
1003
- `}if(await lc(b,x),!i){if(await A({initialValue:!0,message:"Delete original stones?"}))for(let S of l)await Eo(S.path)}else for(let C of l)await Eo(C.path);$.success(`Created merged stone: ${p.bold(y)}`)}catch(s){Po.error("Failed to merge stones:",s),process.exit(1)}}E();I();B();import{existsSync as mc}from"fs";import{readFile as uc}from"fs/promises";import{join as fc}from"path";import{parseArgs as dc}from"util";var Ue=v({prefix:"sisyphus"}).child("stone:show");async function Bo(e){if(!e)Ue.error("Stone ID is required"),Ue.error("Usage: sisyphus stone show <id>"),process.exit(1);let{values:t}=dc({args:process.argv.slice(5),options:{json:{short:"j",type:"boolean"}}}),{json:n}=t;try{let i=(await j()).stonesPath||".sisyphus/stones",r=fc(i,`${e}.md`);if(!mc(r))Ue.error(`Stone '${e}' not found`),Ue.info("Run 'sisyphus stone list' to see available stones"),process.exit(1);let s=await uc(r,"utf-8");if(n){let a=ve(s);console.log(JSON.stringify({id:e,path:r,...a,raw:s},null,2));return}console.log(p.bold(`Stone: ${e}`)),console.log(p.dim(`Path: ${r}`)),console.log(p.dim("\u2500".repeat(50))),console.log(),console.log(s)}catch(o){Ue.error(`Failed to show stone '${e}':`,o),process.exit(1)}}var bt=["list","delete","show","edit","merge","help"],_e=v({prefix:"sisyphus"}).child("stone"),hc={combine:"merge",del:"delete",display:"show",join:"merge",ls:"list",modify:"edit",remove:"delete",rm:"delete",update:"edit",view:"show"};async function Mo(){let[,,,e,...t]=process.argv;if(!e||e==="--help"||e==="-h"){gt();return}let n=e;if(!bt.includes(e)){let o=tt(e,hc);if(o&&bt.includes(o))n=o,_e.warn(`Assuming you meant '${o}'`)}if(!bt.includes(n)){_e.error(`Unknown stone command: ${e}`);let o=et(e,bt);if(o.length>0){_e.error("Did you mean one of these?");for(let i of o)_e.error(` ${i}`)}_e.error("Run 'sisyphus stone --help' for usage information"),process.exit(1)}if(t.includes("--help")||t.includes("-h")){gt(n);return}try{switch(n){case"list":await ko();break;case"delete":await vo(t[0]);break;case"show":await Bo(t[0]);break;case"edit":await xo(t[0]);break;case"merge":await Ao(t);break;case"help":{let o=t[0];gt(o);break}default:throw new Error(`Unknown stone command: ${n}`)}}catch(o){_e.error(`Failed to execute stone ${n}:`,o),process.exit(1)}}M();I();import{parseArgs as $c}from"util";B();M();E();I();B();var{$:Oo}=globalThis.Bun;var gc=v({prefix:"sisyphus"}).child("from-commits"),yc=/^(\w+)(?:\(([^)]+)\))?(!)?: (.+)$/,Go={build:"patch",chore:"patch",ci:"patch",docs:"patch",feat:"minor",fix:"patch",perf:"patch",refactor:"patch",style:"patch",test:"patch"};async function Ho(e){try{let n=(await j()).lastStone?.commit||"",o=n?`${n}..HEAD`:"HEAD",{stdout:i}=await Oo`git log ${o} --pretty=format:"%H|%s" --no-merges`.quiet();if(!i.toString().trim())return $.info("No commits found since last release"),[];let r=i.toString().trim().split(`
1004
- `),s=[];for(let c of r){let[l,m]=c.split("|");if(!l||!m)continue;let u=bc(l,m);if(u){let{stdout:g}=await Oo`git diff-tree --no-commit-id --name-only -r ${l}`.quiet();u.files=g.toString().trim().split(`
1005
- `).filter(Boolean),s.push(u)}}if(s.length===0)return $.info("No conventional commits found"),[];let a=await wc(s,e);return $.info(`Found ${p.bold(String(s.length))} conventional commits`),$.info(`Creating ${p.bold(String(a.length))} stone${a.length>1?"s":""}`),a}catch(t){throw gc.error("Failed to analyze commits:",t),t}}function bc(e,t){let n=t.match(yc);if(!n)return null;let[,o="",i,r,s=""]=n;if(!o||!Go[o])return null;return{breaking:!!r,files:[],hash:e,message:s,scope:i,type:o}}async function wc(e,t){let{packages:n}=await Promise.resolve().then(() => (B(),rn)).then((r)=>r.getPackages({filter:t})),o=new Map;for(let[r,s]of Object.entries(n)){let a=s.file.substring(0,s.file.lastIndexOf("/"));o.set(a,r)}let i=new Map;for(let r of e){let s=new Set;for(let m of r.files)for(let[u,g]of o.entries())if(m.startsWith(u))s.add(g);if(s.size===0)continue;let a;if(r.breaking)a="major";else a=Go[r.type]||"patch";let c=`${r.type}${r.breaking?"!":""}`;if(!i.has(c)){let m=r.breaking?"feat!: breaking changes":`${r.type}: ${r.type} updates`;i.set(c,{bump:a,message:m,packages:new Set})}let l=i.get(c);if(l)for(let m of s)l.packages.add(m)}return Array.from(i.values()).filter((r)=>r.packages.size>0)}function vc(){let{values:e}=$c({allowPositionals:!0,args:process.argv.slice(3),options:{bump:{default:"",short:"b",type:"string"},dryRun:{default:!1,short:"d",type:"boolean"},filter:{default:"",short:"f",type:"string"},"from-commits":{default:!1,type:"boolean"},"include-private":{default:!1,type:"boolean"},snapshot:{default:!1,short:"s",type:"boolean"},tag:{default:"",short:"t",type:"string"},yes:{default:!1,short:"y",type:"boolean"}},strict:!1});return e}function xc(e){let{snapshot:t,bump:n}=e;if(t&&n)throw new Error(`Cannot use both ${f.cyanBright("--snapshot")} and ${f.cyanBright("--bump")} options, pick one.`)}async function Cc(){let e=await A({active:"Yes, continue",inactive:"No, cancel",message:"Are you sure you want to create a new stone?"});if(!e||oe(e))throw new Error("Operation cancelled by user")}async function Sc(e,t,n){await Bun.write(`.sisyphus/stones/${e}.md`,t.join(`
1006
- `)),await Bun.write(".sisyphus/config.json",`${JSON.stringify(n,null,2)}
1007
- `)}async function To(){try{let e=vc();xc(e);let{dryRun:t}=sn(e);if(e["from-commits"]){await kc(e);return}let{packages:n,packageNames:o,privatePackageCount:i}=await G({filter:e.filter,includePrivate:e["include-private"]});if(i>0&&!e["include-private"])$.info(f.dim(`Note: ${i} private package${i>1?"s":""} excluded from versioning`));let{message:r,majorPackages:s,minorPackages:a,patchPackages:c}=await Ys({bump:e.bump,packageNames:o,packages:n,tag:e.tag}),{packages:l,stoneContent:m,stoneName:u}=await pe({majorPackages:s,message:r,minorPackages:a,packages:n,patchPackages:c,tag:e.tag});if($.step([`${e.dryRun?f.bold(f.yellow(`[dry-run]
1008
- `)):""}${f.italic("Changes preview:")}
1009
- `,`${f.italic("Stone: ")}${f.bold(r)}`,...l.map(Oe)].join(`
1010
- `)),t){$.info(`${f.bold(f.yellow("[dry-run]"))}
213
+ `,d.major.length>0||d.minor.length>0||d.patch.length>0){let S=[],v=[];if(d.major.length>0)S.push("major"),v.push(d.major.join(", "));if(d.minor.length>0)S.push("minor"),v.push(d.minor.join(", "));if(d.patch.length>0)S.push("patch"),v.push(d.patch.join(", "));x+=`| ${S.join(" | ")} |
214
+ `,x+=`| ${S.map(()=>":---:").join(" | ")} |
215
+ `,x+=`| ${v.join(" | ")} |
216
+ `}if(await tp(y,x),!t){if(await N({initialValue:!0,message:"Delete original stones?"}))for(let v of p)await Ks(v.path)}else for(let S of p)await Ks(S.path);$.success(`Created merged stone: ${l.bold(g)}`)}catch(r){Xs.error("Failed to merge stones:",r),process.exit(1)}}M();_();H();import{existsSync as ap}from"fs";import{readFile as cp}from"fs/promises";import{join as pp}from"path";import{parseArgs as lp}from"util";var Zn=R({prefix:"sisyphus"}).child("stone:show");async function Qs(n){if(!n)Zn.error("Stone ID is required"),Zn.error("Usage: sisyphus stone show <id>"),process.exit(1);let{values:o}=lp({args:process.argv.slice(5),options:{json:{short:"j",type:"boolean"}}}),{json:i}=o;try{let t=(await P()).stonesPath||".sisyphus/stones",e=pp(t,`${n}.md`);if(!ap(e))Zn.error(`Stone '${n}' not found`),Zn.info("Run 'sisyphus stone list' to see available stones"),process.exit(1);let r=await cp(e,"utf-8");if(i){let a=vn(r);console.log(JSON.stringify({id:n,path:e,...a,raw:r},null,2));return}console.log(l.bold(`Stone: ${n}`)),console.log(l.dim(`Path: ${e}`)),console.log(l.dim("\u2500".repeat(50))),console.log(),console.log(r)}catch(s){Zn.error(`Failed to show stone '${n}':`,s),process.exit(1)}}var Io=["list","delete","show","edit","merge","help"],Bn=R({prefix:"sisyphus"}).child("stone"),fp={combine:"merge",del:"delete",display:"show",join:"merge",ls:"list",modify:"edit",remove:"delete",rm:"delete",update:"edit",view:"show"};async function Vs(){let[,,,n,...o]=process.argv;if(!n||n==="--help"||n==="-h"){Ro();return}let i=n;if(!Io.includes(n)){let s=eo(n,fp);if(s&&Io.includes(s))i=s,Bn.warn(`Assuming you meant '${s}'`)}if(!Io.includes(i)){Bn.error(`Unknown stone command: ${n}`);let s=to(n,Io);if(s.length>0){Bn.error("Did you mean one of these?");for(let t of s)Bn.error(` ${t}`)}Bn.error("Run 'sisyphus stone --help' for usage information"),process.exit(1)}if(o.includes("--help")||o.includes("-h")){Ro(i);return}try{switch(i){case"list":await zs();break;case"delete":await Hs(o[0]);break;case"show":await Qs(o[0]);break;case"edit":await Gs(o[0]);break;case"merge":await Zs(o);break;case"help":{let s=o[0];Ro(s);break}default:throw Error(`Unknown stone command: ${i}`)}}catch(s){Bn.error(`Failed to execute stone ${i}:`,s),process.exit(1)}}U();_();import{parseArgs as dp}from"util";H();U();M();_();H();var{$:Fs}=globalThis.Bun;var mp=R({prefix:"sisyphus"}).child("from-commits"),up=/^(\w+)(?:\(([^)]+)\))?(!)?: (.+)$/,Ds={build:"patch",chore:"patch",ci:"patch",docs:"patch",feat:"minor",fix:"patch",perf:"patch",refactor:"patch",style:"patch",test:"patch"};async function nt(n){try{let i=(await P()).lastStone?.commit||"",s=i?`${i}..HEAD`:"HEAD",{stdout:t}=await Fs`git log ${s} --pretty=format:"%H|%s" --no-merges`.quiet();if(!t.toString().trim())return $.info("No commits found since last release"),[];let e=t.toString().trim().split(`
217
+ `),r=[];for(let c of e){let[p,f]=c.split("|");if(!p||!f)continue;let m=gp(p,f);if(m){let{stdout:d}=await Fs`git diff-tree --no-commit-id --name-only -r ${p}`.quiet();m.files=d.toString().trim().split(`
218
+ `).filter(Boolean),r.push(m)}}if(r.length===0)return $.info("No conventional commits found"),[];let a=await hp(r,n);return $.info(`Found ${l.bold(String(r.length))} conventional commits`),$.info(`Creating ${l.bold(String(a.length))} stone${a.length>1?"s":""}`),a}catch(o){throw mp.error("Failed to analyze commits:",o),o}}function gp(n,o){let i=o.match(up);if(!i)return null;let[,s="",t,e,r=""]=i;if(!s||!Ds[s])return null;return{breaking:!!e,files:[],hash:n,message:r,scope:t,type:s}}async function hp(n,o){let{packages:i}=await Promise.resolve().then(() => (H(),jr)).then((e)=>e.getPackages({filter:o})),s=new Map;for(let[e,r]of Object.entries(i)){let a=r.file.substring(0,r.file.lastIndexOf("/"));s.set(a,e)}let t=new Map;for(let e of n){let r=new Set;for(let f of e.files)for(let[m,d]of s.entries())if(f.startsWith(m))r.add(d);if(r.size===0)continue;let a;if(e.breaking)a="major";else a=Ds[e.type]||"patch";let c=`${e.type}${e.breaking?"!":""}`;if(!t.has(c)){let f=e.breaking?"feat!: breaking changes":`${e.type}: ${e.type} updates`;t.set(c,{bump:a,message:f,packages:new Set})}let p=t.get(c);if(p)for(let f of r)p.packages.add(f)}return Array.from(t.values()).filter((e)=>e.packages.size>0)}function yp(){let{values:n}=dp({allowPositionals:!0,args:process.argv.slice(3),options:{bump:{default:"",short:"b",type:"string"},dryRun:{default:!1,short:"d",type:"boolean"},filter:{default:"",short:"f",type:"string"},"from-commits":{default:!1,type:"boolean"},"include-private":{default:!1,type:"boolean"},snapshot:{default:!1,short:"s",type:"boolean"},tag:{default:"",short:"t",type:"string"},yes:{default:!1,short:"y",type:"boolean"}},strict:!1});return n}function bp(n){let{snapshot:o,bump:i}=n;if(o&&i)throw Error(`Cannot use both ${h.cyanBright("--snapshot")} and ${h.cyanBright("--bump")} options, pick one.`)}async function wp(){let n=await N({active:"Yes, continue",inactive:"No, cancel",message:"Are you sure you want to create a new stone?"});if(!n||yn(n))throw Error("Operation cancelled by user")}async function $p(n,o,i){await Bun.write(`.sisyphus/stones/${n}.md`,o.join(`
219
+ `)),await Bun.write(".sisyphus/config.json",`${JSON.stringify(i,null,2)}
220
+ `)}async function ot(){try{let n=yp();bp(n);let{dryRun:o}=Sr(n);if(n["from-commits"]){await xp(n);return}let{packages:i,packageNames:s,privatePackageCount:t}=await q({filter:n.filter,includePrivate:n["include-private"]});if(t>0&&!n["include-private"])$.info(h.dim(`Note: ${t} private package${t>1?"s":""} excluded from versioning`));let{message:e,majorPackages:r,minorPackages:a,patchPackages:c}=await Rs({bump:n.bump,packageNames:s,packages:i,tag:n.tag}),{packages:p,stoneContent:f,stoneName:m}=await hn({majorPackages:r,message:e,minorPackages:a,packages:i,patchPackages:c,tag:n.tag});if($.step([`${n.dryRun?h.bold(h.yellow(`[dry-run]
221
+ `)):""}${h.italic("Changes preview:")}
222
+ `,`${h.italic("Stone: ")}${h.bold(e)}`,...p.map(Jn)].join(`
223
+ `)),o){$.info(`${h.bold(h.yellow("[dry-run]"))}
1011
224
  Stone file preview:
1012
- ${m.join(`
1013
- `)}`);return}if(!e.yes)await Cc();let g=await j();g.stones.push(u),await Sc(u,m,g),P(`Now you can run ${f.green("bunx @r5n/sisyphus roll")} to release packages
1014
- or create another stone with ${f.green("bunx @r5n/sisyphus version")}`,`${f.bold("Stone ")}${f.italic(`${u}.md`)} ${f.green("created!")}`)}catch(e){je(e instanceof Error?e.message:String(e))}}async function kc(e){let t=await Ho(e.filter);if(t.length===0)return;let{packages:n,privatePackageCount:o}=await G({filter:e.filter});if(o>0)$.info(f.dim(`Note: ${o} private package${o>1?"s":""} excluded from versioning`));let i=await j(),r=0;for(let s of t){let a=[],c=[],l=[];for(let g of s.packages)switch(s.bump){case"major":a.push(g);break;case"minor":c.push(g);break;case"patch":case"dependency":l.push(g);break}let{stoneContent:m,stoneName:u}=await pe({majorPackages:a,message:s.message,minorPackages:c,packages:n,patchPackages:l,tag:e.tag});if(e.dryRun)$.info(`${f.bold(f.yellow("[dry-run]"))}
225
+ ${f.join(`
226
+ `)}`);return}if(!n.yes)await wp();let d=await P();d.stones.push(m),await $p(m,f,d),B(`Now you can run ${h.green("bunx @r5n/sisyphus roll")} to release packages
227
+ or create another stone with ${h.green("bunx @r5n/sisyphus version")}`,`${h.bold("Stone ")}${h.italic(`${m}.md`)} ${h.green("created!")}`)}catch(n){Cn(n instanceof Error?n.message:String(n))}}async function xp(n){let o=await nt(n.filter);if(o.length===0)return;let{packages:i,privatePackageCount:s}=await q({filter:n.filter});if(s>0)$.info(h.dim(`Note: ${s} private package${s>1?"s":""} excluded from versioning`));let t=await P(),e=0;for(let r of o){let a=[],c=[],p=[];for(let d of r.packages)switch(r.bump){case"major":a.push(d);break;case"minor":c.push(d);break;case"patch":case"dependency":p.push(d);break}let{stoneContent:f,stoneName:m}=await hn({majorPackages:a,message:r.message,minorPackages:c,packages:i,patchPackages:p,tag:n.tag});if(n.dryRun)$.info(`${h.bold(h.yellow("[dry-run]"))}
1015
228
  Stone file preview:
1016
- ${m.join(`
1017
- `)}`);else i.stones.push(u),await Bun.write(`.sisyphus/stones/${u}.md`,m.join(`
1018
- `)),r++}if(!e.dryRun&&r>0)await Bun.write(".sisyphus/config.json",`${JSON.stringify(i,null,2)}
1019
- `),P(`Created ${f.bold(String(r))} stone${r>1?"s":""} from commits.
1020
- Run ${f.green("bunx @r5n/sisyphus preview")} to see what will be released`,f.green("Success!"))}var wt=["init","check","changeset","version","roll","solo","stone","preview","prerelease","graph","metrics","insights","migrate","pr","setup","help"],We=v({prefix:"sisyphus"}),Rc={c:"check",change:"changeset",changes:"changeset",cheack:"check",chekc:"check",cs:"changeset",g:"graph",graf:"graph",grah:"graph",h:"help",i:"init",initialise:"init",inti:"init",intialize:"init",m:"metrics",metric:"metrics",mig:"migrate",migration:"migrate",p:"preview",pr:"prerelease",pre:"preview",preivew:"preview",prerelease:"prerelease",publish:"roll",r:"roll",relase:"release",release:"roll",rool:"roll",s:"stone",single:"solo",solo:"solo",st:"stone",state:"check",stats:"metrics",status:"check",stones:"stone",v:"version",ver:"version",verison:"version"};async function jc(){try{let[,,e,...t]=process.argv;if(e==="--version"||e==="-v"){console.log(de);return}if(rs("@r5n/sisyphus",de),!e||e==="--help"||e==="-h"){mt();return}let n=e;if(!wt.includes(e)){let o=tt(e,Rc);if(o&&wt.includes(o))n=o,We.warn(`Assuming you meant '${o}'`)}if(!wt.includes(n)){We.error(`Unknown command: ${e}`);let o=et(e,wt);if(o.length>0){We.error("Did you mean one of these?");for(let i of o)We.error(` ${i}`)}We.error("Run 'sisyphus --help' for usage information"),process.exit(1)}if(t.includes("--help")||t.includes("-h")){mt(n);return}switch(n){case"init":await Xs();break;case"check":await zs();break;case"changeset":await Gs();break;case"version":await To();break;case"roll":await Us();break;case"solo":await $o();break;case"stone":await Mo();break;case"preview":await ro();break;case"prerelease":await io();break;case"graph":await Ks();break;case"metrics":await to();break;case"insights":await Qs();break;case"migrate":await so();break;case"pr":await oo();break;case"setup":await ho();break;case"help":{let o=t[0];mt(o);break}default:throw new Error(`Unknown command: ${n}`)}process.exit(0)}catch(e){fs(e)}}await jc();
229
+ ${f.join(`
230
+ `)}`);else t.stones.push(m),await Bun.write(`.sisyphus/stones/${m}.md`,f.join(`
231
+ `)),e++}if(!n.dryRun&&e>0)await Bun.write(".sisyphus/config.json",`${JSON.stringify(t,null,2)}
232
+ `),B(`Created ${h.bold(String(e))} stone${e>1?"s":""} from commits.
233
+ Run ${h.green("bunx @r5n/sisyphus preview")} to see what will be released`,h.green("Success!"))}var Po=["init","check","changeset","version","roll","solo","stone","preview","prerelease","graph","metrics","insights","migrate","pr","help"],Qn=R({prefix:"sisyphus"}),Sp={c:"check",change:"changeset",changes:"changeset",cheack:"check",chekc:"check",cs:"changeset",g:"graph",graf:"graph",grah:"graph",h:"help",i:"init",initialise:"init",inti:"init",intialize:"init",m:"metrics",metric:"metrics",mig:"migrate",migration:"migrate",p:"preview",pr:"prerelease",pre:"preview",preivew:"preview",prerelease:"prerelease",publish:"roll",r:"roll",relase:"release",release:"roll",rool:"roll",s:"stone",single:"solo",solo:"solo",st:"stone",state:"check",stats:"metrics",status:"check",stones:"stone",v:"version",ver:"version",verison:"version"};async function vp(){try{let[,,n,...o]=process.argv;if(n==="--version"||n==="-v"){console.log(dn);return}if(gi("@r5n/sisyphus",dn),!n||n==="--help"||n==="-h"){vo();return}let i=n;if(!Po.includes(n)){let s=eo(n,Sp);if(s&&Po.includes(s))i=s,Qn.warn(`Assuming you meant '${s}'`)}if(!Po.includes(i)){Qn.error(`Unknown command: ${n}`);let s=to(n,Po);if(s.length>0){Qn.error("Did you mean one of these?");for(let t of s)Qn.error(` ${t}`)}Qn.error("Run 'sisyphus --help' for usage information"),process.exit(1)}if(o.includes("--help")||o.includes("-h")){vo(i);return}switch(i){case"init":await Es();break;case"check":await $s();break;case"changeset":await rs();break;case"version":await ot();break;case"roll":await bs();break;case"solo":await Ns();break;case"stone":await Vs();break;case"preview":await Ls();break;case"prerelease":await Ms();break;case"graph":await Ss();break;case"metrics":await Cs();break;case"insights":await Is();break;case"migrate":await Bs();break;case"pr":await As();break;case"help":{let s=o[0];vo(s);break}default:throw Error(`Unknown command: ${i}`)}process.exit(0)}catch(n){$i(n)}}await vp();