@automagik/genie 0.260202.400 → 0.260202.453
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/claudio.js +1 -1
- package/dist/genie.js +11 -4
- package/dist/term.js +50 -50
- package/package.json +1 -1
- package/src/lib/hook-script.ts +8 -1
- package/src/lib/tmux.ts +74 -0
- package/src/lib/version.ts +1 -1
- package/src/term-commands/exec.ts +14 -7
package/dist/claudio.js
CHANGED
|
@@ -27,7 +27,7 @@ Expecting one of '${E.join("', '")}'`);let B=`${D}Help`;return this.on(B,($)=>{l
|
|
|
27
27
|
`)$+=d3(q)}}return $};c3.exports=(D,F,E)=>{return String(D).normalize().replace(/\r\n/g,`
|
|
28
28
|
`).split(`
|
|
29
29
|
`).map((B)=>_1(B,F,E)).join(`
|
|
30
|
-
`)}});var s3=h((N7,o3)=>{var C1=VD("stream");class a3 extends C1{#E=null;constructor(D={}){super(D);this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=D.replace,this._prompt=D.prompt||null,this._hadControl=!1}#F(D,F){if(this._dest)return this._dest[D];if(this._src)return this._src[D];return F}#D(D,...F){if(typeof this._dest?.[D]==="function")this._dest[D](...F);if(typeof this._src?.[D]==="function")this._src[D](...F)}get isTTY(){if(this.#E!==null)return this.#E;return this.#F("isTTY",!1)}set isTTY(D){this.#E=D}get rows(){return this.#F("rows")}get columns(){return this.#F("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(D){this._src=D}pipe(D,F){return this._dest=D,super.pipe(D,F)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(D){if(this.muted){if(!this.replace)return!0;if(D.match(/^\u001b/)){if(D.indexOf(this._prompt)===0)D=D.slice(this._prompt.length),D=D.replace(/./g,this.replace),D=this._prompt+D;return this._hadControl=!0,this.emit("data",D)}else{if(this._prompt&&this._hadControl&&D.indexOf(this._prompt)===0)this._hadControl=!1,this.emit("data",this._prompt),D=D.slice(this._prompt.length);D=D.toString().replace(/./g,this.replace)}}this.emit("data",D)}end(D){if(this.muted)if(D&&this.replace)D=D.toString().replace(/./g,this.replace);else D=null;if(D)this.emit("data",D);this.emit("end")}destroy(...D){return this.#D("destroy",...D)}destroySoon(...D){return this.#D("destroySoon",...D)}close(...D){return this.#D("close",...D)}}o3.exports=a3});var J3=UD(X3(),1),{program:U5,createCommand:V5,createArgument:u5,createOption:K5,CommanderError:L5,InvalidArgumentError:N5,InvalidOptionArgumentError:O5,Command:Q3,Argument:w5,Option:S5,Help:I5}=J3.default;var Y3="0.260202.0400";var CD=(D,F=[])=>D.name==="up"||F.includes("vim")&&D.name==="k"||F.includes("emacs")&&D.ctrl&&D.name==="p",ID=(D,F=[])=>D.name==="down"||F.includes("vim")&&D.name==="j"||F.includes("emacs")&&D.ctrl&&D.name==="n",D0=(D)=>D.name==="space",F0=(D)=>D.name==="backspace",PD=(D)=>D.name==="tab",E0=(D)=>"1234567890".includes(D.name),t=(D)=>D.name==="enter"||D.name==="return";class B0 extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(D){super();this.cause=D?.cause}}class $0 extends Error{name="CancelPromptError";message="Prompt was canceled"}class I2 extends Error{name="ExitPromptError"}class q0 extends Error{name="HookError"}class Y2 extends Error{name="ValidationError"}import{AsyncResource as x6}from"async_hooks";import{AsyncLocalStorage as f6,AsyncResource as v6}from"async_hooks";var W3=new f6;function Z6(D){return{rl:D,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function H3(D,F){let E=Z6(D);return W3.run(E,()=>{function B($){E.handleChange=()=>{E.index=0,$()},E.handleChange()}return F(B)})}function TD(){let D=W3.getStore();if(!D)throw new q0("[Inquirer] Hook functions can only be called from within a prompt");return D}function X0(){return TD().rl}function J0(D){let F=(...E)=>{let B=TD(),$=!1,q=B.handleChange;B.handleChange=()=>{$=!0};let X=D(...E);if($)q();return B.handleChange=q,X};return v6.bind(F)}function lD(D){let F=TD(),{index:E}=F,B={get(){return F.hooks[E]},set(q){F.hooks[E]=q},initialized:E in F.hooks},$=D(B);return F.index++,$}function _3(){TD().handleChange()}var bD={queue(D){let F=TD(),{index:E}=F;F.hooksEffect.push(()=>{F.hooksCleanup[E]?.();let B=D(X0());if(B!=null&&typeof B!=="function")throw new Y2("useEffect return value must be a cleanup function or nothing.");F.hooksCleanup[E]=B})},run(){let D=TD();J0(()=>{D.hooksEffect.forEach((F)=>{F()}),D.hooksEffect.length=0})()},clearAll(){let D=TD();D.hooksCleanup.forEach((F)=>{F?.()}),D.hooksEffect.length=0,D.hooksCleanup.length=0}};function v(D){return lD((F)=>{let E=x6.bind(function(q){if(F.get()!==q)F.set(q),_3()});if(F.initialized)return[F.get(),E];let B=typeof D==="function"?D():D;return F.set(B),[B,E]})}function MD(D,F){lD((E)=>{let B=E.get();if(!Array.isArray(B)||F.some((q,X)=>!Object.is(q,B[X])))bD.queue(D);E.set(F)})}var i=UD(W2(),1);import QD from"process";function g6(){if(QD.platform!=="win32")return QD.env.TERM!=="linux";return Boolean(QD.env.WT_SESSION)||Boolean(QD.env.TERMINUS_SUBLIME)||QD.env.ConEmuTask==="{cmd::Cmder}"||QD.env.TERM_PROGRAM==="Terminus-Sublime"||QD.env.TERM_PROGRAM==="vscode"||QD.env.TERM==="xterm-256color"||QD.env.TERM==="alacritty"||QD.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var C3={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},M3={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},m6={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},l6={...C3,...M3},p6={...C3,...m6},d6=g6(),c6=d6?l6:p6,YD=c6,d5=Object.entries(M3);var R3={prefix:{idle:i.default.blue("?"),done:i.default.green(YD.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map((D)=>i.default.yellow(D))},style:{answer:i.default.cyan,message:i.default.bold,error:(D)=>i.default.red(`> ${D}`),defaultAnswer:(D)=>i.default.dim(`(${D})`),help:i.default.dim,highlight:i.default.cyan,key:(D)=>i.default.cyan(i.default.bold(`<${D}>`))}};function A3(D){if(typeof D!=="object"||D===null)return!1;let F=D;while(Object.getPrototypeOf(F)!==null)F=Object.getPrototypeOf(F);return Object.getPrototypeOf(D)===F}function j3(...D){let F={};for(let E of D)for(let[B,$]of Object.entries(E)){let q=F[B];F[B]=A3(q)&&A3($)?j3(q,$):$}return F}function n(...D){let F=[R3,...D.filter((E)=>E!=null)];return j3(...F)}function e({status:D="idle",theme:F}){let[E,B]=v(!1),[$,q]=v(0),{prefix:X,spinner:J}=n(F);if(MD(()=>{if(D==="loading"){let Y,W=-1,C=setTimeout(()=>{B(!0),Y=setInterval(()=>{W=W+1,q(W%J.frames.length)},J.interval)},300);return()=>{clearTimeout(C),clearInterval(Y)}}else B(!1)},[D]),E)return J.frames[$];return typeof X==="string"?X:X[D==="loading"?"idle":D]??X.idle}function H2(D,F){return lD((E)=>{let B=E.get();if(!B||B.dependencies.length!==F.length||B.dependencies.some(($,q)=>$!==F[q])){let $=D();return E.set({value:$,dependencies:F}),$}return B.value})}function P2(D){return v({current:D})[0]}function DD(D){let F=P2(D);F.current=D,MD((E)=>{let B=!1,$=J0((q,X)=>{if(B)return;F.current(X,E)});return E.input.on("keypress",$),()=>{B=!0,E.input.removeListener("keypress",$)}},[])}var i3=UD(U3(),1),r3=UD(n3(),1);function C2(D,F){return D.split(`
|
|
30
|
+
`)}});var s3=h((N7,o3)=>{var C1=VD("stream");class a3 extends C1{#E=null;constructor(D={}){super(D);this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=D.replace,this._prompt=D.prompt||null,this._hadControl=!1}#F(D,F){if(this._dest)return this._dest[D];if(this._src)return this._src[D];return F}#D(D,...F){if(typeof this._dest?.[D]==="function")this._dest[D](...F);if(typeof this._src?.[D]==="function")this._src[D](...F)}get isTTY(){if(this.#E!==null)return this.#E;return this.#F("isTTY",!1)}set isTTY(D){this.#E=D}get rows(){return this.#F("rows")}get columns(){return this.#F("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(D){this._src=D}pipe(D,F){return this._dest=D,super.pipe(D,F)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(D){if(this.muted){if(!this.replace)return!0;if(D.match(/^\u001b/)){if(D.indexOf(this._prompt)===0)D=D.slice(this._prompt.length),D=D.replace(/./g,this.replace),D=this._prompt+D;return this._hadControl=!0,this.emit("data",D)}else{if(this._prompt&&this._hadControl&&D.indexOf(this._prompt)===0)this._hadControl=!1,this.emit("data",this._prompt),D=D.slice(this._prompt.length);D=D.toString().replace(/./g,this.replace)}}this.emit("data",D)}end(D){if(this.muted)if(D&&this.replace)D=D.toString().replace(/./g,this.replace);else D=null;if(D)this.emit("data",D);this.emit("end")}destroy(...D){return this.#D("destroy",...D)}destroySoon(...D){return this.#D("destroySoon",...D)}close(...D){return this.#D("close",...D)}}o3.exports=a3});var J3=UD(X3(),1),{program:U5,createCommand:V5,createArgument:u5,createOption:K5,CommanderError:L5,InvalidArgumentError:N5,InvalidOptionArgumentError:O5,Command:Q3,Argument:w5,Option:S5,Help:I5}=J3.default;var Y3="0.260202.0453";var CD=(D,F=[])=>D.name==="up"||F.includes("vim")&&D.name==="k"||F.includes("emacs")&&D.ctrl&&D.name==="p",ID=(D,F=[])=>D.name==="down"||F.includes("vim")&&D.name==="j"||F.includes("emacs")&&D.ctrl&&D.name==="n",D0=(D)=>D.name==="space",F0=(D)=>D.name==="backspace",PD=(D)=>D.name==="tab",E0=(D)=>"1234567890".includes(D.name),t=(D)=>D.name==="enter"||D.name==="return";class B0 extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(D){super();this.cause=D?.cause}}class $0 extends Error{name="CancelPromptError";message="Prompt was canceled"}class I2 extends Error{name="ExitPromptError"}class q0 extends Error{name="HookError"}class Y2 extends Error{name="ValidationError"}import{AsyncResource as x6}from"async_hooks";import{AsyncLocalStorage as f6,AsyncResource as v6}from"async_hooks";var W3=new f6;function Z6(D){return{rl:D,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function H3(D,F){let E=Z6(D);return W3.run(E,()=>{function B($){E.handleChange=()=>{E.index=0,$()},E.handleChange()}return F(B)})}function TD(){let D=W3.getStore();if(!D)throw new q0("[Inquirer] Hook functions can only be called from within a prompt");return D}function X0(){return TD().rl}function J0(D){let F=(...E)=>{let B=TD(),$=!1,q=B.handleChange;B.handleChange=()=>{$=!0};let X=D(...E);if($)q();return B.handleChange=q,X};return v6.bind(F)}function lD(D){let F=TD(),{index:E}=F,B={get(){return F.hooks[E]},set(q){F.hooks[E]=q},initialized:E in F.hooks},$=D(B);return F.index++,$}function _3(){TD().handleChange()}var bD={queue(D){let F=TD(),{index:E}=F;F.hooksEffect.push(()=>{F.hooksCleanup[E]?.();let B=D(X0());if(B!=null&&typeof B!=="function")throw new Y2("useEffect return value must be a cleanup function or nothing.");F.hooksCleanup[E]=B})},run(){let D=TD();J0(()=>{D.hooksEffect.forEach((F)=>{F()}),D.hooksEffect.length=0})()},clearAll(){let D=TD();D.hooksCleanup.forEach((F)=>{F?.()}),D.hooksEffect.length=0,D.hooksCleanup.length=0}};function v(D){return lD((F)=>{let E=x6.bind(function(q){if(F.get()!==q)F.set(q),_3()});if(F.initialized)return[F.get(),E];let B=typeof D==="function"?D():D;return F.set(B),[B,E]})}function MD(D,F){lD((E)=>{let B=E.get();if(!Array.isArray(B)||F.some((q,X)=>!Object.is(q,B[X])))bD.queue(D);E.set(F)})}var i=UD(W2(),1);import QD from"process";function g6(){if(QD.platform!=="win32")return QD.env.TERM!=="linux";return Boolean(QD.env.WT_SESSION)||Boolean(QD.env.TERMINUS_SUBLIME)||QD.env.ConEmuTask==="{cmd::Cmder}"||QD.env.TERM_PROGRAM==="Terminus-Sublime"||QD.env.TERM_PROGRAM==="vscode"||QD.env.TERM==="xterm-256color"||QD.env.TERM==="alacritty"||QD.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var C3={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},M3={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},m6={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},l6={...C3,...M3},p6={...C3,...m6},d6=g6(),c6=d6?l6:p6,YD=c6,d5=Object.entries(M3);var R3={prefix:{idle:i.default.blue("?"),done:i.default.green(YD.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map((D)=>i.default.yellow(D))},style:{answer:i.default.cyan,message:i.default.bold,error:(D)=>i.default.red(`> ${D}`),defaultAnswer:(D)=>i.default.dim(`(${D})`),help:i.default.dim,highlight:i.default.cyan,key:(D)=>i.default.cyan(i.default.bold(`<${D}>`))}};function A3(D){if(typeof D!=="object"||D===null)return!1;let F=D;while(Object.getPrototypeOf(F)!==null)F=Object.getPrototypeOf(F);return Object.getPrototypeOf(D)===F}function j3(...D){let F={};for(let E of D)for(let[B,$]of Object.entries(E)){let q=F[B];F[B]=A3(q)&&A3($)?j3(q,$):$}return F}function n(...D){let F=[R3,...D.filter((E)=>E!=null)];return j3(...F)}function e({status:D="idle",theme:F}){let[E,B]=v(!1),[$,q]=v(0),{prefix:X,spinner:J}=n(F);if(MD(()=>{if(D==="loading"){let Y,W=-1,C=setTimeout(()=>{B(!0),Y=setInterval(()=>{W=W+1,q(W%J.frames.length)},J.interval)},300);return()=>{clearTimeout(C),clearInterval(Y)}}else B(!1)},[D]),E)return J.frames[$];return typeof X==="string"?X:X[D==="loading"?"idle":D]??X.idle}function H2(D,F){return lD((E)=>{let B=E.get();if(!B||B.dependencies.length!==F.length||B.dependencies.some(($,q)=>$!==F[q])){let $=D();return E.set({value:$,dependencies:F}),$}return B.value})}function P2(D){return v({current:D})[0]}function DD(D){let F=P2(D);F.current=D,MD((E)=>{let B=!1,$=J0((q,X)=>{if(B)return;F.current(X,E)});return E.input.on("keypress",$),()=>{B=!0,E.input.removeListener("keypress",$)}},[])}var i3=UD(U3(),1),r3=UD(n3(),1);function C2(D,F){return D.split(`
|
|
31
31
|
`).flatMap((E)=>r3.default(E,F,{trim:!1,hard:!0}).split(`
|
|
32
32
|
`).map((B)=>B.trimEnd())).join(`
|
|
33
33
|
`)}function k2(){return i3.default({defaultWidth:80,output:X0().output})}function G1({active:D,renderedItems:F,pageSize:E,loop:B}){let $=P2({lastPointer:D,lastActive:void 0}),{lastPointer:q,lastActive:X}=$.current,J=Math.floor(E/2),Q=F.reduce((C,U)=>C+U.length,0),Y=F.slice(0,D).reduce((C,U)=>C+U.length,0),W=Y;if(Q>E)if(B){if(W=q,X!=null&&X<D&&D-X<E)W=Math.min(J,Math.abs(D-X)===1?Math.min(q+(F[X]?.length??0),Math.max(Y,q)):q+D-X)}else{let C=F.slice(D).reduce((U,M)=>U+M.length,0);W=C<E-J?E-C:Math.min(Y,J)}return $.current.lastPointer=W,$.current.lastActive=D,W}function M2({items:D,active:F,renderItem:E,pageSize:B,loop:$=!0}){let q=k2(),X=(V)=>(V%D.length+D.length)%D.length,J=D.map((V,O)=>{if(V==null)return[];return C2(E({item:V,index:O,isActive:O===F}),q).split(`
|
package/dist/genie.js
CHANGED
|
@@ -27,7 +27,7 @@ Expecting one of '${B.join("', '")}'`);let E=`${D}Help`;return this.on(E,($)=>{l
|
|
|
27
27
|
`)$+=K8(X)}}return $};N8.exports=(D,F,B)=>{return String(D).normalize().replace(/\r\n/g,`
|
|
28
28
|
`).split(`
|
|
29
29
|
`).map((E)=>W1(E,F,B)).join(`
|
|
30
|
-
`)}});var I8=h((E4,u8)=>{var _1=YD("stream");class S8 extends _1{#B=null;constructor(D={}){super(D);this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=D.replace,this._prompt=D.prompt||null,this._hadControl=!1}#F(D,F){if(this._dest)return this._dest[D];if(this._src)return this._src[D];return F}#D(D,...F){if(typeof this._dest?.[D]==="function")this._dest[D](...F);if(typeof this._src?.[D]==="function")this._src[D](...F)}get isTTY(){if(this.#B!==null)return this.#B;return this.#F("isTTY",!1)}set isTTY(D){this.#B=D}get rows(){return this.#F("rows")}get columns(){return this.#F("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(D){this._src=D}pipe(D,F){return this._dest=D,super.pipe(D,F)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(D){if(this.muted){if(!this.replace)return!0;if(D.match(/^\u001b/)){if(D.indexOf(this._prompt)===0)D=D.slice(this._prompt.length),D=D.replace(/./g,this.replace),D=this._prompt+D;return this._hadControl=!0,this.emit("data",D)}else{if(this._prompt&&this._hadControl&&D.indexOf(this._prompt)===0)this._hadControl=!1,this.emit("data",this._prompt),D=D.slice(this._prompt.length);D=D.toString().replace(/./g,this.replace)}}this.emit("data",D)}end(D){if(this.muted)if(D&&this.replace)D=D.toString().replace(/./g,this.replace);else D=null;if(D)this.emit("data",D);this.emit("end")}destroy(...D){return this.#D("destroy",...D)}destroySoon(...D){return this.#D("destroySoon",...D)}close(...D){return this.#D("close",...D)}}u8.exports=S8});var h3=ND(y3(),1),{program:t7,createCommand:e7,createArgument:D9,createOption:F9,CommanderError:B9,InvalidArgumentError:E9,InvalidOptionArgumentError:$9,Command:g3,Argument:X9,Option:J9,Help:Q9}=h3.default;var m3="0.260202.0400";var AD=(D,F=[])=>D.name==="up"||F.includes("vim")&&D.name==="k"||F.includes("emacs")&&D.ctrl&&D.name==="p",PD=(D,F=[])=>D.name==="down"||F.includes("vim")&&D.name==="j"||F.includes("emacs")&&D.ctrl&&D.name==="n",T0=(D)=>D.name==="space",b0=(D)=>D.name==="backspace",kD=(D)=>D.name==="tab",P0=(D)=>"1234567890".includes(D.name),o=(D)=>D.name==="enter"||D.name==="return";class k0 extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(D){super();this.cause=D?.cause}}class v0 extends Error{name="CancelPromptError";message="Prompt was canceled"}class i2 extends Error{name="ExitPromptError"}class Z0 extends Error{name="HookError"}class N2 extends Error{name="ValidationError"}import{AsyncResource as vF}from"async_hooks";import{AsyncLocalStorage as bF,AsyncResource as PF}from"async_hooks";var l3=new bF;function kF(D){return{rl:D,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function p3(D,F){let B=kF(D);return l3.run(B,()=>{function E($){B.handleChange=()=>{B.index=0,$()},B.handleChange()}return F(E)})}function vD(){let D=l3.getStore();if(!D)throw new Z0("[Inquirer] Hook functions can only be called from within a prompt");return D}function f0(){return vD().rl}function x0(D){let F=(...B)=>{let E=vD(),$=!1,X=E.handleChange;E.handleChange=()=>{$=!0};let J=D(...B);if($)X();return E.handleChange=X,J};return PF.bind(F)}function tD(D){let F=vD(),{index:B}=F,E={get(){return F.hooks[B]},set(X){F.hooks[B]=X},initialized:B in F.hooks},$=D(E);return F.index++,$}function d3(){vD().handleChange()}var ZD={queue(D){let F=vD(),{index:B}=F;F.hooksEffect.push(()=>{F.hooksCleanup[B]?.();let E=D(f0());if(E!=null&&typeof E!=="function")throw new N2("useEffect return value must be a cleanup function or nothing.");F.hooksCleanup[B]=E})},run(){let D=vD();x0(()=>{D.hooksEffect.forEach((F)=>{F()}),D.hooksEffect.length=0})()},clearAll(){let D=vD();D.hooksCleanup.forEach((F)=>{F?.()}),D.hooksEffect.length=0,D.hooksCleanup.length=0}};function Z(D){return tD((F)=>{let B=vF.bind(function(X){if(F.get()!==X)F.set(X),d3()});if(F.initialized)return[F.get(),B];let E=typeof D==="function"?D():D;return F.set(E),[E,B]})}function zD(D,F){tD((B)=>{let E=B.get();if(!Array.isArray(E)||F.some((X,J)=>!Object.is(X,E[J])))ZD.queue(D);B.set(F)})}var i=ND(L2(),1);import WD from"process";function xF(){if(WD.platform!=="win32")return WD.env.TERM!=="linux";return Boolean(WD.env.WT_SESSION)||Boolean(WD.env.TERMINUS_SUBLIME)||WD.env.ConEmuTask==="{cmd::Cmder}"||WD.env.TERM_PROGRAM==="Terminus-Sublime"||WD.env.TERM_PROGRAM==="vscode"||WD.env.TERM==="xterm-256color"||WD.env.TERM==="alacritty"||WD.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var n3={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},i3={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},yF={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},hF={...n3,...i3},gF={...n3,...yF},mF=xF(),lF=mF?hF:gF,qD=lF,K9=Object.entries(i3);var a3={prefix:{idle:i.default.blue("?"),done:i.default.green(qD.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map((D)=>i.default.yellow(D))},style:{answer:i.default.cyan,message:i.default.bold,error:(D)=>i.default.red(`> ${D}`),defaultAnswer:(D)=>i.default.dim(`(${D})`),help:i.default.dim,highlight:i.default.cyan,key:(D)=>i.default.cyan(i.default.bold(`<${D}>`))}};function r3(D){if(typeof D!=="object"||D===null)return!1;let F=D;while(Object.getPrototypeOf(F)!==null)F=Object.getPrototypeOf(F);return Object.getPrototypeOf(D)===F}function o3(...D){let F={};for(let B of D)for(let[E,$]of Object.entries(B)){let X=F[E];F[E]=r3(X)&&r3($)?o3(X,$):$}return F}function n(...D){let F=[a3,...D.filter((B)=>B!=null)];return o3(...F)}function s({status:D="idle",theme:F}){let[B,E]=Z(!1),[$,X]=Z(0),{prefix:J,spinner:Q}=n(F);if(zD(()=>{if(D==="loading"){let W,q=-1,G=setTimeout(()=>{E(!0),W=setInterval(()=>{q=q+1,X(q%Q.frames.length)},Q.interval)},300);return()=>{clearTimeout(G),clearInterval(W)}}else E(!1)},[D]),B)return Q.frames[$];return typeof J==="string"?J:J[D==="loading"?"idle":D]??J.idle}function O2(D,F){return tD((B)=>{let E=B.get();if(!E||E.dependencies.length!==F.length||E.dependencies.some(($,X)=>$!==F[X])){let $=D();return B.set({value:$,dependencies:F}),$}return E.value})}function a2(D){return Z({current:D})[0]}function t(D){let F=a2(D);F.current=D,zD((B)=>{let E=!1,$=x0((X,J)=>{if(E)return;F.current(J,B)});return B.input.on("keypress",$),()=>{E=!0,B.input.removeListener("keypress",$)}},[])}var O8=ND(t3(),1),w8=ND(L8(),1);function u2(D,F){return D.split(`
|
|
30
|
+
`)}});var I8=h((E4,u8)=>{var _1=YD("stream");class S8 extends _1{#B=null;constructor(D={}){super(D);this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=D.replace,this._prompt=D.prompt||null,this._hadControl=!1}#F(D,F){if(this._dest)return this._dest[D];if(this._src)return this._src[D];return F}#D(D,...F){if(typeof this._dest?.[D]==="function")this._dest[D](...F);if(typeof this._src?.[D]==="function")this._src[D](...F)}get isTTY(){if(this.#B!==null)return this.#B;return this.#F("isTTY",!1)}set isTTY(D){this.#B=D}get rows(){return this.#F("rows")}get columns(){return this.#F("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(D){this._src=D}pipe(D,F){return this._dest=D,super.pipe(D,F)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(D){if(this.muted){if(!this.replace)return!0;if(D.match(/^\u001b/)){if(D.indexOf(this._prompt)===0)D=D.slice(this._prompt.length),D=D.replace(/./g,this.replace),D=this._prompt+D;return this._hadControl=!0,this.emit("data",D)}else{if(this._prompt&&this._hadControl&&D.indexOf(this._prompt)===0)this._hadControl=!1,this.emit("data",this._prompt),D=D.slice(this._prompt.length);D=D.toString().replace(/./g,this.replace)}}this.emit("data",D)}end(D){if(this.muted)if(D&&this.replace)D=D.toString().replace(/./g,this.replace);else D=null;if(D)this.emit("data",D);this.emit("end")}destroy(...D){return this.#D("destroy",...D)}destroySoon(...D){return this.#D("destroySoon",...D)}close(...D){return this.#D("close",...D)}}u8.exports=S8});var h3=ND(y3(),1),{program:t7,createCommand:e7,createArgument:D9,createOption:F9,CommanderError:B9,InvalidArgumentError:E9,InvalidOptionArgumentError:$9,Command:g3,Argument:X9,Option:J9,Help:Q9}=h3.default;var m3="0.260202.0453";var AD=(D,F=[])=>D.name==="up"||F.includes("vim")&&D.name==="k"||F.includes("emacs")&&D.ctrl&&D.name==="p",PD=(D,F=[])=>D.name==="down"||F.includes("vim")&&D.name==="j"||F.includes("emacs")&&D.ctrl&&D.name==="n",T0=(D)=>D.name==="space",b0=(D)=>D.name==="backspace",kD=(D)=>D.name==="tab",P0=(D)=>"1234567890".includes(D.name),o=(D)=>D.name==="enter"||D.name==="return";class k0 extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(D){super();this.cause=D?.cause}}class v0 extends Error{name="CancelPromptError";message="Prompt was canceled"}class i2 extends Error{name="ExitPromptError"}class Z0 extends Error{name="HookError"}class N2 extends Error{name="ValidationError"}import{AsyncResource as vF}from"async_hooks";import{AsyncLocalStorage as bF,AsyncResource as PF}from"async_hooks";var l3=new bF;function kF(D){return{rl:D,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function p3(D,F){let B=kF(D);return l3.run(B,()=>{function E($){B.handleChange=()=>{B.index=0,$()},B.handleChange()}return F(E)})}function vD(){let D=l3.getStore();if(!D)throw new Z0("[Inquirer] Hook functions can only be called from within a prompt");return D}function f0(){return vD().rl}function x0(D){let F=(...B)=>{let E=vD(),$=!1,X=E.handleChange;E.handleChange=()=>{$=!0};let J=D(...B);if($)X();return E.handleChange=X,J};return PF.bind(F)}function tD(D){let F=vD(),{index:B}=F,E={get(){return F.hooks[B]},set(X){F.hooks[B]=X},initialized:B in F.hooks},$=D(E);return F.index++,$}function d3(){vD().handleChange()}var ZD={queue(D){let F=vD(),{index:B}=F;F.hooksEffect.push(()=>{F.hooksCleanup[B]?.();let E=D(f0());if(E!=null&&typeof E!=="function")throw new N2("useEffect return value must be a cleanup function or nothing.");F.hooksCleanup[B]=E})},run(){let D=vD();x0(()=>{D.hooksEffect.forEach((F)=>{F()}),D.hooksEffect.length=0})()},clearAll(){let D=vD();D.hooksCleanup.forEach((F)=>{F?.()}),D.hooksEffect.length=0,D.hooksCleanup.length=0}};function Z(D){return tD((F)=>{let B=vF.bind(function(X){if(F.get()!==X)F.set(X),d3()});if(F.initialized)return[F.get(),B];let E=typeof D==="function"?D():D;return F.set(E),[E,B]})}function zD(D,F){tD((B)=>{let E=B.get();if(!Array.isArray(E)||F.some((X,J)=>!Object.is(X,E[J])))ZD.queue(D);B.set(F)})}var i=ND(L2(),1);import WD from"process";function xF(){if(WD.platform!=="win32")return WD.env.TERM!=="linux";return Boolean(WD.env.WT_SESSION)||Boolean(WD.env.TERMINUS_SUBLIME)||WD.env.ConEmuTask==="{cmd::Cmder}"||WD.env.TERM_PROGRAM==="Terminus-Sublime"||WD.env.TERM_PROGRAM==="vscode"||WD.env.TERM==="xterm-256color"||WD.env.TERM==="alacritty"||WD.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var n3={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},i3={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},yF={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},hF={...n3,...i3},gF={...n3,...yF},mF=xF(),lF=mF?hF:gF,qD=lF,K9=Object.entries(i3);var a3={prefix:{idle:i.default.blue("?"),done:i.default.green(qD.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map((D)=>i.default.yellow(D))},style:{answer:i.default.cyan,message:i.default.bold,error:(D)=>i.default.red(`> ${D}`),defaultAnswer:(D)=>i.default.dim(`(${D})`),help:i.default.dim,highlight:i.default.cyan,key:(D)=>i.default.cyan(i.default.bold(`<${D}>`))}};function r3(D){if(typeof D!=="object"||D===null)return!1;let F=D;while(Object.getPrototypeOf(F)!==null)F=Object.getPrototypeOf(F);return Object.getPrototypeOf(D)===F}function o3(...D){let F={};for(let B of D)for(let[E,$]of Object.entries(B)){let X=F[E];F[E]=r3(X)&&r3($)?o3(X,$):$}return F}function n(...D){let F=[a3,...D.filter((B)=>B!=null)];return o3(...F)}function s({status:D="idle",theme:F}){let[B,E]=Z(!1),[$,X]=Z(0),{prefix:J,spinner:Q}=n(F);if(zD(()=>{if(D==="loading"){let W,q=-1,G=setTimeout(()=>{E(!0),W=setInterval(()=>{q=q+1,X(q%Q.frames.length)},Q.interval)},300);return()=>{clearTimeout(G),clearInterval(W)}}else E(!1)},[D]),B)return Q.frames[$];return typeof J==="string"?J:J[D==="loading"?"idle":D]??J.idle}function O2(D,F){return tD((B)=>{let E=B.get();if(!E||E.dependencies.length!==F.length||E.dependencies.some(($,X)=>$!==F[X])){let $=D();return B.set({value:$,dependencies:F}),$}return E.value})}function a2(D){return Z({current:D})[0]}function t(D){let F=a2(D);F.current=D,zD((B)=>{let E=!1,$=x0((X,J)=>{if(E)return;F.current(J,B)});return B.input.on("keypress",$),()=>{E=!0,B.input.removeListener("keypress",$)}},[])}var O8=ND(t3(),1),w8=ND(L8(),1);function u2(D,F){return D.split(`
|
|
31
31
|
`).flatMap((B)=>w8.default(B,F,{trim:!1,hard:!0}).split(`
|
|
32
32
|
`).map((E)=>E.trimEnd())).join(`
|
|
33
33
|
`)}function s2(){return O8.default({defaultWidth:80,output:f0().output})}function q1({active:D,renderedItems:F,pageSize:B,loop:E}){let $=a2({lastPointer:D,lastActive:void 0}),{lastPointer:X,lastActive:J}=$.current,Q=Math.floor(B/2),Y=F.reduce((G,C)=>G+C.length,0),W=F.slice(0,D).reduce((G,C)=>G+C.length,0),q=W;if(Y>B)if(E){if(q=X,J!=null&&J<D&&D-J<B)q=Math.min(Q,Math.abs(D-J)===1?Math.min(X+(F[J]?.length??0),Math.max(W,X)):X+D-J)}else{let G=F.slice(D).reduce((C,A)=>C+A.length,0);q=G<B-Q?B-G:Math.min(W,Q)}return $.current.lastPointer=q,$.current.lastActive=D,q}function I2({items:D,active:F,renderItem:B,pageSize:E,loop:$=!0}){let X=s2(),J=(V)=>(V%D.length+D.length)%D.length,Q=D.map((V,w)=>{if(V==null)return[];return u2(B({item:V,index:w,isActive:w===F}),X).split(`
|
|
@@ -129,7 +129,7 @@ Next steps:`),console.log(" 1. Reload tmux: tmux source ~/.tmux.conf"),console.
|
|
|
129
129
|
`);let B=JD(D,".tmux.conf");if(!iD(B,"generated by genie-cli"))console.log("\u2713 tmux.conf has no genie shortcuts");else if(await j2(`Remove shortcuts from ${B}? [Y/n] `)!=="n"){if(H3(B,"generated by genie-cli"))console.log(`\u2705 Removed from ${B}`)}else console.log("\u23ED\uFE0F Skipped tmux.conf");let E=JD(D,".zshrc"),$=JD(D,".bashrc");for(let Y of[E,$]){if(!nD(Y))continue;if(!iD(Y,"generated by genie-cli"))console.log(`\u2713 ${Y} has no genie shortcuts`);else if(await j2(`Remove shell functions from ${Y}? [Y/n] `)!=="n"){if(H3(Y,"generated by genie-cli"))console.log(`\u2705 Removed from ${Y}`)}else console.log(`\u23ED\uFE0F Skipped ${Y}`)}let X=JD(D,".termux"),J=JD(X,"termux.properties"),Q=nD(X)||process.env.TERMUX_VERSION;if(Q)if(!iD(J,"generated by genie-cli"))console.log("\u2713 termux.properties has no genie shortcuts");else if(await j2(`Remove extra keys from ${J}? [Y/n] `)!=="n"){if(H3(J,"generated by genie-cli"))console.log(`\u2705 Removed from ${J}`),console.log(" Run: termux-reload-settings")}else console.log("\u23ED\uFE0F Skipped termux.properties");if(console.log(`
|
|
130
130
|
\u2705 Uninstallation complete!`),console.log(`
|
|
131
131
|
Next steps:`),console.log(" 1. Reload tmux: tmux source ~/.tmux.conf"),console.log(" 2. Restart your shell or run: source ~/.bashrc"),Q)console.log(" 3. Reload Termux: termux-reload-settings")}async function jE(D){if(D.tmux)console.log(Q6());else if(D.termux)console.log(Y6());else if(D.install)await g2();else G3()}import{homedir as Q7}from"os";import{join as Y7}from"path";function W7(){console.log(),console.log("\x1B[1m\x1B[36m"+"\u2554"+"\u2550".repeat(62)+"\u2557"+"\x1B[0m"),console.log("\x1B[1m\x1B[36m"+"\u2551 "+"\x1B[0m\x1B[1m\uD83E\uDDDE Genie Setup - Configure Your AI Assistant"+" ".repeat(16)+"\x1B[36m\u2551\x1B[0m"),console.log("\x1B[1m\x1B[36m"+"\u255A"+"\u2550".repeat(62)+"\u255D"+"\x1B[0m"),console.log()}function q7(){console.log("\x1B[1m\uD83D\uDCDA ABOUT HOOKS\x1B[0m"),console.log("\x1B[2mHooks let you control how the AI uses tools - without wasting\x1B[0m"),console.log('\x1B[2mtokens on prompts! Instead of telling the AI "please use term",\x1B[0m'),console.log("\x1B[2mhooks automatically enforce the behavior.\x1B[0m"),console.log(),console.log("\x1B[2m"+"\u2500".repeat(64)+"\x1B[0m"),console.log()}function _7(){console.log("\x1B[1m\uD83D\uDD27 AVAILABLE HOOK PRESETS\x1B[0m"),console.log();for(let D=0;D<Q0.length;D++){let F=Q0[D],B=D+1,E=F.recommended?" \x1B[32m(Recommended)\x1B[0m":"";console.log(`\x1B[1m${B}. ${F.title}\x1B[0m${E}`),console.log(` \u251C\u2500 What: ${F.what}`),console.log(` \u251C\u2500 Why: ${F.why}`),console.log(` \u2514\u2500 How: ${F.how}`),console.log()}console.log("\x1B[2m"+"\u2500".repeat(64)+"\x1B[0m"),console.log()}function H7(D,F){let B=D.recommended?" \x1B[32m(Recommended)\x1B[0m":"";return{name:`${D.title}${B} - ${D.what}`,value:D.name,checked:F}}function G7(D){console.log(),console.log(`\x1B[32m\u2713 Configuration saved to ${D}\x1B[0m`),console.log(),console.log("\x1B[1m\uD83D\uDCA1 TIP:\x1B[0m Claudio will automatically use these hooks."),console.log(" Run: \x1B[36mclaudio launch\x1B[0m"),console.log(" Watch: \x1B[36mtmux attach -t genie\x1B[0m"),console.log()}function M7(D){let F=R2(D);if(F.length===0)console.log("\x1B[33mNo hooks currently enabled.\x1B[0m");else{console.log("\x1B[1mCurrently enabled hooks:\x1B[0m");for(let B of F)console.log(` \u2022 ${B}`)}console.log()}async function A7(D){let F=D.hooks.sandboxed?.allowedPaths||["~/projects","/tmp"];console.log("\x1B[1mSandbox Configuration\x1B[0m"),console.log("\x1B[2mEnter paths where the AI can access files (comma-separated):\x1B[0m");let E=(await F0({message:"Allowed paths:",default:F.join(", ")})).split(",").map(($)=>$.trim()).filter(Boolean);D.hooks.sandboxed={allowedPaths:E}}async function z7(D){let F=D.hooks.audited?.logPath||"~/.genie/audit.log";console.log("\x1B[1mAudit Configuration\x1B[0m");let B=await F0({message:"Audit log path:",default:F});D.hooks.audited={logPath:B}}async function W0(){W7(),q7(),_7();let D=await XD(),F=new Set(D.hooks.enabled);if(U2())console.log("\x1B[1m\uD83D\uDCCB CURRENT CONFIGURATION\x1B[0m"),M7(D);let B=Q0.map(($)=>H7($,F.has($.name))),E=await E3({message:"Select hooks to enable (space to toggle, enter to confirm):",choices:B});if(D.hooks.enabled=E,E.includes("sandboxed"))console.log(),await A7(D);if(E.includes("audited")){if(console.log(),await yD({message:"Customize audit log path?",default:!1}))await z7(D)}if(await q3(D),G7(Y0()),E.length>0){console.log("\x1B[1mEnabled hooks:\x1B[0m");let $=R2(D);for(let X of $)console.log(` \x1B[32m\u2713\x1B[0m ${X}`);console.log()}await U7()}async function U7(){let D=Q7(),F=Y7(D,".tmux.conf");if(m2(F)){console.log("\x1B[2m\u2713 Tmux shortcuts already installed\x1B[0m"),console.log();return}if(console.log("\x1B[2m"+"\u2500".repeat(64)+"\x1B[0m"),console.log(),console.log("\x1B[1m\u2328\uFE0F KEYBOARD SHORTCUTS\x1B[0m"),console.log("\x1B[2mOptional: Install Warp-like tmux shortcuts for quick navigation:\x1B[0m"),console.log(" \u2022 Ctrl+T \u2192 New tab (window)"),console.log(" \u2022 Ctrl+S \u2192 Vertical split"),console.log(" \u2022 Alt+S \u2192 Horizontal split"),console.log(),await yD({message:"Install tmux keyboard shortcuts?",default:!1}))console.log(),await g2();else console.log(),console.log("\x1B[2mSkipped. Run \x1B[0m\x1B[36mgenie shortcuts install\x1B[0m\x1B[2m later to add them.\x1B[0m"),console.log()}async function q6(){console.log("\x1B[1m\uD83E\uDDDE Quick Setup - Using recommended defaults\x1B[0m"),console.log();let D=await XD();D.hooks.enabled=["collaborative","audited"],await q3(D),console.log("\x1B[32m\u2713 Enabled:\x1B[0m collaborative, audited"),console.log(),console.log("Run \x1B[36mgenie setup\x1B[0m to customize further."),console.log()}var j7={tmux:{brew:"brew install tmux",apt:"sudo apt update && sudo apt install -y tmux",dnf:"sudo dnf install -y tmux",yum:"sudo yum install -y tmux",pacman:"sudo pacman -S --noconfirm tmux",none:null},bun:{all:"curl -fsSL https://bun.sh/install | bash"},claude:{all:"npm install -g @anthropic-ai/claude-code"}};function C7(D,F){let B=j7[D];if(!B)return null;if(B.all)return B.all;if(F!=="none"&&B[F])return B[F];if(B.none!==void 0)return B.none;return null}function _6(D){switch(D){case"tmux":return"Visit https://github.com/tmux/tmux/wiki/Installing for installation instructions";case"bun":return"Visit https://bun.sh for installation instructions";case"claude":return"Run: npm install -g @anthropic-ai/claude-code (requires Node.js/npm)";default:return`Search for "${D} install" for installation instructions`}}async function V7(D){return new Promise((F)=>{console.log(`\x1B[2m$ ${D}\x1B[0m
|
|
132
|
-
`);let B=R7("bash",["-c",D],{stdio:"inherit",env:{...process.env,FORCE_COLOR:"1"}});B.on("close",(E)=>{F(E===0)}),B.on("error",(E)=>{console.error(`\x1B[31mError: ${E.message}\x1B[0m`),F(!1)})})}function K7(){console.log(),console.log("\x1B[1m\uD83D\uDD27 Genie Prerequisites Check\x1B[0m"),console.log()}function N7(D){let F=D.os==="macos"?"macOS":"Linux";if(D.linuxDistro&&D.linuxDistro!=="unknown")F=`Linux (${d8(D.linuxDistro)})`;console.log(`System: ${F} (${D.arch})`),console.log(`Package Manager: ${D.preferredPM==="none"?"none detected":D.preferredPM}`),console.log()}function L7(D){console.log("Checking prerequisites..."),console.log();for(let F of D)if(F.installed){let B=F.version?` ${F.version}`:"",E=F.path?`\x1B[2m (${F.path})\x1B[0m`:"";console.log(` \x1B[32m\u2705\x1B[0m ${F.name}${B}${E}`)}else if(F.required)console.log(` \x1B[31m\u274C\x1B[0m ${F.name} \x1B[31mnot found\x1B[0m`);else console.log(` \x1B[33m\u26A0\uFE0F\x1B[0m ${F.name} \x1B[33mnot found\x1B[0m \x1B[2m(optional)\x1B[0m`);console.log()}function q0(){console.log("\x1B[2m"+"\u2500".repeat(40)+"\x1B[0m"),console.log()}async function O7(D,F,B){let E=D.required?"\x1B[31mrequired\x1B[0m":"\x1B[2moptional, recommended\x1B[0m";if(!F)return console.log(`\x1B[33mManual installation required for\x1B[0m ${D.name} (${E})`),console.log(` ${_6(D.name)}`),console.log(),"skipped";console.log(`Install \x1B[1m${D.name}\x1B[0m? (${E})`),console.log(` Command: \x1B[36m${F}\x1B[0m`);let $;if(B.yes)$=!0,console.log("\x1B[2mAuto-approved with --yes\x1B[0m");else $=await yD({message:"Proceed",default:D.required});if(!$)return console.log(`\x1B[33mSkipped: ${D.name}\x1B[0m`),console.log(),"skipped";if(console.log(),console.log(`Installing ${D.name}...`),console.log(),await V7(F)){let J=await gD(D.name);if(J.exists){let Q=J.version?` ${J.version}`:"";return console.log(),console.log(`\x1B[32m\u2705 ${D.name}${Q} installed\x1B[0m`),console.log(),"installed"}else return console.log(),console.log(`\x1B[33m\u26A0\uFE0F ${D.name} installed but not found in PATH\x1B[0m`),console.log("\x1B[2m You may need to restart your shell or source your profile\x1B[0m"),console.log(),"installed"}else return console.log(),console.log(`\x1B[31m\u274C Failed to install ${D.name}\x1B[0m`),console.log(`\x1B[2m ${_6(D.name)}\x1B[0m`),console.log(),"failed"}async function H6(D){if(U2()){console.log("\x1B[2m\u2713 Genie hooks already configured (~/.genie/config.json)\x1B[0m"),console.log(" Run \x1B[36mgenie setup\x1B[0m to reconfigure."),console.log();return}console.log(),q0(),console.log("\x1B[1m\uD83E\uDDDE Configure Genie Hooks?\x1B[0m"),console.log(),console.log("\x1B[2mHooks let you control how AI tools execute - without wasting tokens!\x1B[0m"),console.log('\x1B[2mFor example, the "collaborative" hook routes all bash commands through\x1B[0m'),console.log("\x1B[2mtmux so you can watch the AI work in real-time.\x1B[0m"),console.log();let F;if(D.yes)F=!0,console.log("\x1B[2mAuto-approved with --yes\x1B[0m");else F=await yD({message:"Would you like to configure genie hooks now?",default:!0});if(F)console.log(),await W0();else console.log(),console.log("\x1B[2mSkipped. Run \x1B[0m\x1B[36mgenie setup\x1B[0m\x1B[2m anytime to configure hooks.\x1B[0m"),console.log()}async function G6(D){K7();let F=await l8();N7(F);let B=await p8();L7(B);let E=B.filter((q)=>!q.installed),$=E.filter((q)=>q.required),X=E.filter((q)=>!q.required);if(E.length===0){console.log("\x1B[32m\u2705 All prerequisites are installed!\x1B[0m"),console.log(),await H6(D),console.log("Run \x1B[36mterm --help\x1B[0m or \x1B[36mclaudio --help\x1B[0m to get started."),console.log();return}if(console.log(`Missing: ${$.length} required, ${X.length} optional`),console.log(),D.check){if($.length>0)console.log("\x1B[31m\u274C Missing required prerequisites\x1B[0m"),console.log("Run \x1B[36mgenie install\x1B[0m to install them."),process.exit(1);return}q0();let J={installed:[],skipped:[],failed:[]};for(let q of E){let G=C7(q.name,F.preferredPM),C=await O7(q,G,D);if(C==="installed")J.installed.push(q.name);else if(C==="skipped")J.skipped.push(q.name);else J.failed.push(q.name);if(q!==E[E.length-1])q0()}q0(),console.log("\x1B[1mSummary:\x1B[0m");let Q=J.installed.filter((q)=>$.some((G)=>G.name===q)),Y=J.failed.filter((q)=>$.some((G)=>G.name===q)),W=J.skipped.filter((q)=>X.some((G)=>G.name===q));if(Y.length>0)console.log(`\x1B[31m \u274C ${Y.length} required failed: ${Y.join(", ")}\x1B[0m`);else if(Q.length>0||$.length===0)console.log("\x1B[32m \u2705 All required prerequisites installed\x1B[0m");if(J.installed.length>0)console.log(`\x1B[32m \u2705 Installed: ${J.installed.join(", ")}\x1B[0m`);if(W.length>0)console.log(`\x1B[33m \u26A0\uFE0F ${W.length} optional skipped: ${W.join(", ")}\x1B[0m`);if(console.log(),Y.length===0)await H6(D),console.log("Run \x1B[36mterm --help\x1B[0m or \x1B[36mclaudio --help\x1B[0m to get started.");else console.log("\x1B[31mSome required prerequisites could not be installed.\x1B[0m"),console.log("Please install them manually and run this command again."),process.exit(1);console.log()}import{spawn as z6}from"child_process";import{existsSync as U6}from"fs";import{mkdir as M6,copyFile as R6,chmod as w7}from"fs/promises";import{join as VD}from"path";import{homedir as j6}from"os";var C6=process.env.GENIE_HOME||VD(j6(),".genie"),TD=VD(C6,"src"),M3=VD(C6,"bin"),A3=VD(j6(),".local","bin");function bD(D){console.log(`\x1B[32m\u25B8\x1B[0m ${D}`)}function l2(D){console.log(`\x1B[32m\u2714\x1B[0m ${D}`)}function CD(D){console.log(`\x1B[31m\u2716\x1B[0m ${D}`)}async function C2(D,F,B){return new Promise((E)=>{let $=[],X=z6(D,F,{cwd:B,stdio:["inherit","pipe","pipe"],env:{...process.env,FORCE_COLOR:"1"}});X.stdout?.on("data",(J)=>{let Q=J.toString();$.push(Q),process.stdout.write(Q)}),X.stderr?.on("data",(J)=>{let Q=J.toString();$.push(Q),process.stderr.write(Q)}),X.on("close",(J)=>{E({success:J===0,output:$.join("")})}),X.on("error",(J)=>{CD(J.message),E({success:!1,output:J.message})})})}async function A6(D){try{let F=await p2("git",["rev-parse","--abbrev-ref","HEAD"],D),B=await p2("git",["rev-parse","--short","HEAD"],D),E=await p2("git",["log","-1","--format=%ci"],D);if(F.success&&B.success&&E.success)return{branch:F.output.trim(),commit:B.output.trim(),commitDate:E.output.trim().split(" ")[0]}}catch{}return null}async function p2(D,F,B){return new Promise((E)=>{let $=[],X=z6(D,F,{cwd:B,stdio:["inherit","pipe","pipe"]});X.stdout?.on("data",(J)=>{$.push(J.toString())}),X.stderr?.on("data",(J)=>{$.push(J.toString())}),X.on("close",(J)=>{E({success:J===0,output:$.join("")})}),X.on("error",(J)=>{E({success:!1,output:J.message})})})}async function S7(){if(U2())try{let F=await XD();if(F.installMethod)return F.installMethod}catch{}if(U6(VD(TD,".git")))return"source";let D=await p2("which",["genie"]);if(D.success){let F=D.output.trim();if(F.includes(".bun"))return"bun";if(F.includes("node_modules"))return"npm";if(F===VD(A3,"genie")||F.startsWith(M3))return"source";return(await p2("which",["bun"])).success?"bun":"npm"}return"unknown"}async function u7(){if(bD("Updating via bun..."),!(await C2("bun",["install","-g","@automagik/genie@latest"])).success)CD("Failed to update via bun"),process.exit(1);console.log(),l2("Genie CLI updated!")}async function I7(){if(bD("Updating via npm..."),!(await C2("npm",["install","-g","@automagik/genie@latest"])).success)CD("Failed to update via npm"),process.exit(1);console.log(),l2("Genie CLI updated!")}async function T7(){let D=await A6(TD);if(D)console.log(`Current: \x1B[2m${D.branch}@${D.commit} (${D.commitDate})\x1B[0m`),console.log();if(bD("Fetching latest changes..."),!(await C2("git",["fetch","origin"],TD)).success)CD("Failed to fetch from origin"),process.exit(1);if(bD("Resetting to origin/main..."),!(await C2("git",["reset","--hard","origin/main"],TD)).success)CD("Failed to reset to origin/main"),process.exit(1);console.log();let E=await A6(TD);if(D&&E&&D.commit===E.commit){l2("Already up to date!"),console.log();return}if(bD("Installing dependencies..."),!(await C2("bun",["install"],TD)).success)CD("Failed to install dependencies"),process.exit(1);if(console.log(),bD("Building..."),!(await C2("bun",["run","build"],TD)).success)CD("Failed to build"),process.exit(1);console.log(),bD("Installing binaries...");try{await M6(M3,{recursive:!0}),await M6(A3,{recursive:!0});let J=["genie.js","term.js","claudio.js"],Q=["genie","term","claudio"];for(let Y=0;Y<J.length;Y++){let W=VD(TD,"dist",J[Y]),q=VD(M3,J[Y]),G=VD(A3,Q[Y]);await R6(W,q),await w7(q,493),await b7(q,G)}l2("Binaries installed")}catch(J){CD(`Failed to install binaries: ${J}`),process.exit(1)}if(console.log(),console.log("\x1B[2m\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\x1B[0m"),l2("Genie CLI updated successfully!"),console.log(),E)console.log(`Version: \x1B[36m${E.branch}@${E.commit}\x1B[0m (${E.commitDate})`),console.log()}async function b7(D,F){let{symlink:B,unlink:E}=await import("fs/promises");try{if(U6(F))await E(F);await B(D,F)}catch{await R6(D,F)}}async function V6(){console.log(),console.log("\x1B[1m\uD83E\uDDDE Genie CLI Update\x1B[0m"),console.log("\x1B[2m\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\x1B[0m"),console.log();let D=await S7();if(bD(`Detected installation: ${D}`),console.log(),D==="unknown")CD("No Genie CLI installation found"),console.log(),console.log("Install method not configured. Please reinstall genie:"),console.log("\x1B[36m curl -fsSL https://raw.githubusercontent.com/namastexlabs/genie-cli/main/install.sh | bash\x1B[0m"),console.log(),process.exit(1);switch(D){case"source":await T7();break;case"bun":await u7();break;case"npm":await I7();break}}import{existsSync as U3,mkdirSync as N6,readFileSync as P7,writeFileSync as k7}from"fs";import{homedir as L6}from"os";import{join as M0}from"path";var H0=M0(L6(),".claude"),z3=M0(H0,"hooks"),G0=M0(H0,"settings.json"),v7=u.object({type:u.literal("command"),command:u.string(),timeout:u.number().optional()}).passthrough(),K6=u.object({matcher:u.string(),hooks:u.array(v7)}).passthrough(),Z7=u.object({PreToolUse:u.array(K6).optional(),PostToolUse:u.array(K6).optional()}).passthrough(),_0=u.object({model:u.string().optional(),enabledPlugins:u.record(u.unknown()).optional(),hooks:Z7.optional()}).passthrough(),R3="genie-bash-hook.sh",A0="Bash";function z0(){return G0}function aD(){return M0(z3,R3)}function O6(){if(!U3(H0))N6(H0,{recursive:!0})}function w6(){if(O6(),!U3(z3))N6(z3,{recursive:!0})}async function U0(){if(!U3(G0))return _0.parse({});try{let D=P7(G0,"utf-8"),F=JSON.parse(D);return _0.parse(F)}catch(D){return console.warn(`Warning: Invalid Claude settings, using defaults: ${D.message}`),_0.parse({})}}async function j3(D){O6();try{let F=_0.parse(D),B=JSON.stringify(F,null,2);k7(G0,B,"utf-8")}catch(F){throw Error(`Failed to save Claude settings: ${F.message}`)}}function f7(D){return{matcher:A0,hooks:[{type:"command",command:D,timeout:600}]}}function d2(D){let F=D.hooks?.PreToolUse;if(!F||!Array.isArray(F))return!1;return F.some((B)=>{if(B.matcher!==A0)return!1;if(!Array.isArray(B.hooks))return!1;return B.hooks.some((E)=>E.type==="command"&&E.command?.includes(R3))})}function S6(D){let F=aD(),B=f7(F);if(!D.hooks)D.hooks={};if(!D.hooks.PreToolUse)D.hooks.PreToolUse=[];if(d2(D))return D;return D.hooks.PreToolUse=D.hooks.PreToolUse.filter((E)=>!(E.matcher===A0&&E.hooks?.some(($)=>$.command?.includes("genie")))),D.hooks.PreToolUse.push(B),D}function u6(D){if(!D.hooks?.PreToolUse)return D;if(D.hooks.PreToolUse=D.hooks.PreToolUse.filter((F)=>{if(F.matcher!==A0)return!0;if(!Array.isArray(F.hooks))return!0;return!F.hooks.some((E)=>E.type==="command"&&E.command?.includes(R3))}),D.hooks.PreToolUse.length===0)delete D.hooks.PreToolUse;if(D.hooks&&Object.keys(D.hooks).length===0)delete D.hooks;return D}function rD(D){let F=L6();if(D.startsWith(F+"/"))return"~"+D.slice(F.length);if(D===F)return"~";return D}import{existsSync as C3,unlinkSync as x7,writeFileSync as y7,chmodSync as h7}from"fs";function R0(){return C3(aD())}function j0(){return rD(aD())}async function g7(){let D=await XD(),F=D.hooks.collaborative?.sessionName||"genie",B=D.hooks.collaborative?.windowName||"shell",E=`${F}:${B}`;return`#!/bin/bash
|
|
132
|
+
`);let B=R7("bash",["-c",D],{stdio:"inherit",env:{...process.env,FORCE_COLOR:"1"}});B.on("close",(E)=>{F(E===0)}),B.on("error",(E)=>{console.error(`\x1B[31mError: ${E.message}\x1B[0m`),F(!1)})})}function K7(){console.log(),console.log("\x1B[1m\uD83D\uDD27 Genie Prerequisites Check\x1B[0m"),console.log()}function N7(D){let F=D.os==="macos"?"macOS":"Linux";if(D.linuxDistro&&D.linuxDistro!=="unknown")F=`Linux (${d8(D.linuxDistro)})`;console.log(`System: ${F} (${D.arch})`),console.log(`Package Manager: ${D.preferredPM==="none"?"none detected":D.preferredPM}`),console.log()}function L7(D){console.log("Checking prerequisites..."),console.log();for(let F of D)if(F.installed){let B=F.version?` ${F.version}`:"",E=F.path?`\x1B[2m (${F.path})\x1B[0m`:"";console.log(` \x1B[32m\u2705\x1B[0m ${F.name}${B}${E}`)}else if(F.required)console.log(` \x1B[31m\u274C\x1B[0m ${F.name} \x1B[31mnot found\x1B[0m`);else console.log(` \x1B[33m\u26A0\uFE0F\x1B[0m ${F.name} \x1B[33mnot found\x1B[0m \x1B[2m(optional)\x1B[0m`);console.log()}function q0(){console.log("\x1B[2m"+"\u2500".repeat(40)+"\x1B[0m"),console.log()}async function O7(D,F,B){let E=D.required?"\x1B[31mrequired\x1B[0m":"\x1B[2moptional, recommended\x1B[0m";if(!F)return console.log(`\x1B[33mManual installation required for\x1B[0m ${D.name} (${E})`),console.log(` ${_6(D.name)}`),console.log(),"skipped";console.log(`Install \x1B[1m${D.name}\x1B[0m? (${E})`),console.log(` Command: \x1B[36m${F}\x1B[0m`);let $;if(B.yes)$=!0,console.log("\x1B[2mAuto-approved with --yes\x1B[0m");else $=await yD({message:"Proceed",default:D.required});if(!$)return console.log(`\x1B[33mSkipped: ${D.name}\x1B[0m`),console.log(),"skipped";if(console.log(),console.log(`Installing ${D.name}...`),console.log(),await V7(F)){let J=await gD(D.name);if(J.exists){let Q=J.version?` ${J.version}`:"";return console.log(),console.log(`\x1B[32m\u2705 ${D.name}${Q} installed\x1B[0m`),console.log(),"installed"}else return console.log(),console.log(`\x1B[33m\u26A0\uFE0F ${D.name} installed but not found in PATH\x1B[0m`),console.log("\x1B[2m You may need to restart your shell or source your profile\x1B[0m"),console.log(),"installed"}else return console.log(),console.log(`\x1B[31m\u274C Failed to install ${D.name}\x1B[0m`),console.log(`\x1B[2m ${_6(D.name)}\x1B[0m`),console.log(),"failed"}async function H6(D){if(U2()){console.log("\x1B[2m\u2713 Genie hooks already configured (~/.genie/config.json)\x1B[0m"),console.log(" Run \x1B[36mgenie setup\x1B[0m to reconfigure."),console.log();return}console.log(),q0(),console.log("\x1B[1m\uD83E\uDDDE Configure Genie Hooks?\x1B[0m"),console.log(),console.log("\x1B[2mHooks let you control how AI tools execute - without wasting tokens!\x1B[0m"),console.log('\x1B[2mFor example, the "collaborative" hook routes all bash commands through\x1B[0m'),console.log("\x1B[2mtmux so you can watch the AI work in real-time.\x1B[0m"),console.log();let F;if(D.yes)F=!0,console.log("\x1B[2mAuto-approved with --yes\x1B[0m");else F=await yD({message:"Would you like to configure genie hooks now?",default:!0});if(F)console.log(),await W0();else console.log(),console.log("\x1B[2mSkipped. Run \x1B[0m\x1B[36mgenie setup\x1B[0m\x1B[2m anytime to configure hooks.\x1B[0m"),console.log()}async function G6(D){K7();let F=await l8();N7(F);let B=await p8();L7(B);let E=B.filter((q)=>!q.installed),$=E.filter((q)=>q.required),X=E.filter((q)=>!q.required);if(E.length===0){console.log("\x1B[32m\u2705 All prerequisites are installed!\x1B[0m"),console.log(),await H6(D),console.log("Run \x1B[36mterm --help\x1B[0m or \x1B[36mclaudio --help\x1B[0m to get started."),console.log();return}if(console.log(`Missing: ${$.length} required, ${X.length} optional`),console.log(),D.check){if($.length>0)console.log("\x1B[31m\u274C Missing required prerequisites\x1B[0m"),console.log("Run \x1B[36mgenie install\x1B[0m to install them."),process.exit(1);return}q0();let J={installed:[],skipped:[],failed:[]};for(let q of E){let G=C7(q.name,F.preferredPM),C=await O7(q,G,D);if(C==="installed")J.installed.push(q.name);else if(C==="skipped")J.skipped.push(q.name);else J.failed.push(q.name);if(q!==E[E.length-1])q0()}q0(),console.log("\x1B[1mSummary:\x1B[0m");let Q=J.installed.filter((q)=>$.some((G)=>G.name===q)),Y=J.failed.filter((q)=>$.some((G)=>G.name===q)),W=J.skipped.filter((q)=>X.some((G)=>G.name===q));if(Y.length>0)console.log(`\x1B[31m \u274C ${Y.length} required failed: ${Y.join(", ")}\x1B[0m`);else if(Q.length>0||$.length===0)console.log("\x1B[32m \u2705 All required prerequisites installed\x1B[0m");if(J.installed.length>0)console.log(`\x1B[32m \u2705 Installed: ${J.installed.join(", ")}\x1B[0m`);if(W.length>0)console.log(`\x1B[33m \u26A0\uFE0F ${W.length} optional skipped: ${W.join(", ")}\x1B[0m`);if(console.log(),Y.length===0)await H6(D),console.log("Run \x1B[36mterm --help\x1B[0m or \x1B[36mclaudio --help\x1B[0m to get started.");else console.log("\x1B[31mSome required prerequisites could not be installed.\x1B[0m"),console.log("Please install them manually and run this command again."),process.exit(1);console.log()}import{spawn as z6}from"child_process";import{existsSync as U6}from"fs";import{mkdir as M6,copyFile as R6,chmod as w7}from"fs/promises";import{join as VD}from"path";import{homedir as j6}from"os";var C6=process.env.GENIE_HOME||VD(j6(),".genie"),TD=VD(C6,"src"),M3=VD(C6,"bin"),A3=VD(j6(),".local","bin");function bD(D){console.log(`\x1B[32m\u25B8\x1B[0m ${D}`)}function l2(D){console.log(`\x1B[32m\u2714\x1B[0m ${D}`)}function CD(D){console.log(`\x1B[31m\u2716\x1B[0m ${D}`)}async function C2(D,F,B){return new Promise((E)=>{let $=[],X=z6(D,F,{cwd:B,stdio:["inherit","pipe","pipe"],env:{...process.env,FORCE_COLOR:"1"}});X.stdout?.on("data",(J)=>{let Q=J.toString();$.push(Q),process.stdout.write(Q)}),X.stderr?.on("data",(J)=>{let Q=J.toString();$.push(Q),process.stderr.write(Q)}),X.on("close",(J)=>{E({success:J===0,output:$.join("")})}),X.on("error",(J)=>{CD(J.message),E({success:!1,output:J.message})})})}async function A6(D){try{let F=await p2("git",["rev-parse","--abbrev-ref","HEAD"],D),B=await p2("git",["rev-parse","--short","HEAD"],D),E=await p2("git",["log","-1","--format=%ci"],D);if(F.success&&B.success&&E.success)return{branch:F.output.trim(),commit:B.output.trim(),commitDate:E.output.trim().split(" ")[0]}}catch{}return null}async function p2(D,F,B){return new Promise((E)=>{let $=[],X=z6(D,F,{cwd:B,stdio:["inherit","pipe","pipe"]});X.stdout?.on("data",(J)=>{$.push(J.toString())}),X.stderr?.on("data",(J)=>{$.push(J.toString())}),X.on("close",(J)=>{E({success:J===0,output:$.join("")})}),X.on("error",(J)=>{E({success:!1,output:J.message})})})}async function S7(){if(U2())try{let F=await XD();if(F.installMethod)return F.installMethod}catch{}if(U6(VD(TD,".git")))return"source";let D=await p2("which",["genie"]);if(D.success){let F=D.output.trim();if(F.includes(".bun"))return"bun";if(F.includes("node_modules"))return"npm";if(F===VD(A3,"genie")||F.startsWith(M3))return"source";return(await p2("which",["bun"])).success?"bun":"npm"}return"unknown"}async function u7(){if(bD("Updating via bun..."),!(await C2("bun",["install","-g","@automagik/genie@latest"])).success)CD("Failed to update via bun"),process.exit(1);console.log(),l2("Genie CLI updated!")}async function I7(){if(bD("Updating via npm..."),!(await C2("npm",["install","-g","@automagik/genie@latest"])).success)CD("Failed to update via npm"),process.exit(1);console.log(),l2("Genie CLI updated!")}async function T7(){let D=await A6(TD);if(D)console.log(`Current: \x1B[2m${D.branch}@${D.commit} (${D.commitDate})\x1B[0m`),console.log();if(bD("Fetching latest changes..."),!(await C2("git",["fetch","origin"],TD)).success)CD("Failed to fetch from origin"),process.exit(1);if(bD("Resetting to origin/main..."),!(await C2("git",["reset","--hard","origin/main"],TD)).success)CD("Failed to reset to origin/main"),process.exit(1);console.log();let E=await A6(TD);if(D&&E&&D.commit===E.commit){l2("Already up to date!"),console.log();return}if(bD("Installing dependencies..."),!(await C2("bun",["install"],TD)).success)CD("Failed to install dependencies"),process.exit(1);if(console.log(),bD("Building..."),!(await C2("bun",["run","build"],TD)).success)CD("Failed to build"),process.exit(1);console.log(),bD("Installing binaries...");try{await M6(M3,{recursive:!0}),await M6(A3,{recursive:!0});let J=["genie.js","term.js","claudio.js"],Q=["genie","term","claudio"];for(let Y=0;Y<J.length;Y++){let W=VD(TD,"dist",J[Y]),q=VD(M3,J[Y]),G=VD(A3,Q[Y]);await R6(W,q),await w7(q,493),await b7(q,G)}l2("Binaries installed")}catch(J){CD(`Failed to install binaries: ${J}`),process.exit(1)}if(console.log(),console.log("\x1B[2m\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\x1B[0m"),l2("Genie CLI updated successfully!"),console.log(),E)console.log(`Version: \x1B[36m${E.branch}@${E.commit}\x1B[0m (${E.commitDate})`),console.log()}async function b7(D,F){let{symlink:B,unlink:E}=await import("fs/promises");try{if(U6(F))await E(F);await B(D,F)}catch{await R6(D,F)}}async function V6(){console.log(),console.log("\x1B[1m\uD83E\uDDDE Genie CLI Update\x1B[0m"),console.log("\x1B[2m\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\x1B[0m"),console.log();let D=await S7();if(bD(`Detected installation: ${D}`),console.log(),D==="unknown")CD("No Genie CLI installation found"),console.log(),console.log("Install method not configured. Please reinstall genie:"),console.log("\x1B[36m curl -fsSL https://raw.githubusercontent.com/namastexlabs/genie-cli/main/install.sh | bash\x1B[0m"),console.log(),process.exit(1);switch(D){case"source":await T7();break;case"bun":await u7();break;case"npm":await I7();break}}import{existsSync as U3,mkdirSync as N6,readFileSync as P7,writeFileSync as k7}from"fs";import{homedir as L6}from"os";import{join as M0}from"path";var H0=M0(L6(),".claude"),z3=M0(H0,"hooks"),G0=M0(H0,"settings.json"),v7=u.object({type:u.literal("command"),command:u.string(),timeout:u.number().optional()}).passthrough(),K6=u.object({matcher:u.string(),hooks:u.array(v7)}).passthrough(),Z7=u.object({PreToolUse:u.array(K6).optional(),PostToolUse:u.array(K6).optional()}).passthrough(),_0=u.object({model:u.string().optional(),enabledPlugins:u.record(u.unknown()).optional(),hooks:Z7.optional()}).passthrough(),R3="genie-bash-hook.sh",A0="Bash";function z0(){return G0}function aD(){return M0(z3,R3)}function O6(){if(!U3(H0))N6(H0,{recursive:!0})}function w6(){if(O6(),!U3(z3))N6(z3,{recursive:!0})}async function U0(){if(!U3(G0))return _0.parse({});try{let D=P7(G0,"utf-8"),F=JSON.parse(D);return _0.parse(F)}catch(D){return console.warn(`Warning: Invalid Claude settings, using defaults: ${D.message}`),_0.parse({})}}async function j3(D){O6();try{let F=_0.parse(D),B=JSON.stringify(F,null,2);k7(G0,B,"utf-8")}catch(F){throw Error(`Failed to save Claude settings: ${F.message}`)}}function f7(D){return{matcher:A0,hooks:[{type:"command",command:D,timeout:600}]}}function d2(D){let F=D.hooks?.PreToolUse;if(!F||!Array.isArray(F))return!1;return F.some((B)=>{if(B.matcher!==A0)return!1;if(!Array.isArray(B.hooks))return!1;return B.hooks.some((E)=>E.type==="command"&&E.command?.includes(R3))})}function S6(D){let F=aD(),B=f7(F);if(!D.hooks)D.hooks={};if(!D.hooks.PreToolUse)D.hooks.PreToolUse=[];if(d2(D))return D;return D.hooks.PreToolUse=D.hooks.PreToolUse.filter((E)=>!(E.matcher===A0&&E.hooks?.some(($)=>$.command?.includes("genie")))),D.hooks.PreToolUse.push(B),D}function u6(D){if(!D.hooks?.PreToolUse)return D;if(D.hooks.PreToolUse=D.hooks.PreToolUse.filter((F)=>{if(F.matcher!==A0)return!0;if(!Array.isArray(F.hooks))return!0;return!F.hooks.some((E)=>E.type==="command"&&E.command?.includes(R3))}),D.hooks.PreToolUse.length===0)delete D.hooks.PreToolUse;if(D.hooks&&Object.keys(D.hooks).length===0)delete D.hooks;return D}function rD(D){let F=L6();if(D.startsWith(F+"/"))return"~"+D.slice(F.length);if(D===F)return"~";return D}import{existsSync as C3,unlinkSync as x7,writeFileSync as y7,chmodSync as h7}from"fs";function R0(){return C3(aD())}function j0(){return rD(aD())}async function g7(){let D=await XD(),F=D.hooks.collaborative?.sessionName||"genie",B=D.hooks.collaborative?.windowName||"shell";return`#!/bin/bash
|
|
133
133
|
#
|
|
134
134
|
# Genie Bash Hook for Claude Code
|
|
135
135
|
#
|
|
@@ -138,7 +138,7 @@ Next steps:`),console.log(" 1. Reload tmux: tmux source ~/.tmux.conf"),console.
|
|
|
138
138
|
# in a shared tmux session.
|
|
139
139
|
#
|
|
140
140
|
# Generated by: genie hooks install
|
|
141
|
-
# Target session: ${
|
|
141
|
+
# Target session: ${`${F}:${B}`}
|
|
142
142
|
#
|
|
143
143
|
|
|
144
144
|
# Read the entire input from stdin
|
|
@@ -162,12 +162,19 @@ if [ -z "$COMMAND" ]; then
|
|
|
162
162
|
exit 0
|
|
163
163
|
fi
|
|
164
164
|
|
|
165
|
+
# Don't wrap commands that are already term exec calls (avoid infinite recursion)
|
|
166
|
+
if [[ "$COMMAND" == *"term exec "* ]] || [[ "$COMMAND" == *"/term.js exec"* ]] || [[ "$COMMAND" == *".local/bin/term "* ]] || [[ "$COMMAND" == *".genie/bin/term"* ]]; then
|
|
167
|
+
echo '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"allow"}}'
|
|
168
|
+
exit 0
|
|
169
|
+
fi
|
|
170
|
+
|
|
165
171
|
# Escape single quotes in the command for safe shell embedding
|
|
166
172
|
# Replace ' with '\\'\\''
|
|
167
173
|
ESCAPED_COMMAND=$(echo "$COMMAND" | sed "s/'/'\\\\'\\\\''/" )
|
|
168
174
|
|
|
169
175
|
# Build the wrapped command that goes through term exec
|
|
170
|
-
|
|
176
|
+
# Uses full path since Claude's subprocess may not have full PATH
|
|
177
|
+
WRAPPED_COMMAND="$HOME/.local/bin/term exec ${F}:\\\${CLAUDIO_SESSION:-claude} '\${ESCAPED_COMMAND}'"
|
|
171
178
|
|
|
172
179
|
# Extract other fields from the original input to preserve them
|
|
173
180
|
TIMEOUT=$(echo "$INPUT" | jq -r '.tool_input.timeout // empty')
|
package/dist/term.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
4
|
-
`).replace(/^/gm," ".repeat(2))}let
|
|
5
|
-
`)}padWidth($,J){return Math.max(J.longestOptionTermLength($,J),J.longestGlobalOptionTermLength($,J),J.longestSubcommandTermLength($,J),J.longestArgumentTermLength($,J))}wrap($,J,q,U=40){let
|
|
3
|
+
var F0=Object.create;var{getPrototypeOf:D0,defineProperty:m,getOwnPropertyNames:y0}=Object;var P0=Object.prototype.hasOwnProperty;var j0=($,J,q)=>{q=$!=null?F0(D0($)):{};let U=J||!$||!$.__esModule?m(q,"default",{value:$,enumerable:!0}):q;for(let G of y0($))if(!P0.call(U,G))m(U,G,{get:()=>$[G],enumerable:!0});return U};var A=($,J)=>()=>(J||$((J={exports:{}}).exports,J),J.exports);var R6=($,J)=>{for(var q in J)m($,q,{get:J[q],enumerable:!0,configurable:!0,set:(U)=>J[q]=()=>U})};var f=import.meta.require;var b=A((A0)=>{class r extends Error{constructor($,J,q){super(q);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=J,this.exitCode=$,this.nestedError=void 0}}class H1 extends r{constructor($){super(1,"commander.invalidArgument",$);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}A0.CommanderError=r;A0.InvalidArgumentError=H1});var v=A((C0)=>{var{InvalidArgumentError:O0}=b();class R1{constructor($,J){switch(this.description=J||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,$[0]){case"<":this.required=!0,this._name=$.slice(1,-1);break;case"[":this.required=!1,this._name=$.slice(1,-1);break;default:this.required=!0,this._name=$;break}if(this._name.length>3&&this._name.slice(-3)==="...")this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_concatValue($,J){if(J===this.defaultValue||!Array.isArray(J))return[$];return J.concat($)}default($,J){return this.defaultValue=$,this.defaultValueDescription=J,this}argParser($){return this.parseArg=$,this}choices($){return this.argChoices=$.slice(),this.parseArg=(J,q)=>{if(!this.argChoices.includes(J))throw new O0(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(J,q);return J},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function f0($){let J=$.name()+($.variadic===!0?"...":"");return $.required?"<"+J+">":"["+J+"]"}C0.Argument=R1;C0.humanReadableArgName=f0});var s=A((x0)=>{var{humanReadableArgName:b0}=v();class B1{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands($){let J=$.commands.filter((U)=>!U._hidden),q=$._getHelpCommand();if(q&&!q._hidden)J.push(q);if(this.sortSubcommands)J.sort((U,G)=>{return U.name().localeCompare(G.name())});return J}compareOptions($,J){let q=(U)=>{return U.short?U.short.replace(/^-/,""):U.long.replace(/^--/,"")};return q($).localeCompare(q(J))}visibleOptions($){let J=$.options.filter((U)=>!U.hidden),q=$._getHelpOption();if(q&&!q.hidden){let U=q.short&&$._findOption(q.short),G=q.long&&$._findOption(q.long);if(!U&&!G)J.push(q);else if(q.long&&!G)J.push($.createOption(q.long,q.description));else if(q.short&&!U)J.push($.createOption(q.short,q.description))}if(this.sortOptions)J.sort(this.compareOptions);return J}visibleGlobalOptions($){if(!this.showGlobalOptions)return[];let J=[];for(let q=$.parent;q;q=q.parent){let U=q.options.filter((G)=>!G.hidden);J.push(...U)}if(this.sortOptions)J.sort(this.compareOptions);return J}visibleArguments($){if($._argsDescription)$.registeredArguments.forEach((J)=>{J.description=J.description||$._argsDescription[J.name()]||""});if($.registeredArguments.find((J)=>J.description))return $.registeredArguments;return[]}subcommandTerm($){let J=$.registeredArguments.map((q)=>b0(q)).join(" ");return $._name+($._aliases[0]?"|"+$._aliases[0]:"")+($.options.length?" [options]":"")+(J?" "+J:"")}optionTerm($){return $.flags}argumentTerm($){return $.name()}longestSubcommandTermLength($,J){return J.visibleCommands($).reduce((q,U)=>{return Math.max(q,J.subcommandTerm(U).length)},0)}longestOptionTermLength($,J){return J.visibleOptions($).reduce((q,U)=>{return Math.max(q,J.optionTerm(U).length)},0)}longestGlobalOptionTermLength($,J){return J.visibleGlobalOptions($).reduce((q,U)=>{return Math.max(q,J.optionTerm(U).length)},0)}longestArgumentTermLength($,J){return J.visibleArguments($).reduce((q,U)=>{return Math.max(q,J.argumentTerm(U).length)},0)}commandUsage($){let J=$._name;if($._aliases[0])J=J+"|"+$._aliases[0];let q="";for(let U=$.parent;U;U=U.parent)q=U.name()+" "+q;return q+J+" "+$.usage()}commandDescription($){return $.description()}subcommandDescription($){return $.summary()||$.description()}optionDescription($){let J=[];if($.argChoices)J.push(`choices: ${$.argChoices.map((q)=>JSON.stringify(q)).join(", ")}`);if($.defaultValue!==void 0){if($.required||$.optional||$.isBoolean()&&typeof $.defaultValue==="boolean")J.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`)}if($.presetArg!==void 0&&$.optional)J.push(`preset: ${JSON.stringify($.presetArg)}`);if($.envVar!==void 0)J.push(`env: ${$.envVar}`);if(J.length>0)return`${$.description} (${J.join(", ")})`;return $.description}argumentDescription($){let J=[];if($.argChoices)J.push(`choices: ${$.argChoices.map((q)=>JSON.stringify(q)).join(", ")}`);if($.defaultValue!==void 0)J.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`);if(J.length>0){let q=`(${J.join(", ")})`;if($.description)return`${$.description} ${q}`;return q}return $.description}formatHelp($,J){let q=J.padWidth($,J),U=J.helpWidth||80,G=2,X=2;function Q(H,T){if(T){let j=`${H.padEnd(q+2)}${T}`;return J.wrap(j,U-2,q+2)}return H}function Z(H){return H.join(`
|
|
4
|
+
`).replace(/^/gm," ".repeat(2))}let _=[`Usage: ${J.commandUsage($)}`,""],Y=J.commandDescription($);if(Y.length>0)_=_.concat([J.wrap(Y,U,0),""]);let S=J.visibleArguments($).map((H)=>{return Q(J.argumentTerm(H),J.argumentDescription(H))});if(S.length>0)_=_.concat(["Arguments:",Z(S),""]);let W=J.visibleOptions($).map((H)=>{return Q(J.optionTerm(H),J.optionDescription(H))});if(W.length>0)_=_.concat(["Options:",Z(W),""]);if(this.showGlobalOptions){let H=J.visibleGlobalOptions($).map((T)=>{return Q(J.optionTerm(T),J.optionDescription(T))});if(H.length>0)_=_.concat(["Global Options:",Z(H),""])}let B=J.visibleCommands($).map((H)=>{return Q(J.subcommandTerm(H),J.subcommandDescription(H))});if(B.length>0)_=_.concat(["Commands:",Z(B),""]);return _.join(`
|
|
5
|
+
`)}padWidth($,J){return Math.max(J.longestOptionTermLength($,J),J.longestGlobalOptionTermLength($,J),J.longestSubcommandTermLength($,J),J.longestArgumentTermLength($,J))}wrap($,J,q,U=40){let X=new RegExp(`[\\n][${" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF"}]+`);if($.match(X))return $;let Q=J-q;if(Q<U)return $;let Z=$.slice(0,q),_=$.slice(q).replace(`\r
|
|
6
6
|
`,`
|
|
7
|
-
`),Y=" ".repeat(q),
|
|
8
|
-
|.{1,${
|
|
9
|
-
`)return"";return(j>0?Y:"")+
|
|
10
|
-
`)}}x0.Help=
|
|
7
|
+
`),Y=" ".repeat(q),W=`\\s${"\u200B"}`,B=new RegExp(`
|
|
8
|
+
|.{1,${Q-1}}([${W}]|$)|[^${W}]+?([${W}]|$)`,"g"),H=_.match(B)||[];return Z+H.map((T,j)=>{if(T===`
|
|
9
|
+
`)return"";return(j>0?Y:"")+T.trimEnd()}).join(`
|
|
10
|
+
`)}}x0.Help=B1});var i=A((c0)=>{var{InvalidArgumentError:h0}=b();class K1{constructor($,J){this.flags=$,this.description=J||"",this.required=$.includes("<"),this.optional=$.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test($),this.mandatory=!1;let q=u0($);if(this.short=q.shortFlag,this.long=q.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default($,J){return this.defaultValue=$,this.defaultValueDescription=J,this}preset($){return this.presetArg=$,this}conflicts($){return this.conflictsWith=this.conflictsWith.concat($),this}implies($){let J=$;if(typeof $==="string")J={[$]:!0};return this.implied=Object.assign(this.implied||{},J),this}env($){return this.envVar=$,this}argParser($){return this.parseArg=$,this}makeOptionMandatory($=!0){return this.mandatory=!!$,this}hideHelp($=!0){return this.hidden=!!$,this}_concatValue($,J){if(J===this.defaultValue||!Array.isArray(J))return[$];return J.concat($)}choices($){return this.argChoices=$.slice(),this.parseArg=(J,q)=>{if(!this.argChoices.includes(J))throw new h0(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(J,q);return J},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){return g0(this.name().replace(/^no-/,""))}is($){return this.short===$||this.long===$}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class E1{constructor($){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,$.forEach((J)=>{if(J.negate)this.negativeOptions.set(J.attributeName(),J);else this.positiveOptions.set(J.attributeName(),J)}),this.negativeOptions.forEach((J,q)=>{if(this.positiveOptions.has(q))this.dualOptions.add(q)})}valueFromOption($,J){let q=J.attributeName();if(!this.dualOptions.has(q))return!0;let U=this.negativeOptions.get(q).presetArg,G=U!==void 0?U:!1;return J.negate===(G===$)}}function g0($){return $.split("-").reduce((J,q)=>{return J+q[0].toUpperCase()+q.slice(1)})}function u0($){let J,q,U=$.split(/[ |,]+/);if(U.length>1&&!/^[[<]/.test(U[1]))J=U.shift();if(q=U.shift(),!J&&/^-[^-]$/.test(q))J=q,q=void 0;return{shortFlag:J,longFlag:q}}c0.Option=K1;c0.DualOptions=E1});var z1=A((r0)=>{function p0($,J){if(Math.abs($.length-J.length)>3)return Math.max($.length,J.length);let q=[];for(let U=0;U<=$.length;U++)q[U]=[U];for(let U=0;U<=J.length;U++)q[0][U]=U;for(let U=1;U<=J.length;U++)for(let G=1;G<=$.length;G++){let X=1;if($[G-1]===J[U-1])X=0;else X=1;if(q[G][U]=Math.min(q[G-1][U]+1,q[G][U-1]+1,q[G-1][U-1]+X),G>1&&U>1&&$[G-1]===J[U-2]&&$[G-2]===J[U-1])q[G][U]=Math.min(q[G][U],q[G-2][U-2]+1)}return q[$.length][J.length]}function m0($,J){if(!J||J.length===0)return"";J=Array.from(new Set(J));let q=$.startsWith("--");if(q)$=$.slice(2),J=J.map((Q)=>Q.slice(2));let U=[],G=3,X=0.4;if(J.forEach((Q)=>{if(Q.length<=1)return;let Z=p0($,Q),_=Math.max($.length,Q.length);if((_-Z)/_>X){if(Z<G)G=Z,U=[Q];else if(Z===G)U.push(Q)}}),U.sort((Q,Z)=>Q.localeCompare(Z)),q)U=U.map((Q)=>`--${Q}`);if(U.length>1)return`
|
|
11
11
|
(Did you mean one of ${U.join(", ")}?)`;if(U.length===1)return`
|
|
12
|
-
(Did you mean ${U[0]}?)`;return""}
|
|
13
|
-
- specify the name in Command constructor or using .name()`);if(J=J||{},J.isDefault)this._defaultCommandName=$._name;if(J.noHelp||J.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,J){return new
|
|
14
|
-
Expecting one of '${q.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(J);else this._lifeCycleHooks[$]=[J];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(J)=>{if(J.code!=="commander.executeSubCommandAsync")throw J};return this}_exit($,J,q){if(this._exitCallback)this._exitCallback(new a($,J,q));
|
|
15
|
-
- already used by option '${J.flags}'`)}this.options.push($)}_registerCommand($){let J=(U)=>{return[U.name()].concat(U.aliases())},q=J($).find((U)=>this._findCommand(U));if(q){let U=J(this._findCommand(q)).join("|"),
|
|
12
|
+
(Did you mean ${U[0]}?)`;return""}r0.suggestSimilar=m0});var T1=A((e0)=>{var i0=f("events").EventEmitter,t=f("child_process"),y=f("path"),o=f("fs"),E=f("process"),{Argument:t0,humanReadableArgName:o0}=v(),{CommanderError:a}=b(),{Help:a0}=s(),{Option:L1,DualOptions:n0}=i(),{suggestSimilar:V1}=z1();class n extends i0{constructor($){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=$||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:(J)=>E.stdout.write(J),writeErr:(J)=>E.stderr.write(J),getOutHelpWidth:()=>E.stdout.isTTY?E.stdout.columns:void 0,getErrHelpWidth:()=>E.stderr.isTTY?E.stderr.columns:void 0,outputError:(J,q)=>q(J)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings($){return this._outputConfiguration=$._outputConfiguration,this._helpOption=$._helpOption,this._helpCommand=$._helpCommand,this._helpConfiguration=$._helpConfiguration,this._exitCallback=$._exitCallback,this._storeOptionsAsProperties=$._storeOptionsAsProperties,this._combineFlagAndOptionalValue=$._combineFlagAndOptionalValue,this._allowExcessArguments=$._allowExcessArguments,this._enablePositionalOptions=$._enablePositionalOptions,this._showHelpAfterError=$._showHelpAfterError,this._showSuggestionAfterError=$._showSuggestionAfterError,this}_getCommandAndAncestors(){let $=[];for(let J=this;J;J=J.parent)$.push(J);return $}command($,J,q){let U=J,G=q;if(typeof U==="object"&&U!==null)G=U,U=null;G=G||{};let[,X,Q]=$.match(/([^ ]+) *(.*)/),Z=this.createCommand(X);if(U)Z.description(U),Z._executableHandler=!0;if(G.isDefault)this._defaultCommandName=Z._name;if(Z._hidden=!!(G.noHelp||G.hidden),Z._executableFile=G.executableFile||null,Q)Z.arguments(Q);if(this._registerCommand(Z),Z.parent=this,Z.copyInheritedSettings(this),U)return this;return Z}createCommand($){return new n($)}createHelp(){return Object.assign(new a0,this.configureHelp())}configureHelp($){if($===void 0)return this._helpConfiguration;return this._helpConfiguration=$,this}configureOutput($){if($===void 0)return this._outputConfiguration;return Object.assign(this._outputConfiguration,$),this}showHelpAfterError($=!0){if(typeof $!=="string")$=!!$;return this._showHelpAfterError=$,this}showSuggestionAfterError($=!0){return this._showSuggestionAfterError=!!$,this}addCommand($,J){if(!$._name)throw Error(`Command passed to .addCommand() must have a name
|
|
13
|
+
- specify the name in Command constructor or using .name()`);if(J=J||{},J.isDefault)this._defaultCommandName=$._name;if(J.noHelp||J.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,J){return new t0($,J)}argument($,J,q,U){let G=this.createArgument($,J);if(typeof q==="function")G.default(U).argParser(q);else G.default(q);return this.addArgument(G),this}arguments($){return $.trim().split(/ +/).forEach((J)=>{this.argument(J)}),this}addArgument($){let J=this.registeredArguments.slice(-1)[0];if(J&&J.variadic)throw Error(`only the last argument can be variadic '${J.name()}'`);if($.required&&$.defaultValue!==void 0&&$.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${$.name()}'`);return this.registeredArguments.push($),this}helpCommand($,J){if(typeof $==="boolean")return this._addImplicitHelpCommand=$,this;$=$??"help [command]";let[,q,U]=$.match(/([^ ]+) *(.*)/),G=J??"display help for command",X=this.createCommand(q);if(X.helpOption(!1),U)X.arguments(U);if(G)X.description(G);return this._addImplicitHelpCommand=!0,this._helpCommand=X,this}addHelpCommand($,J){if(typeof $!=="object")return this.helpCommand($,J),this;return this._addImplicitHelpCommand=!0,this._helpCommand=$,this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook($,J){let q=["preSubcommand","preAction","postAction"];if(!q.includes($))throw Error(`Unexpected value for event passed to hook : '${$}'.
|
|
14
|
+
Expecting one of '${q.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(J);else this._lifeCycleHooks[$]=[J];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(J)=>{if(J.code!=="commander.executeSubCommandAsync")throw J};return this}_exit($,J,q){if(this._exitCallback)this._exitCallback(new a($,J,q));E.exit($)}action($){let J=(q)=>{let U=this.registeredArguments.length,G=q.slice(0,U);if(this._storeOptionsAsProperties)G[U]=this;else G[U]=this.opts();return G.push(this),$.apply(this,G)};return this._actionHandler=J,this}createOption($,J){return new L1($,J)}_callParseArg($,J,q,U){try{return $.parseArg(J,q)}catch(G){if(G.code==="commander.invalidArgument"){let X=`${U} ${G.message}`;this.error(X,{exitCode:G.exitCode,code:G.code})}throw G}}_registerOption($){let J=$.short&&this._findOption($.short)||$.long&&this._findOption($.long);if(J){let q=$.long&&this._findOption($.long)?$.long:$.short;throw Error(`Cannot add option '${$.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${q}'
|
|
15
|
+
- already used by option '${J.flags}'`)}this.options.push($)}_registerCommand($){let J=(U)=>{return[U.name()].concat(U.aliases())},q=J($).find((U)=>this._findCommand(U));if(q){let U=J(this._findCommand(q)).join("|"),G=J($).join("|");throw Error(`cannot add command '${G}' as already have command '${U}'`)}this.commands.push($)}addOption($){this._registerOption($);let J=$.name(),q=$.attributeName();if($.negate){let G=$.long.replace(/^--no-/,"--");if(!this._findOption(G))this.setOptionValueWithSource(q,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(q,$.defaultValue,"default");let U=(G,X,Q)=>{if(G==null&&$.presetArg!==void 0)G=$.presetArg;let Z=this.getOptionValue(q);if(G!==null&&$.parseArg)G=this._callParseArg($,G,Z,X);else if(G!==null&&$.variadic)G=$._concatValue(G,Z);if(G==null)if($.negate)G=!1;else if($.isBoolean()||$.optional)G=!0;else G="";this.setOptionValueWithSource(q,G,Q)};if(this.on("option:"+J,(G)=>{let X=`error: option '${$.flags}' argument '${G}' is invalid.`;U(G,X,"cli")}),$.envVar)this.on("optionEnv:"+J,(G)=>{let X=`error: option '${$.flags}' value '${G}' from env '${$.envVar}' is invalid.`;U(G,X,"env")});return this}_optionEx($,J,q,U,G){if(typeof J==="object"&&J instanceof L1)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let X=this.createOption(J,q);if(X.makeOptionMandatory(!!$.mandatory),typeof U==="function")X.default(G).argParser(U);else if(U instanceof RegExp){let Q=U;U=(Z,_)=>{let Y=Q.exec(Z);return Y?Y[0]:_},X.default(G).argParser(U)}else X.default(U);return this.addOption(X)}option($,J,q,U){return this._optionEx({},$,J,q,U)}requiredOption($,J,q,U){return this._optionEx({mandatory:!0},$,J,q,U)}combineFlagAndOptionalValue($=!0){return this._combineFlagAndOptionalValue=!!$,this}allowUnknownOption($=!0){return this._allowUnknownOption=!!$,this}allowExcessArguments($=!0){return this._allowExcessArguments=!!$,this}enablePositionalOptions($=!0){return this._enablePositionalOptions=!!$,this}passThroughOptions($=!0){return this._passThroughOptions=!!$,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties($=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!$,this}getOptionValue($){if(this._storeOptionsAsProperties)return this[$];return this._optionValues[$]}setOptionValue($,J){return this.setOptionValueWithSource($,J,void 0)}setOptionValueWithSource($,J,q){if(this._storeOptionsAsProperties)this[$]=J;else this._optionValues[$]=J;return this._optionValueSources[$]=q,this}getOptionValueSource($){return this._optionValueSources[$]}getOptionValueSourceWithGlobals($){let J;return this._getCommandAndAncestors().forEach((q)=>{if(q.getOptionValueSource($)!==void 0)J=q.getOptionValueSource($)}),J}_prepareUserArgs($,J){if($!==void 0&&!Array.isArray($))throw Error("first parameter to parse must be array or undefined");if(J=J||{},$===void 0&&J.from===void 0){if(E.versions?.electron)J.from="electron";let U=E.execArgv??[];if(U.includes("-e")||U.includes("--eval")||U.includes("-p")||U.includes("--print"))J.from="eval"}if($===void 0)$=E.argv;this.rawArgs=$.slice();let q;switch(J.from){case void 0:case"node":this._scriptPath=$[1],q=$.slice(2);break;case"electron":if(E.defaultApp)this._scriptPath=$[1],q=$.slice(2);else q=$.slice(1);break;case"user":q=$.slice(0);break;case"eval":q=$.slice(1);break;default:throw Error(`unexpected parse option { from: '${J.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",q}parse($,J){let q=this._prepareUserArgs($,J);return this._parseCommand([],q),this}async parseAsync($,J){let q=this._prepareUserArgs($,J);return await this._parseCommand([],q),this}_executeSubCommand($,J){J=J.slice();let q=!1,U=[".js",".ts",".tsx",".mjs",".cjs"];function G(Y,S){let W=y.resolve(Y,S);if(o.existsSync(W))return W;if(U.includes(y.extname(S)))return;let B=U.find((H)=>o.existsSync(`${W}${H}`));if(B)return`${W}${B}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let X=$._executableFile||`${this._name}-${$._name}`,Q=this._executableDir||"";if(this._scriptPath){let Y;try{Y=o.realpathSync(this._scriptPath)}catch(S){Y=this._scriptPath}Q=y.resolve(y.dirname(Y),Q)}if(Q){let Y=G(Q,X);if(!Y&&!$._executableFile&&this._scriptPath){let S=y.basename(this._scriptPath,y.extname(this._scriptPath));if(S!==this._name)Y=G(Q,`${S}-${$._name}`)}X=Y||X}q=U.includes(y.extname(X));let Z;if(E.platform!=="win32")if(q)J.unshift(X),J=M1(E.execArgv).concat(J),Z=t.spawn(E.argv[0],J,{stdio:"inherit"});else Z=t.spawn(X,J,{stdio:"inherit"});else J.unshift(X),J=M1(E.execArgv).concat(J),Z=t.spawn(E.execPath,J,{stdio:"inherit"});if(!Z.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((S)=>{E.on(S,()=>{if(Z.killed===!1&&Z.exitCode===null)Z.kill(S)})});let _=this._exitCallback;Z.on("close",(Y)=>{if(Y=Y??1,!_)E.exit(Y);else _(new a(Y,"commander.executeSubCommandAsync","(close)"))}),Z.on("error",(Y)=>{if(Y.code==="ENOENT"){let S=Q?`searched for local subcommand relative to directory '${Q}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",W=`'${X}' does not exist
|
|
16
16
|
- if '${$._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
17
17
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
18
|
-
- ${S}`;throw Error(
|
|
18
|
+
- ${S}`;throw Error(W)}else if(Y.code==="EACCES")throw Error(`'${X}' not executable`);if(!_)E.exit(1);else{let S=new a(1,"commander.executeSubCommandAsync","(error)");S.nestedError=Y,_(S)}}),this.runningCommand=Z}_dispatchSubcommand($,J,q){let U=this._findCommand($);if(!U)this.help({error:!0});let G;return G=this._chainOrCallSubCommandHook(G,U,"preSubcommand"),G=this._chainOrCall(G,()=>{if(U._executableHandler)this._executeSubCommand(U,J.concat(q));else return U._parseCommand(J,q)}),G}_dispatchHelpCommand($){if(!$)this.help();let J=this._findCommand($);if(J&&!J._executableHandler)J.help();return this._dispatchSubcommand($,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach(($,J)=>{if($.required&&this.args[J]==null)this.missingArgument($.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let $=(q,U,G)=>{let X=U;if(U!==null&&q.parseArg){let Q=`error: command-argument value '${U}' is invalid for argument '${q.name()}'.`;X=this._callParseArg(q,U,G,Q)}return X};this._checkNumberOfArguments();let J=[];this.registeredArguments.forEach((q,U)=>{let G=q.defaultValue;if(q.variadic){if(U<this.args.length){if(G=this.args.slice(U),q.parseArg)G=G.reduce((X,Q)=>{return $(q,Q,X)},q.defaultValue)}else if(G===void 0)G=[]}else if(U<this.args.length){if(G=this.args[U],q.parseArg)G=$(q,G,q.defaultValue)}J[U]=G}),this.processedArgs=J}_chainOrCall($,J){if($&&$.then&&typeof $.then==="function")return $.then(()=>J());return J()}_chainOrCallHooks($,J){let q=$,U=[];if(this._getCommandAndAncestors().reverse().filter((G)=>G._lifeCycleHooks[J]!==void 0).forEach((G)=>{G._lifeCycleHooks[J].forEach((X)=>{U.push({hookedCommand:G,callback:X})})}),J==="postAction")U.reverse();return U.forEach((G)=>{q=this._chainOrCall(q,()=>{return G.callback(G.hookedCommand,this)})}),q}_chainOrCallSubCommandHook($,J,q){let U=$;if(this._lifeCycleHooks[q]!==void 0)this._lifeCycleHooks[q].forEach((G)=>{U=this._chainOrCall(U,()=>{return G(this,J)})});return U}_parseCommand($,J){let q=this.parseOptions(J);if(this._parseOptionsEnv(),this._parseOptionsImplied(),$=$.concat(q.operands),J=q.unknown,this.args=$.concat(J),$&&this._findCommand($[0]))return this._dispatchSubcommand($[0],$.slice(1),J);if(this._getHelpCommand()&&$[0]===this._getHelpCommand().name())return this._dispatchHelpCommand($[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(J),this._dispatchSubcommand(this._defaultCommandName,$,J);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(q.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let U=()=>{if(q.unknown.length>0)this.unknownOption(q.unknown[0])},G=`command:${this.name()}`;if(this._actionHandler){U(),this._processArguments();let X;if(X=this._chainOrCallHooks(X,"preAction"),X=this._chainOrCall(X,()=>this._actionHandler(this.processedArgs)),this.parent)X=this._chainOrCall(X,()=>{this.parent.emit(G,$,J)});return X=this._chainOrCallHooks(X,"postAction"),X}if(this.parent&&this.parent.listenerCount(G))U(),this._processArguments(),this.parent.emit(G,$,J);else if($.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",$,J);if(this.listenerCount("command:*"))this.emit("command:*",$,J);else if(this.commands.length)this.unknownCommand();else U(),this._processArguments()}else if(this.commands.length)U(),this.help({error:!0});else U(),this._processArguments()}_findCommand($){if(!$)return;return this.commands.find((J)=>J._name===$||J._aliases.includes($))}_findOption($){return this.options.find((J)=>J.is($))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(($)=>{$.options.forEach((J)=>{if(J.mandatory&&$.getOptionValue(J.attributeName())===void 0)$.missingMandatoryOptionValue(J)})})}_checkForConflictingLocalOptions(){let $=this.options.filter((q)=>{let U=q.attributeName();if(this.getOptionValue(U)===void 0)return!1;return this.getOptionValueSource(U)!=="default"});$.filter((q)=>q.conflictsWith.length>0).forEach((q)=>{let U=$.find((G)=>q.conflictsWith.includes(G.attributeName()));if(U)this._conflictingOption(q,U)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(($)=>{$._checkForConflictingLocalOptions()})}parseOptions($){let J=[],q=[],U=J,G=$.slice();function X(Z){return Z.length>1&&Z[0]==="-"}let Q=null;while(G.length){let Z=G.shift();if(Z==="--"){if(U===q)U.push(Z);U.push(...G);break}if(Q&&!X(Z)){this.emit(`option:${Q.name()}`,Z);continue}if(Q=null,X(Z)){let _=this._findOption(Z);if(_){if(_.required){let Y=G.shift();if(Y===void 0)this.optionMissingArgument(_);this.emit(`option:${_.name()}`,Y)}else if(_.optional){let Y=null;if(G.length>0&&!X(G[0]))Y=G.shift();this.emit(`option:${_.name()}`,Y)}else this.emit(`option:${_.name()}`);Q=_.variadic?_:null;continue}}if(Z.length>2&&Z[0]==="-"&&Z[1]!=="-"){let _=this._findOption(`-${Z[1]}`);if(_){if(_.required||_.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${_.name()}`,Z.slice(2));else this.emit(`option:${_.name()}`),G.unshift(`-${Z.slice(2)}`);continue}}if(/^--[^=]+=/.test(Z)){let _=Z.indexOf("="),Y=this._findOption(Z.slice(0,_));if(Y&&(Y.required||Y.optional)){this.emit(`option:${Y.name()}`,Z.slice(_+1));continue}}if(X(Z))U=q;if((this._enablePositionalOptions||this._passThroughOptions)&&J.length===0&&q.length===0){if(this._findCommand(Z)){if(J.push(Z),G.length>0)q.push(...G);break}else if(this._getHelpCommand()&&Z===this._getHelpCommand().name()){if(J.push(Z),G.length>0)J.push(...G);break}else if(this._defaultCommandName){if(q.push(Z),G.length>0)q.push(...G);break}}if(this._passThroughOptions){if(U.push(Z),G.length>0)U.push(...G);break}U.push(Z)}return{operands:J,unknown:q}}opts(){if(this._storeOptionsAsProperties){let $={},J=this.options.length;for(let q=0;q<J;q++){let U=this.options[q].attributeName();$[U]=U===this._versionOptionName?this._version:this[U]}return $}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(($,J)=>Object.assign($,J.opts()),{})}error($,J){if(this._outputConfiguration.outputError(`${$}
|
|
19
19
|
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
20
20
|
`);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
|
|
21
|
-
`),this.outputHelp({error:!0});let q=J||{},U=q.exitCode||1,
|
|
22
|
-
`),this._exit(0,"commander.version",$)}),this}description($,J){if($===void 0&&J===void 0)return this._description;if(this._description=$,J)this._argsDescription=J;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let J=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)J=this.commands[this.commands.length-1];if($===J._name)throw Error("Command alias can't be the same as its name");let q=this.parent?._findCommand($);if(q){let U=[q.name()].concat(q.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${U}'`)}return J._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((J)=>this.alias(J)),this}usage($){if($===void 0){if(this._usage)return this._usage;let J=this.registeredArguments.map((q)=>{return
|
|
23
|
-
Expecting one of '${q.join("', '")}'`);let U=`${$}Help`;return this.on(U,(
|
|
24
|
-
`)}),this}_outputHelpIfRequested($){let J=this._getHelpOption();if(J&&$.find((U)=>J.is(U)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function
|
|
25
|
-
`).map((q)=>{let[U,X,Q
|
|
26
|
-
`).map((U)=>{let[X,Q
|
|
27
|
-
`).map((U)=>{let[X,Q
|
|
28
|
-
`)[0],
|
|
29
|
-
`)+1).trim(),
|
|
30
|
-
`))if(
|
|
31
|
-
To attach: term attach ${$}`)}catch(q){console.error(`\u274C Error creating session: ${q.message}`),process.exit(1)}}async function
|
|
32
|
-
`).filter((U)=>{let
|
|
33
|
-
`)}async function
|
|
21
|
+
`),this.outputHelp({error:!0});let q=J||{},U=q.exitCode||1,G=q.code||"commander.error";this._exit(U,G,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in E.env){let J=$.attributeName();if(this.getOptionValue(J)===void 0||["default","config","env"].includes(this.getOptionValueSource(J)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,E.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new n0(this.options),J=(q)=>{return this.getOptionValue(q)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(q))};this.options.filter((q)=>q.implied!==void 0&&J(q.attributeName())&&$.valueFromOption(this.getOptionValue(q.attributeName()),q)).forEach((q)=>{Object.keys(q.implied).filter((U)=>!J(U)).forEach((U)=>{this.setOptionValueWithSource(U,q.implied[U],"implied")})})}missingArgument($){let J=`error: missing required argument '${$}'`;this.error(J,{code:"commander.missingArgument"})}optionMissingArgument($){let J=`error: option '${$.flags}' argument missing`;this.error(J,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue($){let J=`error: required option '${$.flags}' not specified`;this.error(J,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption($,J){let q=(X)=>{let Q=X.attributeName(),Z=this.getOptionValue(Q),_=this.options.find((S)=>S.negate&&Q===S.attributeName()),Y=this.options.find((S)=>!S.negate&&Q===S.attributeName());if(_&&(_.presetArg===void 0&&Z===!1||_.presetArg!==void 0&&Z===_.presetArg))return _;return Y||X},U=(X)=>{let Q=q(X),Z=Q.attributeName();if(this.getOptionValueSource(Z)==="env")return`environment variable '${Q.envVar}'`;return`option '${Q.flags}'`},G=`error: ${U($)} cannot be used with ${U(J)}`;this.error(G,{code:"commander.conflictingOption"})}unknownOption($){if(this._allowUnknownOption)return;let J="";if($.startsWith("--")&&this._showSuggestionAfterError){let U=[],G=this;do{let X=G.createHelp().visibleOptions(G).filter((Q)=>Q.long).map((Q)=>Q.long);U=U.concat(X),G=G.parent}while(G&&!G._enablePositionalOptions);J=V1($,U)}let q=`error: unknown option '${$}'${J}`;this.error(q,{code:"commander.unknownOption"})}_excessArguments($){if(this._allowExcessArguments)return;let J=this.registeredArguments.length,q=J===1?"":"s",G=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${J} argument${q} but got ${$.length}.`;this.error(G,{code:"commander.excessArguments"})}unknownCommand(){let $=this.args[0],J="";if(this._showSuggestionAfterError){let U=[];this.createHelp().visibleCommands(this).forEach((G)=>{if(U.push(G.name()),G.alias())U.push(G.alias())}),J=V1($,U)}let q=`error: unknown command '${$}'${J}`;this.error(q,{code:"commander.unknownCommand"})}version($,J,q){if($===void 0)return this._version;this._version=$,J=J||"-V, --version",q=q||"output the version number";let U=this.createOption(J,q);return this._versionOptionName=U.attributeName(),this._registerOption(U),this.on("option:"+U.name(),()=>{this._outputConfiguration.writeOut(`${$}
|
|
22
|
+
`),this._exit(0,"commander.version",$)}),this}description($,J){if($===void 0&&J===void 0)return this._description;if(this._description=$,J)this._argsDescription=J;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let J=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)J=this.commands[this.commands.length-1];if($===J._name)throw Error("Command alias can't be the same as its name");let q=this.parent?._findCommand($);if(q){let U=[q.name()].concat(q.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${U}'`)}return J._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((J)=>this.alias(J)),this}usage($){if($===void 0){if(this._usage)return this._usage;let J=this.registeredArguments.map((q)=>{return o0(q)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?J:[]).join(" ")}return this._usage=$,this}name($){if($===void 0)return this._name;return this._name=$,this}nameFromFilename($){return this._name=y.basename($,y.extname($)),this}executableDir($){if($===void 0)return this._executableDir;return this._executableDir=$,this}helpInformation($){let J=this.createHelp();if(J.helpWidth===void 0)J.helpWidth=$&&$.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth();return J.formatHelp(this,J)}_getHelpContext($){$=$||{};let J={error:!!$.error},q;if(J.error)q=(U)=>this._outputConfiguration.writeErr(U);else q=(U)=>this._outputConfiguration.writeOut(U);return J.write=$.write||q,J.command=this,J}outputHelp($){let J;if(typeof $==="function")J=$,$=void 0;let q=this._getHelpContext($);this._getCommandAndAncestors().reverse().forEach((G)=>G.emit("beforeAllHelp",q)),this.emit("beforeHelp",q);let U=this.helpInformation(q);if(J){if(U=J(U),typeof U!=="string"&&!Buffer.isBuffer(U))throw Error("outputHelp callback must return a string or a Buffer")}if(q.write(U),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",q),this._getCommandAndAncestors().forEach((G)=>G.emit("afterAllHelp",q))}helpOption($,J){if(typeof $==="boolean"){if($)this._helpOption=this._helpOption??void 0;else this._helpOption=null;return this}return $=$??"-h, --help",J=J??"display help for command",this._helpOption=this.createOption($,J),this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption($){return this._helpOption=$,this}help($){this.outputHelp($);let J=E.exitCode||0;if(J===0&&$&&typeof $!=="function"&&$.error)J=1;this._exit(J,"commander.help","(outputHelp)")}addHelpText($,J){let q=["beforeAll","before","after","afterAll"];if(!q.includes($))throw Error(`Unexpected value for position to addHelpText.
|
|
23
|
+
Expecting one of '${q.join("', '")}'`);let U=`${$}Help`;return this.on(U,(G)=>{let X;if(typeof J==="function")X=J({error:G.error,command:G.command});else X=J;if(X)G.write(`${X}
|
|
24
|
+
`)}),this}_outputHelpIfRequested($){let J=this._getHelpOption();if(J&&$.find((U)=>J.is(U)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function M1($){return $.map((J)=>{if(!J.startsWith("--inspect"))return J;let q,U="127.0.0.1",G="9229",X;if((X=J.match(/^(--inspect(-brk)?)$/))!==null)q=X[1];else if((X=J.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(q=X[1],/^\d+$/.test(X[3]))G=X[3];else U=X[3];else if((X=J.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)q=X[1],U=X[3],G=X[4];if(q&&G!=="0")return`${q}=${U}:${parseInt(G)+1}`;return J})}e0.Command=n});var P1=A((U$)=>{var{Argument:F1}=v(),{Command:e}=T1(),{CommanderError:J$,InvalidArgumentError:D1}=b(),{Help:q$}=s(),{Option:y1}=i();U$.program=new e;U$.createCommand=($)=>new e($);U$.createOption=($,J)=>new y1($,J);U$.createArgument=($,J)=>new F1($,J);U$.Command=e;U$.Option=y1;U$.Argument=F1;U$.Help=q$;U$.CommanderError=J$;U$.InvalidArgumentError=D1;U$.InvalidOptionArgumentError=D1});var j1=j0(P1(),1),{program:F6,createCommand:D6,createArgument:y6,createOption:P6,CommanderError:j6,InvalidArgumentError:A6,InvalidOptionArgumentError:I6,Command:A1,Argument:N6,Option:O6,Help:f6}=j1.default;var I1="0.260202.0453";import{join as u$}from"path";var z=[];for(let $=0;$<256;++$)z.push(($+256).toString(16).slice(1));function N1($,J=0){return(z[$[J+0]]+z[$[J+1]]+z[$[J+2]]+z[$[J+3]]+"-"+z[$[J+4]]+z[$[J+5]]+"-"+z[$[J+6]]+z[$[J+7]]+"-"+z[$[J+8]]+z[$[J+9]]+"-"+z[$[J+10]]+z[$[J+11]]+z[$[J+12]]+z[$[J+13]]+z[$[J+14]]+z[$[J+15]]).toLowerCase()}import{randomFillSync as K$}from"crypto";var g=new Uint8Array(256),h=g.length;function $1(){if(h>g.length-16)K$(g),h=0;return g.slice(h,h+=16)}import{randomUUID as E$}from"crypto";var J1={randomUUID:E$};function z$($,J,q){if(J1.randomUUID&&!J&&!$)return J1.randomUUID();$=$||{};let U=$.random??$.rng?.()??$1();if(U.length<16)throw Error("Random bytes length must be >= 16");if(U[6]=U[6]&15|64,U[8]=U[8]&63|128,J){if(q=q||0,q<0||q+16>J.length)throw RangeError(`UUID byte range ${q}:${q+15} is out of buffer bounds`);for(let G=0;G<16;++G)J[q+G]=U[G];return J}return N1(U)}var u=z$;import{exec as L$}from"child_process";import{promisify as V$}from"util";import{join as M$}from"path";import{mkdirSync as T$,existsSync as F$}from"fs";import{homedir as D$}from"os";var y$=V$(L$);function P$(){let $=M$(D$(),".genie","logs","tmux");if(!F$($))T$($,{recursive:!0});return $}function j$($){return $.filter((J)=>!/^-v+$/.test(J))}function A$(){return process.env.GENIE_TMUX_DEBUG==="1"}async function O1($){let J=typeof $==="string"?$.split(/\s+/).filter(Boolean):$,q=j$(J),U=A$(),G={};if(U)q=["-v",...q],G.cwd=P$();let X=`tmux ${q.join(" ")}`,{stdout:Q}=await y$(X,G);return Q.trim()}var I$={type:"bash"};async function R($){try{return await O1($)}catch(J){throw Error(`Failed to execute tmux command: ${J.message}`)}}async function G1(){try{let J=await R("list-sessions -F '#{session_id}:#{session_name}:#{?session_attached,1,0}:#{session_windows}'");if(!J)return[];return J.split(`
|
|
25
|
+
`).map((q)=>{let[U,G,X,Q]=q.split(":");return{id:U,name:G,attached:X==="1",windows:parseInt(Q,10)}})}catch($){if($.message.includes("no server running"))return[];throw $}}async function K($){try{return(await G1()).find((q)=>q.name===$)||null}catch(J){return null}}async function L($){try{let q=await R(`list-windows -t '${$}' -F '#{window_id}:#{window_name}:#{?window_active,1,0}'`);if(!q)return[];return q.split(`
|
|
26
|
+
`).map((U)=>{let[G,X,Q]=U.split(":");return{id:G,name:X,active:Q==="1",sessionId:$}})}catch(J){if(J.message.includes("no server running")||J.message.includes("session not found"))return[];throw J}}async function M($){try{let q=await R(`list-panes -t '${$}' -F '#{pane_id}:#{pane_title}:#{?pane_active,1,0}'`);if(!q)return[];return q.split(`
|
|
27
|
+
`).map((U)=>{let[G,X,Q]=U.split(":");return{id:G,windowId:$,title:X,active:Q==="1"}})}catch(J){if(J.message.includes("no server running")||J.message.includes("window not found"))return[];throw J}}async function I($,J=200,q=!1){try{return await R(`capture-pane -p ${q?"-e":""} -t '${$}' -S -${J} -E -`)}catch(U){if(U.message.includes("no server running")||U.message.includes("pane not found"))return"";throw U}}async function l($){return await R(`new-session -d -s "${$}" -e LC_ALL=C.UTF-8 -e LANG=C.UTF-8`),K($)}async function d($,J){let q=await R(`new-window -t '${$}' -n '${J}'`);return(await L($)).find((G)=>G.name===J)||null}async function f1($){await R(`kill-session -t '${$}'`)}async function C1($){await R(`kill-window -t '${$}'`)}async function k1($){await R(`kill-pane -t '${$}'`)}async function w1($,J="vertical",q){let U="split-window";if(J==="horizontal")U+=" -h";else U+=" -v";if(U+=` -t '${$}'`,q!==void 0&&q>0&&q<100)U+=` -p ${q}`;await R(U);let G=await R(`display-message -p -t '${$}' '#{window_id}'`),X=await M(G);return X.length>0?X[X.length-1]:null}var q1=new Map,U1="TMUX_MCP_START",c="TMUX_MCP_DONE_";async function b1($,J,q,U){let G=u(),X;if(q||U)X=J;else{let Q=N$();X=`echo "${U1}"; ${J}; echo "${Q}"`}if(q1.set(G,{id:G,paneId:$,command:J,status:"pending",startTime:new Date,rawMode:q||U}),U)if(["Up","Down","Left","Right","Escape","Tab","Enter","Space","BSpace","Delete","Home","End","PageUp","PageDown","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"].includes(X))await R(`send-keys -t '${$}' ${X}`);else for(let Z of X)await R(`send-keys -t '${$}' '${Z.replace(/'/g,"'\\''")}'`);else await R(`send-keys -t '${$}' '${X.replace(/'/g,"'\\''")}' Enter`);return G}async function x1($){let J=q1.get($);if(!J)return null;if(J.status!=="pending")return J;let q=await I(J.paneId,1000);if(J.rawMode)return J.result="Status tracking unavailable for rawMode commands. Use capture-pane to monitor interactive apps instead.",J;let U=q.lastIndexOf(U1),G=q.lastIndexOf(c);if(U===-1||G===-1||G<=U)return J.result="Command output could not be captured properly",J;let X=q.substring(G).split(`
|
|
28
|
+
`)[0],Q=new RegExp(`${c}(\\d+)`),Z=X.match(Q);if(Z){let _=parseInt(Z[1],10);J.status=_===0?"completed":"error",J.exitCode=_;let Y=U+U1.length,S=q.substring(Y,G).trim();J.result=S.substring(S.indexOf(`
|
|
29
|
+
`)+1).trim(),q1.set($,J)}return J}function N$(){return I$.type==="fish"?`${c}$status`:`${c}$?`}async function v1($,J,q=120000){let U=u().substring(0,8),G=`/tmp/genie-${U}.out`,X=`/tmp/genie-${U}.exit`,Q=`genie-${U}`,_=`{ ${J.replace(/'/g,"'\\''")}; } 2>&1 | tee ${G}; echo \${PIPESTATUS[0]} > ${X}; tmux wait-for -S ${Q}`;await R(`send-keys -t '${$}' '${_.replace(/'/g,"'\\''")}' Enter`);try{await Promise.race([R(`wait-for ${Q}`),new Promise((W,B)=>setTimeout(()=>B(Error("Command timed out")),q))])}catch(W){if(W.message==="Command timed out"){try{await R(`wait-for -S ${Q}`)}catch{}return{output:"",exitCode:124}}throw W}let Y="",S=0;try{let{readFile:W,unlink:B}=await import("fs/promises");Y=await W(G,"utf-8"),Y=Y.trim();let H=await W(X,"utf-8");S=parseInt(H.trim(),10)||0,await B(G).catch(()=>{}),await B(X).catch(()=>{})}catch(W){console.error("Failed to read command output:",W)}return{output:Y,exitCode:S}}var{$:P}=globalThis.Bun;import{mkdir as h1,rm as g1,access as X1,readFile as O$,writeFile as f$}from"fs/promises";import{join as C,basename as C$}from"path";function p($){return $.replace(/\//g,"-").replace(/\\/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function k$($){let J=$.match(/^(\d+)([hdwm])$/i);if(!J)throw Error(`Invalid timeframe format: ${$}. Use format like 7d, 2w, 1m, 24h`);let q=parseInt(J[1],10),U=J[2].toLowerCase();return q*{h:3600000,d:86400000,w:604800000,m:2592000000}[U]}class u1{baseDir;repoPath;metadataPath;constructor($){this.baseDir=$.baseDir,this.repoPath=$.repoPath,this.metadataPath=C(this.baseDir,".metadata.json")}async loadMetadata(){try{let $=await O$(this.metadataPath,"utf-8");return JSON.parse($)}catch{return{worktrees:{}}}}async saveMetadata($){await h1(this.baseDir,{recursive:!0}),await f$(this.metadataPath,JSON.stringify($,null,2))}async createWorktree($,J=!1,q){let U=p($),G=C(this.baseDir,U);await h1(this.baseDir,{recursive:!0});try{throw await X1(G),Error(`Worktree already exists at ${G}`)}catch(Z){if(Z.code!=="ENOENT")throw Z}if(J)if(q)await P`git -C ${this.repoPath} worktree add -b ${$} ${G} ${q}`.quiet();else await P`git -C ${this.repoPath} worktree add -b ${$} ${G}`.quiet();else{if(!await this.branchExists($))throw Error(`Branch '${$}' does not exist. Use -b to create a new branch.`);await P`git -C ${this.repoPath} worktree add ${G} ${$}`.quiet()}let X=await this.loadMetadata();X.worktrees[U]={branch:$,createdAt:new Date().toISOString()},await this.saveMetadata(X);let Q=await this.getCommitHash(G);return{path:G,branch:$,commitHash:Q,createdAt:new Date}}async removeWorktree($){let J=p($),q=C(this.baseDir,J);try{await P`git -C ${this.repoPath} worktree remove ${q} --force`.quiet()}catch{try{await g1(q,{recursive:!0,force:!0})}catch{}}try{await X1(q),await g1(q,{recursive:!0,force:!0})}catch{}let U=await this.loadMetadata();delete U.worktrees[J],await this.saveMetadata(U)}async listWorktrees(){let J=(await P`git -C ${this.repoPath} worktree list --porcelain`.quiet()).stdout.toString(),q=[],U={};for(let Q of J.split(`
|
|
30
|
+
`))if(Q.startsWith("worktree ")){if(U.path)q.push(U);U={path:Q.slice(9)}}else if(Q.startsWith("HEAD "))U.commitHash=Q.slice(5);else if(Q.startsWith("branch "))U.branch=Q.slice(7).replace("refs/heads/","");if(U.path)q.push(U);let G=q.filter((Q)=>Q.path.startsWith(this.baseDir)),X=await this.loadMetadata();for(let Q of G){let Z=C$(Q.path),_=X.worktrees[Z];if(_)Q.createdAt=new Date(_.createdAt);Q.size=await this.getDiskUsage(Q.path)}return G}async cleanup($,J=!1){let q=k$($),U=Date.now(),G=await this.listWorktrees(),X=[];for(let Q of G)if(Q.createdAt){if(U-Q.createdAt.getTime()>q)X.push(Q)}if(!J)for(let Q of X)await this.removeWorktree(Q.branch);return X}async prune(){await P`git -C ${this.repoPath} worktree prune`.quiet()}async getDiskUsage($){try{let q=(await P`du -sb ${$}`.quiet()).stdout.toString().trim(),U=parseInt(q.split("\t")[0],10);return isNaN(U)?0:U}catch{return 0}}getWorktreePath($){let J=p($);return C(this.baseDir,J)}async worktreeExists($){let J=p($),q=C(this.baseDir,J);try{return await X1(q),!0}catch{return!1}}async branchExists($){try{return await P`git -C ${this.repoPath} rev-parse --verify ${$}`.quiet(),!0}catch{return!1}}async getCommitHash($){return(await P`git -C ${$} rev-parse HEAD`.quiet()).stdout.toString().trim()}}function k($){let J=$?.baseDir||C(process.cwd(),".worktrees"),q=$?.repoPath||process.cwd();return new u1({baseDir:J,repoPath:q})}import{mkdir as w$,readFile as b$,writeFile as x$,access as v$}from"fs/promises";import{join as c1}from"path";import{homedir as h$}from"os";var l1=c1(h$(),".config","term"),Q1=c1(l1,"sessions.json");async function g$(){await w$(l1,{recursive:!0})}async function Z1(){try{await v$(Q1);let $=await b$(Q1,"utf-8");return JSON.parse($)}catch{return{sessions:{}}}}async function d1($){await g$(),await x$(Q1,JSON.stringify($,null,2))}async function p1($,J){let q=await Z1();q.sessions[$]={...J,createdAt:new Date().toISOString()},await d1(q)}async function m1($){return(await Z1()).sessions[$]||null}async function r1($){let J=await Z1();delete J.sessions[$],await d1(J)}async function s1($,J={}){try{if(await K($))console.error(`\u274C Session "${$}" already exists`),process.exit(1);let U=J.workspace||process.cwd(),G;if(J.worktree){if(!J.workspace)console.error("\u274C --worktree requires --workspace"),process.exit(1);let Q=k({baseDir:u$(J.workspace,".worktrees"),repoPath:J.workspace});if(await Q.worktreeExists($))console.error(`\u274C Worktree for "${$}" already exists`),process.exit(1);let _=await Q.createWorktree($,!0);G=_.path,U=_.path,console.log(`\u2705 Worktree created at ${G}`)}if(!await l($))console.error(`\u274C Failed to create session "${$}"`),process.exit(1);if(await R(`send-keys -t '${$}' 'cd ${U}' Enter`),G)await p1($,{worktreePath:G,workspace:J.workspace});if(console.log(`\u2705 Session "${$}" created`),U!==process.cwd())console.log(` Working directory: ${U}`);console.log(`
|
|
31
|
+
To attach: term attach ${$}`)}catch(q){console.error(`\u274C Error creating session: ${q.message}`),process.exit(1)}}async function i1($={}){try{let J=await G1();if($.json){console.log(JSON.stringify(J,null,2));return}if(J.length===0){console.log("No tmux sessions found");return}console.log("SESSION ID\t\tNAME\t\t\tWINDOWS\t\tATTACHED"),console.log("\u2500".repeat(80));for(let q of J){let U=q.attached?"yes":"no";console.log(`${q.id} ${q.name} ${q.windows} ${U}`)}}catch(J){console.error(`Error listing sessions: ${J.message}`),process.exit(1)}}import{exec as d$}from"child_process";import{promisify as p$}from"util";var m$=p$(d$);async function t1($){try{if(!await K($))console.error(`\u274C Session "${$}" not found`),process.exit(1);console.log(`\uD83D\uDCCE Attaching to session "${$}"...`),await m$(`tmux attach -t "${$}"`)}catch(J){console.error(`\u274C Error attaching to session: ${J.message}`),process.exit(1)}}import{join as s$}from"path";async function o1($,J={}){try{let q=await K($);if(!q)console.error(`\u274C Session "${$}" not found`),process.exit(1);let U=await m1($);if(await f1(q.id),U?.worktreePath&&U?.workspace&&!J.keepWorktree)await k({baseDir:s$(U.workspace,".worktrees"),repoPath:U.workspace}).removeWorktree($),console.log(`\u2705 Session "${$}" and worktree removed`);else if(U?.worktreePath&&J.keepWorktree)console.log(`\u2705 Session "${$}" removed (worktree kept at ${U.worktreePath})`);else console.log(`\u2705 Session "${$}" removed`);if(U)await r1($)}catch(q){console.error(`\u274C Error removing session: ${q.message}`),process.exit(1)}}function x($){let q=$.split(`
|
|
32
|
+
`).filter((U)=>{let G=U.trim();if(G.match(/^TMUX_MCP_START$/))return!1;if(G.match(/^TMUX_MCP_DONE_\d+$/))return!1;if(G.includes("TMUX_MCP_START"))return!1;if(G.includes("TMUX_MCP_DONE_"))return!1;if(U.includes('echo "TMUX_MCP_START"'))return!1;if(U.includes('echo "TMUX_MCP_DONE_'))return!1;if(U.includes("-bash:"))return!1;if(U.includes("warning: setlocale:"))return!1;if(U.includes("cannot change locale"))return!1;if(G==="or directory")return!1;return!0});while(q.length>0&&q[0].trim()==="")q.shift();while(q.length>0&&q[q.length-1].trim()==="")q.pop();return q.join(`
|
|
33
|
+
`)}async function a1($,J={}){let q=await K($);if(!q)throw Error(`Session "${$}" not found`);let U=await L(q.id);if(!U||U.length===0)throw Error(`No windows found in session "${$}"`);let G=await M(U[0].id);if(!G||G.length===0)throw Error(`No panes found in session "${$}"`);let X=G[0].id;if(J.range){let _=J.range.split(":");if(_.length===2)J.from=parseInt(_[0],10),J.to=parseInt(_[1],10)}if(J.all){let _=await I(X,1e4);return x(_)}if(J.from!==void 0&&J.to!==void 0){let _=await I(X,1e4),W=x(_).split(`
|
|
34
34
|
`).slice(J.from,J.to+1).join(`
|
|
35
|
-
`);if(J.reverse)return
|
|
35
|
+
`);if(J.reverse)return W.split(`
|
|
36
36
|
`).reverse().join(`
|
|
37
|
-
`);return
|
|
38
|
-
`);try{let
|
|
39
|
-
`);return
|
|
40
|
-
`)}catch(
|
|
37
|
+
`);return W}if(J.search||J.grep){let _=J.search||J.grep,Y=await I(X,1e4),W=x(Y).split(`
|
|
38
|
+
`);try{let B=new RegExp(_,"i"),H=W.filter((T)=>B.test(T));if(J.reverse)return H.reverse().join(`
|
|
39
|
+
`);return H.join(`
|
|
40
|
+
`)}catch(B){throw Error(`Invalid regex pattern: ${B.message}`)}}let Q=J.lines||100,Z=await I(X,Q);if(Z=x(Z),J.reverse)Z=Z.split(`
|
|
41
41
|
`).reverse().join(`
|
|
42
|
-
`);return
|
|
43
|
-
`),
|
|
44
|
-
`),
|
|
45
|
-
Stopped following`),process.exit(0)}),await new Promise(()=>{});return}let U=await
|
|
46
|
-
`);console.log(JSON.stringify({session:$,lineCount:
|
|
42
|
+
`);return Z}async function n1($,J){let q=await K($);if(!q)throw Error(`Session "${$}" not found`);let U=await L(q.id);if(!U||U.length===0)throw Error(`No windows found in session "${$}"`);let G=await M(U[0].id);if(!G||G.length===0)throw Error(`No panes found in session "${$}"`);let X=G[0].id,Q="",Z=!0,_=setInterval(async()=>{if(!Z){clearInterval(_);return}try{let Y=await I(X,100),S=x(Y);if(S!==Q){let W=S.split(`
|
|
43
|
+
`),B=Q.split(`
|
|
44
|
+
`),H=B.length>0?B.length-1:0;W.slice(H).forEach((j)=>{if(j&&j!==B[B.length-1])J(j)}),Q=S}}catch(Y){clearInterval(_),Z=!1}},500);return()=>{Z=!1,clearInterval(_)}}async function e1($,J){try{let q={lines:J.lines?parseInt(J.lines,10):100,from:J.from?parseInt(J.from,10):void 0,to:J.to?parseInt(J.to,10):void 0,range:J.range,search:J.search,grep:J.grep,follow:J.follow,all:J.all,reverse:J.reverse};if(J.follow){console.log(`Following session "${$}" (Ctrl+C to stop)...`),console.log("");let G=await n1($,(X)=>{console.log(X)});process.on("SIGINT",()=>{G(),console.log(`
|
|
45
|
+
Stopped following`),process.exit(0)}),await new Promise(()=>{});return}let U=await a1($,q);if(J.json){let G=U.split(`
|
|
46
|
+
`);console.log(JSON.stringify({session:$,lineCount:G.length,content:G},null,2));return}console.log(U)}catch(q){console.error(`Error reading session logs: ${q.message}`),process.exit(1)}}async function $0($,J){let[q,U]=$.includes(":")?$.split(":"):[$,"shell"];try{let G=await K(q);if(!G){if(console.error(`Session "${q}" not found, creating...`),G=await l(q),!G)console.error(`Failed to create session "${q}"`),process.exit(1)}let Q=(await L(G.id)).find((S)=>S.name===U);if(!Q){if(console.error(`Window "${U}" not found, creating...`),Q=await d(G.id,U),!Q)console.error(`Failed to create window "${U}"`),process.exit(1)}let Z=await M(Q.id);if(!Z||Z.length===0)console.error(`No panes found in window "${U}"`),process.exit(1);let{output:_,exitCode:Y}=await v1(Z[0].id,J);if(_)console.log(_);process.exit(Y)}catch(G){console.error(`Error: ${G.message}`),process.exit(1)}}async function J0($,J){try{let q=await K($);if(!q)console.error(`\u274C Session "${$}" not found`),process.exit(1);let U=await L(q.id);if(!U||U.length===0)console.error(`\u274C No windows found in session "${$}"`),process.exit(1);let G=await M(U[0].id);if(!G||G.length===0)console.error(`\u274C No panes found in session "${$}"`),process.exit(1);let X=G[0].id;await b1(X,J,!1,!0),console.log(`\u2705 Keys sent to session "${$}"`)}catch(q){console.error(`\u274C Error sending keys: ${q.message}`),process.exit(1)}}import{join as e$}from"path";async function q0($,J,q={}){try{let U=await K($);if(!U)console.error(`\u274C Session "${$}" not found`),process.exit(1);let G=await L(U.id);if(!G||G.length===0)console.error(`\u274C No windows found in session "${$}"`),process.exit(1);let X=await M(G[0].id);if(!X||X.length===0)console.error(`\u274C No panes found in session "${$}"`),process.exit(1);let Q=X[0].id,Z=J==="h"?"horizontal":"vertical",_;if(q.worktree){if(!q.workspace)console.error("\u274C --worktree requires --workspace"),process.exit(1);let S=k({baseDir:e$(q.workspace,".worktrees"),repoPath:q.workspace});if(!await S.worktreeExists(q.worktree)){let B=await S.createWorktree(q.worktree,!0);console.log(`\u2705 Worktree created at ${B.path}`)}_=S.getWorktreePath(q.worktree)}else if(q.workspace)_=q.workspace;let Y=await w1(Q,Z);if(!Y)console.error("\u274C Failed to split pane"),process.exit(1);if(_&&Y)await R(`send-keys -t '${Y.id}' 'cd ${_}' Enter`);if(console.log(`\u2705 Pane split ${Z}ly in session "${$}"`),_)console.log(` Working directory: ${_}`)}catch(U){console.error(`\u274C Error splitting pane: ${U.message}`),process.exit(1)}}async function U0($,J){await R(`set-hook -g ${$} '${J.replace(/'/g,"'\\''")}'`)}async function G0($){await R(`set-hook -gu ${$}`)}async function X0(){let $=["after-bind-key","after-capture-pane","after-copy-mode","after-display-message","after-display-panes","after-kill-pane","after-list-buffers","after-list-clients","after-list-keys","after-list-panes","after-list-sessions","after-list-windows","after-load-buffer","after-lock-server","after-new-session","after-new-window","after-paste-buffer","after-pipe-pane","after-queue","after-refresh-client","after-rename-session","after-rename-window","after-resize-pane","after-resize-window","after-save-buffer","after-select-layout","after-select-pane","after-select-window","after-send-keys","after-set-buffer","after-set-environment","after-set-option","after-show-environment","after-show-messages","after-show-options","after-split-window","after-unbind-key","alert-activity","alert-bell","alert-silence","client-attached","client-detached","client-resized","client-session-changed","pane-died","pane-exited","pane-focus-in","pane-focus-out","pane-mode-changed","pane-set-clipboard","session-closed","session-created","session-renamed","session-window-changed","window-linked","window-pane-changed","window-renamed","window-unlinked"],J=[];for(let q of $)try{let U=await R(`show-hooks -g ${q}`);if(U.trim()){let G=U.trim().split(" ");if(G.length>=2)J.push({event:G[0],command:G.slice(1).join(" ")})}}catch(U){continue}return J}async function Q0($,J){try{await U0($,J),console.log(`\u2705 Hook set: ${$} \u2192 ${J}`)}catch(q){console.error(`\u274C Error setting hook: ${q.message}`),process.exit(1)}}async function Z0(){try{let $=await X0();if($.length===0){console.log("No hooks configured");return}console.log("EVENT\t\t\t\tCOMMAND"),console.log("\u2500".repeat(80));for(let J of $)console.log(`${J.event} ${J.command}`)}catch($){console.error(`\u274C Error listing hooks: ${$.message}`),process.exit(1)}}async function _0($){try{await G0($),console.log(`\u2705 Hook removed: ${$}`)}catch(J){console.error(`\u274C Error removing hook: ${J.message}`),process.exit(1)}}async function Y0($,J={}){try{let q=await K($);if(!q)console.error(`Session "${$}" not found`),process.exit(1);let U=await L(q.id);if(J.json){console.log(JSON.stringify(U,null,2));return}if(U.length===0){console.log("No windows found");return}console.log("WINDOW ID\t\tNAME\t\t\tACTIVE"),console.log("\u2500".repeat(60));for(let G of U){let X=G.active?"yes":"no";console.log(`${G.id} ${G.name} ${X}`)}}catch(q){console.error(`Error listing windows: ${q.message}`),process.exit(1)}}async function S0($,J){try{let q=await K($);if(!q)console.error(`Session "${$}" not found`),process.exit(1);let U=await d(q.id,J);if(U)console.log(`Window created: ${U.id}`);else console.error("Failed to create window"),process.exit(1)}catch(q){console.error(`Error creating window: ${q.message}`),process.exit(1)}}async function W0($){try{await C1($),console.log(`Window removed: ${$}`)}catch(J){console.error(`Error removing window: ${J.message}`),process.exit(1)}}async function H0($,J={}){try{let q=await K($);if(!q)console.error(`Session "${$}" not found`),process.exit(1);let U=await L(q.id);if(U.length===0){if(J.json)console.log("[]");else console.log("No panes found");return}let G=[];for(let X of U){let Q=await M(X.id);for(let Z of Q)G.push({id:Z.id,windowId:X.id,windowName:X.name,title:Z.title,active:Z.active})}if(J.json){console.log(JSON.stringify(G,null,2));return}if(G.length===0){console.log("No panes found");return}console.log("PANE ID\t\tWINDOW\t\t\tTITLE\t\t\tACTIVE"),console.log("\u2500".repeat(80));for(let X of G){let Q=X.active?"yes":"no",Z=X.title||"-";console.log(`${X.id} ${X.windowName} ${Z} ${Q}`)}}catch(q){console.error(`Error listing panes: ${q.message}`),process.exit(1)}}async function R0($){try{await k1($),console.log(`Pane removed: ${$}`)}catch(J){console.error(`Error removing pane: ${J.message}`),process.exit(1)}}async function B0($,J={}){try{if(J.command){await X6(J.command,J.json);return}let q=await K($);if(!q)console.error(`Session "${$}" not found`),process.exit(1);let U=await L(q.id),G=0;for(let Z of U){let _=await M(Z.id);G+=_.length}let X="idle",Q={session:q.name,id:q.id,attached:q.attached,windows:U.length,panes:G,state:X};if(J.json){console.log(JSON.stringify(Q,null,2));return}console.log(`Session: ${Q.session}`),console.log(`ID: ${Q.id}`),console.log(`Attached: ${Q.attached?"yes":"no"}`),console.log(`Windows: ${Q.windows}`),console.log(`Panes: ${Q.panes}`),console.log(`State: ${Q.state}`)}catch(q){console.error(`Error getting status: ${q.message}`),process.exit(1)}}async function X6($,J){try{let q=await x1($);if(!q)console.error(`Command "${$}" not found`),process.exit(1);let U={id:q.id,paneId:q.paneId,command:q.command,status:q.status,exitCode:q.exitCode,startTime:q.startTime.toISOString(),result:q.result};if(J){console.log(JSON.stringify(U,null,2));return}if(console.log(`Command: ${U.id}`),console.log(`Status: ${U.status}`),console.log(`Exit Code: ${U.exitCode??"N/A"}`),console.log(`Start Time: ${U.startTime}`),U.result)console.log(`
|
|
47
47
|
Output:
|
|
48
|
-
${U.result}`)}catch(q){console.error(`Error getting command status: ${q.message}`),process.exit(1)}}import{homedir as
|
|
48
|
+
${U.result}`)}catch(q){console.error(`Error getting command status: ${q.message}`),process.exit(1)}}import{homedir as K0}from"os";import{join as D}from"path";import{existsSync as N,readFileSync as E0,writeFileSync as Z6,mkdirSync as _6,appendFileSync as _1}from"fs";import*as z0 from"readline";function L0(){return`# Warp-like keyboard shortcuts (generated by genie-cli)
|
|
49
49
|
# To use: add to ~/.tmux.conf or source this file
|
|
50
50
|
|
|
51
51
|
# Ctrl+T: New window (tab) in current session
|
|
@@ -56,13 +56,13 @@ bind-key -n C-s split-window -v
|
|
|
56
56
|
|
|
57
57
|
# Alt+S: Horizontal split
|
|
58
58
|
bind-key -n M-s split-window -h
|
|
59
|
-
`}function
|
|
59
|
+
`}function V0(){return`# Warp-like extra keys (generated by genie-cli)
|
|
60
60
|
# To use: add to ~/.termux/termux.properties
|
|
61
61
|
|
|
62
62
|
# Extra keys row with F-keys for shortcuts
|
|
63
63
|
# F1=New Tab, F2=VSplit, F3=HSplit
|
|
64
64
|
extra-keys = [['ESC','TAB','CTRL','ALT','F1','F2','F3']]
|
|
65
|
-
`}function
|
|
65
|
+
`}function Y6(){return`# Warp-like shortcuts (generated by genie-cli)
|
|
66
66
|
# To use: add to ~/.bashrc or ~/.zshrc
|
|
67
67
|
|
|
68
68
|
# Disable Ctrl+S flow control (required for Ctrl+S to work in tmux)
|
|
@@ -99,7 +99,7 @@ genie-hsplit() {
|
|
|
99
99
|
bind -x '"eOP":"genie-new-tab"' 2>/dev/null # F1
|
|
100
100
|
bind -x '"eOQ":"genie-vsplit"' 2>/dev/null # F2
|
|
101
101
|
bind -x '"eOR":"genie-hsplit"' 2>/dev/null # F3
|
|
102
|
-
`}function
|
|
102
|
+
`}function S6(){console.log(`
|
|
103
103
|
Warp-like Terminal Shortcuts for tmux + Termux
|
|
104
104
|
|
|
105
105
|
\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\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
|
|
@@ -118,19 +118,19 @@ Commands:
|
|
|
118
118
|
term shortcuts --tmux Output tmux.conf snippet
|
|
119
119
|
term shortcuts --termux Output termux.properties snippet
|
|
120
120
|
term shortcuts --install Install to config files
|
|
121
|
-
`)}async function
|
|
122
|
-
`);let q=D($,".tmux.conf");if(O(q,"generated by genie-cli"))console.log("\u2713 tmux.conf already has genie shortcuts");else if(await
|
|
123
|
-
`+
|
|
124
|
-
`+
|
|
125
|
-
`+
|
|
121
|
+
`)}async function w($){let J=z0.createInterface({input:process.stdin,output:process.stdout});return new Promise((q)=>{J.question($,(U)=>{J.close(),q(U.trim().toLowerCase())})})}function O($,J){if(!N($))return!1;return E0($,"utf-8").includes(J)}async function W6(){let $=K0(),J="generated by genie-cli";console.log(`Installing Warp-like shortcuts...
|
|
122
|
+
`);let q=D($,".tmux.conf");if(O(q,"generated by genie-cli"))console.log("\u2713 tmux.conf already has genie shortcuts");else if(await w(`Add shortcuts to ${q}? [Y/n] `)!=="n"){let _=`
|
|
123
|
+
`+L0();_1(q,_),console.log(`\u2705 Added to ${q}`)}else console.log("\u23ED\uFE0F Skipped tmux.conf");let U=N(D($,".zshrc"))?D($,".zshrc"):D($,".bashrc");if(O(U,"generated by genie-cli"))console.log(`\u2713 ${U} already has genie shortcuts`);else if(await w(`Add shell functions to ${U}? [Y/n] `)!=="n"){let _=`
|
|
124
|
+
`+Y6();_1(U,_),console.log(`\u2705 Added to ${U}`)}else console.log(`\u23ED\uFE0F Skipped ${U}`);let G=D($,".termux"),X=D(G,"termux.properties"),Q=N(G)||process.env.TERMUX_VERSION;if(Q)if(O(X,"generated by genie-cli"))console.log("\u2713 termux.properties already has genie shortcuts");else if(await w(`Add extra keys to ${X}? [Y/n] `)!=="n"){if(!N(G))_6(G,{recursive:!0});let _=`
|
|
125
|
+
`+V0();_1(X,_),console.log(`\u2705 Added to ${X}`),console.log(" Run: termux-reload-settings")}else console.log("\u23ED\uFE0F Skipped termux.properties");if(console.log(`
|
|
126
126
|
\u2705 Installation complete!`),console.log(`
|
|
127
|
-
Next steps:`),console.log(" 1. Reload tmux: tmux source ~/.tmux.conf"),console.log(" 2. Restart your shell or run: source ~/.bashrc"),
|
|
128
|
-
`),
|
|
127
|
+
Next steps:`),console.log(" 1. Reload tmux: tmux source ~/.tmux.conf"),console.log(" 2. Restart your shell or run: source ~/.bashrc"),Q)console.log(" 3. Reload Termux: termux-reload-settings")}function D8($){return O($,"generated by genie-cli")}function Y1($,J){if(!N($))return!1;let q=E0($,"utf-8");if(!q.includes(J))return!1;let U=q.split(`
|
|
128
|
+
`),G=[],X=!1,Q=-1;for(let _=0;_<U.length;_++){let Y=U[_];if(Y.includes(J)&&!X){if(X=!0,Q===-1&&G.length>0&&G[G.length-1].trim()==="")G.pop();continue}if(X){if(Y.trim()===""&&_+1<U.length&&!U[_+1].includes("genie")){X=!1;continue}if(!(Y.includes("genie")||Y.includes("Ctrl+")||Y.includes("split-window")||Y.includes("new-window")||Y.includes("stty -ixon")||Y.includes("Warp-like")||Y.includes("bind-key -n")||Y.includes("extra-keys")||Y.includes("F1=")||Y.includes("bind -x")||Y.startsWith("#")&&U[_-1]?.includes("genie"))&&Y.trim()!=="")X=!1,G.push(Y);continue}G.push(Y)}while(G.length>0&&G[G.length-1].trim()==="")G.pop();let Z=G.length>0?G.join(`
|
|
129
129
|
`)+`
|
|
130
|
-
`:"";return Z6($,
|
|
131
|
-
`);let q=D($,".tmux.conf");if(!O(q,"generated by genie-cli"))console.log("\u2713 tmux.conf has no genie shortcuts");else if(await
|
|
130
|
+
`:"";return Z6($,Z),!0}async function y8(){let $=K0(),J="generated by genie-cli";console.log(`Uninstalling Warp-like shortcuts...
|
|
131
|
+
`);let q=D($,".tmux.conf");if(!O(q,"generated by genie-cli"))console.log("\u2713 tmux.conf has no genie shortcuts");else if(await w(`Remove shortcuts from ${q}? [Y/n] `)!=="n"){if(Y1(q,"generated by genie-cli"))console.log(`\u2705 Removed from ${q}`)}else console.log("\u23ED\uFE0F Skipped tmux.conf");let U=D($,".zshrc"),G=D($,".bashrc");for(let _ of[U,G]){if(!N(_))continue;if(!O(_,"generated by genie-cli"))console.log(`\u2713 ${_} has no genie shortcuts`);else if(await w(`Remove shell functions from ${_}? [Y/n] `)!=="n"){if(Y1(_,"generated by genie-cli"))console.log(`\u2705 Removed from ${_}`)}else console.log(`\u23ED\uFE0F Skipped ${_}`)}let X=D($,".termux"),Q=D(X,"termux.properties"),Z=N(X)||process.env.TERMUX_VERSION;if(Z)if(!O(Q,"generated by genie-cli"))console.log("\u2713 termux.properties has no genie shortcuts");else if(await w(`Remove extra keys from ${Q}? [Y/n] `)!=="n"){if(Y1(Q,"generated by genie-cli"))console.log(`\u2705 Removed from ${Q}`),console.log(" Run: termux-reload-settings")}else console.log("\u23ED\uFE0F Skipped termux.properties");if(console.log(`
|
|
132
132
|
\u2705 Uninstallation complete!`),console.log(`
|
|
133
|
-
Next steps:`),console.log(" 1. Reload tmux: tmux source ~/.tmux.conf"),console.log(" 2. Restart your shell or run: source ~/.bashrc"),
|
|
133
|
+
Next steps:`),console.log(" 1. Reload tmux: tmux source ~/.tmux.conf"),console.log(" 2. Restart your shell or run: source ~/.bashrc"),Z)console.log(" 3. Reload Termux: termux-reload-settings")}async function M0($){if($.tmux)console.log(L0());else if($.termux)console.log(V0());else if($.install)await W6();else S6()}var V=new A1;V.name("term").description(`AI-friendly terminal orchestration (tmux wrapper)
|
|
134
134
|
|
|
135
135
|
Workflow: new \u2192 exec \u2192 read \u2192 rm
|
|
136
|
-
Full control: window new/ls/rm, pane ls/rm, split, status`).version(
|
|
136
|
+
Full control: window new/ls/rm, pane ls/rm, split, status`).version(I1);V.command("new <name>").description("Create a new tmux session").option("-d, --workspace <path>","Working directory for the session").option("-w, --worktree","Create git worktree in .worktrees/<name>/").action(async($,J)=>{await s1($,J)});V.command("ls").description("List all tmux sessions").option("--json","Output as JSON").action(async($)=>{await i1($)});V.command("attach <name>").description("Attach to a tmux session").action(async($)=>{await t1($)});V.command("rm <name>").description("Remove a tmux session").option("--keep-worktree","Keep worktree folder when removing session").action(async($,J)=>{await o1($,J)});V.command("read <session>").description("Read logs from a tmux session").option("-n, --lines <number>","Number of lines to read (default: 100)","100").option("--from <line>","Start line number").option("--to <line>","End line number").option("--range <range>","Line range (e.g., 100:200)").option("--search <pattern>","Search for pattern").option("--grep <pattern>","Regex search pattern").option("-f, --follow","Follow mode (live tail)").option("--all","Export entire scrollback buffer").option("--reverse","Reverse chronological (newest first)").option("--json","Output as JSON").action(async($,J)=>{await e1($,J)});V.command("exec <session> <command...>").description("Execute command in a tmux session").action(async($,J)=>{await $0($,J.join(" "))});V.command("send <session> <keys>").description("Send raw keys to a tmux session").action(async($,J)=>{await J0($,J)});V.command("split <session> [direction]").description("Split pane in a tmux session (h=horizontal, v=vertical)").option("-d, --workspace <path>","Working directory for the new pane").option("-w, --worktree <branch>","Create git worktree in .worktrees/<branch>/").action(async($,J,q)=>{await q0($,J,q)});V.command("status <session>").description("Check session state (idle/busy, pane count)").option("--command <id>","Check specific command status").option("--json","Output as JSON").action(async($,J)=>{await B0($,J)});var S1=V.command("window").description("Manage tmux windows");S1.command("new <session> <name>").description("Create a new window in session").action(async($,J)=>{await S0($,J)});S1.command("ls <session>").description("List windows in session").option("--json","Output as JSON").action(async($,J)=>{await Y0($,J)});S1.command("rm <window-id>").description("Remove window by ID").action(async($)=>{await W0($)});var T0=V.command("pane").description("Manage tmux panes");T0.command("ls <session>").description("List all panes in session").option("--json","Output as JSON").action(async($,J)=>{await H0($,J)});T0.command("rm <pane-id>").description("Remove pane by ID").action(async($)=>{await R0($)});var W1=V.command("hook").description("Manage tmux hooks");W1.command("set <event> <command>").description("Set a tmux hook").action(async($,J)=>{await Q0($,J)});W1.command("list").description("List all tmux hooks").action(async()=>{await Z0()});W1.command("rm <event>").description("Remove a tmux hook").action(async($)=>{await _0($)});V.command("shortcuts").description("Warp-like keyboard shortcuts for tmux/Termux").option("--tmux","Output tmux.conf snippet").option("--termux","Output termux.properties snippet").option("--install","Install to config files (interactive)").action(async($)=>{await M0($)});V.parse();
|
package/package.json
CHANGED
package/src/lib/hook-script.ts
CHANGED
|
@@ -85,12 +85,19 @@ if [ -z "$COMMAND" ]; then
|
|
|
85
85
|
exit 0
|
|
86
86
|
fi
|
|
87
87
|
|
|
88
|
+
# Don't wrap commands that are already term exec calls (avoid infinite recursion)
|
|
89
|
+
if [[ "$COMMAND" == *"term exec "* ]] || [[ "$COMMAND" == *"/term.js exec"* ]] || [[ "$COMMAND" == *".local/bin/term "* ]] || [[ "$COMMAND" == *".genie/bin/term"* ]]; then
|
|
90
|
+
echo '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"allow"}}'
|
|
91
|
+
exit 0
|
|
92
|
+
fi
|
|
93
|
+
|
|
88
94
|
# Escape single quotes in the command for safe shell embedding
|
|
89
95
|
# Replace ' with '\\'\\''
|
|
90
96
|
ESCAPED_COMMAND=$(echo "$COMMAND" | sed "s/'/'\\\\'\\\\''/" )
|
|
91
97
|
|
|
92
98
|
# Build the wrapped command that goes through term exec
|
|
93
|
-
|
|
99
|
+
# Uses full path since Claude's subprocess may not have full PATH
|
|
100
|
+
WRAPPED_COMMAND="\$HOME/.local/bin/term exec ${sessionName}:\\\${CLAUDIO_SESSION:-claude} '\${ESCAPED_COMMAND}'"
|
|
94
101
|
|
|
95
102
|
# Extract other fields from the original input to preserve them
|
|
96
103
|
TIMEOUT=$(echo "$INPUT" | jq -r '.tool_input.timeout // empty')
|
package/src/lib/tmux.ts
CHANGED
|
@@ -404,3 +404,77 @@ export async function renameWindow(windowId: string, newName: string): Promise<v
|
|
|
404
404
|
await executeTmux(`rename-window -t '${windowId}' '${newName}'`);
|
|
405
405
|
}
|
|
406
406
|
|
|
407
|
+
/**
|
|
408
|
+
* Run a command synchronously in a tmux pane using wait-for.
|
|
409
|
+
*
|
|
410
|
+
* Uses tmux wait-for for proper synchronization (no polling).
|
|
411
|
+
* Output is captured via tee so it's visible in the pane AND returned.
|
|
412
|
+
*
|
|
413
|
+
* @returns {output: string, exitCode: number}
|
|
414
|
+
*/
|
|
415
|
+
export async function runCommandSync(
|
|
416
|
+
paneId: string,
|
|
417
|
+
command: string,
|
|
418
|
+
timeoutMs: number = 120000
|
|
419
|
+
): Promise<{ output: string; exitCode: number }> {
|
|
420
|
+
const id = uuidv4().substring(0, 8);
|
|
421
|
+
const outFile = `/tmp/genie-${id}.out`;
|
|
422
|
+
const exitFile = `/tmp/genie-${id}.exit`;
|
|
423
|
+
const channel = `genie-${id}`;
|
|
424
|
+
|
|
425
|
+
// Escape single quotes in command for shell embedding
|
|
426
|
+
const escapedCommand = command.replace(/'/g, "'\\''");
|
|
427
|
+
|
|
428
|
+
// Wrap command using tee for output capture:
|
|
429
|
+
// - Run command, pipe through tee (visible in terminal AND saved to file)
|
|
430
|
+
// - Capture exit code via PIPESTATUS
|
|
431
|
+
// - Signal completion via wait-for
|
|
432
|
+
const fullCommand = `{ ${escapedCommand}; } 2>&1 | tee ${outFile}; echo \${PIPESTATUS[0]} > ${exitFile}; tmux wait-for -S ${channel}`;
|
|
433
|
+
|
|
434
|
+
// Send command to pane
|
|
435
|
+
await executeTmux(`send-keys -t '${paneId}' '${fullCommand.replace(/'/g, "'\\''")}' Enter`);
|
|
436
|
+
|
|
437
|
+
// Wait for completion (blocks until signaled, with timeout)
|
|
438
|
+
try {
|
|
439
|
+
await Promise.race([
|
|
440
|
+
executeTmux(`wait-for ${channel}`),
|
|
441
|
+
new Promise((_, reject) =>
|
|
442
|
+
setTimeout(() => reject(new Error('Command timed out')), timeoutMs)
|
|
443
|
+
),
|
|
444
|
+
]);
|
|
445
|
+
} catch (error: any) {
|
|
446
|
+
if (error.message === 'Command timed out') {
|
|
447
|
+
// Clean up on timeout
|
|
448
|
+
try {
|
|
449
|
+
await executeTmux(`wait-for -S ${channel}`); // Unblock any waiters
|
|
450
|
+
} catch {}
|
|
451
|
+
return { output: '', exitCode: 124 };
|
|
452
|
+
}
|
|
453
|
+
throw error;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// Read output and exit code from files
|
|
457
|
+
let output = '';
|
|
458
|
+
let exitCode = 0;
|
|
459
|
+
|
|
460
|
+
try {
|
|
461
|
+
const { readFile, unlink } = await import('fs/promises');
|
|
462
|
+
|
|
463
|
+
output = await readFile(outFile, 'utf-8');
|
|
464
|
+
// Clean up output
|
|
465
|
+
output = output.trim();
|
|
466
|
+
|
|
467
|
+
const exitStr = await readFile(exitFile, 'utf-8');
|
|
468
|
+
exitCode = parseInt(exitStr.trim(), 10) || 0;
|
|
469
|
+
|
|
470
|
+
// Clean up temp files
|
|
471
|
+
await unlink(outFile).catch(() => {});
|
|
472
|
+
await unlink(exitFile).catch(() => {});
|
|
473
|
+
} catch (err) {
|
|
474
|
+
// If files don't exist, command may have failed to start
|
|
475
|
+
console.error('Failed to read command output:', err);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
return { output, exitCode };
|
|
479
|
+
}
|
|
480
|
+
|
package/src/lib/version.ts
CHANGED
|
@@ -13,7 +13,7 @@ export async function executeInSession(target: string, command: string): Promise
|
|
|
13
13
|
console.error(`Session "${sessionName}" not found, creating...`);
|
|
14
14
|
session = await tmux.createSession(sessionName);
|
|
15
15
|
if (!session) {
|
|
16
|
-
console.error(
|
|
16
|
+
console.error(`Failed to create session "${sessionName}"`);
|
|
17
17
|
process.exit(1);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -25,22 +25,29 @@ export async function executeInSession(target: string, command: string): Promise
|
|
|
25
25
|
console.error(`Window "${windowName}" not found, creating...`);
|
|
26
26
|
targetWindow = await tmux.createWindow(session.id, windowName);
|
|
27
27
|
if (!targetWindow) {
|
|
28
|
-
console.error(
|
|
28
|
+
console.error(`Failed to create window "${windowName}"`);
|
|
29
29
|
process.exit(1);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
// Get pane
|
|
33
|
+
// Get pane
|
|
34
34
|
const panes = await tmux.listPanes(targetWindow.id);
|
|
35
35
|
if (!panes || panes.length === 0) {
|
|
36
|
-
console.error(
|
|
36
|
+
console.error(`No panes found in window "${windowName}"`);
|
|
37
37
|
process.exit(1);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
// Run command synchronously using wait-for (no polling, no ugly markers)
|
|
41
|
+
const { output, exitCode } = await tmux.runCommandSync(panes[0].id, command);
|
|
42
|
+
|
|
43
|
+
// Output the result
|
|
44
|
+
if (output) {
|
|
45
|
+
console.log(output);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
process.exit(exitCode);
|
|
42
49
|
} catch (error: any) {
|
|
43
|
-
console.error(
|
|
50
|
+
console.error(`Error: ${error.message}`);
|
|
44
51
|
process.exit(1);
|
|
45
52
|
}
|
|
46
53
|
}
|