@buddysh/buddy 0.11.7 → 0.11.9
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/CHANGELOG.md +28 -0
- package/bin/cli.ts +18 -5
- package/dist/bin/cli.js +70 -70
- package/dist/chunk-00vbhh0z.js +2 -0
- package/dist/{chunk-wcjf072v.js → chunk-04qvf24t.js} +1 -1
- package/dist/{chunk-njfbmhm4.js → chunk-0apd8zqn.js} +7 -7
- package/dist/chunk-0y706m2d.js +2 -0
- package/dist/chunk-1aee33aa.js +2 -0
- package/dist/{chunk-fvhnza91.js → chunk-1m5wprvm.js} +1 -1
- package/dist/{chunk-2egzc1fp.js → chunk-1tg7dfq5.js} +1 -1
- package/dist/{chunk-5zs6jrpt.js → chunk-1vhqtq6m.js} +1 -1
- package/dist/{chunk-ysp81zyt.js → chunk-2145m12g.js} +1 -1
- package/dist/chunk-2fx0tbc0.js +2 -0
- package/dist/{chunk-w16pwfh3.js → chunk-2m0134q8.js} +1 -1
- package/dist/{chunk-1z4nhstx.js → chunk-34rmja4x.js} +1 -1
- package/dist/chunk-3ggd7z2f.js +2 -0
- package/dist/{chunk-675c6ddc.js → chunk-3waqfh3y.js} +1 -1
- package/dist/chunk-3xbx315d.js +2 -0
- package/dist/{chunk-3z759ya5.js → chunk-4akhxmfk.js} +1 -1
- package/dist/{chunk-q0tve4cm.js → chunk-4c3dws2k.js} +1 -1
- package/dist/{chunk-03j2dx5h.js → chunk-4hd1mryc.js} +1 -1
- package/dist/chunk-4k9f9vn2.js +2 -0
- package/dist/{chunk-3wy8fypy.js → chunk-4wbbbcs2.js} +1 -1
- package/dist/chunk-4zvjzesh.js +2 -0
- package/dist/chunk-5dw0q5ng.js +2 -0
- package/dist/chunk-5qtdc2mb.js +2 -0
- package/dist/{chunk-xe2xdg6z.js → chunk-61gfjcqt.js} +1 -1
- package/dist/chunk-6gttmvww.js +2 -0
- package/dist/{chunk-97cvp0t3.js → chunk-6wxwewbh.js} +1 -1
- package/dist/chunk-6xzzs109.js +3 -0
- package/dist/{chunk-4ycesykg.js → chunk-7bctsv0x.js} +1 -1
- package/dist/{chunk-0ewzxzt3.js → chunk-7crh00m7.js} +1 -1
- package/dist/{chunk-na0b9r57.js → chunk-7ds5q6j3.js} +1 -1
- package/dist/chunk-7f6mpphq.js +2 -0
- package/dist/{chunk-1q6s6a5e.js → chunk-7mmdxbcm.js} +1 -1
- package/dist/{chunk-p8azbpq6.js → chunk-7rjrea9g.js} +1 -1
- package/dist/chunk-7ze1qrmt.js +2 -0
- package/dist/{chunk-55znd3yn.js → chunk-88xaexj1.js} +1 -1
- package/dist/{chunk-f0z6kyqt.js → chunk-8dj94fsy.js} +1 -1
- package/dist/{chunk-yke7v3gh.js → chunk-8tsw3cjk.js} +1 -1
- package/dist/{chunk-q5pxt13t.js → chunk-90q6r1j7.js} +1 -1
- package/dist/chunk-9634xcvq.js +2 -0
- package/dist/{chunk-4wh0wryv.js → chunk-9m0epv44.js} +1 -1
- package/dist/{chunk-v8746363.js → chunk-a34szd4r.js} +3 -3
- package/dist/{chunk-ddmvjp0y.js → chunk-a3bnhq58.js} +1 -1
- package/dist/{chunk-d2d5m2kx.js → chunk-amj037yy.js} +2 -2
- package/dist/{chunk-j0bsva07.js → chunk-be059ncv.js} +1 -1
- package/dist/{chunk-m17kvr7m.js → chunk-bjymeq7e.js} +1 -1
- package/dist/{chunk-9b4z1bpx.js → chunk-d4wqe366.js} +1 -1
- package/dist/chunk-d7jpbw1z.js +9 -0
- package/dist/{chunk-qv1nvaha.js → chunk-db9rffcf.js} +1 -1
- package/dist/{chunk-zkv7e2q2.js → chunk-drkzf2gz.js} +1 -1
- package/dist/chunk-ea6rtyvy.js +2 -0
- package/dist/{chunk-t3a1703q.js → chunk-fpzgxg8a.js} +1 -1
- package/dist/{chunk-3d3rwmmj.js → chunk-ggzjv4s0.js} +1 -1
- package/dist/{chunk-sf4p2t84.js → chunk-gs5b2ssa.js} +1 -1
- package/dist/chunk-gw69sjx2.js +2 -0
- package/dist/{chunk-4rvgatmm.js → chunk-gyf7psxg.js} +1 -1
- package/dist/{chunk-wr1q4k9e.js → chunk-h8e796qs.js} +1 -1
- package/dist/{chunk-xzhzvdcv.js → chunk-hdqmcp3n.js} +1 -1
- package/dist/{chunk-x4ea69ek.js → chunk-hyp0wfta.js} +1 -1
- package/dist/{chunk-06k6abjj.js → chunk-j0fcqty9.js} +1 -1
- package/dist/{chunk-3zk2ye6r.js → chunk-jj1gjkb7.js} +1 -1
- package/dist/{chunk-39ne6m3w.js → chunk-jxd64dzs.js} +1 -1
- package/dist/{chunk-4mwgk0jh.js → chunk-k3x0mabj.js} +2 -2
- package/dist/{chunk-p96zq2zc.js → chunk-k7x9af5r.js} +1 -1
- package/dist/{chunk-7wk4px2k.js → chunk-kh6v93yb.js} +1 -1
- package/dist/{chunk-efqnnrwq.js → chunk-khn11t39.js} +1 -1
- package/dist/{chunk-z456ptfw.js → chunk-kpdz73mc.js} +1 -1
- package/dist/{chunk-a1fkxmxq.js → chunk-mdbf728w.js} +1 -1
- package/dist/{chunk-he97rsmj.js → chunk-mg3em5qj.js} +1 -1
- package/dist/chunk-mzb7cg8a.js +2 -0
- package/dist/{chunk-v6dephze.js → chunk-nwrr6jas.js} +1 -1
- package/dist/{chunk-srznv36n.js → chunk-p5yaf72b.js} +1 -1
- package/dist/{chunk-sczx20gw.js → chunk-p9z0hzej.js} +1 -1
- package/dist/{chunk-52jcty4n.js → chunk-pjq0qxst.js} +1 -1
- package/dist/chunk-pksrcdh6.js +2 -0
- package/dist/{chunk-cbqg29zr.js → chunk-pmszvhja.js} +1 -1
- package/dist/chunk-pxdrwhxx.js +3 -0
- package/dist/{chunk-1z9a3hpe.js → chunk-q90s02qc.js} +1 -1
- package/dist/chunk-qdmr84mc.js +5 -0
- package/dist/chunk-r7nh070r.js +106 -0
- package/dist/{chunk-qczzpthf.js → chunk-rg996jqw.js} +1 -1
- package/dist/{chunk-c87s8txp.js → chunk-rrnvxj90.js} +1 -1
- package/dist/{chunk-6sm15trq.js → chunk-s3ksf6s5.js} +1 -1
- package/dist/{chunk-qk43d3vv.js → chunk-s3q7g2hy.js} +1 -1
- package/dist/chunk-sdhyhefy.js +2 -0
- package/dist/{chunk-qz5nqeza.js → chunk-se4g70q2.js} +1 -1
- package/dist/{chunk-305184z3.js → chunk-srz5kgyg.js} +1 -1
- package/dist/chunk-sxdfmskp.js +2 -0
- package/dist/chunk-tf9nqr0p.js +2 -0
- package/dist/chunk-tm8eg4sk.js +2 -0
- package/dist/{chunk-f298fv6p.js → chunk-tq1w2wwa.js} +1 -1
- package/dist/{chunk-eftyxrxw.js → chunk-tx9m7y1z.js} +1 -1
- package/dist/chunk-w93akf6h.js +2 -0
- package/dist/chunk-wd8w0vjs.js +2 -0
- package/dist/{chunk-4b0p7kgk.js → chunk-wjmp2hsj.js} +1 -1
- package/dist/{chunk-f001yg2a.js → chunk-wreexgkb.js} +2 -2
- package/dist/chunk-xffrrs85.js +38 -0
- package/dist/{chunk-tgh61e5e.js → chunk-xps8n8nj.js} +1 -1
- package/dist/{chunk-4gx2f1k6.js → chunk-y7z0br2x.js} +1 -1
- package/dist/{chunk-wts1sqw7.js → chunk-y9senfb6.js} +1 -1
- package/dist/{chunk-sjk83y3d.js → chunk-ydt2sn0j.js} +1 -1
- package/dist/{chunk-5gybfx14.js → chunk-ysgex7h7.js} +1 -1
- package/dist/chunk-z0qbkvyz.js +2 -0
- package/dist/{chunk-nhe8axrf.js → chunk-z21tw4fz.js} +2 -2
- package/dist/chunk-zefqbamj.js +2 -0
- package/dist/{chunk-ztw515ew.js → chunk-zrg5ss0x.js} +1 -1
- package/dist/src/git/github-provider.d.ts +1 -0
- package/dist/src/git/provider.d.ts +1 -0
- package/dist/src/index.js +1 -1
- package/dist/src/setup.js +1 -1
- package/dist/src/utils/branches.d.ts +13 -0
- package/package.json +1 -1
- package/dist/chunk-19n3wnxq.js +0 -106
- package/dist/chunk-1n42ghef.js +0 -3
- package/dist/chunk-23c6tfbw.js +0 -2
- package/dist/chunk-2ppt1rrx.js +0 -2
- package/dist/chunk-2pv5zwbm.js +0 -38
- package/dist/chunk-3d5pjrz7.js +0 -5
- package/dist/chunk-3jw9d546.js +0 -2
- package/dist/chunk-4d13qb9f.js +0 -2
- package/dist/chunk-5ct11b1j.js +0 -2
- package/dist/chunk-6t1rb4tz.js +0 -2
- package/dist/chunk-9b2yfhzj.js +0 -9
- package/dist/chunk-a4m6bqpq.js +0 -2
- package/dist/chunk-djdf848n.js +0 -2
- package/dist/chunk-dsep28r5.js +0 -2
- package/dist/chunk-e6sg7jg4.js +0 -2
- package/dist/chunk-eme4fny7.js +0 -2
- package/dist/chunk-fjp4k18r.js +0 -2
- package/dist/chunk-gw3t78fw.js +0 -2
- package/dist/chunk-h4084ykd.js +0 -2
- package/dist/chunk-jczf4z85.js +0 -2
- package/dist/chunk-m2qq154g.js +0 -2
- package/dist/chunk-m8kqe55k.js +0 -2
- package/dist/chunk-n42c80f3.js +0 -2
- package/dist/chunk-nfcyqj66.js +0 -2
- package/dist/chunk-pvfavmy3.js +0 -2
- package/dist/chunk-rfgacg5h.js +0 -2
- package/dist/chunk-t0kvt1pm.js +0 -2
- package/dist/chunk-wfn702a2.js +0 -2
- package/dist/chunk-xpsetmcw.js +0 -2
- package/dist/chunk-yd834q68.js +0 -2
- package/dist/chunk-ymwjjyke.js +0 -2
package/dist/bin/cli.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{Uc as C1}from"../chunk-
|
|
3
|
+
import{Uc as C1}from"../chunk-xps8n8nj.js";import"../chunk-tx9m7y1z.js";import{dd as m}from"../chunk-r7nh070r.js";import"../chunk-p9z0hzej.js";import"../chunk-amj037yy.js";import"../chunk-4wbbbcs2.js";import"../chunk-89s9f3mf.js";import"../chunk-ja3rvd6y.js";import"../chunk-p5yaf72b.js";import{td as g}from"../chunk-mg3em5qj.js";import"../chunk-7crh00m7.js";import{Dd as R1,Ld as z0}from"../chunk-bggpgbdx.js";import"../chunk-be059ncv.js";import"../chunk-xny4kgcc.js";import{pe as Q0,qe as Q1,re as z1}from"../chunk-34rmja4x.js";import"../chunk-hyp0wfta.js";import"../chunk-4hd1mryc.js";import"../chunk-nwrr6jas.js";import"../chunk-kh6v93yb.js";import"../chunk-88j356ng.js";import"../chunk-3waqfh3y.js";import"../chunk-k7x9af5r.js";import"../chunk-jpdd59fh.js";import"../chunk-7rjrea9g.js";import"../chunk-emygmh7r.js";import"../chunk-kpqez1ht.js";import"../chunk-vckn5ate.js";import"../chunk-wreexgkb.js";import{sg as $0,wg as J0}from"../chunk-gvnsr72j.js";import"../chunk-1m5wprvm.js";import"../chunk-ktmgq0ja.js";import{$g as Y0,_g as SZ,ah as X0,bh as j0,ch as G0,dh as K0,eh as f,fh as y,hh as q0,ih as H0,jh as U0,kh as V0,lh as W0,oh as F0,ph as M0,qh as D0,rh as O0,sh as W1,th as L0,uh as T0}from"../chunk-9m0epv44.js";import"../chunk-hkb714k3.js";import"../chunk-6k6dgwmy.js";import{Dh as S1}from"../chunk-pxdrwhxx.js";import"../chunk-a3bnhq58.js";import{Lh as r,Mh as O}from"../chunk-8dj94fsy.js";import"../chunk-0apd8zqn.js";import{bl as CZ,dl as D}from"../chunk-s3ksf6s5.js";import e1 from"fs";import V from"process";import{EventEmitter as E0}from"events";import c from"process";import _1 from"process";import T1 from"process";import q1 from"process";import Z1 from"process";import d1 from"tty";import KZ,{stdin as iZ,stdout as aZ}from"process";import g1,{stdin as UZ,stdout as VZ}from"process";import WZ from"readline";import{existsSync as PZ}from"fs";import D1 from"fs/promises";import l1 from"os";import O1 from"path";import n from"process";function L1(Z){return Z.replace(/[<[].+/,"").trim()}function I0(Z){let $=/<([^>]+)>/g,J=/\[([^\]]+)\]/g,Q=[],z=(X)=>{let G=!1,j=X[1];if(j.startsWith("..."))j=j.slice(3),G=!0;else if(j.endsWith("..."))j=j.slice(0,-3),G=!0;return{required:X[0].startsWith("<"),value:j.trim(),variadic:G}},Y;while(Y=$.exec(Z))Q.push(z(Y));let U;while(U=J.exec(Z))Q.push(z(U));return Q}function B0(Z){let $={alias:{},boolean:[]};for(let[J,Q]of Z.entries()){if(Q.names.length>1)$.alias[Q.names[0]]=Q.names.slice(1);if(Q.isBoolean)if(Q.negated){if(!Z.some((Y,U)=>{return U!==J&&Y.names.some((X)=>Q.names.includes(X))&&typeof Y.required==="boolean"}))$.boolean.push(Q.names[0])}else $.boolean.push(Q.names[0])}return $}function f1(Z){return Z.reduce(($,J)=>$.length>=J.length?$:J,"")}function F1(Z,$){return Z.length>=$?Z:`${Z}${" ".repeat($-Z.length)}`}function K1(Z){return Z.replace(/([a-z])-([a-z])/g,($,J,Q)=>{return J+Q.toUpperCase()})}function P0(Z,$,J){let Q=0,z=$.length,Y=Z,U;for(;Q<z;++Q)U=Y[$[Q]],Y=Y[$[Q]]=Q===z-1?J:U!=null?U:!!~$[Q+1].indexOf(".")||!(+$[Q+1]>-1)?{}:[]}function N0(Z,$){for(let J of Object.keys($)){let Q=$[J];if(Z[J]===void 0)continue;if(Q.shouldTransform){if(Z[J]=Array.prototype.concat.call([],Z[J]),typeof Q.transformFunction==="function")Z[J]=Z[J].map(Q.transformFunction)}}}function A0(Z){let $=/([^\\/]+)$/.exec(Z);return $?$[1]:""}function $1(Z){return Z.split(".").map(($,J)=>{return J===0?K1($):$}).join(".")}class J1 extends Error{exitCode=2;isUsageError=!0;usage;constructor(Z,$){super(Z);if(this.name=this.constructor.name,$!==void 0)this.usage=$;if(typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,this.constructor);else this.stack=Error(Z).stack}format(Z=!1){if(Z&&this.stack)return`${this.message}
|
|
4
4
|
|
|
5
5
|
Stack trace:
|
|
6
|
-
${this.stack}`;return this.message}}function
|
|
6
|
+
${this.stack}`;return this.message}}function x0(Z){if(Z instanceof J1)return!0;return!!Z&&typeof Z==="object"&&Z.name==="ClappError"&&typeof Z.message==="string"}function R0(){let{env:Z}=_1,{TERM:$,TERM_PROGRAM:J}=Z;if(_1.platform!=="win32")return $!=="linux";return Boolean(Z.WT_SESSION)||Boolean(Z.TERMINUS_SUBLIME)||Z.ConEmuTask==="{cmd::Cmder}"||J==="Terminus-Sublime"||J==="vscode"||$==="xterm-256color"||$==="alacritty"||$==="rxvt-unicode"||$==="rxvt-unicode-256color"||Z.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var V1="\x1B",S=`${V1}[`;var u={to(Z,$){if(!$)return`${S}${Z+1}G`;return`${S}${$+1};${Z+1}H`},move(Z,$){let J="";if(Z<0)J+=`${S}${-Z}D`;else if(Z>0)J+=`${S}${Z}C`;if($<0)J+=`${S}${-$}A`;else if($>0)J+=`${S}${$}B`;return J},up:(Z=1)=>`${S}${Z}A`,down:(Z=1)=>`${S}${Z}B`,forward:(Z=1)=>`${S}${Z}C`,backward:(Z=1)=>`${S}${Z}D`,nextLine:(Z=1)=>`${S}E`.repeat(Z),prevLine:(Z=1)=>`${S}F`.repeat(Z),left:`${S}G`,hide:`${S}?25l`,show:`${S}?25h`,save:`${V1}7`,restore:`${V1}8`};var M1={screen:`${S}2J`,up:(Z=1)=>`${S}1J`.repeat(Z),down:(Z=1)=>`${S}J`.repeat(Z),line:`${S}2K`,lineEnd:`${S}K`,lineStart:`${S}1K`,lines(Z){let $="";for(let J=0;J<Z;J++)$+=this.line+(J<Z-1?u.up():"");if(Z)$+=u.left;return $}},mZ={screen:`${V1}c`};function C0(Z,$){let J=[];for(let Q=0;Q<=$.length;Q++)J[Q]=[Q];for(let Q=0;Q<=Z.length;Q++)J[0][Q]=Q;for(let Q=1;Q<=$.length;Q++)for(let z=1;z<=Z.length;z++)if($.charAt(Q-1)===Z.charAt(z-1))J[Q][z]=J[Q-1][z-1];else J[Q][z]=Math.min(J[Q-1][z-1]+1,J[Q][z-1]+1,J[Q-1][z]+1);return J[$.length][Z.length]}function p1(Z,$,J=2,Q=3){return $.map((z)=>({cmd:z,distance:C0(Z,z)})).filter(({distance:z})=>z<=J).sort((z,Y)=>z.distance-Y.distance).slice(0,Q).map(({cmd:z})=>z)}function S0(Z,$={}){let J={_:[]},Q=$.alias||{},z=new Set($.boolean||[]),Y={};for(let G of Object.keys(Q))for(let j of Q[G])Y[j]=G;for(let G of z)if(Q[G])for(let j of Q[G])z.add(j);function U(G,j){if(G===void 0)return j;if(typeof j==="boolean")return j;return Array.isArray(G)?[...G,j]:[G,j]}function X(G,j){let H=Y[G]||G,q=U(J[H],j);if(J[H]=q,Q[H])for(let K of Q[H])J[K]=q;if(Y[G]&&Q[Y[G]])for(let K of Q[Y[G]])J[K]=q;J[G]=q}for(let G=0;G<Z.length;G++){let j=Z[G];if(j==="--"){J._.push(...Z.slice(G+1));break}if(j.startsWith("--")){let H=j.indexOf("=");if(H!==-1){let q=K1(j.slice(2,H)),K=j.slice(H+1);X(q,K)}else{let q=j.slice(2);if(q.startsWith("no-")){let W=K1(q.slice(3));X(W,!1);continue}let K=K1(q),F=Y[K]||K;if(z.has(F)||z.has(K))X(K,!0);else{let W=Z[G+1];if(W!==void 0&&!W.startsWith("-"))X(K,W),G++;else X(K,!0)}}}else if(j.startsWith("-")&&j.length>1){let H=j.slice(1);for(let q=0;q<H.length;q++){let K=H[q],F=Y[K]||K;if(q===H.length-1&&!z.has(F)&&!z.has(K)){let W=Z[G+1];if(W!==void 0&&!W.startsWith("-"))X(K,W),G++;else X(K,!0)}else X(K,!0)}}else J._.push(j)}return J}class n1{rawName;description;name;names;isBoolean;required;config;negated;variadic;constructor(Z,$,J){if(this.rawName=Z,this.description=$,this.config=Object.assign({},J),Z=Z.replace(/\.\*/g,""),this.negated=!1,this.variadic=/[<[](?:\.\.\.[^\]>]+|[^\]>]+\.\.\.)[\]>]/.test(Z),this.names=L1(Z).split(",").map((Q)=>{let z=Q.trim().replace(/^-{1,2}/,"");if(z.startsWith("no-"))this.negated=!0,z=z.replace(/^no-/,"");return $1(z)}).sort((Q,z)=>Q.length>z.length?1:-1),this.name=this.names[this.names.length-1],this.negated&&this.config.default==null)this.config.default=!0;if(Z.includes("<"))this.required=!0;else if(Z.includes("["))this.required=!1;else this.isBoolean=!0}}var uZ=T1.argv,k0=`${T1.platform}-${T1.arch} bun-v${typeof Bun<"u"?Bun.version:"unknown"}`,m1=q1.argv,b0=`${q1.platform}-${q1.arch} node-${q1.version}`;class w1{rawName;description;config;cli;options;aliasNames;name;namespace;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;beforeHooks;afterHooks;middleware;constructor(Z,$,J,Q){this.rawName=Z,this.description=$,this.config=J,this.cli=Q,this.options=[],this.aliasNames=[],this.name=L1(Z);let z=L1(Z),Y=z.indexOf(":");if(Y>0)this.namespace=z.substring(0,Y),this.name=z.substring(Y+1);if(this.args=I0(Z),this.examples=[],this.beforeHooks=[],this.afterHooks=[],this.middleware=[],!J)this.config={}}usage(Z){return this.usageText=Z,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(Z,$="-v, --version"){return this.versionNumber=Z,this.option($,"Display version number"),this}example(Z){return this.examples.push(Z),this}option(Z,$,J){let Q=new n1(Z,$,J);return this.options.push(Q),this}alias(Z){return this.aliasNames.push(Z),this}action(Z){return this.commandAction=Z,this}before(Z){return this.beforeHooks.push(Z),this}after(Z){return this.afterHooks.push(Z),this}use(Z){return this.middleware.push(Z),this}isMatched(Z){if(this.aliasNames.includes(Z))return!0;if(this.namespace)return`${this.namespace}:${this.name}`===Z;return this.name===Z}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof E1}get displayName(){return this.namespace?`${this.namespace}:${this.name}`:this.name}hasOption(Z){let $=$1(Z.split(".")[0]);return!!this.options.find((J)=>{return J.names.some((Q)=>$1(Q)===$)})}outputHelp(){let{name:Z,commands:$}=this.cli,{versionNumber:J,options:Q,helpCallback:z}=this.cli.globalCommand,Y=[{body:`${Z}${J?`/${J}`:""}`}];if(Y.push({title:"Usage",body:` $ ${Z} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&$.length>0){let j=f1($.map((W)=>W.rawName)),H=new Map,q=[];for(let W of $)if(W.namespace){if(!H.has(W.namespace))H.set(W.namespace,[]);H.get(W.namespace).push(W)}else q.push(W);let K="";if(q.sort((W,T)=>W.rawName<T.rawName?-1:W.rawName>T.rawName?1:0),q.length>0)K+=q.map((W)=>{return` ${F1(W.rawName,j.length)} ${W.description}`}).join(`
|
|
7
7
|
`);let F=Array.from(H.keys()).sort();for(let W of F){let T=H.get(W);if(K.length>0)K+=`
|
|
8
8
|
|
|
9
9
|
`;K+=` ${W}:
|
|
10
|
-
`,K+=T.map((A)=>{return` ${F1(A.rawName,
|
|
11
|
-
`)}Y.push({title:"Commands",body:K}),Y.push({body:`Run \`${Z} <command> --help\` for command details.`})}let
|
|
12
|
-
`)})}if(this.examples.length>0)Y.push({title:"Examples",body:this.examples.map((
|
|
13
|
-
`)});if(z)Y=z(Y)||Y;console.log(Y.map((
|
|
14
|
-
${
|
|
10
|
+
`,K+=T.map((A)=>{return` ${F1(A.rawName,j.length-2)} ${A.description}`}).join(`
|
|
11
|
+
`)}Y.push({title:"Commands",body:K}),Y.push({body:`Run \`${Z} <command> --help\` for command details.`})}let X=new Set(this.options.flatMap((j)=>j.names)),G=this.isGlobalCommand?Q:[...this.options,...(Q||[]).filter((j)=>!j.names.some((H)=>X.has(H)))];if(!this.isGlobalCommand&&!this.isDefaultCommand)G=G.filter((j)=>j.name!=="version");if(G.length>0){let j=f1(G.map((H)=>H.rawName));Y.push({title:"Options",body:G.map((H)=>{return` ${F1(H.rawName,j.length)} ${H.description} ${H.config.default===void 0?"":`(default: ${H.config.default})`}`}).join(`
|
|
12
|
+
`)})}if(this.examples.length>0)Y.push({title:"Examples",body:this.examples.map((j)=>{if(typeof j==="function")return j(Z);return j}).join(`
|
|
13
|
+
`)});if(z)Y=z(Y)||Y;console.log(Y.map((j)=>{return j.title?`${j.title}:
|
|
14
|
+
${j.body}`:j.body}).join(`
|
|
15
15
|
|
|
16
|
-
`))}outputVersion(){let{name:Z}=this.cli,{versionNumber:$}=this.cli.globalCommand;if($)console.log(`${Z}/${$} ${typeof Bun<"u"?
|
|
16
|
+
`))}outputVersion(){let{name:Z}=this.cli,{versionNumber:$}=this.cli.globalCommand;if($)console.log(`${Z}/${$} ${typeof Bun<"u"?k0:b0}`)}get usageLine(){return`$ ${this.cli.name} ${this.usageText||this.rawName}`}checkRequiredArgs(){let Z=this.args.filter(($)=>$.required).length;if(this.cli.args.length<Z){let J=this.args.filter((z)=>z.required).slice(this.cli.args.length),Q=J.map((z)=>`<${z.value}>`).join(" ");throw new J1(`Missing required argument${J.length>1?"s":""}: ${Q}
|
|
17
17
|
|
|
18
|
-
Run \`${this.cli.name} ${this.rawName} --help\` for usage information.`,this.usageLine)}}checkUnknownOptions(){let{options:Z,globalCommand:$}=this.cli;if(!this.config.allowUnknownOptions){for(let J of Object.keys(Z))if(J!=="--"&&!this.hasOption(J)&&!$.hasOption(J)){let z=[...$.options,...this.options].flatMap((
|
|
18
|
+
Run \`${this.cli.name} ${this.rawName} --help\` for usage information.`,this.usageLine)}}checkUnknownOptions(){let{options:Z,globalCommand:$}=this.cli;if(!this.config.allowUnknownOptions){for(let J of Object.keys(Z))if(J!=="--"&&!this.hasOption(J)&&!$.hasOption(J)){let z=[...$.options,...this.options].flatMap((j)=>j.names),Y=$1(J.split(".")[0]),U=J.length>1?`--${J}`:`-${J}`,X=p1(Y,z),G=`Unknown option \`${U}\``;if(X.length>0)G+=`
|
|
19
19
|
|
|
20
|
-
Did you mean one of these?`,
|
|
20
|
+
Did you mean one of these?`,X.forEach((j)=>{let H=j.length>1?`--${j}`:`-${j}`;G+=`
|
|
21
21
|
\u2022 ${H}`});throw G+=`
|
|
22
22
|
|
|
23
23
|
Run \`${this.cli.name} ${this.rawName} --help\` to see available options.`,new J1(G,this.usageLine)}}}checkOptionValue(){let{options:Z,globalCommand:$}=this.cli,J=[...$.options,...this.options];for(let Q of J){let z=Z[Q.name.split(".")[0]];if(Q.required){let Y=J.some((U)=>U.negated&&U.names.includes(Q.name));if(z===!0||z===!1&&!Y)throw new J1(`Option \`${Q.rawName}\` requires a value.
|
|
24
24
|
|
|
25
|
-
Example: ${this.cli.name} ${this.rawName} ${Q.rawName} <value>`,this.usageLine)}}}}class E1 extends w1{constructor(Z){super("@@global@@","",{},Z)}}var
|
|
25
|
+
Example: ${this.cli.name} ${this.rawName} ${Q.rawName} <value>`,this.usageLine)}}}}class E1 extends w1{constructor(Z){super("@@global@@","",{},Z)}}var h0=w1,l={red:["\x1B[31m","\x1B[39m"],green:["\x1B[32m","\x1B[39m"],blue:["\x1B[34m","\x1B[39m"],yellow:["\x1B[33m","\x1B[39m"],cyan:["\x1B[36m","\x1B[39m"],magenta:["\x1B[35m","\x1B[39m"],white:["\x1B[37m","\x1B[39m"],gray:["\x1B[90m","\x1B[39m"],bgRed:["\x1B[41m","\x1B[49m"],bgGreen:["\x1B[42m","\x1B[49m"],bgBlue:["\x1B[44m","\x1B[49m"],bgYellow:["\x1B[43m","\x1B[49m"],bgCyan:["\x1B[46m","\x1B[49m"],bgMagenta:["\x1B[45m","\x1B[49m"],bold:["\x1B[1m","\x1B[22m"],italic:["\x1B[3m","\x1B[23m"],underline:["\x1B[4m","\x1B[24m"],dim:["\x1B[2m","\x1B[22m"],inverse:["\x1B[7m","\x1B[27m"],hidden:["\x1B[8m","\x1B[28m"],strikethrough:["\x1B[9m","\x1B[29m"]};var o={primary:"blue",secondary:"cyan",success:"green",warning:"yellow",error:"red",info:"magenta",muted:"gray"};function y0(){return!0}function v0(){let Z={};Z.supportsColor=y0();function $(Q,z=[]){let Y=Q===""?[]:[...z,Q],U=function(G){if(!Z.supportsColor)return G;let j="",H="";for(let q of Y)if(q in o&&o[q]in l){let K=o[q];j+=l[K][0],H=l[K][1]+H}else if(q in l)j+=l[q][0],H=l[q][1]+H;return j+G+H},X=[...Object.keys(l),...Object.keys(o)];for(let G of X)if(!(G in U))Object.defineProperty(U,G,{get(){return $(G,Y)}});return U}let J=[...Object.keys(l),...Object.keys(o)];for(let Q of J)if(!(Q in Z))Object.defineProperty(Z,Q,{get(){return $(Q)}});return Z}var e=v0();class I1 extends E0{name;commands;globalCommand;matchedCommand;matchedCommandName;rawArgs;args;options;showHelpOnExit;showVersionOnExit;enableDidYouMean=!0;signalHandlersSet=!1;isVerbose=!1;isQuiet=!1;isDebug=!1;isNoInteraction=!1;environment;isDryRun=!1;isForce=!1;useEmoji=!0;theme;isNoCache=!1;constructor(Z=""){super();this.name=Z,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new E1(this),this.globalCommand.usage("<command> [options]")}handleSignals(Z){if(this.signalHandlersSet)return this;let $=async(J)=>{if(console.log(`
|
|
26
26
|
|
|
27
|
-
Received ${J}, cleaning up...`),Z)try{await Z()}catch(Q){console.error("Error during cleanup:",Q)}c.exit(0)};return c.on("SIGINT",()=>$("SIGINT")),c.on("SIGTERM",()=>$("SIGTERM")),this.signalHandlersSet=!0,this}didYouMean(Z=!0){return this.enableDidYouMean=Z,this}verbose(){return this.globalCommand.option("-v, --verbose","Enable verbose output"),this}quiet(){return this.globalCommand.option("-q, --quiet","Suppress non-essential output"),this}debug(){return this.globalCommand.option("--debug","Enable debug mode with detailed error information"),this}noInteraction(){return this.globalCommand.option("-n, --no-interaction","Do not ask any interactive questions (for CI/CD)"),this}env(){return this.globalCommand.option("--env <environment>","Target environment (e.g., production, staging, local)"),this}dryRun(){return this.globalCommand.option("--dry-run","Preview actions without executing them"),this}force(){return this.globalCommand.option("-f, --force","Skip confirmation prompts"),this}emoji(){return this.globalCommand.option("--no-emoji","Disable emoji in output"),this}themes(){return this.globalCommand.option("--theme <theme>","Color theme (default, dracula, nord, solarized, monokai)"),this}cache(){return this.globalCommand.option("--no-cache","Disable caching"),this}usage(Z){return this.globalCommand.usage(Z),this}command(Z,$,J){if(!J)J={};let Q=new
|
|
27
|
+
Received ${J}, cleaning up...`),Z)try{await Z()}catch(Q){console.error("Error during cleanup:",Q)}c.exit(0)};return c.on("SIGINT",()=>$("SIGINT")),c.on("SIGTERM",()=>$("SIGTERM")),this.signalHandlersSet=!0,this}didYouMean(Z=!0){return this.enableDidYouMean=Z,this}verbose(){return this.globalCommand.option("-v, --verbose","Enable verbose output"),this}quiet(){return this.globalCommand.option("-q, --quiet","Suppress non-essential output"),this}debug(){return this.globalCommand.option("--debug","Enable debug mode with detailed error information"),this}noInteraction(){return this.globalCommand.option("-n, --no-interaction","Do not ask any interactive questions (for CI/CD)"),this}env(){return this.globalCommand.option("--env <environment>","Target environment (e.g., production, staging, local)"),this}dryRun(){return this.globalCommand.option("--dry-run","Preview actions without executing them"),this}force(){return this.globalCommand.option("-f, --force","Skip confirmation prompts"),this}emoji(){return this.globalCommand.option("--no-emoji","Disable emoji in output"),this}themes(){return this.globalCommand.option("--theme <theme>","Color theme (default, dracula, nord, solarized, monokai)"),this}cache(){return this.globalCommand.option("--no-cache","Disable caching"),this}usage(Z){return this.globalCommand.usage(Z),this}command(Z,$,J){if(!J)J={};let Q=new h0(Z,$||"",J,this);return Q.globalCommand=this.globalCommand,this.commands.push(Q),Q}option(Z,$,J){return this.globalCommand.option(Z,$,J),this}help(Z){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=Z,this.showHelpOnExit=!0,this}version(Z,$="-v, --version"){return this.globalCommand.version(Z,$),this.showVersionOnExit=!0,this}example(Z){return this.globalCommand.example(Z),this}outputHelp(){if(this.matchedCommand)this.matchedCommand.outputHelp();else this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:Z,options:$},J,Q){if(this.args=Z,this.options=$,J)this.matchedCommand=J;if(Q)this.matchedCommandName=Q;return this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}showCommandNotFound(Z){if(console.log(e.red(`
|
|
28
28
|
\u2717 Command "${Z}" not found.
|
|
29
|
-
`)),this.enableDidYouMean){let $=[];for(let Q of this.commands){if(Q.displayName)$.push(Q.displayName);if(Q.aliasNames)$.push(...Q.aliasNames)}let J=
|
|
29
|
+
`)),this.enableDidYouMean){let $=[];for(let Q of this.commands){if(Q.displayName)$.push(Q.displayName);if(Q.aliasNames)$.push(...Q.aliasNames)}let J=p1(Z,$);if(J.length>0)console.log(e.yellow("Did you mean one of these?")),J.forEach((Q)=>console.log(` ${e.dim("\u2022")} ${this.name} ${Q}`)),console.log("")}console.log(e.dim("Run"),`${this.name} --help`,e.dim("to see all available commands")),c.exit(1)}async parse(Z=m1,$={}){let{run:J=!0,exitOnError:Q=!1}=$;if(Q)try{return await this.parse(Z,{run:J})}catch(G){throw this.handleUsageError(G),G}if(this.rawArgs=Z,!this.name)this.name=Z[1]?A0(Z[1]):"cli";let z=!0,Y=Z.slice(2),U=Y[0];if(U&&!U.startsWith("-")){for(let G of this.commands)if(G.isMatched(U)){let j=this.mri(Y,G);z=!1;let H={...j,args:j.args.slice(1)};this.setParsedInfo(H,G,U),this.emit(`command:${U}`,G);break}if(z){let G=Y[1];if(G&&!G.startsWith("-")){let j=`${U}:${G}`;for(let H of this.commands)if(H.isMatched(j)){let q=this.mri(Y,H);z=!1;let K={...q,args:q.args.slice(2)};this.setParsedInfo(K,H,j),this.emit(`command:${j}`,H);break}}}}if(z){for(let G of this.commands)if(G.name===""){z=!1;let j=this.mri(Y,G);this.setParsedInfo(j,G),this.emit("command:!",G);break}}if(z){let G=this.mri(Z.slice(2));this.setParsedInfo(G)}if(this.options.verbose)this.isVerbose=!0;if(this.options.quiet)this.isQuiet=!0;if(this.options.debug)this.isDebug=!0;if(this.options.noInteraction||this.options.interaction===!1)this.isNoInteraction=!0;if(this.options.env)this.environment=String(this.options.env);if(this.options.dryRun)this.isDryRun=!0;if(this.options.force)this.isForce=!0;if(this.options.noEmoji||this.options.emoji===!1)this.useEmoji=!1;if(this.options.theme)this.theme=String(this.options.theme);if(this.options.noCache||this.options.cache===!1)this.isNoCache=!0;if(this.options.help&&this.showHelpOnExit)this.outputHelp(),J=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),J=!1,this.unsetMatchedCommand();let X={args:this.args,options:this.options};if(J)await this.runMatchedCommand();if(!this.matchedCommand&&this.args[0]){if(this.emit("command:*"),!(this.listenerCount("command:*")>0))this.showCommandNotFound(this.args[0])}return X}mri(Z,$){let J=[...this.globalCommand.options,...$?$.options:[]],Q=B0(J),z=[],Y=Z.indexOf("--");if(Y>-1)z=Z.slice(Y+1),Z=Z.slice(0,Y);let U=S0(Z,Q),X={_:U._};for(let K of Object.keys(U))if(K!=="_")X[$1(K)]=U[K];let G=X._,j={"--":z},H=$&&$.config.ignoreOptionDefaultValue?$.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,q=Object.create(null);for(let K of J){if(!H&&K.config.default!==void 0)for(let F of K.names)j[F]=K.config.default;if(Array.isArray(K.config.type)){if(q[K.name]===void 0)q[K.name]={shouldTransform:!0,transformFunction:K.config.type[0]}}}for(let K of Object.keys(X))if(K!=="_"){let F=K.split(".");P0(j,F,X[K]),N0(j,q)}for(let K of J){if(!K.variadic)continue;for(let F of K.names){let W=j[F];if(W===void 0||Array.isArray(W))continue;if(K.config.default!==void 0&&W===K.config.default)continue;j[F]=[W]}}return{args:G,options:j}}async run(Z=m1){return this.parse(Z,{run:!0,exitOnError:!0})}handleUsageError(Z){if(!x0(Z)||Z.isUsageError===!1)return;let $=Z.message||"command-line error",J=this.name?`${this.name}: `:"",Q=/--help/.test($)?"":Z.usage?`
|
|
30
30
|
Usage: ${Z.usage}`:`
|
|
31
31
|
Run \`${this.name??"cli"} --help\` for usage.`;c.stderr.write(`${J}${$}${Q}
|
|
32
|
-
`),c.exit(Z.exitCode??2)}async runMatchedCommand(){let{args:Z,options:$,matchedCommand:J}=this;if(!J||!J.commandAction)return;J.checkUnknownOptions(),J.checkOptionValue(),J.checkRequiredArgs();let Q=[];J.args.forEach((
|
|
32
|
+
`),c.exit(Z.exitCode??2)}async runMatchedCommand(){let{args:Z,options:$,matchedCommand:J}=this;if(!J||!J.commandAction)return;J.checkUnknownOptions(),J.checkOptionValue(),J.checkRequiredArgs();let Q=[];J.args.forEach((X,G)=>{if(X.variadic)Q.push(Z.slice(G));else Q.push(Z[G])}),Q.push($);let z={command:J,args:Q,options:$};for(let X of J.beforeHooks)await X(z);let Y,U=async()=>{let X=J.commandAction.apply(this,Q);if(X instanceof Promise)Y=await X;else Y=X;return Y};if(J.middleware.length>0){let X=0,G=async()=>{if(X<J.middleware.length){let j=J.middleware[X++];await j({...z,next:G})}else await U()};await G()}else await U();for(let X of J.afterHooks)await X(z);return Y}removeSignalHandlers(){if(!this.signalHandlersSet)return this;return c.removeAllListeners("SIGINT"),c.removeAllListeners("SIGTERM"),this.signalHandlersSet=!1,this}destroy(){this.removeSignalHandlers(),this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.matchedCommand=void 0,this.matchedCommandName=void 0,this.removeAllListeners()}}class i1{cache;enabled;cleanupInterval=null;hits=0;misses=0;constructor(){this.cache=new Map,this.enabled=!0,this.startCleanupInterval()}startCleanupInterval(){if(this.cleanupInterval)return;this.cleanupInterval=setInterval(()=>{this.cleanup()},30000),this.cleanupInterval.unref()}stopCleanup(){if(this.cleanupInterval)clearInterval(this.cleanupInterval),this.cleanupInterval=null}isEnabled(){return this.enabled}get(Z){if(!this.enabled){this.misses++;return}let $=this.cache.get(Z);if(!$){this.misses++;return}if(Date.now()-$.timestamp>$.ttl){this.cache.delete(Z),this.misses++;return}return this.hits++,$.value}set(Z,$,J=5000){if(!this.enabled)return;this.cache.set(Z,{value:$,timestamp:Date.now(),ttl:J})}has(Z){if(!this.enabled)return!1;let $=this.cache.get(Z);if(!$)return!1;if(Date.now()-$.timestamp>$.ttl)return this.cache.delete(Z),!1;return!0}delete(Z){this.cache.delete(Z)}clear(){this.cache.clear()}disable(){this.enabled=!1,this.clear()}enable(){this.enabled=!0}stats(){return{size:this.cache.size,enabled:this.enabled,hits:this.hits,misses:this.misses}}resetStats(){this.hits=0,this.misses=0}keys(){return Array.from(this.cache.keys())}cleanup(){let Z=Date.now();for(let[$,J]of this.cache.entries())if(Z-J.timestamp>J.ttl)this.cache.delete($)}destroy(){this.stopCleanup(),this.clear(),this.resetStats()}}var cZ=new i1;function _0(){if("FORCE_COLOR"in Z1.env)return Z1.env.FORCE_COLOR!=="0";if("NO_COLOR"in Z1.env||Z1.env.TERM==="dumb")return!1;if(Z1.platform==="win32")return!0;return d1.isatty(1)&&d1.isatty(2)}var a1=_0();function C(Z,$){if(!a1)return(J)=>J;return(J)=>Z+J+$}var f0=C("\x1B[0m","\x1B[0m"),m0=C("\x1B[31m","\x1B[39m"),d0=C("\x1B[32m","\x1B[39m"),u0=C("\x1B[33m","\x1B[39m"),g0=C("\x1B[34m","\x1B[39m"),c0=C("\x1B[35m","\x1B[39m"),l0=C("\x1B[36m","\x1B[39m"),p0=C("\x1B[37m","\x1B[39m"),n0=C("\x1B[90m","\x1B[39m"),i0=C("\x1B[1m","\x1B[22m"),a0=C("\x1B[3m","\x1B[23m"),r0=C("\x1B[4m","\x1B[24m"),s0=C("\x1B[2m","\x1B[22m"),t0=C("\x1B[7m","\x1B[27m"),o0=C("\x1B[8m","\x1B[28m"),e0=C("\x1B[9m","\x1B[29m"),ZZ=C("\x1B[41m","\x1B[49m"),$Z=C("\x1B[42m","\x1B[49m"),JZ=C("\x1B[43m","\x1B[49m"),QZ=C("\x1B[44m","\x1B[49m"),zZ=C("\x1B[45m","\x1B[49m"),YZ=C("\x1B[46m","\x1B[49m"),XZ=C("\x1B[47m","\x1B[49m"),jZ=a1,GZ={reset:f0,red:m0,green:d0,yellow:u0,blue:g0,magenta:c0,cyan:l0,white:p0,gray:n0,bold:i0,italic:a0,underline:r0,dim:s0,inverse:t0,hidden:o0,strikethrough:e0,bgRed:ZZ,bgGreen:$Z,bgYellow:JZ,bgBlue:QZ,bgMagenta:zZ,bgCyan:YZ,bgWhite:XZ,isColorSupported:jZ},H1=GZ,qZ=["up","down","left","right","space","enter","cancel"],U1={actions:new Set(qZ),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"}};function r1(Z,$){if(typeof Z==="string")return U1.aliases.get(Z)===$;for(let J of Z){if(J===void 0)continue;if(r1(J,$))return!0}return!1}function HZ(Z,$){if(Z===$)return[];let J=Z.split(`
|
|
33
33
|
`),Q=$.split(`
|
|
34
|
-
`),z=[];for(let Y=0;Y<Math.max(J.length,Q.length);Y++)if(J[Y]!==Q[Y])z.push(Y);return z}var
|
|
35
|
-
`),U=[];for(let
|
|
36
|
-
`)}class
|
|
37
|
-
`),G1(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.state==="cancel")setTimeout(()=>{this.unsubscribe()},10);else this.unsubscribe()}restoreCursor(){let Z=
|
|
38
|
-
`).length-1;this.output.write(u.move(-999,Z*-1))}render(){let Z=
|
|
34
|
+
`),z=[];for(let Y=0;Y<Math.max(J.length,Q.length);Y++)if(J[Y]!==Q[Y])z.push(Y);return z}var rZ=KZ.platform.startsWith("win"),u1=Symbol("clapp:cancel");function G1(Z,$){let J=Z;if(J.isTTY)J.setRawMode($)}function FZ(Z){return Z.replace(/\x1b\[[0-9;]*m/g,"")}function MZ(Z){return FZ(Z).length}function c1(Z,$,J){if(!$||$<1)return Z;let Q=J?.hard??!1,z=J?.trim??!0,Y=Z.split(`
|
|
35
|
+
`),U=[];for(let X of Y){if(MZ(X)<=$){U.push(z?X.trimEnd():X);continue}if(Q){let G="",j=0,H=0;while(H<X.length){let q=X.slice(H).match(/^\x1b\[[0-9;]*m/);if(q){G+=q[0],H+=q[0].length;continue}if(j>=$)U.push(z?G.trimEnd():G),G="",j=0;G+=X[H],j++,H++}if(G)U.push(z?G.trimEnd():G)}else U.push(z?X.trimEnd():X)}return U.join(`
|
|
36
|
+
`)}class B1{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;_manualLine="";state="initial";error="";value;userInput="";constructor(Z,$=!0){let{input:J=UZ,output:Q=VZ,render:z,signal:Y,...U}=Z;this.opts=U,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=z.bind(this),this._track=$,this._abortSignal=Y,this.input=J,this.output=Q}unsubscribe(){this._subscribers.clear()}setSubscriber(Z,$){let J=this._subscribers.get(Z)??[];J.push($),this._subscribers.set(Z,J)}on(Z,$){return this.setSubscriber(Z,{cb:$}),this}once(Z,$){return this.setSubscriber(Z,{cb:$,once:!0}),this}emit(Z,...$){let J=this._subscribers.get(Z)??[],Q=[];for(let z of J)if(z.cb(...$),z.once)Q.push(()=>J.splice(J.indexOf(z),1));for(let z of Q)z();return this}prompt(){return new Promise((Z)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),Z(u1);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}if(this.rl=WZ.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0)this._setUserInput(this.opts.initialUserInput,!0);this.input.on("keypress",this.onKeypress),G1(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(u.show),this.output.off("resize",this.render),G1(this.input,!1),Z(this.value)}),this.once("cancel",()=>{this.output.write(u.show),this.output.off("resize",this.render),G1(this.input,!1),Z(u1)})})}_isActionKey(Z,$){return Z==="\t"}_setValue(Z){this.value=Z,this.emit("value",this.value)}_setUserInput(Z,$){if(this.userInput=Z??"",this.emit("userInput",this.userInput),$&&this._track&&this.rl)this.rl.write(this.userInput),this._cursor=this.rl.cursor}onKeypress(Z,$){if(this._track&&$.name!=="return"){if($.name&&this._isActionKey(Z,$))this.rl?.write(null,{ctrl:!0,name:"h"});this._cursor=this.rl?.cursor??0;let J=$.name==="tab"||$.name==="escape"||$.name==="backspace"||$.name==="delete"||$.name==="enter"||$.name==="return"||$.name&&["up","down","left","right"].includes($.name);if(Z&&!J&&Z.length===1&&Z>=" ")this._manualLine+=Z;else if($.name==="backspace"&&this._manualLine.length>0)this._manualLine=this._manualLine.slice(0,-1);let Q=this._manualLine.length>=(this.rl?.line?.length||0)?this._manualLine:this.rl?.line;this._setUserInput(Q)}if(this.state==="error")this.state="active",this.error="";if($?.name){if(!this._track&&U1.aliases.has($.name))this.emit("cursor",U1.aliases.get($.name));if(U1.actions.has($.name))this.emit("cursor",$.name)}if(Z&&(Z.toLowerCase()==="y"||Z.toLowerCase()==="n"))this.emit("confirm",Z.toLowerCase()==="y");if(this.emit("key",Z?.toLowerCase(),$),$?.name==="return"){if(this.opts.validate){let J=this.opts.validate(this.value);if(J)this.error=J instanceof Error?J.message:J,this.state="error"}if(this.state!=="error")this.state="submit"}if(r1([Z,$?.name,$?.sequence],"cancel"))this.state="cancel";if(this.state==="submit"||this.state==="cancel")this.emit("finalize");if(this.render(),this.state==="submit"||this.state==="cancel")this.close()}close(){if(this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
37
|
+
`),G1(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.state==="cancel")setTimeout(()=>{this.unsubscribe()},10);else this.unsubscribe()}restoreCursor(){let Z=c1(this._prevFrame,g1.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
38
|
+
`).length-1;this.output.write(u.move(-999,Z*-1))}render(){let Z=c1(this._render(this)??"",g1.stdout.columns,{hard:!0,trim:!1});if(Z===this._prevFrame)return;if(this.state==="initial")this.output.write(u.hide);else{let $=HZ(this._prevFrame,Z);if(this.restoreCursor(),$&&$?.length===1){let J=$[0];this.output.write(u.move(0,J)),this.output.write(M1.lines(1));let Q=Z.split(`
|
|
39
39
|
`);this.output.write(Q[J]),this._prevFrame=Z,this.output.write(u.move(0,Q.length-J-1));return}if($&&$?.length>1){let J=$[0];this.output.write(u.move(0,J)),this.output.write(M1.down());let z=Z.split(`
|
|
40
40
|
`).slice(J);this.output.write(z.join(`
|
|
41
|
-
`)),this._prevFrame=Z;return}this.output.write(M1.down())}if(this.output.write(Z),this.state==="initial")this.state="active";this._prevFrame=Z}}function
|
|
41
|
+
`)),this._prevFrame=Z;return}this.output.write(M1.down())}if(this.output.write(Z),this.state==="initial")this.state="active";this._prevFrame=Z}}function DZ(Z,$){if(Z===void 0)return 0;if($.length===0)return 0;let Q=$.findIndex((z)=>z.value===Z);return Q!==-1?Q:0}function OZ(Z,$){return($.label??String($.value)).toLowerCase().includes(Z.toLowerCase())}function LZ(Z,$){if(!$)return;if(Z)return $;return $[0]}class TZ extends B1{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#Z=0;#J="";#Q;#$;get cursor(){return this.#Z}get userInputWithCursor(){if(!this.userInput)return H1.inverse(H1.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}\u2588`;let Z=this.userInput.slice(0,this._cursor),[$,...J]=this.userInput.slice(this._cursor);return`${Z}${H1.inverse($)}${J.join("")}`}get options(){if(typeof this.#$==="function")return this.#$();return this.#$}constructor(Z){super(Z);this.#$=Z.options;let $=this.options;this.filteredOptions=[...$],this.multiple=Z.multiple===!0,this.#Q=Z.filter??OZ;let J;if(Z.initialValue&&Array.isArray(Z.initialValue))if(this.multiple)J=Z.initialValue;else J=Z.initialValue.slice(0,1);else if(!this.multiple&&this.options.length>0)J=[this.options[0].value];if(J)for(let Q of J){let z=$.findIndex((Y)=>Y.value===Q);if(z!==-1)this.toggleSelected(Q),this.#Z=z}this.focusedValue=this.options[this.#Z]?.value,this.on("key",(Q,z)=>this.#z(Q,z)),this.on("userInput",(Q)=>this.#Y(Q))}_isActionKey(Z,$){return Z==="\t"||this.multiple&&this.isNavigating&&$.name==="space"&&Z!==void 0&&Z!==""}#z(Z,$){let J=$.name==="up",Q=$.name==="down",z=$.name==="return";if(J||Q){if(this.#Z=Math.max(0,Math.min(this.#Z+(J?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#Z]?.value,!this.multiple)this.selectedValues=[this.focusedValue];this.isNavigating=!0}else if(z)this.value=LZ(this.multiple,this.selectedValues);else if(this.multiple)if(this.focusedValue!==void 0&&($.name==="tab"||this.isNavigating&&$.name==="space"))this.toggleSelected(this.focusedValue);else this.isNavigating=!1;else{if(this.focusedValue)this.selectedValues=[this.focusedValue];this.isNavigating=!1}}deselectAll(){this.selectedValues=[]}toggleSelected(Z){if(this.filteredOptions.length===0)return;if(this.multiple)if(this.selectedValues.includes(Z))this.selectedValues=this.selectedValues.filter(($)=>$!==Z);else this.selectedValues=[...this.selectedValues,Z];else this.selectedValues=[Z]}#Y(Z){if(Z!==this.#J){this.#J=Z;let $=this.options;if(Z)this.filteredOptions=$.filter((J)=>this.#Q(Z,J));else this.filteredOptions=[...$];if(this.#Z=DZ(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#Z]?.value,!this.multiple)if(this.focusedValue!==void 0)this.toggleSelected(this.focusedValue);else this.deselectAll()}}}class wZ extends B1{options;cursor=0;#Z;getGroupItems(Z){return this.options.filter(($)=>$.group===Z)}isGroupSelected(Z){let $=this.getGroupItems(Z),J=this.value;if(J===void 0)return!1;return $.every((Q)=>J.includes(Q.value))}toggleValue(){let Z=this.options[this.cursor];if(this.value===void 0)this.value=[];if(Z.group===!0){let $=String(Z.value),J=this.getGroupItems($);if(this.isGroupSelected($))this.value=this.value.filter((Q)=>J.findIndex((z)=>z.value===Q)===-1);else this.value=[...this.value,...J.map((Q)=>Q.value)];this.value=Array.from(new Set(this.value))}else{let $=this.value.includes(Z.value);this.value=$?this.value.filter((J)=>J!==Z.value):[...this.value,Z.value]}}constructor(Z){super(Z,!1);let{options:$}=Z;this.#Z=Z.selectableGroups!==!1,this.options=Object.entries($).flatMap(([J,Q])=>[{value:J,group:!0,label:J},...Q.map((z)=>({...z,group:J}))]),this.value=[...Z.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:J})=>J===Z.cursorAt),this.#Z?0:1),this.on("cursor",(J)=>{switch(J){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let Q=this.options[this.cursor]?.group===!0;if(!this.#Z&&Q)this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let Q=this.options[this.cursor]?.group===!0;if(!this.#Z&&Q)this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}case"space":this.toggleValue();break}})}}var EZ=R0();var x=(Z,$)=>EZ?Z:$,oZ=x("\u25C6","*"),eZ=x("\u25A0","x"),Z$=x("\u25B2","x"),$$=x("\u25C7","o"),J$=x("\u250C","T"),IZ=x("\u2502","|"),Q$=x("\u2514","\u2014"),z$=x("\u25CF",">"),Y$=x("\u25CB"," "),X$=x("\u25FB","[\u2022]"),j$=x("\u25FC","[+]"),G$=x("\u25FB","[ ]"),K$=x("\u25AA","\u2022"),q$=x("\u2500","-"),H$=x("\u256E","+"),U$=x("\u251C","+"),V$=x("\u256F","+"),W$=x("\u25CF","\u2022"),F$=x("\u25C6","*"),M$=x("\u25B2","!"),D$=x("\u25A0","x");var O$={light:x("\u2500","-"),heavy:x("\u2501","="),block:x("\u2588","#")};function BZ(){return`${H1.gray(IZ)} `}var L$=BZ();class s1{configPath;config=null;events=[];retryCount=0;maxRetries=3;retryDelayMs=1000;constructor(){let Z=l1.homedir(),$=O1.join(Z,".config","clapp");this.configPath=O1.join($,"telemetry.json")}async isEnabled(){if(n.env.DO_NOT_TRACK==="1"||n.env.DO_NOT_TRACK==="true")return!1;if(n.env.NO_TELEMETRY==="1"||n.env.NO_TELEMETRY==="true")return!1;return(await this.loadConfig()).enabled}async enable(){let Z=await this.loadConfig();if(Z.enabled=!0,!Z.userId)Z.userId=this.generateUserId();await this.saveConfig(Z)}async disable(){let Z=await this.loadConfig();Z.enabled=!1,await this.saveConfig(Z)}async track(Z,$){if(!await this.isEnabled())return;let Q={event:Z,...$,timestamp:Date.now(),platform:l1.platform(),nodeVersion:n.version};if(this.events.push(Q),this.events.length>=10)await this.send()}async trackCommand(Z,$){await this.track("command",{command:Z,duration:$})}async trackError(Z,$){await this.track("error",{error:Z,command:$})}async send(){if(!await this.isEnabled()||this.events.length===0)return!0;try{this.events=[],this.retryCount=0;let $=await this.loadConfig();return $.lastSent=Date.now(),await this.saveConfig($),!0}catch{if(this.retryCount<this.maxRetries){this.retryCount++;let $=this.retryDelayMs*2**(this.retryCount-1);return await this.sleep($),this.send()}return this.events=[],this.retryCount=0,!1}}async flush(){if(this.events.length===0)return!0;return this.send()}sleep(Z){return new Promise(($)=>setTimeout($,Z))}async status(){let Z=await this.loadConfig();return{enabled:Z.enabled,doNotTrack:n.env.DO_NOT_TRACK==="1"||n.env.DO_NOT_TRACK==="true",eventsQueued:this.events.length,lastSent:Z.lastSent}}async loadConfig(){if(this.config)return this.config;try{if(PZ(this.configPath)){let Z=await D1.readFile(this.configPath,"utf-8");return this.config=JSON.parse(Z),this.config}}catch{}return this.config={enabled:!1},this.config}async saveConfig(Z){this.config=Z;try{let $=O1.dirname(this.configPath);await D1.mkdir($,{recursive:!0}),await D1.writeFile(this.configPath,JSON.stringify(Z,null,2),"utf-8")}catch{}}generateUserId(){let Z=Math.random().toString(36).substring(2,15),$=Date.now().toString(36);return`${Z}-${$}`}}var P$=new s1;var a=CZ(SZ(),1);var P1="0.11.9";var N1=String.raw`^\s*-\s*\[[xX]\]\s*`,AZ=new RegExp(`${N1}<!--\\s*rebase-branch=([^>]*?)\\s*-->`,"gm"),xZ=new RegExp(`${N1}<!--\\s*rebase-all-open-prs\\s*-->`,"m"),RZ=new RegExp(`${N1}<!--\\s*manual job\\s*-->`,"m");function t1(Z){if(!Z)return{rebaseBranches:[],rebaseAll:!1,manualRun:!1};let $=[];for(let J of Z.matchAll(AZ)){let Q=J[1].trim();if(Q&&!$.includes(Q))$.push(Q)}return{rebaseBranches:$,rebaseAll:xZ.test(Z),manualRun:RZ.test(Z)}}function A1(Z){return Z.rebaseBranches.length>0||Z.rebaseAll||Z.manualRun}function o1(Z){return Z.replace(/^(\s*-\s*)\[[xX]\](\s*<!--\s*(?:rebase-branch=[^>]*?|rebase-all-open-prs|manual job)\s*-->)/gm,"$1[ ]$2")}var x1=null;async function k(Z){if(Z)return await C1(Z);if(!x1)x1=await C1();return x1}async function d(Z,$,J){if(!Z.repository?.owner||!Z.repository.name)J.error(`\u274C Repository owner and name are required for ${$}`),J.info("Configure repository.owner and repository.name in buddy.config.ts"),V.exit(1);try{return await Q0({provider:Z.repository.provider,owner:Z.repository.owner,name:Z.repository.name,...Z.repository.token?{token:Z.repository.token}:{},...Z.repository.apiUrl?{apiUrl:Z.repository.apiUrl}:{}},{logger:J})}catch(Q){J.error(`\u274C ${r(Q)}`),V.exit(1)}}async function Z0(Z,$,J){let Q=Z.filter((U)=>U.suggestion);if(Q.length===0)return J.info("No committable suggestions in this review"),0;let z=new Map;for(let U of Q){let X=z.get(U.path);if(X)X.push(U);else z.set(U.path,[U])}let Y=0;for(let[U,X]of z){let G=Bun.file(U);if(!await G.exists()){J.warn(`\u26A0\uFE0F Skipping ${U}: not in the working tree`);continue}let j=await G.text();for(let H of[...X].sort((q,K)=>K.line-q.line)){if(!$){if(!(await a.default({type:"confirm",name:"apply",message:`${U}:${H.line} \u2014 ${H.message}
|
|
42
42
|
${H.suggestion}
|
|
43
|
-
Apply?`,initial:!1})).apply)continue}let q=
|
|
43
|
+
Apply?`,initial:!1})).apply)continue}let q=z0(j,H.line,H.suggestion);if(q===null){J.warn(`\u26A0\uFE0F Skipping ${U}:${H.line}: the file changed since the review`);continue}j=q,Y++}await Bun.write(U,j)}return Y}async function kZ(Z,$){try{let{PackageScanner:J}=await import("../chunk-3xbx315d.js"),Q=await new J(V.cwd(),$,Z.packages?.ignorePaths).scanProject(),z=new Map;for(let Y of Q)for(let U of Y.dependencies)if(!z.has(U.name))z.set(U.name,U.currentVersion);return[...z].map(([Y,U])=>({name:Y,declaredVersion:U}))}catch(J){return $.debug(`Could not collect dependency context: ${r(J)}`),[]}}var w=new I1("buddy");w.usage(`[command] [options]
|
|
44
44
|
|
|
45
45
|
\uD83D\uDC36 Buddy - AI code review and dependency updates, in one teammate
|
|
46
46
|
|
|
@@ -113,68 +113,68 @@ Migration:
|
|
|
113
113
|
- Converts settings to Buddy format with compatibility report
|
|
114
114
|
- Generates optimized GitHub Actions workflows
|
|
115
115
|
- Provides migration guidance and best practices`);w.command("setup","\uD83D\uDE80 Interactive setup for automated dependency updates (recommended)").alias("init").option("--verbose, -v","Enable verbose logging").option("--non-interactive","Run setup without prompts (use defaults)").option("--preset <type>","Workflow preset: standard|high-frequency|security|minimal|testing",{default:"standard"}).option("--token-setup <type>","Token setup: existing-secret|new-pat|default-token",{default:"default-token"}).example("buddy setup").example("buddy setup --verbose").example("buddy setup --non-interactive").example("buddy setup --non-interactive --preset testing --verbose").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet();try{console.log("\uD83E\uDD16 Welcome to Buddy Setup!"),console.log(`Let's configure automated dependency updates for your project.
|
|
116
|
-
`);let J=
|
|
116
|
+
`);let J=K0(10);y(J),f(J,"Detecting existing configurations"),y(J);let Q=new Y0,z=await Q.detectExistingTools(),Y=[];if(z.length>0&&!Z.nonInteractive){if(console.log(`
|
|
117
117
|
\uD83D\uDD0D Configuration Migration Detection:`),console.log(`Found ${z.length} existing dependency management tool(s):`),z.forEach((M)=>console.log(` \u2022 ${M.name} (${M.configFile})`)),(await a.default({type:"confirm",name:"migrate",message:"Would you like to migrate existing configurations to Buddy?",initial:!0})).migrate){console.log(`
|
|
118
118
|
\uD83D\uDCCB Migrating configurations...`);for(let M of z)try{let L;if(M.name==="renovate")L=await Q.migrateFromRenovate(M.configFile);else if(M.name==="dependabot")L=await Q.migrateFromDependabot(M.configFile);else continue;Y.push(L),console.log(`\u2705 Migrated ${M.name} configuration`)}catch(L){console.log(`\u26A0\uFE0F Failed to migrate ${M.name}: ${L instanceof Error?L.message:"Unknown error"}`)}if(Y.length>0){let M=await Q.generateMigrationReport(Y);console.log(`
|
|
119
119
|
${M}`)}}}else if(z.length>0&&Z.nonInteractive)console.log(`
|
|
120
|
-
\uD83D\uDD0D Found ${z.length} existing tool(s), skipping migration in non-interactive mode`);
|
|
121
|
-
\uD83D\uDD0C Integration Discovery:`),console.log(`Found ${
|
|
122
|
-
\uD83D\uDD0C Found ${
|
|
123
|
-
\u274C Pre-flight checks failed. Please fix the errors above and try again.`),V.exit(1);
|
|
124
|
-
\uD83D\uDD0D Project Analysis:`),console.log(`\uD83D\uDCE6 Project Type: ${
|
|
125
|
-
\uD83D\uDCCB Recommendations:`),
|
|
126
|
-
\uD83D\uDCCD Repository Detection`);let H=await
|
|
120
|
+
\uD83D\uDD0D Found ${z.length} existing tool(s), skipping migration in non-interactive mode`);f(J,"Discovering integrations",!0),y(J);let U=new X0,X=await U.discoverPlugins();if(X.length>0&&!Z.nonInteractive){if(console.log(`
|
|
121
|
+
\uD83D\uDD0C Integration Discovery:`),console.log(`Found ${X.length} available integration(s):`),X.forEach((M)=>console.log(` \u2022 ${M.name} v${M.version}`)),(await a.default({type:"confirm",name:"enablePlugins",message:"Would you like to enable these integrations?",initial:!0})).enablePlugins)for(let M of X)await U.loadPlugin(M)}else if(X.length>0&&Z.nonInteractive){console.log(`
|
|
122
|
+
\uD83D\uDD0C Found ${X.length} integration(s) \u2014 enabled for setup notifications`);for(let I of X)await U.loadPlugin(I)}f(J,"Running pre-flight checks",!0),y(J);let G=await j0();if(W1(G,"\uD83D\uDD0D Pre-flight Validation"),!G.success)console.log(`
|
|
123
|
+
\u274C Pre-flight checks failed. Please fix the errors above and try again.`),V.exit(1);f(J,"Analyzing project",!0),y(J);let j=await G0();if(console.log(`
|
|
124
|
+
\uD83D\uDD0D Project Analysis:`),console.log(`\uD83D\uDCE6 Project Type: ${j.type}`),console.log(`\u2699\uFE0F Package Manager: ${j.packageManager}`),console.log(`\uD83D\uDD12 Lock File: ${j.hasLockFile?"Found":"Not found"}`),console.log(`\uD83D\uDCC4 Dependency Files: ${j.hasDependencyFiles?"Found":"None"}`),console.log(`\uD83D\uDD04 GitHub Actions: ${j.hasGitHubActions?"Found":"None"}`),console.log(`\uD83D\uDCA1 Recommended Preset: ${j.recommendedPreset}`),j.recommendations.length>0)console.log(`
|
|
125
|
+
\uD83D\uDCCB Recommendations:`),j.recommendations.forEach((I)=>console.log(` \u2022 ${I}`));f(J,"Repository Detection",!0),y(J),console.log(`
|
|
126
|
+
\uD83D\uDCCD Repository Detection`);let H=await q0();if(!H)console.log("\u274C Could not detect repository. Please ensure you're in a Git repository."),V.exit(1);console.log(`\u2705 Detected repository: ${H.owner}/${H.name}`),console.log(`\uD83D\uDD17 GitHub URL: https://github.com/${H.owner}/${H.name}`);let q=await O0(H);if(q.warnings.length>0||q.suggestions.length>0)W1(q,"\uD83D\uDD0D Repository Validation");f(J,"GitHub Token Setup",!0),y(J),console.log(`
|
|
127
127
|
\uD83D\uDD11 GitHub Token Setup`),console.log("For full functionality, Buddy needs appropriate GitHub permissions."),console.log(`This enables workflow file updates and advanced GitHub Actions features.
|
|
128
|
-
`);let K;if(Z.nonInteractive)switch(Z.tokenSetup){case"existing-secret":K={hasCustomToken:!0,needsGuide:!1},console.log("\u2705 Using existing organization/repository secrets");break;case"new-pat":K={hasCustomToken:!0,needsGuide:!0},console.log("\u26A0\uFE0F Non-interactive mode: Will use custom token but skip setup guide");break;case"default-token":default:K={hasCustomToken:!1,needsGuide:!1},console.log("\u2705 Using default GITHUB_TOKEN (limited functionality)");break}else if(K=await
|
|
129
|
-
\uD83D\uDD27 Repository Settings`),await
|
|
130
|
-
\u2699\uFE0F Workflow Configuration`);let F;if(Z.nonInteractive)F={useCase:Z.preset},console.log(`\u2705 Using ${Z.preset} preset for workflow configuration`);else if(F=await a.default([{type:"select",name:"useCase",message:"What type of update schedule would you like?",choices:[{title:"Standard Setup (Recommended)",description:"Dashboard updates 3x/week, dependency updates on schedule",value:"standard"},{title:"High Frequency",description:"Check for updates multiple times per day",value:"high-frequency"},{title:"Security Focused",description:"Frequent patch updates with security-first approach",value:"security"},{title:"Minimal Updates",description:"Weekly checks, lower frequency",value:"minimal"},{title:"Development/Testing",description:"Manual triggers + frequent checks for testing",value:"testing"},{title:"Custom Configuration",description:"Create your own schedule",value:"custom"}]}]),!F.useCase){console.log("Setup cancelled.");return}let W=
|
|
131
|
-
\uD83D\uDCDD Configuration File`),await
|
|
132
|
-
\uD83D\uDD04 Workflow Generation`),F.useCase==="custom"&&!Z.nonInteractive)await
|
|
133
|
-
\uD83D\uDD0D Validating Generated Workflows`);let T=[{name:"buddy-dashboard.yml",content:""},{name:"buddy-check.yml",content:""},{name:"buddy-update.yml",content:""}],A=!0;for(let
|
|
134
|
-
\u26A0\uFE0F Some workflows have validation issues. Please review the warnings above.`);if(
|
|
135
|
-
\uD83C\uDF89 Setup Complete!`),await
|
|
136
|
-
\uD83D\uDD0C Executing integration hooks...`);let
|
|
137
|
-
Scan Results:`),$.info(`\uD83D\uDCE6 Total packages: ${
|
|
138
|
-
\uD83D\uDEA8 Major updates (${G.length}):`);for(let q of G)$.info(` ${q.name}: ${q.currentVersion} \u2192 ${q.newVersion}`)}if(
|
|
139
|
-
\u2728 Minor updates (${
|
|
140
|
-
\uD83D\uDD27 Patch updates (${H.length}):`);for(let q of H)$.info(` ${q.name}: ${q.currentVersion} \u2192 ${q.newVersion}`)}if(
|
|
141
|
-
\uD83D\uDCCB Update groups (${j.groups.length}):`);for(let q of j.groups)$.info(` ${q.name}: ${q.updates.length} updates`)}}catch(Q){$.error("Scan failed:",Q),await g(J.notifications,"run.failed",{command:"scan",error:Q instanceof Error?Q.message:String(Q)}),V.exit(1)}});w.command("dashboard","Create or update dependency dashboard issue").option("--verbose, -v","Enable verbose logging").option("--title <title>","Custom dashboard title").option("--issue-number <number>","Update specific issue number").option("--pin","Pin the dashboard issue to the top of the issue list").option("--no-pin","Unpin the dashboard issue").example("buddy dashboard").example('buddy dashboard --title "My Dependencies"').example("buddy dashboard --issue-number 42").example("buddy dashboard --pin").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await S(Z.config);if(J.dashboard?.enabled===!1){$.info("\u2139\uFE0F Dashboard is disabled by config (dashboard.enabled: false)");return}try{if($.info("Creating or updating dependency dashboard..."),!J.repository)$.error("\u274C Repository configuration required for dashboard"),$.info("Configure repository.provider, repository.owner, repository.name in buddy.config.ts"),V.exit(1);let Q={...J,verbose:Z.verbose??J.verbose,dashboard:{...J.dashboard,enabled:!0,title:Z.title??J.dashboard?.title,issueNumber:Z.issueNumber?Number.parseInt(Z.issueNumber,10):J.dashboard?.issueNumber,pin:Z.pin??J.dashboard?.pin}},Y=await new f(Q).createOrUpdateDashboard();$.success(`\u2705 Dashboard updated: ${Y.url}`),$.info(`\uD83D\uDCCA Issue #${Y.number}: ${Y.title}`)}catch(Q){$.error("Dashboard creation failed:",Q),await g(J.notifications,"run.failed",{command:"dashboard",error:Q instanceof Error?Q.message:String(Q)}),V.exit(1)}});w.command("update","Update dependencies and create PRs").option("--verbose, -v","Enable verbose logging").option("--strategy <type>","Update strategy: major|minor|patch|all (default: packages.strategy from config, else all)").option("--ignore <names>","Comma-separated list of packages to ignore").option("--dry-run","Preview changes without making them").option("--reviewers <names>","Comma-separated reviewers to assign (overrides pullRequest.reviewers)").option("--assignees <names>","Comma-separated assignees to assign (overrides pullRequest.assignees)").option("--labels <names>","Comma-separated labels to add (overrides pullRequest.labels)").option("--respect-latest",'Respect "latest", "*", and other dynamic version indicators (default: true)').option("--no-respect-latest",'Allow updating "latest", "*", and other dynamic version indicators').example("buddy update").example("buddy update --dry-run").example("buddy update --strategy patch").example("buddy update --verbose").example("buddy update --no-respect-latest").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await S(Z.config);try{$.info("Starting dependency update process...");let Q;if(Z.ignore)Q=Z.ignore.split(",").map((K)=>K.trim());let z=(K)=>K?K.split(",").map((F)=>F.trim()).filter(Boolean):void 0,Y=z(Z.reviewers),U=z(Z.assignees),j=z(Z.labels),G={...Y?{reviewers:Y}:{},...U?{assignees:U}:{},...j?{labels:j}:{}},X={...J,verbose:Z.verbose??J.verbose,...Object.keys(G).length?{pullRequest:{...J.pullRequest,...G}}:{},packages:{...J.packages,strategy:Z.strategy??J.packages?.strategy??"all",ignore:Q??J.packages?.ignore,respectLatest:Z.respectLatest??J.packages?.respectLatest??!0}},H=new f(X),q=await H.scanForUpdates();if(q.updates.length===0){$.success("All dependencies are up to date!");return}if(Z.dryRun){$.info("\uD83D\uDD0D Dry run mode - no changes will be made"),$.info(`Would create ${q.groups.length} pull request(s):`);for(let K of q.groups)$.info(` \uD83D\uDCDD ${K.title} (${K.updates.length} updates)`);return}await H.createPullRequests(q),$.success("Update process completed!")}catch(Q){$.error("Update failed:",Q),await g(J.notifications,"run.failed",{command:"update",error:Q instanceof Error?Q.message:String(Q)}),V.exit(1)}});w.command("rebase <pr-number>","Rebase/retry a pull request by recreating it with latest updates").option("--verbose, -v","Enable verbose logging").option("--force","Force rebase even if PR appears to be up to date").example("buddy rebase 17").example("buddy rebase 17 --verbose").example("buddy rebase 17 --force").action(async(Z,$)=>{let J=$.verbose?O.verbose():O.quiet(),Q=await S($.config);try{if(J.info(`\uD83D\uDD04 Rebasing/retrying PR #${Z}...`),!Q.repository)J.error("\u274C Repository configuration required for PR operations"),J.info("Configure repository.provider, repository.owner, repository.name in buddy.config.ts"),V.exit(1);let z=await m(Q,"PR operations",J),Y=Number.parseInt(Z,10);if(Number.isNaN(Y))J.error("\u274C Invalid PR number provided"),V.exit(1);let j=(await z.getPullRequests("open")).find((M)=>M.number===Y);if(!j)J.error(`\u274C Could not find open PR #${Y}`),V.exit(1);if(!j.head.startsWith("buddy/"))J.error(`\u274C PR #${Y} is not a buddy PR (branch: ${j.head})`),V.exit(1);J.info(`\uD83D\uDCCB Found PR: ${j.title}`),J.info(`\uD83C\uDF3F Branch: ${j.head}`);let G=await kZ(j.body);if(G.length===0)J.error("\u274C Could not extract package updates from PR body"),V.exit(1);if(J.info(`\uD83D\uDCE6 Found ${G.length} packages to update`),!$.force){J.info("\uD83D\uDD0D Checking if rebase is needed...");let E=(await new f(Q).scanForUpdates()).updates.filter((N)=>G.some((b)=>b.name===N.name));if(G.every((N)=>E.some((b)=>b.name===N.name&&b.newVersion===N.newVersion))){J.success("\u2705 PR is already up to date, no rebase needed"),J.info("\uD83D\uDCA1 Use --force to rebase anyway");return}}J.info("\uD83D\uDD04 Updating PR with latest updates...");let X=new f({...Q,verbose:$.verbose??Q.verbose}),H=await X.scanForUpdates();if(H.updates.length===0){J.success("\u2705 All dependencies are now up to date!");return}let q=H.groups.find((M)=>M.updates.length===G.length&&M.updates.every((L)=>G.some((E)=>E.name===L.name))&&G.every((L)=>M.updates.some((E)=>E.name===L.name)));if(!q){J.error("\u274C Could not find matching update group. This likely means the package grouping has changed."),J.info(`\uD83D\uDCCB PR packages: ${G.map((M)=>M.name).join(", ")}`),J.info(`\uD83D\uDCCB Available groups: ${H.groups.map((M)=>`${M.name} (${M.updates.length} packages)`).join(", ")}`),J.info("\uD83D\uDCA1 Close this PR manually and let buddy create new ones with correct grouping");return}let K=await X.generateAllFileUpdates(q.updates);if(K.length===0){J.info(`\u2139\uFE0F No file changes generated for PR #${Y} \u2014 likely a pantry/pkgx-style dep with no JS writer. Skipping commit to avoid an empty force-push.`);let M=j.body||"",L=M.replace(/- \[x\] <!-- rebase-check -->/g,"- [ ] <!-- rebase-check -->");if(L!==M)await z.updatePullRequest(Y,{body:L}),J.info("\u2705 Unticked rebase checkbox to prevent the next update-check run from re-triggering this no-op rebase.");return}let F=Q.repository?.baseBranch||"main";await z.commitChanges(j.head,q.title,K,F),J.info(`\u2705 Recreated branch ${j.head} from ${F} with latest changes`);let{PullRequestGenerator:W}=await import("../chunk-jczf4z85.js"),B=(await new W({verbose:$.verbose}).generateBody(q)).replace(/- \[x\] <!-- rebase-check -->/g,"- [ ] <!-- rebase-check -->");await z.updatePullRequest(Y,{title:q.title,body:B}),J.success("\uD83D\uDD04 PR rebase completed! Updated existing PR in place.")}catch(z){J.error("Rebase failed:",z),V.exit(1)}});async function kZ(Z){let $=Z0(Z);if($?.truncated)return[];if($)return $0($);let J=[],Q=/\|\s*\[([^\]]+)\][^|]*\|\s*\[?`\^?([^`]+)`\s*->\s*`\^?([^`]+)`\]?/g,z;while((z=Q.exec(Z))!==null){let[,Y,U,j]=z;J.push({name:Y,currentVersion:U,newVersion:j})}return J}w.command("update-check","Check all open buddy PRs for rebase checkbox and auto-rebase if checked").option("--verbose, -v","Enable verbose logging").option("--dry-run","Check but don't actually rebase").example("buddy update-check").example("buddy update-check --verbose").example("buddy update-check --dry-run").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await S(Z.config);try{if(!J.repository)$.error("\u274C Repository configuration required for PR operations"),$.info("Configure repository.provider, repository.owner, repository.name in buddy.config.ts"),V.exit(1);let Q=await m(J,"PR operations",$),z=await bZ(Q,J,$),Y=s1(z?.body);if(A1(Y))$.info(`\uD83D\uDCCB Dashboard requests: ${Y.rebaseBranches.length} branch(es)${Y.rebaseAll?", rebase all":""}${Y.manualRun?", manual run":""}`);let U=new Set(Y.rebaseBranches);$.info("\uD83D\uDD0D Checking for PRs with rebase checkbox enabled...");let j=0,G=0;try{let K=(await Q.getPullRequests("open")).filter((F)=>F.head.startsWith("buddy/"));$.info(`\uD83D\uDCCB Found ${K.length} buddy PRs to check for rebase requests`);for(let F of K){G++;let W=Y.rebaseAll||U.has(F.head);if(hZ(F.body||"")||W)if($.info(`\uD83D\uDD04 PR #${F.number} has rebase ${W?"requested from the dashboard":"checkbox checked"}`),Z.dryRun)$.info(`\uD83D\uDD0D [DRY RUN] Would rebase PR #${F.number}`),j++;else{$.info(`\uD83D\uDD04 Rebasing PR #${F.number} via rebase command...`);try{let{spawn:A}=await import("child_process"),B=A("bunx",["@buddysh/buddy","rebase",F.number.toString()],{stdio:"inherit",cwd:V.cwd()});await new Promise((M,L)=>{B.on("close",(E)=>{if(E===0)j++,M(E);else L(Error(`Rebase failed with code ${E}`))})}),$.success(`\u2705 Successfully rebased PR #${F.number}`)}catch(A){$.error(`\u274C Failed to rebase PR #${F.number}:`,A)}}}if(j>0)$.success(`\u2705 ${Z.dryRun?"Would rebase":"Successfully rebased"} ${j} PR(s)`);else if(G>0)$.info("\uD83D\uDCCB No PRs have rebase checkbox enabled")}catch(q){$.warn("\u26A0\uFE0F Could not check for rebase requests:",q)}if(A1(Y)&&z){if(Z.dryRun)$.info("\uD83D\uDD0D [DRY RUN] Would clear dashboard checkboxes");else try{await Q.updateIssue(z.number,{body:t1(z.body||"")}),$.success("\u2705 Cleared dashboard checkboxes")}catch(q){$.warn("\u26A0\uFE0F Could not clear dashboard checkboxes:",q)}if(Y.manualRun)if($.info("\uD83D\uDD04 Dashboard requested a full update run..."),Z.dryRun)$.info("\uD83D\uDD0D [DRY RUN] Would run a full scan and create PRs");else try{let q=new f(J),K=await q.scanForUpdates();if(K.updates.length>0)await q.createPullRequests(K);else $.info("\u2705 No updates found during the requested run")}catch(q){$.error("\u274C Requested update run failed:",q)}}$.info(`
|
|
142
|
-
\u2705 Checking for PRs with satisfied dependencies...`);try{let{Buddy:q}=await import("../chunk-
|
|
143
|
-
\uD83D\uDD0D Checking for obsolete PRs due to removed dependency files...`);try{let{Buddy:q}=await import("../chunk-
|
|
144
|
-
\uD83E\uDDF9 Running branch cleanup...`),z1(Q,"branchHousekeeping","cleanupStaleBranches","branch cleanup");let H=await Q.cleanupStaleBranches(2,!!Z.dryRun);if(Z.dryRun)$.info(`\uD83D\uDD0D [DRY RUN] Would delete ${H.deleted.length} stale branches`);else $.success(`\uD83C\uDF89 Cleanup complete: ${H.deleted.length} branches deleted, ${H.failed.length} failed`);if(
|
|
145
|
-
\uD83C\uDF89 Update-check complete: ${
|
|
146
|
-
|
|
147
|
-
> ${L}`,head:i,base:
|
|
148
|
-
`);try{let
|
|
128
|
+
`);let K;if(Z.nonInteractive)switch(Z.tokenSetup){case"existing-secret":K={hasCustomToken:!0,needsGuide:!1},console.log("\u2705 Using existing organization/repository secrets");break;case"new-pat":K={hasCustomToken:!0,needsGuide:!0},console.log("\u26A0\uFE0F Non-interactive mode: Will use custom token but skip setup guide");break;case"default-token":default:K={hasCustomToken:!1,needsGuide:!1},console.log("\u2705 Using default GITHUB_TOKEN (limited functionality)");break}else if(K=await U0(),K.needsGuide)await H0(H);f(J,"Repository Settings",!0),y(J),console.log(`
|
|
129
|
+
\uD83D\uDD27 Repository Settings`),await V0(H),f(J,"Workflow Configuration",!0),y(J),console.log(`
|
|
130
|
+
\u2699\uFE0F Workflow Configuration`);let F;if(Z.nonInteractive)F={useCase:Z.preset},console.log(`\u2705 Using ${Z.preset} preset for workflow configuration`);else if(F=await a.default([{type:"select",name:"useCase",message:"What type of update schedule would you like?",choices:[{title:"Standard Setup (Recommended)",description:"Dashboard updates 3x/week, dependency updates on schedule",value:"standard"},{title:"High Frequency",description:"Check for updates multiple times per day",value:"high-frequency"},{title:"Security Focused",description:"Frequent patch updates with security-first approach",value:"security"},{title:"Minimal Updates",description:"Weekly checks, lower frequency",value:"minimal"},{title:"Development/Testing",description:"Manual triggers + frequent checks for testing",value:"testing"},{title:"Custom Configuration",description:"Create your own schedule",value:"custom"}]}]),!F.useCase){console.log("Setup cancelled.");return}let W=M0(F.useCase);if(f(J,"Configuration File",!0),y(J),console.log(`
|
|
131
|
+
\uD83D\uDCDD Configuration File`),await W0(H,K.hasCustomToken,W),f(J,"Workflow Generation",!0),y(J),console.log(`
|
|
132
|
+
\uD83D\uDD04 Workflow Generation`),F.useCase==="custom"&&!Z.nonInteractive)await L0(W,$);else console.log(`\u2728 Setting up ${W.name}...`),console.log(`\uD83D\uDCCB ${W.description}`);await F0(W,H,K.hasCustomToken,$),f(J,"Workflow Validation",!0),y(J),console.log(`
|
|
133
|
+
\uD83D\uDD0D Validating Generated Workflows`);let T=[{name:"buddy-dashboard.yml",content:""},{name:"buddy-check.yml",content:""},{name:"buddy-update.yml",content:""}],A=!0;for(let I of T)try{let M=`.github/workflows/${I.name}`;if(e1.existsSync(M)){let L=e1.readFileSync(M,"utf8"),E=await D0(L);if(!E.success)console.log(`\u274C ${I.name} validation failed`),W1(E,`${I.name} Issues`),A=!1;else console.log(`\u2705 ${I.name} validated successfully`)}}catch{console.log(`\u26A0\uFE0F Could not validate ${I.name}`)}if(!A)console.log(`
|
|
134
|
+
\u26A0\uFE0F Some workflows have validation issues. Please review the warnings above.`);if(f(J,"Setup Complete",!0),y(J),console.log(`
|
|
135
|
+
\uD83C\uDF89 Setup Complete!`),await T0(H,K.hasCustomToken),X.length>0){console.log(`
|
|
136
|
+
\uD83D\uDD0C Executing integration hooks...`);let I={step:"setup_complete",progress:J,config:Y.length>0?Y[0].migratedSettings:{},repository:H,analysis:j,plugins:X};U.setContext(I),await U.executePluginHooks({event:"setup_complete"})}}catch(J){$.error("Setup failed:",J),V.exit(1)}});w.command("scan","Scan for dependency updates").option("--verbose, -v","Enable verbose logging").option("--packages <names>","Comma-separated list of packages to check").option("--pattern <pattern>","Glob pattern to match packages").option("--strategy <type>","Update strategy: major|minor|patch|all (default: packages.strategy from config, else all)").option("--ignore <names>","Comma-separated list of packages to ignore").option("--respect-latest",'Respect "latest", "*", and other dynamic version indicators (default: true)').option("--no-respect-latest",'Allow updating "latest", "*", and other dynamic version indicators').example("buddy scan").example("buddy scan --verbose").example('buddy scan --packages "react,typescript,laravel/framework"').example('buddy scan --pattern "@types/*"').example("buddy scan --strategy minor").example("buddy scan --no-respect-latest").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await k(Z.config);try{$.info("Loading configuration...");let Q;if(Z.packages)Q=Z.packages.split(",").map((q)=>q.trim());let z;if(Z.ignore)z=Z.ignore.split(",").map((q)=>q.trim());let Y={...J,verbose:Z.verbose??J.verbose,packages:{...J.packages,strategy:Z.strategy??J.packages?.strategy??"all",ignore:z??J.packages?.ignore,respectLatest:Z.respectLatest??J.packages?.respectLatest??!0}},U=new m(Y);if(Q?.length){$.info(`Checking specific packages: ${Q.join(", ")}`);let q=await U.checkPackages(Q);if(q.length===0)$.success("All specified packages are up to date!");else{$.info(`Found ${q.length} updates:`);for(let K of q)$.info(` ${K.name}: ${K.currentVersion} \u2192 ${K.newVersion} (${K.updateType})`)}return}if(Z.pattern){$.info(`Checking packages with pattern: ${Z.pattern}`);let q=await U.checkPackagesWithPattern(Z.pattern);if(q.length===0)$.success("All matching packages are up to date!");else{$.info(`Found ${q.length} updates:`);for(let K of q)$.info(` ${K.name}: ${K.currentVersion} \u2192 ${K.newVersion} (${K.updateType})`)}return}let X=await U.scanForUpdates();if(X.updates.length===0){$.success("All dependencies are up to date!");return}$.info(`
|
|
137
|
+
Scan Results:`),$.info(`\uD83D\uDCE6 Total packages: ${X.totalPackages}`),$.info(`\uD83D\uDD04 Available updates: ${X.updates.length}`),$.info(`\u23F1\uFE0F Scan duration: ${X.duration}ms`);let G=X.updates.filter((q)=>q.updateType==="major"),j=X.updates.filter((q)=>q.updateType==="minor"),H=X.updates.filter((q)=>q.updateType==="patch");if(G.length>0){$.warn(`
|
|
138
|
+
\uD83D\uDEA8 Major updates (${G.length}):`);for(let q of G)$.info(` ${q.name}: ${q.currentVersion} \u2192 ${q.newVersion}`)}if(j.length>0){$.info(`
|
|
139
|
+
\u2728 Minor updates (${j.length}):`);for(let q of j)$.info(` ${q.name}: ${q.currentVersion} \u2192 ${q.newVersion}`)}if(H.length>0){$.info(`
|
|
140
|
+
\uD83D\uDD27 Patch updates (${H.length}):`);for(let q of H)$.info(` ${q.name}: ${q.currentVersion} \u2192 ${q.newVersion}`)}if(X.groups.length>0){$.info(`
|
|
141
|
+
\uD83D\uDCCB Update groups (${X.groups.length}):`);for(let q of X.groups)$.info(` ${q.name}: ${q.updates.length} updates`)}}catch(Q){$.error("Scan failed:",Q),await g(J.notifications,"run.failed",{command:"scan",error:Q instanceof Error?Q.message:String(Q)}),V.exit(1)}});w.command("dashboard","Create or update dependency dashboard issue").option("--verbose, -v","Enable verbose logging").option("--title <title>","Custom dashboard title").option("--issue-number <number>","Update specific issue number").option("--pin","Pin the dashboard issue to the top of the issue list").option("--no-pin","Unpin the dashboard issue").example("buddy dashboard").example('buddy dashboard --title "My Dependencies"').example("buddy dashboard --issue-number 42").example("buddy dashboard --pin").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await k(Z.config);if(J.dashboard?.enabled===!1){$.info("\u2139\uFE0F Dashboard is disabled by config (dashboard.enabled: false)");return}try{if($.info("Creating or updating dependency dashboard..."),!J.repository)$.error("\u274C Repository configuration required for dashboard"),$.info("Configure repository.provider, repository.owner, repository.name in buddy.config.ts"),V.exit(1);let Q={...J,verbose:Z.verbose??J.verbose,dashboard:{...J.dashboard,enabled:!0,title:Z.title??J.dashboard?.title,issueNumber:Z.issueNumber?Number.parseInt(Z.issueNumber,10):J.dashboard?.issueNumber,pin:Z.pin??J.dashboard?.pin}},Y=await new m(Q).createOrUpdateDashboard();$.success(`\u2705 Dashboard updated: ${Y.url}`),$.info(`\uD83D\uDCCA Issue #${Y.number}: ${Y.title}`)}catch(Q){$.error("Dashboard creation failed:",Q),await g(J.notifications,"run.failed",{command:"dashboard",error:Q instanceof Error?Q.message:String(Q)}),V.exit(1)}});w.command("update","Update dependencies and create PRs").option("--verbose, -v","Enable verbose logging").option("--strategy <type>","Update strategy: major|minor|patch|all (default: packages.strategy from config, else all)").option("--ignore <names>","Comma-separated list of packages to ignore").option("--dry-run","Preview changes without making them").option("--reviewers <names>","Comma-separated reviewers to assign (overrides pullRequest.reviewers)").option("--assignees <names>","Comma-separated assignees to assign (overrides pullRequest.assignees)").option("--labels <names>","Comma-separated labels to add (overrides pullRequest.labels)").option("--respect-latest",'Respect "latest", "*", and other dynamic version indicators (default: true)').option("--no-respect-latest",'Allow updating "latest", "*", and other dynamic version indicators').example("buddy update").example("buddy update --dry-run").example("buddy update --strategy patch").example("buddy update --verbose").example("buddy update --no-respect-latest").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await k(Z.config);try{$.info("Starting dependency update process...");let Q;if(Z.ignore)Q=Z.ignore.split(",").map((K)=>K.trim());let z=(K)=>K?K.split(",").map((F)=>F.trim()).filter(Boolean):void 0,Y=z(Z.reviewers),U=z(Z.assignees),X=z(Z.labels),G={...Y?{reviewers:Y}:{},...U?{assignees:U}:{},...X?{labels:X}:{}},j={...J,verbose:Z.verbose??J.verbose,...Object.keys(G).length?{pullRequest:{...J.pullRequest,...G}}:{},packages:{...J.packages,strategy:Z.strategy??J.packages?.strategy??"all",ignore:Q??J.packages?.ignore,respectLatest:Z.respectLatest??J.packages?.respectLatest??!0}},H=new m(j),q=await H.scanForUpdates();if(q.updates.length===0){$.success("All dependencies are up to date!");return}if(Z.dryRun){$.info("\uD83D\uDD0D Dry run mode - no changes will be made"),$.info(`Would create ${q.groups.length} pull request(s):`);for(let K of q.groups)$.info(` \uD83D\uDCDD ${K.title} (${K.updates.length} updates)`);return}await H.createPullRequests(q),$.success("Update process completed!")}catch(Q){$.error("Update failed:",Q),await g(J.notifications,"run.failed",{command:"update",error:Q instanceof Error?Q.message:String(Q)}),V.exit(1)}});w.command("rebase <pr-number>","Rebase/retry a pull request by recreating it with latest updates").option("--verbose, -v","Enable verbose logging").option("--force","Force rebase even if PR appears to be up to date").example("buddy rebase 17").example("buddy rebase 17 --verbose").example("buddy rebase 17 --force").action(async(Z,$)=>{let J=$.verbose?O.verbose():O.quiet(),Q=await k($.config);try{if(J.info(`\uD83D\uDD04 Rebasing/retrying PR #${Z}...`),!Q.repository)J.error("\u274C Repository configuration required for PR operations"),J.info("Configure repository.provider, repository.owner, repository.name in buddy.config.ts"),V.exit(1);let z=await d(Q,"PR operations",J),Y=Number.parseInt(Z,10);if(Number.isNaN(Y))J.error("\u274C Invalid PR number provided"),V.exit(1);let X=(await z.getPullRequests("open")).find((M)=>M.number===Y);if(!X)J.error(`\u274C Could not find open PR #${Y}`),V.exit(1);if(!S1(X.head))J.error(`\u274C PR #${Y} is not a buddy PR (branch: ${X.head})`),V.exit(1);J.info(`\uD83D\uDCCB Found PR: ${X.title}`),J.info(`\uD83C\uDF3F Branch: ${X.head}`);let G=await bZ(X.body);if(G.length===0)J.error("\u274C Could not extract package updates from PR body"),V.exit(1);if(J.info(`\uD83D\uDCE6 Found ${G.length} packages to update`),!$.force){J.info("\uD83D\uDD0D Checking if rebase is needed...");let E=(await new m(Q).scanForUpdates()).updates.filter((R)=>G.some((h)=>h.name===R.name)),B=G.every((R)=>E.some((h)=>h.name===R.name&&h.newVersion===R.newVersion)),N=Q.repository.baseBranch||"main",b=B&&z.isBranchBehind?await z.isBranchBehind(X.head,N).catch(()=>!1):!1;if(b)J.info(`\uD83D\uDD04 ${X.head} is behind ${N}; rebasing`);if(B&&!b){J.success("\u2705 PR is already up to date, no rebase needed"),J.info("\uD83D\uDCA1 Use --force to rebase anyway");return}}J.info("\uD83D\uDD04 Updating PR with latest updates...");let j=new m({...Q,verbose:$.verbose??Q.verbose}),H=await j.scanForUpdates();if(H.updates.length===0){J.success("\u2705 All dependencies are now up to date!");return}let q=H.groups.find((M)=>M.updates.length===G.length&&M.updates.every((L)=>G.some((E)=>E.name===L.name))&&G.every((L)=>M.updates.some((E)=>E.name===L.name)));if(!q){J.error("\u274C Could not find matching update group. This likely means the package grouping has changed."),J.info(`\uD83D\uDCCB PR packages: ${G.map((M)=>M.name).join(", ")}`),J.info(`\uD83D\uDCCB Available groups: ${H.groups.map((M)=>`${M.name} (${M.updates.length} packages)`).join(", ")}`),J.info("\uD83D\uDCA1 Close this PR manually and let buddy create new ones with correct grouping");return}let K=await j.generateAllFileUpdates(q.updates);if(K.length===0){J.info(`\u2139\uFE0F No file changes generated for PR #${Y} \u2014 likely a pantry/pkgx-style dep with no JS writer. Skipping commit to avoid an empty force-push.`);let M=X.body||"",L=M.replace(/- \[x\] <!-- rebase-check -->/g,"- [ ] <!-- rebase-check -->");if(L!==M)await z.updatePullRequest(Y,{body:L}),J.info("\u2705 Unticked rebase checkbox to prevent the next update-check run from re-triggering this no-op rebase.");return}let F=Q.repository?.baseBranch||"main";await z.commitChanges(X.head,q.title,K,F),J.info(`\u2705 Recreated branch ${X.head} from ${F} with latest changes`);let{PullRequestGenerator:W}=await import("../chunk-tm8eg4sk.js"),I=(await new W({verbose:$.verbose}).generateBody(q)).replace(/- \[x\] <!-- rebase-check -->/g,"- [ ] <!-- rebase-check -->");await z.updatePullRequest(Y,{title:q.title,body:I}),J.success("\uD83D\uDD04 PR rebase completed! Updated existing PR in place.")}catch(z){J.error("Rebase failed:",z),V.exit(1)}});async function bZ(Z){let $=$0(Z);if($?.truncated)return[];if($)return J0($);let J=[],Q=/\|\s*\[([^\]]+)\][^|]*\|\s*\[?`\^?([^`]+)`\s*->\s*`\^?([^`]+)`\]?/g,z;while((z=Q.exec(Z))!==null){let[,Y,U,X]=z;J.push({name:Y,currentVersion:U,newVersion:X})}return J}w.command("update-check","Check all open buddy PRs for rebase checkbox and auto-rebase if checked").option("--verbose, -v","Enable verbose logging").option("--dry-run","Check but don't actually rebase").example("buddy update-check").example("buddy update-check --verbose").example("buddy update-check --dry-run").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await k(Z.config);try{if(!J.repository)$.error("\u274C Repository configuration required for PR operations"),$.info("Configure repository.provider, repository.owner, repository.name in buddy.config.ts"),V.exit(1);let Q=await d(J,"PR operations",$),z=await hZ(Q,J,$),Y=t1(z?.body);if(A1(Y))$.info(`\uD83D\uDCCB Dashboard requests: ${Y.rebaseBranches.length} branch(es)${Y.rebaseAll?", rebase all":""}${Y.manualRun?", manual run":""}`);let U=new Set(Y.rebaseBranches);$.info("\uD83D\uDD0D Checking for PRs with rebase checkbox enabled...");let X=0,G=0;try{let K=(await Q.getPullRequests("open")).filter((F)=>S1(F.head));$.info(`\uD83D\uDCCB Found ${K.length} buddy PRs to check for rebase requests`);for(let F of K){G++;let W=Y.rebaseAll||U.has(F.head);if(yZ(F.body||"")||W)if($.info(`\uD83D\uDD04 PR #${F.number} has rebase ${W?"requested from the dashboard":"checkbox checked"}`),Z.dryRun)$.info(`\uD83D\uDD0D [DRY RUN] Would rebase PR #${F.number}`),X++;else{$.info(`\uD83D\uDD04 Rebasing PR #${F.number} via rebase command...`);try{let{spawn:A}=await import("child_process"),I=A("bunx",["@buddysh/buddy","rebase",F.number.toString(),"--force"],{stdio:"inherit",cwd:V.cwd()});await new Promise((M,L)=>{I.on("close",(E)=>{if(E===0)X++,M(E);else L(Error(`Rebase failed with code ${E}`))})}),$.success(`\u2705 Successfully rebased PR #${F.number}`)}catch(A){$.error(`\u274C Failed to rebase PR #${F.number}:`,A)}}}if(X>0)$.success(`\u2705 ${Z.dryRun?"Would rebase":"Successfully rebased"} ${X} PR(s)`);else if(G>0)$.info("\uD83D\uDCCB No PRs have rebase checkbox enabled")}catch(q){$.warn("\u26A0\uFE0F Could not check for rebase requests:",q)}if(A1(Y)&&z){if(Z.dryRun)$.info("\uD83D\uDD0D [DRY RUN] Would clear dashboard checkboxes");else try{await Q.updateIssue(z.number,{body:o1(z.body||"")}),$.success("\u2705 Cleared dashboard checkboxes")}catch(q){$.warn("\u26A0\uFE0F Could not clear dashboard checkboxes:",q)}if(Y.manualRun)if($.info("\uD83D\uDD04 Dashboard requested a full update run..."),Z.dryRun)$.info("\uD83D\uDD0D [DRY RUN] Would run a full scan and create PRs");else try{let q=new m(J),K=await q.scanForUpdates();if(K.updates.length>0)await q.createPullRequests(K);else $.info("\u2705 No updates found during the requested run")}catch(q){$.error("\u274C Requested update run failed:",q)}}$.info(`
|
|
142
|
+
\u2705 Checking for PRs with satisfied dependencies...`);try{let{Buddy:q}=await import("../chunk-sdhyhefy.js");await new q(J).checkAndCloseSatisfiedPRs(Q,!!Z.dryRun)}catch(q){$.error("\u26A0\uFE0F Could not check for satisfied PRs:",q)}$.info(`
|
|
143
|
+
\uD83D\uDD0D Checking for obsolete PRs due to removed dependency files...`);try{let{Buddy:q}=await import("../chunk-sdhyhefy.js");await new q(J).checkAndCloseObsoletePRs(Q,!!Z.dryRun)}catch(q){$.error("\u26A0\uFE0F Could not check for obsolete PRs:",q)}let j=0;try{if(j=(await new m(J).mergeEligiblePullRequests(!!Z.dryRun)).length,j>0)$.success(`\uD83D\uDD00 ${Z.dryRun?"Would merge":"Merged"} ${j} PR(s)`)}catch(q){$.warn("\u26A0\uFE0F Could not process auto-merge:",q)}$.info(`
|
|
144
|
+
\uD83E\uDDF9 Running branch cleanup...`),z1(Q,"branchHousekeeping","cleanupStaleBranches","branch cleanup");let H=await Q.cleanupStaleBranches(2,!!Z.dryRun);if(Z.dryRun)$.info(`\uD83D\uDD0D [DRY RUN] Would delete ${H.deleted.length} stale branches`);else $.success(`\uD83C\uDF89 Cleanup complete: ${H.deleted.length} branches deleted, ${H.failed.length} failed`);if(X>0||j>0||H.deleted.length>0)$.success(`
|
|
145
|
+
\uD83C\uDF89 Update-check complete: ${X} PR(s) rebased, ${j} merged, ${H.deleted.length} branches cleaned`)}catch(Q){$.error("update-check failed:",Q),await g(J.notifications,"run.failed",{command:"update-check",error:Q instanceof Error?Q.message:String(Q)}),V.exit(1)}});async function hZ(Z,$,J){try{let Q=await Z.getIssues("open"),z=$.dashboard?.issueNumber;if(z)return Q.find((U)=>U.number===z)??null;let Y=$.dashboard?.title??"Dependency Dashboard";return Q.find((U)=>U.title===Y)??Q.find((U)=>U.title.includes("Dependency Dashboard"))??null}catch(Q){return J.warn("\u26A0\uFE0F Could not load the dependency dashboard:",Q),null}}function yZ(Z){return/\s*-\s*\[x\]\s*<!--\s*rebase-check\s*-->.*(?:rebase|update)\/retry/i.test(Z)}w.command("fix-ci","Diagnose a failing workflow run and repair it when the fix is clear").option("--verbose, -v","Enable verbose logging").option("--run-id <id>","Workflow run to diagnose").option("--pr <number>","Pull request to comment on").option("--dry-run","Report the diagnosis without acting").example("buddy fix-ci --run-id 12345").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await k(Z.config);try{let Q=await d(J,"this command",$),{runFixCi:z}=await import("../chunk-2fx0tbc0.js"),Y=await z({config:J,provider:Q,logger:$,dryRun:Boolean(Z.dryRun),...Z.runId?{runId:Number.parseInt(Z.runId,10)}:{},...Z.pr?{prNumber:Number.parseInt(Z.pr,10)}:{}});$.success(`\u2705 ${Y}`)}catch(Q){$.error("fix-ci failed:",Q),await g(J.notifications,"run.failed",{command:"fix-ci",error:Q instanceof Error?Q.message:String(Q)}),V.exit(1)}});w.command("handle-comment","Handle an @buddy command from a GitHub event payload").option("--verbose, -v","Enable verbose logging").option("--payload <path>","Path to the event payload (default: GITHUB_EVENT_PATH)").option("--dry-run","Report what would run without acting").example("buddy handle-comment").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await k(Z.config);try{let Q=Z.payload||V.env.GITHUB_EVENT_PATH;if(!Q)$.error("\u274C No event payload. Pass --payload or run inside GitHub Actions."),V.exit(1);let z=await Bun.file(Q).json(),Y=z.comment,U=z.issue??z.pull_request;if(!Y?.body||!U?.number){$.info("\u2139\uFE0F Event carries no comment; nothing to do");return}let{mentionsBot:X,parseCommand:G}=await import("../chunk-q90s02qc.js");if(!X(Y.body)){$.info("\u2139\uFE0F Comment does not mention buddy; nothing to do");return}let j=G(Y.body);if(!j){$.info("\u2139\uFE0F Mention is not a command (quoted or inside code); nothing to do");return}let H=await d(J,"this command",$),q=Y.user?.login??"",K=Y.user?.type==="Bot"||q.endsWith("[bot]"),F={login:q,isBot:K,canWrite:!K&&Q1(H,"permissionLookup","hasWriteAccess")?await H.hasWriteAccess(q):!1},W=Boolean(z.pull_request??z.issue?.pull_request);if($.info(`\uD83E\uDD16 Handling \`${j.name}\` from @${q} on #${U.number}`),Z.dryRun){$.info(`\uD83D\uDD0D [DRY RUN] Would run ${j.name} (canWrite: ${F.canWrite})`);return}if(Q1(H,"commentReactions","reactToComment"))await H.reactToComment(Y.id,"eyes");let{createHandlers:T,dispatchCommand:A}=await import("../chunk-q90s02qc.js"),{runReviewForPR:I}=await import("../chunk-4zvjzesh.js"),M=await A({command:j,actor:F,number:U.number,isPullRequest:W,commentId:Y.id,logger:$},T({config:J,provider:H,review:async(L,E)=>await I({config:J,provider:H,prNumber:L,logger:$,...E}),rebase:async(L)=>{let{spawn:E}=await import("child_process");return await new Promise((B,N)=>{E("bunx",["@buddysh/buddy","rebase",String(L)],{stdio:"inherit"}).on("close",(R)=>R===0?B():N(Error(`rebase exited ${R}`)))}),"Rebased."},merge:async()=>await new m(J).mergeEligiblePullRequests(!1),fixCi:async(L)=>{let{runFixCi:E}=await import("../chunk-2fx0tbc0.js");return await E({config:J,provider:H,prNumber:L,analysisOnly:!0,logger:$})},plan:async(L,E,B)=>{let{runPlan:N}=await import("../chunk-4akhxmfk.js");return await N({config:J,provider:H,number:L,isPullRequest:E,request:B,logger:$})},resolve:async(L)=>{let{resolveBuddyThreads:E}=await import("../chunk-jxd64dzs.js");return await E({provider:H,prNumber:L,logger:$})},remember:async(L,E)=>{let{addLearning:B,createLearning:N,loadLearnings:b,serializeLearnings:R,DEFAULT_LEARNINGS_FILE:h}=await import("../chunk-2145m12g.js"),v=J.repository?.baseBranch??"main",P=await b((s,p)=>H.getFileContent(s,p),v,h,$),_=N(L,{source:E.isPullRequest?{pr:E.number}:{issue:E.number}}),i=`buddy/learning-${_.id}`;return await H.commitChanges(i,"chore(buddy): record a learning",[{path:h,content:R(B(P,_)),type:"update"}],v),await H.createPullRequest({title:"chore(buddy): record a learning",body:`Recorded from #${E.number}:
|
|
146
|
+
|
|
147
|
+
> ${L}`,head:i,base:v,draft:!1}),`Noted. I opened a pull request adding it to \`${h}\` so it gets reviewed like any other change.`}}));if(M.reply)await H.createComment(U.number,M.reply);if(Q1(H,"commentReactions","reactToComment"))await H.reactToComment(Y.id,M.handled?"rocket":"confused");$.success(M.handled?`\u2705 Handled \`${j.name}\``:`\u2139\uFE0F Did not run: ${M.refusal}`)}catch(Q){$.error("handle-comment failed:",Q),V.exit(1)}});w.command("review [pr-number]","Review a pull request, or local changes when no PR is given").option("--verbose, -v","Enable verbose logging").option("--base <branch>","Base branch to diff against for a local review").option("--staged","Review staged changes only").option("--branch","Review this branch against its base, rather than the working tree").option("--light","Analyzers only \u2014 no AI call, fast enough for a pre-commit hook").option("--format <name>","Output format: pretty|json|github|agent",{default:"pretty"}).option("--fix","Apply committable suggestions to the working tree").option("--yes","Apply fixes without confirming each one").option("--fail-on <severity>","Exit non-zero when a finding at or above this severity is found").option("--profile <name>","Review profile: chill|assertive").option("--summary-only","Post only the summary, without inline findings").option("--auto","Treat this as an automatic trigger, honouring the ai.review filters").option("--dry-run","Print the review instead of posting it").example("buddy review 42").example("buddy review --staged --light").example("buddy review --format agent | claude").action(async(Z,$)=>{let J=$.verbose?O.verbose():O.quiet(),Q=await k($.config),z=$.format??"pretty";if(!R1.includes(z))J.error(`\u274C Unknown format '${z}'. Expected one of ${R1.join(", ")}.`),V.exit(1);let Y=z!=="pretty",U=Y?O.silent():J;try{let{createAiClient:X}=await import("../chunk-2145m12g.js"),G=X(Q,U);if(!G&&(Z||!$.light))J.error("\u274C AI review needs an API key, or use --light for analyzers only. See https://buddy.sh/ai/providers"),V.exit(1);let{composeInstructions:j,reviewDiff:H}=await import("../chunk-jxd64dzs.js"),{collectLocalDiff:q,formatReview:K,shouldFail:F}=await import("../chunk-pjq0qxst.js"),{runAnalyzers:W}=await import("../chunk-gs5b2ssa.js");if(Z){let B=await d(Q,"reviewing a pull request",U),{reviewPullRequest:N}=await import("../chunk-4zvjzesh.js"),{status:b,result:R}=await N({config:Q,provider:B,prNumber:Number.parseInt(Z,10),trigger:$.auto?"automatic":"requested",...$.auto?{skipIfReviewed:!0}:{},logger:U,dryRun:Boolean($.dryRun),...$.summaryOnly?{summaryOnly:!0}:{},...$.profile?{profile:$.profile}:{}});if(J.success(`\u2705 ${b}`),await g(Q.notifications,"review.completed",{number:Number.parseInt(Z,10),findings:R?.findings.length??0}),R&&z!=="pretty")V.stdout.write(K(R,z));if(R&&$.failOn&&F(R.findings,$.failOn))V.exit(1);return}let T;{let B=$.base||Q.repository?.baseBranch||"main",N=$.staged?"staged":$.branch?"branch":"working";U.info(`\uD83D\uDD0D Reviewing ${N} changes${N==="branch"?` against ${B}`:""}...`),T=await q(N,B)}if(!T.trim()){if(!Y)J.success("\u2705 No changes to review");return}let{parseUnifiedDiff:A}=await import("../chunk-7ds5q6j3.js"),I=A(T).files.map((B)=>B.path),M=Q.analysis?.enabled===!1?{findings:[],ran:[],skipped:[]}:await W({files:I,root:V.cwd(),...Q.analysis?.tools?{enabled:Q.analysis.tools}:{},logger:U});if($.light){let B={summary:`Static analysis of ${I.length} changed file(s).`,walkthrough:[],findings:M.findings,effort:1,omittedFiles:M.skipped.map((N)=>`${N.name} (${N.reason})`)};if(V.stdout.write(K(B,z)),$.fix){let N=await Z0(B.findings,Boolean($.yes),J);J.success(`\uD83D\uDD27 Applied ${N} suggestion(s)`)}if($.failOn&&F(B.findings,$.failOn))V.exit(1);return}let L=await H(G,{diff:T,profile:$.profile??Q.ai?.review?.profile,summaryOnly:$.summaryOnly??Q.ai?.review?.summaryOnly,instructions:j({global:Q.ai?.review?.instructions}),pathFilters:Q.ai?.review?.pathFilters,pathInstructions:Q.ai?.review?.pathInstructions,seenFingerprints:[],logger:U}),E={...L,findings:[...M.findings,...L.findings],omittedFiles:[...L.omittedFiles,...M.skipped.map((B)=>`${B.name} (${B.reason})`)]};if(V.stdout.write(K(E,z)),$.fix){let B=await Z0(E.findings,Boolean($.yes),J);J.success(`\uD83D\uDD27 Applied ${B} suggestion(s)`)}if($.failOn&&F(E.findings,$.failOn))V.exit(1)}catch(X){J.error("Review failed:",X),await g(Q.notifications,"run.failed",{command:"review",error:X instanceof Error?X.message:String(X)}),V.exit(1)}});w.command("check <packages...>","Check specific packages for updates").option("--verbose, -v","Enable verbose logging").option("--strategy <type>","Update strategy: major|minor|patch|all (default: packages.strategy from config, else all)").example("buddy check react typescript").example("buddy check react --verbose").action(async(...Z)=>{let $=Z[Z.length-1],J=Z.slice(0,-1),Q=$.verbose?O.verbose():O.quiet(),z=await k($.config);if(!J.length)Q.error("No packages specified to check"),V.exit(1);try{Q.info(`Checking specific packages: ${J.join(", ")}`);let Y={...z,verbose:$.verbose??z.verbose,packages:{...z.packages,strategy:$.strategy??z.packages?.strategy??"all"}},X=await new m(Y).checkPackages(J);if(X.length===0)Q.success("All specified packages are up to date!");else{Q.info(`Found ${X.length} updates:`);for(let G of X)Q.info(` ${G.name}: ${G.currentVersion} \u2192 ${G.newVersion} (${G.updateType})`)}}catch(Y){Q.error("Check failed:",Y),V.exit(1)}});w.command("schedule","Run automated dependency updates on schedule").option("--verbose, -v","Enable verbose logging").option("--strategy <type>","Update strategy: major|minor|patch|all (default: packages.strategy from config, else all)").example("buddy schedule").example("buddy schedule --verbose").example("buddy schedule --strategy patch").action(async(Z)=>{let{Scheduler:$}=await import("../chunk-sxdfmskp.js"),J=Z.verbose?O.verbose():O.quiet(),Q=await k(Z.config);try{J.info("\uD83D\uDD52 Starting Buddy Scheduler...");let z;if(Z.ignore)z=Z.ignore.split(",").map((G)=>G.trim());let Y={...Q,verbose:Z.verbose??Q.verbose,packages:{...Q.packages,strategy:Z.strategy??Q.packages?.strategy??"all",ignore:z??Q.packages?.ignore}};if(!Y.repository?.provider||!Y.repository?.owner||!Y.repository?.name)J.error("\u274C Repository configuration required for scheduling. Please configure:"),J.info(" - repository.provider (github)"),J.info(" - repository.owner"),J.info(" - repository.name"),J.info(" - repository.token (via environment variable)"),V.exit(1);let U=new $(Z.verbose),X=$.createJobFromConfig(Y,"cli-schedule");if(Z.strategy)switch(Z.strategy){case"major":X.schedule.cron=$.PRESETS.WEEKLY;break;case"minor":X.schedule.cron=$.PRESETS.TWICE_WEEKLY;break;case"patch":X.schedule.cron=$.PRESETS.DAILY;break;default:X.schedule.cron=$.PRESETS.WEEKLY}U.addJob(X),U.start(),J.success(`\u2705 Scheduler started with cron: ${X.schedule.cron}`),J.info("\uD83D\uDCC5 Next run:",X.nextRun?.toISOString()||"Unknown"),J.info("\uD83D\uDED1 Press Ctrl+C to stop the scheduler"),V.stdin.resume()}catch(z){J.error("Scheduler failed:",z),V.exit(1)}});w.command("generate-workflows",'Generate GitHub Actions workflow templates (deprecated - use "setup" instead)').option("--verbose, -v","Enable verbose logging").example("buddy generate-workflows").example("buddy generate-workflows --verbose").action(async(Z)=>{let{GitHubActionsTemplate:$}=await import("../chunk-7ze1qrmt.js"),{writeFileSync:J,mkdirSync:Q}=await import("fs"),{resolve:z}=await import("path"),Y=Z.verbose?O.verbose():O.quiet(),U=await k(Z.config);if(U.workflows?.enabled===!1){Y.info("\u2139\uFE0F Workflow generation is disabled by config (workflows.enabled: false)");return}console.log('\u26A0\uFE0F The "generate-workflows" command is deprecated.'),console.log(`\uD83D\uDCA1 Use "buddy setup" for a better interactive experience.
|
|
148
|
+
`);try{let X={...U,verbose:Z.verbose??U.verbose},G=X.workflows?.outputDir?z(V.cwd(),X.workflows.outputDir):z(V.cwd(),".github","workflows");Y.info("\uD83D\uDE80 Generating GitHub Actions workflow templates...");try{Q(G,{recursive:!0})}catch{}let j=X.workflows?.templates||{comprehensive:!0,daily:!0,weekly:!0,monthly:!0,docker:!0,monorepo:!0},H=0;if(j.daily||j.weekly||j.monthly){let q=$.generateScheduledWorkflows(X);for(let[K,F]of Object.entries(q))if(K.includes("daily")&&j.daily||K.includes("weekly")&&j.weekly||K.includes("monthly")&&j.monthly){let T=z(G,K);J(T,F),Y.success(`Generated: ${K}`),H++}}if(j.comprehensive){let q=$.generateComprehensiveWorkflow(X);J(z(G,"buddy-comprehensive.yml"),q),Y.success("Generated: buddy-comprehensive.yml"),H++}if(j.docker){let q=$.generateDockerWorkflow(X);J(z(G,"buddy-docker.yml"),q),Y.success("Generated: buddy-docker.yml"),H++}if(j.monorepo){let q=$.generateMonorepoWorkflow(X);J(z(G,"buddy-monorepo.yml"),q),Y.success("Generated: buddy-monorepo.yml"),H++}if(X.workflows?.custom?.length)for(let q of X.workflows.custom){let K=$.generateCustomWorkflow(q,X),F=`buddy-${q.name.toLowerCase().replace(/\s+/g,"-")}.yml`;J(z(G,F),K),Y.success(`Generated: ${F}`),H++}if(H===0){Y.warn("No workflows were generated. Check your configuration in buddy.config.ts"),Y.info("Set workflows.templates to enable specific templates or add custom workflows.");return}Y.success(`
|
|
149
149
|
\uD83C\uDF89 ${H} GitHub Actions workflow(s) generated!`),Y.info(`\uD83D\uDCC1 Location: ${G}`),Y.info(`
|
|
150
150
|
\uD83D\uDCA1 Next steps:`),Y.info(" 1. Review and customize the workflows for your project"),Y.info(" 2. Ensure GITHUB_TOKEN is available as a secret"),Y.info(" 3. Configure buddy.config.ts with your repository settings"),Y.info(" 4. Enable GitHub Actions in your repository settings"),Y.info(`
|
|
151
|
-
\uD83D\uDD17 Learn more: https://docs.github.com/en/actions`)}catch(
|
|
152
|
-
\uD83D\uDCCB Recent versions:`),Y.versions.slice(-U).reverse().forEach((G,
|
|
153
|
-
\uD83D\uDCCB Production Dependencies (${H}):`),H>0)Object.entries(
|
|
154
|
-
\uD83D\uDEE0\uFE0F Dev Dependencies (${H}):`),H>0)Object.entries(
|
|
155
|
-
\uD83E\uDD1D Peer Dependencies (${H}):`),H>0)Object.entries(
|
|
151
|
+
\uD83D\uDD17 Learn more: https://docs.github.com/en/actions`)}catch(X){Y.error("Failed to generate workflows:",X),V.exit(1)}});w.command("info <package>","Show detailed package information").option("--verbose, -v","Enable verbose logging").option("--json","Output in JSON format").example("buddy info react").example("buddy info react --json").example("buddy info typescript@latest").action(async(Z,$)=>{let{RegistryClient:J}=await import("../chunk-3ggd7z2f.js"),Q=$.verbose?O.verbose():O.quiet();try{let z=new J(V.cwd(),Q,void 0);if($.json){let{spawn:X}=await import("child_process");X("bun",["info",Z,"--json"],{stdio:"inherit"}).on("close",(j)=>{V.exit(j||0)});return}let Y=await z.getPackageMetadata(Z);if(!Y)Q.error(`Package "${Z}" not found or failed to fetch metadata`),V.exit(1);if(console.log(`\uD83D\uDCE6 ${Y.name}@${Y.latestVersion}`),Y.description)console.log(`\uD83D\uDCDD ${Y.description}`);if(Y.homepage)console.log(`\uD83C\uDF10 ${Y.homepage}`);if(Y.repository)console.log(`\uD83D\uDCC1 ${Y.repository}`);if(Y.license)console.log(`\u2696\uFE0F License: ${Y.license}`);if(Y.author)console.log(`\uD83D\uDC64 Author: ${Y.author}`);if(Y.keywords&&Y.keywords.length>0)console.log(`\uD83C\uDFF7\uFE0F Keywords: ${Y.keywords.join(", ")}`);let U={deps:Object.keys(Y.dependencies||{}).length,devDeps:Object.keys(Y.devDependencies||{}).length,peerDeps:Object.keys(Y.peerDependencies||{}).length};if(console.log(`\uD83D\uDCCA Dependencies: ${U.deps} | Dev: ${U.devDeps} | Peer: ${U.peerDeps}`),Y.versions&&Y.versions.length>1){if(console.log(`\uD83D\uDCC8 ${Y.versions.length} versions available`),$.verbose&&Y.versions.length<=10)console.log(` Latest versions: ${Y.versions.slice(-5).join(", ")}`)}}catch(z){Q.error("Failed to get package info:",z),V.exit(1)}});w.command("versions <package>","Show all available versions of a package").option("--verbose, -v","Enable verbose logging").option("--latest <count>","Show only the latest N versions",{default:"10"}).example("buddy versions react").example("buddy versions react --latest 5").action(async(Z,$)=>{let{RegistryClient:J}=await import("../chunk-3ggd7z2f.js"),Q=$.verbose?O.verbose():O.quiet();try{let Y=await new J(V.cwd(),Q,void 0).getPackageMetadata(Z);if(!Y)Q.error(`Package "${Z}" not found`),V.exit(1);let U=Number.parseInt($.latest||"10",10);if(console.log(`\uD83D\uDCE6 ${Y.name} - Available Versions`),console.log(`\uD83D\uDCC8 Total: ${Y.versions?.length||0} versions`),console.log(`\u2B50 Latest: ${Y.latestVersion}`),Y.versions&&Y.versions.length>0){if(console.log(`
|
|
152
|
+
\uD83D\uDCCB Recent versions:`),Y.versions.slice(-U).reverse().forEach((G,j)=>{let q=G===Y.latestVersion?"\u2B50":" ";console.log(`${q} ${G}`)}),Y.versions.length>U)console.log(` ... and ${Y.versions.length-U} older versions`)}}catch(z){Q.error("Failed to get package versions:",z),V.exit(1)}});w.command("exists <package>","Check if a package exists in the registry").option("--verbose, -v","Enable verbose logging").example("buddy exists react").example("buddy exists nonexistent-package-xyz").action(async(Z,$)=>{let{RegistryClient:J}=await import("../chunk-3ggd7z2f.js"),Q=$.verbose?O.verbose():O.quiet();try{if(await new J(V.cwd(),Q,void 0).packageExists(Z))console.log(`\u2705 Package "${Z}" exists in the registry`),V.exit(0);else console.log(`\u274C Package "${Z}" does not exist in the registry`),V.exit(1)}catch(z){Q.error("Failed to check package existence:",z),V.exit(1)}});w.command("latest <package>","Get the latest version of a package").option("--verbose, -v","Enable verbose logging").example("buddy latest react").example("buddy latest @types/node").action(async(Z,$)=>{let{RegistryClient:J}=await import("../chunk-3ggd7z2f.js"),Q=$.verbose?O.verbose():O.quiet();try{let Y=await new J(V.cwd(),Q,void 0).getLatestVersion(Z);if(Y)console.log(`\uD83D\uDCE6 ${Z}@${Y}`);else Q.error(`Package "${Z}" not found`),V.exit(1)}catch(z){Q.error("Failed to get latest version:",z),V.exit(1)}});w.command("deps <package>","Show dependencies of a package").option("--verbose, -v","Enable verbose logging").option("--dev","Show dev dependencies").option("--peer","Show peer dependencies").option("--all","Show all dependency types").example("buddy deps react").example("buddy deps react --dev").example("buddy deps react --all").action(async(Z,$)=>{let{RegistryClient:J}=await import("../chunk-3ggd7z2f.js"),Q=$.verbose?O.verbose():O.quiet();try{let Y=await new J(V.cwd(),Q,void 0).getPackageMetadata(Z);if(!Y)Q.error(`Package "${Z}" not found`),V.exit(1);console.log(`\uD83D\uDCE6 ${Y.name}@${Y.latestVersion} - Dependencies`);let U=!$.dev&&!$.peer,X=$.dev||$.all,G=$.peer||$.all;if(U||$.all){let j=Y.dependencies||{},H=Object.keys(j).length;if(console.log(`
|
|
153
|
+
\uD83D\uDCCB Production Dependencies (${H}):`),H>0)Object.entries(j).forEach(([q,K])=>{console.log(` ${q}: ${K}`)});else console.log(" No production dependencies")}if(X){let j=Y.devDependencies||{},H=Object.keys(j).length;if(console.log(`
|
|
154
|
+
\uD83D\uDEE0\uFE0F Dev Dependencies (${H}):`),H>0)Object.entries(j).forEach(([q,K])=>{console.log(` ${q}: ${K}`)});else console.log(" No dev dependencies")}if(G){let j=Y.peerDependencies||{},H=Object.keys(j).length;if(console.log(`
|
|
155
|
+
\uD83E\uDD1D Peer Dependencies (${H}):`),H>0)Object.entries(j).forEach(([q,K])=>{console.log(` ${q}: ${K}`)});else console.log(" No peer dependencies")}}catch(z){Q.error("Failed to get package dependencies:",z),V.exit(1)}});w.command("compare <package> <version1> <version2>","Compare two versions of a package").option("--verbose, -v","Enable verbose logging").example("buddy compare react 17.0.0 18.0.0").example("buddy compare typescript 4.9.0 5.0.0").action(async(Z,$,J,Q)=>{let z=Q.verbose?O.verbose():O.quiet();try{console.log(`\uD83D\uDCCA Comparing ${Z}: ${$} vs ${J}`);let{RegistryClient:Y}=await import("../chunk-3ggd7z2f.js"),X=await new Y(V.cwd(),z,void 0).getPackageMetadata(Z);if(!X)z.error(`Package "${Z}" not found`),V.exit(1);let G=X.versions||[];if(!G.includes($))console.log(`\u26A0\uFE0F Version ${$} not found in available versions`);if(!G.includes(J))console.log(`\u26A0\uFE0F Version ${J} not found in available versions`);let{getUpdateType:j}=await import("../chunk-1vhqtq6m.js"),H=j($,J);console.log(`
|
|
156
156
|
\uD83D\uDD0D Version Analysis:`),console.log(` From: ${$}`),console.log(` To: ${J}`),console.log(` Type: ${H} update`);let q=G.indexOf($),K=G.indexOf(J);if(q!==-1&&K!==-1){let F=Math.abs(K-q)-1;if(console.log(` Gap: ${F} versions between them`),K>q)console.log(` \uD83D\uDCC8 ${J} is newer than ${$}`);else console.log(` \uD83D\uDCC9 ${J} is older than ${$}`)}console.log(`
|
|
157
157
|
\uD83D\uDCA1 Use 'buddy versions ${Z}' to see all available versions`),console.log(`\uD83D\uDCA1 Use 'buddy info ${Z}' for detailed package information`)}catch(Y){z.error("Failed to compare versions:",Y),V.exit(1)}});w.command("search <query>","Search for packages in the registry").option("--verbose, -v","Enable verbose logging").option("--limit <count>","Limit number of results",{default:"10"}).example("buddy search react").example('buddy search "test framework" --limit 5').action(async(Z,$)=>{let J=$.verbose?O.verbose():O.quiet();try{let{spawn:Q}=await import("child_process"),z=Number.parseInt($.limit||"10",10);console.log(`\uD83D\uDD0D Searching for: "${Z}"`),console.log(`\uD83D\uDCCA Showing top ${z} results
|
|
158
|
-
`),Q("which",["npm"],{stdio:"pipe"}).on("close",async(U)=>{if(U!==0){console.log("\uD83D\uDCE1 Using npm registry API search...");try{let{RegistryClient:
|
|
159
|
-
\uD83D\uDD0D [DRY RUN] These branches would be deleted`),$.info("\uD83D\uDCA1 Run without --dry-run to actually delete them");return}if(!Z.force){if(!(await a.default({type:"confirm",name:"confirmed",message:`Are you sure you want to delete ${
|
|
160
|
-
\uD83D\uDCCA Cleanup Summary:`),$.info(` \u2705 Deleted: ${G.deleted.length}`),$.info(` \u274C Failed: ${G.failed.length}`),$.info(` \uD83D\uDCCA Total processed: ${
|
|
161
|
-
\uD83D\uDCCA Found ${
|
|
162
|
-
`),
|
|
163
|
-
\uD83D\uDCA1 Run 'buddy cleanup' to clean up stale branches`)}catch(Q){$.error("Branch listing failed:",Q),V.exit(1)}});w.command("open-settings","Open GitHub repository and organization settings pages").option("--type <scope>","Which settings to open: repo, org or both",{default:"both"}).option("--verbose, -v","Enable verbose logging").example("buddy open-settings").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=String(Z?.type??"both").toLowerCase();if(!["repo","org","both"].includes(J))$.error(`Unknown --type ${J}. Expected repo, org or both.`),V.exit(1);let Q=await
|
|
164
|
-
For manual setup, visit:`),$.info("\uD83D\uDD17 Repository settings: https://github.com/YOUR_ORG/YOUR_REPO/settings/actions"),$.info("\uD83D\uDD17 Organization settings: https://github.com/organizations/YOUR_ORG/settings/actions");return}let
|
|
158
|
+
`),Q("which",["npm"],{stdio:"pipe"}).on("close",async(U)=>{if(U!==0){console.log("\uD83D\uDCE1 Using npm registry API search...");try{let{RegistryClient:j}=await import("../chunk-3ggd7z2f.js"),q=await new j(V.cwd(),J,void 0).searchPackages(Z,z);if(q.length===0){console.log(`\u274C No packages found for "${Z}"`),console.log("\uD83D\uDCA1 Try different search terms or browse https://www.npmjs.com");return}q.forEach((K,F)=>{if(console.log(`${F+1}. \uD83D\uDCE6 ${K.name}@${K.version}`),K.description)console.log(` \uD83D\uDCDD ${K.description}`);if(K.keywords&&K.keywords.length>0)console.log(` \uD83C\uDFF7\uFE0F ${K.keywords.slice(0,3).join(", ")}${K.keywords.length>3?"...":""}`);console.log()}),console.log("\u2728 Use 'buddy info <package>' for detailed information")}catch{console.log("\u274C Registry API search failed"),console.log("\uD83D\uDCA1 Alternative search options:"),console.log(` \u2022 Visit https://www.npmjs.com/search?q=${encodeURIComponent(Z)}`),console.log(" \u2022 Use: bun add <package-name> to test if a package exists"),console.log(" \u2022 Use: buddy exists <package-name> to check existence")}return}let X=Q("npm",["search",Z,"--json"],{stdio:"pipe"}),G="";X.stdout?.on("data",(j)=>{G+=j.toString()}),X.stderr?.on("data",(j)=>{if($.verbose)J.warn("npm search stderr:",j.toString())}),X.on("close",(j)=>{if(j===0)try{let q=JSON.parse(G).slice(0,z);if(q.length===0){console.log(`\u274C No packages found for "${Z}"`),console.log("\uD83D\uDCA1 Try different search terms or browse https://www.npmjs.com");return}q.forEach((K,F)=>{if(console.log(`${F+1}. \uD83D\uDCE6 ${K.name}@${K.version}`),K.description)console.log(` \uD83D\uDCDD ${K.description}`);if(K.keywords&&K.keywords.length>0)console.log(` \uD83C\uDFF7\uFE0F ${K.keywords.slice(0,3).join(", ")}${K.keywords.length>3?"...":""}`);console.log()}),console.log("\u2728 Use 'buddy info <package>' for detailed information")}catch(H){J.error("Failed to parse search results:",H),console.log(`\uD83D\uDCA1 Try searching at https://www.npmjs.com/search?q=${encodeURIComponent(Z)}`)}else console.log("\u274C Search failed"),console.log(`\uD83D\uDCA1 Try searching at https://www.npmjs.com/search?q=${encodeURIComponent(Z)}`)})})}catch(Q){J.error("Failed to search packages:",Q),console.log(`\uD83D\uDCA1 Try searching at https://www.npmjs.com/search?q=${encodeURIComponent(Z)}`)}});w.command("cleanup","Clean up stale buddy branches that don't have associated open PRs").option("--verbose, -v","Enable verbose logging").option("--dry-run","Show what would be deleted without actually deleting").option("--days <number>","Delete branches older than N days (default: 7)",{default:"7"}).option("--force","Force cleanup without confirmation prompt").example("buddy cleanup").example("buddy cleanup --dry-run").example("buddy cleanup --days 14").example("buddy cleanup --force").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await k(Z.config);try{if($.info("\uD83E\uDDF9 Starting buddy branch cleanup..."),!J.repository)$.error("\u274C Repository configuration required for branch cleanup"),$.info("Configure repository.provider, repository.owner, repository.name in buddy.config.ts"),V.exit(1);let Q=await d(J,"branch operations",$),z=Number.parseInt(Z.days||"7",10);if(Number.isNaN(z)||z<1)$.error("\u274C Invalid days value. Must be a positive number."),V.exit(1);$.info(`\uD83D\uDD0D Looking for buddy branches older than ${z} days...`),z1(Q,"branchHousekeeping","getOrphanedBuddyBranches","branch cleanup");let Y=await Q.getOrphanedBuddyBranches(),U=new Date;U.setDate(U.getDate()-z);let X=Y.filter((j)=>j.lastCommitDate<U);if(X.length===0){$.success("\u2705 No stale branches found!"),$.info(`\uD83D\uDCCA Total buddy branches: ${Y.length}`),$.info(`\uD83D\uDCCA Stale branches (>${z} days): 0`);return}if($.info(`\uD83D\uDCCA Found ${X.length} stale branches to clean up:`),X.forEach((j)=>{let H=Math.floor((Date.now()-j.lastCommitDate.getTime())/86400000);$.info(` - ${j.name} (${H} days old)`)}),Z.dryRun){$.info(`
|
|
159
|
+
\uD83D\uDD0D [DRY RUN] These branches would be deleted`),$.info("\uD83D\uDCA1 Run without --dry-run to actually delete them");return}if(!Z.force){if(!(await a.default({type:"confirm",name:"confirmed",message:`Are you sure you want to delete ${X.length} stale branches?`,initial:!1})).confirmed){$.info("\u274C Cleanup cancelled");return}}z1(Q,"branchHousekeeping","cleanupStaleBranches","branch cleanup");let G=await Q.cleanupStaleBranches(z,!1);if(G.deleted.length>0)$.success(`\u2705 Successfully deleted ${G.deleted.length} stale branches`);if(G.failed.length>0)$.warn(`\u26A0\uFE0F Failed to delete ${G.failed.length} branches`),G.failed.forEach((j)=>$.warn(` - ${j}`));$.info(`
|
|
160
|
+
\uD83D\uDCCA Cleanup Summary:`),$.info(` \u2705 Deleted: ${G.deleted.length}`),$.info(` \u274C Failed: ${G.failed.length}`),$.info(` \uD83D\uDCCA Total processed: ${X.length}`)}catch(Q){$.error("Branch cleanup failed:",Q),V.exit(1)}});w.command("list-branches","List all buddy branches and their status").option("--verbose, -v","Enable verbose logging").option("--orphaned-only","Show only branches without associated open PRs").option("--stale-only","Show only stale branches (older than 7 days)").option("--days <number>","Define stale threshold in days (default: 7)",{default:"7"}).example("buddy list-branches").example("buddy list-branches --orphaned-only").example("buddy list-branches --stale-only --days 14").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await k(Z.config);try{if($.info("\uD83D\uDCCB Listing buddy branches..."),!J.repository)$.error("\u274C Repository configuration required for branch listing"),$.info("Configure repository.provider, repository.owner, repository.name in buddy.config.ts"),V.exit(1);let Q=await d(J,"branch operations",$),z=Number.parseInt(Z.days||"7",10),Y=new Date;Y.setDate(Y.getDate()-z),z1(Q,"branchHousekeeping","getBuddyBranches","branch listing");let[U,X]=await Promise.all([Q.getBuddyBranches(),Q.getPullRequests("open")]),G=new Set(X.map((K)=>K.head)),j=U;if(Z.orphanedOnly)j=j.filter((K)=>!G.has(K.name));if(Z.staleOnly)j=j.filter((K)=>K.lastCommitDate<Y&&!G.has(K.name));if(j.length===0){if(Z.orphanedOnly&&Z.staleOnly)$.success("\u2705 No stale orphaned branches found!");else if(Z.orphanedOnly)$.success("\u2705 No orphaned branches found!");else if(Z.staleOnly)$.success("\u2705 No stale branches found!");else $.info("\uD83D\uDCCB No buddy branches found");return}console.log(`
|
|
161
|
+
\uD83D\uDCCA Found ${j.length} buddy branch${j.length!==1?"es":""}:
|
|
162
|
+
`),j.sort((K,F)=>F.lastCommitDate.getTime()-K.lastCommitDate.getTime()),j.forEach((K)=>{let F=G.has(K.name),W=Math.floor((Date.now()-K.lastCommitDate.getTime())/86400000),T=K.lastCommitDate<Y,A=F?"\uD83D\uDD34 Open PR":T?"\uD83D\uDFE1 Stale":"\uD83D\uDFE2 Recent",I=K.sha.substring(0,7);console.log(`${A} ${K.name}`),console.log(` \uD83D\uDCC5 ${W} days old | \uD83D\uDCDD ${I} | \uD83D\uDDD3\uFE0F ${K.lastCommitDate.toISOString().split("T")[0]}`),console.log()});let H=j.filter((K)=>!G.has(K.name)).length,q=j.filter((K)=>K.lastCommitDate<Y&&!G.has(K.name)).length;if(console.log("\uD83D\uDCCA Summary:"),console.log(` \uD83D\uDCCB Total buddy branches: ${U.length}`),console.log(` \uD83D\uDD34 With open PRs: ${U.length-H}`),console.log(` \uD83D\uDFE1 Orphaned: ${H}`),console.log(` \uD83D\uDDD1\uFE0F Stale (>${z} days): ${q}`),q>0)console.log(`
|
|
163
|
+
\uD83D\uDCA1 Run 'buddy cleanup' to clean up stale branches`)}catch(Q){$.error("Branch listing failed:",Q),V.exit(1)}});w.command("open-settings","Open GitHub repository and organization settings pages").option("--type <scope>","Which settings to open: repo, org or both",{default:"both"}).option("--verbose, -v","Enable verbose logging").example("buddy open-settings").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=String(Z?.type??"both").toLowerCase();if(!["repo","org","both"].includes(J))$.error(`Unknown --type ${J}. Expected repo, org or both.`),V.exit(1);let Q=await k(Z.config);try{let{exec:z}=await import("child_process"),{promisify:Y}=await import("util"),U=Y(z),X=Q.repository?.owner,G=Q.repository?.name;if(!X||!G)try{let{stdout:K}=await U("git remote get-url origin"),W=K.trim().match(/github\.com[/:]([\w-]+)\/([\w-]+)(?:\.git)?/);if(W)X=W[1],G=W[2],$.info(`\uD83D\uDCE1 Detected repository: ${X}/${G}`)}catch{}if(!X||!G){$.warn("\u26A0\uFE0F Could not determine repository information."),$.info("\uD83D\uDCA1 Please configure repository settings in buddy.config.ts or run from a Git repository."),$.info(`
|
|
164
|
+
For manual setup, visit:`),$.info("\uD83D\uDD17 Repository settings: https://github.com/YOUR_ORG/YOUR_REPO/settings/actions"),$.info("\uD83D\uDD17 Organization settings: https://github.com/organizations/YOUR_ORG/settings/actions");return}let j=`https://github.com/${X}/${G}/settings/actions`,H=`https://github.com/organizations/${X}/settings/actions`;$.info("\uD83D\uDD27 Opening GitHub Actions settings pages..."),$.info(`\uD83D\uDCE6 Repository: ${X}/${G}`);let q=async(K,F)=>{try{let W;switch(V.platform){case"darwin":W=`open "${K}"`;break;case"win32":W=`start "" "${K}"`;break;default:W=`xdg-open "${K}"`}await U(W),$.success(`\u2705 Opened ${F}: ${K}`)}catch{$.warn(`\u26A0\uFE0F Could not auto-open ${F}. Please visit manually:`),$.info(`\uD83D\uDD17 ${K}`)}};if(J!=="org")await q(j,"repository settings");setTimeout(async()=>{if(J!=="repo")$.info(`
|
|
165
165
|
\uD83C\uDFE2 Attempting to open organization settings...`),await q(H,"organization settings");$.info(`
|
|
166
166
|
\uD83D\uDCCB Required Settings:`),$.info(' 1. Under "Workflow permissions":'),$.info(' \u2705 Select "Read and write permissions"'),$.info(' \u2705 Check "Allow GitHub Actions to create and approve pull requests"'),$.info(' 2. Click "Save"'),$.info(`
|
|
167
167
|
\uD83D\uDCA1 Note: Organization settings may override repository settings.`)},1000)}catch(z){$.error("Failed to open settings:",z),$.info(`
|
|
168
|
-
\uD83D\uDCCB Manual Setup:`),$.info("\uD83D\uDD17 Repository: https://github.com/YOUR_ORG/YOUR_REPO/settings/actions"),$.info("\uD83D\uDD17 Organization: https://github.com/organizations/YOUR_ORG/settings/actions")}});w.command("security [path]","\uD83D\uDEE1 Static-analyse GitHub Actions workflows for supply-chain footguns").option("-f, --format <format>","Reporter (pretty | json | github). Defaults to github on a runner, pretty otherwise.").option("--ignore <ids>","Comma-separated rule ids to skip (e.g. missing-timeout,unpinned-action)").option("--no-color","Disable ANSI colours in pretty output").action(async(Z,$)=>{let{audit:J}=await import("../chunk-
|
|
169
|
-
`),V.exit(2);return}if(
|
|
170
|
-
`);V.exit(
|
|
168
|
+
\uD83D\uDCCB Manual Setup:`),$.info("\uD83D\uDD17 Repository: https://github.com/YOUR_ORG/YOUR_REPO/settings/actions"),$.info("\uD83D\uDD17 Organization: https://github.com/organizations/YOUR_ORG/settings/actions")}});w.command("security [path]","\uD83D\uDEE1 Static-analyse GitHub Actions workflows for supply-chain footguns").option("-f, --format <format>","Reporter (pretty | json | github). Defaults to github on a runner, pretty otherwise.").option("--ignore <ids>","Comma-separated rule ids to skip (e.g. missing-timeout,unpinned-action)").option("--no-color","Disable ANSI colours in pretty output").action(async(Z,$)=>{let{audit:J}=await import("../chunk-ydt2sn0j.js"),{formatPretty:Q}=await import("../chunk-bjymeq7e.js"),{formatJson:z}=await import("../chunk-04qvf24t.js"),{formatGitHub:Y}=await import("../chunk-90q6r1j7.js"),U=$.ignore?.split(",").filter(Boolean)??[],X=await J(Z??".",{ignore:U}),G=$.format??(V.env.GITHUB_ACTIONS==="true"?"github":"pretty"),j;switch(G){case"json":j=z(X);break;case"github":j=Y(X);break;case"pretty":j=Q(X,{color:$.color!==!1});break;default:V.stderr.write(`Unknown --format ${G}. Use pretty | json | github.
|
|
169
|
+
`),V.exit(2);return}if(j)V.stdout.write(`${j}
|
|
170
|
+
`);V.exit(X.failed?1:0)});w.command("touch <pr-number>","Run a finishing touch ticked on a pull request, as a stacked PR").option("--name <touch>","Run a specific touch rather than reading the checkboxes").option("--offer","Post the checkboxes on the pull request rather than running one").option("--test-command <command>","Command that verifies the change").option("--dry-run","Report what would run without acting").option("--verbose, -v","Enable verbose logging").example("buddy touch 42").example("buddy touch 42 --offer").example("buddy touch 42 --name unit-tests").action(async(Z,$)=>{let J=$.verbose?O.verbose():O.quiet(),Q=await k($.config);try{let z=Number.parseInt(Z,10),Y=await d(Q,"finishing touches",J),X=(await Y.getPullRequests("open")).find((M)=>M.number===z);if(!X)J.error(`\u274C Pull request #${z} is not open`),V.exit(1);let{FINISHING_TOUCHES:G,getFinishingTouch:j,hasTouchOffer:H,parseTouchSelections:q,withTouchOffer:K}=await import("../chunk-8tsw3cjk.js");if($.offer){if(H(X.body)){J.info(`\u2139\uFE0F PR #${X.number} already carries the finishing-touch offer`);return}let M=K(X.body);if($.dryRun){J.info(`\uD83D\uDD0D [DRY RUN] Would offer finishing touches on PR #${X.number}`);return}await Y.updatePullRequest(X.number,{body:M}),J.success(`\u2705 Offered finishing touches on PR #${X.number}`);return}let F=$.name?[$.name]:q(X.body);if(F.length===0){J.info("\u2139\uFE0F No finishing touches are ticked on this pull request");return}let{createAiClient:W}=await import("../chunk-2145m12g.js"),T=W(Q,J);if(!T)J.error("\u274C Finishing touches need an API key. See https://buddy.sh/ai/providers"),V.exit(1);if($.dryRun){J.info(`\uD83D\uDD0D [DRY RUN] Would run: ${F.join(", ")}`);return}let{runStackedTouch:A}=await import("../chunk-mzb7cg8a.js");for(let M of F){if(!G[M]){J.warn(`\u26A0\uFE0F Unknown finishing touch '${M}', skipping`);continue}let L=await A({provider:Y,pullRequest:X,touch:j(M),ai:T,workspace:V.cwd(),...$.testCommand?{testCommand:$.testCommand.split(" ")}:{},logger:J});await Y.createComment(z,L.comment),J.success(`\u2705 ${M}: ${L.mode}`)}let I=X.body.replace(/^(\s*-\s*)\[[xX]\](\s*<!--\s*buddy:touch=)/gm,"$1[ ]$2");if(I!==X.body)await Y.updatePullRequest(z,{body:I})}catch(z){J.error("Finishing touch failed:",z),V.exit(1)}});w.command("handle-issue","Post Buddy quick-links on a new issue, or run a ticked action").option("--payload <path>","Path to the event payload (default: GITHUB_EVENT_PATH)").option("--issue <number>","Act on an issue directly rather than reading an event").option("--dry-run","Report what would happen without acting").option("--verbose, -v","Enable verbose logging").example("buddy handle-issue").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await k(Z.config);if(J.issues?.quickLinks!==!0){$.info("\u2139\uFE0F Issue quick-links are off (set issues.quickLinks to enable)");return}try{let Q=Z.issue?Number.parseInt(Z.issue,10):Number.NaN;if(Number.isNaN(Q)){let W=Z.payload||V.env.GITHUB_EVENT_PATH;if(!W)$.error("\u274C No event payload. Pass --issue or --payload, or run inside CI."),V.exit(1);let T=await Bun.file(W).json();if(Q=Number(T?.issue?.number),Number.isNaN(Q)){$.info("\u2139\uFE0F Event carries no issue; nothing to do");return}}let z=await d(J,"issue quick-links",$),U=(await z.getIssues("open")).find((W)=>W.number===Q);if(!U){$.info(`\u2139\uFE0F Issue #${Q} is not open`);return}let{clearQuickSelection:X,parseQuickSelection:G,QUICK_LINKS_MARKER:j,renderQuickLinks:H}=await import("../chunk-1tg7dfq5.js"),q=G(U.body);if(q.actions.length>0){if($.info(`\uD83E\uDD16 Requested: ${q.actions.join(", ")}`),Z.dryRun)return;let{createAiClient:W}=await import("../chunk-2145m12g.js"),T=W(J,$);if(!T){await z.createComment(Q,"Buddy needs an AI provider configured to act on this. See https://buddy.sh/ai/providers");return}await z.updateIssue(Q,{body:X(U.body)});for(let A of q.actions){if(A==="plan"){let{runPlan:b}=await import("../chunk-4akhxmfk.js"),R=await b({config:J,provider:z,number:Q,isPullRequest:!1,logger:$});await z.createComment(Q,R),$.success("\u2705 Ran plan");continue}let{BUILTIN_TOOLS:I,createReadIssueTool:M,getFinishingTouch:L,runAgent:E}=await import("../chunk-4akhxmfk.js"),B=L("autofix"),N=await E(T,{mode:B.mode,task:`${B.buildTask({files:[]})}
|
|
171
171
|
|
|
172
|
-
Call \`read_issue\` to see what was asked for.`,tools:[...
|
|
173
|
-
`);return}let{createAiClient:s}=await import("../chunk-
|
|
174
|
-
`);return}let
|
|
172
|
+
Call \`read_issue\` to see what was asked for.`,tools:[...I,M(z,Q,!1)],context:{workspace:V.cwd(),baseBranch:J.repository?.baseBranch??"main"},logger:$});await z.createComment(Q,N.output||`I could not finish that (${N.stopReason}).`),$.success(`\u2705 Ran ${A}`)}return}if(U.body.includes(j)){$.debug("Quick-links already posted on this issue");return}let K=J.issues?.dependencyContext?await kZ(J,$):[],F=H({body:U.body,packages:K});if(Z.dryRun){$.info(F);return}await z.createComment(Q,F),$.success(`\u2705 Posted quick-links on #${Q}`)}catch(Q){$.error("handle-issue failed:",Q),V.exit(1)}});w.command("gate <pr-number>","Run pre-merge gates on a pull request and publish the result").option("--dry-run","Print the result instead of publishing a check run").option("--verbose, -v","Enable verbose logging").example("buddy gate 42").action(async(Z,$)=>{let J=$.verbose?O.verbose():O.quiet(),Q=await k($.config);try{let z=Number.parseInt(Z,10);if(Number.isNaN(z))J.error("\u274C Invalid PR number"),V.exit(1);let Y=await d(Q,"running gates",J),{findLinkedIssues:U,runAiGates:X,runGates:G,gateIcon:j,summarizeGates:H}=await import("../chunk-hdqmcp3n.js"),{parseManifest:q}=await import("../chunk-tq1w2wwa.js"),F=(await Y.getPullRequests("open")).find((P)=>P.number===z);if(!F)J.error(`\u274C Pull request #${z} is not open`),V.exit(1);let W=Q.gates??{},T=q(F.body),{manifestUpdates:A}=await import("../chunk-tq1w2wwa.js"),I=T?await Promise.all(A(T).map(async(P)=>{let _={name:P.name,version:P.newVersion};if(W.dependencyGate?.blockEol===!1)return _;if(T.updates.find((k1)=>k1.name===P.name)?.dependencyType!=="docker-image")return _;let{checkEol:s,describeEol:p}=await import("../chunk-61gfjcqt.js"),Y1=await s(P.name,P.newVersion,{logger:J}),t=p(Y1);return Y1?.eol&&t?{..._,eol:t}:_})):[],M=G({title:F.title,body:F.body,manifest:T,dependencies:I},{...W.titleFormat?{titleFormat:W.titleFormat}:{},...W.description?{description:W.description}:{},...W.dependencyGate?{dependencyGate:W.dependencyGate}:{}}),L=U(F.body??""),E=L.length>0?await Y.getIssues("all"):[],B=L.map((P)=>E.find((_)=>_.number===P)).filter((P)=>Boolean(P)).map((P)=>({number:P.number,title:P.title,body:P.body})),{createAiClient:N}=await import("../chunk-2145m12g.js"),b=await X(N(Q,J),{title:F.title,body:F.body,diff:await Y.getPullRequestDiff(z),linkedIssues:B},{...W.linkedIssue?{linkedIssue:W.linkedIssue}:{},...W.custom?{custom:W.custom}:{}},J),R=[...M,...b],h=H(R);for(let P of R)J.info(`${j(P)} ${P.name}: ${P.summary}`);let v=h.conclusion==="failure";if(v)await g(Q.notifications,"gate.failed",{number:z,checks:R.filter((P)=>!P.passed).map((P)=>P.name)});if($.dryRun||!Q1(Y,"checkRuns","createCheckRun")){if(J.info(h.summary),v)V.exit(1);return}if(await Y.createCheckRun("buddy/gates",await Y.getPullRequestHeadSha(z),h),v)V.exit(1)}catch(z){J.error("Gate run failed:",z),V.exit(1)}});w.command("post-merge <pr-number>","Run post-merge actions for a merged pull request").option("--verbose, -v","Enable verbose logging").example("buddy post-merge 42").action(async(Z,$)=>{let J=$.verbose?O.verbose():O.quiet(),Q=await k($.config);try{let z=Number.parseInt(Z,10),Y=await d(Q,"post-merge actions",J),X=(await Y.getPullRequests("all")).find((H)=>H.number===z);if(!X)J.error(`\u274C Pull request #${z} not found`),V.exit(1);if(X.state!=="merged"){J.info(`\u2139\uFE0F PR #${z} was closed without merging; nothing to do`);return}let{runPostMerge:G}=await import("../chunk-hdqmcp3n.js"),j=await G(Y,X,Q.gates?.postMerge??{},{baseBranch:Q.repository?.baseBranch??X.base,logger:J,refreshDashboard:async()=>{if(Q.dashboard?.enabled===!1)throw Error("dashboard.enabled is false");await new m(Q).createOrUpdateDashboard()}});for(let H of j.performed)J.success(`\u2705 ${H}`);for(let H of j.skipped)J.info(`\u23ED\uFE0F ${H.action}: ${H.reason}`)}catch(z){J.error("Post-merge actions failed:",z),V.exit(1)}});w.command("report","Generate a dependency-health and activity report").option("--period <window>","Reporting window: 7d|30d|90d",{default:"30d"}).option("--format <name>","Output format: markdown|json",{default:"markdown"}).option("--prompt <focus>","Focus for the AI narrative, when a provider is configured").option("--publish","Publish to the repository's report issue").option("--scheduled","This is the workflow's scheduled run; honour reports.enabled").option("--verbose, -v","Enable verbose logging").example("buddy report --period 7d").example('buddy report --prompt "focus on security posture" --publish').action(async(Z)=>{let $=Z.format==="json",J=Z.verbose?O.verbose():$?O.silent():O.quiet(),Q=await k(Z.config);try{let{appendHistory:z,computeDeltas:Y,computeMetrics:U,findPrevious:X,HISTORY_PATH:G,loadHistory:j,REPORT_MARKER:H,REPORT_PERIODS:q,renderReport:K,withNarrative:F}=await import("../chunk-wd8w0vjs.js"),W=Z.period??Q.reports?.period??"30d";if(!q.includes(W))J.error(`\u274C Unknown period '${W}'. Expected one of ${q.join(", ")}.`),V.exit(1);let T=await d(Q,"reporting",J),A=new m(Q,V.cwd()),{PackageScanner:I}=await import("../chunk-3xbx315d.js"),M=new I(V.cwd(),J,Q.packages?.ignorePaths),[L,E,B]=await Promise.all([A.scanForUpdates(),T.getPullRequests("all"),M.scanProject()]),{ecosystemOf:N}=await import("../chunk-1aee33aa.js"),b={};for(let X1 of B)for(let j1 of X1.dependencies){let v1=N({name:j1.name,currentVersion:j1.currentVersion,newVersion:j1.currentVersion,updateType:"patch",dependencyType:j1.type,file:X1.path});b[v1]=(b[v1]??0)+1}let{DeprecatedDependenciesChecker:R}=await import("../chunk-ea6rtyvy.js"),h=await new R().checkDeprecatedDependencies(B).catch(()=>[]),v=U({period:W,now:new Date,pullRequests:E,updates:L.updates,dependenciesByEcosystem:b,deprecated:h.length}),P=Q.repository?.baseBranch||"main",_=await j(T,P,J),i=Y(v,X(_,W));if(Z.format==="json"){V.stdout.write(`${JSON.stringify({metrics:v,deltas:i},null,2)}
|
|
173
|
+
`);return}let{createAiClient:s}=await import("../chunk-2145m12g.js"),p=await F(K(v,i),v,s(Q,J),Z.prompt??Q.reports?.prompt,J),{shouldPublishReport:Y1}=await import("../chunk-wd8w0vjs.js"),t=Y1({scheduled:Boolean(Z.scheduled),enabled:Q.reports?.enabled});if(Z.publish&&!t.publish){J.info(`\u2139\uFE0F Not publishing: ${t.reason}`);return}if(!Z.publish){V.stdout.write(`${p}
|
|
174
|
+
`);return}let b1=(await T.getIssues("open")).find((X1)=>X1.body.includes(H)),h1=Q.reports?.title??"Dependency Report",y1=Q.reports?.labels??["dependencies","report"],w0=b1?await T.updateIssue(b1.number,{title:h1,body:p,labels:y1}):await T.createIssue({title:h1,body:p,labels:y1});J.success(`\u2705 Report published: ${w0.url}`),await T.commitChanges(P,"chore(reports): record dependency metrics snapshot",[{path:G,content:z(_,v),type:_.length>0?"update":"create"}],P)}catch(z){J.error("Report failed:",z),V.exit(1)}});w.command("doctor","Diagnose this environment: credentials, git state and analyzer tooling").option("--verbose, -v","Enable verbose logging").example("buddy doctor").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await k(Z.config).catch((U)=>{return $.warn(`\u26A0\uFE0F Could not load configuration: ${r(U)}`),{}}),{diagnose:Q,renderDoctorReport:z}=await import("../chunk-pksrcdh6.js"),Y=await Q(J);if(V.stdout.write(z(Y)),!Y.healthy)V.exit(1)});w.command("run","Run a prompt headlessly, with optional schema-validated output").option("--prompt <text>","The prompt to run").option("--prompt-file <path>","Read the prompt from a file").option("--output-schema <json>","JSON Schema the output must satisfy").option("--output-schema-file <path>","Read the schema from a file").option("--model <name>","Model override").option("--retries <n>","Schema retries before failing",{default:"2"}).option("--verbose, -v","Enable verbose logging").example(`buddy run --prompt "Summarize this week's dependency updates"`).example(`buddy run --prompt-file p.txt --output-schema '{"type":"object"}'`).action(async(Z)=>{let $=Z.verbose?O.verbose():O.silent(),J=await k(Z.config);try{let Q=Z.promptFile?await Bun.file(Z.promptFile).text():Z.prompt;if(!Q?.trim())V.stderr.write(`\u274C Provide --prompt or --prompt-file
|
|
175
175
|
`),V.exit(1);let z=Z.outputSchemaFile?await Bun.file(Z.outputSchemaFile).text():Z.outputSchema,Y;if(z)try{Y=JSON.parse(z)}catch(F){V.stderr.write(`\u274C --output-schema is not valid JSON: ${r(F)}
|
|
176
|
-
`),V.exit(1)}let{createAiClient:U}=await import("../chunk-
|
|
177
|
-
`),V.exit(1);let{publishOutput:G,runHeadless:
|
|
176
|
+
`),V.exit(1)}let{createAiClient:U}=await import("../chunk-2145m12g.js"),X=U(Z.model?{...J,ai:{...J.ai,model:Z.model}}:J,$);if(!X)V.stderr.write(`\u274C No AI provider configured. See https://buddy.sh/ai/providers
|
|
177
|
+
`),V.exit(1);let{publishOutput:G,runHeadless:j}=await import("../chunk-w93akf6h.js"),H=await j({prompt:Q,ai:X,...Y?{schema:Y}:{},maxRetries:Number.parseInt(Z.retries??"2",10),logger:$});if(!H.valid)V.stderr.write(`\u274C Output did not satisfy the schema after ${H.attempts} attempt(s):
|
|
178
178
|
${H.error}
|
|
179
179
|
`),V.exit(1);let q=await G(H.result,V.env.GITHUB_OUTPUT),K=typeof H.result==="string"?H.result:JSON.stringify(H.result,null,2);if(V.stdout.write(`${K}
|
|
180
180
|
`),q)$.info("\uD83D\uDCE4 Wrote `result` to $GITHUB_OUTPUT")}catch(Q){V.stderr.write(`\u274C ${r(Q)}
|