@buddysh/buddy 0.11.5 → 0.11.7
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 +29 -0
- package/dist/bin/cli.js +19 -19
- package/dist/chunk-03j2dx5h.js +4 -0
- package/dist/chunk-06k6abjj.js +2 -0
- package/dist/{chunk-mkzmjg3f.js → chunk-0ewzxzt3.js} +2 -2
- package/dist/chunk-19n3wnxq.js +106 -0
- package/dist/{chunk-f53y8ans.js → chunk-1n42ghef.js} +2 -2
- package/dist/chunk-1q6s6a5e.js +2 -0
- package/dist/{chunk-s4zb0fcj.js → chunk-1szfwcst.js} +1 -1
- package/dist/{chunk-tzwnfagh.js → chunk-1z4nhstx.js} +2 -2
- package/dist/{chunk-hd5j9e3c.js → chunk-1z9a3hpe.js} +1 -1
- package/dist/chunk-23c6tfbw.js +2 -0
- package/dist/{chunk-v1wfa758.js → chunk-2egzc1fp.js} +1 -1
- package/dist/chunk-2ppt1rrx.js +2 -0
- package/dist/chunk-2pv5zwbm.js +38 -0
- package/dist/{chunk-wn6pbyzn.js → chunk-305184z3.js} +1 -1
- package/dist/{chunk-9t15md0g.js → chunk-39ne6m3w.js} +1 -1
- package/dist/{chunk-tjc2vgwn.js → chunk-3d3rwmmj.js} +1 -1
- package/dist/{chunk-5044y9en.js → chunk-3d5pjrz7.js} +2 -2
- package/dist/chunk-3jw9d546.js +2 -0
- package/dist/{chunk-be629jhq.js → chunk-3wy8fypy.js} +2 -2
- package/dist/{chunk-c3es7pgf.js → chunk-3z759ya5.js} +1 -1
- package/dist/{chunk-aa277p5r.js → chunk-3zk2ye6r.js} +1 -1
- package/dist/{chunk-3fzbvs2p.js → chunk-4b0p7kgk.js} +1 -1
- package/dist/chunk-4d13qb9f.js +2 -0
- package/dist/{chunk-rc2mk5x6.js → chunk-4gx2f1k6.js} +1 -1
- package/dist/{chunk-96ht6hwd.js → chunk-4mwgk0jh.js} +2 -2
- package/dist/{chunk-1qgr52wx.js → chunk-4rvgatmm.js} +1 -1
- package/dist/{chunk-vbeeyhhe.js → chunk-4wh0wryv.js} +2 -2
- package/dist/{chunk-fjp3a7hp.js → chunk-4ycesykg.js} +1 -1
- package/dist/chunk-52jcty4n.js +2 -0
- package/dist/{chunk-tw047td6.js → chunk-55znd3yn.js} +1 -1
- package/dist/chunk-5ct11b1j.js +2 -0
- package/dist/{chunk-3cvng2nz.js → chunk-5gybfx14.js} +1 -1
- package/dist/chunk-5zs6jrpt.js +2 -0
- package/dist/{chunk-8hjvthz4.js → chunk-675c6ddc.js} +2 -2
- package/dist/{chunk-193abzy6.js → chunk-6k6dgwmy.js} +1 -1
- package/dist/{chunk-q4t568hv.js → chunk-6sm15trq.js} +1 -1
- package/dist/chunk-6t1rb4tz.js +2 -0
- package/dist/{chunk-g30dr44w.js → chunk-7wk4px2k.js} +2 -2
- package/dist/{chunk-2et8yavs.js → chunk-88j356ng.js} +1 -1
- package/dist/{chunk-pkr6905p.js → chunk-89s9f3mf.js} +1 -1
- package/dist/{chunk-05me15qw.js → chunk-97cvp0t3.js} +1 -1
- package/dist/{chunk-0w695m54.js → chunk-9b2yfhzj.js} +1 -1
- package/dist/{chunk-dm5yktev.js → chunk-9b4z1bpx.js} +1 -1
- package/dist/{chunk-3pqra420.js → chunk-a1fkxmxq.js} +1 -1
- package/dist/chunk-a4m6bqpq.js +2 -0
- package/dist/{chunk-vgtmrd4c.js → chunk-bggpgbdx.js} +1 -1
- package/dist/{chunk-jnb80k2x.js → chunk-c87s8txp.js} +1 -1
- package/dist/{chunk-s6z3gm2s.js → chunk-cbqg29zr.js} +1 -1
- package/dist/{chunk-r763e19p.js → chunk-d2d5m2kx.js} +3 -3
- package/dist/{chunk-e68nf7cm.js → chunk-ddmvjp0y.js} +1 -1
- package/dist/chunk-djdf848n.js +2 -0
- package/dist/chunk-dsep28r5.js +2 -0
- package/dist/chunk-e6sg7jg4.js +2 -0
- package/dist/{chunk-bffxf4xy.js → chunk-efqnnrwq.js} +1 -1
- package/dist/{chunk-ctt9xk2j.js → chunk-eftyxrxw.js} +2 -2
- package/dist/chunk-eme4fny7.js +2 -0
- package/dist/{chunk-1cpdz49v.js → chunk-emygmh7r.js} +1 -1
- package/dist/{chunk-0hc97k0t.js → chunk-f001yg2a.js} +3 -3
- package/dist/{chunk-hfjywbbc.js → chunk-f0z6kyqt.js} +1 -1
- package/dist/chunk-f298fv6p.js +2 -0
- package/dist/chunk-fjp4k18r.js +2 -0
- package/dist/{chunk-jtxcr5yw.js → chunk-fvhnza91.js} +2 -2
- package/dist/{chunk-3901s7h9.js → chunk-gvnsr72j.js} +1 -1
- package/dist/{chunk-zgkrhymn.js → chunk-gw3t78fw.js} +1 -1
- package/dist/chunk-h4084ykd.js +2 -0
- package/dist/{chunk-cwfkm7h9.js → chunk-he97rsmj.js} +2 -2
- package/dist/{chunk-k26wnmzk.js → chunk-hkb714k3.js} +1 -1
- package/dist/{chunk-nrr8z2z7.js → chunk-j0bsva07.js} +2 -2
- package/dist/{chunk-eseshkd0.js → chunk-ja3rvd6y.js} +1 -1
- package/dist/chunk-jczf4z85.js +2 -0
- package/dist/{chunk-08x5b93v.js → chunk-jpdd59fh.js} +1 -1
- package/dist/{chunk-cgvt98pd.js → chunk-kpqez1ht.js} +1 -1
- package/dist/{chunk-qd2s51gc.js → chunk-ktmgq0ja.js} +1 -1
- package/dist/{chunk-0scz1dv5.js → chunk-m17kvr7m.js} +1 -1
- package/dist/chunk-m2qq154g.js +2 -0
- package/dist/chunk-m8kqe55k.js +2 -0
- package/dist/chunk-n42c80f3.js +2 -0
- package/dist/{chunk-428c5652.js → chunk-na0b9r57.js} +1 -1
- package/dist/chunk-nfcyqj66.js +2 -0
- package/dist/{chunk-sw2538r0.js → chunk-nhe8axrf.js} +2 -2
- package/dist/{chunk-g24hav8e.js → chunk-njfbmhm4.js} +7 -7
- package/dist/{chunk-p6qbqsyp.js → chunk-p8azbpq6.js} +2 -2
- package/dist/{chunk-yngahb11.js → chunk-p96zq2zc.js} +2 -2
- package/dist/chunk-pvfavmy3.js +2 -0
- package/dist/{chunk-25sz1y7j.js → chunk-q0tve4cm.js} +1 -1
- package/dist/{chunk-hptfq3rg.js → chunk-q5pxt13t.js} +1 -1
- package/dist/{chunk-61xecp1z.js → chunk-qczzpthf.js} +1 -1
- package/dist/{chunk-5x4gt4c5.js → chunk-qk43d3vv.js} +1 -1
- package/dist/{chunk-kbbqs8ae.js → chunk-qv1nvaha.js} +1 -1
- package/dist/{chunk-pskqrv5r.js → chunk-qz5nqeza.js} +1 -1
- package/dist/chunk-rfgacg5h.js +2 -0
- package/dist/{chunk-phfmnnne.js → chunk-sczx20gw.js} +2 -2
- package/dist/chunk-sf4p2t84.js +2 -0
- package/dist/chunk-sjk83y3d.js +2 -0
- package/dist/{chunk-11hdrnf6.js → chunk-srznv36n.js} +2 -2
- package/dist/chunk-t0kvt1pm.js +2 -0
- package/dist/{chunk-9fq7drn8.js → chunk-t3a1703q.js} +1 -1
- package/dist/{chunk-8gd76j8e.js → chunk-tgh61e5e.js} +2 -2
- package/dist/{chunk-b9escac0.js → chunk-v6dephze.js} +2 -2
- package/dist/{chunk-rz7pg7pb.js → chunk-v8746363.js} +3 -3
- package/dist/{chunk-c8rzx3a1.js → chunk-vckn5ate.js} +1 -1
- package/dist/{chunk-6p4qz8qv.js → chunk-w16pwfh3.js} +1 -1
- package/dist/{chunk-kprtsn8c.js → chunk-wcjf072v.js} +1 -1
- package/dist/chunk-wfn702a2.js +2 -0
- package/dist/{chunk-40znfg3x.js → chunk-wr1q4k9e.js} +1 -1
- package/dist/{chunk-m4p7cnvk.js → chunk-wts1sqw7.js} +1 -1
- package/dist/{chunk-txtrpypt.js → chunk-x4ea69ek.js} +2 -2
- package/dist/{chunk-ds4stft2.js → chunk-xe2xdg6z.js} +1 -1
- package/dist/{chunk-xs12dtf1.js → chunk-xny4kgcc.js} +1 -1
- package/dist/chunk-xpsetmcw.js +2 -0
- package/dist/{chunk-hmskwy76.js → chunk-xzhzvdcv.js} +1 -1
- package/dist/chunk-yd834q68.js +2 -0
- package/dist/{chunk-68fw3ma0.js → chunk-yke7v3gh.js} +1 -1
- package/dist/chunk-ymwjjyke.js +2 -0
- package/dist/{chunk-hsa07n7c.js → chunk-ysp81zyt.js} +1 -1
- package/dist/{chunk-vqa6vte3.js → chunk-z456ptfw.js} +1 -1
- package/dist/{chunk-yp1tgdh3.js → chunk-zkv7e2q2.js} +1 -1
- package/dist/chunk-ztw515ew.js +3 -0
- package/dist/src/git/github-provider.d.ts +20 -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/types.d.ts +1 -0
- package/dist/src/utils/github-actions-parser.d.ts +10 -0
- package/dist/src/utils/lock-file.d.ts +16 -0
- package/package.json +1 -1
- package/dist/chunk-0paakbpj.js +0 -2
- package/dist/chunk-19zyq15p.js +0 -2
- package/dist/chunk-24c2ab29.js +0 -2
- package/dist/chunk-2wj5xtdn.js +0 -2
- package/dist/chunk-3cab6vqx.js +0 -106
- package/dist/chunk-49znmbh8.js +0 -2
- package/dist/chunk-4sfyfxdk.js +0 -2
- package/dist/chunk-4yq2fny9.js +0 -2
- package/dist/chunk-5gejc3rx.js +0 -2
- package/dist/chunk-5xfs8a89.js +0 -2
- package/dist/chunk-8ycrg9gp.js +0 -3
- package/dist/chunk-90zmqn5k.js +0 -2
- package/dist/chunk-97qf7mdt.js +0 -2
- package/dist/chunk-a4hzzn28.js +0 -2
- package/dist/chunk-b357cgb0.js +0 -2
- package/dist/chunk-baq6x78h.js +0 -2
- package/dist/chunk-brfyymhf.js +0 -2
- package/dist/chunk-dgfb8k0h.js +0 -2
- package/dist/chunk-emyvrx5t.js +0 -2
- package/dist/chunk-fpnjpgrb.js +0 -2
- package/dist/chunk-fr5c326k.js +0 -2
- package/dist/chunk-gkpd5nw2.js +0 -2
- package/dist/chunk-hns85dqw.js +0 -2
- package/dist/chunk-j9cgwkm8.js +0 -38
- package/dist/chunk-jfzqpmnp.js +0 -2
- package/dist/chunk-mcwxpdg9.js +0 -2
- package/dist/chunk-mf959vjt.js +0 -2
- package/dist/chunk-ppmabn5h.js +0 -2
- package/dist/chunk-sc7emb71.js +0 -2
- package/dist/chunk-vdd1cghr.js +0 -2
- package/dist/chunk-vj1sdxpp.js +0 -2
- package/dist/chunk-xznnmhyt.js +0 -2
- package/dist/chunk-yk183r6z.js +0 -2
- package/dist/chunk-ys1qqcpp.js +0 -2
- package/dist/chunk-ytmxd5fk.js +0 -4
- package/dist/chunk-zxgkp71x.js +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
[Compare changes](https://github.com/stacksjs/buddy/compare/v0.11.6...v0.11.7)
|
|
4
|
+
|
|
5
|
+
## 🐛 Bug Fixes
|
|
6
|
+
|
|
7
|
+
- **git**: push with BUDDY_TOKEN for real, so refreshed PRs re-run CI ([17486c6](https://github.com/stacksjs/buddy/commit/17486c6)) _(by Chris <chrisbreuer93@gmail.com>)_ ([#2848](https://github.com/stacksjs/buddy/issues/2848))
|
|
8
|
+
|
|
9
|
+
## 🔧 Chores
|
|
10
|
+
|
|
11
|
+
- release v0.11.7 ([77c2bd1](https://github.com/stacksjs/buddy/commit/77c2bd1)) _(by Chris <chrisbreuer93@gmail.com>)_
|
|
12
|
+
|
|
13
|
+
## Contributors
|
|
14
|
+
|
|
15
|
+
- _Chris <chrisbreuer93@gmail.com>_
|
|
16
|
+
|
|
17
|
+
[Compare changes](https://github.com/stacksjs/buddy/compare/v0.11.5...v0.11.6)
|
|
18
|
+
|
|
19
|
+
## 🐛 Bug Fixes
|
|
20
|
+
|
|
21
|
+
- **pr**: stop failing runs on refused workflow pushes, and refresh stale PRs ([4fa72de](https://github.com/stacksjs/buddy/commit/4fa72de)) _(by Chris <chrisbreuer93@gmail.com>)_ ([#2848](https://github.com/stacksjs/buddy/issues/2848), [#1359](https://github.com/stacksjs/buddy/issues/1359))
|
|
22
|
+
- **actions**: compare a SHA pin by its version comment, and keep it pinned ([00953f3](https://github.com/stacksjs/buddy/commit/00953f3)) _(by Chris <chrisbreuer93@gmail.com>)_ ([#1458](https://github.com/stacksjs/buddy/issues/1458))
|
|
23
|
+
|
|
24
|
+
## 🔧 Chores
|
|
25
|
+
|
|
26
|
+
- release v0.11.6 ([4bb4a6c](https://github.com/stacksjs/buddy/commit/4bb4a6c)) _(by Chris <chrisbreuer93@gmail.com>)_
|
|
27
|
+
|
|
28
|
+
## Contributors
|
|
29
|
+
|
|
30
|
+
- _Chris <chrisbreuer93@gmail.com>_
|
|
31
|
+
|
|
3
32
|
[Compare changes](https://github.com/stacksjs/buddy/compare/v0.11.4...v0.11.5)
|
|
4
33
|
|
|
5
34
|
## 🐛 Bug Fixes
|
package/dist/bin/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{
|
|
3
|
+
import{Uc as C1}from"../chunk-tgh61e5e.js";import"../chunk-eftyxrxw.js";import{dd as f}from"../chunk-19n3wnxq.js";import"../chunk-sczx20gw.js";import"../chunk-d2d5m2kx.js";import"../chunk-3wy8fypy.js";import"../chunk-89s9f3mf.js";import"../chunk-ja3rvd6y.js";import"../chunk-srznv36n.js";import{td as g}from"../chunk-he97rsmj.js";import"../chunk-0ewzxzt3.js";import{Dd as R1,Ld as Q0}from"../chunk-bggpgbdx.js";import"../chunk-j0bsva07.js";import"../chunk-xny4kgcc.js";import{pe as J0,qe as Q1,re as z1}from"../chunk-1z4nhstx.js";import"../chunk-x4ea69ek.js";import"../chunk-03j2dx5h.js";import"../chunk-v6dephze.js";import"../chunk-7wk4px2k.js";import"../chunk-88j356ng.js";import"../chunk-675c6ddc.js";import"../chunk-p96zq2zc.js";import"../chunk-jpdd59fh.js";import"../chunk-p8azbpq6.js";import"../chunk-emygmh7r.js";import"../chunk-kpqez1ht.js";import"../chunk-vckn5ate.js";import"../chunk-f001yg2a.js";import{sg as Z0,wg as $0}from"../chunk-gvnsr72j.js";import"../chunk-fvhnza91.js";import"../chunk-ktmgq0ja.js";import{$g as z0,_g as CZ,ah as Y0,bh as X0,ch as j0,dh as G0,eh as _,fh as h,hh as K0,ih as q0,jh as H0,kh as U0,lh as V0,oh as W0,ph as F0,qh as M0,rh as D0,sh as W1,th as O0,uh as L0}from"../chunk-4wh0wryv.js";import"../chunk-hkb714k3.js";import"../chunk-6k6dgwmy.js";import"../chunk-ddmvjp0y.js";import{Kh as r,Lh as O}from"../chunk-f0z6kyqt.js";import"../chunk-njfbmhm4.js";import{al as RZ,cl as D}from"../chunk-6sm15trq.js";import o1 from"fs";import V from"process";import{EventEmitter as w0}from"events";import c from"process";import v1 from"process";import T1 from"process";import q1 from"process";import Z1 from"process";import m1 from"tty";import GZ,{stdin as nZ,stdout as iZ}from"process";import u1,{stdin as HZ,stdout as UZ}from"process";import VZ from"readline";import{existsSync as IZ}from"fs";import D1 from"fs/promises";import c1 from"os";import O1 from"path";import n from"process";function L1(Z){return Z.replace(/[<[].+/,"").trim()}function E0(Z){let $=/<([^>]+)>/g,J=/\[([^\]]+)\]/g,Q=[],z=(j)=>{let G=!1,X=j[1];if(X.startsWith("..."))X=X.slice(3),G=!0;else if(X.endsWith("..."))X=X.slice(0,-3),G=!0;return{required:j[0].startsWith("<"),value:X.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((j)=>Q.names.includes(j))&&typeof Y.required==="boolean"}))$.boolean.push(Q.names[0])}else $.boolean.push(Q.names[0])}return $}function _1(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 I0(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 P0(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 N0(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
6
|
${this.stack}`;return this.message}}function A0(Z){if(Z instanceof J1)return!0;return!!Z&&typeof Z==="object"&&Z.name==="ClappError"&&typeof Z.message==="string"}function x0(){let{env:Z}=v1,{TERM:$,TERM_PROGRAM:J}=Z;if(v1.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",C=`${V1}[`;var u={to(Z,$){if(!$)return`${C}${Z+1}G`;return`${C}${$+1};${Z+1}H`},move(Z,$){let J="";if(Z<0)J+=`${C}${-Z}D`;else if(Z>0)J+=`${C}${Z}C`;if($<0)J+=`${C}${-$}A`;else if($>0)J+=`${C}${$}B`;return J},up:(Z=1)=>`${C}${Z}A`,down:(Z=1)=>`${C}${Z}B`,forward:(Z=1)=>`${C}${Z}C`,backward:(Z=1)=>`${C}${Z}D`,nextLine:(Z=1)=>`${C}E`.repeat(Z),prevLine:(Z=1)=>`${C}F`.repeat(Z),left:`${C}G`,hide:`${C}?25l`,show:`${C}?25h`,save:`${V1}7`,restore:`${V1}8`};var M1={screen:`${C}2J`,up:(Z=1)=>`${C}1J`.repeat(Z),down:(Z=1)=>`${C}J`.repeat(Z),line:`${C}2K`,lineEnd:`${C}K`,lineStart:`${C}1K`,lines(Z){let $="";for(let J=0;J<Z;J++)$+=this.line+(J<Z-1?u.up():"");if(Z)$+=u.left;return $}},fZ={screen:`${V1}c`};function R0(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 l1(Z,$,J=2,Q=3){return $.map((z)=>({cmd:z,distance:R0(Z,z)})).filter(({distance:z})=>z<=J).sort((z,Y)=>z.distance-Y.distance).slice(0,Q).map(({cmd:z})=>z)}function C0(Z,$={}){let J={_:[]},Q=$.alias||{},z=new Set($.boolean||[]),Y={};for(let G of Object.keys(Q))for(let X of Q[G])Y[X]=G;for(let G of z)if(Q[G])for(let X of Q[G])z.add(X);function U(G,X){if(G===void 0)return X;if(typeof X==="boolean")return X;return Array.isArray(G)?[...G,X]:[G,X]}function j(G,X){let H=Y[G]||G,q=U(J[H],X);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 X=Z[G];if(X==="--"){J._.push(...Z.slice(G+1));break}if(X.startsWith("--")){let H=X.indexOf("=");if(H!==-1){let q=K1(X.slice(2,H)),K=X.slice(H+1);j(q,K)}else{let q=X.slice(2);if(q.startsWith("no-")){let W=K1(q.slice(3));j(W,!1);continue}let K=K1(q),F=Y[K]||K;if(z.has(F)||z.has(K))j(K,!0);else{let W=Z[G+1];if(W!==void 0&&!W.startsWith("-"))j(K,W),G++;else j(K,!0)}}}else if(X.startsWith("-")&&X.length>1){let H=X.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("-"))j(K,W),G++;else j(K,!0)}else j(K,!0)}}else J._.push(X)}return J}class p1{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 dZ=T1.argv,S0=`${T1.platform}-${T1.arch} bun-v${typeof Bun<"u"?Bun.version:"unknown"}`,f1=q1.argv,k0=`${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=E0(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 p1(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 X=_1($.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,X.length)} ${W.description}`}).join(`
|
|
@@ -38,9 +38,9 @@ Run \`${this.name??"cli"} --help\` for usage.`;c.stderr.write(`${J}${$}${Q}
|
|
|
38
38
|
`).length-1;this.output.write(u.move(-999,Z*-1))}render(){let Z=g1(this._render(this)??"",u1.stdout.columns,{hard:!0,trim:!1});if(Z===this._prevFrame)return;if(this.state==="initial")this.output.write(u.hide);else{let $=qZ(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 MZ(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 DZ(Z,$){return($.label??String($.value)).toLowerCase().includes(Z.toLowerCase())}function OZ(Z,$){if(!$)return;if(Z)return $;return $[0]}class LZ extends I1{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??DZ;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=OZ(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=MZ(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 TZ extends I1{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 wZ=x0();var x=(Z,$)=>wZ?Z:$,tZ=x("\u25C6","*"),oZ=x("\u25A0","x"),eZ=x("\u25B2","x"),Z$=x("\u25C7","o"),$$=x("\u250C","T"),EZ=x("\u2502","|"),J$=x("\u2514","\u2014"),Q$=x("\u25CF",">"),z$=x("\u25CB"," "),Y$=x("\u25FB","[\u2022]"),X$=x("\u25FC","[+]"),j$=x("\u25FB","[ ]"),G$=x("\u25AA","\u2022"),K$=x("\u2500","-"),q$=x("\u256E","+"),H$=x("\u251C","+"),U$=x("\u256F","+"),V$=x("\u25CF","\u2022"),W$=x("\u25C6","*"),F$=x("\u25B2","!"),M$=x("\u25A0","x");var D$={light:x("\u2500","-"),heavy:x("\u2501","="),block:x("\u2588","#")};function BZ(){return`${H1.gray(EZ)} `}var O$=BZ();class r1{configPath;config=null;events=[];retryCount=0;maxRetries=3;retryDelayMs=1000;constructor(){let Z=c1.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:c1.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(IZ(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 I$=new r1;var a=RZ(CZ(),1);var P1="0.11.
|
|
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 MZ(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 DZ(Z,$){return($.label??String($.value)).toLowerCase().includes(Z.toLowerCase())}function OZ(Z,$){if(!$)return;if(Z)return $;return $[0]}class LZ extends I1{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??DZ;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=OZ(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=MZ(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 TZ extends I1{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 wZ=x0();var x=(Z,$)=>wZ?Z:$,tZ=x("\u25C6","*"),oZ=x("\u25A0","x"),eZ=x("\u25B2","x"),Z$=x("\u25C7","o"),$$=x("\u250C","T"),EZ=x("\u2502","|"),J$=x("\u2514","\u2014"),Q$=x("\u25CF",">"),z$=x("\u25CB"," "),Y$=x("\u25FB","[\u2022]"),X$=x("\u25FC","[+]"),j$=x("\u25FB","[ ]"),G$=x("\u25AA","\u2022"),K$=x("\u2500","-"),q$=x("\u256E","+"),H$=x("\u251C","+"),U$=x("\u256F","+"),V$=x("\u25CF","\u2022"),W$=x("\u25C6","*"),F$=x("\u25B2","!"),M$=x("\u25A0","x");var D$={light:x("\u2500","-"),heavy:x("\u2501","="),block:x("\u2588","#")};function BZ(){return`${H1.gray(EZ)} `}var O$=BZ();class r1{configPath;config=null;events=[];retryCount=0;maxRetries=3;retryDelayMs=1000;constructor(){let Z=c1.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:c1.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(IZ(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 I$=new r1;var a=RZ(CZ(),1);var P1="0.11.7";var N1=String.raw`^\s*-\s*\[[xX]\]\s*`,NZ=new RegExp(`${N1}<!--\\s*rebase-branch=([^>]*?)\\s*-->`,"gm"),AZ=new RegExp(`${N1}<!--\\s*rebase-all-open-prs\\s*-->`,"m"),xZ=new RegExp(`${N1}<!--\\s*manual job\\s*-->`,"m");function s1(Z){if(!Z)return{rebaseBranches:[],rebaseAll:!1,manualRun:!1};let $=[];for(let J of Z.matchAll(NZ)){let Q=J[1].trim();if(Q&&!$.includes(Q))$.push(Q)}return{rebaseBranches:$,rebaseAll:AZ.test(Z),manualRun:xZ.test(Z)}}function A1(Z){return Z.rebaseBranches.length>0||Z.rebaseAll||Z.manualRun}function t1(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 S(Z){if(Z)return await C1(Z);if(!x1)x1=await C1();return x1}async function m(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 J0({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 e1(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 j=z.get(U.path);if(j)j.push(U);else z.set(U.path,[U])}let Y=0;for(let[U,j]of z){let G=Bun.file(U);if(!await G.exists()){J.warn(`\u26A0\uFE0F Skipping ${U}: not in the working tree`);continue}let X=await G.text();for(let H of[...j].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=Q0(X,H.line,H.suggestion);if(q===null){J.warn(`\u26A0\uFE0F Skipping ${U}:${H.line}: the file changed since the review`);continue}X=q,Y++}await Bun.write(U,X)}return Y}async function SZ(Z,$){try{let{PackageScanner:J}=await import("../chunk-
|
|
43
|
+
Apply?`,initial:!1})).apply)continue}let q=Q0(X,H.line,H.suggestion);if(q===null){J.warn(`\u26A0\uFE0F Skipping ${U}:${H.line}: the file changed since the review`);continue}X=q,Y++}await Bun.write(U,X)}return Y}async function SZ(Z,$){try{let{PackageScanner:J}=await import("../chunk-6t1rb4tz.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 B1("buddy");w.usage(`[command] [options]
|
|
44
44
|
|
|
45
45
|
\uD83D\uDC36 Buddy - AI code review and dependency updates, in one teammate
|
|
46
46
|
|
|
@@ -138,24 +138,24 @@ Scan Results:`),$.info(`\uD83D\uDCE6 Total packages: ${j.totalPackages}`),$.info
|
|
|
138
138
|
\uD83D\uDEA8 Major updates (${G.length}):`);for(let q of G)$.info(` ${q.name}: ${q.currentVersion} \u2192 ${q.newVersion}`)}if(X.length>0){$.info(`
|
|
139
139
|
\u2728 Minor updates (${X.length}):`);for(let q of X)$.info(` ${q.name}: ${q.currentVersion} \u2192 ${q.newVersion}`)}if(H.length>0){$.info(`
|
|
140
140
|
\uD83D\uDD27 Patch updates (${H.length}):`);for(let q of H)$.info(` ${q.name}: ${q.currentVersion} \u2192 ${q.newVersion}`)}if(j.groups.length>0){$.info(`
|
|
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-xznnmhyt.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-
|
|
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-nfcyqj66.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-nfcyqj66.js");await new q(J).checkAndCloseObsoletePRs(Q,!!Z.dryRun)}catch(q){$.error("\u26A0\uFE0F Could not check for obsolete PRs:",q)}let X=0;try{if(X=(await new f(J).mergeEligiblePullRequests(!!Z.dryRun)).length,X>0)$.success(`\uD83D\uDD00 ${Z.dryRun?"Would merge":"Merged"} ${X} PR(s)`)}catch(q){$.warn("\u26A0\uFE0F Could not process auto-merge:",q)}$.info(`
|
|
144
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(j>0||X>0||H.deleted.length>0)$.success(`
|
|
145
|
-
\uD83C\uDF89 Update-check complete: ${j} PR(s) rebased, ${X} 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 bZ(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 hZ(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 S(Z.config);try{let Q=await m(J,"this command",$),{runFixCi:z}=await import("../chunk-
|
|
145
|
+
\uD83C\uDF89 Update-check complete: ${j} PR(s) rebased, ${X} 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 bZ(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 hZ(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 S(Z.config);try{let Q=await m(J,"this command",$),{runFixCi:z}=await import("../chunk-t0kvt1pm.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 S(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:j,parseCommand:G}=await import("../chunk-1z9a3hpe.js");if(!j(Y.body)){$.info("\u2139\uFE0F Comment does not mention buddy; nothing to do");return}let X=G(Y.body);if(!X){$.info("\u2139\uFE0F Mention is not a command (quoted or inside code); nothing to do");return}let H=await m(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 \`${X.name}\` from @${q} on #${U.number}`),Z.dryRun){$.info(`\uD83D\uDD0D [DRY RUN] Would run ${X.name} (canWrite: ${F.canWrite})`);return}if(Q1(H,"commentReactions","reactToComment"))await H.reactToComment(Y.id,"eyes");let{createHandlers:T,dispatchCommand:A}=await import("../chunk-1z9a3hpe.js"),{runReviewForPR:B}=await import("../chunk-23c6tfbw.js"),M=await A({command:X,actor:F,number:U.number,isPullRequest:W,commentId:Y.id,logger:$},T({config:J,provider:H,review:async(L,E)=>await B({config:J,provider:H,prNumber:L,logger:$,...E}),rebase:async(L)=>{let{spawn:E}=await import("child_process");return await new Promise((I,N)=>{E("bunx",["@buddysh/buddy","rebase",String(L)],{stdio:"inherit"}).on("close",(k)=>k===0?I():N(Error(`rebase exited ${k}`)))}),"Rebased."},merge:async()=>await new f(J).mergeEligiblePullRequests(!1),fixCi:async(L)=>{let{runFixCi:E}=await import("../chunk-t0kvt1pm.js");return await E({config:J,provider:H,prNumber:L,analysisOnly:!0,logger:$})},plan:async(L,E,I)=>{let{runPlan:N}=await import("../chunk-3z759ya5.js");return await N({config:J,provider:H,number:L,isPullRequest:E,request:I,logger:$})},resolve:async(L)=>{let{resolveBuddyThreads:E}=await import("../chunk-39ne6m3w.js");return await E({provider:H,prNumber:L,logger:$})},remember:async(L,E)=>{let{addLearning:I,createLearning:N,loadLearnings:b,serializeLearnings:k,DEFAULT_LEARNINGS_FILE:d}=await import("../chunk-ysp81zyt.js"),y=J.repository?.baseBranch??"main",P=await b((s,p)=>H.getFileContent(s,p),y,d,$),v=N(L,{source:E.isPullRequest?{pr:E.number}:{issue:E.number}}),i=`buddy/learning-${v.id}`;return await H.commitChanges(i,"chore(buddy): record a learning",[{path:d,content:k(I(P,v)),type:"update"}],y),await H.createPullRequest({title:"chore(buddy): record a learning",body:`Recorded from #${E.number}:
|
|
146
146
|
|
|
147
|
-
> ${L}`,head:i,base:y,draft:!1}),`Noted. I opened a pull request adding it to \`${d}\` 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 \`${X.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 S($.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:j}=await import("../chunk-
|
|
147
|
+
> ${L}`,head:i,base:y,draft:!1}),`Noted. I opened a pull request adding it to \`${d}\` 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 \`${X.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 S($.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:j}=await import("../chunk-ysp81zyt.js"),G=j(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:X,reviewDiff:H}=await import("../chunk-39ne6m3w.js"),{collectLocalDiff:q,formatReview:K,shouldFail:F}=await import("../chunk-52jcty4n.js"),{runAnalyzers:W}=await import("../chunk-sf4p2t84.js");if(Z){let I=await m(Q,"reviewing a pull request",U),{reviewPullRequest:N}=await import("../chunk-23c6tfbw.js"),{status:b,result:k}=await N({config:Q,provider:I,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:k?.findings.length??0}),k&&z!=="pretty")V.stdout.write(K(k,z));if(k&&$.failOn&&F(k.findings,$.failOn))V.exit(1);return}let T;{let I=$.base||Q.repository?.baseBranch||"main",N=$.staged?"staged":$.branch?"branch":"working";U.info(`\uD83D\uDD0D Reviewing ${N} changes${N==="branch"?` against ${I}`:""}...`),T=await q(N,I)}if(!T.trim()){if(!Y)J.success("\u2705 No changes to review");return}let{parseUnifiedDiff:A}=await import("../chunk-na0b9r57.js"),B=A(T).files.map((I)=>I.path),M=Q.analysis?.enabled===!1?{findings:[],ran:[],skipped:[]}:await W({files:B,root:V.cwd(),...Q.analysis?.tools?{enabled:Q.analysis.tools}:{},logger:U});if($.light){let I={summary:`Static analysis of ${B.length} changed file(s).`,walkthrough:[],findings:M.findings,effort:1,omittedFiles:M.skipped.map((N)=>`${N.name} (${N.reason})`)};if(V.stdout.write(K(I,z)),$.fix){let N=await e1(I.findings,Boolean($.yes),J);J.success(`\uD83D\uDD27 Applied ${N} suggestion(s)`)}if($.failOn&&F(I.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:X({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((I)=>`${I.name} (${I.reason})`)]};if(V.stdout.write(K(E,z)),$.fix){let I=await e1(E.findings,Boolean($.yes),J);J.success(`\uD83D\uDD27 Applied ${I} suggestion(s)`)}if($.failOn&&F(E.findings,$.failOn))V.exit(1)}catch(j){J.error("Review failed:",j),await g(Q.notifications,"run.failed",{command:"review",error:j instanceof Error?j.message:String(j)}),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 S($.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"}},j=await new f(Y).checkPackages(J);if(j.length===0)Q.success("All specified packages are up to date!");else{Q.info(`Found ${j.length} updates:`);for(let G of j)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-5ct11b1j.js"),J=Z.verbose?O.verbose():O.quiet(),Q=await S(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),j=$.createJobFromConfig(Y,"cli-schedule");if(Z.strategy)switch(Z.strategy){case"major":j.schedule.cron=$.PRESETS.WEEKLY;break;case"minor":j.schedule.cron=$.PRESETS.TWICE_WEEKLY;break;case"patch":j.schedule.cron=$.PRESETS.DAILY;break;default:j.schedule.cron=$.PRESETS.WEEKLY}U.addJob(j),U.start(),J.success(`\u2705 Scheduler started with cron: ${j.schedule.cron}`),J.info("\uD83D\uDCC5 Next run:",j.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-e6sg7jg4.js"),{writeFileSync:J,mkdirSync:Q}=await import("fs"),{resolve:z}=await import("path"),Y=Z.verbose?O.verbose():O.quiet(),U=await S(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
148
|
`);try{let j={...U,verbose:Z.verbose??U.verbose},G=j.workflows?.outputDir?z(V.cwd(),j.workflows.outputDir):z(V.cwd(),".github","workflows");Y.info("\uD83D\uDE80 Generating GitHub Actions workflow templates...");try{Q(G,{recursive:!0})}catch{}let X=j.workflows?.templates||{comprehensive:!0,daily:!0,weekly:!0,monthly:!0,docker:!0,monorepo:!0},H=0;if(X.daily||X.weekly||X.monthly){let q=$.generateScheduledWorkflows(j);for(let[K,F]of Object.entries(q))if(K.includes("daily")&&X.daily||K.includes("weekly")&&X.weekly||K.includes("monthly")&&X.monthly){let T=z(G,K);J(T,F),Y.success(`Generated: ${K}`),H++}}if(X.comprehensive){let q=$.generateComprehensiveWorkflow(j);J(z(G,"buddy-comprehensive.yml"),q),Y.success("Generated: buddy-comprehensive.yml"),H++}if(X.docker){let q=$.generateDockerWorkflow(j);J(z(G,"buddy-docker.yml"),q),Y.success("Generated: buddy-docker.yml"),H++}if(X.monorepo){let q=$.generateMonorepoWorkflow(j);J(z(G,"buddy-monorepo.yml"),q),Y.success("Generated: buddy-monorepo.yml"),H++}if(j.workflows?.custom?.length)for(let q of j.workflows.custom){let K=$.generateCustomWorkflow(q,j),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(j){Y.error("Failed to generate workflows:",j),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-
|
|
152
|
-
\uD83D\uDCCB Recent versions:`),Y.versions.slice(-U).reverse().forEach((G,X)=>{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-
|
|
151
|
+
\uD83D\uDD17 Learn more: https://docs.github.com/en/actions`)}catch(j){Y.error("Failed to generate workflows:",j),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-pvfavmy3.js"),Q=$.verbose?O.verbose():O.quiet();try{let z=new J(V.cwd(),Q,void 0);if($.json){let{spawn:j}=await import("child_process");j("bun",["info",Z,"--json"],{stdio:"inherit"}).on("close",(X)=>{V.exit(X||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-pvfavmy3.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,X)=>{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-pvfavmy3.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-pvfavmy3.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-pvfavmy3.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,j=$.dev||$.all,G=$.peer||$.all;if(U||$.all){let X=Y.dependencies||{},H=Object.keys(X).length;if(console.log(`
|
|
153
153
|
\uD83D\uDCCB Production Dependencies (${H}):`),H>0)Object.entries(X).forEach(([q,K])=>{console.log(` ${q}: ${K}`)});else console.log(" No production dependencies")}if(j){let X=Y.devDependencies||{},H=Object.keys(X).length;if(console.log(`
|
|
154
154
|
\uD83D\uDEE0\uFE0F Dev Dependencies (${H}):`),H>0)Object.entries(X).forEach(([q,K])=>{console.log(` ${q}: ${K}`)});else console.log(" No dev dependencies")}if(G){let X=Y.peerDependencies||{},H=Object.keys(X).length;if(console.log(`
|
|
155
|
-
\uD83E\uDD1D Peer Dependencies (${H}):`),H>0)Object.entries(X).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-
|
|
155
|
+
\uD83E\uDD1D Peer Dependencies (${H}):`),H>0)Object.entries(X).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-pvfavmy3.js"),j=await new Y(V.cwd(),z,void 0).getPackageMetadata(Z);if(!j)z.error(`Package "${Z}" not found`),V.exit(1);let G=j.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:X}=await import("../chunk-5zs6jrpt.js"),H=X($,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:X}=await import("../chunk-
|
|
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:X}=await import("../chunk-pvfavmy3.js"),q=await new X(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 j=Q("npm",["search",Z,"--json"],{stdio:"pipe"}),G="";j.stdout?.on("data",(X)=>{G+=X.toString()}),j.stderr?.on("data",(X)=>{if($.verbose)J.warn("npm search stderr:",X.toString())}),j.on("close",(X)=>{if(X===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 S(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 m(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 j=Y.filter((X)=>X.lastCommitDate<U);if(j.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 ${j.length} stale branches to clean up:`),j.forEach((X)=>{let H=Math.floor((Date.now()-X.lastCommitDate.getTime())/86400000);$.info(` - ${X.name} (${H} days old)`)}),Z.dryRun){$.info(`
|
|
159
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 ${j.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((X)=>$.warn(` - ${X}`));$.info(`
|
|
160
160
|
\uD83D\uDCCA Cleanup Summary:`),$.info(` \u2705 Deleted: ${G.deleted.length}`),$.info(` \u274C Failed: ${G.failed.length}`),$.info(` \uD83D\uDCCA Total processed: ${j.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 S(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 m(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,j]=await Promise.all([Q.getBuddyBranches(),Q.getPullRequests("open")]),G=new Set(j.map((K)=>K.head)),X=U;if(Z.orphanedOnly)X=X.filter((K)=>!G.has(K.name));if(Z.staleOnly)X=X.filter((K)=>K.lastCommitDate<Y&&!G.has(K.name));if(X.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
161
|
\uD83D\uDCCA Found ${X.length} buddy branch${X.length!==1?"es":""}:
|
|
@@ -165,16 +165,16 @@ For manual setup, visit:`),$.info("\uD83D\uDD17 Repository settings: https://git
|
|
|
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-
|
|
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-sjk83y3d.js"),{formatPretty:Q}=await import("../chunk-m17kvr7m.js"),{formatJson:z}=await import("../chunk-wcjf072v.js"),{formatGitHub:Y}=await import("../chunk-q5pxt13t.js"),U=$.ignore?.split(",").filter(Boolean)??[],j=await J(Z??".",{ignore:U}),G=$.format??(V.env.GITHUB_ACTIONS==="true"?"github":"pretty"),X;switch(G){case"json":X=z(j);break;case"github":X=Y(j);break;case"pretty":X=Q(j,{color:$.color!==!1});break;default:V.stderr.write(`Unknown --format ${G}. Use pretty | json | github.
|
|
169
169
|
`),V.exit(2);return}if(X)V.stdout.write(`${X}
|
|
170
|
-
`);V.exit(j.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 S($.config);try{let z=Number.parseInt(Z,10),Y=await m(Q,"finishing touches",J),j=(await Y.getPullRequests("open")).find((M)=>M.number===z);if(!j)J.error(`\u274C Pull request #${z} is not open`),V.exit(1);let{FINISHING_TOUCHES:G,getFinishingTouch:X,hasTouchOffer:H,parseTouchSelections:q,withTouchOffer:K}=await import("../chunk-
|
|
170
|
+
`);V.exit(j.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 S($.config);try{let z=Number.parseInt(Z,10),Y=await m(Q,"finishing touches",J),j=(await Y.getPullRequests("open")).find((M)=>M.number===z);if(!j)J.error(`\u274C Pull request #${z} is not open`),V.exit(1);let{FINISHING_TOUCHES:G,getFinishingTouch:X,hasTouchOffer:H,parseTouchSelections:q,withTouchOffer:K}=await import("../chunk-yke7v3gh.js");if($.offer){if(H(j.body)){J.info(`\u2139\uFE0F PR #${j.number} already carries the finishing-touch offer`);return}let M=K(j.body);if($.dryRun){J.info(`\uD83D\uDD0D [DRY RUN] Would offer finishing touches on PR #${j.number}`);return}await Y.updatePullRequest(j.number,{body:M}),J.success(`\u2705 Offered finishing touches on PR #${j.number}`);return}let F=$.name?[$.name]:q(j.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-ysp81zyt.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-dsep28r5.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:j,touch:X(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 B=j.body.replace(/^(\s*-\s*)\[[xX]\](\s*<!--\s*buddy:touch=)/gm,"$1[ ]$2");if(B!==j.body)await Y.updatePullRequest(z,{body:B})}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 S(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 m(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:j,parseQuickSelection:G,QUICK_LINKS_MARKER:X,renderQuickLinks:H}=await import("../chunk-2egzc1fp.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-ysp81zyt.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:j(U.body)});for(let A of q.actions){if(A==="plan"){let{runPlan:b}=await import("../chunk-3z759ya5.js"),k=await b({config:J,provider:z,number:Q,isPullRequest:!1,logger:$});await z.createComment(Q,k),$.success("\u2705 Ran plan");continue}let{BUILTIN_TOOLS:B,createReadIssueTool:M,getFinishingTouch:L,runAgent:E}=await import("../chunk-3z759ya5.js"),I=L("autofix"),N=await E(T,{mode:I.mode,task:`${I.buildTask({files:[]})}
|
|
171
171
|
|
|
172
|
-
Call \`read_issue\` to see what was asked for.`,tools:[...B,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(X)){$.debug("Quick-links already posted on this issue");return}let K=J.issues?.dependencyContext?await SZ(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 S($.config);try{let z=Number.parseInt(Z,10);if(Number.isNaN(z))J.error("\u274C Invalid PR number"),V.exit(1);let Y=await m(Q,"running gates",J),{findLinkedIssues:U,runAiGates:j,runGates:G,gateIcon:X,summarizeGates:H}=await import("../chunk-
|
|
173
|
-
`);return}let{createAiClient:s}=await import("../chunk-
|
|
174
|
-
`);return}let k1=(await T.getIssues("open")).find((X1)=>X1.body.includes(H)),b1=Q.reports?.title??"Dependency Report",h1=Q.reports?.labels??["dependencies","report"],T0=k1?await T.updateIssue(k1.number,{title:b1,body:p,labels:h1}):await T.createIssue({title:b1,body:p,labels:h1});J.success(`\u2705 Report published: ${T0.url}`),await T.commitChanges(P,"chore(reports): record dependency metrics snapshot",[{path:G,content:z(v,y),type:v.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 S(Z.config).catch((U)=>{return $.warn(`\u26A0\uFE0F Could not load configuration: ${r(U)}`),{}}),{diagnose:Q,renderDoctorReport:z}=await import("../chunk-
|
|
172
|
+
Call \`read_issue\` to see what was asked for.`,tools:[...B,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(X)){$.debug("Quick-links already posted on this issue");return}let K=J.issues?.dependencyContext?await SZ(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 S($.config);try{let z=Number.parseInt(Z,10);if(Number.isNaN(z))J.error("\u274C Invalid PR number"),V.exit(1);let Y=await m(Q,"running gates",J),{findLinkedIssues:U,runAiGates:j,runGates:G,gateIcon:X,summarizeGates:H}=await import("../chunk-xzhzvdcv.js"),{parseManifest:q}=await import("../chunk-f298fv6p.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-f298fv6p.js"),B=T?await Promise.all(A(T).map(async(P)=>{let v={name:P.name,version:P.newVersion};if(W.dependencyGate?.blockEol===!1)return v;if(T.updates.find((S1)=>S1.name===P.name)?.dependencyType!=="docker-image")return v;let{checkEol:s,describeEol:p}=await import("../chunk-xe2xdg6z.js"),Y1=await s(P.name,P.newVersion,{logger:J}),t=p(Y1);return Y1?.eol&&t?{...v,eol:t}:v})):[],M=G({title:F.title,body:F.body,manifest:T,dependencies:B},{...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"):[],I=L.map((P)=>E.find((v)=>v.number===P)).filter((P)=>Boolean(P)).map((P)=>({number:P.number,title:P.title,body:P.body})),{createAiClient:N}=await import("../chunk-ysp81zyt.js"),b=await j(N(Q,J),{title:F.title,body:F.body,diff:await Y.getPullRequestDiff(z),linkedIssues:I},{...W.linkedIssue?{linkedIssue:W.linkedIssue}:{},...W.custom?{custom:W.custom}:{}},J),k=[...M,...b],d=H(k);for(let P of k)J.info(`${X(P)} ${P.name}: ${P.summary}`);let y=d.conclusion==="failure";if(y)await g(Q.notifications,"gate.failed",{number:z,checks:k.filter((P)=>!P.passed).map((P)=>P.name)});if($.dryRun||!Q1(Y,"checkRuns","createCheckRun")){if(J.info(d.summary),y)V.exit(1);return}if(await Y.createCheckRun("buddy/gates",await Y.getPullRequestHeadSha(z),d),y)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 S($.config);try{let z=Number.parseInt(Z,10),Y=await m(Q,"post-merge actions",J),j=(await Y.getPullRequests("all")).find((H)=>H.number===z);if(!j)J.error(`\u274C Pull request #${z} not found`),V.exit(1);if(j.state!=="merged"){J.info(`\u2139\uFE0F PR #${z} was closed without merging; nothing to do`);return}let{runPostMerge:G}=await import("../chunk-xzhzvdcv.js"),X=await G(Y,j,Q.gates?.postMerge??{},{baseBranch:Q.repository?.baseBranch??j.base,logger:J,refreshDashboard:async()=>{if(Q.dashboard?.enabled===!1)throw Error("dashboard.enabled is false");await new f(Q).createOrUpdateDashboard()}});for(let H of X.performed)J.success(`\u2705 ${H}`);for(let H of X.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 S(Z.config);try{let{appendHistory:z,computeDeltas:Y,computeMetrics:U,findPrevious:j,HISTORY_PATH:G,loadHistory:X,REPORT_MARKER:H,REPORT_PERIODS:q,renderReport:K,withNarrative:F}=await import("../chunk-gw3t78fw.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 m(Q,"reporting",J),A=new f(Q,V.cwd()),{PackageScanner:B}=await import("../chunk-6t1rb4tz.js"),M=new B(V.cwd(),J,Q.packages?.ignorePaths),[L,E,I]=await Promise.all([A.scanForUpdates(),T.getPullRequests("all"),M.scanProject()]),{ecosystemOf:N}=await import("../chunk-4d13qb9f.js"),b={};for(let X1 of I)for(let j1 of X1.dependencies){let y1=N({name:j1.name,currentVersion:j1.currentVersion,newVersion:j1.currentVersion,updateType:"patch",dependencyType:j1.type,file:X1.path});b[y1]=(b[y1]??0)+1}let{DeprecatedDependenciesChecker:k}=await import("../chunk-xpsetmcw.js"),d=await new k().checkDeprecatedDependencies(I).catch(()=>[]),y=U({period:W,now:new Date,pullRequests:E,updates:L.updates,dependenciesByEcosystem:b,deprecated:d.length}),P=Q.repository?.baseBranch||"main",v=await X(T,P,J),i=Y(y,j(v,W));if(Z.format==="json"){V.stdout.write(`${JSON.stringify({metrics:y,deltas:i},null,2)}
|
|
173
|
+
`);return}let{createAiClient:s}=await import("../chunk-ysp81zyt.js"),p=await F(K(y,i),y,s(Q,J),Z.prompt??Q.reports?.prompt,J),{shouldPublishReport:Y1}=await import("../chunk-gw3t78fw.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 k1=(await T.getIssues("open")).find((X1)=>X1.body.includes(H)),b1=Q.reports?.title??"Dependency Report",h1=Q.reports?.labels??["dependencies","report"],T0=k1?await T.updateIssue(k1.number,{title:b1,body:p,labels:h1}):await T.createIssue({title:b1,body:p,labels:h1});J.success(`\u2705 Report published: ${T0.url}`),await T.commitChanges(P,"chore(reports): record dependency metrics snapshot",[{path:G,content:z(v,y),type:v.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 S(Z.config).catch((U)=>{return $.warn(`\u26A0\uFE0F Could not load configuration: ${r(U)}`),{}}),{diagnose:Q,renderDoctorReport:z}=await import("../chunk-h4084ykd.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 S(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:X}=await import("../chunk-
|
|
176
|
+
`),V.exit(1)}let{createAiClient:U}=await import("../chunk-ysp81zyt.js"),j=U(Z.model?{...J,ai:{...J.ai,model:Z.model}}:J,$);if(!j)V.stderr.write(`\u274C No AI provider configured. See https://buddy.sh/ai/providers
|
|
177
|
+
`),V.exit(1);let{publishOutput:G,runHeadless:X}=await import("../chunk-rfgacg5h.js"),H=await X({prompt:Q,ai:j,...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)}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{wh as W}from"./chunk-6k6dgwmy.js";import{Hh as y}from"./chunk-ddmvjp0y.js";import{Nh as J}from"./chunk-f0z6kyqt.js";import{cl as F}from"./chunk-6sm15trq.js";import S from"process";function G(E){let q=E.replace(/\\/g,"/");return q.includes(".github/workflows/")&&(q.endsWith(".yml")||q.endsWith(".yaml"))}async function L(E,q){try{if(!G(E))return null;let I=[],j=q.split(`
|
|
3
|
+
`);for(let K=0;K<j.length;K++){let Q=j[K].trim().match(/^-?\s*uses:\s*(.+)/);if(Q){let $=Q[1].trim().replace(/['"`]/g,"");if($.startsWith("./")||$.startsWith("docker://"))continue;let X=$.split("@");if(X.length===2){let[_,Y]=X;if(!_||!_.trim())continue;let[z,...k]=Y.split("#"),M=z.trim(),V={name:_.trim(),currentVersion:M,type:"github-actions",file:E};if(v(M)){let x=k.join("#").trim().split(/\s+/)[0];V.metadata=x?{pinnedSha:M,pinnedVersion:x}:{pinnedSha:M}}if(!I.find((x)=>x.name===V.name&&x.currentVersion===V.currentVersion))I.push(V)}}}return{path:E,type:"github-actions",content:q,dependencies:I}}catch(I){return J().warn(`Failed to parse GitHub Actions file ${E}:`,I),null}}function v(E){return/^[0-9a-f]{40}$/i.test(E)}function R(E,q){return E.replace(/^v/i,"")===q.replace(/^v/i,"")}async function U(E,q,I){try{if(!G(E))return q;let j=q;for(let K of I){let O=K.name.replace(/\s*\(.*\)$/,""),Z=O.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(K.resolved?.sha){let $=new RegExp(`((?:^\\s*-\\s*)?uses:\\s*["']?)(${Z})@(${K.currentVersion})(["']?)([ \\t]*#[^\\n]*)?`,"gm");j=j.replace($,`$1$2@${K.resolved.sha}$4 # ${K.newVersion}`);continue}let Q=new RegExp(`((?:^\\s*-\\s*)?uses:\\s*["']?)(${O.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})@(${K.currentVersion.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})(["']?)`,"gm");j=j.replace(Q,`$1$2@${K.newVersion}$4`)}return j}catch(j){return J().warn(`Failed to update GitHub Actions file ${E}:`,j),q}}async function D(E){let q=[],I=new Map;for(let j of E)if(G(j.file)){if(!I.has(j.file))I.set(j.file,[]);I.get(j.file).push(j)}for(let[j,K]of I)try{let O=await import("fs");if(O.existsSync(j)){let Z=O.readFileSync(j,"utf-8"),Q=await U(j,Z,K);q.push({path:j,content:Q,type:"update"})}}catch(O){J().warn(`Failed to generate updates for GitHub Actions file ${j}:`,O)}return q}async function b(E,q){let[I,j]=E.split("/");if(!I||!j)return null;let K={Accept:"application/vnd.github.v3+json","User-Agent":"buddy"},O=S.env.BUDDY_TOKEN||S.env.GITHUB_TOKEN||S.env.GH_TOKEN;if(O)K.Authorization=`Bearer ${O}`;try{let Z=await y(`${W()}/repos/${I}/${j}/commits/${encodeURIComponent(q)}`,{headers:K});if(!Z.ok)return null;let Q=await Z.json();return Q.sha&&v(Q.sha)?Q.sha:null}catch{return null}}async function P(E){try{if(!E.includes("/"))return J().info(`\u26A0\uFE0F Invalid action name format: ${E}`),null;let[q,I]=E.split("/");J().info(`\uD83D\uDD0D Fetching latest version for ${q}/${I}`);let j={Accept:"application/vnd.github.v3+json","User-Agent":"buddy"},K=S.env.BUDDY_TOKEN||S.env.GITHUB_TOKEN||S.env.GH_TOKEN;if(K)j.Authorization=`Bearer ${K}`;let O=W();J().info(`\uD83D\uDCE1 Trying latest release for ${q}/${I}`);let Z=await y(`${O}/repos/${q}/${I}/releases/latest`,{headers:j});if(Z.ok){let X=await Z.json();if(X.tag_name)return J().info(`\u2705 Found latest release: ${X.tag_name}`),X.tag_name}else J().info(`\u26A0\uFE0F Latest release not found: ${Z.status} ${Z.statusText}`);J().info(`\uD83D\uDCE1 Trying all releases for ${q}/${I}`);let Q=await y(`${O}/repos/${q}/${I}/releases?per_page=10`,{headers:j});if(Q.ok){let X=await Q.json();if(!Array.isArray(X))J().info("\u26A0\uFE0F Unexpected releases response format (expected array)");else{J().info(`\uD83D\uDCCB Found ${X.length} releases`);let _=X.filter((Y)=>Y.tag_name&&!Y.tag_name.includes("-")).sort((Y,z)=>{let k=Y.published_at?new Date(Y.published_at).getTime():0;return(z.published_at?new Date(z.published_at).getTime():0)-k});if(_.length>0)return J().info(`\u2705 Found latest stable release: ${_[0].tag_name}`),_[0].tag_name||null}}else J().info(`\u26A0\uFE0F Releases not found: ${Q.status} ${Q.statusText}`);J().info(`\uD83D\uDCE1 Trying tags for ${q}/${I}`);let $=await y(`${O}/repos/${q}/${I}/tags?per_page=10`,{headers:j});if($.ok){let X=await $.json();if(!Array.isArray(X))J().info("\u26A0\uFE0F Unexpected tags response format (expected array)");else{J().info(`\uD83D\uDCCB Found ${X.length} tags`);let _=X.filter((Y)=>Y.name&&!Y.name.includes("-")).map((Y)=>Y.name).sort((Y,z)=>{let k=Y.replace(/^v/,""),M=z.replace(/^v/,""),V=k.split(".").map(Number),B=M.split(".").map(Number);for(let x=0;x<Math.max(V.length,B.length);x++){let H=V[x]||0,T=B[x]||0;if(H!==T)return T-H}return 0});if(_.length>0)return J().info(`\u2705 Found latest stable tag: ${_[0]}`),_[0]}}else J().info(`\u26A0\uFE0F Tags not found: ${$.status} ${$.statusText}`);return J().info(`\u274C No version found for ${E}`),null}catch(q){return J().warn(`Failed to fetch latest version for ${E}:`,q),null}}
|
|
4
|
+
export{G as we,L as xe,v as ye,R as ze,U as Ae,D as Be,b as Ce,P as De};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ae as e,Be as f,Ce as g,De as h,we as a,xe as b,ye as c,ze as d}from"./chunk-03j2dx5h.js";import"./chunk-6k6dgwmy.js";import"./chunk-ddmvjp0y.js";import"./chunk-f0z6kyqt.js";import"./chunk-6sm15trq.js";export{e as updateGitHubActionsFile,d as sameActionVersion,b as parseGitHubActionsFile,a as isGitHubActionsFile,c as isCommitSha,f as generateGitHubActionsUpdates,h as fetchLatestActionVersion,g as fetchActionTagCommit};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Uf as B}from"./chunk-kpqez1ht.js";import{Hh as $}from"./chunk-ddmvjp0y.js";import{Nh as Z}from"./chunk-f0z6kyqt.js";var _=["scan.completed","pr.created","pr.updated","pr.closed","pr.merged","security.advisories","dashboard.updated","review.completed","fixci.completed","gate.failed","run.failed"];class I{logger;sinks=[];constructor(z=Z()){this.logger=z}register(z){this.sinks.push(z)}get size(){return this.sinks.length}async emit(z,q){let j=this.sinks.filter((C)=>!C.events?.length||C.events.includes(z));if(j.length===0)return;await Promise.all(j.map(async(C)=>{try{await C.deliver(z,q),this.logger.debug(`\uD83D\uDCE3 Delivered ${z} to ${C.name}`)}catch(F){this.logger.warn(`\u26A0\uFE0F Could not deliver ${z} to ${C.name}: ${F}`)}}))}}function J(z,q){switch(z){case"scan.completed":{let j=q;return`Found ${j.total} update(s): ${j.major} major, ${j.minor} minor, ${j.patch} patch`}case"pr.created":{let j=q;return`Opened #${j.number}: ${j.title}`}case"pr.merged":{let j=q;return`Merged #${j.number}: ${j.title}`}case"security.advisories":return`${q.packages.length} dependency/dependencies with known advisories`;case"pr.updated":{let j=q;return`Updated #${j.number}: ${j.title}`}case"pr.closed":{let j=q;return`Closed #${j.number} (${j.reason}): ${j.title}`}case"dashboard.updated":return`Dashboard refreshed: #${q.number}`;case"review.completed":{let j=q;return`Reviewed #${j.number}: ${j.findings} finding(s)`}case"fixci.completed":{let j=q;return`fix-ci ${j.action}${j.fixed?" (fixed)":""}${j.number?` on #${j.number}`:""}`}case"gate.failed":{let j=q;return`Gates failed on #${j.number}: ${j.checks.join(", ")}`}case"run.failed":{let j=q;return`\`${j.command}\` failed: ${j.error}`}default:return z}}import{createHmac as K}from"crypto";import N from"process";var P=1;function U(z){if(!z)return[];let q=[],j=M(z.slack?.webhookEnv??"SLACK_WEBHOOK_URL");if(j)q.push(V(j,z.slack?.events));let C=M(z.discord?.webhookEnv??"DISCORD_WEBHOOK_URL");if(C)q.push(Y(C,z.discord?.events));for(let[F,G]of(z.webhooks??[]).entries())q.push(A(G,F));return q}function V(z,q){return{name:"slack",...q?.length?{events:q}:{},async deliver(j,C){await Q(z,{text:`Buddy: ${J(j,C)}`,blocks:[{type:"section",text:{type:"mrkdwn",text:`*Buddy*
|
|
3
3
|
${J(j,C)}`}}]})}}}function Y(z,q){return{name:"discord",...q?.length?{events:q}:{},async deliver(j,C){await Q(z,{embeds:[{title:"Buddy",description:J(j,C),color:j==="security.advisories"||j==="run.failed"?14687834:3061373,timestamp:new Date().toISOString()}]})}}}function A(z,q=0){let j=z.secretEnv?M(z.secretEnv):void 0;return{name:`webhook[${q}]`,...z.events?.length?{events:z.events}:{},async deliver(C,F){let G=JSON.stringify({version:P,event:C,payload:F,sentAt:new Date().toISOString()}),X={"Content-Type":"application/json"};if(j)X["x-buddy-signature"]=`sha256=${R(G,j)}`;await Q(z.url,G,X)}}}function R(z,q){return K("sha256",q).update(z).digest("hex")}async function Q(z,q,j={}){let C=await $(z,{method:"POST",headers:{"Content-Type":"application/json",...j},body:typeof q==="string"?q:JSON.stringify(q)});if(!C.ok){let F=await C.text().catch(()=>"");throw Error(`${C.status} ${C.statusText} ${B(F.slice(0,200))}`.trim())}}function M(z){let q=N.env[z];return q?.trim()?q.trim():void 0}
|
|
4
|
-
export{_ as
|
|
4
|
+
export{_ as ud,I as vd,J as wd,P as xd,U as yd,V as zd,Y as Ad,A as Bd,R as Cd};
|