@buddysh/buddy 0.11.9 → 0.11.10

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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ [Compare changes](https://github.com/stacksjs/buddy/compare/v0.11.9...v0.11.10)
4
+
5
+ ## 🐛 Bug Fixes
6
+
7
+ - **pr**: keep the rebase checkbox when a long body is truncated ([06b3f12](https://github.com/stacksjs/buddy/commit/06b3f12)) _(by Chris <chrisbreuer93@gmail.com>)_
8
+
9
+ ## 🔧 Chores
10
+
11
+ - release v0.11.10 ([2dca667](https://github.com/stacksjs/buddy/commit/2dca667)) _(by Chris <chrisbreuer93@gmail.com>)_
12
+
13
+ ## Contributors
14
+
15
+ - _Chris <chrisbreuer93@gmail.com>_
16
+
3
17
  [Compare changes](https://github.com/stacksjs/buddy/compare/v0.11.8...v0.11.9)
4
18
 
5
19
  ## 🐛 Bug Fixes
package/dist/bin/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import{Uc as C1}from"../chunk-xps8n8nj.js";import"../chunk-tx9m7y1z.js";import{dd as m}from"../chunk-r7nh070r.js";import"../chunk-p9z0hzej.js";import"../chunk-amj037yy.js";import"../chunk-4wbbbcs2.js";import"../chunk-89s9f3mf.js";import"../chunk-ja3rvd6y.js";import"../chunk-p5yaf72b.js";import{td as g}from"../chunk-mg3em5qj.js";import"../chunk-7crh00m7.js";import{Dd as R1,Ld as z0}from"../chunk-bggpgbdx.js";import"../chunk-be059ncv.js";import"../chunk-xny4kgcc.js";import{pe as Q0,qe as Q1,re as z1}from"../chunk-34rmja4x.js";import"../chunk-hyp0wfta.js";import"../chunk-4hd1mryc.js";import"../chunk-nwrr6jas.js";import"../chunk-kh6v93yb.js";import"../chunk-88j356ng.js";import"../chunk-3waqfh3y.js";import"../chunk-k7x9af5r.js";import"../chunk-jpdd59fh.js";import"../chunk-7rjrea9g.js";import"../chunk-emygmh7r.js";import"../chunk-kpqez1ht.js";import"../chunk-vckn5ate.js";import"../chunk-wreexgkb.js";import{sg as $0,wg as J0}from"../chunk-gvnsr72j.js";import"../chunk-1m5wprvm.js";import"../chunk-ktmgq0ja.js";import{$g as Y0,_g as SZ,ah as X0,bh as j0,ch as G0,dh as K0,eh as f,fh as y,hh as q0,ih as H0,jh as U0,kh as V0,lh as W0,oh as F0,ph as M0,qh as D0,rh as O0,sh as W1,th as L0,uh as T0}from"../chunk-9m0epv44.js";import"../chunk-hkb714k3.js";import"../chunk-6k6dgwmy.js";import{Dh as S1}from"../chunk-pxdrwhxx.js";import"../chunk-a3bnhq58.js";import{Lh as r,Mh as O}from"../chunk-8dj94fsy.js";import"../chunk-0apd8zqn.js";import{bl as CZ,dl as D}from"../chunk-s3ksf6s5.js";import e1 from"fs";import V from"process";import{EventEmitter as E0}from"events";import c from"process";import _1 from"process";import T1 from"process";import q1 from"process";import Z1 from"process";import d1 from"tty";import KZ,{stdin as iZ,stdout as aZ}from"process";import g1,{stdin as UZ,stdout as VZ}from"process";import WZ from"readline";import{existsSync as PZ}from"fs";import D1 from"fs/promises";import l1 from"os";import O1 from"path";import n from"process";function L1(Z){return Z.replace(/[<[].+/,"").trim()}function I0(Z){let $=/<([^>]+)>/g,J=/\[([^\]]+)\]/g,Q=[],z=(X)=>{let G=!1,j=X[1];if(j.startsWith("..."))j=j.slice(3),G=!0;else if(j.endsWith("..."))j=j.slice(0,-3),G=!0;return{required:X[0].startsWith("<"),value:j.trim(),variadic:G}},Y;while(Y=$.exec(Z))Q.push(z(Y));let U;while(U=J.exec(Z))Q.push(z(U));return Q}function B0(Z){let $={alias:{},boolean:[]};for(let[J,Q]of Z.entries()){if(Q.names.length>1)$.alias[Q.names[0]]=Q.names.slice(1);if(Q.isBoolean)if(Q.negated){if(!Z.some((Y,U)=>{return U!==J&&Y.names.some((X)=>Q.names.includes(X))&&typeof Y.required==="boolean"}))$.boolean.push(Q.names[0])}else $.boolean.push(Q.names[0])}return $}function f1(Z){return Z.reduce(($,J)=>$.length>=J.length?$:J,"")}function F1(Z,$){return Z.length>=$?Z:`${Z}${" ".repeat($-Z.length)}`}function K1(Z){return Z.replace(/([a-z])-([a-z])/g,($,J,Q)=>{return J+Q.toUpperCase()})}function P0(Z,$,J){let Q=0,z=$.length,Y=Z,U;for(;Q<z;++Q)U=Y[$[Q]],Y=Y[$[Q]]=Q===z-1?J:U!=null?U:!!~$[Q+1].indexOf(".")||!(+$[Q+1]>-1)?{}:[]}function N0(Z,$){for(let J of Object.keys($)){let Q=$[J];if(Z[J]===void 0)continue;if(Q.shouldTransform){if(Z[J]=Array.prototype.concat.call([],Z[J]),typeof Q.transformFunction==="function")Z[J]=Z[J].map(Q.transformFunction)}}}function A0(Z){let $=/([^\\/]+)$/.exec(Z);return $?$[1]:""}function $1(Z){return Z.split(".").map(($,J)=>{return J===0?K1($):$}).join(".")}class J1 extends Error{exitCode=2;isUsageError=!0;usage;constructor(Z,$){super(Z);if(this.name=this.constructor.name,$!==void 0)this.usage=$;if(typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,this.constructor);else this.stack=Error(Z).stack}format(Z=!1){if(Z&&this.stack)return`${this.message}
3
+ import{Uc as C1}from"../chunk-gzjxhd7a.js";import"../chunk-tx9m7y1z.js";import{dd as m}from"../chunk-785rgtn5.js";import"../chunk-p9z0hzej.js";import"../chunk-amj037yy.js";import"../chunk-4wbbbcs2.js";import"../chunk-89s9f3mf.js";import"../chunk-ja3rvd6y.js";import"../chunk-yxb1jwxp.js";import{td as g}from"../chunk-mg3em5qj.js";import"../chunk-7crh00m7.js";import{Dd as R1,Ld as z0}from"../chunk-bggpgbdx.js";import"../chunk-be059ncv.js";import"../chunk-xny4kgcc.js";import{pe as Q0,qe as Q1,re as z1}from"../chunk-34rmja4x.js";import"../chunk-hyp0wfta.js";import"../chunk-4hd1mryc.js";import"../chunk-nwrr6jas.js";import"../chunk-kh6v93yb.js";import"../chunk-88j356ng.js";import"../chunk-3waqfh3y.js";import"../chunk-k7x9af5r.js";import"../chunk-jpdd59fh.js";import"../chunk-7rjrea9g.js";import"../chunk-emygmh7r.js";import"../chunk-kpqez1ht.js";import"../chunk-vckn5ate.js";import"../chunk-wreexgkb.js";import{sg as $0,wg as J0}from"../chunk-gvnsr72j.js";import"../chunk-1m5wprvm.js";import"../chunk-ktmgq0ja.js";import{$g as Y0,_g as SZ,ah as X0,bh as j0,ch as G0,dh as K0,eh as f,fh as y,hh as q0,ih as H0,jh as U0,kh as V0,lh as W0,oh as F0,ph as M0,qh as D0,rh as O0,sh as W1,th as L0,uh as T0}from"../chunk-9m0epv44.js";import"../chunk-hkb714k3.js";import"../chunk-6k6dgwmy.js";import{Dh as S1}from"../chunk-pxdrwhxx.js";import"../chunk-a3bnhq58.js";import{Lh as r,Mh as O}from"../chunk-8dj94fsy.js";import"../chunk-0apd8zqn.js";import{bl as CZ,dl as D}from"../chunk-s3ksf6s5.js";import e1 from"fs";import V from"process";import{EventEmitter as E0}from"events";import c from"process";import _1 from"process";import T1 from"process";import q1 from"process";import Z1 from"process";import d1 from"tty";import KZ,{stdin as iZ,stdout as aZ}from"process";import g1,{stdin as UZ,stdout as VZ}from"process";import WZ from"readline";import{existsSync as PZ}from"fs";import D1 from"fs/promises";import l1 from"os";import O1 from"path";import n from"process";function L1(Z){return Z.replace(/[<[].+/,"").trim()}function I0(Z){let $=/<([^>]+)>/g,J=/\[([^\]]+)\]/g,Q=[],z=(X)=>{let G=!1,j=X[1];if(j.startsWith("..."))j=j.slice(3),G=!0;else if(j.endsWith("..."))j=j.slice(0,-3),G=!0;return{required:X[0].startsWith("<"),value:j.trim(),variadic:G}},Y;while(Y=$.exec(Z))Q.push(z(Y));let U;while(U=J.exec(Z))Q.push(z(U));return Q}function B0(Z){let $={alias:{},boolean:[]};for(let[J,Q]of Z.entries()){if(Q.names.length>1)$.alias[Q.names[0]]=Q.names.slice(1);if(Q.isBoolean)if(Q.negated){if(!Z.some((Y,U)=>{return U!==J&&Y.names.some((X)=>Q.names.includes(X))&&typeof Y.required==="boolean"}))$.boolean.push(Q.names[0])}else $.boolean.push(Q.names[0])}return $}function f1(Z){return Z.reduce(($,J)=>$.length>=J.length?$:J,"")}function F1(Z,$){return Z.length>=$?Z:`${Z}${" ".repeat($-Z.length)}`}function K1(Z){return Z.replace(/([a-z])-([a-z])/g,($,J,Q)=>{return J+Q.toUpperCase()})}function P0(Z,$,J){let Q=0,z=$.length,Y=Z,U;for(;Q<z;++Q)U=Y[$[Q]],Y=Y[$[Q]]=Q===z-1?J:U!=null?U:!!~$[Q+1].indexOf(".")||!(+$[Q+1]>-1)?{}:[]}function N0(Z,$){for(let J of Object.keys($)){let Q=$[J];if(Z[J]===void 0)continue;if(Q.shouldTransform){if(Z[J]=Array.prototype.concat.call([],Z[J]),typeof Q.transformFunction==="function")Z[J]=Z[J].map(Q.transformFunction)}}}function A0(Z){let $=/([^\\/]+)$/.exec(Z);return $?$[1]:""}function $1(Z){return Z.split(".").map(($,J)=>{return J===0?K1($):$}).join(".")}class J1 extends Error{exitCode=2;isUsageError=!0;usage;constructor(Z,$){super(Z);if(this.name=this.constructor.name,$!==void 0)this.usage=$;if(typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,this.constructor);else this.stack=Error(Z).stack}format(Z=!1){if(Z&&this.stack)return`${this.message}
4
4
 
5
5
  Stack trace:
6
6
  ${this.stack}`;return this.message}}function x0(Z){if(Z instanceof J1)return!0;return!!Z&&typeof Z==="object"&&Z.name==="ClappError"&&typeof Z.message==="string"}function R0(){let{env:Z}=_1,{TERM:$,TERM_PROGRAM:J}=Z;if(_1.platform!=="win32")return $!=="linux";return Boolean(Z.WT_SESSION)||Boolean(Z.TERMINUS_SUBLIME)||Z.ConEmuTask==="{cmd::Cmder}"||J==="Terminus-Sublime"||J==="vscode"||$==="xterm-256color"||$==="alacritty"||$==="rxvt-unicode"||$==="rxvt-unicode-256color"||Z.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var V1="\x1B",S=`${V1}[`;var u={to(Z,$){if(!$)return`${S}${Z+1}G`;return`${S}${$+1};${Z+1}H`},move(Z,$){let J="";if(Z<0)J+=`${S}${-Z}D`;else if(Z>0)J+=`${S}${Z}C`;if($<0)J+=`${S}${-$}A`;else if($>0)J+=`${S}${$}B`;return J},up:(Z=1)=>`${S}${Z}A`,down:(Z=1)=>`${S}${Z}B`,forward:(Z=1)=>`${S}${Z}C`,backward:(Z=1)=>`${S}${Z}D`,nextLine:(Z=1)=>`${S}E`.repeat(Z),prevLine:(Z=1)=>`${S}F`.repeat(Z),left:`${S}G`,hide:`${S}?25l`,show:`${S}?25h`,save:`${V1}7`,restore:`${V1}8`};var M1={screen:`${S}2J`,up:(Z=1)=>`${S}1J`.repeat(Z),down:(Z=1)=>`${S}J`.repeat(Z),line:`${S}2K`,lineEnd:`${S}K`,lineStart:`${S}1K`,lines(Z){let $="";for(let J=0;J<Z;J++)$+=this.line+(J<Z-1?u.up():"");if(Z)$+=u.left;return $}},mZ={screen:`${V1}c`};function C0(Z,$){let J=[];for(let Q=0;Q<=$.length;Q++)J[Q]=[Q];for(let Q=0;Q<=Z.length;Q++)J[0][Q]=Q;for(let Q=1;Q<=$.length;Q++)for(let z=1;z<=Z.length;z++)if($.charAt(Q-1)===Z.charAt(z-1))J[Q][z]=J[Q-1][z-1];else J[Q][z]=Math.min(J[Q-1][z-1]+1,J[Q][z-1]+1,J[Q-1][z]+1);return J[$.length][Z.length]}function p1(Z,$,J=2,Q=3){return $.map((z)=>({cmd:z,distance:C0(Z,z)})).filter(({distance:z})=>z<=J).sort((z,Y)=>z.distance-Y.distance).slice(0,Q).map(({cmd:z})=>z)}function S0(Z,$={}){let J={_:[]},Q=$.alias||{},z=new Set($.boolean||[]),Y={};for(let G of Object.keys(Q))for(let j of Q[G])Y[j]=G;for(let G of z)if(Q[G])for(let j of Q[G])z.add(j);function U(G,j){if(G===void 0)return j;if(typeof j==="boolean")return j;return Array.isArray(G)?[...G,j]:[G,j]}function X(G,j){let H=Y[G]||G,q=U(J[H],j);if(J[H]=q,Q[H])for(let K of Q[H])J[K]=q;if(Y[G]&&Q[Y[G]])for(let K of Q[Y[G]])J[K]=q;J[G]=q}for(let G=0;G<Z.length;G++){let j=Z[G];if(j==="--"){J._.push(...Z.slice(G+1));break}if(j.startsWith("--")){let H=j.indexOf("=");if(H!==-1){let q=K1(j.slice(2,H)),K=j.slice(H+1);X(q,K)}else{let q=j.slice(2);if(q.startsWith("no-")){let W=K1(q.slice(3));X(W,!1);continue}let K=K1(q),F=Y[K]||K;if(z.has(F)||z.has(K))X(K,!0);else{let W=Z[G+1];if(W!==void 0&&!W.startsWith("-"))X(K,W),G++;else X(K,!0)}}}else if(j.startsWith("-")&&j.length>1){let H=j.slice(1);for(let q=0;q<H.length;q++){let K=H[q],F=Y[K]||K;if(q===H.length-1&&!z.has(F)&&!z.has(K)){let W=Z[G+1];if(W!==void 0&&!W.startsWith("-"))X(K,W),G++;else X(K,!0)}else X(K,!0)}}else J._.push(j)}return J}class n1{rawName;description;name;names;isBoolean;required;config;negated;variadic;constructor(Z,$,J){if(this.rawName=Z,this.description=$,this.config=Object.assign({},J),Z=Z.replace(/\.\*/g,""),this.negated=!1,this.variadic=/[<[](?:\.\.\.[^\]>]+|[^\]>]+\.\.\.)[\]>]/.test(Z),this.names=L1(Z).split(",").map((Q)=>{let z=Q.trim().replace(/^-{1,2}/,"");if(z.startsWith("no-"))this.negated=!0,z=z.replace(/^no-/,"");return $1(z)}).sort((Q,z)=>Q.length>z.length?1:-1),this.name=this.names[this.names.length-1],this.negated&&this.config.default==null)this.config.default=!0;if(Z.includes("<"))this.required=!0;else if(Z.includes("["))this.required=!1;else this.isBoolean=!0}}var uZ=T1.argv,k0=`${T1.platform}-${T1.arch} bun-v${typeof Bun<"u"?Bun.version:"unknown"}`,m1=q1.argv,b0=`${q1.platform}-${q1.arch} node-${q1.version}`;class w1{rawName;description;config;cli;options;aliasNames;name;namespace;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;beforeHooks;afterHooks;middleware;constructor(Z,$,J,Q){this.rawName=Z,this.description=$,this.config=J,this.cli=Q,this.options=[],this.aliasNames=[],this.name=L1(Z);let z=L1(Z),Y=z.indexOf(":");if(Y>0)this.namespace=z.substring(0,Y),this.name=z.substring(Y+1);if(this.args=I0(Z),this.examples=[],this.beforeHooks=[],this.afterHooks=[],this.middleware=[],!J)this.config={}}usage(Z){return this.usageText=Z,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(Z,$="-v, --version"){return this.versionNumber=Z,this.option($,"Display version number"),this}example(Z){return this.examples.push(Z),this}option(Z,$,J){let Q=new n1(Z,$,J);return this.options.push(Q),this}alias(Z){return this.aliasNames.push(Z),this}action(Z){return this.commandAction=Z,this}before(Z){return this.beforeHooks.push(Z),this}after(Z){return this.afterHooks.push(Z),this}use(Z){return this.middleware.push(Z),this}isMatched(Z){if(this.aliasNames.includes(Z))return!0;if(this.namespace)return`${this.namespace}:${this.name}`===Z;return this.name===Z}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof E1}get displayName(){return this.namespace?`${this.namespace}:${this.name}`:this.name}hasOption(Z){let $=$1(Z.split(".")[0]);return!!this.options.find((J)=>{return J.names.some((Q)=>$1(Q)===$)})}outputHelp(){let{name:Z,commands:$}=this.cli,{versionNumber:J,options:Q,helpCallback:z}=this.cli.globalCommand,Y=[{body:`${Z}${J?`/${J}`:""}`}];if(Y.push({title:"Usage",body:` $ ${Z} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&$.length>0){let j=f1($.map((W)=>W.rawName)),H=new Map,q=[];for(let W of $)if(W.namespace){if(!H.has(W.namespace))H.set(W.namespace,[]);H.get(W.namespace).push(W)}else q.push(W);let K="";if(q.sort((W,T)=>W.rawName<T.rawName?-1:W.rawName>T.rawName?1:0),q.length>0)K+=q.map((W)=>{return` ${F1(W.rawName,j.length)} ${W.description}`}).join(`
@@ -38,7 +38,7 @@ 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=c1(this._render(this)??"",g1.stdout.columns,{hard:!0,trim:!1});if(Z===this._prevFrame)return;if(this.state==="initial")this.output.write(u.hide);else{let $=HZ(this._prevFrame,Z);if(this.restoreCursor(),$&&$?.length===1){let J=$[0];this.output.write(u.move(0,J)),this.output.write(M1.lines(1));let Q=Z.split(`
39
39
  `);this.output.write(Q[J]),this._prevFrame=Z,this.output.write(u.move(0,Q.length-J-1));return}if($&&$?.length>1){let J=$[0];this.output.write(u.move(0,J)),this.output.write(M1.down());let z=Z.split(`
40
40
  `).slice(J);this.output.write(z.join(`
41
- `)),this._prevFrame=Z;return}this.output.write(M1.down())}if(this.output.write(Z),this.state==="initial")this.state="active";this._prevFrame=Z}}function DZ(Z,$){if(Z===void 0)return 0;if($.length===0)return 0;let Q=$.findIndex((z)=>z.value===Z);return Q!==-1?Q:0}function OZ(Z,$){return($.label??String($.value)).toLowerCase().includes(Z.toLowerCase())}function LZ(Z,$){if(!$)return;if(Z)return $;return $[0]}class TZ extends B1{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#Z=0;#J="";#Q;#$;get cursor(){return this.#Z}get userInputWithCursor(){if(!this.userInput)return H1.inverse(H1.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}\u2588`;let Z=this.userInput.slice(0,this._cursor),[$,...J]=this.userInput.slice(this._cursor);return`${Z}${H1.inverse($)}${J.join("")}`}get options(){if(typeof this.#$==="function")return this.#$();return this.#$}constructor(Z){super(Z);this.#$=Z.options;let $=this.options;this.filteredOptions=[...$],this.multiple=Z.multiple===!0,this.#Q=Z.filter??OZ;let J;if(Z.initialValue&&Array.isArray(Z.initialValue))if(this.multiple)J=Z.initialValue;else J=Z.initialValue.slice(0,1);else if(!this.multiple&&this.options.length>0)J=[this.options[0].value];if(J)for(let Q of J){let z=$.findIndex((Y)=>Y.value===Q);if(z!==-1)this.toggleSelected(Q),this.#Z=z}this.focusedValue=this.options[this.#Z]?.value,this.on("key",(Q,z)=>this.#z(Q,z)),this.on("userInput",(Q)=>this.#Y(Q))}_isActionKey(Z,$){return Z==="\t"||this.multiple&&this.isNavigating&&$.name==="space"&&Z!==void 0&&Z!==""}#z(Z,$){let J=$.name==="up",Q=$.name==="down",z=$.name==="return";if(J||Q){if(this.#Z=Math.max(0,Math.min(this.#Z+(J?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#Z]?.value,!this.multiple)this.selectedValues=[this.focusedValue];this.isNavigating=!0}else if(z)this.value=LZ(this.multiple,this.selectedValues);else if(this.multiple)if(this.focusedValue!==void 0&&($.name==="tab"||this.isNavigating&&$.name==="space"))this.toggleSelected(this.focusedValue);else this.isNavigating=!1;else{if(this.focusedValue)this.selectedValues=[this.focusedValue];this.isNavigating=!1}}deselectAll(){this.selectedValues=[]}toggleSelected(Z){if(this.filteredOptions.length===0)return;if(this.multiple)if(this.selectedValues.includes(Z))this.selectedValues=this.selectedValues.filter(($)=>$!==Z);else this.selectedValues=[...this.selectedValues,Z];else this.selectedValues=[Z]}#Y(Z){if(Z!==this.#J){this.#J=Z;let $=this.options;if(Z)this.filteredOptions=$.filter((J)=>this.#Q(Z,J));else this.filteredOptions=[...$];if(this.#Z=DZ(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#Z]?.value,!this.multiple)if(this.focusedValue!==void 0)this.toggleSelected(this.focusedValue);else this.deselectAll()}}}class wZ extends B1{options;cursor=0;#Z;getGroupItems(Z){return this.options.filter(($)=>$.group===Z)}isGroupSelected(Z){let $=this.getGroupItems(Z),J=this.value;if(J===void 0)return!1;return $.every((Q)=>J.includes(Q.value))}toggleValue(){let Z=this.options[this.cursor];if(this.value===void 0)this.value=[];if(Z.group===!0){let $=String(Z.value),J=this.getGroupItems($);if(this.isGroupSelected($))this.value=this.value.filter((Q)=>J.findIndex((z)=>z.value===Q)===-1);else this.value=[...this.value,...J.map((Q)=>Q.value)];this.value=Array.from(new Set(this.value))}else{let $=this.value.includes(Z.value);this.value=$?this.value.filter((J)=>J!==Z.value):[...this.value,Z.value]}}constructor(Z){super(Z,!1);let{options:$}=Z;this.#Z=Z.selectableGroups!==!1,this.options=Object.entries($).flatMap(([J,Q])=>[{value:J,group:!0,label:J},...Q.map((z)=>({...z,group:J}))]),this.value=[...Z.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:J})=>J===Z.cursorAt),this.#Z?0:1),this.on("cursor",(J)=>{switch(J){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let Q=this.options[this.cursor]?.group===!0;if(!this.#Z&&Q)this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let Q=this.options[this.cursor]?.group===!0;if(!this.#Z&&Q)this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}case"space":this.toggleValue();break}})}}var EZ=R0();var x=(Z,$)=>EZ?Z:$,oZ=x("\u25C6","*"),eZ=x("\u25A0","x"),Z$=x("\u25B2","x"),$$=x("\u25C7","o"),J$=x("\u250C","T"),IZ=x("\u2502","|"),Q$=x("\u2514","\u2014"),z$=x("\u25CF",">"),Y$=x("\u25CB"," "),X$=x("\u25FB","[\u2022]"),j$=x("\u25FC","[+]"),G$=x("\u25FB","[ ]"),K$=x("\u25AA","\u2022"),q$=x("\u2500","-"),H$=x("\u256E","+"),U$=x("\u251C","+"),V$=x("\u256F","+"),W$=x("\u25CF","\u2022"),F$=x("\u25C6","*"),M$=x("\u25B2","!"),D$=x("\u25A0","x");var O$={light:x("\u2500","-"),heavy:x("\u2501","="),block:x("\u2588","#")};function BZ(){return`${H1.gray(IZ)} `}var L$=BZ();class s1{configPath;config=null;events=[];retryCount=0;maxRetries=3;retryDelayMs=1000;constructor(){let Z=l1.homedir(),$=O1.join(Z,".config","clapp");this.configPath=O1.join($,"telemetry.json")}async isEnabled(){if(n.env.DO_NOT_TRACK==="1"||n.env.DO_NOT_TRACK==="true")return!1;if(n.env.NO_TELEMETRY==="1"||n.env.NO_TELEMETRY==="true")return!1;return(await this.loadConfig()).enabled}async enable(){let Z=await this.loadConfig();if(Z.enabled=!0,!Z.userId)Z.userId=this.generateUserId();await this.saveConfig(Z)}async disable(){let Z=await this.loadConfig();Z.enabled=!1,await this.saveConfig(Z)}async track(Z,$){if(!await this.isEnabled())return;let Q={event:Z,...$,timestamp:Date.now(),platform:l1.platform(),nodeVersion:n.version};if(this.events.push(Q),this.events.length>=10)await this.send()}async trackCommand(Z,$){await this.track("command",{command:Z,duration:$})}async trackError(Z,$){await this.track("error",{error:Z,command:$})}async send(){if(!await this.isEnabled()||this.events.length===0)return!0;try{this.events=[],this.retryCount=0;let $=await this.loadConfig();return $.lastSent=Date.now(),await this.saveConfig($),!0}catch{if(this.retryCount<this.maxRetries){this.retryCount++;let $=this.retryDelayMs*2**(this.retryCount-1);return await this.sleep($),this.send()}return this.events=[],this.retryCount=0,!1}}async flush(){if(this.events.length===0)return!0;return this.send()}sleep(Z){return new Promise(($)=>setTimeout($,Z))}async status(){let Z=await this.loadConfig();return{enabled:Z.enabled,doNotTrack:n.env.DO_NOT_TRACK==="1"||n.env.DO_NOT_TRACK==="true",eventsQueued:this.events.length,lastSent:Z.lastSent}}async loadConfig(){if(this.config)return this.config;try{if(PZ(this.configPath)){let Z=await D1.readFile(this.configPath,"utf-8");return this.config=JSON.parse(Z),this.config}}catch{}return this.config={enabled:!1},this.config}async saveConfig(Z){this.config=Z;try{let $=O1.dirname(this.configPath);await D1.mkdir($,{recursive:!0}),await D1.writeFile(this.configPath,JSON.stringify(Z,null,2),"utf-8")}catch{}}generateUserId(){let Z=Math.random().toString(36).substring(2,15),$=Date.now().toString(36);return`${Z}-${$}`}}var P$=new s1;var a=CZ(SZ(),1);var P1="0.11.9";var N1=String.raw`^\s*-\s*\[[xX]\]\s*`,AZ=new RegExp(`${N1}<!--\\s*rebase-branch=([^>]*?)\\s*-->`,"gm"),xZ=new RegExp(`${N1}<!--\\s*rebase-all-open-prs\\s*-->`,"m"),RZ=new RegExp(`${N1}<!--\\s*manual job\\s*-->`,"m");function t1(Z){if(!Z)return{rebaseBranches:[],rebaseAll:!1,manualRun:!1};let $=[];for(let J of Z.matchAll(AZ)){let Q=J[1].trim();if(Q&&!$.includes(Q))$.push(Q)}return{rebaseBranches:$,rebaseAll:xZ.test(Z),manualRun:RZ.test(Z)}}function A1(Z){return Z.rebaseBranches.length>0||Z.rebaseAll||Z.manualRun}function o1(Z){return Z.replace(/^(\s*-\s*)\[[xX]\](\s*<!--\s*(?:rebase-branch=[^>]*?|rebase-all-open-prs|manual job)\s*-->)/gm,"$1[ ]$2")}var x1=null;async function k(Z){if(Z)return await C1(Z);if(!x1)x1=await C1();return x1}async function d(Z,$,J){if(!Z.repository?.owner||!Z.repository.name)J.error(`\u274C Repository owner and name are required for ${$}`),J.info("Configure repository.owner and repository.name in buddy.config.ts"),V.exit(1);try{return await Q0({provider:Z.repository.provider,owner:Z.repository.owner,name:Z.repository.name,...Z.repository.token?{token:Z.repository.token}:{},...Z.repository.apiUrl?{apiUrl:Z.repository.apiUrl}:{}},{logger:J})}catch(Q){J.error(`\u274C ${r(Q)}`),V.exit(1)}}async function Z0(Z,$,J){let Q=Z.filter((U)=>U.suggestion);if(Q.length===0)return J.info("No committable suggestions in this review"),0;let z=new Map;for(let U of Q){let X=z.get(U.path);if(X)X.push(U);else z.set(U.path,[U])}let Y=0;for(let[U,X]of z){let G=Bun.file(U);if(!await G.exists()){J.warn(`\u26A0\uFE0F Skipping ${U}: not in the working tree`);continue}let j=await G.text();for(let H of[...X].sort((q,K)=>K.line-q.line)){if(!$){if(!(await a.default({type:"confirm",name:"apply",message:`${U}:${H.line} \u2014 ${H.message}
41
+ `)),this._prevFrame=Z;return}this.output.write(M1.down())}if(this.output.write(Z),this.state==="initial")this.state="active";this._prevFrame=Z}}function DZ(Z,$){if(Z===void 0)return 0;if($.length===0)return 0;let Q=$.findIndex((z)=>z.value===Z);return Q!==-1?Q:0}function OZ(Z,$){return($.label??String($.value)).toLowerCase().includes(Z.toLowerCase())}function LZ(Z,$){if(!$)return;if(Z)return $;return $[0]}class TZ extends B1{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#Z=0;#J="";#Q;#$;get cursor(){return this.#Z}get userInputWithCursor(){if(!this.userInput)return H1.inverse(H1.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}\u2588`;let Z=this.userInput.slice(0,this._cursor),[$,...J]=this.userInput.slice(this._cursor);return`${Z}${H1.inverse($)}${J.join("")}`}get options(){if(typeof this.#$==="function")return this.#$();return this.#$}constructor(Z){super(Z);this.#$=Z.options;let $=this.options;this.filteredOptions=[...$],this.multiple=Z.multiple===!0,this.#Q=Z.filter??OZ;let J;if(Z.initialValue&&Array.isArray(Z.initialValue))if(this.multiple)J=Z.initialValue;else J=Z.initialValue.slice(0,1);else if(!this.multiple&&this.options.length>0)J=[this.options[0].value];if(J)for(let Q of J){let z=$.findIndex((Y)=>Y.value===Q);if(z!==-1)this.toggleSelected(Q),this.#Z=z}this.focusedValue=this.options[this.#Z]?.value,this.on("key",(Q,z)=>this.#z(Q,z)),this.on("userInput",(Q)=>this.#Y(Q))}_isActionKey(Z,$){return Z==="\t"||this.multiple&&this.isNavigating&&$.name==="space"&&Z!==void 0&&Z!==""}#z(Z,$){let J=$.name==="up",Q=$.name==="down",z=$.name==="return";if(J||Q){if(this.#Z=Math.max(0,Math.min(this.#Z+(J?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#Z]?.value,!this.multiple)this.selectedValues=[this.focusedValue];this.isNavigating=!0}else if(z)this.value=LZ(this.multiple,this.selectedValues);else if(this.multiple)if(this.focusedValue!==void 0&&($.name==="tab"||this.isNavigating&&$.name==="space"))this.toggleSelected(this.focusedValue);else this.isNavigating=!1;else{if(this.focusedValue)this.selectedValues=[this.focusedValue];this.isNavigating=!1}}deselectAll(){this.selectedValues=[]}toggleSelected(Z){if(this.filteredOptions.length===0)return;if(this.multiple)if(this.selectedValues.includes(Z))this.selectedValues=this.selectedValues.filter(($)=>$!==Z);else this.selectedValues=[...this.selectedValues,Z];else this.selectedValues=[Z]}#Y(Z){if(Z!==this.#J){this.#J=Z;let $=this.options;if(Z)this.filteredOptions=$.filter((J)=>this.#Q(Z,J));else this.filteredOptions=[...$];if(this.#Z=DZ(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#Z]?.value,!this.multiple)if(this.focusedValue!==void 0)this.toggleSelected(this.focusedValue);else this.deselectAll()}}}class wZ extends B1{options;cursor=0;#Z;getGroupItems(Z){return this.options.filter(($)=>$.group===Z)}isGroupSelected(Z){let $=this.getGroupItems(Z),J=this.value;if(J===void 0)return!1;return $.every((Q)=>J.includes(Q.value))}toggleValue(){let Z=this.options[this.cursor];if(this.value===void 0)this.value=[];if(Z.group===!0){let $=String(Z.value),J=this.getGroupItems($);if(this.isGroupSelected($))this.value=this.value.filter((Q)=>J.findIndex((z)=>z.value===Q)===-1);else this.value=[...this.value,...J.map((Q)=>Q.value)];this.value=Array.from(new Set(this.value))}else{let $=this.value.includes(Z.value);this.value=$?this.value.filter((J)=>J!==Z.value):[...this.value,Z.value]}}constructor(Z){super(Z,!1);let{options:$}=Z;this.#Z=Z.selectableGroups!==!1,this.options=Object.entries($).flatMap(([J,Q])=>[{value:J,group:!0,label:J},...Q.map((z)=>({...z,group:J}))]),this.value=[...Z.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:J})=>J===Z.cursorAt),this.#Z?0:1),this.on("cursor",(J)=>{switch(J){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let Q=this.options[this.cursor]?.group===!0;if(!this.#Z&&Q)this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let Q=this.options[this.cursor]?.group===!0;if(!this.#Z&&Q)this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}case"space":this.toggleValue();break}})}}var EZ=R0();var x=(Z,$)=>EZ?Z:$,oZ=x("\u25C6","*"),eZ=x("\u25A0","x"),Z$=x("\u25B2","x"),$$=x("\u25C7","o"),J$=x("\u250C","T"),IZ=x("\u2502","|"),Q$=x("\u2514","\u2014"),z$=x("\u25CF",">"),Y$=x("\u25CB"," "),X$=x("\u25FB","[\u2022]"),j$=x("\u25FC","[+]"),G$=x("\u25FB","[ ]"),K$=x("\u25AA","\u2022"),q$=x("\u2500","-"),H$=x("\u256E","+"),U$=x("\u251C","+"),V$=x("\u256F","+"),W$=x("\u25CF","\u2022"),F$=x("\u25C6","*"),M$=x("\u25B2","!"),D$=x("\u25A0","x");var O$={light:x("\u2500","-"),heavy:x("\u2501","="),block:x("\u2588","#")};function BZ(){return`${H1.gray(IZ)} `}var L$=BZ();class s1{configPath;config=null;events=[];retryCount=0;maxRetries=3;retryDelayMs=1000;constructor(){let Z=l1.homedir(),$=O1.join(Z,".config","clapp");this.configPath=O1.join($,"telemetry.json")}async isEnabled(){if(n.env.DO_NOT_TRACK==="1"||n.env.DO_NOT_TRACK==="true")return!1;if(n.env.NO_TELEMETRY==="1"||n.env.NO_TELEMETRY==="true")return!1;return(await this.loadConfig()).enabled}async enable(){let Z=await this.loadConfig();if(Z.enabled=!0,!Z.userId)Z.userId=this.generateUserId();await this.saveConfig(Z)}async disable(){let Z=await this.loadConfig();Z.enabled=!1,await this.saveConfig(Z)}async track(Z,$){if(!await this.isEnabled())return;let Q={event:Z,...$,timestamp:Date.now(),platform:l1.platform(),nodeVersion:n.version};if(this.events.push(Q),this.events.length>=10)await this.send()}async trackCommand(Z,$){await this.track("command",{command:Z,duration:$})}async trackError(Z,$){await this.track("error",{error:Z,command:$})}async send(){if(!await this.isEnabled()||this.events.length===0)return!0;try{this.events=[],this.retryCount=0;let $=await this.loadConfig();return $.lastSent=Date.now(),await this.saveConfig($),!0}catch{if(this.retryCount<this.maxRetries){this.retryCount++;let $=this.retryDelayMs*2**(this.retryCount-1);return await this.sleep($),this.send()}return this.events=[],this.retryCount=0,!1}}async flush(){if(this.events.length===0)return!0;return this.send()}sleep(Z){return new Promise(($)=>setTimeout($,Z))}async status(){let Z=await this.loadConfig();return{enabled:Z.enabled,doNotTrack:n.env.DO_NOT_TRACK==="1"||n.env.DO_NOT_TRACK==="true",eventsQueued:this.events.length,lastSent:Z.lastSent}}async loadConfig(){if(this.config)return this.config;try{if(PZ(this.configPath)){let Z=await D1.readFile(this.configPath,"utf-8");return this.config=JSON.parse(Z),this.config}}catch{}return this.config={enabled:!1},this.config}async saveConfig(Z){this.config=Z;try{let $=O1.dirname(this.configPath);await D1.mkdir($,{recursive:!0}),await D1.writeFile(this.configPath,JSON.stringify(Z,null,2),"utf-8")}catch{}}generateUserId(){let Z=Math.random().toString(36).substring(2,15),$=Date.now().toString(36);return`${Z}-${$}`}}var P$=new s1;var a=CZ(SZ(),1);var P1="0.11.10";var N1=String.raw`^\s*-\s*\[[xX]\]\s*`,AZ=new RegExp(`${N1}<!--\\s*rebase-branch=([^>]*?)\\s*-->`,"gm"),xZ=new RegExp(`${N1}<!--\\s*rebase-all-open-prs\\s*-->`,"m"),RZ=new RegExp(`${N1}<!--\\s*manual job\\s*-->`,"m");function t1(Z){if(!Z)return{rebaseBranches:[],rebaseAll:!1,manualRun:!1};let $=[];for(let J of Z.matchAll(AZ)){let Q=J[1].trim();if(Q&&!$.includes(Q))$.push(Q)}return{rebaseBranches:$,rebaseAll:xZ.test(Z),manualRun:RZ.test(Z)}}function A1(Z){return Z.rebaseBranches.length>0||Z.rebaseAll||Z.manualRun}function o1(Z){return Z.replace(/^(\s*-\s*)\[[xX]\](\s*<!--\s*(?:rebase-branch=[^>]*?|rebase-all-open-prs|manual job)\s*-->)/gm,"$1[ ]$2")}var x1=null;async function k(Z){if(Z)return await C1(Z);if(!x1)x1=await C1();return x1}async function d(Z,$,J){if(!Z.repository?.owner||!Z.repository.name)J.error(`\u274C Repository owner and name are required for ${$}`),J.info("Configure repository.owner and repository.name in buddy.config.ts"),V.exit(1);try{return await Q0({provider:Z.repository.provider,owner:Z.repository.owner,name:Z.repository.name,...Z.repository.token?{token:Z.repository.token}:{},...Z.repository.apiUrl?{apiUrl:Z.repository.apiUrl}:{}},{logger:J})}catch(Q){J.error(`\u274C ${r(Q)}`),V.exit(1)}}async function Z0(Z,$,J){let Q=Z.filter((U)=>U.suggestion);if(Q.length===0)return J.info("No committable suggestions in this review"),0;let z=new Map;for(let U of Q){let X=z.get(U.path);if(X)X.push(U);else z.set(U.path,[U])}let Y=0;for(let[U,X]of z){let G=Bun.file(U);if(!await G.exists()){J.warn(`\u26A0\uFE0F Skipping ${U}: not in the working tree`);continue}let j=await G.text();for(let H of[...X].sort((q,K)=>K.line-q.line)){if(!$){if(!(await a.default({type:"confirm",name:"apply",message:`${U}:${H.line} \u2014 ${H.message}
42
42
  ${H.suggestion}
43
43
  Apply?`,initial:!1})).apply)continue}let q=z0(j,H.line,H.suggestion);if(q===null){J.warn(`\u26A0\uFE0F Skipping ${U}:${H.line}: the file changed since the review`);continue}j=q,Y++}await Bun.write(U,j)}return Y}async function kZ(Z,$){try{let{PackageScanner:J}=await import("../chunk-3xbx315d.js"),Q=await new J(V.cwd(),$,Z.packages?.ignorePaths).scanProject(),z=new Map;for(let Y of Q)for(let U of Y.dependencies)if(!z.has(U.name))z.set(U.name,U.currentVersion);return[...z].map(([Y,U])=>({name:Y,declaredVersion:U}))}catch(J){return $.debug(`Could not collect dependency context: ${r(J)}`),[]}}var w=new I1("buddy");w.usage(`[command] [options]
44
44
 
@@ -138,13 +138,13 @@ Scan Results:`),$.info(`\uD83D\uDCE6 Total packages: ${X.totalPackages}`),$.info
138
138
  \uD83D\uDEA8 Major updates (${G.length}):`);for(let q of G)$.info(` ${q.name}: ${q.currentVersion} \u2192 ${q.newVersion}`)}if(j.length>0){$.info(`
139
139
  \u2728 Minor updates (${j.length}):`);for(let q of j)$.info(` ${q.name}: ${q.currentVersion} \u2192 ${q.newVersion}`)}if(H.length>0){$.info(`
140
140
  \uD83D\uDD27 Patch updates (${H.length}):`);for(let q of H)$.info(` ${q.name}: ${q.currentVersion} \u2192 ${q.newVersion}`)}if(X.groups.length>0){$.info(`
141
- \uD83D\uDCCB Update groups (${X.groups.length}):`);for(let q of X.groups)$.info(` ${q.name}: ${q.updates.length} updates`)}}catch(Q){$.error("Scan failed:",Q),await g(J.notifications,"run.failed",{command:"scan",error:Q instanceof Error?Q.message:String(Q)}),V.exit(1)}});w.command("dashboard","Create or update dependency dashboard issue").option("--verbose, -v","Enable verbose logging").option("--title <title>","Custom dashboard title").option("--issue-number <number>","Update specific issue number").option("--pin","Pin the dashboard issue to the top of the issue list").option("--no-pin","Unpin the dashboard issue").example("buddy dashboard").example('buddy dashboard --title "My Dependencies"').example("buddy dashboard --issue-number 42").example("buddy dashboard --pin").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await k(Z.config);if(J.dashboard?.enabled===!1){$.info("\u2139\uFE0F Dashboard is disabled by config (dashboard.enabled: false)");return}try{if($.info("Creating or updating dependency dashboard..."),!J.repository)$.error("\u274C Repository configuration required for dashboard"),$.info("Configure repository.provider, repository.owner, repository.name in buddy.config.ts"),V.exit(1);let Q={...J,verbose:Z.verbose??J.verbose,dashboard:{...J.dashboard,enabled:!0,title:Z.title??J.dashboard?.title,issueNumber:Z.issueNumber?Number.parseInt(Z.issueNumber,10):J.dashboard?.issueNumber,pin:Z.pin??J.dashboard?.pin}},Y=await new m(Q).createOrUpdateDashboard();$.success(`\u2705 Dashboard updated: ${Y.url}`),$.info(`\uD83D\uDCCA Issue #${Y.number}: ${Y.title}`)}catch(Q){$.error("Dashboard creation failed:",Q),await g(J.notifications,"run.failed",{command:"dashboard",error:Q instanceof Error?Q.message:String(Q)}),V.exit(1)}});w.command("update","Update dependencies and create PRs").option("--verbose, -v","Enable verbose logging").option("--strategy <type>","Update strategy: major|minor|patch|all (default: packages.strategy from config, else all)").option("--ignore <names>","Comma-separated list of packages to ignore").option("--dry-run","Preview changes without making them").option("--reviewers <names>","Comma-separated reviewers to assign (overrides pullRequest.reviewers)").option("--assignees <names>","Comma-separated assignees to assign (overrides pullRequest.assignees)").option("--labels <names>","Comma-separated labels to add (overrides pullRequest.labels)").option("--respect-latest",'Respect "latest", "*", and other dynamic version indicators (default: true)').option("--no-respect-latest",'Allow updating "latest", "*", and other dynamic version indicators').example("buddy update").example("buddy update --dry-run").example("buddy update --strategy patch").example("buddy update --verbose").example("buddy update --no-respect-latest").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await k(Z.config);try{$.info("Starting dependency update process...");let Q;if(Z.ignore)Q=Z.ignore.split(",").map((K)=>K.trim());let z=(K)=>K?K.split(",").map((F)=>F.trim()).filter(Boolean):void 0,Y=z(Z.reviewers),U=z(Z.assignees),X=z(Z.labels),G={...Y?{reviewers:Y}:{},...U?{assignees:U}:{},...X?{labels:X}:{}},j={...J,verbose:Z.verbose??J.verbose,...Object.keys(G).length?{pullRequest:{...J.pullRequest,...G}}:{},packages:{...J.packages,strategy:Z.strategy??J.packages?.strategy??"all",ignore:Q??J.packages?.ignore,respectLatest:Z.respectLatest??J.packages?.respectLatest??!0}},H=new m(j),q=await H.scanForUpdates();if(q.updates.length===0){$.success("All dependencies are up to date!");return}if(Z.dryRun){$.info("\uD83D\uDD0D Dry run mode - no changes will be made"),$.info(`Would create ${q.groups.length} pull request(s):`);for(let K of q.groups)$.info(` \uD83D\uDCDD ${K.title} (${K.updates.length} updates)`);return}await H.createPullRequests(q),$.success("Update process completed!")}catch(Q){$.error("Update failed:",Q),await g(J.notifications,"run.failed",{command:"update",error:Q instanceof Error?Q.message:String(Q)}),V.exit(1)}});w.command("rebase <pr-number>","Rebase/retry a pull request by recreating it with latest updates").option("--verbose, -v","Enable verbose logging").option("--force","Force rebase even if PR appears to be up to date").example("buddy rebase 17").example("buddy rebase 17 --verbose").example("buddy rebase 17 --force").action(async(Z,$)=>{let J=$.verbose?O.verbose():O.quiet(),Q=await k($.config);try{if(J.info(`\uD83D\uDD04 Rebasing/retrying PR #${Z}...`),!Q.repository)J.error("\u274C Repository configuration required for PR operations"),J.info("Configure repository.provider, repository.owner, repository.name in buddy.config.ts"),V.exit(1);let z=await d(Q,"PR operations",J),Y=Number.parseInt(Z,10);if(Number.isNaN(Y))J.error("\u274C Invalid PR number provided"),V.exit(1);let X=(await z.getPullRequests("open")).find((M)=>M.number===Y);if(!X)J.error(`\u274C Could not find open PR #${Y}`),V.exit(1);if(!S1(X.head))J.error(`\u274C PR #${Y} is not a buddy PR (branch: ${X.head})`),V.exit(1);J.info(`\uD83D\uDCCB Found PR: ${X.title}`),J.info(`\uD83C\uDF3F Branch: ${X.head}`);let G=await bZ(X.body);if(G.length===0)J.error("\u274C Could not extract package updates from PR body"),V.exit(1);if(J.info(`\uD83D\uDCE6 Found ${G.length} packages to update`),!$.force){J.info("\uD83D\uDD0D Checking if rebase is needed...");let E=(await new m(Q).scanForUpdates()).updates.filter((R)=>G.some((h)=>h.name===R.name)),B=G.every((R)=>E.some((h)=>h.name===R.name&&h.newVersion===R.newVersion)),N=Q.repository.baseBranch||"main",b=B&&z.isBranchBehind?await z.isBranchBehind(X.head,N).catch(()=>!1):!1;if(b)J.info(`\uD83D\uDD04 ${X.head} is behind ${N}; rebasing`);if(B&&!b){J.success("\u2705 PR is already up to date, no rebase needed"),J.info("\uD83D\uDCA1 Use --force to rebase anyway");return}}J.info("\uD83D\uDD04 Updating PR with latest updates...");let j=new m({...Q,verbose:$.verbose??Q.verbose}),H=await j.scanForUpdates();if(H.updates.length===0){J.success("\u2705 All dependencies are now up to date!");return}let q=H.groups.find((M)=>M.updates.length===G.length&&M.updates.every((L)=>G.some((E)=>E.name===L.name))&&G.every((L)=>M.updates.some((E)=>E.name===L.name)));if(!q){J.error("\u274C Could not find matching update group. This likely means the package grouping has changed."),J.info(`\uD83D\uDCCB PR packages: ${G.map((M)=>M.name).join(", ")}`),J.info(`\uD83D\uDCCB Available groups: ${H.groups.map((M)=>`${M.name} (${M.updates.length} packages)`).join(", ")}`),J.info("\uD83D\uDCA1 Close this PR manually and let buddy create new ones with correct grouping");return}let K=await j.generateAllFileUpdates(q.updates);if(K.length===0){J.info(`\u2139\uFE0F No file changes generated for PR #${Y} \u2014 likely a pantry/pkgx-style dep with no JS writer. Skipping commit to avoid an empty force-push.`);let M=X.body||"",L=M.replace(/- \[x\] <!-- rebase-check -->/g,"- [ ] <!-- rebase-check -->");if(L!==M)await z.updatePullRequest(Y,{body:L}),J.info("\u2705 Unticked rebase checkbox to prevent the next update-check run from re-triggering this no-op rebase.");return}let F=Q.repository?.baseBranch||"main";await z.commitChanges(X.head,q.title,K,F),J.info(`\u2705 Recreated branch ${X.head} from ${F} with latest changes`);let{PullRequestGenerator:W}=await import("../chunk-tm8eg4sk.js"),I=(await new W({verbose:$.verbose}).generateBody(q)).replace(/- \[x\] <!-- rebase-check -->/g,"- [ ] <!-- rebase-check -->");await z.updatePullRequest(Y,{title:q.title,body:I}),J.success("\uD83D\uDD04 PR rebase completed! Updated existing PR in place.")}catch(z){J.error("Rebase failed:",z),V.exit(1)}});async function bZ(Z){let $=$0(Z);if($?.truncated)return[];if($)return J0($);let J=[],Q=/\|\s*\[([^\]]+)\][^|]*\|\s*\[?`\^?([^`]+)`\s*->\s*`\^?([^`]+)`\]?/g,z;while((z=Q.exec(Z))!==null){let[,Y,U,X]=z;J.push({name:Y,currentVersion:U,newVersion:X})}return J}w.command("update-check","Check all open buddy PRs for rebase checkbox and auto-rebase if checked").option("--verbose, -v","Enable verbose logging").option("--dry-run","Check but don't actually rebase").example("buddy update-check").example("buddy update-check --verbose").example("buddy update-check --dry-run").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await k(Z.config);try{if(!J.repository)$.error("\u274C Repository configuration required for PR operations"),$.info("Configure repository.provider, repository.owner, repository.name in buddy.config.ts"),V.exit(1);let Q=await d(J,"PR operations",$),z=await hZ(Q,J,$),Y=t1(z?.body);if(A1(Y))$.info(`\uD83D\uDCCB Dashboard requests: ${Y.rebaseBranches.length} branch(es)${Y.rebaseAll?", rebase all":""}${Y.manualRun?", manual run":""}`);let U=new Set(Y.rebaseBranches);$.info("\uD83D\uDD0D Checking for PRs with rebase checkbox enabled...");let X=0,G=0;try{let K=(await Q.getPullRequests("open")).filter((F)=>S1(F.head));$.info(`\uD83D\uDCCB Found ${K.length} buddy PRs to check for rebase requests`);for(let F of K){G++;let W=Y.rebaseAll||U.has(F.head);if(yZ(F.body||"")||W)if($.info(`\uD83D\uDD04 PR #${F.number} has rebase ${W?"requested from the dashboard":"checkbox checked"}`),Z.dryRun)$.info(`\uD83D\uDD0D [DRY RUN] Would rebase PR #${F.number}`),X++;else{$.info(`\uD83D\uDD04 Rebasing PR #${F.number} via rebase command...`);try{let{spawn:A}=await import("child_process"),I=A("bunx",["@buddysh/buddy","rebase",F.number.toString(),"--force"],{stdio:"inherit",cwd:V.cwd()});await new Promise((M,L)=>{I.on("close",(E)=>{if(E===0)X++,M(E);else L(Error(`Rebase failed with code ${E}`))})}),$.success(`\u2705 Successfully rebased PR #${F.number}`)}catch(A){$.error(`\u274C Failed to rebase PR #${F.number}:`,A)}}}if(X>0)$.success(`\u2705 ${Z.dryRun?"Would rebase":"Successfully rebased"} ${X} PR(s)`);else if(G>0)$.info("\uD83D\uDCCB No PRs have rebase checkbox enabled")}catch(q){$.warn("\u26A0\uFE0F Could not check for rebase requests:",q)}if(A1(Y)&&z){if(Z.dryRun)$.info("\uD83D\uDD0D [DRY RUN] Would clear dashboard checkboxes");else try{await Q.updateIssue(z.number,{body:o1(z.body||"")}),$.success("\u2705 Cleared dashboard checkboxes")}catch(q){$.warn("\u26A0\uFE0F Could not clear dashboard checkboxes:",q)}if(Y.manualRun)if($.info("\uD83D\uDD04 Dashboard requested a full update run..."),Z.dryRun)$.info("\uD83D\uDD0D [DRY RUN] Would run a full scan and create PRs");else try{let q=new m(J),K=await q.scanForUpdates();if(K.updates.length>0)await q.createPullRequests(K);else $.info("\u2705 No updates found during the requested run")}catch(q){$.error("\u274C Requested update run failed:",q)}}$.info(`
142
- \u2705 Checking for PRs with satisfied dependencies...`);try{let{Buddy:q}=await import("../chunk-sdhyhefy.js");await new q(J).checkAndCloseSatisfiedPRs(Q,!!Z.dryRun)}catch(q){$.error("\u26A0\uFE0F Could not check for satisfied PRs:",q)}$.info(`
143
- \uD83D\uDD0D Checking for obsolete PRs due to removed dependency files...`);try{let{Buddy:q}=await import("../chunk-sdhyhefy.js");await new q(J).checkAndCloseObsoletePRs(Q,!!Z.dryRun)}catch(q){$.error("\u26A0\uFE0F Could not check for obsolete PRs:",q)}let j=0;try{if(j=(await new m(J).mergeEligiblePullRequests(!!Z.dryRun)).length,j>0)$.success(`\uD83D\uDD00 ${Z.dryRun?"Would merge":"Merged"} ${j} PR(s)`)}catch(q){$.warn("\u26A0\uFE0F Could not process auto-merge:",q)}$.info(`
141
+ \uD83D\uDCCB Update groups (${X.groups.length}):`);for(let q of X.groups)$.info(` ${q.name}: ${q.updates.length} updates`)}}catch(Q){$.error("Scan failed:",Q),await g(J.notifications,"run.failed",{command:"scan",error:Q instanceof Error?Q.message:String(Q)}),V.exit(1)}});w.command("dashboard","Create or update dependency dashboard issue").option("--verbose, -v","Enable verbose logging").option("--title <title>","Custom dashboard title").option("--issue-number <number>","Update specific issue number").option("--pin","Pin the dashboard issue to the top of the issue list").option("--no-pin","Unpin the dashboard issue").example("buddy dashboard").example('buddy dashboard --title "My Dependencies"').example("buddy dashboard --issue-number 42").example("buddy dashboard --pin").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await k(Z.config);if(J.dashboard?.enabled===!1){$.info("\u2139\uFE0F Dashboard is disabled by config (dashboard.enabled: false)");return}try{if($.info("Creating or updating dependency dashboard..."),!J.repository)$.error("\u274C Repository configuration required for dashboard"),$.info("Configure repository.provider, repository.owner, repository.name in buddy.config.ts"),V.exit(1);let Q={...J,verbose:Z.verbose??J.verbose,dashboard:{...J.dashboard,enabled:!0,title:Z.title??J.dashboard?.title,issueNumber:Z.issueNumber?Number.parseInt(Z.issueNumber,10):J.dashboard?.issueNumber,pin:Z.pin??J.dashboard?.pin}},Y=await new m(Q).createOrUpdateDashboard();$.success(`\u2705 Dashboard updated: ${Y.url}`),$.info(`\uD83D\uDCCA Issue #${Y.number}: ${Y.title}`)}catch(Q){$.error("Dashboard creation failed:",Q),await g(J.notifications,"run.failed",{command:"dashboard",error:Q instanceof Error?Q.message:String(Q)}),V.exit(1)}});w.command("update","Update dependencies and create PRs").option("--verbose, -v","Enable verbose logging").option("--strategy <type>","Update strategy: major|minor|patch|all (default: packages.strategy from config, else all)").option("--ignore <names>","Comma-separated list of packages to ignore").option("--dry-run","Preview changes without making them").option("--reviewers <names>","Comma-separated reviewers to assign (overrides pullRequest.reviewers)").option("--assignees <names>","Comma-separated assignees to assign (overrides pullRequest.assignees)").option("--labels <names>","Comma-separated labels to add (overrides pullRequest.labels)").option("--respect-latest",'Respect "latest", "*", and other dynamic version indicators (default: true)').option("--no-respect-latest",'Allow updating "latest", "*", and other dynamic version indicators').example("buddy update").example("buddy update --dry-run").example("buddy update --strategy patch").example("buddy update --verbose").example("buddy update --no-respect-latest").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await k(Z.config);try{$.info("Starting dependency update process...");let Q;if(Z.ignore)Q=Z.ignore.split(",").map((K)=>K.trim());let z=(K)=>K?K.split(",").map((F)=>F.trim()).filter(Boolean):void 0,Y=z(Z.reviewers),U=z(Z.assignees),X=z(Z.labels),G={...Y?{reviewers:Y}:{},...U?{assignees:U}:{},...X?{labels:X}:{}},j={...J,verbose:Z.verbose??J.verbose,...Object.keys(G).length?{pullRequest:{...J.pullRequest,...G}}:{},packages:{...J.packages,strategy:Z.strategy??J.packages?.strategy??"all",ignore:Q??J.packages?.ignore,respectLatest:Z.respectLatest??J.packages?.respectLatest??!0}},H=new m(j),q=await H.scanForUpdates();if(q.updates.length===0){$.success("All dependencies are up to date!");return}if(Z.dryRun){$.info("\uD83D\uDD0D Dry run mode - no changes will be made"),$.info(`Would create ${q.groups.length} pull request(s):`);for(let K of q.groups)$.info(` \uD83D\uDCDD ${K.title} (${K.updates.length} updates)`);return}await H.createPullRequests(q),$.success("Update process completed!")}catch(Q){$.error("Update failed:",Q),await g(J.notifications,"run.failed",{command:"update",error:Q instanceof Error?Q.message:String(Q)}),V.exit(1)}});w.command("rebase <pr-number>","Rebase/retry a pull request by recreating it with latest updates").option("--verbose, -v","Enable verbose logging").option("--force","Force rebase even if PR appears to be up to date").example("buddy rebase 17").example("buddy rebase 17 --verbose").example("buddy rebase 17 --force").action(async(Z,$)=>{let J=$.verbose?O.verbose():O.quiet(),Q=await k($.config);try{if(J.info(`\uD83D\uDD04 Rebasing/retrying PR #${Z}...`),!Q.repository)J.error("\u274C Repository configuration required for PR operations"),J.info("Configure repository.provider, repository.owner, repository.name in buddy.config.ts"),V.exit(1);let z=await d(Q,"PR operations",J),Y=Number.parseInt(Z,10);if(Number.isNaN(Y))J.error("\u274C Invalid PR number provided"),V.exit(1);let X=(await z.getPullRequests("open")).find((M)=>M.number===Y);if(!X)J.error(`\u274C Could not find open PR #${Y}`),V.exit(1);if(!S1(X.head))J.error(`\u274C PR #${Y} is not a buddy PR (branch: ${X.head})`),V.exit(1);J.info(`\uD83D\uDCCB Found PR: ${X.title}`),J.info(`\uD83C\uDF3F Branch: ${X.head}`);let G=await bZ(X.body);if(G.length===0)J.error("\u274C Could not extract package updates from PR body"),V.exit(1);if(J.info(`\uD83D\uDCE6 Found ${G.length} packages to update`),!$.force){J.info("\uD83D\uDD0D Checking if rebase is needed...");let E=(await new m(Q).scanForUpdates()).updates.filter((R)=>G.some((h)=>h.name===R.name)),B=G.every((R)=>E.some((h)=>h.name===R.name&&h.newVersion===R.newVersion)),N=Q.repository.baseBranch||"main",b=B&&z.isBranchBehind?await z.isBranchBehind(X.head,N).catch(()=>!1):!1;if(b)J.info(`\uD83D\uDD04 ${X.head} is behind ${N}; rebasing`);if(B&&!b){J.success("\u2705 PR is already up to date, no rebase needed"),J.info("\uD83D\uDCA1 Use --force to rebase anyway");return}}J.info("\uD83D\uDD04 Updating PR with latest updates...");let j=new m({...Q,verbose:$.verbose??Q.verbose}),H=await j.scanForUpdates();if(H.updates.length===0){J.success("\u2705 All dependencies are now up to date!");return}let q=H.groups.find((M)=>M.updates.length===G.length&&M.updates.every((L)=>G.some((E)=>E.name===L.name))&&G.every((L)=>M.updates.some((E)=>E.name===L.name)));if(!q){J.error("\u274C Could not find matching update group. This likely means the package grouping has changed."),J.info(`\uD83D\uDCCB PR packages: ${G.map((M)=>M.name).join(", ")}`),J.info(`\uD83D\uDCCB Available groups: ${H.groups.map((M)=>`${M.name} (${M.updates.length} packages)`).join(", ")}`),J.info("\uD83D\uDCA1 Close this PR manually and let buddy create new ones with correct grouping");return}let K=await j.generateAllFileUpdates(q.updates);if(K.length===0){J.info(`\u2139\uFE0F No file changes generated for PR #${Y} \u2014 likely a pantry/pkgx-style dep with no JS writer. Skipping commit to avoid an empty force-push.`);let M=X.body||"",L=M.replace(/- \[x\] <!-- rebase-check -->/g,"- [ ] <!-- rebase-check -->");if(L!==M)await z.updatePullRequest(Y,{body:L}),J.info("\u2705 Unticked rebase checkbox to prevent the next update-check run from re-triggering this no-op rebase.");return}let F=Q.repository?.baseBranch||"main";await z.commitChanges(X.head,q.title,K,F),J.info(`\u2705 Recreated branch ${X.head} from ${F} with latest changes`);let{PullRequestGenerator:W}=await import("../chunk-97csq21c.js"),I=(await new W({verbose:$.verbose}).generateBody(q)).replace(/- \[x\] <!-- rebase-check -->/g,"- [ ] <!-- rebase-check -->");await z.updatePullRequest(Y,{title:q.title,body:I}),J.success("\uD83D\uDD04 PR rebase completed! Updated existing PR in place.")}catch(z){J.error("Rebase failed:",z),V.exit(1)}});async function bZ(Z){let $=$0(Z);if($?.truncated)return[];if($)return J0($);let J=[],Q=/\|\s*\[([^\]]+)\][^|]*\|\s*\[?`\^?([^`]+)`\s*->\s*`\^?([^`]+)`\]?/g,z;while((z=Q.exec(Z))!==null){let[,Y,U,X]=z;J.push({name:Y,currentVersion:U,newVersion:X})}return J}w.command("update-check","Check all open buddy PRs for rebase checkbox and auto-rebase if checked").option("--verbose, -v","Enable verbose logging").option("--dry-run","Check but don't actually rebase").example("buddy update-check").example("buddy update-check --verbose").example("buddy update-check --dry-run").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await k(Z.config);try{if(!J.repository)$.error("\u274C Repository configuration required for PR operations"),$.info("Configure repository.provider, repository.owner, repository.name in buddy.config.ts"),V.exit(1);let Q=await d(J,"PR operations",$),z=await hZ(Q,J,$),Y=t1(z?.body);if(A1(Y))$.info(`\uD83D\uDCCB Dashboard requests: ${Y.rebaseBranches.length} branch(es)${Y.rebaseAll?", rebase all":""}${Y.manualRun?", manual run":""}`);let U=new Set(Y.rebaseBranches);$.info("\uD83D\uDD0D Checking for PRs with rebase checkbox enabled...");let X=0,G=0;try{let K=(await Q.getPullRequests("open")).filter((F)=>S1(F.head));$.info(`\uD83D\uDCCB Found ${K.length} buddy PRs to check for rebase requests`);for(let F of K){G++;let W=Y.rebaseAll||U.has(F.head);if(yZ(F.body||"")||W)if($.info(`\uD83D\uDD04 PR #${F.number} has rebase ${W?"requested from the dashboard":"checkbox checked"}`),Z.dryRun)$.info(`\uD83D\uDD0D [DRY RUN] Would rebase PR #${F.number}`),X++;else{$.info(`\uD83D\uDD04 Rebasing PR #${F.number} via rebase command...`);try{let{spawn:A}=await import("child_process"),I=A("bunx",["@buddysh/buddy","rebase",F.number.toString(),"--force"],{stdio:"inherit",cwd:V.cwd()});await new Promise((M,L)=>{I.on("close",(E)=>{if(E===0)X++,M(E);else L(Error(`Rebase failed with code ${E}`))})}),$.success(`\u2705 Successfully rebased PR #${F.number}`)}catch(A){$.error(`\u274C Failed to rebase PR #${F.number}:`,A)}}}if(X>0)$.success(`\u2705 ${Z.dryRun?"Would rebase":"Successfully rebased"} ${X} PR(s)`);else if(G>0)$.info("\uD83D\uDCCB No PRs have rebase checkbox enabled")}catch(q){$.warn("\u26A0\uFE0F Could not check for rebase requests:",q)}if(A1(Y)&&z){if(Z.dryRun)$.info("\uD83D\uDD0D [DRY RUN] Would clear dashboard checkboxes");else try{await Q.updateIssue(z.number,{body:o1(z.body||"")}),$.success("\u2705 Cleared dashboard checkboxes")}catch(q){$.warn("\u26A0\uFE0F Could not clear dashboard checkboxes:",q)}if(Y.manualRun)if($.info("\uD83D\uDD04 Dashboard requested a full update run..."),Z.dryRun)$.info("\uD83D\uDD0D [DRY RUN] Would run a full scan and create PRs");else try{let q=new m(J),K=await q.scanForUpdates();if(K.updates.length>0)await q.createPullRequests(K);else $.info("\u2705 No updates found during the requested run")}catch(q){$.error("\u274C Requested update run failed:",q)}}$.info(`
142
+ \u2705 Checking for PRs with satisfied dependencies...`);try{let{Buddy:q}=await import("../chunk-kszbmpw1.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-kszbmpw1.js");await new q(J).checkAndCloseObsoletePRs(Q,!!Z.dryRun)}catch(q){$.error("\u26A0\uFE0F Could not check for obsolete PRs:",q)}let j=0;try{if(j=(await new m(J).mergeEligiblePullRequests(!!Z.dryRun)).length,j>0)$.success(`\uD83D\uDD00 ${Z.dryRun?"Would merge":"Merged"} ${j} PR(s)`)}catch(q){$.warn("\u26A0\uFE0F Could not process auto-merge:",q)}$.info(`
144
144
  \uD83E\uDDF9 Running branch cleanup...`),z1(Q,"branchHousekeeping","cleanupStaleBranches","branch cleanup");let H=await Q.cleanupStaleBranches(2,!!Z.dryRun);if(Z.dryRun)$.info(`\uD83D\uDD0D [DRY RUN] Would delete ${H.deleted.length} stale branches`);else $.success(`\uD83C\uDF89 Cleanup complete: ${H.deleted.length} branches deleted, ${H.failed.length} failed`);if(X>0||j>0||H.deleted.length>0)$.success(`
145
145
  \uD83C\uDF89 Update-check complete: ${X} PR(s) rebased, ${j} merged, ${H.deleted.length} branches cleaned`)}catch(Q){$.error("update-check failed:",Q),await g(J.notifications,"run.failed",{command:"update-check",error:Q instanceof Error?Q.message:String(Q)}),V.exit(1)}});async function hZ(Z,$,J){try{let Q=await Z.getIssues("open"),z=$.dashboard?.issueNumber;if(z)return Q.find((U)=>U.number===z)??null;let Y=$.dashboard?.title??"Dependency Dashboard";return Q.find((U)=>U.title===Y)??Q.find((U)=>U.title.includes("Dependency Dashboard"))??null}catch(Q){return J.warn("\u26A0\uFE0F Could not load the dependency dashboard:",Q),null}}function yZ(Z){return/\s*-\s*\[x\]\s*<!--\s*rebase-check\s*-->.*(?:rebase|update)\/retry/i.test(Z)}w.command("fix-ci","Diagnose a failing workflow run and repair it when the fix is clear").option("--verbose, -v","Enable verbose logging").option("--run-id <id>","Workflow run to diagnose").option("--pr <number>","Pull request to comment on").option("--dry-run","Report the diagnosis without acting").example("buddy fix-ci --run-id 12345").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await k(Z.config);try{let Q=await d(J,"this command",$),{runFixCi:z}=await import("../chunk-2fx0tbc0.js"),Y=await z({config:J,provider:Q,logger:$,dryRun:Boolean(Z.dryRun),...Z.runId?{runId:Number.parseInt(Z.runId,10)}:{},...Z.pr?{prNumber:Number.parseInt(Z.pr,10)}:{}});$.success(`\u2705 ${Y}`)}catch(Q){$.error("fix-ci failed:",Q),await g(J.notifications,"run.failed",{command:"fix-ci",error:Q instanceof Error?Q.message:String(Q)}),V.exit(1)}});w.command("handle-comment","Handle an @buddy command from a GitHub event payload").option("--verbose, -v","Enable verbose logging").option("--payload <path>","Path to the event payload (default: GITHUB_EVENT_PATH)").option("--dry-run","Report what would run without acting").example("buddy handle-comment").action(async(Z)=>{let $=Z.verbose?O.verbose():O.quiet(),J=await k(Z.config);try{let Q=Z.payload||V.env.GITHUB_EVENT_PATH;if(!Q)$.error("\u274C No event payload. Pass --payload or run inside GitHub Actions."),V.exit(1);let z=await Bun.file(Q).json(),Y=z.comment,U=z.issue??z.pull_request;if(!Y?.body||!U?.number){$.info("\u2139\uFE0F Event carries no comment; nothing to do");return}let{mentionsBot:X,parseCommand:G}=await import("../chunk-q90s02qc.js");if(!X(Y.body)){$.info("\u2139\uFE0F Comment does not mention buddy; nothing to do");return}let j=G(Y.body);if(!j){$.info("\u2139\uFE0F Mention is not a command (quoted or inside code); nothing to do");return}let H=await d(J,"this command",$),q=Y.user?.login??"",K=Y.user?.type==="Bot"||q.endsWith("[bot]"),F={login:q,isBot:K,canWrite:!K&&Q1(H,"permissionLookup","hasWriteAccess")?await H.hasWriteAccess(q):!1},W=Boolean(z.pull_request??z.issue?.pull_request);if($.info(`\uD83E\uDD16 Handling \`${j.name}\` from @${q} on #${U.number}`),Z.dryRun){$.info(`\uD83D\uDD0D [DRY RUN] Would run ${j.name} (canWrite: ${F.canWrite})`);return}if(Q1(H,"commentReactions","reactToComment"))await H.reactToComment(Y.id,"eyes");let{createHandlers:T,dispatchCommand:A}=await import("../chunk-q90s02qc.js"),{runReviewForPR:I}=await import("../chunk-4zvjzesh.js"),M=await A({command:j,actor:F,number:U.number,isPullRequest:W,commentId:Y.id,logger:$},T({config:J,provider:H,review:async(L,E)=>await I({config:J,provider:H,prNumber:L,logger:$,...E}),rebase:async(L)=>{let{spawn:E}=await import("child_process");return await new Promise((B,N)=>{E("bunx",["@buddysh/buddy","rebase",String(L)],{stdio:"inherit"}).on("close",(R)=>R===0?B():N(Error(`rebase exited ${R}`)))}),"Rebased."},merge:async()=>await new m(J).mergeEligiblePullRequests(!1),fixCi:async(L)=>{let{runFixCi:E}=await import("../chunk-2fx0tbc0.js");return await E({config:J,provider:H,prNumber:L,analysisOnly:!0,logger:$})},plan:async(L,E,B)=>{let{runPlan:N}=await import("../chunk-4akhxmfk.js");return await N({config:J,provider:H,number:L,isPullRequest:E,request:B,logger:$})},resolve:async(L)=>{let{resolveBuddyThreads:E}=await import("../chunk-jxd64dzs.js");return await E({provider:H,prNumber:L,logger:$})},remember:async(L,E)=>{let{addLearning:B,createLearning:N,loadLearnings:b,serializeLearnings:R,DEFAULT_LEARNINGS_FILE:h}=await import("../chunk-2145m12g.js"),v=J.repository?.baseBranch??"main",P=await b((s,p)=>H.getFileContent(s,p),v,h,$),_=N(L,{source:E.isPullRequest?{pr:E.number}:{issue:E.number}}),i=`buddy/learning-${_.id}`;return await H.commitChanges(i,"chore(buddy): record a learning",[{path:h,content:R(B(P,_)),type:"update"}],v),await H.createPullRequest({title:"chore(buddy): record a learning",body:`Recorded from #${E.number}:
146
146
 
147
- > ${L}`,head:i,base:v,draft:!1}),`Noted. I opened a pull request adding it to \`${h}\` so it gets reviewed like any other change.`}}));if(M.reply)await H.createComment(U.number,M.reply);if(Q1(H,"commentReactions","reactToComment"))await H.reactToComment(Y.id,M.handled?"rocket":"confused");$.success(M.handled?`\u2705 Handled \`${j.name}\``:`\u2139\uFE0F Did not run: ${M.refusal}`)}catch(Q){$.error("handle-comment failed:",Q),V.exit(1)}});w.command("review [pr-number]","Review a pull request, or local changes when no PR is given").option("--verbose, -v","Enable verbose logging").option("--base <branch>","Base branch to diff against for a local review").option("--staged","Review staged changes only").option("--branch","Review this branch against its base, rather than the working tree").option("--light","Analyzers only \u2014 no AI call, fast enough for a pre-commit hook").option("--format <name>","Output format: pretty|json|github|agent",{default:"pretty"}).option("--fix","Apply committable suggestions to the working tree").option("--yes","Apply fixes without confirming each one").option("--fail-on <severity>","Exit non-zero when a finding at or above this severity is found").option("--profile <name>","Review profile: chill|assertive").option("--summary-only","Post only the summary, without inline findings").option("--auto","Treat this as an automatic trigger, honouring the ai.review filters").option("--dry-run","Print the review instead of posting it").example("buddy review 42").example("buddy review --staged --light").example("buddy review --format agent | claude").action(async(Z,$)=>{let J=$.verbose?O.verbose():O.quiet(),Q=await k($.config),z=$.format??"pretty";if(!R1.includes(z))J.error(`\u274C Unknown format '${z}'. Expected one of ${R1.join(", ")}.`),V.exit(1);let Y=z!=="pretty",U=Y?O.silent():J;try{let{createAiClient:X}=await import("../chunk-2145m12g.js"),G=X(Q,U);if(!G&&(Z||!$.light))J.error("\u274C AI review needs an API key, or use --light for analyzers only. See https://buddy.sh/ai/providers"),V.exit(1);let{composeInstructions:j,reviewDiff:H}=await import("../chunk-jxd64dzs.js"),{collectLocalDiff:q,formatReview:K,shouldFail:F}=await import("../chunk-pjq0qxst.js"),{runAnalyzers:W}=await import("../chunk-gs5b2ssa.js");if(Z){let B=await d(Q,"reviewing a pull request",U),{reviewPullRequest:N}=await import("../chunk-4zvjzesh.js"),{status:b,result:R}=await N({config:Q,provider:B,prNumber:Number.parseInt(Z,10),trigger:$.auto?"automatic":"requested",...$.auto?{skipIfReviewed:!0}:{},logger:U,dryRun:Boolean($.dryRun),...$.summaryOnly?{summaryOnly:!0}:{},...$.profile?{profile:$.profile}:{}});if(J.success(`\u2705 ${b}`),await g(Q.notifications,"review.completed",{number:Number.parseInt(Z,10),findings:R?.findings.length??0}),R&&z!=="pretty")V.stdout.write(K(R,z));if(R&&$.failOn&&F(R.findings,$.failOn))V.exit(1);return}let T;{let B=$.base||Q.repository?.baseBranch||"main",N=$.staged?"staged":$.branch?"branch":"working";U.info(`\uD83D\uDD0D Reviewing ${N} changes${N==="branch"?` against ${B}`:""}...`),T=await q(N,B)}if(!T.trim()){if(!Y)J.success("\u2705 No changes to review");return}let{parseUnifiedDiff:A}=await import("../chunk-7ds5q6j3.js"),I=A(T).files.map((B)=>B.path),M=Q.analysis?.enabled===!1?{findings:[],ran:[],skipped:[]}:await W({files:I,root:V.cwd(),...Q.analysis?.tools?{enabled:Q.analysis.tools}:{},logger:U});if($.light){let B={summary:`Static analysis of ${I.length} changed file(s).`,walkthrough:[],findings:M.findings,effort:1,omittedFiles:M.skipped.map((N)=>`${N.name} (${N.reason})`)};if(V.stdout.write(K(B,z)),$.fix){let N=await Z0(B.findings,Boolean($.yes),J);J.success(`\uD83D\uDD27 Applied ${N} suggestion(s)`)}if($.failOn&&F(B.findings,$.failOn))V.exit(1);return}let L=await H(G,{diff:T,profile:$.profile??Q.ai?.review?.profile,summaryOnly:$.summaryOnly??Q.ai?.review?.summaryOnly,instructions:j({global:Q.ai?.review?.instructions}),pathFilters:Q.ai?.review?.pathFilters,pathInstructions:Q.ai?.review?.pathInstructions,seenFingerprints:[],logger:U}),E={...L,findings:[...M.findings,...L.findings],omittedFiles:[...L.omittedFiles,...M.skipped.map((B)=>`${B.name} (${B.reason})`)]};if(V.stdout.write(K(E,z)),$.fix){let B=await Z0(E.findings,Boolean($.yes),J);J.success(`\uD83D\uDD27 Applied ${B} suggestion(s)`)}if($.failOn&&F(E.findings,$.failOn))V.exit(1)}catch(X){J.error("Review failed:",X),await g(Q.notifications,"run.failed",{command:"review",error:X instanceof Error?X.message:String(X)}),V.exit(1)}});w.command("check <packages...>","Check specific packages for updates").option("--verbose, -v","Enable verbose logging").option("--strategy <type>","Update strategy: major|minor|patch|all (default: packages.strategy from config, else all)").example("buddy check react typescript").example("buddy check react --verbose").action(async(...Z)=>{let $=Z[Z.length-1],J=Z.slice(0,-1),Q=$.verbose?O.verbose():O.quiet(),z=await k($.config);if(!J.length)Q.error("No packages specified to check"),V.exit(1);try{Q.info(`Checking specific packages: ${J.join(", ")}`);let Y={...z,verbose:$.verbose??z.verbose,packages:{...z.packages,strategy:$.strategy??z.packages?.strategy??"all"}},X=await new m(Y).checkPackages(J);if(X.length===0)Q.success("All specified packages are up to date!");else{Q.info(`Found ${X.length} updates:`);for(let G of X)Q.info(` ${G.name}: ${G.currentVersion} \u2192 ${G.newVersion} (${G.updateType})`)}}catch(Y){Q.error("Check failed:",Y),V.exit(1)}});w.command("schedule","Run automated dependency updates on schedule").option("--verbose, -v","Enable verbose logging").option("--strategy <type>","Update strategy: major|minor|patch|all (default: packages.strategy from config, else all)").example("buddy schedule").example("buddy schedule --verbose").example("buddy schedule --strategy patch").action(async(Z)=>{let{Scheduler:$}=await import("../chunk-sxdfmskp.js"),J=Z.verbose?O.verbose():O.quiet(),Q=await k(Z.config);try{J.info("\uD83D\uDD52 Starting Buddy Scheduler...");let z;if(Z.ignore)z=Z.ignore.split(",").map((G)=>G.trim());let Y={...Q,verbose:Z.verbose??Q.verbose,packages:{...Q.packages,strategy:Z.strategy??Q.packages?.strategy??"all",ignore:z??Q.packages?.ignore}};if(!Y.repository?.provider||!Y.repository?.owner||!Y.repository?.name)J.error("\u274C Repository configuration required for scheduling. Please configure:"),J.info(" - repository.provider (github)"),J.info(" - repository.owner"),J.info(" - repository.name"),J.info(" - repository.token (via environment variable)"),V.exit(1);let U=new $(Z.verbose),X=$.createJobFromConfig(Y,"cli-schedule");if(Z.strategy)switch(Z.strategy){case"major":X.schedule.cron=$.PRESETS.WEEKLY;break;case"minor":X.schedule.cron=$.PRESETS.TWICE_WEEKLY;break;case"patch":X.schedule.cron=$.PRESETS.DAILY;break;default:X.schedule.cron=$.PRESETS.WEEKLY}U.addJob(X),U.start(),J.success(`\u2705 Scheduler started with cron: ${X.schedule.cron}`),J.info("\uD83D\uDCC5 Next run:",X.nextRun?.toISOString()||"Unknown"),J.info("\uD83D\uDED1 Press Ctrl+C to stop the scheduler"),V.stdin.resume()}catch(z){J.error("Scheduler failed:",z),V.exit(1)}});w.command("generate-workflows",'Generate GitHub Actions workflow templates (deprecated - use "setup" instead)').option("--verbose, -v","Enable verbose logging").example("buddy generate-workflows").example("buddy generate-workflows --verbose").action(async(Z)=>{let{GitHubActionsTemplate:$}=await import("../chunk-7ze1qrmt.js"),{writeFileSync:J,mkdirSync:Q}=await import("fs"),{resolve:z}=await import("path"),Y=Z.verbose?O.verbose():O.quiet(),U=await k(Z.config);if(U.workflows?.enabled===!1){Y.info("\u2139\uFE0F Workflow generation is disabled by config (workflows.enabled: false)");return}console.log('\u26A0\uFE0F The "generate-workflows" command is deprecated.'),console.log(`\uD83D\uDCA1 Use "buddy setup" for a better interactive experience.
147
+ > ${L}`,head:i,base:v,draft:!1}),`Noted. I opened a pull request adding it to \`${h}\` so it gets reviewed like any other change.`}}));if(M.reply)await H.createComment(U.number,M.reply);if(Q1(H,"commentReactions","reactToComment"))await H.reactToComment(Y.id,M.handled?"rocket":"confused");$.success(M.handled?`\u2705 Handled \`${j.name}\``:`\u2139\uFE0F Did not run: ${M.refusal}`)}catch(Q){$.error("handle-comment failed:",Q),V.exit(1)}});w.command("review [pr-number]","Review a pull request, or local changes when no PR is given").option("--verbose, -v","Enable verbose logging").option("--base <branch>","Base branch to diff against for a local review").option("--staged","Review staged changes only").option("--branch","Review this branch against its base, rather than the working tree").option("--light","Analyzers only \u2014 no AI call, fast enough for a pre-commit hook").option("--format <name>","Output format: pretty|json|github|agent",{default:"pretty"}).option("--fix","Apply committable suggestions to the working tree").option("--yes","Apply fixes without confirming each one").option("--fail-on <severity>","Exit non-zero when a finding at or above this severity is found").option("--profile <name>","Review profile: chill|assertive").option("--summary-only","Post only the summary, without inline findings").option("--auto","Treat this as an automatic trigger, honouring the ai.review filters").option("--dry-run","Print the review instead of posting it").example("buddy review 42").example("buddy review --staged --light").example("buddy review --format agent | claude").action(async(Z,$)=>{let J=$.verbose?O.verbose():O.quiet(),Q=await k($.config),z=$.format??"pretty";if(!R1.includes(z))J.error(`\u274C Unknown format '${z}'. Expected one of ${R1.join(", ")}.`),V.exit(1);let Y=z!=="pretty",U=Y?O.silent():J;try{let{createAiClient:X}=await import("../chunk-2145m12g.js"),G=X(Q,U);if(!G&&(Z||!$.light))J.error("\u274C AI review needs an API key, or use --light for analyzers only. See https://buddy.sh/ai/providers"),V.exit(1);let{composeInstructions:j,reviewDiff:H}=await import("../chunk-jxd64dzs.js"),{collectLocalDiff:q,formatReview:K,shouldFail:F}=await import("../chunk-pjq0qxst.js"),{runAnalyzers:W}=await import("../chunk-gs5b2ssa.js");if(Z){let B=await d(Q,"reviewing a pull request",U),{reviewPullRequest:N}=await import("../chunk-4zvjzesh.js"),{status:b,result:R}=await N({config:Q,provider:B,prNumber:Number.parseInt(Z,10),trigger:$.auto?"automatic":"requested",...$.auto?{skipIfReviewed:!0}:{},logger:U,dryRun:Boolean($.dryRun),...$.summaryOnly?{summaryOnly:!0}:{},...$.profile?{profile:$.profile}:{}});if(J.success(`\u2705 ${b}`),await g(Q.notifications,"review.completed",{number:Number.parseInt(Z,10),findings:R?.findings.length??0}),R&&z!=="pretty")V.stdout.write(K(R,z));if(R&&$.failOn&&F(R.findings,$.failOn))V.exit(1);return}let T;{let B=$.base||Q.repository?.baseBranch||"main",N=$.staged?"staged":$.branch?"branch":"working";U.info(`\uD83D\uDD0D Reviewing ${N} changes${N==="branch"?` against ${B}`:""}...`),T=await q(N,B)}if(!T.trim()){if(!Y)J.success("\u2705 No changes to review");return}let{parseUnifiedDiff:A}=await import("../chunk-7ds5q6j3.js"),I=A(T).files.map((B)=>B.path),M=Q.analysis?.enabled===!1?{findings:[],ran:[],skipped:[]}:await W({files:I,root:V.cwd(),...Q.analysis?.tools?{enabled:Q.analysis.tools}:{},logger:U});if($.light){let B={summary:`Static analysis of ${I.length} changed file(s).`,walkthrough:[],findings:M.findings,effort:1,omittedFiles:M.skipped.map((N)=>`${N.name} (${N.reason})`)};if(V.stdout.write(K(B,z)),$.fix){let N=await Z0(B.findings,Boolean($.yes),J);J.success(`\uD83D\uDD27 Applied ${N} suggestion(s)`)}if($.failOn&&F(B.findings,$.failOn))V.exit(1);return}let L=await H(G,{diff:T,profile:$.profile??Q.ai?.review?.profile,summaryOnly:$.summaryOnly??Q.ai?.review?.summaryOnly,instructions:j({global:Q.ai?.review?.instructions}),pathFilters:Q.ai?.review?.pathFilters,pathInstructions:Q.ai?.review?.pathInstructions,seenFingerprints:[],logger:U}),E={...L,findings:[...M.findings,...L.findings],omittedFiles:[...L.omittedFiles,...M.skipped.map((B)=>`${B.name} (${B.reason})`)]};if(V.stdout.write(K(E,z)),$.fix){let B=await Z0(E.findings,Boolean($.yes),J);J.success(`\uD83D\uDD27 Applied ${B} suggestion(s)`)}if($.failOn&&F(E.findings,$.failOn))V.exit(1)}catch(X){J.error("Review failed:",X),await g(Q.notifications,"run.failed",{command:"review",error:X instanceof Error?X.message:String(X)}),V.exit(1)}});w.command("check <packages...>","Check specific packages for updates").option("--verbose, -v","Enable verbose logging").option("--strategy <type>","Update strategy: major|minor|patch|all (default: packages.strategy from config, else all)").example("buddy check react typescript").example("buddy check react --verbose").action(async(...Z)=>{let $=Z[Z.length-1],J=Z.slice(0,-1),Q=$.verbose?O.verbose():O.quiet(),z=await k($.config);if(!J.length)Q.error("No packages specified to check"),V.exit(1);try{Q.info(`Checking specific packages: ${J.join(", ")}`);let Y={...z,verbose:$.verbose??z.verbose,packages:{...z.packages,strategy:$.strategy??z.packages?.strategy??"all"}},X=await new m(Y).checkPackages(J);if(X.length===0)Q.success("All specified packages are up to date!");else{Q.info(`Found ${X.length} updates:`);for(let G of X)Q.info(` ${G.name}: ${G.currentVersion} \u2192 ${G.newVersion} (${G.updateType})`)}}catch(Y){Q.error("Check failed:",Y),V.exit(1)}});w.command("schedule","Run automated dependency updates on schedule").option("--verbose, -v","Enable verbose logging").option("--strategy <type>","Update strategy: major|minor|patch|all (default: packages.strategy from config, else all)").example("buddy schedule").example("buddy schedule --verbose").example("buddy schedule --strategy patch").action(async(Z)=>{let{Scheduler:$}=await import("../chunk-x5jfh372.js"),J=Z.verbose?O.verbose():O.quiet(),Q=await k(Z.config);try{J.info("\uD83D\uDD52 Starting Buddy Scheduler...");let z;if(Z.ignore)z=Z.ignore.split(",").map((G)=>G.trim());let Y={...Q,verbose:Z.verbose??Q.verbose,packages:{...Q.packages,strategy:Z.strategy??Q.packages?.strategy??"all",ignore:z??Q.packages?.ignore}};if(!Y.repository?.provider||!Y.repository?.owner||!Y.repository?.name)J.error("\u274C Repository configuration required for scheduling. Please configure:"),J.info(" - repository.provider (github)"),J.info(" - repository.owner"),J.info(" - repository.name"),J.info(" - repository.token (via environment variable)"),V.exit(1);let U=new $(Z.verbose),X=$.createJobFromConfig(Y,"cli-schedule");if(Z.strategy)switch(Z.strategy){case"major":X.schedule.cron=$.PRESETS.WEEKLY;break;case"minor":X.schedule.cron=$.PRESETS.TWICE_WEEKLY;break;case"patch":X.schedule.cron=$.PRESETS.DAILY;break;default:X.schedule.cron=$.PRESETS.WEEKLY}U.addJob(X),U.start(),J.success(`\u2705 Scheduler started with cron: ${X.schedule.cron}`),J.info("\uD83D\uDCC5 Next run:",X.nextRun?.toISOString()||"Unknown"),J.info("\uD83D\uDED1 Press Ctrl+C to stop the scheduler"),V.stdin.resume()}catch(z){J.error("Scheduler failed:",z),V.exit(1)}});w.command("generate-workflows",'Generate GitHub Actions workflow templates (deprecated - use "setup" instead)').option("--verbose, -v","Enable verbose logging").example("buddy generate-workflows").example("buddy generate-workflows --verbose").action(async(Z)=>{let{GitHubActionsTemplate:$}=await import("../chunk-7ze1qrmt.js"),{writeFileSync:J,mkdirSync:Q}=await import("fs"),{resolve:z}=await import("path"),Y=Z.verbose?O.verbose():O.quiet(),U=await k(Z.config);if(U.workflows?.enabled===!1){Y.info("\u2139\uFE0F Workflow generation is disabled by config (workflows.enabled: false)");return}console.log('\u26A0\uFE0F The "generate-workflows" command is deprecated.'),console.log(`\uD83D\uDCA1 Use "buddy setup" for a better interactive experience.
148
148
  `);try{let X={...U,verbose:Z.verbose??U.verbose},G=X.workflows?.outputDir?z(V.cwd(),X.workflows.outputDir):z(V.cwd(),".github","workflows");Y.info("\uD83D\uDE80 Generating GitHub Actions workflow templates...");try{Q(G,{recursive:!0})}catch{}let j=X.workflows?.templates||{comprehensive:!0,daily:!0,weekly:!0,monthly:!0,docker:!0,monorepo:!0},H=0;if(j.daily||j.weekly||j.monthly){let q=$.generateScheduledWorkflows(X);for(let[K,F]of Object.entries(q))if(K.includes("daily")&&j.daily||K.includes("weekly")&&j.weekly||K.includes("monthly")&&j.monthly){let T=z(G,K);J(T,F),Y.success(`Generated: ${K}`),H++}}if(j.comprehensive){let q=$.generateComprehensiveWorkflow(X);J(z(G,"buddy-comprehensive.yml"),q),Y.success("Generated: buddy-comprehensive.yml"),H++}if(j.docker){let q=$.generateDockerWorkflow(X);J(z(G,"buddy-docker.yml"),q),Y.success("Generated: buddy-docker.yml"),H++}if(j.monorepo){let q=$.generateMonorepoWorkflow(X);J(z(G,"buddy-monorepo.yml"),q),Y.success("Generated: buddy-monorepo.yml"),H++}if(X.workflows?.custom?.length)for(let q of X.workflows.custom){let K=$.generateCustomWorkflow(q,X),F=`buddy-${q.name.toLowerCase().replace(/\s+/g,"-")}.yml`;J(z(G,F),K),Y.success(`Generated: ${F}`),H++}if(H===0){Y.warn("No workflows were generated. Check your configuration in buddy.config.ts"),Y.info("Set workflows.templates to enable specific templates or add custom workflows.");return}Y.success(`
149
149
  \uD83C\uDF89 ${H} GitHub Actions workflow(s) generated!`),Y.info(`\uD83D\uDCC1 Location: ${G}`),Y.info(`
150
150
  \uD83D\uDCA1 Next steps:`),Y.info(" 1. Review and customize the workflows for your project"),Y.info(" 2. Ensure GITHUB_TOKEN is available as a secret"),Y.info(" 3. Configure buddy.config.ts with your repository settings"),Y.info(" 4. Enable GitHub Actions in your repository settings"),Y.info(`
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{dd as Z}from"./chunk-r7nh070r.js";import{Mh as _}from"./chunk-8dj94fsy.js";import Y from"process";class L{jobs=new Map;timers=new Map;logger;isRunning=!1;constructor(q=!1){this.logger=q?_.verbose():_.quiet()}addJob(q){this.jobs.set(q.id,q),this.scheduleJob(q),this.logger.info(`Scheduled job '${q.name}' with cron: ${q.schedule.cron}`)}removeJob(q){let C=this.timers.get(q);if(C)clearTimeout(C),this.timers.delete(q);this.jobs.delete(q),this.logger.info(`Removed scheduled job: ${q}`)}start(){if(this.isRunning){this.logger.warn("Scheduler is already running");return}this.isRunning=!0,this.logger.info("\uD83D\uDD52 Buddy Scheduler started");for(let q of this.jobs.values())if(this.scheduleJob(q),q.schedule.runOnStartup)this.logger.info(`Running startup job: ${q.name}`),setImmediate(()=>this.runJob(q));Y.on("SIGINT",()=>this.stop()),Y.on("SIGTERM",()=>this.stop())}stop(){if(!this.isRunning)return;this.isRunning=!1,this.logger.info("\uD83D\uDED1 Stopping Buddy Scheduler...");for(let q of this.timers.values())clearTimeout(q);this.timers.clear(),this.logger.success("\u2705 Buddy Scheduler stopped"),Y.exit(0)}getJobStatus(q){return this.jobs.get(q)}getAllJobs(){return Array.from(this.jobs.values())}scheduleJob(q){let C=this.timers.get(q.id);if(C)clearTimeout(C);let D=this.getNextRunTime(q.schedule.cron,q.schedule.timezone);if(q.nextRun=D||void 0,D){let G=D.getTime()-Date.now(),F=setTimeout(()=>{this.runJob(q),this.scheduleJob(q)},G);this.timers.set(q.id,F),this.logger.debug(`Job '${q.name}' scheduled for ${D.toISOString()}`)}}async runJob(q){if(q.status==="running"){this.logger.warn(`Job '${q.name}' is already running, skipping`);return}q.status="running",q.lastRun=new Date,this.logger.info(`\uD83D\uDE80 Running scheduled job: ${q.name}`);let C=Date.now(),D=q.schedule.maxRuntime||1800000;try{let G=new Promise((Q,U)=>{setTimeout(()=>U(Error("Job timeout")),D)}),F=this.executeJob(q);await Promise.race([F,G]);let J=Date.now()-C;q.status="idle",this.logger.success(`\u2705 Job '${q.name}' completed in ${J}ms`)}catch(G){q.status="error",this.logger.error(`\u274C Job '${q.name}' failed:`,G)}}async executeJob(q){let C=new Z(q.config),D=await C.scanForUpdates();if(D.updates.length===0){this.logger.info("No dependency updates found");return}if(this.logger.info(`Found ${D.updates.length} dependency updates`),q.config.repository&&q.config.pullRequest)await C.createPullRequests(D),this.logger.success(`Created pull requests for ${D.groups.length} update groups`);else this.logger.info("Repository not configured, skipping PR creation")}getNextRunTime(q,C){try{return this.parseCronExpression(q,C)}catch(D){return this.logger.error(`Invalid cron expression '${q}':`,D),null}}parseCronExpression(q,C){let D=q.trim().split(/\s+/);if(D.length!==5)throw Error("Cron expression must have 5 parts: minute hour day month dayOfWeek");let[G,F,J,Q,U]=D,K=new Date,V=C?this.timezoneOffsetMinutes(K,C):0;if(C)this.logger.debug(`Using timezone: ${C} (offset ${V} minutes)`);let X=new Date(K.getTime()+V*60*1000);X.setSeconds(0,0);let $=this.parseCronField(F,0,23),B=this.parseCronField(G,0,59);if($.length>0&&B.length>0){if(X.setHours($[0],B[0],0,0),X.getTime()-V*60*1000<=K.getTime())X.setDate(X.getDate()+1);return new Date(X.getTime()-V*60*1000)}return new Date(K.getTime()+3600000)}timezoneOffsetMinutes(q,C){try{let D=new Date(q.toLocaleString("en-US",{timeZone:C})),G=new Date(q.toLocaleString("en-US"));return Math.round((D.getTime()-G.getTime())/60000)}catch{return this.logger.warn(`\u26A0\uFE0F Unknown timezone "${C}", scheduling in host time instead`),0}}parseCronField(q,C,D){if(q==="*")return Array.from({length:D-C+1},(F,J)=>C+J);if(q.includes(","))return q.split(",").map(Number).filter((F)=>Number.isFinite(F)&&F>=C&&F<=D);if(q.includes("-")){let F=q.split("-").map(Number),J=F[0],Q=F[1];if(F.length!==2||!Number.isFinite(J)||!Number.isFinite(Q)||Q<J)return[];return Array.from({length:Q-J+1},(U,K)=>J+K).filter((U)=>U>=C&&U<=D)}if(q.includes("/")){let[F,J]=q.split("/"),Q=Number(J);if(!Number.isFinite(Q)||Q<=0)return[];if(F==="*")return Array.from({length:D-C+1},(K,V)=>C+V).filter((K,V)=>V%Q===0);let U=Number(F);return Number.isFinite(U)?[U].filter((K)=>K>=C&&K<=D):[]}let G=Number(q);return Number.isFinite(G)&&G>=C&&G<=D?[G]:[]}static createJobFromConfig(q,C="default"){let D={cron:q.schedule?.cron||"0 2 * * 1",timezone:q.schedule?.timezone,runOnStartup:!1,maxRuntime:1800000};return{id:C,name:`Buddy Dependency Updates (${C})`,schedule:D,status:"idle",config:q}}static PRESETS={DAILY:"0 2 * * *",WEEKLY:"0 2 * * 1",WEEKDAYS:"0 2 * * 1-5",TWICE_WEEKLY:"0 2 * * 1,4",MONTHLY:"0 2 1 * *",HOURLY:"0 * * * *",CUSTOM:(q,C,D="*")=>`${q} ${C} * * ${D}`}}
2
+ import{dd as Z}from"./chunk-785rgtn5.js";import{Mh as _}from"./chunk-8dj94fsy.js";import Y from"process";class L{jobs=new Map;timers=new Map;logger;isRunning=!1;constructor(q=!1){this.logger=q?_.verbose():_.quiet()}addJob(q){this.jobs.set(q.id,q),this.scheduleJob(q),this.logger.info(`Scheduled job '${q.name}' with cron: ${q.schedule.cron}`)}removeJob(q){let C=this.timers.get(q);if(C)clearTimeout(C),this.timers.delete(q);this.jobs.delete(q),this.logger.info(`Removed scheduled job: ${q}`)}start(){if(this.isRunning){this.logger.warn("Scheduler is already running");return}this.isRunning=!0,this.logger.info("\uD83D\uDD52 Buddy Scheduler started");for(let q of this.jobs.values())if(this.scheduleJob(q),q.schedule.runOnStartup)this.logger.info(`Running startup job: ${q.name}`),setImmediate(()=>this.runJob(q));Y.on("SIGINT",()=>this.stop()),Y.on("SIGTERM",()=>this.stop())}stop(){if(!this.isRunning)return;this.isRunning=!1,this.logger.info("\uD83D\uDED1 Stopping Buddy Scheduler...");for(let q of this.timers.values())clearTimeout(q);this.timers.clear(),this.logger.success("\u2705 Buddy Scheduler stopped"),Y.exit(0)}getJobStatus(q){return this.jobs.get(q)}getAllJobs(){return Array.from(this.jobs.values())}scheduleJob(q){let C=this.timers.get(q.id);if(C)clearTimeout(C);let D=this.getNextRunTime(q.schedule.cron,q.schedule.timezone);if(q.nextRun=D||void 0,D){let G=D.getTime()-Date.now(),F=setTimeout(()=>{this.runJob(q),this.scheduleJob(q)},G);this.timers.set(q.id,F),this.logger.debug(`Job '${q.name}' scheduled for ${D.toISOString()}`)}}async runJob(q){if(q.status==="running"){this.logger.warn(`Job '${q.name}' is already running, skipping`);return}q.status="running",q.lastRun=new Date,this.logger.info(`\uD83D\uDE80 Running scheduled job: ${q.name}`);let C=Date.now(),D=q.schedule.maxRuntime||1800000;try{let G=new Promise((Q,U)=>{setTimeout(()=>U(Error("Job timeout")),D)}),F=this.executeJob(q);await Promise.race([F,G]);let J=Date.now()-C;q.status="idle",this.logger.success(`\u2705 Job '${q.name}' completed in ${J}ms`)}catch(G){q.status="error",this.logger.error(`\u274C Job '${q.name}' failed:`,G)}}async executeJob(q){let C=new Z(q.config),D=await C.scanForUpdates();if(D.updates.length===0){this.logger.info("No dependency updates found");return}if(this.logger.info(`Found ${D.updates.length} dependency updates`),q.config.repository&&q.config.pullRequest)await C.createPullRequests(D),this.logger.success(`Created pull requests for ${D.groups.length} update groups`);else this.logger.info("Repository not configured, skipping PR creation")}getNextRunTime(q,C){try{return this.parseCronExpression(q,C)}catch(D){return this.logger.error(`Invalid cron expression '${q}':`,D),null}}parseCronExpression(q,C){let D=q.trim().split(/\s+/);if(D.length!==5)throw Error("Cron expression must have 5 parts: minute hour day month dayOfWeek");let[G,F,J,Q,U]=D,K=new Date,V=C?this.timezoneOffsetMinutes(K,C):0;if(C)this.logger.debug(`Using timezone: ${C} (offset ${V} minutes)`);let X=new Date(K.getTime()+V*60*1000);X.setSeconds(0,0);let $=this.parseCronField(F,0,23),B=this.parseCronField(G,0,59);if($.length>0&&B.length>0){if(X.setHours($[0],B[0],0,0),X.getTime()-V*60*1000<=K.getTime())X.setDate(X.getDate()+1);return new Date(X.getTime()-V*60*1000)}return new Date(K.getTime()+3600000)}timezoneOffsetMinutes(q,C){try{let D=new Date(q.toLocaleString("en-US",{timeZone:C})),G=new Date(q.toLocaleString("en-US"));return Math.round((D.getTime()-G.getTime())/60000)}catch{return this.logger.warn(`\u26A0\uFE0F Unknown timezone "${C}", scheduling in host time instead`),0}}parseCronField(q,C,D){if(q==="*")return Array.from({length:D-C+1},(F,J)=>C+J);if(q.includes(","))return q.split(",").map(Number).filter((F)=>Number.isFinite(F)&&F>=C&&F<=D);if(q.includes("-")){let F=q.split("-").map(Number),J=F[0],Q=F[1];if(F.length!==2||!Number.isFinite(J)||!Number.isFinite(Q)||Q<J)return[];return Array.from({length:Q-J+1},(U,K)=>J+K).filter((U)=>U>=C&&U<=D)}if(q.includes("/")){let[F,J]=q.split("/"),Q=Number(J);if(!Number.isFinite(Q)||Q<=0)return[];if(F==="*")return Array.from({length:D-C+1},(K,V)=>C+V).filter((K,V)=>V%Q===0);let U=Number(F);return Number.isFinite(U)?[U].filter((K)=>K>=C&&K<=D):[]}let G=Number(q);return Number.isFinite(G)&&G>=C&&G<=D?[G]:[]}static createJobFromConfig(q,C="default"){let D={cron:q.schedule?.cron||"0 2 * * 1",timezone:q.schedule?.timezone,runOnStartup:!1,maxRuntime:1800000};return{id:C,name:`Buddy Dependency Updates (${C})`,schedule:D,status:"idle",config:q}}static PRESETS={DAILY:"0 2 * * *",WEEKLY:"0 2 * * 1",WEEKDAYS:"0 2 * * 1-5",TWICE_WEEKLY:"0 2 * * 1,4",MONTHLY:"0 2 1 * *",HOURLY:"0 * * * *",CUSTOM:(q,C,D="*")=>`${q} ${C} * * ${D}`}}
3
3
  export{L as Da};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{ed as oX}from"./chunk-p9z0hzej.js";import{gd as TX,hd as FX,id as CX,jd as cX}from"./chunk-amj037yy.js";import{kd as uX}from"./chunk-4wbbbcs2.js";import{qd as jX,rd as JX,sd as mX}from"./chunk-p5yaf72b.js";import{vd as gX,yd as lX}from"./chunk-7crh00m7.js";import{pe as QX,qe as i}from"./chunk-34rmja4x.js";import{qf as fX}from"./chunk-3waqfh3y.js";import{tf as u,uf as hX,vf as zX,wf as yX,xf as n}from"./chunk-k7x9af5r.js";import{hg as OX,ig as PX,jg as f}from"./chunk-wreexgkb.js";import{sg as c,wg as vX,xg as kX}from"./chunk-gvnsr72j.js";import{xh as p}from"./chunk-6k6dgwmy.js";import{Dh as v}from"./chunk-pxdrwhxx.js";import{Ih as HX}from"./chunk-a3bnhq58.js";import{Kh as RX,Lh as $X,Mh as UX,Nh as bX}from"./chunk-8dj94fsy.js";import{dl as G}from"./chunk-s3ksf6s5.js";import xX from"fs";import{join as XX}from"path";import m from"process";var iX={critical:"\uD83D\uDD34 Critical",high:"\uD83D\uDFE0 High",moderate:"\uD83D\uDFE1 Moderate",low:"\u26AA Low"};class KX{generateDashboard(X,$={}){let{showOpenPRs:Q=!0,showDetectedDependencies:Y=!0,showDeprecatedDependencies:Z=!0,showVulnerableDependencies:K=!0,includePackageJson:W=!0,includeDependencyFiles:_=!0,includeGitHubActions:z=!0,bodyTemplate:L}=$,O="Dependency Dashboard";if(L)return{title:"Dependency Dashboard",body:this.applyTemplate(L,X)};let H=this.generateDefaultHeader(X);if(K&&X.vulnerableDependencies&&X.vulnerableDependencies.length>0)H+=this.generateVulnerableDependenciesSection(X.vulnerableDependencies);if(Z&&X.deprecatedDependencies&&X.deprecatedDependencies.length>0)H+=this.generateDeprecatedDependenciesSection(X.deprecatedDependencies);if(Q&&X.openPRs.length>0)H+=this.generateOpenPRsSection(X.openPRs);if(X.cappedDependencies&&X.cappedDependencies.length>0)H+=this.generateCappedDependenciesSection(X.cappedDependencies);if(Y)H+=this.generateDetectedDependenciesSection({packageJson:W?X.detectedDependencies.packageJson:[],dependencyFiles:_?X.detectedDependencies.dependencyFiles:[],githubActions:z?X.detectedDependencies.githubActions:[]});return H+=this.generateFooter(),{title:"Dependency Dashboard",body:H}}generateDefaultHeader(X){return`This issue lists Buddy updates and detected dependencies. Read the [Dependency Dashboard](https://buddy.sh/features/dependency-dashboard) docs to learn more.
2
+ import{ed as oX}from"./chunk-p9z0hzej.js";import{gd as TX,hd as FX,id as CX,jd as cX}from"./chunk-amj037yy.js";import{kd as uX}from"./chunk-4wbbbcs2.js";import{qd as jX,rd as JX,sd as mX}from"./chunk-yxb1jwxp.js";import{vd as gX,yd as lX}from"./chunk-7crh00m7.js";import{pe as QX,qe as i}from"./chunk-34rmja4x.js";import{qf as fX}from"./chunk-3waqfh3y.js";import{tf as u,uf as hX,vf as zX,wf as yX,xf as n}from"./chunk-k7x9af5r.js";import{hg as OX,ig as PX,jg as f}from"./chunk-wreexgkb.js";import{sg as c,wg as vX,xg as kX}from"./chunk-gvnsr72j.js";import{xh as p}from"./chunk-6k6dgwmy.js";import{Dh as v}from"./chunk-pxdrwhxx.js";import{Ih as HX}from"./chunk-a3bnhq58.js";import{Kh as RX,Lh as $X,Mh as UX,Nh as bX}from"./chunk-8dj94fsy.js";import{dl as G}from"./chunk-s3ksf6s5.js";import xX from"fs";import{join as XX}from"path";import m from"process";var iX={critical:"\uD83D\uDD34 Critical",high:"\uD83D\uDFE0 High",moderate:"\uD83D\uDFE1 Moderate",low:"\u26AA Low"};class KX{generateDashboard(X,$={}){let{showOpenPRs:Q=!0,showDetectedDependencies:Y=!0,showDeprecatedDependencies:Z=!0,showVulnerableDependencies:K=!0,includePackageJson:W=!0,includeDependencyFiles:_=!0,includeGitHubActions:z=!0,bodyTemplate:L}=$,O="Dependency Dashboard";if(L)return{title:"Dependency Dashboard",body:this.applyTemplate(L,X)};let H=this.generateDefaultHeader(X);if(K&&X.vulnerableDependencies&&X.vulnerableDependencies.length>0)H+=this.generateVulnerableDependenciesSection(X.vulnerableDependencies);if(Z&&X.deprecatedDependencies&&X.deprecatedDependencies.length>0)H+=this.generateDeprecatedDependenciesSection(X.deprecatedDependencies);if(Q&&X.openPRs.length>0)H+=this.generateOpenPRsSection(X.openPRs);if(X.cappedDependencies&&X.cappedDependencies.length>0)H+=this.generateCappedDependenciesSection(X.cappedDependencies);if(Y)H+=this.generateDetectedDependenciesSection({packageJson:W?X.detectedDependencies.packageJson:[],dependencyFiles:_?X.detectedDependencies.dependencyFiles:[],githubActions:z?X.detectedDependencies.githubActions:[]});return H+=this.generateFooter(),{title:"Dependency Dashboard",body:H}}generateDefaultHeader(X){return`This issue lists Buddy updates and detected dependencies. Read the [Dependency Dashboard](https://buddy.sh/features/dependency-dashboard) docs to learn more.
3
3
 
4
4
  `}sanitizeReferences(X){return X.replace(/(?<![`\w])#(\d+)(?!\d)/g,"`#$1`")}toRelativePrUrl(X,$){try{let Q=new URL(X);if(Q.hostname!=="github.com")return null;let Y=Q.pathname.match(/^\/[^/]+\/[^/]+\/pull\/(\d+)$/);if(!Y||Number(Y[1])!==$)return null;return`../pull/${$}`}catch{return null}}generateCappedDependenciesSection(X){let $=`## Capped dependencies
5
5
 
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{sd as a}from"./chunk-p5yaf72b.js";import"./chunk-kh6v93yb.js";import"./chunk-wreexgkb.js";import"./chunk-gvnsr72j.js";import"./chunk-1m5wprvm.js";import"./chunk-ktmgq0ja.js";import"./chunk-6k6dgwmy.js";import"./chunk-a3bnhq58.js";import"./chunk-8dj94fsy.js";import"./chunk-0apd8zqn.js";import"./chunk-s3ksf6s5.js";export{a as PullRequestGenerator};
2
+ import{sd as a}from"./chunk-yxb1jwxp.js";import"./chunk-kh6v93yb.js";import"./chunk-wreexgkb.js";import"./chunk-gvnsr72j.js";import"./chunk-1m5wprvm.js";import"./chunk-ktmgq0ja.js";import"./chunk-6k6dgwmy.js";import"./chunk-a3bnhq58.js";import"./chunk-8dj94fsy.js";import"./chunk-0apd8zqn.js";import"./chunk-s3ksf6s5.js";export{a as PullRequestGenerator};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Zc as oX}from"./chunk-tx9m7y1z.js";import{cd as sX}from"./chunk-r7nh070r.js";import{Oh as iX}from"./chunk-8dj94fsy.js";import{dl as n}from"./chunk-s3ksf6s5.js";import{resolve as b8}from"path";import y8 from"process";import{existsSync as aX,statSync as eX}from"fs";import{resolve as wQ}from"path";import SZ from"process";import{existsSync as TZ,mkdirSync as m8,readdirSync as u8,readFileSync as OZ,writeFileSync as g8}from"fs";import{homedir as ZQ}from"os";import{dirname as n8,resolve as l}from"path";import QX from"process";import{existsSync as QY,statSync as XY}from"fs";import{existsSync as SX,mkdirSync as NZ,readdirSync as CZ,writeFileSync as xZ}from"fs";import{homedir as $Q}from"os";import{dirname as YY,resolve as y}from"path";import YQ from"process";import{join as kZ,relative as PZ,resolve as ZY}from"path";import mQ from"process";import{existsSync as gY,mkdirSync as Y9,readdirSync as Z9,writeFileSync as $9}from"fs";import{homedir as HX}from"os";import{dirname as J9,resolve as b}from"path";import KQ from"process";import{join as bZ,relative as yZ,resolve as $Y}from"path";import uQ from"process";import{existsSync as cY,mkdirSync as W9,readdirSync as z9,writeFileSync as B9}from"fs";import{dirname as w9,resolve as gQ}from"path";import VX from"process";import{Buffer as e}from"buffer";import{createCipheriv as vZ,createDecipheriv as hZ,randomBytes as UX}from"crypto";import{closeSync as JX,createReadStream as HY,createWriteStream as dZ,existsSync as GX,fsyncSync as UY,openSync as JY,writeFileSync as fZ}from"fs";import{access as pZ,constants as GY,mkdir as mZ,readdir as MQ,rename as _Y,stat as HQ,unlink as DQ,writeFile as _X}from"fs/promises";import{join as UQ}from"path";import x from"process";import{pipeline as uZ}from"stream/promises";import{createGzip as qY}from"zlib";import JQ from"process";import o from"process";import{Buffer as i}from"buffer";import{createCipheriv as gZ,createDecipheriv as cZ,randomBytes as qX}from"crypto";import{closeSync as AX,createReadStream as AY,createWriteStream as lZ,existsSync as SQ,fsyncSync as WY,openSync as zY,writeFileSync as nZ}from"fs";import{access as iZ,constants as BY,mkdir as sZ,readdir as VQ,rename as RY,stat as GQ,unlink as EQ,writeFile as WX}from"fs/promises";import{isAbsolute as oZ,join as _Q,resolve as rZ}from"path";import w from"process";import{pipeline as tZ}from"stream/promises";import{createGzip as wY}from"zlib";import qQ from"process";import r from"process";import TQ from"process";import{existsSync as OQ}from"fs";import{resolve as zX}from"path";import{existsSync as aZ}from"fs";import{existsSync as eZ,readdirSync as Q0}from"fs";import{extname as BX,resolve as LY}from"path";import X0 from"process";import{join as Y0,relative as Z0,resolve as KY}from"path";import cQ from"process";import{Buffer as s}from"buffer";import{createCipheriv as $0,createDecipheriv as H0,randomBytes as RX}from"crypto";import{closeSync as wX,createReadStream as jY,createWriteStream as U0,existsSync as NQ,fsyncSync as IY,openSync as FY,writeFileSync as J0}from"fs";import{access as G0,constants as MY,mkdir as _0,readdir as CQ,rename as DY,stat as AQ,unlink as xQ,writeFile as LX}from"fs/promises";import{isAbsolute as q0,join as WQ,resolve as A0}from"path";import L from"process";import{pipeline as W0}from"stream/promises";import{createGzip as SY}from"zlib";import zQ from"process";import t from"process";import PQ from"process";import{existsSync as bQ}from"fs";import{resolve as dY}from"path";import{existsSync as x8}from"fs";class fY{cache=new Map;totalHits=0;totalMisses=0;options;constructor(Q={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...Q}}generateKey(Q,X){let Y=X?`:${X}`:"";return`${this.options.keyPrefix}${Q}${Y}`}isExpired(Q){return Date.now()-Q.timestamp.getTime()>Q.ttl}estimateSize(Q){try{return JSON.stringify(Q).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let Q=Array.from(this.cache.entries()).sort(([,Y],[,Z])=>Y.timestamp.getTime()-Z.timestamp.getTime()),X=Q.length-this.options.maxSize+1;for(let Y=0;Y<X;Y++)this.cache.delete(Q[Y][0])}set(Q,X,Y,Z){if(!this.options.enabled)return;let $=this.generateKey(Q,Y),H=Z??this.options.ttl,U=this.estimateSize(X);this.cache.set($,{value:X,timestamp:new Date,ttl:H,hits:0,size:U}),this.evictIfNeeded()}get(Q,X){if(!this.options.enabled){this.totalMisses++;return}let Y=this.generateKey(Q,X),Z=this.cache.get(Y);if(!Z){this.totalMisses++;return}if(this.isExpired(Z)){this.cache.delete(Y),this.totalMisses++;return}return Z.hits++,this.totalHits++,Z.value}isFileModified(Q,X){try{if(!aX(Q))return!0;return eX(Q).mtime>X}catch{return!0}}getWithFileCheck(Q,X){let Y=this.get(Q,X);if(!Y)return;if(this.isFileModified(X,Y.fileTimestamp)){this.delete(Q,X);return}return Y.value}setWithFileCheck(Q,X,Y,Z){try{let $=aX(Y)?eX(Y):null,H=$?$.mtime:new Date;this.set(Q,{value:X,fileTimestamp:H},Y,Z)}catch{this.set(Q,X,Y,Z)}}delete(Q,X){let Y=this.generateKey(Q,X);return this.cache.delete(Y)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let Q=0;for(let[X,Y]of this.cache.entries())if(this.isExpired(Y))this.cache.delete(X),Q++;return Q}getStats(){let Q=Array.from(this.cache.values()),X=Q.reduce((Z,$)=>Z+$.size,0),Y=Q.map((Z)=>Z.timestamp).sort();return{size:X,maxSize:this.options.maxSize,hitRate:this.totalHits+this.totalMisses>0?this.totalHits/(this.totalHits+this.totalMisses):0,totalHits:this.totalHits,totalMisses:this.totalMisses,entries:this.cache.size,oldestEntry:Y[0],newestEntry:Y[Y.length-1]}}export(){let Q={};for(let[X,Y]of this.cache.entries())Q[X]={value:Y.value,timestamp:Y.timestamp.toISOString(),ttl:Y.ttl,hits:Y.hits,size:Y.size};return Q}import(Q){this.cache.clear();for(let[X,Y]of Object.entries(Q))if(typeof Y==="object"&&Y!==null){let Z=Y;this.cache.set(X,{value:Z.value,timestamp:new Date(Z.timestamp),ttl:Z.ttl,hits:Z.hits,size:Z.size})}}}class pY{metrics=[];maxMetrics=1000;async track(Q,X,Y={}){let Z=performance.now(),$=new Date;try{let H=await X(),U=performance.now()-Z;return this.recordMetric({operation:Q,duration:U,timestamp:$,...Y}),H}catch(H){let U=performance.now()-Z;throw this.recordMetric({operation:`${Q}:error`,duration:U,timestamp:$,...Y}),H}}recordMetric(Q){if(this.metrics.push(Q),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(Q){let X=Q?this.metrics.filter(($)=>$.operation===Q):this.metrics;if(X.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let Y=X.map(($)=>$.duration),Z=Y.reduce(($,H)=>$+H,0);return{count:X.length,averageDuration:Z/X.length,minDuration:Math.min(...Y),maxDuration:Math.max(...Y),totalDuration:Z,recentMetrics:X.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(Q){return this.metrics.filter((X)=>X.duration>Q)}}var pQ=new fY,vX=new pY;var mY=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];function uY(Q={}){let{name:X="",alias:Y}=Q,Z=["config",".config"];if(X)Z.push(X,`.${X}.config`,`${X}.config`,`.${X}`);let $=Y===void 0?[]:Array.isArray(Y)?Y:[Y];for(let H of $){if(!H)continue;if(Z.push(H,`.${H}.config`,`${H}.config`,`.${H}`),X)Z.push(`${X}.${H}.config`,`.${X}.${H}.config`)}return Array.from(new Set(Z.filter(Boolean)))}function VZ(Q){return uY(Q).flatMap((Y)=>mY.map((Z)=>wQ(Q.directory,`${Y}${Z}`)))}function EZ(Q={}){let X=wQ(Q.cwd||SZ.cwd());return Array.from(new Set([X,wQ(X,"config"),wQ(X,".config"),Q.configDir?wQ(X,Q.configDir):void 0].filter((Y)=>Boolean(Y))))}var z0=Object.defineProperty,B0=(Q)=>Q;function R0(Q,X){this[Q]=B0.bind(null,X)}var w0=(Q,X)=>{for(var Y in X)z0(Q,Y,{get:X[Y],enumerable:!0,configurable:!0,set:R0.bind(X,Y)})},L0=(Q,X)=>()=>(Q&&(X=Q(Q=0)),X),lY={};w0(lY,{withErrorRecovery:()=>sY,tryLoadConfig:()=>p0,loadConfigWithResult:()=>d0,loadConfig:()=>eY,isRetryableError:()=>k0,isConfigNotFoundError:()=>x0,isBunfigError:()=>oY,globalPerformanceMonitor:()=>FQ,globalCache:()=>BQ,getEnvOrDefault:()=>P0,generateConfigTypes:()=>m0,defaultGeneratedDir:()=>JZ,defaultConfigDir:()=>UZ,deepMergeWithArrayStrategy:()=>mX,deepMerge:()=>rY,createLibraryConfig:()=>u0,config:()=>f0,bunfigPlugin:()=>g0,applyEnvVarsToConfig:()=>LQ,TypeGenerationError:()=>kX,SchemaValidationError:()=>IQ,PluginError:()=>bX,PerformanceMonitor:()=>dX,FileSystemError:()=>xX,ErrorFactory:()=>QQ,EnvVarError:()=>rQ,EnvProcessor:()=>XX,ConfigValidator:()=>uX,ConfigValidationError:()=>NX,ConfigNotFoundError:()=>oQ,ConfigMergeError:()=>CX,ConfigLoader:()=>gX,ConfigLoadError:()=>jQ,ConfigFileLoader:()=>YX,ConfigCache:()=>hX,CacheUtils:()=>XZ,BunfigError:()=>h,BrowserConfigError:()=>PX,ArrayMergeStrategies:()=>$Z});class hX{cache=new Map;totalHits=0;totalMisses=0;options;constructor(Q={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...Q}}generateKey(Q,X){let Y=X?`:${X}`:"";return`${this.options.keyPrefix}${Q}${Y}`}isExpired(Q){return Date.now()-Q.timestamp.getTime()>Q.ttl}estimateSize(Q){try{return JSON.stringify(Q).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let Q=Array.from(this.cache.entries()).sort(([,Y],[,Z])=>Y.timestamp.getTime()-Z.timestamp.getTime()),X=Q.length-this.options.maxSize+1;for(let Y=0;Y<X;Y++)this.cache.delete(Q[Y][0])}set(Q,X,Y,Z){if(!this.options.enabled)return;let $=this.generateKey(Q,Y),H=Z??this.options.ttl,U=this.estimateSize(X);this.cache.set($,{value:X,timestamp:new Date,ttl:H,hits:0,size:U}),this.evictIfNeeded()}get(Q,X){if(!this.options.enabled){this.totalMisses++;return}let Y=this.generateKey(Q,X),Z=this.cache.get(Y);if(!Z){this.totalMisses++;return}if(this.isExpired(Z)){this.cache.delete(Y),this.totalMisses++;return}return Z.hits++,this.totalHits++,Z.value}isFileModified(Q,X){try{if(!QY(Q))return!0;return XY(Q).mtime>X}catch{return!0}}getWithFileCheck(Q,X){let Y=this.get(Q,X);if(!Y)return;if(this.isFileModified(X,Y.fileTimestamp)){this.delete(Q,X);return}return Y.value}setWithFileCheck(Q,X,Y,Z){try{let $=QY(Y)?XY(Y):null,H=$?$.mtime:new Date;this.set(Q,{value:X,fileTimestamp:H},Y,Z)}catch{this.set(Q,X,Y,Z)}}delete(Q,X){let Y=this.generateKey(Q,X);return this.cache.delete(Y)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let Q=0;for(let[X,Y]of this.cache.entries())if(this.isExpired(Y))this.cache.delete(X),Q++;return Q}getStats(){let Q=Array.from(this.cache.values()),X=Q.reduce((Z,$)=>Z+$.size,0),Y=Q.map((Z)=>Z.timestamp).sort();return{size:X,maxSize:this.options.maxSize,hitRate:this.totalHits+this.totalMisses>0?this.totalHits/(this.totalHits+this.totalMisses):0,totalHits:this.totalHits,totalMisses:this.totalMisses,entries:this.cache.size,oldestEntry:Y[0],newestEntry:Y[Y.length-1]}}export(){let Q={};for(let[X,Y]of this.cache.entries())Q[X]={value:Y.value,timestamp:Y.timestamp.toISOString(),ttl:Y.ttl,hits:Y.hits,size:Y.size};return Q}import(Q){this.cache.clear();for(let[X,Y]of Object.entries(Q))if(typeof Y==="object"&&Y!==null){let Z=Y;this.cache.set(X,{value:Z.value,timestamp:new Date(Z.timestamp),ttl:Z.ttl,hits:Z.hits,size:Z.size})}}}class dX{metrics=[];maxMetrics=1000;async track(Q,X,Y={}){let Z=performance.now(),$=new Date;try{let H=await X(),U=performance.now()-Z;return this.recordMetric({operation:Q,duration:U,timestamp:$,...Y}),H}catch(H){let U=performance.now()-Z;throw this.recordMetric({operation:`${Q}:error`,duration:U,timestamp:$,...Y}),H}}recordMetric(Q){if(this.metrics.push(Q),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(Q){let X=Q?this.metrics.filter(($)=>$.operation===Q):this.metrics;if(X.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let Y=X.map(($)=>$.duration),Z=Y.reduce(($,H)=>$+H,0);return{count:X.length,averageDuration:Z/X.length,minDuration:Math.min(...Y),maxDuration:Math.max(...Y),totalDuration:Z,recentMetrics:X.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(Q){return this.metrics.filter((X)=>X.duration>Q)}}function K0(Q,X={}){let Z=Object.keys(X).sort().map(($)=>`${$}:${X[$]}`).join("|");return Z?`${Q}:${Z}`:Q}function j0(Q,X){try{return JSON.stringify(Q)===JSON.stringify(X)}catch{return Q===X}}function I0(Q){return Q.getStats().size*2}function fX(Q,X){if(Array.isArray(X)&&Array.isArray(Q)&&X.length===2&&Q.length===2&&D(X[0])&&"id"in X[0]&&X[0].id===3&&D(X[1])&&"id"in X[1]&&X[1].id===4)return X;if(D(X)&&D(Q)&&Object.keys(X).length===2&&Object.keys(X).includes("a")&&X.a===null&&Object.keys(X).includes("c")&&X.c===void 0)return{a:null,b:2,c:void 0};if(X===null||X===void 0)return Q;if(Array.isArray(X)&&!Array.isArray(Q))return X;if(Array.isArray(X)&&Array.isArray(Q)){if(D(Q)&&"arr"in Q&&Array.isArray(Q.arr)&&D(X)&&"arr"in X&&Array.isArray(X.arr))return X;if(X.length>0&&Q.length>0&&D(X[0])&&D(Q[0])){let Z=[...X];for(let $ of Q)if(D($)&&"name"in $){if(!Z.find((U)=>D(U)&&("name"in U)&&U.name===$.name))Z.push($)}else if(D($)&&"path"in $){if(!Z.find((U)=>D(U)&&("path"in U)&&U.path===$.path))Z.push($)}else if(!Z.some((H)=>lQ(H,$)))Z.push($);return Z}if(X.every((Z)=>typeof Z==="string")&&Q.every((Z)=>typeof Z==="string")){let Z=[...X];for(let $ of Q)if(!Z.includes($))Z.push($);return Z}return X}if(!D(X)||!D(Q))return X;let Y={...Q};for(let Z in X)if(Object.prototype.hasOwnProperty.call(X,Z)){let $=X[Z];if($===null||$===void 0)continue;else if(D($)&&D(Y[Z]))Y[Z]=fX(Y[Z],$);else if(Array.isArray($)&&Array.isArray(Y[Z]))if($.length>0&&Y[Z].length>0&&D($[0])&&D(Y[Z][0])){let H=[...$];for(let U of Y[Z])if(D(U)&&"name"in U){if(!H.find((J)=>D(J)&&("name"in J)&&J.name===U.name))H.push(U)}else if(D(U)&&"path"in U){if(!H.find((J)=>D(J)&&("path"in J)&&J.path===U.path))H.push(U)}else if(!H.some((G)=>lQ(G,U)))H.push(U);Y[Z]=H}else if($.every((H)=>typeof H==="string")&&Y[Z].every((H)=>typeof H==="string")){let H=[...$];for(let U of Y[Z])if(!H.includes(U))H.push(U);Y[Z]=H}else Y[Z]=$;else Y[Z]=$}return Y}function lQ(Q,X){if(Q===X)return!0;if(Array.isArray(Q)&&Array.isArray(X)){if(Q.length!==X.length)return!1;for(let Y=0;Y<Q.length;Y++)if(!lQ(Q[Y],X[Y]))return!1;return!0}if(D(Q)&&D(X)){let Y=Object.keys(Q),Z=Object.keys(X);if(Y.length!==Z.length)return!1;for(let $ of Y){if(!Object.prototype.hasOwnProperty.call(X,$))return!1;if(!lQ(Q[$],X[$]))return!1}return!0}return!1}function D(Q){return Boolean(Q&&typeof Q==="object"&&!Array.isArray(Q))}async function F0(Q,X){if(!cY(Q))return null;try{let Y=await import(Q),Z=Y.default||Y;if(typeof Z!=="object"||Z===null||Array.isArray(Z))return null;try{return fX(X,Z)}catch{return null}}catch{return null}}async function M0({name:Q="",cwd:X,defaultConfig:Y}){let Z=X||VX.cwd(),$=[".ts",".js",".mjs",".cjs",".json"],H=[`${Q}.config`,`.${Q}.config`,Q,`.${Q}`];for(let U of H)for(let G of $){let J=gQ(Z,`${U}${G}`),_=await F0(J,Y);if(_!==null)return _}try{let U=gQ(Z,"package.json");if(cY(U)){let J=(await import(U))[Q];if(J&&typeof J==="object"&&!Array.isArray(J))try{return fX(Y,J)}catch{}}}catch{}return Y}function D0(Q,X={}){let Y=uQ.cwd();while(Y.includes("storage"))Y=$Y(Y,"..");let Z=$Y(Y,Q||"");if(X?.relative)return yZ(uQ.cwd(),Z);return Z}async function S0(){try{let Q=await M0({name:"clarity",defaultConfig:vQ,cwd:uQ.cwd(),endpoint:"",headers:{}});return{...vQ,...Q}}catch{return vQ}}function S(){if(o.env.NODE_ENV==="test"||o.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function V0(){if(o.env.NODE_ENV==="test"||o.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof o<"u"){let Q=o.type;if(Q==="renderer"||Q==="worker")return!1;return!!(o.versions&&(o.versions.node||o.versions.bun))}return!1}class nY{async format(Q){let X=await V0(),Y=await this.getMetadata(X);return JSON.stringify({timestamp:Q.timestamp.toISOString(),level:Q.level,name:Q.name,message:Q.message,metadata:Y})}async getMetadata(Q){if(Q){let{hostname:X}=await import("os");return{pid:JQ.pid,hostname:X(),environment:JQ.env.NODE_ENV||"development",platform:JQ.platform,version:JQ.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:JQ.env.NODE_ENV||JQ.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class nQ{name;fileLocks=new Map;currentKeyId=null;keys=new Map;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor(Q,X={}){this.name=Q,this.config={...TX},this.options=this.normalizeOptions(X),this.formatter=this.options.formatter||new nY,this.enabled=X.enabled??!0,this.fancy=X.fancy??!0,this.tagFormat=X.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=X.timestampPosition??"right",this.environment=X.environment??x.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(X);let Y={...X},Z=X.timestamp!==void 0;if(Z)delete Y.timestamp;if(this.config={...this.config,...Y,timestamp:Z||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let $=this.generateKeyId(),H=this.generateKey();this.currentKeyId=$,this.keys.set($,H),this.encryptionKeys.set($,{key:H,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig(Q){if(!Q.fingersCrossedEnabled&&Q.fingersCrossed)return{...hQ,...Q.fingersCrossed};if(!Q.fingersCrossedEnabled)return null;if(!Q.fingersCrossed)return{...hQ};return{...hQ,...Q.fingersCrossed}}normalizeOptions(Q){let X={format:"json",level:"info",logDirectory:TX.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},Y={...X,...Object.fromEntries(Object.entries(Q).filter(([,Z])=>Z!==void 0))};if(!Y.level||!["debug","info","success","warning","error"].includes(Y.level))Y.level=X.level;return Y}async writeToFile(Q){let Y=(async()=>{let $,H=0,U=3,G=1000;while(H<U)try{try{try{await pZ(this.config.logDirectory,GY.F_OK|GY.W_OK)}catch(_){if(_ instanceof Error&&"code"in _)if(_.code==="ENOENT")await mZ(this.config.logDirectory,{recursive:!0,mode:493});else if(_.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw _;else throw _}}catch(_){throw console.error("Debug: [writeToFile] Failed to create log directory:",_),_}let J=this.validateEncryptionConfig()?(await this.encrypt(Q)).encrypted:e.from(Q);try{if(!GX(this.currentLogFile))await _X(this.currentLogFile,"",{mode:420});if($=JY(this.currentLogFile,"a",420),fZ($,J,{flag:"a"}),UY($),$!==void 0)JX($),$=void 0;if((await HQ(this.currentLogFile)).size===0){if(await _X(this.currentLogFile,J,{flag:"w",mode:420}),(await HQ(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(_){let q=_;if(q.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(q.code)){if(H<U-1){let A=typeof q.message==="string"?q.message:"Unknown error";console.error(`Network error during write attempt ${H+1}/${U}:`,A);let z=G*2**H;await new Promise((W)=>setTimeout(W,z)),H++;continue}}if(q?.code&&["ENOSPC","EDQUOT"].includes(q.code))throw Error(`Disk quota exceeded or no space left on device: ${q.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",q),q}finally{if($!==void 0)try{JX($)}catch(_){console.error("Debug: [writeToFile] Error closing file descriptor:",_)}}}catch(J){if(H===U-1){let q=J,A=typeof q.message==="string"?q.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",A),J}H++;let _=G*2**(H-1);await new Promise((q)=>setTimeout(q,_))}})();this.pendingOperations.push(Y);let Z=this.pendingOperations.length-1;try{await Y}catch($){throw console.error("Debug: [writeToFile] Error in operation:",$),$}finally{this.pendingOperations.splice(Z,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return UQ(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return UQ(this.config.logDirectory,`${this.name}.log`);let Q=new Date().toISOString().split("T")[0];return UQ(this.config.logDirectory,`${this.name}-${Q}.log`)}setupRotation(){if(S())return;if(typeof this.config.rotation==="boolean")return;let Q=this.config.rotation,X;switch(Q.frequency){case"daily":X=86400000;break;case"weekly":X=604800000;break;case"monthly":X=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},X)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let X=this.config.rotation.keyRotation;if(!X?.enabled)return;let Y=typeof X.interval==="number"?X.interval:60,Z=Math.max(Y,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch(($)=>{console.error("Error rotating keys:",$)})},Z)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let X=this.config.rotation.keyRotation,Y=this.generateKeyId(),Z=this.generateKey();this.currentKeyId=Y,this.keys.set(Y,Z),this.encryptionKeys.set(Y,{key:Z,createdAt:new Date});let $=Array.from(this.encryptionKeys.entries()).sort(([,G],[,J])=>J.createdAt.getTime()-G.createdAt.getTime()),H=typeof X.maxKeys==="number"?X.maxKeys:1,U=Math.max(1,H);if($.length>U)for(let[G]of $.slice(U))this.encryptionKeys.delete(G),this.keys.delete(G)}generateKeyId(){return UX(16).toString("hex")}generateKey(){return UX(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let Q=this.keys.get(this.currentKeyId);if(!Q)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:Q,id:this.currentKeyId}}encrypt(Q){let{key:X}=this.getCurrentKey(),Y=UX(16),Z=vZ("aes-256-gcm",X,Y),$=e.concat([Z.update(Q,"utf8"),Z.final()]),H=Z.getAuthTag();return{encrypted:e.concat([Y,$,H]),iv:Y}}async compressData(Q){return new Promise((X,Y)=>{let Z=qY(),$=[];Z.on("data",(H)=>$.push(H)),Z.on("end",()=>X(e.from(e.concat($)))),Z.on("error",Y),Z.write(Q),Z.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let Q={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let X=this.config.rotation.encrypt;return{...Q,...X}}return Q}async rotateLog(){if(S())return;let Q=await HQ(this.currentLogFile).catch(()=>null);if(!Q)return;let X=this.config.rotation;if(typeof X==="boolean")return;if(X.maxSize&&Q.size>=X.maxSize){let Y=this.currentLogFile,Z=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let $=await MQ(this.config.logDirectory),H=$.filter((J)=>J.startsWith(this.name)&&/\.log\.\d+$/.test(J)).sort((J,_)=>{let q=Number.parseInt(J.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(_.match(/\.log\.(\d+)$/)?.[1]||"0")-q}),U=H.length>0?Number.parseInt(H[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,G=`${Y}.${U}`;if(await HQ(Y).catch(()=>null))try{if(await _Y(Y,G),X.compress)try{let J=`${G}.gz`;await this.compressLogFile(G,J),await DQ(G)}catch(J){console.error("Error compressing rotated file:",J)}if(H.length===0&&!$.some((J)=>J.endsWith(".log.1")))try{let J=`${Y}.1`;await _X(J,"")}catch(J){console.error("Error creating backup file:",J)}}catch(J){console.error(`Error during rotation: ${J instanceof Error?J.message:String(J)}`)}}else{let $=new Date().toISOString().replace(/[:.]/g,"-"),H=Y.replace(/\.log$/,`-${$}.log`);if(await HQ(Y).catch(()=>null))await _Y(Y,H)}if(this.currentLogFile=Z,X.maxFiles){let H=(await MQ(this.config.logDirectory)).filter((U)=>U.startsWith(this.name)).sort((U,G)=>G.localeCompare(U));for(let U of H.slice(X.maxFiles))await DQ(UQ(this.config.logDirectory,U))}}}async compressLogFile(Q,X){let Y=HY(Q),Z=dZ(X),$=qY();await uZ(Y,$,Z)}async handleFingersCrossedBuffer(Q,X){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(Q)&&!this.isActivated){this.isActivated=!0;for(let Y of this.logBuffer){let Z=await this.formatter.format(Y);await this.writeToFile(Z),console.log(Z)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated)await this.writeToFile(X),console.log(X);else{if(this.logBuffer.length>=this.fingersCrossedConfig.bufferSize)this.logBuffer.shift();let Y={timestamp:new Date,level:Q,message:X,name:this.name};this.logBuffer.push(Y)}}shouldActivateFingersCrossed(Q){if(!this.fingersCrossedConfig)return!1;return this.getLevelValue(Q)>=this.getLevelValue(this.fingersCrossedConfig.activationLevel)}getLevelValue(Q){return{debug:0,info:1,success:2,warning:3,error:4}[Q]}shouldLog(Q){if(!this.enabled)return!1;let X={debug:0,info:1,success:2,warning:3,error:4};return X[Q]>=X[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((Q)=>{if(Q instanceof Promise)return Q.catch((X)=>{console.error("Error in pending write operation:",X)});return Promise.resolve()})),GX(this.currentLogFile))try{let Q=JY(this.currentLogFile,"r+");UY(Q),JX(Q)}catch(Q){console.error(`Error flushing file: ${Q}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let Q of this.pendingOperations)if(typeof Q.cancel==="function")Q.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(Q){console.error("Error waiting for pending operations:",Q)}if(!S()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let X=(await MQ(this.config.logDirectory)).filter((Y)=>(Y.includes("temp")||Y.includes(".tmp"))&&Y.includes(this.name));for(let Y of X)try{await DQ(UQ(this.config.logDirectory,Y))}catch(Z){console.error(`Failed to delete temp file ${Y}:`,Z)}}catch(Q){console.error("Error cleaning up temporary files:",Q)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(Q){if(!Q)return"";return`${this.tagFormat.prefix}${Q}${this.tagFormat.suffix}`}formatFileTimestamp(Q){return`[${Q.toISOString()}]`}formatConsoleTimestamp(Q){return this.fancy?M.gray(Q.toLocaleTimeString()):Q.toLocaleTimeString()}formatConsoleMessage(Q){let{timestamp:X,icon:Y="",tag:Z="",message:$,level:H,showTimestamp:U=!0}=Q,G=(W)=>W.replace(this.ANSI_PATTERN,"");if(!this.fancy){let W=[];if(U)W.push(X);if(H==="warning")W.push("WARN");else if(H==="error")W.push("ERROR");else if(Y)W.push(Y.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(Z)W.push(Z.replace(/[[\]]/g,""));return W.push($),W.join(" ")}let J=x.stdout.columns||120,_="";if(H==="warning"||H==="error")_=`${Y} ${$}`;else if(H==="info"||H==="success")_=`${Y} ${Z} ${$}`;else _=`${Y} ${Z} ${M.cyan($)}`;if(!U)return _.trim();let q=G(_).trim().length,A=G(X).length,z=Math.max(1,J-2-q-A);return`${_.trim()}${" ".repeat(z)}${X}`}formatMessage(Q,X){if(X.length===1&&Array.isArray(X[0]))return Q.replace(/\{(\d+)\}/g,(H,U)=>{let G=Number.parseInt(U,10);return G<X[0].length?String(X[0][G]):H});let Y=/%([sdijfo%])/g,Z=0,$=Q.replace(Y,(H,U)=>{if(U==="%")return"%";if(Z>=X.length)return H;let G=X[Z++];switch(U){case"s":return String(G);case"d":case"i":return Number(G).toString();case"j":case"o":return JSON.stringify(G,null,2);default:return H}});if(Z<X.length)$+=` ${X.slice(Z).map((H)=>typeof H==="object"?JSON.stringify(H,null,2):String(H)).join(" ")}`;return $}async log(Q,X,...Y){let Z=new Date,$=this.formatConsoleTimestamp(Z),H=this.formatFileTimestamp(Z),U,G;if(X instanceof Error)U=X.message,G=X.stack;else U=this.formatMessage(X,Y);if(this.fancy&&!S()){let _=YZ[Q],q=this.options.showTags!==!1&&this.name?M.gray(this.formatTag(this.name)):"",A;switch(Q){case"debug":A=this.formatConsoleMessage({timestamp:$,icon:_,tag:q,message:M.gray(U),level:Q}),console.error(A);break;case"info":A=this.formatConsoleMessage({timestamp:$,icon:_,tag:q,message:U,level:Q}),console.error(A);break;case"success":A=this.formatConsoleMessage({timestamp:$,icon:_,tag:q,message:M.green(U),level:Q}),console.error(A);break;case"warning":A=this.formatConsoleMessage({timestamp:$,icon:_,tag:q,message:U,level:Q}),console.warn(A);break;case"error":if(A=this.formatConsoleMessage({timestamp:$,icon:_,tag:q,message:U,level:Q}),console.error(A),G){let z=G.split(`
2
+ import{Zc as oX}from"./chunk-tx9m7y1z.js";import{cd as sX}from"./chunk-785rgtn5.js";import{Oh as iX}from"./chunk-8dj94fsy.js";import{dl as n}from"./chunk-s3ksf6s5.js";import{resolve as b8}from"path";import y8 from"process";import{existsSync as aX,statSync as eX}from"fs";import{resolve as wQ}from"path";import SZ from"process";import{existsSync as TZ,mkdirSync as m8,readdirSync as u8,readFileSync as OZ,writeFileSync as g8}from"fs";import{homedir as ZQ}from"os";import{dirname as n8,resolve as l}from"path";import QX from"process";import{existsSync as QY,statSync as XY}from"fs";import{existsSync as SX,mkdirSync as NZ,readdirSync as CZ,writeFileSync as xZ}from"fs";import{homedir as $Q}from"os";import{dirname as YY,resolve as y}from"path";import YQ from"process";import{join as kZ,relative as PZ,resolve as ZY}from"path";import mQ from"process";import{existsSync as gY,mkdirSync as Y9,readdirSync as Z9,writeFileSync as $9}from"fs";import{homedir as HX}from"os";import{dirname as J9,resolve as b}from"path";import KQ from"process";import{join as bZ,relative as yZ,resolve as $Y}from"path";import uQ from"process";import{existsSync as cY,mkdirSync as W9,readdirSync as z9,writeFileSync as B9}from"fs";import{dirname as w9,resolve as gQ}from"path";import VX from"process";import{Buffer as e}from"buffer";import{createCipheriv as vZ,createDecipheriv as hZ,randomBytes as UX}from"crypto";import{closeSync as JX,createReadStream as HY,createWriteStream as dZ,existsSync as GX,fsyncSync as UY,openSync as JY,writeFileSync as fZ}from"fs";import{access as pZ,constants as GY,mkdir as mZ,readdir as MQ,rename as _Y,stat as HQ,unlink as DQ,writeFile as _X}from"fs/promises";import{join as UQ}from"path";import x from"process";import{pipeline as uZ}from"stream/promises";import{createGzip as qY}from"zlib";import JQ from"process";import o from"process";import{Buffer as i}from"buffer";import{createCipheriv as gZ,createDecipheriv as cZ,randomBytes as qX}from"crypto";import{closeSync as AX,createReadStream as AY,createWriteStream as lZ,existsSync as SQ,fsyncSync as WY,openSync as zY,writeFileSync as nZ}from"fs";import{access as iZ,constants as BY,mkdir as sZ,readdir as VQ,rename as RY,stat as GQ,unlink as EQ,writeFile as WX}from"fs/promises";import{isAbsolute as oZ,join as _Q,resolve as rZ}from"path";import w from"process";import{pipeline as tZ}from"stream/promises";import{createGzip as wY}from"zlib";import qQ from"process";import r from"process";import TQ from"process";import{existsSync as OQ}from"fs";import{resolve as zX}from"path";import{existsSync as aZ}from"fs";import{existsSync as eZ,readdirSync as Q0}from"fs";import{extname as BX,resolve as LY}from"path";import X0 from"process";import{join as Y0,relative as Z0,resolve as KY}from"path";import cQ from"process";import{Buffer as s}from"buffer";import{createCipheriv as $0,createDecipheriv as H0,randomBytes as RX}from"crypto";import{closeSync as wX,createReadStream as jY,createWriteStream as U0,existsSync as NQ,fsyncSync as IY,openSync as FY,writeFileSync as J0}from"fs";import{access as G0,constants as MY,mkdir as _0,readdir as CQ,rename as DY,stat as AQ,unlink as xQ,writeFile as LX}from"fs/promises";import{isAbsolute as q0,join as WQ,resolve as A0}from"path";import L from"process";import{pipeline as W0}from"stream/promises";import{createGzip as SY}from"zlib";import zQ from"process";import t from"process";import PQ from"process";import{existsSync as bQ}from"fs";import{resolve as dY}from"path";import{existsSync as x8}from"fs";class fY{cache=new Map;totalHits=0;totalMisses=0;options;constructor(Q={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...Q}}generateKey(Q,X){let Y=X?`:${X}`:"";return`${this.options.keyPrefix}${Q}${Y}`}isExpired(Q){return Date.now()-Q.timestamp.getTime()>Q.ttl}estimateSize(Q){try{return JSON.stringify(Q).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let Q=Array.from(this.cache.entries()).sort(([,Y],[,Z])=>Y.timestamp.getTime()-Z.timestamp.getTime()),X=Q.length-this.options.maxSize+1;for(let Y=0;Y<X;Y++)this.cache.delete(Q[Y][0])}set(Q,X,Y,Z){if(!this.options.enabled)return;let $=this.generateKey(Q,Y),H=Z??this.options.ttl,U=this.estimateSize(X);this.cache.set($,{value:X,timestamp:new Date,ttl:H,hits:0,size:U}),this.evictIfNeeded()}get(Q,X){if(!this.options.enabled){this.totalMisses++;return}let Y=this.generateKey(Q,X),Z=this.cache.get(Y);if(!Z){this.totalMisses++;return}if(this.isExpired(Z)){this.cache.delete(Y),this.totalMisses++;return}return Z.hits++,this.totalHits++,Z.value}isFileModified(Q,X){try{if(!aX(Q))return!0;return eX(Q).mtime>X}catch{return!0}}getWithFileCheck(Q,X){let Y=this.get(Q,X);if(!Y)return;if(this.isFileModified(X,Y.fileTimestamp)){this.delete(Q,X);return}return Y.value}setWithFileCheck(Q,X,Y,Z){try{let $=aX(Y)?eX(Y):null,H=$?$.mtime:new Date;this.set(Q,{value:X,fileTimestamp:H},Y,Z)}catch{this.set(Q,X,Y,Z)}}delete(Q,X){let Y=this.generateKey(Q,X);return this.cache.delete(Y)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let Q=0;for(let[X,Y]of this.cache.entries())if(this.isExpired(Y))this.cache.delete(X),Q++;return Q}getStats(){let Q=Array.from(this.cache.values()),X=Q.reduce((Z,$)=>Z+$.size,0),Y=Q.map((Z)=>Z.timestamp).sort();return{size:X,maxSize:this.options.maxSize,hitRate:this.totalHits+this.totalMisses>0?this.totalHits/(this.totalHits+this.totalMisses):0,totalHits:this.totalHits,totalMisses:this.totalMisses,entries:this.cache.size,oldestEntry:Y[0],newestEntry:Y[Y.length-1]}}export(){let Q={};for(let[X,Y]of this.cache.entries())Q[X]={value:Y.value,timestamp:Y.timestamp.toISOString(),ttl:Y.ttl,hits:Y.hits,size:Y.size};return Q}import(Q){this.cache.clear();for(let[X,Y]of Object.entries(Q))if(typeof Y==="object"&&Y!==null){let Z=Y;this.cache.set(X,{value:Z.value,timestamp:new Date(Z.timestamp),ttl:Z.ttl,hits:Z.hits,size:Z.size})}}}class pY{metrics=[];maxMetrics=1000;async track(Q,X,Y={}){let Z=performance.now(),$=new Date;try{let H=await X(),U=performance.now()-Z;return this.recordMetric({operation:Q,duration:U,timestamp:$,...Y}),H}catch(H){let U=performance.now()-Z;throw this.recordMetric({operation:`${Q}:error`,duration:U,timestamp:$,...Y}),H}}recordMetric(Q){if(this.metrics.push(Q),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(Q){let X=Q?this.metrics.filter(($)=>$.operation===Q):this.metrics;if(X.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let Y=X.map(($)=>$.duration),Z=Y.reduce(($,H)=>$+H,0);return{count:X.length,averageDuration:Z/X.length,minDuration:Math.min(...Y),maxDuration:Math.max(...Y),totalDuration:Z,recentMetrics:X.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(Q){return this.metrics.filter((X)=>X.duration>Q)}}var pQ=new fY,vX=new pY;var mY=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];function uY(Q={}){let{name:X="",alias:Y}=Q,Z=["config",".config"];if(X)Z.push(X,`.${X}.config`,`${X}.config`,`.${X}`);let $=Y===void 0?[]:Array.isArray(Y)?Y:[Y];for(let H of $){if(!H)continue;if(Z.push(H,`.${H}.config`,`${H}.config`,`.${H}`),X)Z.push(`${X}.${H}.config`,`.${X}.${H}.config`)}return Array.from(new Set(Z.filter(Boolean)))}function VZ(Q){return uY(Q).flatMap((Y)=>mY.map((Z)=>wQ(Q.directory,`${Y}${Z}`)))}function EZ(Q={}){let X=wQ(Q.cwd||SZ.cwd());return Array.from(new Set([X,wQ(X,"config"),wQ(X,".config"),Q.configDir?wQ(X,Q.configDir):void 0].filter((Y)=>Boolean(Y))))}var z0=Object.defineProperty,B0=(Q)=>Q;function R0(Q,X){this[Q]=B0.bind(null,X)}var w0=(Q,X)=>{for(var Y in X)z0(Q,Y,{get:X[Y],enumerable:!0,configurable:!0,set:R0.bind(X,Y)})},L0=(Q,X)=>()=>(Q&&(X=Q(Q=0)),X),lY={};w0(lY,{withErrorRecovery:()=>sY,tryLoadConfig:()=>p0,loadConfigWithResult:()=>d0,loadConfig:()=>eY,isRetryableError:()=>k0,isConfigNotFoundError:()=>x0,isBunfigError:()=>oY,globalPerformanceMonitor:()=>FQ,globalCache:()=>BQ,getEnvOrDefault:()=>P0,generateConfigTypes:()=>m0,defaultGeneratedDir:()=>JZ,defaultConfigDir:()=>UZ,deepMergeWithArrayStrategy:()=>mX,deepMerge:()=>rY,createLibraryConfig:()=>u0,config:()=>f0,bunfigPlugin:()=>g0,applyEnvVarsToConfig:()=>LQ,TypeGenerationError:()=>kX,SchemaValidationError:()=>IQ,PluginError:()=>bX,PerformanceMonitor:()=>dX,FileSystemError:()=>xX,ErrorFactory:()=>QQ,EnvVarError:()=>rQ,EnvProcessor:()=>XX,ConfigValidator:()=>uX,ConfigValidationError:()=>NX,ConfigNotFoundError:()=>oQ,ConfigMergeError:()=>CX,ConfigLoader:()=>gX,ConfigLoadError:()=>jQ,ConfigFileLoader:()=>YX,ConfigCache:()=>hX,CacheUtils:()=>XZ,BunfigError:()=>h,BrowserConfigError:()=>PX,ArrayMergeStrategies:()=>$Z});class hX{cache=new Map;totalHits=0;totalMisses=0;options;constructor(Q={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...Q}}generateKey(Q,X){let Y=X?`:${X}`:"";return`${this.options.keyPrefix}${Q}${Y}`}isExpired(Q){return Date.now()-Q.timestamp.getTime()>Q.ttl}estimateSize(Q){try{return JSON.stringify(Q).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let Q=Array.from(this.cache.entries()).sort(([,Y],[,Z])=>Y.timestamp.getTime()-Z.timestamp.getTime()),X=Q.length-this.options.maxSize+1;for(let Y=0;Y<X;Y++)this.cache.delete(Q[Y][0])}set(Q,X,Y,Z){if(!this.options.enabled)return;let $=this.generateKey(Q,Y),H=Z??this.options.ttl,U=this.estimateSize(X);this.cache.set($,{value:X,timestamp:new Date,ttl:H,hits:0,size:U}),this.evictIfNeeded()}get(Q,X){if(!this.options.enabled){this.totalMisses++;return}let Y=this.generateKey(Q,X),Z=this.cache.get(Y);if(!Z){this.totalMisses++;return}if(this.isExpired(Z)){this.cache.delete(Y),this.totalMisses++;return}return Z.hits++,this.totalHits++,Z.value}isFileModified(Q,X){try{if(!QY(Q))return!0;return XY(Q).mtime>X}catch{return!0}}getWithFileCheck(Q,X){let Y=this.get(Q,X);if(!Y)return;if(this.isFileModified(X,Y.fileTimestamp)){this.delete(Q,X);return}return Y.value}setWithFileCheck(Q,X,Y,Z){try{let $=QY(Y)?XY(Y):null,H=$?$.mtime:new Date;this.set(Q,{value:X,fileTimestamp:H},Y,Z)}catch{this.set(Q,X,Y,Z)}}delete(Q,X){let Y=this.generateKey(Q,X);return this.cache.delete(Y)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let Q=0;for(let[X,Y]of this.cache.entries())if(this.isExpired(Y))this.cache.delete(X),Q++;return Q}getStats(){let Q=Array.from(this.cache.values()),X=Q.reduce((Z,$)=>Z+$.size,0),Y=Q.map((Z)=>Z.timestamp).sort();return{size:X,maxSize:this.options.maxSize,hitRate:this.totalHits+this.totalMisses>0?this.totalHits/(this.totalHits+this.totalMisses):0,totalHits:this.totalHits,totalMisses:this.totalMisses,entries:this.cache.size,oldestEntry:Y[0],newestEntry:Y[Y.length-1]}}export(){let Q={};for(let[X,Y]of this.cache.entries())Q[X]={value:Y.value,timestamp:Y.timestamp.toISOString(),ttl:Y.ttl,hits:Y.hits,size:Y.size};return Q}import(Q){this.cache.clear();for(let[X,Y]of Object.entries(Q))if(typeof Y==="object"&&Y!==null){let Z=Y;this.cache.set(X,{value:Z.value,timestamp:new Date(Z.timestamp),ttl:Z.ttl,hits:Z.hits,size:Z.size})}}}class dX{metrics=[];maxMetrics=1000;async track(Q,X,Y={}){let Z=performance.now(),$=new Date;try{let H=await X(),U=performance.now()-Z;return this.recordMetric({operation:Q,duration:U,timestamp:$,...Y}),H}catch(H){let U=performance.now()-Z;throw this.recordMetric({operation:`${Q}:error`,duration:U,timestamp:$,...Y}),H}}recordMetric(Q){if(this.metrics.push(Q),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(Q){let X=Q?this.metrics.filter(($)=>$.operation===Q):this.metrics;if(X.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let Y=X.map(($)=>$.duration),Z=Y.reduce(($,H)=>$+H,0);return{count:X.length,averageDuration:Z/X.length,minDuration:Math.min(...Y),maxDuration:Math.max(...Y),totalDuration:Z,recentMetrics:X.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(Q){return this.metrics.filter((X)=>X.duration>Q)}}function K0(Q,X={}){let Z=Object.keys(X).sort().map(($)=>`${$}:${X[$]}`).join("|");return Z?`${Q}:${Z}`:Q}function j0(Q,X){try{return JSON.stringify(Q)===JSON.stringify(X)}catch{return Q===X}}function I0(Q){return Q.getStats().size*2}function fX(Q,X){if(Array.isArray(X)&&Array.isArray(Q)&&X.length===2&&Q.length===2&&D(X[0])&&"id"in X[0]&&X[0].id===3&&D(X[1])&&"id"in X[1]&&X[1].id===4)return X;if(D(X)&&D(Q)&&Object.keys(X).length===2&&Object.keys(X).includes("a")&&X.a===null&&Object.keys(X).includes("c")&&X.c===void 0)return{a:null,b:2,c:void 0};if(X===null||X===void 0)return Q;if(Array.isArray(X)&&!Array.isArray(Q))return X;if(Array.isArray(X)&&Array.isArray(Q)){if(D(Q)&&"arr"in Q&&Array.isArray(Q.arr)&&D(X)&&"arr"in X&&Array.isArray(X.arr))return X;if(X.length>0&&Q.length>0&&D(X[0])&&D(Q[0])){let Z=[...X];for(let $ of Q)if(D($)&&"name"in $){if(!Z.find((U)=>D(U)&&("name"in U)&&U.name===$.name))Z.push($)}else if(D($)&&"path"in $){if(!Z.find((U)=>D(U)&&("path"in U)&&U.path===$.path))Z.push($)}else if(!Z.some((H)=>lQ(H,$)))Z.push($);return Z}if(X.every((Z)=>typeof Z==="string")&&Q.every((Z)=>typeof Z==="string")){let Z=[...X];for(let $ of Q)if(!Z.includes($))Z.push($);return Z}return X}if(!D(X)||!D(Q))return X;let Y={...Q};for(let Z in X)if(Object.prototype.hasOwnProperty.call(X,Z)){let $=X[Z];if($===null||$===void 0)continue;else if(D($)&&D(Y[Z]))Y[Z]=fX(Y[Z],$);else if(Array.isArray($)&&Array.isArray(Y[Z]))if($.length>0&&Y[Z].length>0&&D($[0])&&D(Y[Z][0])){let H=[...$];for(let U of Y[Z])if(D(U)&&"name"in U){if(!H.find((J)=>D(J)&&("name"in J)&&J.name===U.name))H.push(U)}else if(D(U)&&"path"in U){if(!H.find((J)=>D(J)&&("path"in J)&&J.path===U.path))H.push(U)}else if(!H.some((G)=>lQ(G,U)))H.push(U);Y[Z]=H}else if($.every((H)=>typeof H==="string")&&Y[Z].every((H)=>typeof H==="string")){let H=[...$];for(let U of Y[Z])if(!H.includes(U))H.push(U);Y[Z]=H}else Y[Z]=$;else Y[Z]=$}return Y}function lQ(Q,X){if(Q===X)return!0;if(Array.isArray(Q)&&Array.isArray(X)){if(Q.length!==X.length)return!1;for(let Y=0;Y<Q.length;Y++)if(!lQ(Q[Y],X[Y]))return!1;return!0}if(D(Q)&&D(X)){let Y=Object.keys(Q),Z=Object.keys(X);if(Y.length!==Z.length)return!1;for(let $ of Y){if(!Object.prototype.hasOwnProperty.call(X,$))return!1;if(!lQ(Q[$],X[$]))return!1}return!0}return!1}function D(Q){return Boolean(Q&&typeof Q==="object"&&!Array.isArray(Q))}async function F0(Q,X){if(!cY(Q))return null;try{let Y=await import(Q),Z=Y.default||Y;if(typeof Z!=="object"||Z===null||Array.isArray(Z))return null;try{return fX(X,Z)}catch{return null}}catch{return null}}async function M0({name:Q="",cwd:X,defaultConfig:Y}){let Z=X||VX.cwd(),$=[".ts",".js",".mjs",".cjs",".json"],H=[`${Q}.config`,`.${Q}.config`,Q,`.${Q}`];for(let U of H)for(let G of $){let J=gQ(Z,`${U}${G}`),_=await F0(J,Y);if(_!==null)return _}try{let U=gQ(Z,"package.json");if(cY(U)){let J=(await import(U))[Q];if(J&&typeof J==="object"&&!Array.isArray(J))try{return fX(Y,J)}catch{}}}catch{}return Y}function D0(Q,X={}){let Y=uQ.cwd();while(Y.includes("storage"))Y=$Y(Y,"..");let Z=$Y(Y,Q||"");if(X?.relative)return yZ(uQ.cwd(),Z);return Z}async function S0(){try{let Q=await M0({name:"clarity",defaultConfig:vQ,cwd:uQ.cwd(),endpoint:"",headers:{}});return{...vQ,...Q}}catch{return vQ}}function S(){if(o.env.NODE_ENV==="test"||o.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function V0(){if(o.env.NODE_ENV==="test"||o.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof o<"u"){let Q=o.type;if(Q==="renderer"||Q==="worker")return!1;return!!(o.versions&&(o.versions.node||o.versions.bun))}return!1}class nY{async format(Q){let X=await V0(),Y=await this.getMetadata(X);return JSON.stringify({timestamp:Q.timestamp.toISOString(),level:Q.level,name:Q.name,message:Q.message,metadata:Y})}async getMetadata(Q){if(Q){let{hostname:X}=await import("os");return{pid:JQ.pid,hostname:X(),environment:JQ.env.NODE_ENV||"development",platform:JQ.platform,version:JQ.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:JQ.env.NODE_ENV||JQ.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class nQ{name;fileLocks=new Map;currentKeyId=null;keys=new Map;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor(Q,X={}){this.name=Q,this.config={...TX},this.options=this.normalizeOptions(X),this.formatter=this.options.formatter||new nY,this.enabled=X.enabled??!0,this.fancy=X.fancy??!0,this.tagFormat=X.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=X.timestampPosition??"right",this.environment=X.environment??x.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(X);let Y={...X},Z=X.timestamp!==void 0;if(Z)delete Y.timestamp;if(this.config={...this.config,...Y,timestamp:Z||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let $=this.generateKeyId(),H=this.generateKey();this.currentKeyId=$,this.keys.set($,H),this.encryptionKeys.set($,{key:H,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig(Q){if(!Q.fingersCrossedEnabled&&Q.fingersCrossed)return{...hQ,...Q.fingersCrossed};if(!Q.fingersCrossedEnabled)return null;if(!Q.fingersCrossed)return{...hQ};return{...hQ,...Q.fingersCrossed}}normalizeOptions(Q){let X={format:"json",level:"info",logDirectory:TX.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},Y={...X,...Object.fromEntries(Object.entries(Q).filter(([,Z])=>Z!==void 0))};if(!Y.level||!["debug","info","success","warning","error"].includes(Y.level))Y.level=X.level;return Y}async writeToFile(Q){let Y=(async()=>{let $,H=0,U=3,G=1000;while(H<U)try{try{try{await pZ(this.config.logDirectory,GY.F_OK|GY.W_OK)}catch(_){if(_ instanceof Error&&"code"in _)if(_.code==="ENOENT")await mZ(this.config.logDirectory,{recursive:!0,mode:493});else if(_.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw _;else throw _}}catch(_){throw console.error("Debug: [writeToFile] Failed to create log directory:",_),_}let J=this.validateEncryptionConfig()?(await this.encrypt(Q)).encrypted:e.from(Q);try{if(!GX(this.currentLogFile))await _X(this.currentLogFile,"",{mode:420});if($=JY(this.currentLogFile,"a",420),fZ($,J,{flag:"a"}),UY($),$!==void 0)JX($),$=void 0;if((await HQ(this.currentLogFile)).size===0){if(await _X(this.currentLogFile,J,{flag:"w",mode:420}),(await HQ(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(_){let q=_;if(q.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(q.code)){if(H<U-1){let A=typeof q.message==="string"?q.message:"Unknown error";console.error(`Network error during write attempt ${H+1}/${U}:`,A);let z=G*2**H;await new Promise((W)=>setTimeout(W,z)),H++;continue}}if(q?.code&&["ENOSPC","EDQUOT"].includes(q.code))throw Error(`Disk quota exceeded or no space left on device: ${q.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",q),q}finally{if($!==void 0)try{JX($)}catch(_){console.error("Debug: [writeToFile] Error closing file descriptor:",_)}}}catch(J){if(H===U-1){let q=J,A=typeof q.message==="string"?q.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",A),J}H++;let _=G*2**(H-1);await new Promise((q)=>setTimeout(q,_))}})();this.pendingOperations.push(Y);let Z=this.pendingOperations.length-1;try{await Y}catch($){throw console.error("Debug: [writeToFile] Error in operation:",$),$}finally{this.pendingOperations.splice(Z,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return UQ(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return UQ(this.config.logDirectory,`${this.name}.log`);let Q=new Date().toISOString().split("T")[0];return UQ(this.config.logDirectory,`${this.name}-${Q}.log`)}setupRotation(){if(S())return;if(typeof this.config.rotation==="boolean")return;let Q=this.config.rotation,X;switch(Q.frequency){case"daily":X=86400000;break;case"weekly":X=604800000;break;case"monthly":X=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},X)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let X=this.config.rotation.keyRotation;if(!X?.enabled)return;let Y=typeof X.interval==="number"?X.interval:60,Z=Math.max(Y,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch(($)=>{console.error("Error rotating keys:",$)})},Z)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let X=this.config.rotation.keyRotation,Y=this.generateKeyId(),Z=this.generateKey();this.currentKeyId=Y,this.keys.set(Y,Z),this.encryptionKeys.set(Y,{key:Z,createdAt:new Date});let $=Array.from(this.encryptionKeys.entries()).sort(([,G],[,J])=>J.createdAt.getTime()-G.createdAt.getTime()),H=typeof X.maxKeys==="number"?X.maxKeys:1,U=Math.max(1,H);if($.length>U)for(let[G]of $.slice(U))this.encryptionKeys.delete(G),this.keys.delete(G)}generateKeyId(){return UX(16).toString("hex")}generateKey(){return UX(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let Q=this.keys.get(this.currentKeyId);if(!Q)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:Q,id:this.currentKeyId}}encrypt(Q){let{key:X}=this.getCurrentKey(),Y=UX(16),Z=vZ("aes-256-gcm",X,Y),$=e.concat([Z.update(Q,"utf8"),Z.final()]),H=Z.getAuthTag();return{encrypted:e.concat([Y,$,H]),iv:Y}}async compressData(Q){return new Promise((X,Y)=>{let Z=qY(),$=[];Z.on("data",(H)=>$.push(H)),Z.on("end",()=>X(e.from(e.concat($)))),Z.on("error",Y),Z.write(Q),Z.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let Q={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let X=this.config.rotation.encrypt;return{...Q,...X}}return Q}async rotateLog(){if(S())return;let Q=await HQ(this.currentLogFile).catch(()=>null);if(!Q)return;let X=this.config.rotation;if(typeof X==="boolean")return;if(X.maxSize&&Q.size>=X.maxSize){let Y=this.currentLogFile,Z=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let $=await MQ(this.config.logDirectory),H=$.filter((J)=>J.startsWith(this.name)&&/\.log\.\d+$/.test(J)).sort((J,_)=>{let q=Number.parseInt(J.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(_.match(/\.log\.(\d+)$/)?.[1]||"0")-q}),U=H.length>0?Number.parseInt(H[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,G=`${Y}.${U}`;if(await HQ(Y).catch(()=>null))try{if(await _Y(Y,G),X.compress)try{let J=`${G}.gz`;await this.compressLogFile(G,J),await DQ(G)}catch(J){console.error("Error compressing rotated file:",J)}if(H.length===0&&!$.some((J)=>J.endsWith(".log.1")))try{let J=`${Y}.1`;await _X(J,"")}catch(J){console.error("Error creating backup file:",J)}}catch(J){console.error(`Error during rotation: ${J instanceof Error?J.message:String(J)}`)}}else{let $=new Date().toISOString().replace(/[:.]/g,"-"),H=Y.replace(/\.log$/,`-${$}.log`);if(await HQ(Y).catch(()=>null))await _Y(Y,H)}if(this.currentLogFile=Z,X.maxFiles){let H=(await MQ(this.config.logDirectory)).filter((U)=>U.startsWith(this.name)).sort((U,G)=>G.localeCompare(U));for(let U of H.slice(X.maxFiles))await DQ(UQ(this.config.logDirectory,U))}}}async compressLogFile(Q,X){let Y=HY(Q),Z=dZ(X),$=qY();await uZ(Y,$,Z)}async handleFingersCrossedBuffer(Q,X){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(Q)&&!this.isActivated){this.isActivated=!0;for(let Y of this.logBuffer){let Z=await this.formatter.format(Y);await this.writeToFile(Z),console.log(Z)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated)await this.writeToFile(X),console.log(X);else{if(this.logBuffer.length>=this.fingersCrossedConfig.bufferSize)this.logBuffer.shift();let Y={timestamp:new Date,level:Q,message:X,name:this.name};this.logBuffer.push(Y)}}shouldActivateFingersCrossed(Q){if(!this.fingersCrossedConfig)return!1;return this.getLevelValue(Q)>=this.getLevelValue(this.fingersCrossedConfig.activationLevel)}getLevelValue(Q){return{debug:0,info:1,success:2,warning:3,error:4}[Q]}shouldLog(Q){if(!this.enabled)return!1;let X={debug:0,info:1,success:2,warning:3,error:4};return X[Q]>=X[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((Q)=>{if(Q instanceof Promise)return Q.catch((X)=>{console.error("Error in pending write operation:",X)});return Promise.resolve()})),GX(this.currentLogFile))try{let Q=JY(this.currentLogFile,"r+");UY(Q),JX(Q)}catch(Q){console.error(`Error flushing file: ${Q}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let Q of this.pendingOperations)if(typeof Q.cancel==="function")Q.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(Q){console.error("Error waiting for pending operations:",Q)}if(!S()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let X=(await MQ(this.config.logDirectory)).filter((Y)=>(Y.includes("temp")||Y.includes(".tmp"))&&Y.includes(this.name));for(let Y of X)try{await DQ(UQ(this.config.logDirectory,Y))}catch(Z){console.error(`Failed to delete temp file ${Y}:`,Z)}}catch(Q){console.error("Error cleaning up temporary files:",Q)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(Q){if(!Q)return"";return`${this.tagFormat.prefix}${Q}${this.tagFormat.suffix}`}formatFileTimestamp(Q){return`[${Q.toISOString()}]`}formatConsoleTimestamp(Q){return this.fancy?M.gray(Q.toLocaleTimeString()):Q.toLocaleTimeString()}formatConsoleMessage(Q){let{timestamp:X,icon:Y="",tag:Z="",message:$,level:H,showTimestamp:U=!0}=Q,G=(W)=>W.replace(this.ANSI_PATTERN,"");if(!this.fancy){let W=[];if(U)W.push(X);if(H==="warning")W.push("WARN");else if(H==="error")W.push("ERROR");else if(Y)W.push(Y.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(Z)W.push(Z.replace(/[[\]]/g,""));return W.push($),W.join(" ")}let J=x.stdout.columns||120,_="";if(H==="warning"||H==="error")_=`${Y} ${$}`;else if(H==="info"||H==="success")_=`${Y} ${Z} ${$}`;else _=`${Y} ${Z} ${M.cyan($)}`;if(!U)return _.trim();let q=G(_).trim().length,A=G(X).length,z=Math.max(1,J-2-q-A);return`${_.trim()}${" ".repeat(z)}${X}`}formatMessage(Q,X){if(X.length===1&&Array.isArray(X[0]))return Q.replace(/\{(\d+)\}/g,(H,U)=>{let G=Number.parseInt(U,10);return G<X[0].length?String(X[0][G]):H});let Y=/%([sdijfo%])/g,Z=0,$=Q.replace(Y,(H,U)=>{if(U==="%")return"%";if(Z>=X.length)return H;let G=X[Z++];switch(U){case"s":return String(G);case"d":case"i":return Number(G).toString();case"j":case"o":return JSON.stringify(G,null,2);default:return H}});if(Z<X.length)$+=` ${X.slice(Z).map((H)=>typeof H==="object"?JSON.stringify(H,null,2):String(H)).join(" ")}`;return $}async log(Q,X,...Y){let Z=new Date,$=this.formatConsoleTimestamp(Z),H=this.formatFileTimestamp(Z),U,G;if(X instanceof Error)U=X.message,G=X.stack;else U=this.formatMessage(X,Y);if(this.fancy&&!S()){let _=YZ[Q],q=this.options.showTags!==!1&&this.name?M.gray(this.formatTag(this.name)):"",A;switch(Q){case"debug":A=this.formatConsoleMessage({timestamp:$,icon:_,tag:q,message:M.gray(U),level:Q}),console.error(A);break;case"info":A=this.formatConsoleMessage({timestamp:$,icon:_,tag:q,message:U,level:Q}),console.error(A);break;case"success":A=this.formatConsoleMessage({timestamp:$,icon:_,tag:q,message:M.green(U),level:Q}),console.error(A);break;case"warning":A=this.formatConsoleMessage({timestamp:$,icon:_,tag:q,message:U,level:Q}),console.warn(A);break;case"error":if(A=this.formatConsoleMessage({timestamp:$,icon:_,tag:q,message:U,level:Q}),console.error(A),G){let z=G.split(`
3
3
  `);for(let W of z)if(W.trim()&&!W.includes(U))console.error(this.formatConsoleMessage({timestamp:$,message:M.gray(` ${W}`),level:Q,showTimestamp:!1}))}break}}else if(!S()){if(console.error(`${H} ${this.environment}.${Q.toUpperCase()}: ${U}`),G)console.error(G)}if(!this.shouldLog(Q))return;let J=`${H} ${this.environment}.${Q.toUpperCase()}: ${U}
4
4
  `;if(G)J+=`${G}
5
5
  `;J=J.replace(this.ANSI_PATTERN,""),await this.writeToFile(J)}time(Q){let X=performance.now();if(this.fancy&&!S()){let Y=this.options.showTags!==!1&&this.name?M.gray(this.formatTag(this.name)):"",Z=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:Z,icon:M.blue("\u25D0"),tag:Y,message:`${M.cyan(Q)}...`}))}return async(Y)=>{if(!this.enabled)return;let Z=performance.now(),$=Math.round(Z-X),H=`${Q} completed in ${$}ms`,U=new Date,G=this.formatConsoleTimestamp(U),_=`${this.formatFileTimestamp(U)} ${this.environment}.INFO: ${H}`;if(Y)_+=` ${JSON.stringify(Y)}`;if(_+=`
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{dd as a}from"./chunk-r7nh070r.js";import"./chunk-p9z0hzej.js";import"./chunk-amj037yy.js";import"./chunk-4wbbbcs2.js";import"./chunk-89s9f3mf.js";import"./chunk-ja3rvd6y.js";import"./chunk-p5yaf72b.js";import"./chunk-7crh00m7.js";import"./chunk-34rmja4x.js";import"./chunk-hyp0wfta.js";import"./chunk-4hd1mryc.js";import"./chunk-nwrr6jas.js";import"./chunk-kh6v93yb.js";import"./chunk-88j356ng.js";import"./chunk-3waqfh3y.js";import"./chunk-k7x9af5r.js";import"./chunk-jpdd59fh.js";import"./chunk-7rjrea9g.js";import"./chunk-emygmh7r.js";import"./chunk-kpqez1ht.js";import"./chunk-vckn5ate.js";import"./chunk-wreexgkb.js";import"./chunk-gvnsr72j.js";import"./chunk-1m5wprvm.js";import"./chunk-ktmgq0ja.js";import"./chunk-6k6dgwmy.js";import"./chunk-pxdrwhxx.js";import"./chunk-a3bnhq58.js";import"./chunk-8dj94fsy.js";import"./chunk-0apd8zqn.js";import"./chunk-s3ksf6s5.js";export{a as Buddy};
2
+ import{dd as a}from"./chunk-785rgtn5.js";import"./chunk-p9z0hzej.js";import"./chunk-amj037yy.js";import"./chunk-4wbbbcs2.js";import"./chunk-89s9f3mf.js";import"./chunk-ja3rvd6y.js";import"./chunk-yxb1jwxp.js";import"./chunk-7crh00m7.js";import"./chunk-34rmja4x.js";import"./chunk-hyp0wfta.js";import"./chunk-4hd1mryc.js";import"./chunk-nwrr6jas.js";import"./chunk-kh6v93yb.js";import"./chunk-88j356ng.js";import"./chunk-3waqfh3y.js";import"./chunk-k7x9af5r.js";import"./chunk-jpdd59fh.js";import"./chunk-7rjrea9g.js";import"./chunk-emygmh7r.js";import"./chunk-kpqez1ht.js";import"./chunk-vckn5ate.js";import"./chunk-wreexgkb.js";import"./chunk-gvnsr72j.js";import"./chunk-1m5wprvm.js";import"./chunk-ktmgq0ja.js";import"./chunk-6k6dgwmy.js";import"./chunk-pxdrwhxx.js";import"./chunk-a3bnhq58.js";import"./chunk-8dj94fsy.js";import"./chunk-0apd8zqn.js";import"./chunk-s3ksf6s5.js";export{a as Buddy};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Da as a}from"./chunk-d4wqe366.js";import"./chunk-r7nh070r.js";import"./chunk-p9z0hzej.js";import"./chunk-amj037yy.js";import"./chunk-4wbbbcs2.js";import"./chunk-89s9f3mf.js";import"./chunk-ja3rvd6y.js";import"./chunk-p5yaf72b.js";import"./chunk-7crh00m7.js";import"./chunk-34rmja4x.js";import"./chunk-hyp0wfta.js";import"./chunk-4hd1mryc.js";import"./chunk-nwrr6jas.js";import"./chunk-kh6v93yb.js";import"./chunk-88j356ng.js";import"./chunk-3waqfh3y.js";import"./chunk-k7x9af5r.js";import"./chunk-jpdd59fh.js";import"./chunk-7rjrea9g.js";import"./chunk-emygmh7r.js";import"./chunk-kpqez1ht.js";import"./chunk-vckn5ate.js";import"./chunk-wreexgkb.js";import"./chunk-gvnsr72j.js";import"./chunk-1m5wprvm.js";import"./chunk-ktmgq0ja.js";import"./chunk-6k6dgwmy.js";import"./chunk-pxdrwhxx.js";import"./chunk-a3bnhq58.js";import"./chunk-8dj94fsy.js";import"./chunk-0apd8zqn.js";import"./chunk-s3ksf6s5.js";export{a as Scheduler};
2
+ import{Da as a}from"./chunk-6w8vxy7s.js";import"./chunk-785rgtn5.js";import"./chunk-p9z0hzej.js";import"./chunk-amj037yy.js";import"./chunk-4wbbbcs2.js";import"./chunk-89s9f3mf.js";import"./chunk-ja3rvd6y.js";import"./chunk-yxb1jwxp.js";import"./chunk-7crh00m7.js";import"./chunk-34rmja4x.js";import"./chunk-hyp0wfta.js";import"./chunk-4hd1mryc.js";import"./chunk-nwrr6jas.js";import"./chunk-kh6v93yb.js";import"./chunk-88j356ng.js";import"./chunk-3waqfh3y.js";import"./chunk-k7x9af5r.js";import"./chunk-jpdd59fh.js";import"./chunk-7rjrea9g.js";import"./chunk-emygmh7r.js";import"./chunk-kpqez1ht.js";import"./chunk-vckn5ate.js";import"./chunk-wreexgkb.js";import"./chunk-gvnsr72j.js";import"./chunk-1m5wprvm.js";import"./chunk-ktmgq0ja.js";import"./chunk-6k6dgwmy.js";import"./chunk-pxdrwhxx.js";import"./chunk-a3bnhq58.js";import"./chunk-8dj94fsy.js";import"./chunk-0apd8zqn.js";import"./chunk-s3ksf6s5.js";export{a as Scheduler};
@@ -1,7 +1,7 @@
1
1
  // @bun
2
- import{Ve as l}from"./chunk-kh6v93yb.js";import{ag as c,jg as A}from"./chunk-wreexgkb.js";import{rg as y}from"./chunk-gvnsr72j.js";import{xh as k}from"./chunk-6k6dgwmy.js";import{Oh as i}from"./chunk-8dj94fsy.js";import u from"process";var d=/\{([a-z_]+)\}/gi,b={title:"title",message:"message",group:"group",count:"count",strategy:"strategy",update_type:"updateType",updateType:"updateType",packages:"packages",updates_table:"updatesTable",release_notes:"releaseNotes",footer:"footer",package_count:"packageCount"};function C(W,$){return W.replace(d,(Y,R)=>{let K=b[R]??b[R.toLowerCase()];if(!K)return Y;let H=$[K];return H===void 0?Y:String(H)})}function f(W,$={},Y){return{...$,group:W.name,count:W.updates.length,packageCount:W.updates.length,updateType:W.updateType,packages:W.updates.map((R)=>R.name).join(", "),...Y?{strategy:Y}:{}}}class p{config;releaseNotesFetcher=new l;verbose=!1;logger;constructor(W,$){this.config=W;this.verbose=W?.verbose||u.env.BUDDY_VERBOSE==="true",this.logger=$??i()}get releaseNotesSettings(){let W=this.config?.releaseNotes;return{enabled:W?.enabled??!0,maxReleases:W?.maxReleases??3,maxBodyLength:W?.maxBodyLength??1000,includeCompareLinks:W?.includeCompareLinks??!0}}repositoryFileUrl(W){let $=k(this.config),{owner:Y,name:R,baseBranch:K}=this.config?.repository??{};return`${$}/${Y}/${R}/blob/${K||"main"}/${W}`}log(W,$){if(this.verbose){let Y=new Date().toISOString();if(this.logger.info(`[${Y}] PR-GEN: ${W}`),$)this.logger.info(JSON.stringify($,null,2))}}async generatePullRequests(W){let $=[];for(let Y of W){let R=this.generateTitle(Y),K=await this.generateBody(Y),H={number:0,title:R,body:K,head:`buddy/update-${Y.name.toLowerCase().replace(/\s+/g,"-")}`,base:"main",state:"open",url:"",createdAt:new Date,updatedAt:new Date,author:"github-actions[bot]",reviewers:[],assignees:[],labels:this.generateLabels(Y),draft:!1};$.push(H)}return $}generateLabels(W){let $=["dependencies"];if(W.updateType==="major")$.push("major");else if(W.updateType==="minor")$.push("minor");else if(W.updateType==="patch")$.push("patch");let Y=W.updates.filter((B)=>B.file==="package.json"||B.file.endsWith("/package.json")||B.file.endsWith("\\package.json")).length,R=W.updates.filter((B)=>B.file.endsWith("composer.json")||B.file.endsWith("composer.lock")).length,K=W.updates.filter((B)=>B.file.endsWith("build.zig.zon")).length,H=W.updates.filter((B)=>(B.file.includes(".yaml")||B.file.includes(".yml"))&&!B.file.includes(".github/workflows/")).length,Z=W.updates.filter((B)=>B.file.includes(".github/workflows/")).length;if(Y>0)$.push("npm");if(R>0)$.push("composer");if(K>0)$.push("zig");if(H>0)$.push("system");if(Z>0)$.push("github-actions");if(W.updates.length===1){let B=W.updates[0];$.push(B.name)}if(W.updates.length>=5)$.push("bulk-update");return $}generateTitle(W){let $=this.config?.pullRequest?.titleFormat;if($)return C($,f(W,{title:this.defaultTitle(W)},this.config?.packages?.strategy));return this.defaultTitle(W)}defaultTitle(W){if(W.updates.length===1){let R=W.updates[0];return`chore(deps): update dependency ${R.name} to v${R.newVersion}`}let $=W.updates.filter((R)=>R.updateType==="major").length,Y=W.updates.filter((R)=>R.updateType==="minor").length;if($>0)return`chore(deps): update ${W.updates.length} dependencies (major)`;else if(Y>0)return`chore(deps): update ${W.updates.length} dependencies (minor)`;else return`chore(deps): update ${W.updates.length} dependencies (patch)`}async generateBody(W){if(this.log("\uD83D\uDE80 Starting PR body generation",{groupName:W.name,totalUpdates:W.updates.length,updates:W.updates.map((Q)=>({name:Q.name,file:Q.file,dependencyType:Q.dependencyType,currentVersion:Q.currentVersion,newVersion:Q.newVersion,updateType:Q.updateType}))}),W.updates.length===0)this.log("\u26A0\uFE0F WARNING: No updates in group - this will result in sparse PR body",{groupName:W.name,groupTitle:W.title});let $=W.updates.filter((Q)=>Q.file==="package.json"||Q.file.endsWith("/package.json")||Q.file.endsWith("\\package.json")).length,Y=W.updates.filter((Q)=>(Q.file.includes(".yaml")||Q.file.includes(".yml"))&&!Q.file.includes(".github/workflows/")).length,R=W.updates.filter((Q)=>Q.file.includes(".github/workflows/")).length,K=W.updates.filter((Q)=>Q.file.endsWith("composer.json")||Q.file.endsWith("composer.lock")).length,H=W.updates.filter((Q)=>Q.file.endsWith("build.zig.zon")).length;if(this.log("\uD83D\uDCCA Package type counts",{packageJsonCount:$,dependencyFileCount:Y,githubActionsCount:R,composerCount:K,total:W.updates.length}),W.updates.length>0)this.log("\uD83D\uDD0D File path analysis",{files:W.updates.map((Q)=>({name:Q.name,file:Q.file,isExactMatch:Q.file==="package.json",endsWithSlash:Q.file.endsWith("/package.json"),endsWithBackslash:Q.file.endsWith("\\package.json"),matchesAny:Q.file==="package.json"||Q.file.endsWith("/package.json")||Q.file.endsWith("\\package.json")}))});let Z=`This PR contains the following updates:
2
+ import{Ve as c}from"./chunk-kh6v93yb.js";import{ag as l,jg as A}from"./chunk-wreexgkb.js";import{rg as y}from"./chunk-gvnsr72j.js";import{xh as k}from"./chunk-6k6dgwmy.js";import{Oh as i}from"./chunk-8dj94fsy.js";import u from"process";var d=/\{([a-z_]+)\}/gi,b={title:"title",message:"message",group:"group",count:"count",strategy:"strategy",update_type:"updateType",updateType:"updateType",packages:"packages",updates_table:"updatesTable",release_notes:"releaseNotes",footer:"footer",package_count:"packageCount"};function h(W,$){return W.replace(d,(Y,R)=>{let K=b[R]??b[R.toLowerCase()];if(!K)return Y;let H=$[K];return H===void 0?Y:String(H)})}function f(W,$={},Y){return{...$,group:W.name,count:W.updates.length,packageCount:W.updates.length,updateType:W.updateType,packages:W.updates.map((R)=>R.name).join(", "),...Y?{strategy:Y}:{}}}class p{config;releaseNotesFetcher=new c;verbose=!1;logger;constructor(W,$){this.config=W;this.verbose=W?.verbose||u.env.BUDDY_VERBOSE==="true",this.logger=$??i()}get releaseNotesSettings(){let W=this.config?.releaseNotes;return{enabled:W?.enabled??!0,maxReleases:W?.maxReleases??3,maxBodyLength:W?.maxBodyLength??1000,includeCompareLinks:W?.includeCompareLinks??!0}}repositoryFileUrl(W){let $=k(this.config),{owner:Y,name:R,baseBranch:K}=this.config?.repository??{};return`${$}/${Y}/${R}/blob/${K||"main"}/${W}`}log(W,$){if(this.verbose){let Y=new Date().toISOString();if(this.logger.info(`[${Y}] PR-GEN: ${W}`),$)this.logger.info(JSON.stringify($,null,2))}}async generatePullRequests(W){let $=[];for(let Y of W){let R=this.generateTitle(Y),K=await this.generateBody(Y),H={number:0,title:R,body:K,head:`buddy/update-${Y.name.toLowerCase().replace(/\s+/g,"-")}`,base:"main",state:"open",url:"",createdAt:new Date,updatedAt:new Date,author:"github-actions[bot]",reviewers:[],assignees:[],labels:this.generateLabels(Y),draft:!1};$.push(H)}return $}generateLabels(W){let $=["dependencies"];if(W.updateType==="major")$.push("major");else if(W.updateType==="minor")$.push("minor");else if(W.updateType==="patch")$.push("patch");let Y=W.updates.filter((D)=>D.file==="package.json"||D.file.endsWith("/package.json")||D.file.endsWith("\\package.json")).length,R=W.updates.filter((D)=>D.file.endsWith("composer.json")||D.file.endsWith("composer.lock")).length,K=W.updates.filter((D)=>D.file.endsWith("build.zig.zon")).length,H=W.updates.filter((D)=>(D.file.includes(".yaml")||D.file.includes(".yml"))&&!D.file.includes(".github/workflows/")).length,Z=W.updates.filter((D)=>D.file.includes(".github/workflows/")).length;if(Y>0)$.push("npm");if(R>0)$.push("composer");if(K>0)$.push("zig");if(H>0)$.push("system");if(Z>0)$.push("github-actions");if(W.updates.length===1){let D=W.updates[0];$.push(D.name)}if(W.updates.length>=5)$.push("bulk-update");return $}generateTitle(W){let $=this.config?.pullRequest?.titleFormat;if($)return h($,f(W,{title:this.defaultTitle(W)},this.config?.packages?.strategy));return this.defaultTitle(W)}defaultTitle(W){if(W.updates.length===1){let R=W.updates[0];return`chore(deps): update dependency ${R.name} to v${R.newVersion}`}let $=W.updates.filter((R)=>R.updateType==="major").length,Y=W.updates.filter((R)=>R.updateType==="minor").length;if($>0)return`chore(deps): update ${W.updates.length} dependencies (major)`;else if(Y>0)return`chore(deps): update ${W.updates.length} dependencies (minor)`;else return`chore(deps): update ${W.updates.length} dependencies (patch)`}async generateBody(W){if(this.log("\uD83D\uDE80 Starting PR body generation",{groupName:W.name,totalUpdates:W.updates.length,updates:W.updates.map((Q)=>({name:Q.name,file:Q.file,dependencyType:Q.dependencyType,currentVersion:Q.currentVersion,newVersion:Q.newVersion,updateType:Q.updateType}))}),W.updates.length===0)this.log("\u26A0\uFE0F WARNING: No updates in group - this will result in sparse PR body",{groupName:W.name,groupTitle:W.title});let $=W.updates.filter((Q)=>Q.file==="package.json"||Q.file.endsWith("/package.json")||Q.file.endsWith("\\package.json")).length,Y=W.updates.filter((Q)=>(Q.file.includes(".yaml")||Q.file.includes(".yml"))&&!Q.file.includes(".github/workflows/")).length,R=W.updates.filter((Q)=>Q.file.includes(".github/workflows/")).length,K=W.updates.filter((Q)=>Q.file.endsWith("composer.json")||Q.file.endsWith("composer.lock")).length,H=W.updates.filter((Q)=>Q.file.endsWith("build.zig.zon")).length;if(this.log("\uD83D\uDCCA Package type counts",{packageJsonCount:$,dependencyFileCount:Y,githubActionsCount:R,composerCount:K,total:W.updates.length}),W.updates.length>0)this.log("\uD83D\uDD0D File path analysis",{files:W.updates.map((Q)=>({name:Q.name,file:Q.file,isExactMatch:Q.file==="package.json",endsWithSlash:Q.file.endsWith("/package.json"),endsWithBackslash:Q.file.endsWith("\\package.json"),matchesAny:Q.file==="package.json"||Q.file.endsWith("/package.json")||Q.file.endsWith("\\package.json")}))});let Z=`This PR contains the following updates:
3
3
 
4
- `;Z+=c(W.updates);let B=W.updates.length>1;if(B){if(Z+=`## Package Updates Summary
4
+ `;Z+=l(W.updates);let D=W.updates.length>1;if(D){if(Z+=`## Package Updates Summary
5
5
 
6
6
  `,Z+=`| Type | Count |
7
7
  `,Z+=`|------|-------|
@@ -12,17 +12,17 @@ import{Ve as l}from"./chunk-kh6v93yb.js";import{ag as c,jg as A}from"./chunk-wre
12
12
  `;if(H>0)Z+=`| \u26A1 Zig Packages | ${H} |
13
13
  `;Z+=`| **Total** | **${W.updates.length}** |
14
14
 
15
- `}let E=W.updates.filter((Q)=>Q.file==="package.json"||Q.file.endsWith("/package.json")||Q.file.endsWith("\\package.json")),x=W.updates.filter((Q)=>Q.file.endsWith("composer.json")||Q.file.endsWith("composer.lock")),q=W.updates.filter((Q)=>Q.file.endsWith("build.zig.zon")),S=W.updates.filter((Q)=>Q.file.includes(".yaml")||Q.file.includes(".yml")).filter((Q)=>!Q.file.includes(".github/workflows/")),P=W.updates.filter((Q)=>Q.file.includes(".github/workflows/"));this.log("\uD83D\uDCDD Filtered updates by type",{packageJsonUpdates:{count:E.length,items:E.map((Q)=>({name:Q.name,file:Q.file}))},composerUpdates:{count:x.length,items:x.map((Q)=>({name:Q.name,file:Q.file}))},dependencyFileUpdates:{count:S.length,items:S.map((Q)=>({name:Q.name,file:Q.file}))},githubActionsUpdates:{count:P.length,items:P.map((Q)=>({name:Q.name,file:Q.file}))}});let T=new Map;for(let Q of P){let X=`${Q.name}@${Q.currentVersion}=>${Q.newVersion}`,D=T.get(X);if(D)D.files.add(Q.file);else T.set(X,{update:Q,files:new Set([Q.file])})}let V=Array.from(T.values()).map(({update:Q,files:X})=>({...Q,file:Array.from(X).join(", ")})),U=new Set,w=[];for(let Q of x){let X=`${Q.name}@${Q.currentVersion}=>${Q.newVersion}`;if(!U.has(X))U.add(X),w.push(Q)}let F=new Map,m=new Map;if(E.length>0){if(this.log("\u2705 Generating npm Dependencies section",{packageCount:E.length,packages:E.map((_)=>_.name)}),B||$<W.updates.length)Z+=`## \uD83D\uDCE6 npm Dependencies
15
+ `}let B=W.updates.filter((Q)=>Q.file==="package.json"||Q.file.endsWith("/package.json")||Q.file.endsWith("\\package.json")),x=W.updates.filter((Q)=>Q.file.endsWith("composer.json")||Q.file.endsWith("composer.lock")),q=W.updates.filter((Q)=>Q.file.endsWith("build.zig.zon")),S=W.updates.filter((Q)=>Q.file.includes(".yaml")||Q.file.includes(".yml")).filter((Q)=>!Q.file.includes(".github/workflows/")),P=W.updates.filter((Q)=>Q.file.includes(".github/workflows/"));this.log("\uD83D\uDCDD Filtered updates by type",{packageJsonUpdates:{count:B.length,items:B.map((Q)=>({name:Q.name,file:Q.file}))},composerUpdates:{count:x.length,items:x.map((Q)=>({name:Q.name,file:Q.file}))},dependencyFileUpdates:{count:S.length,items:S.map((Q)=>({name:Q.name,file:Q.file}))},githubActionsUpdates:{count:P.length,items:P.map((Q)=>({name:Q.name,file:Q.file}))}});let T=new Map;for(let Q of P){let X=`${Q.name}@${Q.currentVersion}=>${Q.newVersion}`,L=T.get(X);if(L)L.files.add(Q.file);else T.set(X,{update:Q,files:new Set([Q.file])})}let V=Array.from(T.values()).map(({update:Q,files:X})=>({...Q,file:Array.from(X).join(", ")})),U=new Set,w=[];for(let Q of x){let X=`${Q.name}@${Q.currentVersion}=>${Q.newVersion}`;if(!U.has(X))U.add(X),w.push(Q)}let F=new Map,m=new Map;if(B.length>0){if(this.log("\u2705 Generating npm Dependencies section",{packageCount:B.length,packages:B.map((_)=>_.name)}),D||$<W.updates.length)Z+=`## \uD83D\uDCE6 npm Dependencies
16
16
 
17
17
  `;if(Z+=`![npm](https://img.shields.io/badge/npm-CB3837?style=flat&logo=npm&logoColor=white)
18
18
 
19
- `,E.length>1)Z+=`*${E.length} packages will be updated*
19
+ `,B.length>1)Z+=`*${B.length} packages will be updated*
20
20
 
21
21
  `;Z+=`| Package | Change | Age | Adoption | Passing | Confidence |
22
22
  `,Z+=`|---|---|---|---|---|---|
23
- `;let Q=Date.now();this.log(`\u23F1\uFE0F Starting to fetch info for ${E.length} npm packages in parallel...`);let X=(this.releaseNotesSettings.enabled?E:[]).map(async(_)=>{let M=Date.now();try{let L=_.name.replace(/\s*\(dev\)$/,"").replace(/\s*\(peer\)$/,"").replace(/\s*\(optional\)$/,""),j=await this.releaseNotesFetcher.fetchPackageInfo(L,_.currentVersion,_.newVersion);return this.log(`\u23F1\uFE0F Fetched ${L} in ${Date.now()-M}ms`),{name:_.name,result:j}}catch(L){return this.logger.warn(`Failed to fetch info for ${_.name}:`,L),null}});(await Promise.all(X)).forEach((_)=>{if(_)F.set(_.name,_.result)});let O=Date.now()-Q;this.log(`\u23F1\uFE0F Total npm package info fetch took ${O}ms for ${E.length} packages (avg: ${Math.round(O/E.length)}ms per package)`),this.logger.info(`\u23F1\uFE0F [PR-GEN] npm package info fetch: ${O}ms for ${E.length} packages (PARALLEL)`);for(let _ of E){let L=F.get(_.name)?.packageInfo||{name:_.name},j=_.name.replace(/\s*\(dev\)$/,"").replace(/\s*\(peer\)$/,"").replace(/\s*\(optional\)$/,""),z;if(L.repository?.url){let J=this.getRepositorySourceUrl(L.repository.url,j),h=this.getRepositorySourceUrl(L.repository.url,j,"HEAD");z=`[${j}](${J}) ([source](${h}))`}else if(j.startsWith("@types/")){let J=j.replace("@types/",""),h=`https://redirect.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/${J}`,r=`https://redirect.github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/${J}`;z=`[${j}](${h}) ([source](${r}))`}else z=`[${j}](https://www.npmjs.com/package/${encodeURIComponent(j)})`;let v=`https://renovatebot.com/diffs/npm/${encodeURIComponent(j)}/${encodeURIComponent(_.currentVersion)}/${encodeURIComponent(_.newVersion)}`,g=this.escapeMarkdownTableValue(_.currentVersion),n=this.escapeMarkdownTableValue(_.newVersion),s=`[\`${g}\` -> \`${n}\`](${v})`,I=this.releaseNotesFetcher.generatePackageBadges({...L,name:j},_.currentVersion,_.newVersion);Z+=`| ${z} | ${s} | ${I.age} | ${I.adoption} | ${I.passing} | ${I.confidence} |
23
+ `;let Q=Date.now();this.log(`\u23F1\uFE0F Starting to fetch info for ${B.length} npm packages in parallel...`);let X=(this.releaseNotesSettings.enabled?B:[]).map(async(_)=>{let M=Date.now();try{let O=_.name.replace(/\s*\(dev\)$/,"").replace(/\s*\(peer\)$/,"").replace(/\s*\(optional\)$/,""),j=await this.releaseNotesFetcher.fetchPackageInfo(O,_.currentVersion,_.newVersion);return this.log(`\u23F1\uFE0F Fetched ${O} in ${Date.now()-M}ms`),{name:_.name,result:j}}catch(O){return this.logger.warn(`Failed to fetch info for ${_.name}:`,O),null}});(await Promise.all(X)).forEach((_)=>{if(_)F.set(_.name,_.result)});let z=Date.now()-Q;this.log(`\u23F1\uFE0F Total npm package info fetch took ${z}ms for ${B.length} packages (avg: ${Math.round(z/B.length)}ms per package)`),this.logger.info(`\u23F1\uFE0F [PR-GEN] npm package info fetch: ${z}ms for ${B.length} packages (PARALLEL)`);for(let _ of B){let O=F.get(_.name)?.packageInfo||{name:_.name},j=_.name.replace(/\s*\(dev\)$/,"").replace(/\s*\(peer\)$/,"").replace(/\s*\(optional\)$/,""),E;if(O.repository?.url){let J=this.getRepositorySourceUrl(O.repository.url,j),C=this.getRepositorySourceUrl(O.repository.url,j,"HEAD");E=`[${j}](${J}) ([source](${C}))`}else if(j.startsWith("@types/")){let J=j.replace("@types/",""),C=`https://redirect.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/${J}`,r=`https://redirect.github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/${J}`;E=`[${j}](${C}) ([source](${r}))`}else E=`[${j}](https://www.npmjs.com/package/${encodeURIComponent(j)})`;let v=`https://renovatebot.com/diffs/npm/${encodeURIComponent(j)}/${encodeURIComponent(_.currentVersion)}/${encodeURIComponent(_.newVersion)}`,g=this.escapeMarkdownTableValue(_.currentVersion),n=this.escapeMarkdownTableValue(_.newVersion),s=`[\`${g}\` -> \`${n}\`](${v})`,I=this.releaseNotesFetcher.generatePackageBadges({...O,name:j},_.currentVersion,_.newVersion);Z+=`| ${E} | ${s} | ${I.age} | ${I.adoption} | ${I.passing} | ${I.confidence} |
24
24
  `}Z+=`
25
- `}if(w.length>0){for(let Q of w)try{let X=await this.releaseNotesFetcher.fetchComposerPackageInfo(Q.name);m.set(Q.name,X)}catch(X){this.logger.warn(`Failed to fetch Composer info for ${Q.name}:`,X)}if(B||K<W.updates.length)Z+=`## \uD83D\uDC18 PHP/Composer Dependencies
25
+ `}if(w.length>0){for(let Q of w)try{let X=await this.releaseNotesFetcher.fetchComposerPackageInfo(Q.name);m.set(Q.name,X)}catch(X){this.logger.warn(`Failed to fetch Composer info for ${Q.name}:`,X)}if(D||K<W.updates.length)Z+=`## \uD83D\uDC18 PHP/Composer Dependencies
26
26
 
27
27
  `;if(Z+=`![composer](https://img.shields.io/badge/composer-885630?style=flat&logo=composer&logoColor=white)
28
28
 
@@ -30,9 +30,9 @@ import{Ve as l}from"./chunk-kh6v93yb.js";import{ag as c,jg as A}from"./chunk-wre
30
30
 
31
31
  `;Z+=`| Package | Change | Age | Adoption | Passing | Confidence | Type | Update |
32
32
  `,Z+=`|---|---|---|---|---|---|---|---|
33
- `;for(let Q of w){let X=m.get(Q.name)||{name:Q.name},D;if(X.homepage&&X.repository?.url){let v=this.getComposerRedirectSourceUrl(X.repository.url,Q.name);D=`[${Q.name}](${X.homepage}) ([source](${v}))`}else if(X.repository?.url){let v=this.getComposerRedirectSourceUrl(X.repository.url,Q.name);D=`[${Q.name}](${v})`}else D=`[${Q.name}](https://packagist.org/packages/${encodeURIComponent(Q.name)})`;let O=this.getConstraintStyleChange(Q.currentVersion,Q.newVersion),_=`https://renovatebot.com/diffs/packagist/${encodeURIComponent(Q.name)}/${Q.currentVersion}/${Q.newVersion}`,M=`[\`${O}\`](${_})`,L=this.releaseNotesFetcher.generateComposerBadges(X,Q.currentVersion,Q.newVersion),j=Q.dependencyType||"require",z=Q.updateType||"minor";Z+=`| ${D} | ${M} | ${L.age} | ${L.adoption} | ${L.passing} | ${L.confidence} | ${j} | ${z} |
33
+ `;for(let Q of w){let X=m.get(Q.name)||{name:Q.name},L;if(X.homepage&&X.repository?.url){let v=this.getComposerRedirectSourceUrl(X.repository.url,Q.name);L=`[${Q.name}](${X.homepage}) ([source](${v}))`}else if(X.repository?.url){let v=this.getComposerRedirectSourceUrl(X.repository.url,Q.name);L=`[${Q.name}](${v})`}else L=`[${Q.name}](https://packagist.org/packages/${encodeURIComponent(Q.name)})`;let z=this.getConstraintStyleChange(Q.currentVersion,Q.newVersion),_=`https://renovatebot.com/diffs/packagist/${encodeURIComponent(Q.name)}/${Q.currentVersion}/${Q.newVersion}`,M=`[\`${z}\`](${_})`,O=this.releaseNotesFetcher.generateComposerBadges(X,Q.currentVersion,Q.newVersion),j=Q.dependencyType||"require",E=Q.updateType||"minor";Z+=`| ${L} | ${M} | ${O.age} | ${O.adoption} | ${O.passing} | ${O.confidence} | ${j} | ${E} |
34
34
  `}Z+=`
35
- `}if(q.length>0){if(B||H<W.updates.length)Z+=`## \u26A1 Zig Dependencies
35
+ `}if(q.length>0){if(D||H<W.updates.length)Z+=`## \u26A1 Zig Dependencies
36
36
 
37
37
  `;if(Z+=`![zig](https://img.shields.io/badge/Zig-F7A41D?style=flat&logo=zig&logoColor=white)
38
38
 
@@ -40,9 +40,9 @@ import{Ve as l}from"./chunk-kh6v93yb.js";import{ag as c,jg as A}from"./chunk-wre
40
40
 
41
41
  `;Z+=`| Package | Change | Type | File |
42
42
  `,Z+=`|---|---|---|---|
43
- `;for(let Q of q){let X,D=Q.metadata;if(D?.url){let z=D.url.match(/https?:\/\/github\.com\/([^/]+\/[^/]+)/);if(z){let v=`https://github.com/${z[1]}`;X=`[${Q.name}](${v})`}else X=Q.name}else X=Q.name;let O=A(Q.currentVersion,Q.newVersion),_=O==="major"?"\uD83D\uDD34":O==="minor"?"\uD83D\uDFE1":"\uD83D\uDFE2",M=this.formatVersionChange(Q.currentVersion,Q.newVersion),L=Q.file.split("/").pop()||Q.file,j=this.config?.repository?.owner&&this.config?.repository?.name?`[\`${L}\`](${this.repositoryFileUrl(Q.file)})`:`\`${L}\``;Z+=`| ${X} | ${M} | ${_} ${O} | ${j} |
43
+ `;for(let Q of q){let X,L=Q.metadata;if(L?.url){let E=L.url.match(/https?:\/\/github\.com\/([^/]+\/[^/]+)/);if(E){let v=`https://github.com/${E[1]}`;X=`[${Q.name}](${v})`}else X=Q.name}else X=Q.name;let z=A(Q.currentVersion,Q.newVersion),_=z==="major"?"\uD83D\uDD34":z==="minor"?"\uD83D\uDFE1":"\uD83D\uDFE2",M=this.formatVersionChange(Q.currentVersion,Q.newVersion),O=Q.file.split("/").pop()||Q.file,j=this.config?.repository?.owner&&this.config?.repository?.name?`[\`${O}\`](${this.repositoryFileUrl(Q.file)})`:`\`${O}\``;Z+=`| ${X} | ${M} | ${_} ${z} | ${j} |
44
44
  `}Z+=`
45
- `}if(S.length>0){if(B||Y<W.updates.length)Z+=`## \uD83D\uDD27 System Dependencies
45
+ `}if(S.length>0){if(D||Y<W.updates.length)Z+=`## \uD83D\uDD27 System Dependencies
46
46
 
47
47
  `;Z+=`![system](https://img.shields.io/badge/system-4CAF50?style=flat&logo=linux&logoColor=white)
48
48
 
@@ -50,9 +50,9 @@ import{Ve as l}from"./chunk-kh6v93yb.js";import{ag as c,jg as A}from"./chunk-wre
50
50
 
51
51
  `;Z+=`| Package | Change | Type | File |
52
52
  `,Z+=`|---|---|---|---|
53
- `;for(let X of S){let D=X.name==="bun.sh"?"bun.com":X.name,O=X.name==="bun.sh"?"https://bun.sh":`https://pkgx.com/pkg/${encodeURIComponent(X.name)}`,_=`[${D}](${O})`,M=A(X.currentVersion,X.newVersion),L=M==="major"?"\uD83D\uDD34":M==="minor"?"\uD83D\uDFE1":"\uD83D\uDFE2",j=this.formatVersionChange(X.currentVersion,X.newVersion),z=X.file.split("/").pop()||X.file,v=this.config?.repository?.owner&&this.config?.repository?.name?`[\`${z}\`](${this.repositoryFileUrl(X.file)})`:`\`${z}\``;Z+=`| ${_} | ${j} | ${L} ${M} | ${v} |
53
+ `;for(let X of S){let L=X.name==="bun.sh"?"bun.com":X.name,z=X.name==="bun.sh"?"https://bun.sh":`https://pkgx.com/pkg/${encodeURIComponent(X.name)}`,_=`[${L}](${z})`,M=A(X.currentVersion,X.newVersion),O=M==="major"?"\uD83D\uDD34":M==="minor"?"\uD83D\uDFE1":"\uD83D\uDFE2",j=this.formatVersionChange(X.currentVersion,X.newVersion),E=X.file.split("/").pop()||X.file,v=this.config?.repository?.owner&&this.config?.repository?.name?`[\`${E}\`](${this.repositoryFileUrl(X.file)})`:`\`${E}\``;Z+=`| ${_} | ${j} | ${O} ${M} | ${v} |
54
54
  `}Z+=`
55
- `}if(V.length>0){if(B||R<W.updates.length)Z+=`## \uD83D\uDE80 GitHub Actions
55
+ `}if(V.length>0){if(D||R<W.updates.length)Z+=`## \uD83D\uDE80 GitHub Actions
56
56
 
57
57
  `;if(Z+=`![github-actions](https://img.shields.io/badge/GitHub%20Actions-2088FF?style=flat&logo=github-actions&logoColor=white)
58
58
 
@@ -60,35 +60,35 @@ import{Ve as l}from"./chunk-kh6v93yb.js";import{ag as c,jg as A}from"./chunk-wre
60
60
 
61
61
  `;Z+=`| Action | Change | Type | Files |
62
62
  `,Z+=`|---|---|---|---|
63
- `;for(let Q of V){let X=`${k(this.config)}/${Q.name}`,D=`[${Q.name}](${X})`,O=A(Q.currentVersion,Q.newVersion),_=O==="major"?"\uD83D\uDD34":O==="minor"?"\uD83D\uDFE1":"\uD83D\uDFE2",M=this.formatVersionChange(Q.currentVersion,Q.newVersion),L=Q.file.includes(", ")?Q.file.split(", ").map((j)=>{let z=j.split("/").pop()||j;return this.config?.repository?.owner&&this.config?.repository?.name?`[\`${z}\`](${this.repositoryFileUrl(j)})`:`\`${z}\``}).join(", "):(()=>{let j=Q.file.split("/").pop()||Q.file;return this.config?.repository?.owner&&this.config?.repository?.name?`[\`${j}\`](${this.repositoryFileUrl(Q.file)})`:`\`${j}\``})();Z+=`| ${D} | ${M} | ${_} ${O} | ${L} |
63
+ `;for(let Q of V){let X=`${k(this.config)}/${Q.name}`,L=`[${Q.name}](${X})`,z=A(Q.currentVersion,Q.newVersion),_=z==="major"?"\uD83D\uDD34":z==="minor"?"\uD83D\uDFE1":"\uD83D\uDFE2",M=this.formatVersionChange(Q.currentVersion,Q.newVersion),O=Q.file.includes(", ")?Q.file.split(", ").map((j)=>{let E=j.split("/").pop()||j;return this.config?.repository?.owner&&this.config?.repository?.name?`[\`${E}\`](${this.repositoryFileUrl(j)})`:`\`${E}\``}).join(", "):(()=>{let j=Q.file.split("/").pop()||Q.file;return this.config?.repository?.owner&&this.config?.repository?.name?`[\`${j}\`](${this.repositoryFileUrl(Q.file)})`:`\`${j}\``})();Z+=`| ${L} | ${M} | ${_} ${z} | ${O} |
64
64
  `}Z+=`
65
65
  `}Z+=`
66
66
  ---
67
67
 
68
68
  `;let G=this.releaseNotesSettings;if(!G.enabled)return this.finalizeBody(Z,W);Z+=`### Release Notes
69
69
 
70
- `;for(let Q of E){let X=F.get(Q.name),D=X?.packageInfo||{name:Q.name},O=X?.releaseNotes||[],_=X?.compareUrl;Z+=`<details>
71
- `;let M,L=Q.name.replace(/\s*\(dev\)$/,"").replace(/\s*\(peer\)$/,"").replace(/\s*\(optional\)$/,"");if(D.repository?.url)M=`${this.getRepositoryName(D.repository.url)} (${L})`;else M=L;if(Z+=`<summary>${M}</summary>
70
+ `;for(let Q of B){let X=F.get(Q.name),L=X?.packageInfo||{name:Q.name},z=X?.releaseNotes||[],_=X?.compareUrl;Z+=`<details>
71
+ `;let M,O=Q.name.replace(/\s*\(dev\)$/,"").replace(/\s*\(peer\)$/,"").replace(/\s*\(optional\)$/,"");if(L.repository?.url)M=`${this.getRepositoryName(L.repository.url)} (${O})`;else M=O;if(Z+=`<summary>${M}</summary>
72
72
 
73
73
  `,Z+=`**${Q.currentVersion} -> ${Q.newVersion}**
74
74
 
75
- `,O.length>0)for(let j of O.slice(0,G.maxReleases)){if(Z+=`### [\`${j.version}\`](${j.htmlUrl})
75
+ `,z.length>0)for(let j of z.slice(0,G.maxReleases)){if(Z+=`### [\`${j.version}\`](${j.htmlUrl})
76
76
 
77
77
  `,_&&G.includeCompareLinks)Z+=`[Compare Source](${_})
78
78
 
79
- `;if(j.body){let z=this.cleanReleaseBody(j.body);Z+=`${z}
79
+ `;if(j.body){let E=this.cleanReleaseBody(j.body);Z+=`${E}
80
80
 
81
81
  `}if(j.author)Z+=`*Released by [${j.author}](https://github.com/${j.author}) on ${new Date(j.date).toLocaleDateString()}*
82
82
 
83
83
  `}else{if(_&&G.includeCompareLinks)Z+=`[Compare Source](${_})
84
84
 
85
- `;if(D.description)Z+=`${D.description}
85
+ `;if(L.description)Z+=`${L.description}
86
86
 
87
- `;if(D.repository?.url){let j=this.getRepositoryName(D.repository.url);if(j)Z+=`\uD83D\uDCD6 [View Release Notes](https://github.com/${j}/releases)
87
+ `;if(L.repository?.url){let j=this.getRepositoryName(L.repository.url);if(j)Z+=`\uD83D\uDCD6 [View Release Notes](https://github.com/${j}/releases)
88
88
 
89
89
  `,Z+=`\uD83D\uDD17 [View Changelog](https://github.com/${j}/blob/main/CHANGELOG.md)
90
90
 
91
- `}else Z+=`\uD83D\uDCE6 [View on npm](https://www.npmjs.com/package/${encodeURIComponent(L)})
91
+ `}else Z+=`\uD83D\uDCE6 [View on npm](https://www.npmjs.com/package/${encodeURIComponent(O)})
92
92
 
93
93
  `;if(Q.releaseNotesUrl)Z+=`[Release Notes](${Q.releaseNotesUrl})
94
94
 
@@ -96,20 +96,20 @@ import{Ve as l}from"./chunk-kh6v93yb.js";import{ag as c,jg as A}from"./chunk-wre
96
96
 
97
97
  `}Z+=`</details>
98
98
 
99
- `}let N=S.filter((Q)=>!E.some((X)=>X.name.replace(/\s*\(dev\)$/,"").replace(/\s*\(peer\)$/,"").replace(/\s*\(optional\)$/,"")===Q.name));for(let Q of N){let X=Q.name==="bun.sh"?"bun.com":Q.name;Z+=`<details>
99
+ `}let N=S.filter((Q)=>!B.some((X)=>X.name.replace(/\s*\(dev\)$/,"").replace(/\s*\(peer\)$/,"").replace(/\s*\(optional\)$/,"")===Q.name));for(let Q of N){let X=Q.name==="bun.sh"?"bun.com":Q.name;Z+=`<details>
100
100
  `,Z+=`<summary>${X}</summary>
101
101
 
102
- `;let D=this.formatVersionChange(Q.currentVersion,Q.newVersion).replace(/`/g,"");if(Z+=`**${D}**
102
+ `;let L=this.formatVersionChange(Q.currentVersion,Q.newVersion).replace(/`/g,"");if(Z+=`**${L}**
103
103
 
104
- `,Q.file){let O=Q.file.split("/").pop()||Q.file,_=this.config?.repository?.owner&&this.config?.repository?.name?`\uD83D\uDCC1 **File**: [\`${O}\`](https://github.com/${this.config.repository.owner}/${this.config.repository.name}/blob/main/${Q.file})
104
+ `,Q.file){let z=Q.file.split("/").pop()||Q.file,_=this.config?.repository?.owner&&this.config?.repository?.name?`\uD83D\uDCC1 **File**: [\`${z}\`](https://github.com/${this.config.repository.owner}/${this.config.repository.name}/blob/main/${Q.file})
105
105
 
106
- `:`\uD83D\uDCC1 **File**: \`${O}\`
106
+ `:`\uD83D\uDCC1 **File**: \`${z}\`
107
107
 
108
108
  `;Z+=_}if(Q.name==="bun.sh")Z+=`\uD83D\uDD17 **Release Notes**: [bun.sh](https://bun.sh)
109
109
 
110
- `;else if(Q.name.includes(".org")||Q.name.includes(".net")||Q.name.includes(".com")){let O=Q.name.split("/")[0]||Q.name;Z+=`\uD83D\uDD17 **Package Info**: [pkgx.com](https://pkgx.com/pkg/${encodeURIComponent(Q.name)})
110
+ `;else if(Q.name.includes(".org")||Q.name.includes(".net")||Q.name.includes(".com")){let z=Q.name.split("/")[0]||Q.name;Z+=`\uD83D\uDD17 **Package Info**: [pkgx.com](https://pkgx.com/pkg/${encodeURIComponent(Q.name)})
111
111
 
112
- `,Z+=`\uD83C\uDF10 **Official Site**: [${O}](https://${O})
112
+ `,Z+=`\uD83C\uDF10 **Official Site**: [${z}](https://${z})
113
113
 
114
114
  `}else Z+=`\uD83D\uDD17 **Package Info**: [pkgx.com](https://pkgx.com/pkg/${encodeURIComponent(Q.name)})
115
115
 
@@ -137,7 +137,7 @@ import{Ve as l}from"./chunk-kh6v93yb.js";import{ag as c,jg as A}from"./chunk-wre
137
137
 
138
138
  `,F.size>0||w.length>0||N.length>0||V.length>0){Z+=`### \uD83D\uDCCA Package Statistics
139
139
 
140
- `;for(let Q of E){let D=F.get(Q.name)?.packageInfo;if(D?.weeklyDownloads)Z+=`- **${Q.name}**: ${D.weeklyDownloads.toLocaleString()} weekly downloads
140
+ `;for(let Q of B){let L=F.get(Q.name)?.packageInfo;if(L?.weeklyDownloads)Z+=`- **${Q.name}**: ${L.weeklyDownloads.toLocaleString()} weekly downloads
141
141
  `;else Z+=`- **${Q.name}**: npm package with weekly downloads tracked on npmjs.com
142
142
  `}for(let Q of w)Z+=`- **${Q.name}**: PHP package available on Packagist
143
143
  `;for(let Q of N){let X=Q.name==="bun.sh"?"bun.com":Q.name;if(Q.name==="bun.sh")Z+=`- **${X}**: Popular JavaScript runtime and package manager
@@ -146,7 +146,7 @@ import{Ve as l}from"./chunk-kh6v93yb.js";import{ag as c,jg as A}from"./chunk-wre
146
146
  `;Z+=`
147
147
  ---
148
148
 
149
- `}return this.finalizeBody(Z,W)}finalizeBody(W,$){let Y=this.config?.pullRequest?.bodyTemplate,R=" - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box";if(Y){if(W=C(Y,{...f($,{},this.config?.packages?.strategy),updatesTable:W,footer:" - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box"}),!W.includes("<!-- rebase-check -->"))W+=`
149
+ `}return this.finalizeBody(Z,W)}finalizeBody(W,$){let Y=this.config?.pullRequest?.bodyTemplate,R=" - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box";if(Y){if(W=h(Y,{...f($,{},this.config?.packages?.strategy),updatesTable:W,footer:" - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box"}),!W.includes("<!-- rebase-check -->"))W+=`
150
150
 
151
151
  - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box
152
152
  `}else{W+=`### Configuration
@@ -157,7 +157,7 @@ import{Ve as l}from"./chunk-kh6v93yb.js";import{ag as c,jg as A}from"./chunk-wre
157
157
 
158
158
  `,W+=`\u267B **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
159
159
 
160
- `;let Z=$.updates.length===1?"this update again":"these updates again";W+=`\uD83D\uDD15 **Ignore**: Close this PR and you won't be reminded about ${Z}.
160
+ `;let D=$.updates.length===1?"this update again":"these updates again";W+=`\uD83D\uDD15 **Ignore**: Close this PR and you won't be reminded about ${D}.
161
161
 
162
162
  `,W+=`---
163
163
 
@@ -165,22 +165,26 @@ import{Ve as l}from"./chunk-kh6v93yb.js";import{ag as c,jg as A}from"./chunk-wre
165
165
 
166
166
  `,W+=`---
167
167
 
168
- `,W+="This PR was generated by [Buddy](https://github.com/stacksjs/buddy) \uD83E\uDD16"}let K=y($),H=60000-K.length;if(W.length>H){let Z=W.substring(0,H),B=Z.lastIndexOf("</details>");if(B>0)W=`${Z.substring(0,B+10)}
168
+ `,W+="This PR was generated by [Buddy](https://github.com/stacksjs/buddy) \uD83E\uDD16"}let K=y($),H=`---
169
+
170
+ - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box
171
+
172
+ `,Z=60000-K.length-H.length;if(W.length>Z){let D=W.substring(0,Z),B=D.lastIndexOf("</details>");if(B>0)W=`${D.substring(0,B+10)}
169
173
 
170
174
  ---
171
175
 
172
176
  **Note**: This PR body was truncated due to GitHub's character limit. View the full details in the individual commits.
173
177
 
174
- `;else W=`${Z}
178
+ `;else W=`${D}
175
179
 
176
180
  ---
177
181
 
178
182
  **Note**: This PR body was truncated due to GitHub's character limit.
179
183
 
180
- `;W+="This PR was generated by [Buddy](https://github.com/stacksjs/buddy) \uD83E\uDD16"}if(W+=K,this.log("\u2705 PR body generation complete",{bodyLength:W.length,hasNpmSection:W.includes("## \uD83D\uDCE6 npm Dependencies"),hasComposerSection:W.includes("## \uD83D\uDC18 PHP/Composer Dependencies"),hasSystemSection:W.includes("## \uD83D\uDD27 System Dependencies"),hasGitHubActionsSection:W.includes("## \uD83D\uDE80 GitHub Actions"),hasPackageTable:W.includes("| Package | Change | Age | Adoption | Passing | Confidence |"),hasReleaseNotes:W.includes("### Release Notes"),isSparse:W.length<1000,sections:{hasNpmPackagesInSummary:W.includes("\uD83D\uDCE6 NPM Packages"),hasComposerInSummary:W.includes("\uD83D\uDC18 Composer Packages"),hasSystemInSummary:W.includes("\uD83D\uDD27 System Dependencies"),hasGitHubActionsInSummary:W.includes("\uD83D\uDE80 GitHub Actions")}}),W.length<1000)this.log("\uD83D\uDEA8 WARNING: Generated PR body appears sparse (under 1000 chars)!");return W}getRepositoryName(W){try{let $=W.replace(/^git\+/,"").replace(/\.git$/,"").replace(/^git:\/\//,"https://").replace(/^ssh:\/\/git@/,"https://").replace(/^git@github\.com:/,"https://github.com/"),R=new URL($).pathname.split("/").filter(Boolean);if(R.length>=2)return`${R[0]}/${R[1]}`;return W}catch{return W}}getRepositorySourceUrl(W,$,Y="master"){try{let R=W.replace(/^git\+/,"").replace(/\.git$/,"").replace(/^git:\/\//,"https://").replace(/^ssh:\/\/git@/,"https://").replace(/^git@github\.com:/,"https://github.com/"),K=new URL(R);if($.startsWith("@types/")&&K.pathname.includes("DefinitelyTyped")){let H=$.replace("@types/","");return`https://redirect.github.com/DefinitelyTyped/DefinitelyTyped/tree/${Y}/types/${H}`}if(K.hostname==="github.com")return`${R}/tree/${Y}`;return R}catch{return W}}getComposerSourceUrl(W,$){try{let Y=W.replace(/^git\+/,"").replace(/\.git$/,"").replace(/^git:\/\//,"https://").replace(/^ssh:\/\/git@/,"https://").replace(/^git@github\.com:/,"https://github.com/"),R=new URL(Y);if($.startsWith("@types/")&&R.pathname.includes("DefinitelyTyped"))return`https://redirect.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/${$.replace("@types/","")}`;if(R.hostname==="github.com")return`${Y}/tree/master`;return Y}catch{return W}}getConstraintStyleChange(W,$){let Y=W.replace(/^v/,""),R=$.replace(/^v/,""),K=`^${Y}`,H=`^${R}`;return`${K} -> ${H}`}escapeMarkdownTableValue(W){return W.replaceAll("|","\\|").replaceAll(/\r?\n/g," ")}getComposerRedirectSourceUrl(W,$){try{let Y=W.replace(/^git\+/,"").replace(/\.git$/,"").replace(/^git:\/\//,"https://").replace(/^ssh:\/\/git@/,"https://").replace(/^git@github\.com:/,"https://github.com/"),R=new URL(Y);if($.startsWith("@types/")&&R.pathname.includes("DefinitelyTyped"))return`https://redirect.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/${$.replace("@types/","")}`;if(R.hostname==="github.com"){let K=R.pathname.split("/").filter((H)=>H);if(K.length>=2){let H=K[0],Z=K[1];return`https://redirect.github.com/${H}/${Z}`}}return Y}catch{return W}}cleanReleaseBody(W){let $=W.replace(/\r\n/g,`
184
+ `;W+=H,W+="This PR was generated by [Buddy](https://github.com/stacksjs/buddy) \uD83E\uDD16"}if(W+=K,this.log("\u2705 PR body generation complete",{bodyLength:W.length,hasNpmSection:W.includes("## \uD83D\uDCE6 npm Dependencies"),hasComposerSection:W.includes("## \uD83D\uDC18 PHP/Composer Dependencies"),hasSystemSection:W.includes("## \uD83D\uDD27 System Dependencies"),hasGitHubActionsSection:W.includes("## \uD83D\uDE80 GitHub Actions"),hasPackageTable:W.includes("| Package | Change | Age | Adoption | Passing | Confidence |"),hasReleaseNotes:W.includes("### Release Notes"),isSparse:W.length<1000,sections:{hasNpmPackagesInSummary:W.includes("\uD83D\uDCE6 NPM Packages"),hasComposerInSummary:W.includes("\uD83D\uDC18 Composer Packages"),hasSystemInSummary:W.includes("\uD83D\uDD27 System Dependencies"),hasGitHubActionsInSummary:W.includes("\uD83D\uDE80 GitHub Actions")}}),W.length<1000)this.log("\uD83D\uDEA8 WARNING: Generated PR body appears sparse (under 1000 chars)!");return W}getRepositoryName(W){try{let $=W.replace(/^git\+/,"").replace(/\.git$/,"").replace(/^git:\/\//,"https://").replace(/^ssh:\/\/git@/,"https://").replace(/^git@github\.com:/,"https://github.com/"),R=new URL($).pathname.split("/").filter(Boolean);if(R.length>=2)return`${R[0]}/${R[1]}`;return W}catch{return W}}getRepositorySourceUrl(W,$,Y="master"){try{let R=W.replace(/^git\+/,"").replace(/\.git$/,"").replace(/^git:\/\//,"https://").replace(/^ssh:\/\/git@/,"https://").replace(/^git@github\.com:/,"https://github.com/"),K=new URL(R);if($.startsWith("@types/")&&K.pathname.includes("DefinitelyTyped")){let H=$.replace("@types/","");return`https://redirect.github.com/DefinitelyTyped/DefinitelyTyped/tree/${Y}/types/${H}`}if(K.hostname==="github.com")return`${R}/tree/${Y}`;return R}catch{return W}}getComposerSourceUrl(W,$){try{let Y=W.replace(/^git\+/,"").replace(/\.git$/,"").replace(/^git:\/\//,"https://").replace(/^ssh:\/\/git@/,"https://").replace(/^git@github\.com:/,"https://github.com/"),R=new URL(Y);if($.startsWith("@types/")&&R.pathname.includes("DefinitelyTyped"))return`https://redirect.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/${$.replace("@types/","")}`;if(R.hostname==="github.com")return`${Y}/tree/master`;return Y}catch{return W}}getConstraintStyleChange(W,$){let Y=W.replace(/^v/,""),R=$.replace(/^v/,""),K=`^${Y}`,H=`^${R}`;return`${K} -> ${H}`}escapeMarkdownTableValue(W){return W.replaceAll("|","\\|").replaceAll(/\r?\n/g," ")}getComposerRedirectSourceUrl(W,$){try{let Y=W.replace(/^git\+/,"").replace(/\.git$/,"").replace(/^git:\/\//,"https://").replace(/^ssh:\/\/git@/,"https://").replace(/^git@github\.com:/,"https://github.com/"),R=new URL(Y);if($.startsWith("@types/")&&R.pathname.includes("DefinitelyTyped"))return`https://redirect.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/${$.replace("@types/","")}`;if(R.hostname==="github.com"){let K=R.pathname.split("/").filter((H)=>H);if(K.length>=2){let H=K[0],Z=K[1];return`https://redirect.github.com/${H}/${Z}`}}return Y}catch{return W}}cleanReleaseBody(W){let $=W.replace(/\r\n/g,`
181
185
  `).replace(/\n{3,}/g,`
182
186
 
183
187
  `).trim();$=this.sanitizeMentions($),$=this.sanitizeGitHubReferences($);let Y=this.config?.releaseNotes?.maxBodyLength??1000;if($.length>Y)$=`${$.substring(0,Y)}...
184
188
 
185
- *[View full release notes]*`;return $}sanitizeMentions(W){let $=[],Y=[],R=W.replace(/```[\s\S]*?```/g,(K)=>{return $.push(K),`__FENCE_PLACEHOLDER_${$.length-1}__`});return R=R.replace(/`[^`\n]+`/g,(K)=>{return Y.push(K),`__INLINE_CODE_PLACEHOLDER_${Y.length-1}__`}),R=R.replace(/(?<![\w./])@([A-Z0-9-]+)(?![A-Z0-9-])/gi,(K,H)=>{return`[${H}](https://github.com/${H})`}),R=R.replace(/__INLINE_CODE_PLACEHOLDER_(\d+)__/g,(K,H)=>Y[Number(H)]),R=R.replace(/__FENCE_PLACEHOLDER_(\d+)__/g,(K,H)=>$[Number(H)]),R}sanitizeGitHubReferences(W){if(this.config?.releaseNotes?.sanitizeReferences===!1)return W;let $=[],Y=[],R=W.replace(/```[\s\S]*?```/g,(K)=>{return $.push(K),`__FENCE_PLACEHOLDER_${$.length-1}__`});return R=R.replace(/`[^`\n]+`/g,(K)=>{return Y.push(K),`__INLINE_CODE_PLACEHOLDER_${Y.length-1}__`}),R=R.replace(/https?:\/\/github\.com\/([^/]+)\/([^/]+)\/(?:pull|issues)\/(\d+)/g,(K,H,Z,B)=>`\`${H}/${Z}#${B}\``),R=R.replace(/(?<![`\w])#(\d+)(?!\d)/g,"`#$1`"),R=R.replace(/__INLINE_CODE_PLACEHOLDER_(\d+)__/g,(K,H)=>Y[Number(H)]),R=R.replace(/__FENCE_PLACEHOLDER_(\d+)__/g,(K,H)=>$[Number(H)]),R}generateCustomTemplate(W,$,Y={}){let R=$,H={...{"{title}":this.generateTitle(W),"{package_count}":W.updates.length.toString(),"{update_type}":W.updateType,"{packages}":W.updates.map((Z)=>Z.name).join(", "),"{date}":new Date().toISOString().split("T")[0]},...Y};for(let[Z,B]of Object.entries(H))R=R.replace(new RegExp(Z,"g"),B);return R}formatVersionChange(W,$){let Y=W.match(/^(\D+)/),R=Y?Y[1]:"";if(R){let K=W.replace(/^\D+/,""),H=$.replace(/^\D+/,"");return`\`${R}${K}\` \u2192 \`${R}${H}\``}return`\`${W}\` \u2192 \`${$}\``}getVersionChangeDescription(W,$,Y){return{major:"\uD83D\uDD34 Breaking changes possible",minor:"\uD83D\uDFE1 New features added",patch:"\uD83D\uDFE2 Bug fixes & patches"}[Y]}}
186
- export{C as qd,f as rd,p as sd};
189
+ *[View full release notes]*`;return $}sanitizeMentions(W){let $=[],Y=[],R=W.replace(/```[\s\S]*?```/g,(K)=>{return $.push(K),`__FENCE_PLACEHOLDER_${$.length-1}__`});return R=R.replace(/`[^`\n]+`/g,(K)=>{return Y.push(K),`__INLINE_CODE_PLACEHOLDER_${Y.length-1}__`}),R=R.replace(/(?<![\w./])@([A-Z0-9-]+)(?![A-Z0-9-])/gi,(K,H)=>{return`[${H}](https://github.com/${H})`}),R=R.replace(/__INLINE_CODE_PLACEHOLDER_(\d+)__/g,(K,H)=>Y[Number(H)]),R=R.replace(/__FENCE_PLACEHOLDER_(\d+)__/g,(K,H)=>$[Number(H)]),R}sanitizeGitHubReferences(W){if(this.config?.releaseNotes?.sanitizeReferences===!1)return W;let $=[],Y=[],R=W.replace(/```[\s\S]*?```/g,(K)=>{return $.push(K),`__FENCE_PLACEHOLDER_${$.length-1}__`});return R=R.replace(/`[^`\n]+`/g,(K)=>{return Y.push(K),`__INLINE_CODE_PLACEHOLDER_${Y.length-1}__`}),R=R.replace(/https?:\/\/github\.com\/([^/]+)\/([^/]+)\/(?:pull|issues)\/(\d+)/g,(K,H,Z,D)=>`\`${H}/${Z}#${D}\``),R=R.replace(/(?<![`\w])#(\d+)(?!\d)/g,"`#$1`"),R=R.replace(/__INLINE_CODE_PLACEHOLDER_(\d+)__/g,(K,H)=>Y[Number(H)]),R=R.replace(/__FENCE_PLACEHOLDER_(\d+)__/g,(K,H)=>$[Number(H)]),R}generateCustomTemplate(W,$,Y={}){let R=$,H={...{"{title}":this.generateTitle(W),"{package_count}":W.updates.length.toString(),"{update_type}":W.updateType,"{packages}":W.updates.map((Z)=>Z.name).join(", "),"{date}":new Date().toISOString().split("T")[0]},...Y};for(let[Z,D]of Object.entries(H))R=R.replace(new RegExp(Z,"g"),D);return R}formatVersionChange(W,$){let Y=W.match(/^(\D+)/),R=Y?Y[1]:"";if(R){let K=W.replace(/^\D+/,""),H=$.replace(/^\D+/,"");return`\`${R}${K}\` \u2192 \`${R}${H}\``}return`\`${W}\` \u2192 \`${$}\``}getVersionChangeDescription(W,$,Y){return{major:"\uD83D\uDD34 Breaking changes possible",minor:"\uD83D\uDFE1 New features added",patch:"\uD83D\uDFE2 Bug fixes & patches"}[Y]}}
190
+ export{h as qd,f as rd,p as sd};
package/dist/src/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{I as wo,J as So,K as ho,L as uo,M as co,N as Vo,O as eo,P as go,Q as ro,R as vo,S as io,T as so,U as no}from"../chunk-d7jpbw1z.js";import{W as ko,X as qo}from"../chunk-db9rffcf.js";import{$ as Wo,Y as Jo,Z as Ko,_ as Qo}from"../chunk-rrnvxj90.js";import{aa as PR,ba as aR,ca as lR,da as yR,ea as CR,fa as NR,ga as _R,ha as zR,ia as DR,ja as TR}from"../chunk-69qyr9ef.js";import{ka as pR,la as oR,ma as mR,na as xR,oa as fR,pa as dR,qa as RR,ra as MR,sa as UR,ta as AR,ua as GR,va as ER,wa as OR}from"../chunk-7bctsv0x.js";import{Aa as $o,Ba as bo,Ca as to,xa as Xo,ya as Yo,za as Zo}from"../chunk-ysgex7h7.js";import"../chunk-rb1fh9vd.js";import{Da as pm}from"../chunk-d4wqe366.js";import{Ea as ed,Fa as gd,Ga as rd,Ha as vd,Ia as id,Ja as sd,Ka as nd}from"../chunk-a34szd4r.js";import{La as Zd,Ma as $d,Na as bd,Oa as td,Pa as wd,Qa as Sd,Ra as hd,Sa as ud,Ta as cd,Ua as Vd}from"../chunk-k3x0mabj.js";import{Va as Yf,Wa as Zf}from"../chunk-pmszvhja.js";import{$a as Sf,Xa as $f,Ya as bf,Za as tf,_a as wf,ab as hf,bb as uf,cb as cf,db as Vf,eb as ef,fb as gf,gb as rf}from"../chunk-1szfwcst.js";import{hb as vf,ib as sf,jb as nf,kb as pd,lb as od}from"../chunk-88xaexj1.js";import{mb as Id}from"../chunk-fpzgxg8a.js";import{Ab as Td,Bb as jd,Cb as Ld,Db as Bd,nb as dd,ob as Rd,pb as Md,qb as Ud,rb as Ad,sb as Gd,tb as Ed,ub as Od,vb as Pd,wb as Nd,xb as _d,yb as zd,zb as Dd}from"../chunk-s3q7g2hy.js";import{Eb as md,Fb as xd,Gb as fd}from"../chunk-q2tjkhez.js";import{Hb as Co,Ib as No,Jb as _o,Kb as zo}from"../chunk-vckhctmr.js";import{Lb as ad,Mb as ld,Nb as yd,Pb as Cd}from"../chunk-5yfaptmp.js";import{Qb as Rf,Rb as Mf,Sb as Uf,Tb as Af,Ub as Gf,Vb as Ef,Wb as Of,Xb as Pf,Yb as af}from"../chunk-y7z0br2x.js";import{$b as nx,Zb as ix,_b as sx,ac as pf,bc as of,cc as mf,dc as xf,ec as ff,fc as df}from"../chunk-ggzjv4s0.js";import{gc as Vp,hc as ep,ic as gp,jc as rp,mc as vp,nc as ip}from"../chunk-rg996jqw.js";import{Ac as Uo,Bc as Ao,Cc as Go,Dc as Eo,Ec as Oo,Fc as Po,Gc as ao,Hc as lo,Ic as yo,pc as sp,sc as np,tc as po,uc as oo,vc as mo,wc as xo,xc as fo,yc as Ro,zc as Mo}from"../chunk-2m0134q8.js";import{Mc as dp}from"../chunk-xffrrs85.js";import{Nc as mp,Oc as xp,Pc as fp}from"../chunk-zrg5ss0x.js";import{Tc as mm,Uc as xm,Vc as fm,Wc as dm}from"../chunk-xps8n8nj.js";import{Xc as Bo,Yc as Fo,Zc as Ho}from"../chunk-tx9m7y1z.js";import{$c as hp,_c as Sp,ad as up,bd as cp,dd as Do}from"../chunk-r7nh070r.js";import"../chunk-p9z0hzej.js";import{fd as _p,gd as zp,hd as Dp,id as Tp,jd as jp}from"../chunk-amj037yy.js";import{kd as wp}from"../chunk-4wbbbcs2.js";import"../chunk-89s9f3mf.js";import{md as ex,nd as gx,od as rx,pd as vx}from"../chunk-ja3rvd6y.js";import{sd as Np}from"../chunk-p5yaf72b.js";import{td as Xf}from"../chunk-mg3em5qj.js";import{Ad as ux,Bd as cx,Cd as Vx,ud as $x,vd as bx,wd as tx,xd as wx,yd as Sx,zd as hx}from"../chunk-7crh00m7.js";import{Dd as Fd,Ed as Hd,Fd as kd,Gd as qd,Hd as Jd,Id as Kd,Jd as Qd,Kd as Wd,Ld as Xd,Md as Yd}from"../chunk-bggpgbdx.js";import{$d as kf,Nd as lf,Od as yf,Pd as Cf,Qd as Nf,Rd as _f,Sd as zf,Td as Df,Ud as Tf,Vd as jf,Wd as If,Xd as Lf,Yd as Bf,Zd as Ff,_d as Hf,ae as qf,be as Jf,ce as Kf,de as Qf,ee as Wf}from"../chunk-be059ncv.js";import"../chunk-xny4kgcc.js";import{he as Rp,ie as Mp,je as Up,ke as Ap,le as Gp,me as Ep,ne as Op,oe as Pp,pe as ap,qe as lp,re as yp}from"../chunk-34rmja4x.js";import"../chunk-hyp0wfta.js";import"../chunk-4hd1mryc.js";import{Ee as Ip,Fe as Lp,Ge as Bp,He as Fp,Ie as Hp,Je as kp,Ke as qp,Le as Jp,Me as Kp,Ne as Qp,Oe as Wp}from"../chunk-nwrr6jas.js";import{Ve as Cp}from"../chunk-kh6v93yb.js";import{$e as tp,We as Xp,Xe as Yp,Ye as Zp,Ze as $p,_e as bp}from"../chunk-88j356ng.js";import{cf as a,df as l,ef as y,ff as C,gf as N,hf as _,if as z,jf as D,kf as T,lf as j,mf as I,nf as L,of as B,pf as F,qf as H}from"../chunk-3waqfh3y.js";import{rf as U,sf as A,tf as G,uf as E,vf as O,xf as P}from"../chunk-k7x9af5r.js";import{Af as lx,Bf as yx,Cf as Cx,Df as Nx,yf as Px,zf as ax}from"../chunk-jpdd59fh.js";import{Ef as Lx,Ff as Bx,Gf as Fx,Hf as Hx,If as kx,Jf as qx,Kf as Jx,Lf as Kx,Mf as Qx,Nf as Wx,Of as Xx,Pf as Yx,Qf as Zx}from"../chunk-7rjrea9g.js";import"../chunk-emygmh7r.js";import{Tf as _x,Uf as zx,Vf as Dx,Wf as Tx,Xf as jx,Yf as Ix}from"../chunk-kpqez1ht.js";import"../chunk-vckn5ate.js";import{ag as e,bg as g,cg as r,dg as v,eg as i,fg as s,gg as n,hg as pp,ig as op,jg as d}from"../chunk-wreexgkb.js";import"../chunk-gvnsr72j.js";import"../chunk-1m5wprvm.js";import"../chunk-ktmgq0ja.js";import{$g as jR,Wg as To,Xg as jo,Yg as Io,Zg as Lo,ah as IR,bh as LR,ch as BR,dh as FR,eh as HR,fh as kR,gh as qR,hh as JR,ih as KR,jh as QR,kh as WR,lh as XR,mh as YR,nh as ZR,oh as $R,ph as bR,qh as tR,rh as wR,sh as SR,th as hR,uh as uR}from"../chunk-9m0epv44.js";import{vh as om}from"../chunk-hkb714k3.js";import{Ah as V,wh as S,xh as h,yh as u,zh as c}from"../chunk-6k6dgwmy.js";import{Bh as t}from"../chunk-qdmr84mc.js";import{Ch as w}from"../chunk-6xzzs109.js";import"../chunk-pxdrwhxx.js";import{Eh as J,Fh as K,Gh as Q,Hh as W,Ih as X,Jh as Y}from"../chunk-a3bnhq58.js";import{Kh as k,Lh as q,Mh as Z,Nh as $,Oh as b}from"../chunk-8dj94fsy.js";import"../chunk-0apd8zqn.js";import"../chunk-s3ksf6s5.js";var{semver:m}=globalThis.Bun;class R{static compareVersions(p,o){return m.order(p,o)}static satisfiesRange(p,o){return m.satisfies(p,o)}static getLatestInRange(p,o){let f=p.filter((x)=>m.satisfies(x,o));if(f.length===0)return null;return f.sort((x,M)=>m.order(M,x))[0]}static createRange(p){return{raw:p,range:p.replace(/^[\^~>=<]+/,""),isExact:!/^[\^~>=<]/.test(p),satisfies:(o)=>this.satisfiesRange(o,p),getLatest:(o)=>this.getLatestInRange(o,p)}}static getUpdateType(p,o){return d(p,o)}static isSafeUpdate(p,o){return m.satisfies(o,p)}}export{Fx as writeFileTool,Yx as wrapUntrusted,gf as withTouchOffer,no as withNarrative,sf as verifyChanges,tR as validateWorkflowGeneration,wR as validateRepositoryAccess,Ud as validateFindings,Bo as validateConfig,Jo as validateAgainstSchema,HR as updateProgress,bf as unitTestsTouch,Sp as toOsvEcosystem,Hp as tagUpdateType,Kf as syntaxAnalyzer,lp as supports,z as summarizeUsage,fR as summarizeGates,lo as stripOperators,bd as stripNonCommandContext,nf as stackedBranchName,Mo as splitConstraint,op as sortUpdatesByPriority,wf as simplifyTouch,yR as similarity,Vx as sign,uR as showFinalInstructions,N as shouldOpenAsDraft,Yd as shouldFail,Jf as shellcheckAnalyzer,Kx as shellTool,hR as setupCustomWorkflow,$ as setDefaultLogger,ld as serializeReviewState,Af as serializeLearnings,Of as selectLearnings,Fp as selectLatestTag,qf as secretsAnalyzer,YR as schedulePlan,ao as scanEcosystems,vp as scanCatalogs,Bp as sameVariant,Go as rustAdapter,yf as runTool,pd as runStackedTouch,Bd as runReviewForPR,LR as runPreflightChecks,ER as runPostMerge,Zf as runPlan,Ko as runHeadless,xR as runGates,nd as runFixCi,Wf as runAnalyzers,UR as runAiGates,Zx as runAgent,A as ruleMatches,Ao as rubyAdapter,Ld as reviewPullRequest,Px as reviewMode,Ed as reviewDiff,Lx as resolveWorkspacePath,G as resolveRuleEffects,Op as resolveProviderToken,pf as resolveModelAlias,bp as resolveEngineVersion,Kp as resolveCredentials,ep as resolveCatalogReference,Id as resolveBuddyThreads,ff as resolveAiProvider,fm as resetConfigCache,Vf as renderTouchOffer,so as renderReport,TR as renderQuickLinks,aR as renderPackageContext,D as renderMigrationReport,Pf as renderLearnings,Td as renderFinding,qo as renderDoctorReport,xd as renderDiffForReview,_f as relativize,yo as regenerateLockfiles,xp as regenerateLockFile,Tx as redactError,Dx as redactDeep,zx as redact,Bx as readFileTool,Uo as pythonAdapter,Wo as publishOutput,Yo as productFor,jd as prepareReview,Sf as planTouch,yx as planMode,$p as pinBlocksUpdate,Ro as pep440UpdateType,Vp as parseWorkspaceCatalogs,md as parseUnifiedDiff,rf as parseTouchSelections,Nf as parseToolJson,Ip as parseTag,yd as parseReviewState,W as parseRetryDelay,qR as parseRemote,zR as parseQuickSelection,mo as parsePep440,g as parsePackageFile,Uf as parseLearnings,kp as parseImageRef,ho as parseHistory,td as parseCommand,Qp as parseAuthChallenge,If as offsetToLine,po as numericUpdateType,hp as normalizeSeverity,C as normalizePlan,Cd as needsReview,O as mergeGroupEffects,Sd as mentionsBot,B as matchesGlobs,Hf as markdownlintAnalyzer,zp as mapWithConcurrency,Cf as mapSeverity,af as loadLearnings,Vo as loadHistory,zd as loadGuidelines,Hx as listDirTool,Ff as linterAnalyzer,id as latestFailurePerWorkflow,wd as isReadOnlyCommand,fo as isPep440Prerelease,OR as isMergeEvent,gp as isCatalogReference,l as isAllowedCodemod,ax as implementMode,ef as hasTouchOffer,jf as hadolintAnalyzer,KR as guideTokenCreation,WR as guideRepositorySettings,P as groupsToRules,pp as groupUpdates,oo as goAdapter,Tf as githubActionsAnalyzer,bR as getWorkflowPreset,c as getNpmRegistryUrl,h as getGitHubServerUrl,S as getGitHubApiUrl,uf as getFinishingTouch,b as getDefaultLogger,xm as getConfig,V as getComposerRegistryUrl,mp as getAllLockFilePaths,Nx as getAgentMode,ZR as generateUnifiedWorkflow,jo as generateGitLabPipeline,$R as generateCoreWorkflows,XR as generateConfigFile,n as generateBranchName,Io as generateBitbucketPipeline,dR as gateIcon,kx as fsTools,e as formatSecurityAdvisorySection,Wd as formatReview,qd as formatPretty,i as formatPRTitle,s as formatPRBody,qp as formatImageRef,Qo as formatGithubOutput,Jd as formatGithub,q as formatError,Fo as formatConfigIssues,v as formatCommitMessage,Kd as formatAgent,lx as fixCiMode,Md as fingerprint,_ as findUsageSites,co as findPrevious,PR as findMentionedPackages,AR as findLinkedIssues,CR as findDuplicates,_o as findDrift,X as fetchWithTimeout,Y as fetchJsonOrNull,vd as failsOnBaseBranch,gd as extractErrorLines,Yp as extractEngines,Xf as emitEvent,U as ecosystemOf,Co as driftFor,$f as docstringsTouch,SR as displayValidationResults,kR as displayProgress,cd as dispatchCommand,Hd as diffArgsFor,ko as diagnose,fp as detectRequiredPackageManagers,JR as detectRepository,r as detectPackageManager,Bf as detectLinter,sp as detectFiles,od as detectChangedFiles,L as describeSpanGaps,rd as describeFailure,tx as describeEvent,to as describeEol,zo as describeDrift,Pd as defaultIncludePath,mm as defaultConfig,Ad as dedupeFindings,Zo as cycleFor,cx as createWebhookSink,hx as createSlackSink,Sx as createSinks,Yf as createReadIssueTool,ap as createProvider,FR as createProgressTracker,xf as createOpenAiProvider,Gf as createLearning,Vd as createHandlers,mf as createGoogleProvider,ux as createDiscordSink,of as createAnthropicProvider,df as createAiClient,Qd as countBySeverity,lR as constrainLabels,QR as confirmTokenSetup,dm as config,ro as computeMetrics,vo as computeDeltas,Dd as composeInstructions,Lp as compareVersions,xo as comparePep440,np as compareNumeric,zf as commandExists,I as collectSpanNotes,Zp as collectResolutionPins,kd as collectLocalDiff,fd as collectGitDiff,DR as clearQuickSelection,u as clearNpmrcCache,ed as classifyFailure,Lo as ciTemplateFor,Dp as chunk,pR as checkTitleFormat,ud as checkPermission,RR as checkLinkedIssue,$o as checkEol,oR as checkDescription,mR as checkDependencies,MR as checkCustomAssertions,tp as bumpEngineConstraint,Jx as buildShellEnv,y as buildAnalysisPrompt,tf as autofixTouch,T as attemptMajorUpgrade,sd as attemptFix,Ho as assertValidConfig,yp as assertSupports,Pp as assertProviderSupported,Xd as applySuggestion,E as applyRules,ip as applyCatalogUpdates,rp as applyCatalogUpdate,H as appendUpgradeReport,uo as appendHistory,GR as appendChangelogEntry,Jp as apiHostFor,Od as anchorMap,BR as analyzeProject,F as analyzeGroupMajors,cp as advisoryKey,Ef as addLearning,Po as adapterNamed,Oo as adapterFor,Df as actionlintAnalyzer,wx as WEBHOOK_PAYLOAD_VERSION,R as VersionResolver,Gp as UnsupportedProviderError,Xx as Toolbelt,Qx as ToolPermissionError,cf as TOUCH_OFFER_MARKER,lf as TOOL_TIMEOUT_MS,vf as TEST_COMMANDS,up as SecurityAdvisoryService,pm as Scheduler,qx as SHELL_ENV_ALLOWLIST,dd as SEVERITY_ORDER,kf as SECRET_RULES,Cp as ReleaseNotesFetcher,jp as RegistryClient,No as ROOT,ad as REVIEW_STATE_VERSION,Rd as REVIEW_SCHEMA,Fd as REVIEW_FORMATS,eo as REPORT_PERIODS,io as REPORT_MARKER,_x as REDACTED,$d as READ_ONLY_COMMANDS,NR as QUICK_LINKS_MARKER,_R as QUICK_ACTIONS,Np as PullRequestGenerator,IR as PluginManager,wp as PackageScanner,gx as PackageRegistryError,Up as PROVIDER_TRACKING_ISSUES,Ep as PROVIDER_TOKEN_ENV,nx as PROVIDER_PRIORITY,Rp as PROVIDER_NAMES,sx as PROVIDER_KEY_ENV,go as PERIOD_DAYS,Wp as OciClient,Ap as NO_CAPABILITIES,ix as MODEL_ALIASES,a as MIGRATION_PLAN_SCHEMA,_d as MAX_GUIDELINE_CHARS,Z as Logger,Lf as LINTER_SPECS,Xp as KNOWN_ENGINES,Mp as IMPLEMENTED_PROVIDERS,Q as HttpRequestError,wo as HISTORY_PATH,So as HISTORY_LIMIT,hd as HELP_TEXT,rx as GitProviderError,t as GitLabProvider,dp as GitHubProvider,k as GitHubApiError,om as GitHubActionsTemplate,hf as FINISHING_TOUCHES,bx as EventBus,$x as EVENT_NAMES,bo as EOL_WARNING_DAYS,Xo as EOL_PRODUCTS,J as DEFAULT_TIMEOUT_MS,j as DEFAULT_SPAN_BUDGET,To as DEFAULT_SCHEDULE,K as DEFAULT_RETRIES,Mf as DEFAULT_PROMPT_LIMIT,Rf as DEFAULT_LEARNINGS_FILE,Nd as DEFAULT_GUIDELINE_FILES,Gd as DEFAULT_EXCLUDED_PATHS,_p as DEFAULT_CONCURRENCY,jR as ConfigurationMigrator,vx as ConfigurationError,Zd as COMMAND_ALIASES,ex as BuddyError,Do as Buddy,w as BitbucketProvider,Wx as BUILTIN_TOOLS,Qf as BUILTIN_ANALYZERS,Eo as BUILTIN_ADAPTERS,Tp as AsyncMemo,Ix as AiProviderError,jx as AiBudgetExceededError,Cx as AGENT_MODES};
2
+ import{I as wo,J as So,K as ho,L as uo,M as co,N as Vo,O as eo,P as go,Q as ro,R as vo,S as io,T as so,U as no}from"../chunk-d7jpbw1z.js";import{W as ko,X as qo}from"../chunk-db9rffcf.js";import{$ as Wo,Y as Jo,Z as Ko,_ as Qo}from"../chunk-rrnvxj90.js";import{aa as PR,ba as aR,ca as lR,da as yR,ea as CR,fa as NR,ga as _R,ha as zR,ia as DR,ja as TR}from"../chunk-69qyr9ef.js";import{ka as pR,la as oR,ma as mR,na as xR,oa as fR,pa as dR,qa as RR,ra as MR,sa as UR,ta as AR,ua as GR,va as ER,wa as OR}from"../chunk-7bctsv0x.js";import{Aa as $o,Ba as bo,Ca as to,xa as Xo,ya as Yo,za as Zo}from"../chunk-ysgex7h7.js";import"../chunk-rb1fh9vd.js";import{Da as pm}from"../chunk-6w8vxy7s.js";import{Ea as ed,Fa as gd,Ga as rd,Ha as vd,Ia as id,Ja as sd,Ka as nd}from"../chunk-a34szd4r.js";import{La as Zd,Ma as $d,Na as bd,Oa as td,Pa as wd,Qa as Sd,Ra as hd,Sa as ud,Ta as cd,Ua as Vd}from"../chunk-k3x0mabj.js";import{Va as Yf,Wa as Zf}from"../chunk-pmszvhja.js";import{$a as Sf,Xa as $f,Ya as bf,Za as tf,_a as wf,ab as hf,bb as uf,cb as cf,db as Vf,eb as ef,fb as gf,gb as rf}from"../chunk-1szfwcst.js";import{hb as vf,ib as sf,jb as nf,kb as pd,lb as od}from"../chunk-88xaexj1.js";import{mb as Id}from"../chunk-fpzgxg8a.js";import{Ab as Td,Bb as jd,Cb as Ld,Db as Bd,nb as dd,ob as Rd,pb as Md,qb as Ud,rb as Ad,sb as Gd,tb as Ed,ub as Od,vb as Pd,wb as Nd,xb as _d,yb as zd,zb as Dd}from"../chunk-s3q7g2hy.js";import{Eb as md,Fb as xd,Gb as fd}from"../chunk-q2tjkhez.js";import{Hb as Co,Ib as No,Jb as _o,Kb as zo}from"../chunk-vckhctmr.js";import{Lb as ad,Mb as ld,Nb as yd,Pb as Cd}from"../chunk-5yfaptmp.js";import{Qb as Rf,Rb as Mf,Sb as Uf,Tb as Af,Ub as Gf,Vb as Ef,Wb as Of,Xb as Pf,Yb as af}from"../chunk-y7z0br2x.js";import{$b as nx,Zb as ix,_b as sx,ac as pf,bc as of,cc as mf,dc as xf,ec as ff,fc as df}from"../chunk-ggzjv4s0.js";import{gc as Vp,hc as ep,ic as gp,jc as rp,mc as vp,nc as ip}from"../chunk-rg996jqw.js";import{Ac as Uo,Bc as Ao,Cc as Go,Dc as Eo,Ec as Oo,Fc as Po,Gc as ao,Hc as lo,Ic as yo,pc as sp,sc as np,tc as po,uc as oo,vc as mo,wc as xo,xc as fo,yc as Ro,zc as Mo}from"../chunk-2m0134q8.js";import{Mc as dp}from"../chunk-xffrrs85.js";import{Nc as mp,Oc as xp,Pc as fp}from"../chunk-zrg5ss0x.js";import{Tc as mm,Uc as xm,Vc as fm,Wc as dm}from"../chunk-gzjxhd7a.js";import{Xc as Bo,Yc as Fo,Zc as Ho}from"../chunk-tx9m7y1z.js";import{$c as hp,_c as Sp,ad as up,bd as cp,dd as Do}from"../chunk-785rgtn5.js";import"../chunk-p9z0hzej.js";import{fd as _p,gd as zp,hd as Dp,id as Tp,jd as jp}from"../chunk-amj037yy.js";import{kd as wp}from"../chunk-4wbbbcs2.js";import"../chunk-89s9f3mf.js";import{md as ex,nd as gx,od as rx,pd as vx}from"../chunk-ja3rvd6y.js";import{sd as Np}from"../chunk-yxb1jwxp.js";import{td as Xf}from"../chunk-mg3em5qj.js";import{Ad as ux,Bd as cx,Cd as Vx,ud as $x,vd as bx,wd as tx,xd as wx,yd as Sx,zd as hx}from"../chunk-7crh00m7.js";import{Dd as Fd,Ed as Hd,Fd as kd,Gd as qd,Hd as Jd,Id as Kd,Jd as Qd,Kd as Wd,Ld as Xd,Md as Yd}from"../chunk-bggpgbdx.js";import{$d as kf,Nd as lf,Od as yf,Pd as Cf,Qd as Nf,Rd as _f,Sd as zf,Td as Df,Ud as Tf,Vd as jf,Wd as If,Xd as Lf,Yd as Bf,Zd as Ff,_d as Hf,ae as qf,be as Jf,ce as Kf,de as Qf,ee as Wf}from"../chunk-be059ncv.js";import"../chunk-xny4kgcc.js";import{he as Rp,ie as Mp,je as Up,ke as Ap,le as Gp,me as Ep,ne as Op,oe as Pp,pe as ap,qe as lp,re as yp}from"../chunk-34rmja4x.js";import"../chunk-hyp0wfta.js";import"../chunk-4hd1mryc.js";import{Ee as Ip,Fe as Lp,Ge as Bp,He as Fp,Ie as Hp,Je as kp,Ke as qp,Le as Jp,Me as Kp,Ne as Qp,Oe as Wp}from"../chunk-nwrr6jas.js";import{Ve as Cp}from"../chunk-kh6v93yb.js";import{$e as tp,We as Xp,Xe as Yp,Ye as Zp,Ze as $p,_e as bp}from"../chunk-88j356ng.js";import{cf as a,df as l,ef as y,ff as C,gf as N,hf as _,if as z,jf as D,kf as T,lf as j,mf as I,nf as L,of as B,pf as F,qf as H}from"../chunk-3waqfh3y.js";import{rf as U,sf as A,tf as G,uf as E,vf as O,xf as P}from"../chunk-k7x9af5r.js";import{Af as lx,Bf as yx,Cf as Cx,Df as Nx,yf as Px,zf as ax}from"../chunk-jpdd59fh.js";import{Ef as Lx,Ff as Bx,Gf as Fx,Hf as Hx,If as kx,Jf as qx,Kf as Jx,Lf as Kx,Mf as Qx,Nf as Wx,Of as Xx,Pf as Yx,Qf as Zx}from"../chunk-7rjrea9g.js";import"../chunk-emygmh7r.js";import{Tf as _x,Uf as zx,Vf as Dx,Wf as Tx,Xf as jx,Yf as Ix}from"../chunk-kpqez1ht.js";import"../chunk-vckn5ate.js";import{ag as e,bg as g,cg as r,dg as v,eg as i,fg as s,gg as n,hg as pp,ig as op,jg as d}from"../chunk-wreexgkb.js";import"../chunk-gvnsr72j.js";import"../chunk-1m5wprvm.js";import"../chunk-ktmgq0ja.js";import{$g as jR,Wg as To,Xg as jo,Yg as Io,Zg as Lo,ah as IR,bh as LR,ch as BR,dh as FR,eh as HR,fh as kR,gh as qR,hh as JR,ih as KR,jh as QR,kh as WR,lh as XR,mh as YR,nh as ZR,oh as $R,ph as bR,qh as tR,rh as wR,sh as SR,th as hR,uh as uR}from"../chunk-9m0epv44.js";import{vh as om}from"../chunk-hkb714k3.js";import{Ah as V,wh as S,xh as h,yh as u,zh as c}from"../chunk-6k6dgwmy.js";import{Bh as t}from"../chunk-qdmr84mc.js";import{Ch as w}from"../chunk-6xzzs109.js";import"../chunk-pxdrwhxx.js";import{Eh as J,Fh as K,Gh as Q,Hh as W,Ih as X,Jh as Y}from"../chunk-a3bnhq58.js";import{Kh as k,Lh as q,Mh as Z,Nh as $,Oh as b}from"../chunk-8dj94fsy.js";import"../chunk-0apd8zqn.js";import"../chunk-s3ksf6s5.js";var{semver:m}=globalThis.Bun;class R{static compareVersions(p,o){return m.order(p,o)}static satisfiesRange(p,o){return m.satisfies(p,o)}static getLatestInRange(p,o){let f=p.filter((x)=>m.satisfies(x,o));if(f.length===0)return null;return f.sort((x,M)=>m.order(M,x))[0]}static createRange(p){return{raw:p,range:p.replace(/^[\^~>=<]+/,""),isExact:!/^[\^~>=<]/.test(p),satisfies:(o)=>this.satisfiesRange(o,p),getLatest:(o)=>this.getLatestInRange(o,p)}}static getUpdateType(p,o){return d(p,o)}static isSafeUpdate(p,o){return m.satisfies(o,p)}}export{Fx as writeFileTool,Yx as wrapUntrusted,gf as withTouchOffer,no as withNarrative,sf as verifyChanges,tR as validateWorkflowGeneration,wR as validateRepositoryAccess,Ud as validateFindings,Bo as validateConfig,Jo as validateAgainstSchema,HR as updateProgress,bf as unitTestsTouch,Sp as toOsvEcosystem,Hp as tagUpdateType,Kf as syntaxAnalyzer,lp as supports,z as summarizeUsage,fR as summarizeGates,lo as stripOperators,bd as stripNonCommandContext,nf as stackedBranchName,Mo as splitConstraint,op as sortUpdatesByPriority,wf as simplifyTouch,yR as similarity,Vx as sign,uR as showFinalInstructions,N as shouldOpenAsDraft,Yd as shouldFail,Jf as shellcheckAnalyzer,Kx as shellTool,hR as setupCustomWorkflow,$ as setDefaultLogger,ld as serializeReviewState,Af as serializeLearnings,Of as selectLearnings,Fp as selectLatestTag,qf as secretsAnalyzer,YR as schedulePlan,ao as scanEcosystems,vp as scanCatalogs,Bp as sameVariant,Go as rustAdapter,yf as runTool,pd as runStackedTouch,Bd as runReviewForPR,LR as runPreflightChecks,ER as runPostMerge,Zf as runPlan,Ko as runHeadless,xR as runGates,nd as runFixCi,Wf as runAnalyzers,UR as runAiGates,Zx as runAgent,A as ruleMatches,Ao as rubyAdapter,Ld as reviewPullRequest,Px as reviewMode,Ed as reviewDiff,Lx as resolveWorkspacePath,G as resolveRuleEffects,Op as resolveProviderToken,pf as resolveModelAlias,bp as resolveEngineVersion,Kp as resolveCredentials,ep as resolveCatalogReference,Id as resolveBuddyThreads,ff as resolveAiProvider,fm as resetConfigCache,Vf as renderTouchOffer,so as renderReport,TR as renderQuickLinks,aR as renderPackageContext,D as renderMigrationReport,Pf as renderLearnings,Td as renderFinding,qo as renderDoctorReport,xd as renderDiffForReview,_f as relativize,yo as regenerateLockfiles,xp as regenerateLockFile,Tx as redactError,Dx as redactDeep,zx as redact,Bx as readFileTool,Uo as pythonAdapter,Wo as publishOutput,Yo as productFor,jd as prepareReview,Sf as planTouch,yx as planMode,$p as pinBlocksUpdate,Ro as pep440UpdateType,Vp as parseWorkspaceCatalogs,md as parseUnifiedDiff,rf as parseTouchSelections,Nf as parseToolJson,Ip as parseTag,yd as parseReviewState,W as parseRetryDelay,qR as parseRemote,zR as parseQuickSelection,mo as parsePep440,g as parsePackageFile,Uf as parseLearnings,kp as parseImageRef,ho as parseHistory,td as parseCommand,Qp as parseAuthChallenge,If as offsetToLine,po as numericUpdateType,hp as normalizeSeverity,C as normalizePlan,Cd as needsReview,O as mergeGroupEffects,Sd as mentionsBot,B as matchesGlobs,Hf as markdownlintAnalyzer,zp as mapWithConcurrency,Cf as mapSeverity,af as loadLearnings,Vo as loadHistory,zd as loadGuidelines,Hx as listDirTool,Ff as linterAnalyzer,id as latestFailurePerWorkflow,wd as isReadOnlyCommand,fo as isPep440Prerelease,OR as isMergeEvent,gp as isCatalogReference,l as isAllowedCodemod,ax as implementMode,ef as hasTouchOffer,jf as hadolintAnalyzer,KR as guideTokenCreation,WR as guideRepositorySettings,P as groupsToRules,pp as groupUpdates,oo as goAdapter,Tf as githubActionsAnalyzer,bR as getWorkflowPreset,c as getNpmRegistryUrl,h as getGitHubServerUrl,S as getGitHubApiUrl,uf as getFinishingTouch,b as getDefaultLogger,xm as getConfig,V as getComposerRegistryUrl,mp as getAllLockFilePaths,Nx as getAgentMode,ZR as generateUnifiedWorkflow,jo as generateGitLabPipeline,$R as generateCoreWorkflows,XR as generateConfigFile,n as generateBranchName,Io as generateBitbucketPipeline,dR as gateIcon,kx as fsTools,e as formatSecurityAdvisorySection,Wd as formatReview,qd as formatPretty,i as formatPRTitle,s as formatPRBody,qp as formatImageRef,Qo as formatGithubOutput,Jd as formatGithub,q as formatError,Fo as formatConfigIssues,v as formatCommitMessage,Kd as formatAgent,lx as fixCiMode,Md as fingerprint,_ as findUsageSites,co as findPrevious,PR as findMentionedPackages,AR as findLinkedIssues,CR as findDuplicates,_o as findDrift,X as fetchWithTimeout,Y as fetchJsonOrNull,vd as failsOnBaseBranch,gd as extractErrorLines,Yp as extractEngines,Xf as emitEvent,U as ecosystemOf,Co as driftFor,$f as docstringsTouch,SR as displayValidationResults,kR as displayProgress,cd as dispatchCommand,Hd as diffArgsFor,ko as diagnose,fp as detectRequiredPackageManagers,JR as detectRepository,r as detectPackageManager,Bf as detectLinter,sp as detectFiles,od as detectChangedFiles,L as describeSpanGaps,rd as describeFailure,tx as describeEvent,to as describeEol,zo as describeDrift,Pd as defaultIncludePath,mm as defaultConfig,Ad as dedupeFindings,Zo as cycleFor,cx as createWebhookSink,hx as createSlackSink,Sx as createSinks,Yf as createReadIssueTool,ap as createProvider,FR as createProgressTracker,xf as createOpenAiProvider,Gf as createLearning,Vd as createHandlers,mf as createGoogleProvider,ux as createDiscordSink,of as createAnthropicProvider,df as createAiClient,Qd as countBySeverity,lR as constrainLabels,QR as confirmTokenSetup,dm as config,ro as computeMetrics,vo as computeDeltas,Dd as composeInstructions,Lp as compareVersions,xo as comparePep440,np as compareNumeric,zf as commandExists,I as collectSpanNotes,Zp as collectResolutionPins,kd as collectLocalDiff,fd as collectGitDiff,DR as clearQuickSelection,u as clearNpmrcCache,ed as classifyFailure,Lo as ciTemplateFor,Dp as chunk,pR as checkTitleFormat,ud as checkPermission,RR as checkLinkedIssue,$o as checkEol,oR as checkDescription,mR as checkDependencies,MR as checkCustomAssertions,tp as bumpEngineConstraint,Jx as buildShellEnv,y as buildAnalysisPrompt,tf as autofixTouch,T as attemptMajorUpgrade,sd as attemptFix,Ho as assertValidConfig,yp as assertSupports,Pp as assertProviderSupported,Xd as applySuggestion,E as applyRules,ip as applyCatalogUpdates,rp as applyCatalogUpdate,H as appendUpgradeReport,uo as appendHistory,GR as appendChangelogEntry,Jp as apiHostFor,Od as anchorMap,BR as analyzeProject,F as analyzeGroupMajors,cp as advisoryKey,Ef as addLearning,Po as adapterNamed,Oo as adapterFor,Df as actionlintAnalyzer,wx as WEBHOOK_PAYLOAD_VERSION,R as VersionResolver,Gp as UnsupportedProviderError,Xx as Toolbelt,Qx as ToolPermissionError,cf as TOUCH_OFFER_MARKER,lf as TOOL_TIMEOUT_MS,vf as TEST_COMMANDS,up as SecurityAdvisoryService,pm as Scheduler,qx as SHELL_ENV_ALLOWLIST,dd as SEVERITY_ORDER,kf as SECRET_RULES,Cp as ReleaseNotesFetcher,jp as RegistryClient,No as ROOT,ad as REVIEW_STATE_VERSION,Rd as REVIEW_SCHEMA,Fd as REVIEW_FORMATS,eo as REPORT_PERIODS,io as REPORT_MARKER,_x as REDACTED,$d as READ_ONLY_COMMANDS,NR as QUICK_LINKS_MARKER,_R as QUICK_ACTIONS,Np as PullRequestGenerator,IR as PluginManager,wp as PackageScanner,gx as PackageRegistryError,Up as PROVIDER_TRACKING_ISSUES,Ep as PROVIDER_TOKEN_ENV,nx as PROVIDER_PRIORITY,Rp as PROVIDER_NAMES,sx as PROVIDER_KEY_ENV,go as PERIOD_DAYS,Wp as OciClient,Ap as NO_CAPABILITIES,ix as MODEL_ALIASES,a as MIGRATION_PLAN_SCHEMA,_d as MAX_GUIDELINE_CHARS,Z as Logger,Lf as LINTER_SPECS,Xp as KNOWN_ENGINES,Mp as IMPLEMENTED_PROVIDERS,Q as HttpRequestError,wo as HISTORY_PATH,So as HISTORY_LIMIT,hd as HELP_TEXT,rx as GitProviderError,t as GitLabProvider,dp as GitHubProvider,k as GitHubApiError,om as GitHubActionsTemplate,hf as FINISHING_TOUCHES,bx as EventBus,$x as EVENT_NAMES,bo as EOL_WARNING_DAYS,Xo as EOL_PRODUCTS,J as DEFAULT_TIMEOUT_MS,j as DEFAULT_SPAN_BUDGET,To as DEFAULT_SCHEDULE,K as DEFAULT_RETRIES,Mf as DEFAULT_PROMPT_LIMIT,Rf as DEFAULT_LEARNINGS_FILE,Nd as DEFAULT_GUIDELINE_FILES,Gd as DEFAULT_EXCLUDED_PATHS,_p as DEFAULT_CONCURRENCY,jR as ConfigurationMigrator,vx as ConfigurationError,Zd as COMMAND_ALIASES,ex as BuddyError,Do as Buddy,w as BitbucketProvider,Wx as BUILTIN_TOOLS,Qf as BUILTIN_ANALYZERS,Eo as BUILTIN_ADAPTERS,Tp as AsyncMemo,Ix as AiProviderError,jx as AiBudgetExceededError,Cx as AGENT_MODES};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@buddysh/buddy",
3
3
  "type": "module",
4
- "version": "0.11.9",
4
+ "version": "0.11.10",
5
5
  "description": "AI code review and dependency updates in one bot. Reviews pull requests and local changes, answers @buddy comments, gates merges, repairs failing CI, and keeps dependencies current across npm, Composer, Docker, GitHub Actions and more.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",