@buddysh/buddy 0.11.7 → 0.11.8
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 +14 -0
- package/bin/cli.ts +3 -2
- package/dist/bin/cli.js +47 -47
- package/dist/chunk-00vbhh0z.js +2 -0
- package/dist/{chunk-wcjf072v.js → chunk-04qvf24t.js} +1 -1
- package/dist/{chunk-njfbmhm4.js → chunk-0apd8zqn.js} +7 -7
- package/dist/chunk-0y706m2d.js +2 -0
- package/dist/chunk-1aee33aa.js +2 -0
- package/dist/{chunk-1z4nhstx.js → chunk-1eh199jk.js} +1 -1
- package/dist/{chunk-fvhnza91.js → chunk-1m5wprvm.js} +1 -1
- package/dist/{chunk-2egzc1fp.js → chunk-1tg7dfq5.js} +1 -1
- package/dist/{chunk-5zs6jrpt.js → chunk-1vhqtq6m.js} +1 -1
- package/dist/{chunk-ysp81zyt.js → chunk-2145m12g.js} +1 -1
- package/dist/{chunk-w16pwfh3.js → chunk-2m0134q8.js} +1 -1
- package/dist/chunk-3ggd7z2f.js +2 -0
- package/dist/chunk-3w79fw62.js +2 -0
- package/dist/{chunk-675c6ddc.js → chunk-3waqfh3y.js} +1 -1
- package/dist/chunk-3xbx315d.js +2 -0
- package/dist/{chunk-3z759ya5.js → chunk-4akhxmfk.js} +1 -1
- package/dist/{chunk-q0tve4cm.js → chunk-4c3dws2k.js} +1 -1
- package/dist/{chunk-03j2dx5h.js → chunk-4hd1mryc.js} +1 -1
- package/dist/chunk-4k9f9vn2.js +2 -0
- package/dist/chunk-4s12xebp.js +2 -0
- package/dist/{chunk-3wy8fypy.js → chunk-4wbbbcs2.js} +1 -1
- package/dist/{chunk-tgh61e5e.js → chunk-5dscgksz.js} +1 -1
- package/dist/chunk-5dw0q5ng.js +2 -0
- package/dist/chunk-5qtdc2mb.js +2 -0
- package/dist/{chunk-xe2xdg6z.js → chunk-61gfjcqt.js} +1 -1
- package/dist/chunk-6gttmvww.js +2 -0
- package/dist/{chunk-97cvp0t3.js → chunk-6wxwewbh.js} +1 -1
- package/dist/chunk-6xzzs109.js +3 -0
- package/dist/{chunk-4ycesykg.js → chunk-7bctsv0x.js} +1 -1
- package/dist/{chunk-0ewzxzt3.js → chunk-7crh00m7.js} +1 -1
- package/dist/{chunk-na0b9r57.js → chunk-7ds5q6j3.js} +1 -1
- package/dist/chunk-7f6mpphq.js +2 -0
- package/dist/{chunk-9b4z1bpx.js → chunk-7gd1et2j.js} +1 -1
- package/dist/{chunk-1q6s6a5e.js → chunk-7mmdxbcm.js} +1 -1
- package/dist/{chunk-p8azbpq6.js → chunk-7rjrea9g.js} +1 -1
- package/dist/chunk-7ze1qrmt.js +2 -0
- package/dist/{chunk-55znd3yn.js → chunk-88xaexj1.js} +1 -1
- package/dist/{chunk-f0z6kyqt.js → chunk-8dj94fsy.js} +1 -1
- package/dist/{chunk-yke7v3gh.js → chunk-8tsw3cjk.js} +1 -1
- package/dist/{chunk-q5pxt13t.js → chunk-90q6r1j7.js} +1 -1
- package/dist/{chunk-4wh0wryv.js → chunk-9m0epv44.js} +1 -1
- package/dist/{chunk-ddmvjp0y.js → chunk-a3bnhq58.js} +1 -1
- package/dist/{chunk-d2d5m2kx.js → chunk-amj037yy.js} +2 -2
- package/dist/chunk-b8t39c5t.js +2 -0
- package/dist/{chunk-j0bsva07.js → chunk-be059ncv.js} +1 -1
- package/dist/{chunk-m17kvr7m.js → chunk-bjymeq7e.js} +1 -1
- package/dist/{chunk-39ne6m3w.js → chunk-c8g8z15b.js} +1 -1
- package/dist/chunk-d7jpbw1z.js +9 -0
- package/dist/{chunk-zkv7e2q2.js → chunk-drkzf2gz.js} +1 -1
- package/dist/chunk-ea6rtyvy.js +2 -0
- package/dist/{chunk-eftyxrxw.js → chunk-er0ntw4q.js} +1 -1
- package/dist/{chunk-2pv5zwbm.js → chunk-f0gag8vx.js} +6 -6
- package/dist/{chunk-t3a1703q.js → chunk-fystbk81.js} +1 -1
- package/dist/{chunk-3d3rwmmj.js → chunk-ggzjv4s0.js} +1 -1
- package/dist/{chunk-sf4p2t84.js → chunk-gs5b2ssa.js} +1 -1
- package/dist/chunk-gw69sjx2.js +2 -0
- package/dist/{chunk-4rvgatmm.js → chunk-gyf7psxg.js} +1 -1
- package/dist/{chunk-wr1q4k9e.js → chunk-h8e796qs.js} +1 -1
- package/dist/{chunk-xzhzvdcv.js → chunk-hdqmcp3n.js} +1 -1
- package/dist/{chunk-x4ea69ek.js → chunk-hyp0wfta.js} +1 -1
- package/dist/{chunk-06k6abjj.js → chunk-j0fcqty9.js} +1 -1
- package/dist/{chunk-3zk2ye6r.js → chunk-jj1gjkb7.js} +1 -1
- package/dist/{chunk-4mwgk0jh.js → chunk-k3x0mabj.js} +2 -2
- package/dist/{chunk-p96zq2zc.js → chunk-k7x9af5r.js} +1 -1
- package/dist/{chunk-7wk4px2k.js → chunk-kh6v93yb.js} +1 -1
- package/dist/{chunk-efqnnrwq.js → chunk-khn11t39.js} +1 -1
- package/dist/{chunk-z456ptfw.js → chunk-kpdz73mc.js} +1 -1
- package/dist/{chunk-v8746363.js → chunk-mcn3508w.js} +3 -3
- package/dist/{chunk-a1fkxmxq.js → chunk-mdbf728w.js} +1 -1
- package/dist/{chunk-he97rsmj.js → chunk-mg3em5qj.js} +1 -1
- package/dist/chunk-mzb7cg8a.js +2 -0
- package/dist/chunk-n0mvh9p4.js +2 -0
- package/dist/chunk-nvz9jajn.js +2 -0
- package/dist/{chunk-v6dephze.js → chunk-nwrr6jas.js} +1 -1
- package/dist/{chunk-srznv36n.js → chunk-p5yaf72b.js} +1 -1
- package/dist/{chunk-sczx20gw.js → chunk-p9z0hzej.js} +1 -1
- package/dist/{chunk-52jcty4n.js → chunk-pjq0qxst.js} +1 -1
- package/dist/{chunk-cbqg29zr.js → chunk-pmszvhja.js} +1 -1
- package/dist/chunk-pxdrwhxx.js +3 -0
- package/dist/{chunk-1z9a3hpe.js → chunk-q90s02qc.js} +1 -1
- package/dist/chunk-qdmr84mc.js +5 -0
- package/dist/{chunk-qv1nvaha.js → chunk-qtyr3kqj.js} +1 -1
- package/dist/{chunk-qczzpthf.js → chunk-rg996jqw.js} +1 -1
- package/dist/{chunk-c87s8txp.js → chunk-rrnvxj90.js} +1 -1
- package/dist/{chunk-6sm15trq.js → chunk-s3ksf6s5.js} +1 -1
- package/dist/{chunk-qz5nqeza.js → chunk-se4g70q2.js} +1 -1
- package/dist/{chunk-305184z3.js → chunk-srz5kgyg.js} +1 -1
- package/dist/chunk-tf9nqr0p.js +2 -0
- package/dist/chunk-tm8eg4sk.js +2 -0
- package/dist/{chunk-f298fv6p.js → chunk-tq1w2wwa.js} +1 -1
- package/dist/chunk-w93akf6h.js +2 -0
- package/dist/chunk-wd8w0vjs.js +2 -0
- package/dist/{chunk-4b0p7kgk.js → chunk-wjmp2hsj.js} +1 -1
- package/dist/{chunk-f001yg2a.js → chunk-wreexgkb.js} +2 -2
- package/dist/{chunk-qk43d3vv.js → chunk-wtt17gzv.js} +1 -1
- package/dist/chunk-xvae9y99.js +2 -0
- package/dist/{chunk-4gx2f1k6.js → chunk-y7z0br2x.js} +1 -1
- package/dist/{chunk-wts1sqw7.js → chunk-y9senfb6.js} +1 -1
- package/dist/{chunk-sjk83y3d.js → chunk-ydt2sn0j.js} +1 -1
- package/dist/{chunk-5gybfx14.js → chunk-ysgex7h7.js} +1 -1
- package/dist/chunk-z0qbkvyz.js +2 -0
- package/dist/{chunk-nhe8axrf.js → chunk-z21tw4fz.js} +2 -2
- package/dist/chunk-z24p5t3p.js +106 -0
- package/dist/chunk-zefqbamj.js +2 -0
- package/dist/{chunk-ztw515ew.js → chunk-zrg5ss0x.js} +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/setup.js +1 -1
- package/dist/src/utils/branches.d.ts +13 -0
- package/package.json +1 -1
- package/dist/chunk-19n3wnxq.js +0 -106
- package/dist/chunk-1n42ghef.js +0 -3
- package/dist/chunk-23c6tfbw.js +0 -2
- package/dist/chunk-2ppt1rrx.js +0 -2
- package/dist/chunk-3d5pjrz7.js +0 -5
- package/dist/chunk-3jw9d546.js +0 -2
- package/dist/chunk-4d13qb9f.js +0 -2
- package/dist/chunk-5ct11b1j.js +0 -2
- package/dist/chunk-6t1rb4tz.js +0 -2
- package/dist/chunk-9b2yfhzj.js +0 -9
- package/dist/chunk-a4m6bqpq.js +0 -2
- package/dist/chunk-djdf848n.js +0 -2
- package/dist/chunk-dsep28r5.js +0 -2
- package/dist/chunk-e6sg7jg4.js +0 -2
- package/dist/chunk-eme4fny7.js +0 -2
- package/dist/chunk-fjp4k18r.js +0 -2
- package/dist/chunk-gw3t78fw.js +0 -2
- package/dist/chunk-h4084ykd.js +0 -2
- package/dist/chunk-jczf4z85.js +0 -2
- package/dist/chunk-m2qq154g.js +0 -2
- package/dist/chunk-m8kqe55k.js +0 -2
- package/dist/chunk-n42c80f3.js +0 -2
- package/dist/chunk-nfcyqj66.js +0 -2
- package/dist/chunk-pvfavmy3.js +0 -2
- package/dist/chunk-rfgacg5h.js +0 -2
- package/dist/chunk-t0kvt1pm.js +0 -2
- package/dist/chunk-wfn702a2.js +0 -2
- package/dist/chunk-xpsetmcw.js +0 -2
- package/dist/chunk-yd834q68.js +0 -2
- package/dist/chunk-ymwjjyke.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{rf as a,sf as b,tf as c,uf as d,vf as e,wf as f,xf as g}from"./chunk-k7x9af5r.js";import"./chunk-emygmh7r.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{f as strategyAllows,b as ruleMatches,c as resolveRuleEffects,e as mergeGroupEffects,g as groupsToRules,a as ecosystemOf,d as applyRules};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{dl as Z}from"./chunk-s3ksf6s5.js";import x from"process";var K=["github","gitlab","bitbucket"],$=["github","gitlab","bitbucket"],H={},L={pinIssues:!1,checkRuns:!1,inlineReviewComments:!1,reviewSuggestions:!1,nativeAutoMerge:!1,commentReactions:!1,ciLogs:!1,ciRuns:!1,reviewThreads:!1,teamReviewers:!1,draftPullRequests:!1,permissionLookup:!1,branchHousekeeping:!1,reopenPullRequests:!1,labels:!1};class Y extends Error{provider;trackingIssue;constructor(j,z,F){super(j);this.provider=z;this.trackingIssue=F;this.name="UnsupportedProviderError"}}var B={github:["GITHUB_TOKEN","BUDDY_TOKEN"],gitlab:["CI_JOB_TOKEN","GITLAB_TOKEN","BUDDY_TOKEN"],bitbucket:["BITBUCKET_TOKEN","BUDDY_TOKEN"]};function A(j,z=x.env){for(let F of B[j]??[]){let J=z[F]?.trim();if(J)return{token:J,source:F}}return null}function C(j){if($.includes(j))return;let z=H[j];if(z)throw new Y(`'${j}' support is not implemented yet \u2014 follow ${z}. Supported today: ${$.join(", ")}.`,j,z);throw new Y(`Unknown git provider '${j}'. Supported: ${$.join(", ")}.`,j)}async function M(j,z={}){let F=j.provider??"github";C(F);let J=z.env??x.env,X=j.token??A(F,J)?.token;if(!X)throw Error(`No token for ${F}. Set one of: ${B[F].join(", ")}.`);switch(F){case"gitlab":{let{GitLabProvider:Q}=await import("./chunk-00vbhh0z.js");return new Q(X,j.owner,j.name,j.apiUrl,z.logger)}case"bitbucket":{let{BitbucketProvider:Q}=await import("./chunk-gw69sjx2.js");return new Q(X,j.owner,j.name,j.apiUrl,z.logger)}case"github":{let{GitHubProvider:Q}=await import("./chunk-nvz9jajn.js"),q=j.workflowToken??J.BUDDY_TOKEN;return new Q(X,j.owner,j.name,Boolean(q),q,j.apiUrl,z.logger)}}}function W(j,z,F){return j.capabilities()[z]===!0&&typeof j[F]==="function"}function S(j,z,F,J){if(W(j,z,F))return;throw new Y(`This provider does not support ${J} (missing capability '${z}').`,"unknown")}
|
|
3
3
|
export{K as he,$ as ie,H as je,L as ke,Y as le,B as me,A as ne,C as oe,M as pe,W as qe,S as re};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Oh as K}from"./chunk-8dj94fsy.js";import{Dj as R}from"./chunk-0apd8zqn.js";import{dl as x}from"./chunk-s3ksf6s5.js";function $(w){let z=w.split("/").pop()||"";if(["deps.yaml","dependencies.yaml","pkgx.yaml",".deps.yaml"].includes(z))return!0;let j=z.replace(/\.(yaml|yml)$/,"");return["deps","dependencies","pkgx",".deps"].includes(j)}async function V(w,z){try{if(!$(w))return null;let H=[];try{let G=await R(w);if(G&&typeof G==="object"){if(G.allDependencies&&Array.isArray(G.allDependencies)){for(let J of G.allDependencies)if(J.name&&J.constraint)H.push({name:J.name,currentVersion:J.constraint,type:"dependencies",file:w})}}}catch(G){K().warn(`ts-pantry failed to parse ${w}, attempting fallback YAML parsing:`,G)}if(H.length===0)try{H=await B(z,w)}catch(G){K().warn(`Fallback YAML parsing failed for ${w}:`,G),H=[]}let j=w.split("/").pop()||"";return{path:w,type:j,content:z,dependencies:H}}catch(H){return K().warn(`Failed to parse dependency file ${w}:`,H),null}}async function B(w,z){let H=[],j=w.split(`
|
|
3
3
|
`),G=!1;for(let J of j){let Q=J.trim();if(Q==="dependencies:"){G=!0;continue}if(G){if(Q&&!J.startsWith(" ")&&!J.startsWith("\t")){G=!1;continue}let T=Q.match(/^([\w@/-]+):\s*(.+)$/);if(T){let[,X,Z]=T;H.push({name:X.trim(),currentVersion:Z.trim(),type:"dependencies",file:z})}}}return H}function O(w){try{return Bun.YAML.parse(w),!0}catch{return!1}}async function M(w,z,H){try{if(!$(w))return K().info(`\u26A0\uFE0F updateDependencyFile: ${w} is not a dependency file, returning original content`),z;if(z.trim().startsWith("{")&&z.includes('"require"'))return K().info(`\u26A0\uFE0F updateDependencyFile: Content appears to be JSON (composer.json), but file is ${w}`),K().info(`Content preview: ${z.substring(0,200)}`),z;let j=z;for(let G of H){let J=G.name.replace(/\s*\(dev\)$/,"").replace(/\s*\(peer\)$/,"").replace(/\s*\(optional\)$/,""),Q=J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),T=new RegExp(`^([ \\t]*)("${Q}"|'${Q}'|${Q})([ \\t]*:[ \\t]*)(["']?)([^\\s#"']+)\\4([ \\t]*#[^\\r\\n]*)?`,"gm");j=j.replace(T,(X,Z,W,A,b,_,E)=>{if(["latest","*","main","master","develop","dev"].includes(_.toLowerCase().trim()))return K().info(`\u26A0\uFE0F Skipping update for ${J} - version "${_}" should be respected`),X;let Y=_.match(/^(\D*)/)?.[1]??"",q=/^[\^~>=<]/.test(G.newVersion)?G.newVersion:`${Y}${G.newVersion}`;return`${Z}${W}${A}${b}${q}${b}${E??""}`})}if(j!==z&&O(z)&&!O(j))return K().warn(`\u26A0\uFE0F Skipping updates for ${w}: the rewrite no longer parses as YAML, so the file is left unchanged`),z;return j}catch(j){return K().warn(`Failed to update dependency file ${w}:`,j),z}}async function k(w){let z=[],H=new Map;for(let j of w)if($(j.file)){if(!H.has(j.file))H.set(j.file,[]);H.get(j.file).push(j)}for(let[j,G]of H)try{let J=await import("fs");if(J.existsSync(j)){let Q=J.readFileSync(j,"utf-8"),T=await M(j,Q,G);if(T!==Q)z.push({path:j,content:T,type:"update"}),K().info(`\u2705 Generated update for ${j} with ${G.length} package changes`);else K().info(`\u2139\uFE0F No changes needed for ${j} - versions already up to date`)}else K().warn(`\u26A0\uFE0F Dependency file ${j} does not exist`)}catch(J){K().warn(`Failed to generate updates for dependency file ${j}:`,J)}return z}
|
|
4
4
|
export{$ as yg,V as zg,M as Ag,k as Bg};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{aa as a,ba as b,ca as c,da as d,ea as e,fa as f,ga as g,ha as h,ia as i,ja as j}from"./chunk-69qyr9ef.js";import"./chunk-
|
|
2
|
+
import{aa as a,ba as b,ca as c,da as d,ea as e,fa as f,ga as g,ha as h,ia as i,ja as j}from"./chunk-69qyr9ef.js";import"./chunk-s3ksf6s5.js";export{d as similarity,j as renderQuickLinks,b as renderPackageContext,h as parseQuickSelection,a as findMentionedPackages,e as findDuplicates,c as constrainLabels,i as clearQuickSelection,f as QUICK_LINKS_MARKER,g as QUICK_ACTIONS};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{bg as a,cg as b,dg as c,eg as d,fg as e,gg as f,hg as g,ig as h,jg as i,kg as j,lg as k,mg as l,ng as m}from"./chunk-
|
|
2
|
+
import{bg as a,cg as b,dg as c,eg as d,fg as e,gg as f,hg as g,ig as h,jg as i,kg as j,lg as k,mg as l,ng as m}from"./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{h as sortUpdatesByPriority,j as satisfiesRange,a as parsePackageFile,g as groupUpdates,i as getUpdateType,f as generateBranchName,d as formatPRTitle,e as formatPRBody,c as formatCommitMessage,l as extractPackageNamesFromPRBody,b as detectPackageManager,k as checkForRebaseRequests,m as checkForAutoClose};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Qb as p,Rb as q,Sb as r,Tb as s,Ub as t,Vb as u,Wb as v,Xb as w,Yb as x}from"./chunk-
|
|
2
|
+
import{Qb as p,Rb as q,Sb as r,Tb as s,Ub as t,Vb as u,Wb as v,Xb as w,Yb as x}from"./chunk-y7z0br2x.js";import{$b as i,Zb as g,_b as h,ac as j,bc as k,cc as l,dc as m,ec as n,fc as o}from"./chunk-ggzjv4s0.js";import"./chunk-emygmh7r.js";import{Tf as a,Uf as b,Vf as c,Wf as d,Xf as e,Yf as f}from"./chunk-kpqez1ht.js";import"./chunk-a3bnhq58.js";import"./chunk-8dj94fsy.js";import"./chunk-s3ksf6s5.js";export{s as serializeLearnings,v as selectLearnings,j as resolveModelAlias,n as resolveAiProvider,w as renderLearnings,d as redactError,c as redactDeep,b as redact,r as parseLearnings,x as loadLearnings,m as createOpenAiProvider,t as createLearning,l as createGoogleProvider,k as createAnthropicProvider,o as createAiClient,u as addLearning,a as REDACTED,i as PROVIDER_PRIORITY,h as PROVIDER_KEY_ENV,g as MODEL_ALIASES,q as DEFAULT_PROMPT_LIMIT,p as DEFAULT_LEARNINGS_FILE,f as AiProviderError,e as AiBudgetExceededError};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Ih as U}from"./chunk-a3bnhq58.js";import{Oh as f}from"./chunk-8dj94fsy.js";var{Glob:u}=globalThis.Bun;import{readdir as m}from"fs/promises";import{join as P,relative as l}from"path";import O from"process";var c=new Set(["node_modules","vendor","target",".git",".venv","venv","dist","build","__pycache__",".next",".cache"]);function W(z){return z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async function L(z,H,$=4){let X=H.map((K)=>new u(K)),Z=[];async function J(K,G){if(G>$)return;let V=await m(K,{withFileTypes:!0}).catch(()=>[]);for(let Q of V){let j=P(K,Q.name);if(Q.isDirectory()){if(!c.has(Q.name)&&!Q.name.startsWith("."))await J(j,G+1);continue}let q=l(z,j);if(X.some((Y)=>Y.match(Q.name)||Y.match(q)))Z.push(q)}}return await J(z,0),Z.sort()}async function M(z,H){let $=[],X=[];for(let Z of H){if(!await Bun.file(P(z,Z.lockfile)).exists())continue;let[J]=Z.command;if(!await E(J)){X.push(`${Z.lockfile} (needs \`${Z.command.join(" ")}\`)`);continue}if(await Bun.spawn(Z.command,{cwd:z,stdout:"ignore",stderr:"ignore",env:{PATH:O.env.PATH??"",HOME:O.env.HOME??""}}).exited===0)$.push(Z.lockfile);else X.push(`${Z.lockfile} (\`${Z.command.join(" ")}\` failed)`)}return{regenerated:$,...X.length>0?{note:`These lockfiles were not regenerated and need updating locally: ${X.join(", ")}.`}:{}}}async function E(z){try{return await Bun.spawn(["which",z],{stdout:"ignore",stderr:"ignore",env:{PATH:O.env.PATH??""}}).exited===0}catch{return!1}}function B(z,H){let $=(J)=>J.replace(/^[^\d]*/,"").split(/[.-]/).map((K)=>Number.parseInt(K,10)||0),X=$(z),Z=$(H);for(let J=0;J<Math.max(X.length,Z.length);J++){let K=(X[J]??0)-(Z[J]??0);if(K!==0)return K}return 0}function C(z,H){let $=(J)=>J.replace(/^[^\d]*/,"").split(/[.-]/).map((K)=>Number.parseInt(K,10)||0),X=$(z),Z=$(H);if((X[0]??0)!==(Z[0]??0))return"major";if((X[1]??0)!==(Z[1]??0))return"minor";return"patch"}var p=/^\s*(?:require\s+)?([\w.~-]+(?:\.[\w.~-]+)*\/[^\s]+)\s+(v[\w.+-]+)\s*(\/\/.*)?$/,R=/^v\d+\.\d+\.\d+-\d{14}-[a-f0-9]{12}$/,I={name:"go",manifestPatterns:["go.mod"],async detect(z){return L(z,this.manifestPatterns)},async parse(z,H){let $=[],X=!1;for(let Z of H.split(`
|
|
3
3
|
`)){let J=Z.trim();if(/^require\s*\($/.test(J)){X=!0;continue}if(X&&J===")"){X=!1;continue}if(!X&&!J.startsWith("require "))continue;let K=p.exec(Z);if(!K)continue;let[,G,V,Q]=K;if(Q?.includes("indirect"))continue;if(R.test(V))continue;$.push({name:G,currentVersion:V,section:"require",file:z})}return $},async latest(z,H={}){let $=H.registryUrl??"https://proxy.golang.org",X=z.name.replace(/[A-Z]/g,(K)=>`!${K.toLowerCase()}`),Z=await U(`${$}/${X}/@latest`,{headers:{"User-Agent":"buddy",Accept:"application/json"}}).catch(()=>null);if(!Z?.ok)return null;let J=await Z.json().catch(()=>null);if(!J?.Version)return null;if(R.test(J.Version))return null;return{latest:J.Version,...J.Time?{publishedAt:new Date(J.Time)}:{},releaseNotesUrl:`https://pkg.go.dev/${z.name}@${J.Version}`,homepage:`https://pkg.go.dev/${z.name}`}},applyUpdate(z,H){let $=W(H.name),X=W(H.currentVersion);return z.replace(new RegExp(`^(\\s*(?:require\\s+)?${$}\\s+)${X}(\\s|$)`,"gm"),`$1${H.newVersion}$2`)},async postWrite(z){return M(z,[{lockfile:"go.sum",command:["go","mod","tidy"]}])},osvEcosystem:"Go",compareVersions:B,updateType:C};var s=/^\s*v?(?:(\d+)!)?(\d+(?:\.\d+)*)((?:[-_.]?(?:a|b|c|rc|alpha|beta|pre|preview)[-_.]?\d*)?)((?:[-_.]?(?:post|rev|r)[-_.]?\d*|-\d+)?)((?:[-_.]?dev[-_.]?\d*)?)(?:\+([a-z0-9]+(?:[-_.][a-z0-9]+)*))?\s*$/i,i={a:"a",alpha:"a",b:"b",beta:"b",c:"rc",rc:"rc",pre:"rc",preview:"rc"},v={a:0,b:1,rc:2};function S(z){let H=s.exec(z);if(!H)return null;let[,$,X,Z,J,K,G]=H,V={epoch:$?Number($):0,release:X.split(".").map(Number)};if(Z){let Q=/([a-z]+)[-_.]?(\d*)/i.exec(Z);if(Q){let j=i[Q[1].toLowerCase()];if(j)V.pre=[j,Q[2]?Number(Q[2]):0]}}if(J){let Q=/(\d+)/.exec(J);V.post=Q?Number(Q[1]):0}if(K){let Q=/(\d+)/.exec(K);V.dev=Q?Number(Q[1]):0}if(G)V.local=G.toLowerCase();return V}function d(z,H){for(let $=0;$<Math.max(z.length,H.length);$++){let X=(z[$]??0)-(H[$]??0);if(X!==0)return X}return 0}function A(z,H){let $=S(z),X=S(H);if(!$||!X)return z===H?0:z<H?-1:1;if($.epoch!==X.epoch)return $.epoch-X.epoch;let Z=d($.release,X.release);if(Z!==0)return Z;let J=(Q)=>{if(Q.dev!==void 0&&Q.pre===void 0&&Q.post===void 0)return 0;if(Q.pre!==void 0)return 1;if(Q.post!==void 0)return 3;return 2},K=J($)-J(X);if(K!==0)return K;if($.pre&&X.pre){let Q=v[$.pre[0]]-v[X.pre[0]];if(Q!==0)return Q;if($.pre[1]!==X.pre[1])return $.pre[1]-X.pre[1]}if(($.post??0)!==(X.post??0))return($.post??0)-(X.post??0);let G=$.dev??Number.POSITIVE_INFINITY,V=X.dev??Number.POSITIVE_INFINITY;if(G!==V)return G<V?-1:1;return 0}function g(z){let H=S(z);return Boolean(H&&(H.pre!==void 0||H.dev!==void 0))}function D(z,H){let $=S(z),X=S(H);if(!$||!X)return"patch";if($.epoch!==X.epoch||($.release[0]??0)!==(X.release[0]??0))return"major";if(($.release[1]??0)!==(X.release[1]??0))return"minor";return"patch"}function N(z){let H=/^\s*(~=|===|==|!=|<=|>=|<|>|\^)?\s*(.*)$/.exec(z.trim());if(!H)return{operator:"",version:z.trim()};return{operator:H[1]??"",version:H[2].trim()}}var b=/^\s*([A-Z0-9][\w.-]*)\s*(\[[^\]]*\])?\s*([<>=!~^].*?)?\s*(?:;.*)?$/i,o=/^\s*(?:-|#|$)/;function r(z,H){let $=[];return H.split(`
|
|
4
4
|
`).forEach((X)=>{let Z=X.split("#")[0];if(o.test(Z))return;let J=b.exec(Z);if(!J?.[1]||!J[3])return;$.push({name:J[1],currentVersion:J[3].trim(),section:"dependencies",file:z,...J[2]?{metadata:{extras:J[2]}}:{}})}),$}var a=[[/^\s*dependencies\s*=\s*\[/m,"dependencies"],[/^\s*(?:dev-dependencies|dev)\s*=\s*\[/m,"devDependencies"]];function n(z,H){let $=[],X=new Set,Z=(K,G,V)=>{let Q=`${V}:${K}`;if(!G.trim()||G.trim()==="*"||X.has(Q))return;X.add(Q),$.push({name:K,currentVersion:G.trim(),section:V,file:z})};for(let[K,G]of a){let V=K.exec(H);if(!V)continue;let Q=V.index+V[0].length,j=H.indexOf("]",Q);if(j===-1)continue;for(let q of H.slice(Q,j).matchAll(/["']([^"']+)["']/g)){let Y=b.exec(q[1]);if(Y?.[1]&&Y[3])Z(Y[1],Y[3],G)}}let J=H.matchAll(/\[tool\.poetry\.(?:group\.[\w-]+\.)?(dependencies|dev-dependencies)\]([\s\S]*?)(?=\n\[|$)/g);for(let K of J){let G=K[1]==="dependencies"?"dependencies":"devDependencies";for(let V of K[2].matchAll(/^\s*([A-Z0-9][\w.-]*)\s*=\s*(.+)$/gim)){let Q=V[1];if(Q.toLowerCase()==="python")continue;let j=V[2].trim(),q=/version\s*=\s*["']([^"']+)["']/.exec(j),Y=/^["']([^"']+)["']/.exec(j),F=q?.[1]??Y?.[1];if(F)Z(Q,F,G)}}return $}var w={name:"python",manifestPatterns:["pyproject.toml","requirements.txt","requirements-*.txt","requirements/*.txt"],async detect(z){return L(z,this.manifestPatterns)},async parse(z,H){return z.endsWith(".toml")?n(z,H):r(z,H)},async latest(z,H={}){let $=H.registryUrl??"https://pypi.org",X=await U(`${$}/pypi/${encodeURIComponent(z.name)}/json`,{headers:{"User-Agent":"buddy",Accept:"application/json"}}).catch(()=>null);if(!X?.ok)return null;let Z=await X.json().catch(()=>null);if(!Z?.info?.version)return null;let J=Z.info.version;if(H.includePrerelease&&Z.releases){let V=Object.keys(Z.releases).filter((Q)=>!Z.releases[Q]?.every((j)=>j.yanked)).sort(A);J=V[V.length-1]??J}let G=Z.releases?.[J]?.find((V)=>V.upload_time_iso_8601)?.upload_time_iso_8601;return{latest:J,...G?{publishedAt:new Date(G)}:{},...Z.info.yanked?{deprecated:!0}:{},...Z.info.project_urls?.Changelog?{releaseNotesUrl:Z.info.project_urls.Changelog}:{},...Z.info.home_page?{homepage:Z.info.home_page}:{}}},applyUpdate(z,H){let{operator:$}=N(H.currentVersion),X=W(H.name),Z=W(H.currentVersion),J=N(H.newVersion).version,K=$?`${$}${J}`:J;return z.replace(new RegExp(`(^|["'\\s])(${X})(\\[[^\\]]*\\])?\\s*${Z}`,"gim"),(G,V,Q,j)=>`${V}${Q}${j??""}${K}`).replace(new RegExp(`^(\\s*${X}\\s*=\\s*["'])${Z}(["'])`,"gim"),`$1${K}$2`).replace(new RegExp(`^(\\s*${X}\\s*=\\s*\\{[^}]*version\\s*=\\s*["'])${Z}(["'])`,"gim"),`$1${K}$2`)},async postWrite(z){return M(z,[{lockfile:"uv.lock",command:["uv","lock"]},{lockfile:"poetry.lock",command:["poetry","lock","--no-update"]}])},osvEcosystem:"PyPI",compareVersions:A,updateType:D};var t=/^\s*gem\s+["']([\w-]+)["']\s*(?:,\s*["']([^"']+)["'])?/,e=/^\s*group\s+(.+?)\s+do\s*$/,zz=/^\s*end\s*$/,x={name:"ruby",manifestPatterns:["Gemfile","*.gemspec"],async detect(z){return L(z,this.manifestPatterns)},async parse(z,H){let $=[],X=[];for(let Z of H.split(`
|
|
5
5
|
`)){let J=Z.replace(/#.*$/,""),K=e.exec(J);if(K){X.push(K[1].replace(/[:'",\s]/g,"")||"default");continue}if(zz.test(J)){X.pop();continue}let G=t.exec(J);if(!G?.[1])continue;if(!G[2])continue;if(/\b(?:path|git|github|branch):/.test(J))continue;$.push({name:G[1],currentVersion:G[2],section:X.length>0?X[X.length-1]:"dependencies",file:z})}return $},async latest(z,H={}){let $=H.registryUrl??"https://rubygems.org",X=await U(`${$}/api/v1/versions/${encodeURIComponent(z.name)}.json`,{headers:{"User-Agent":"buddy",Accept:"application/json"}}).catch(()=>null);if(!X?.ok)return null;let Z=await X.json().catch(()=>null);if(!Array.isArray(Z)||Z.length===0)return null;let J=Z.filter((G)=>G.number&&!G.yanked).filter((G)=>H.includePrerelease?!0:!G.prerelease).sort((G,V)=>B(G.number,V.number)),K=J[J.length-1];if(!K?.number)return null;return{latest:K.number,...K.created_at?{publishedAt:new Date(K.created_at)}:{},homepage:`${$}/gems/${z.name}`}},applyUpdate(z,H){let $=W(H.name),X=W(H.currentVersion),Z=/^\s*(~>|>=|<=|>|<|=)?\s*/.exec(H.currentVersion)?.[1]??"",J=Z?`${Z} ${H.newVersion}`:H.newVersion;return z.replace(new RegExp(`^(\\s*gem\\s+["']${$}["']\\s*,\\s*["'])${X}(["'])`,"gm"),`$1${J}$2`)},async postWrite(z){return M(z,[{lockfile:"Gemfile.lock",command:["bundle","lock","--update"]}])},osvEcosystem:"RubyGems",compareVersions:B,updateType:C};var Hz=[[/^\[dependencies\]/m,"dependencies"],[/^\[dev-dependencies\]/m,"devDependencies"],[/^\[build-dependencies\]/m,"buildDependencies"],[/^\[workspace\.dependencies\]/m,"workspaceDependencies"]],T={name:"rust",manifestPatterns:["Cargo.toml"],async detect(z){return L(z,this.manifestPatterns)},async parse(z,H){let $=[];for(let[X,Z]of Hz){let J=X.exec(H);if(!J)continue;let K=J.index+J[0].length,G=H.slice(K).search(/\n\[/),V=G===-1?H.slice(K):H.slice(K,K+G);for(let Q of V.matchAll(/^\s*([\w-]+)\s*=\s*(.+)$/gm)){let j=Q[1],q=Q[2].trim(),Y=/version\s*=\s*["']([^"']+)["']/.exec(q),F=/^["']([^"']+)["']/.exec(q),_=Y?.[1]??F?.[1];if(!_||/\b(?:path|git)\s*=/.test(q))continue;$.push({name:j,currentVersion:_,section:Z,file:z})}}return $},async latest(z,H={}){let $=H.registryUrl??"https://crates.io",X=await U(`${$}/api/v1/crates/${encodeURIComponent(z.name)}`,{headers:{"User-Agent":"buddy (https://buddy.sh)",Accept:"application/json"}}).catch(()=>null);if(!X?.ok)return null;let Z=await X.json().catch(()=>null);if(!Z?.crate)return null;let J=H.includePrerelease?Z.crate.newest_version??Z.crate.max_stable_version:Z.crate.max_stable_version??Z.crate.newest_version;if(!J)return null;let K=Z.versions?.find((G)=>G.num===J);if(K?.yanked)return null;return{latest:J,...K?.created_at?{publishedAt:new Date(K.created_at)}:{},...Z.crate.repository?{releaseNotesUrl:`${Z.crate.repository}/releases`}:{},...Z.crate.homepage?{homepage:Z.crate.homepage}:{}}},applyUpdate(z,H){let $=W(H.name),X=W(H.currentVersion);return z.replace(new RegExp(`^(\\s*${$}\\s*=\\s*["'])${X}(["'])`,"gm"),`$1${H.newVersion}$2`).replace(new RegExp(`^(\\s*${$}\\s*=\\s*\\{[^}]*?version\\s*=\\s*["'])${X}(["'])`,"gm"),`$1${H.newVersion}$2`)},async postWrite(z){return M(z,[{lockfile:"Cargo.lock",command:["cargo","update","--workspace"]}])},osvEcosystem:"crates.io",compareVersions:B,updateType:C};import{join as Xz}from"path";async function Zz(z){let H=z.logger??f(),$=z.adapters??k,X=new Set(z.ignore??[]),Z=[],J={},K=[];return await Promise.all($.map(async(G)=>{let V;try{V=await G.detect(z.dir)}catch(Q){H.warn(`\u26A0\uFE0F ${G.name}: could not look for manifests: ${Q}`);return}if(V.length===0)return;K.push({ecosystem:G.name,files:V}),H.debug(`\uD83D\uDCE6 ${G.name}: ${V.length} manifest(s)`);for(let Q of V){let j;try{j=await G.parse(Q,await Bun.file(Xz(z.dir,Q)).text())}catch(Y){H.warn(`\u26A0\uFE0F ${G.name}: could not parse ${Q}: ${Y}`);continue}J[G.name]=(J[G.name]??0)+j.length;let q=await Promise.all(j.map(async(Y)=>{if(X.has(Y.name))return null;try{let F=await G.latest(Y,{...z.includePrerelease!==void 0?{includePrerelease:z.includePrerelease}:{},logger:H});if(!F)return null;let _=y(Y.currentVersion);if(G.compareVersions(F.latest,_)<=0)return null;return{name:Y.name,currentVersion:Y.currentVersion,newVersion:F.latest,updateType:G.updateType(_,F.latest),dependencyType:G.name,file:Q,...F.releaseNotesUrl?{releaseNotesUrl:F.releaseNotesUrl}:{},...F.homepage?{homepage:F.homepage}:{}}}catch(F){return H.debug(`${G.name}: could not resolve ${Y.name}: ${F}`),null}}));Z.push(...q.filter((Y)=>Y!==null))}})),{updates:Z,dependenciesByEcosystem:J,manifests:K}}function y(z){let H=/(\d[\w.!+-]*)/.exec(z);return H?H[1]:z.trim()}async function $z(z,H,$=k){let X=[],Z=[];for(let J of $){if(!H.includes(J.name)||!J.postWrite)continue;let K=await J.postWrite(z).catch(()=>({regenerated:[],note:void 0}));if(X.push(...K.regenerated),K.note)Z.push(K.note)}return{regenerated:X,notes:Z}}var k=[w,T,I,x];function Ez(z,H=k){let $=z.split("/").pop()??z;for(let X of H)if(X.manifestPatterns.some((Z)=>h($,Z)||h(z,Z)))return X;return null}function h(z,H){if(!H.includes("*"))return z===H;let $=H.split("*").map((X)=>X.replace(/[.+?^${}()|[\]\\]/g,"\\$&")).join("[^/]*");return new RegExp(`^${$}$`).test(z)}function Rz(z,H=k){return H.find(($)=>$.name===z)??null}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{jd as a}from"./chunk-amj037yy.js";import"./chunk-89s9f3mf.js";import"./chunk-ja3rvd6y.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 RegistryClient};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Da as a}from"./chunk-7gd1et2j.js";import"./chunk-z24p5t3p.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-1eh199jk.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,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{tf as k,xf as b}from"./chunk-
|
|
2
|
+
import{tf as k,xf as b}from"./chunk-k7x9af5r.js";import{zf as C}from"./chunk-jpdd59fh.js";import{Qf as x}from"./chunk-7rjrea9g.js";import{ug as v}from"./chunk-gvnsr72j.js";import{Oh as D}from"./chunk-8dj94fsy.js";var T={type:"object",properties:{changes:{type:"array",items:{type:"object",properties:{description:{type:"string",description:"What upstream changed"},version:{type:"string",description:"Version the change landed in"},affectedFiles:{type:"array",items:{type:"string"}},action:{type:"string",description:"What must be done in this repository"},automatable:{type:"boolean",description:"Whether the fix is mechanical"}},required:["description","affectedFiles","action","automatable"],additionalProperties:!1}},codemod:{type:"object",properties:{command:{type:"string",description:"Command that applies the official codemod"},source:{type:"string",description:"Where the codemod is documented"}},required:["command","source"],additionalProperties:!1},confidence:{type:"string",enum:["high","medium","low"]},effort:{type:"integer",description:"1 (trivial) to 5 (demanding)"},risks:{type:"array",items:{type:"string"}}},required:["changes","confidence","effort","risks"],additionalProperties:!1},f=[/^(?:bunx|npx|pnpm dlx|yarn dlx)\s+[\w@/.-]+(?:\s+[\w@/.:=-]+)*$/];function y(J){let Y=J.trim();if(/[;&|`$><\n]/.test(Y))return!1;return f.some((Q)=>Q.test(Y))}function R(J){let Y=J.usage.slice(0,100).map((Q)=>`${Q.path}:${Q.line} (${Q.kind}) ${Q.text}`).join(`
|
|
3
3
|
`);return[`Analyse upgrading \`${J.packageName}\` from ${J.fromVersion} to ${J.toVersion}.`,"","Report only breaking changes that affect THIS repository, judged against the","usage sites below. A breaking change in a feature this repository does not use","is not worth reporting, and listing it makes the real ones harder to find.","","Mark a change automatable only when the fix is a mechanical edit you could write","exactly. Anything needing judgement is not automatable.","","If the package publishes an official codemod for this upgrade, report the command.","","Set confidence honestly: high when every change is understood and mechanical,","low when the notes are unclear or the change touches something subtle. A low","confidence plan is more useful than a wrong high confidence one.","","--- Release notes across the version span ---",J.releaseNotes||"(none available)","",`--- Usage in this repository (${J.usage.length} site(s)) ---`,Y||"(no direct usage found)"].join(`
|
|
4
4
|
`)}function A(J,Y){let Q=J??{},Z=new Set(Y.knownFiles),K=(Array.isArray(Q.changes)?Q.changes:[]).filter(($)=>Boolean($&&typeof $.description==="string"&&typeof $.action==="string")).map(($)=>({description:$.description,...$.version?{version:$.version}:{},affectedFiles:(Array.isArray($.affectedFiles)?$.affectedFiles:[]).filter((j)=>Z.has(j)),action:$.action,automatable:$.automatable===!0})),H=Q.codemod&&y(Q.codemod.command)?Q.codemod:void 0;return{packageName:Y.packageName,fromVersion:Y.fromVersion,toVersion:Y.toVersion,changes:K,...H?{codemod:H}:{},confidence:h(Q.confidence,K),effort:m(Q.effort),risks:(Array.isArray(Q.risks)?Q.risks:[]).filter(($)=>typeof $==="string")}}function E(J,Y="high"){let Q={low:0,medium:1,high:2};return Q[J.confidence]<Q[Y]}function h(J,Y){let Q=J==="high"||J==="medium"||J==="low"?J:"low";if(Q==="high"&&Y.some((Z)=>!Z.automatable))return"medium";return Q}function m(J){let Y=Number(J);if(!Number.isFinite(Y))return 3;return Math.min(5,Math.max(1,Math.round(Y)))}import{resolve as g}from"path";var c=/\.(?:[cm]?[jt]sx?|vue|svelte)$/,u=/(?:^|\/)(?:[\w.-]*\.config\.[cm]?[jt]s|\.?[\w-]*rc(?:\.\w+)?|tsconfig\.json|vite\.config\.[cm]?[jt]s)$/;async function N(J,Y,Q){let Z=J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),K=`${Z}(?:/[^'"\`]*)?`,H=new RegExp(`(?:^|\\s)import\\s[^'"\`]*['"\`]${K}['"\`]|from\\s*['"\`]${K}['"\`]`),$=new RegExp(`require\\s*\\(\\s*['"\`]${K}['"\`]\\s*\\)`),j=new RegExp(`import\\s*\\(\\s*['"\`]${K}['"\`]\\s*\\)`),W=new RegExp(`(?:^|[^\\w@/.-])${Z}(?![\\w/.-])`),q=[];for(let X of Y){let B=c.test(X),_=u.test(X);if(!B&&!_)continue;let U;try{let z=Bun.file(g(Q,X));if(!await z.exists())continue;U=await z.text()}catch{continue}if(!U.includes(J))continue;for(let[z,G]of U.split(`
|
|
5
5
|
`).entries()){let F=null;if(H.test(G)||j.test(G))F="import";else if($.test(G))F="require";else if(_&&W.test(G))F="config";if(F)q.push({path:X,line:z+1,text:G.trim().slice(0,200),kind:F})}}return q}function V(J){let Y=new Map;for(let Q of J)Y.set(Q.path,(Y.get(Q.path)??0)+1);return[...Y.entries()].map(([Q,Z])=>({path:Q,count:Z})).sort((Q,Z)=>Z.count-Q.count)}var d={high:"\uD83D\uDFE2 high",medium:"\uD83D\uDFE1 medium",low:"\uD83D\uDD34 low"};function L(J,Y,Q=[]){let Z=`## \uD83D\uDD27 Migration report
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{kd as a}from"./chunk-4wbbbcs2.js";import"./chunk-89s9f3mf.js";import"./chunk-ja3rvd6y.js";import"./chunk-hyp0wfta.js";import"./chunk-4hd1mryc.js";import"./chunk-nwrr6jas.js";import"./chunk-88j356ng.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 PackageScanner};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Va as t,Wa as u}from"./chunk-
|
|
2
|
+
import{Va as t,Wa as u}from"./chunk-pmszvhja.js";import{$a as z,Xa as v,Ya as w,Za as x,_a as y,ab as A,bb as B,cb as C,db as D,eb as E,fb as F,gb as G}from"./chunk-1szfwcst.js";import{hb as H,ib as I,jb as J,kb as K,lb as L}from"./chunk-88xaexj1.js";import"./chunk-y7z0br2x.js";import"./chunk-ggzjv4s0.js";import{Af as c,Bf as d,Cf as e,Df as f,yf as a,zf as b}from"./chunk-jpdd59fh.js";import{Ef as g,Ff as h,Gf as i,Hf as j,If as k,Jf as l,Kf as m,Lf as n,Mf as o,Nf as p,Of as q,Pf as r,Qf as s}from"./chunk-7rjrea9g.js";import"./chunk-emygmh7r.js";import"./chunk-kpqez1ht.js";import"./chunk-vckn5ate.js";import"./chunk-a3bnhq58.js";import"./chunk-8dj94fsy.js";import"./chunk-s3ksf6s5.js";export{i as writeFileTool,r as wrapUntrusted,F as withTouchOffer,I as verifyChanges,w as unitTestsTouch,J as stackedBranchName,y as simplifyTouch,n as shellTool,K as runStackedTouch,u as runPlan,s as runAgent,a as reviewMode,g as resolveWorkspacePath,D as renderTouchOffer,h as readFileTool,z as planTouch,d as planMode,G as parseTouchSelections,j as listDirTool,b as implementMode,E as hasTouchOffer,B as getFinishingTouch,f as getAgentMode,k as fsTools,c as fixCiMode,v as docstringsTouch,L as detectChangedFiles,t as createReadIssueTool,m as buildShellEnv,x as autofixTouch,q as Toolbelt,o as ToolPermissionError,C as TOUCH_OFFER_MARKER,H as TEST_COMMANDS,l as SHELL_ENV_ALLOWLIST,A as FINISHING_TOUCHES,p as BUILTIN_TOOLS,e as AGENT_MODES};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{A as V0,B as z0,C as EQ,a as N,b as X,c as R,r as dQ,s as $0,t as HQ,x as F,y as U,z as AQ}from"./chunk-
|
|
2
|
+
import{A as V0,B as z0,C as EQ,a as N,b as X,c as R,r as dQ,s as $0,t as HQ,x as F,y as U,z as AQ}from"./chunk-z21tw4fz.js";import"./chunk-s3ksf6s5.js";import*as O from"fs/promises";import*as XQ from"fs";import*as T from"path";import*as FQ from"child_process";import*as M0 from"crypto";import*as A0 from"readline";function S(V){if(V.inputSchema.type!=="object")throw Error(`JSON schema for tool "${V.name}" must be an object, but got ${V.inputSchema.type}`);return{type:"custom",name:V.name,input_schema:V.inputSchema,description:V.description,run:V.run,parse:(Q)=>Q,...V.close?{close:V.close}:{}}}import*as b from"fs/promises";import*as C from"path";import{randomUUID as L0}from"crypto";var e=493,T0=420;function YQ(V,Q){let $=C.relative(V,Q);return $===""||!$.startsWith(".."+C.sep)&&$!==".."&&!C.isAbsolute($)}async function OQ(V,Q){for(let $ of V)if(YQ(await r(C.resolve($)),Q))return $;return}var y0=40;function QQ(V){let Q=V?.code;return typeof Q==="string"?Q:void 0}async function r(V){let Q=[],$=V,z=0;for(;;){let K;try{K=await b.realpath($)}catch(Z){let q;try{q=(await b.lstat($)).isSymbolicLink()}catch(Y){let W=QQ(Y);if(W!=="ENOENT"&&W!=="ENOTDIR")throw Y;let J=C.dirname($);if(J===$)throw Y;Q.push(C.basename($)),$=J;continue}if(!q)throw Z;if(++z>y0)throw Object.assign(Error("too many levels of symbolic links"),{code:"ELOOP"});$=C.resolve(C.dirname($),await b.readlink($));continue}return Q.length?C.join(K,...Q.reverse()):K}}async function fQ(V,Q,$){let z=$?.allowedRoots??[],K=await r(C.resolve(V)),Z;try{Z=await r(C.resolve(K,Q))}catch(Y){throw new U(n(Y,`path ${JSON.stringify(Q)}`))}if(YQ(K,Z)||await OQ(z,Z)!==void 0)return Z;let q=z.length?"the session's working directory and its other permitted directories":"the session's working directory";throw new U(`path ${JSON.stringify(Q)} is outside ${q}`)}async function RQ(V,Q){let $=C.dirname(V),z=C.join($,`.tmp-${process.pid}-${L0()}`),K;try{K=await b.open(z,"wx",T0),await K.writeFile(Q,"utf-8"),await K.sync(),await K.close(),K=void 0,await b.rename(z,V)}catch(Z){if(K)await K.close().catch(()=>{});throw await b.unlink(z).catch(()=>{}),Z}}function n(V,Q){let $=QQ(V);switch($){case"ENOENT":return`${Q}: no such file or directory`;case"EACCES":case"EPERM":return`${Q}: permission denied`;case"ENOTDIR":return`${Q}: not a directory`;case"EISDIR":return`${Q}: is a directory`;case"ELOOP":return`${Q}: too many levels of symbolic links`;case"ENAMETOOLONG":return`${Q}: file name too long`;case"ENOSPC":return`${Q}: no space left on device`;case"EMFILE":case"ENFILE":return`${Q}: too many open files`;default:return`${Q}: ${$!==void 0?`i/o error (${$})`:"i/o error"}`}}import*as G from"fs/promises";import*as uQ from"fs";import*as w from"path";import{execFile as b0}from"child_process";import{promisify as x0}from"util";import{Readable as v0}from"stream";import{pipeline as P0}from"stream/promises";var E0=x0(b0);async function F0(V){let{client:Q,sessionId:$}=V;if(!Q)return async()=>{};let z=HQ(Q),K=V.session;if(!K){if($===void 0)return async()=>{};z.warn("AgentToolContext.sessionId is deprecated and costs an extra session fetch; fetch the session once and set `session` instead",{component:"agent-tool-context"}),K=await Q.beta.sessions.retrieve($)}let Z=w.resolve(V.workdir,"skills"),q=[];for(let Y of K.agent.skills)try{let W=await Q.beta.skills.versions.retrieve(Y.version,{skill_id:Y.skill_id}),J=w.basename(W.name.trim());if(J===""||J==="."||J==="..")J=Y.skill_id;let H=w.resolve(Z,J);if(H!==Z&&!H.startsWith(Z+w.sep)){z.warn("skill name escapes the skills dir; skipping",{component:"agent-tool-context",name:W.name});continue}let M=await Q.beta.skills.versions.download(W.id,{skill_id:Y.skill_id});await G.rm(H,{recursive:!0,force:!0}),await G.mkdir(H,{recursive:!0,mode:e}),q.push(H),await mQ(M,H),z.info("downloaded skill",{component:"agent-tool-context",skill_id:Y.skill_id,version:W.id,dest:H})}catch(W){z.warn("failed to download skill",{component:"agent-tool-context",skill_id:Y.skill_id,error:String(W)})}return async()=>{for(let Y of q)await G.rm(Y,{recursive:!0,force:!0}).catch((W)=>{z.warn("failed to clean up skill",{component:"agent-tool-context",dest:Y,error:String(W)})})}}function f0(V){for(let Q of V){let $=Q.trim();if(!$)continue;if(w.isAbsolute($)||$.split(/[\\/]/).includes(".."))throw new R(`refusing to extract unsafe archive member: ${$}`)}}var LQ="skill archive listing is inconsistent; refusing to extract",g0={unzip:new Set(["-","d","?"]),tar:new Set(["-","d","C"])};function gQ(V){let Q=V.split(`
|
|
3
3
|
`);if(Q[Q.length-1]==="")Q.pop();return Q}function u0(V,Q){return/^[\x20-\x7E]+$/.test(Q)&&!/[\\^#]/.test(Q)&&!(V==="unzip"&&Q.startsWith("-"))}function S0(V,Q,$){let z=gQ(Q),K=gQ($);if(z.length!==K.length)throw new R(LQ);let Z=[],q=[];return z.forEach((Y,W)=>{if(g0[V].has(K[W].charAt(0))){Z.push(Y);return}if(!u0(V,Y))throw new R(`refusing to extract archive: cannot safely exclude member ${JSON.stringify(Y)}`);q.push(Y)}),{plain:Z,special:q}}async function SQ(V){for(let Q of await G.readdir(V,{withFileTypes:!0}))if(Q.isDirectory())await SQ(w.join(V,Q.name));else if(!Q.isFile())throw new R(LQ)}async function jQ(V,Q){try{let{stdout:$}=await E0(V,Q);return $}catch($){if(QQ($)==="ENOENT")throw new R(`skill extraction requires the \`${V}\` command, but it was not found on PATH`);throw $}}function m0(V){let Q,$=!1;for(let z of V){let K=z.trim().split("/").filter((q)=>q!==""&&q!==".");if(K.length===0)continue;let Z=K[0];if(Q===void 0)Q=Z;else if(Z!==Q)return"";if(K.length>1)$=!0}return Q!==void 0&&$?Q:""}async function mQ(V,Q){let $=w.join(Q,`.skill-archive-${process.pid}-${Date.now()}`);if(!V.body)throw new R("skill download response had no body");await P0(v0.fromWeb(V.body),uQ.createWriteStream($));let z=w.join(w.dirname(Q),`.skill-stage-${process.pid}-${Date.now()}`),K=w.join(w.dirname(Q),`.skill-exclude-${process.pid}-${Date.now()}`);try{let Z=await _0($,4),q=Z.length>=4&&Z[0]===80&&Z[1]===75&&Z[2]===3&&Z[3]===4,Y=q?"unzip":"tar",W=await jQ(Y,q?["-Z1",$]:["-tf",$]),J=await jQ(Y,q?["-Z","--h","--t",$]:["-tvf",$]),{plain:H,special:M}=S0(Y,W,J);f0([...H,...M]);let j=m0(H);if(await G.mkdir(z,{recursive:!0,mode:e}),H.length>0)await jQ(Y,await p0(Y,$,z,M,K));await SQ(z);let v=j?w.join(z,j):z,P=await G.readdir(v).catch((E)=>{throw QQ(E)==="ENOENT"?new R(LQ):E});for(let E of P)await G.rename(w.join(v,E),w.join(Q,E))}finally{await G.rm($,{force:!0}),await G.rm(K,{force:!0}),await G.rm(z,{recursive:!0,force:!0})}}async function p0(V,Q,$,z,K){let Z=z.map((q)=>q.replace(/[*?[\\]/g,"\\$&"));if(V==="unzip")return["-oq",Q,"-d",$,...Z.length>0?["-x",...Z]:[]];if(Z.length===0)return["-xf",Q,"-C",$];return await G.writeFile(K,Z.join(`
|
|
4
4
|
`)+`
|
|
5
5
|
`,{flag:"wx",mode:384}),["-xf",Q,"-C",$,"-X",K]}async function _0(V,Q){let $=await G.open(V,"r");try{let z=Buffer.alloc(Q),{bytesRead:K}=await $.read(z,0,Q,0);return z.subarray(0,K)}finally{await $.close()}}import*as q0 from"path";import{createHash as V1}from"crypto";import*as A from"fs/promises";import*as k from"path";import{constants as i}from"fs";import{createHash as h0,randomBytes as d0}from"crypto";var cQ=448,c0=384,n0=448,TQ=i.O_NOFOLLOW??0,i0=i.O_NONBLOCK??0;class D extends Error{constructor(V,Q){super(`path ${JSON.stringify(Q)} ${V}`);this.name="FileStoreError",this.reason=V,this.relPath=Q}}D.ESCAPES_ROOT="escapes the store root";D.IS_A_SYMLINK="is a symlink";D.NOT_A_FILE="is not a regular file";D.NOT_A_DIRECTORY="is not a directory";D.NOT_UTF8="is not valid utf-8";D.MOVE_DESTINATION_EXISTS="already exists";function yQ(V){return V.startsWith("/")&&!V.split("/").includes("..")}class l{constructor(V,Q,$=!1){this.hashes=new Map,this.rootPath=V,this.removedOnDispose=Q,this.decoder=$?new TextDecoder("utf-8",{fatal:!0}):void 0}static async open(V,Q){if(!l0())throw Error("FileStore requires O_NOFOLLOW support on this platform");let $=!1;try{await A.lstat(V)}catch(z){if(z.code!=="ENOENT")throw z;$=!0}return new l(k.resolve(V),$,Q?.utf8??!1)}async createRoot(){await a0(this.rootPath)}root(){return{path:this.rootPath,removedOnDispose:this.removedOnDispose}}async dispose(){if(!this.removedOnDispose)return;await A.rm(this.rootPath,{recursive:!0,force:!0})}async put(V,Q,$){let z=V.replace(/\\/g,"/");if(z.endsWith("/")||z.endsWith("/.")||z===""||z===".")throw new D(D.NOT_A_FILE,V);let K=this.resolveUnderRoot(V),Z=typeof Q==="string"?dQ(Q):Q;this.requireUtf8(V,Z),await pQ(this.rootPath,k.dirname(K)),await o0(K,Z,$?.executable??!1)}async get(V){let Q=this.resolveUnderRoot(V),$;try{$=await nQ(V,Q)}catch(K){if(K.code==="ENOENT")return null;throw K}let z;try{let K=await $.readFile();z=new Uint8Array(K.buffer,K.byteOffset,K.byteLength)}finally{await $.close()}return this.requireUtf8(V,z),z}async ls(V="/"){let Q=this.resolveUnderRoot(V);return new Set((await _Q(this.rootPath,V,Q)).map(([$])=>$))}async findSymlinks(V="/"){let Q=this.resolveUnderRoot(V);return t0(this.rootPath,V,Q)}async hashtree(V="/"){let Q=this.resolveUnderRoot(V),$=JQ.nowNs(),z=Object.create(null);for(let[K,Z]of await _Q(this.rootPath,V,Q)){let q=await this.hashViaCache(K,Z,$);if(q!==null)z[K]=q}return z}async hashFile(V){let Q=this.resolveUnderRoot(V),$;try{$=await A.lstat(Q,{bigint:!0})}catch(K){if(K.code==="ENOENT")return null;throw K}if($.isSymbolicLink())throw new D(D.IS_A_SYMLINK,V);if(!$.isFile())throw new D(D.NOT_A_FILE,V);let z=k.relative(this.rootPath,Q).split(k.sep).join("/");return this.hashViaCache(z,Q,JQ.nowNs())}async move(V,Q){let $=this.resolveUnderRoot(V),z=this.resolveUnderRoot(Q);if($===this.rootPath||z===this.rootPath)return;if(await A.stat(z).then(()=>!0,()=>!1))throw new D(D.MOVE_DESTINATION_EXISTS,Q);await pQ(this.rootPath,k.dirname(z)),await A.rename($,z)}async remove(V){let Q=this.resolveUnderRoot(V);if(Q===this.rootPath)return;let $;try{$=await A.lstat(Q,{bigint:!0})}catch(z){if(z.code==="ENOENT")return;throw z}if($.isDirectory())await A.rm(Q,{recursive:!0,force:!0});else try{await A.unlink(Q)}catch(z){if(z.code!=="ENOENT")throw z}}resolveUnderRoot(V){let Q=V.replace(/\\/g,"/").replace(/^\/+/,""),$=Q.split("/").filter((z)=>z!==""&&z!==".");if(k.posix.isAbsolute(Q)||$.includes(".."))throw new D(D.ESCAPES_ROOT,V);return $.length===0?this.rootPath:k.join(this.rootPath,...$)}requireUtf8(V,Q){if(!this.decoder)return;try{this.decoder.decode(Q)}catch{throw new D(D.NOT_UTF8,V)}}async hashViaCache(V,Q,$){let z;try{z=await A.lstat(Q,{bigint:!0})}catch(q){if(q.code==="ENOENT")return null;throw q}if(!z.isFile())return null;let K=this.hashes.get(V),Z;if(K!==void 0&&e0(K,z))Z=K.sha;else try{Z=await JQ.hashFile(Q)}catch(q){let Y=q.code;if(Y==="ENOENT"||q instanceof D)return null;if(Y==="ELOOP"||Y==="EMLINK")return null;throw q}if(Q1(z,$))this.hashes.set(V,{mtimeNs:z.mtimeNs,ctimeNs:z.ctimeNs,size:z.size,sha:Z});return Z}}l.isPathLegal=yQ;function l0(){return TQ!==0}async function a0(V){let Q=[],$=V;for(;;){try{await A.stat($);break}catch(K){let Z=K.code;if(Z!=="ENOENT"&&Z!=="ENOTDIR"&&Z!=="ELOOP")throw K}Q.push($);let z=k.dirname($);if(z===$)break;$=z}for(let z of Q.reverse())try{await A.mkdir(z,{mode:cQ})}catch(K){if(K.code!=="EEXIST")throw K}}async function pQ(V,Q){let $=k.relative(V,Q);if($==="")return;let z=V;for(let K of $.split(k.sep)){z=k.join(z,K);try{await A.mkdir(z,{mode:cQ})}catch(Z){if(Z.code!=="EEXIST")throw Z}}}async function o0(V,Q,$){let z=$?n0:c0,K=k.join(k.dirname(V),`.fs-${d0(8).toString("hex")}.tmp`),Z;try{Z=await A.open(K,i.O_WRONLY|i.O_CREAT|i.O_EXCL|TQ,z),await Z.writeFile(Q),await Z.close(),Z=void 0,await A.rename(K,V)}catch(q){if(Z)await Z.close().catch(()=>{});throw await A.unlink(K).catch(()=>{}),q}}async function nQ(V,Q){let $;try{$=await A.open(Q,i.O_RDONLY|TQ|i0)}catch(z){let K=z.code;if(K==="ELOOP"||K==="EMLINK")throw new D(D.IS_A_SYMLINK,V);throw z}try{if(!(await $.stat()).isFile())throw new D(D.NOT_A_FILE,V)}catch(z){throw await $.close().catch(()=>{}),z}return $}async function s0(V){let Q=h0("sha256"),$=await nQ(k.basename(V),V),z=new Uint8Array(1048576);try{for(;;){let{bytesRead:K}=await $.read(z,0,z.length);if(K===0)break;Q.update(z.subarray(0,K))}}finally{await $.close()}return Q.digest("hex")}async function _Q(V,Q,$){if(!await r0(Q,$))return[];let z=[];return await iQ($,(K,Z)=>{if(Z.isFile())z.push([k.relative(V,K).split(k.sep).join("/"),K])}),z.sort(),z}async function t0(V,Q,$){let z=(q)=>k.relative(V,q).split(k.sep).join("/"),K;try{K=await A.lstat($,{bigint:!0})}catch(q){let Y=q.code;if(Y==="ENOENT"||Y==="ENOTDIR")return new Set;throw q}if(K.isSymbolicLink())return new Set([z($)]);if(!K.isDirectory())throw new D(D.NOT_A_DIRECTORY,Q);let Z=new Set;return await iQ($,(q,Y)=>{if(Y.isSymbolicLink())Z.add(z(q))}),Z}async function r0(V,Q){let $;try{$=await A.lstat(Q,{bigint:!0})}catch(z){let K=z.code;if(K==="ENOENT"||K==="ENOTDIR")return!1;throw z}if(!$.isDirectory())throw new D(D.NOT_A_DIRECTORY,V);return!0}async function iQ(V,Q){let $=[V];while($.length){let z=$.pop(),K;try{K=await A.readdir(z,{withFileTypes:!0})}catch(Z){if(Z.code==="ENOENT")continue;throw Z}for(let Z of K){let q=k.join(z,Z.name);if(Q(q,Z),Z.isDirectory()&&!Z.isSymbolicLink())$.push(q)}}}function e0(V,Q){return Q.mtimeNs===V.mtimeNs&&Q.ctimeNs===V.ctimeNs&&Q.size===V.size}function Q1(V,Q){return(V.mtimeNs>V.ctimeNs?V.mtimeNs:V.ctimeNs)<Q-JQ.timestampTrustMarginNs}var $1=2000000000n,JQ={hashFile:s0,timestampTrustMarginNs:$1,nowNs:()=>BigInt(Date.now())*1000000n},lQ=l,hQ=Symbol.asyncDispose;if(hQ)Object.defineProperty(l.prototype,hQ,{value:l.prototype.dispose,configurable:!0,writable:!0});var I,g,BQ,$Q,MQ,B,a,DQ,f,K0,NQ,Z0,X0,bQ,vQ,aQ,oQ,xQ,sQ,tQ,WQ,UQ,rQ,eQ,z1=30000,o=".anthropic-memory-store",Y0=1;function Q0(V){return V1("sha256").update(`version ${Y0}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{wh as W}from"./chunk-6k6dgwmy.js";import{
|
|
2
|
+
import{wh as W}from"./chunk-6k6dgwmy.js";import{Ih as y}from"./chunk-a3bnhq58.js";import{Oh as J}from"./chunk-8dj94fsy.js";import{dl as F}from"./chunk-s3ksf6s5.js";import S from"process";function G(E){let q=E.replace(/\\/g,"/");return q.includes(".github/workflows/")&&(q.endsWith(".yml")||q.endsWith(".yaml"))}async function L(E,q){try{if(!G(E))return null;let I=[],j=q.split(`
|
|
3
3
|
`);for(let K=0;K<j.length;K++){let Q=j[K].trim().match(/^-?\s*uses:\s*(.+)/);if(Q){let $=Q[1].trim().replace(/['"`]/g,"");if($.startsWith("./")||$.startsWith("docker://"))continue;let X=$.split("@");if(X.length===2){let[_,Y]=X;if(!_||!_.trim())continue;let[z,...k]=Y.split("#"),M=z.trim(),V={name:_.trim(),currentVersion:M,type:"github-actions",file:E};if(v(M)){let x=k.join("#").trim().split(/\s+/)[0];V.metadata=x?{pinnedSha:M,pinnedVersion:x}:{pinnedSha:M}}if(!I.find((x)=>x.name===V.name&&x.currentVersion===V.currentVersion))I.push(V)}}}return{path:E,type:"github-actions",content:q,dependencies:I}}catch(I){return J().warn(`Failed to parse GitHub Actions file ${E}:`,I),null}}function v(E){return/^[0-9a-f]{40}$/i.test(E)}function R(E,q){return E.replace(/^v/i,"")===q.replace(/^v/i,"")}async function U(E,q,I){try{if(!G(E))return q;let j=q;for(let K of I){let O=K.name.replace(/\s*\(.*\)$/,""),Z=O.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(K.resolved?.sha){let $=new RegExp(`((?:^\\s*-\\s*)?uses:\\s*["']?)(${Z})@(${K.currentVersion})(["']?)([ \\t]*#[^\\n]*)?`,"gm");j=j.replace($,`$1$2@${K.resolved.sha}$4 # ${K.newVersion}`);continue}let Q=new RegExp(`((?:^\\s*-\\s*)?uses:\\s*["']?)(${O.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})@(${K.currentVersion.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})(["']?)`,"gm");j=j.replace(Q,`$1$2@${K.newVersion}$4`)}return j}catch(j){return J().warn(`Failed to update GitHub Actions file ${E}:`,j),q}}async function D(E){let q=[],I=new Map;for(let j of E)if(G(j.file)){if(!I.has(j.file))I.set(j.file,[]);I.get(j.file).push(j)}for(let[j,K]of I)try{let O=await import("fs");if(O.existsSync(j)){let Z=O.readFileSync(j,"utf-8"),Q=await U(j,Z,K);q.push({path:j,content:Q,type:"update"})}}catch(O){J().warn(`Failed to generate updates for GitHub Actions file ${j}:`,O)}return q}async function b(E,q){let[I,j]=E.split("/");if(!I||!j)return null;let K={Accept:"application/vnd.github.v3+json","User-Agent":"buddy"},O=S.env.BUDDY_TOKEN||S.env.GITHUB_TOKEN||S.env.GH_TOKEN;if(O)K.Authorization=`Bearer ${O}`;try{let Z=await y(`${W()}/repos/${I}/${j}/commits/${encodeURIComponent(q)}`,{headers:K});if(!Z.ok)return null;let Q=await Z.json();return Q.sha&&v(Q.sha)?Q.sha:null}catch{return null}}async function P(E){try{if(!E.includes("/"))return J().info(`\u26A0\uFE0F Invalid action name format: ${E}`),null;let[q,I]=E.split("/");J().info(`\uD83D\uDD0D Fetching latest version for ${q}/${I}`);let j={Accept:"application/vnd.github.v3+json","User-Agent":"buddy"},K=S.env.BUDDY_TOKEN||S.env.GITHUB_TOKEN||S.env.GH_TOKEN;if(K)j.Authorization=`Bearer ${K}`;let O=W();J().info(`\uD83D\uDCE1 Trying latest release for ${q}/${I}`);let Z=await y(`${O}/repos/${q}/${I}/releases/latest`,{headers:j});if(Z.ok){let X=await Z.json();if(X.tag_name)return J().info(`\u2705 Found latest release: ${X.tag_name}`),X.tag_name}else J().info(`\u26A0\uFE0F Latest release not found: ${Z.status} ${Z.statusText}`);J().info(`\uD83D\uDCE1 Trying all releases for ${q}/${I}`);let Q=await y(`${O}/repos/${q}/${I}/releases?per_page=10`,{headers:j});if(Q.ok){let X=await Q.json();if(!Array.isArray(X))J().info("\u26A0\uFE0F Unexpected releases response format (expected array)");else{J().info(`\uD83D\uDCCB Found ${X.length} releases`);let _=X.filter((Y)=>Y.tag_name&&!Y.tag_name.includes("-")).sort((Y,z)=>{let k=Y.published_at?new Date(Y.published_at).getTime():0;return(z.published_at?new Date(z.published_at).getTime():0)-k});if(_.length>0)return J().info(`\u2705 Found latest stable release: ${_[0].tag_name}`),_[0].tag_name||null}}else J().info(`\u26A0\uFE0F Releases not found: ${Q.status} ${Q.statusText}`);J().info(`\uD83D\uDCE1 Trying tags for ${q}/${I}`);let $=await y(`${O}/repos/${q}/${I}/tags?per_page=10`,{headers:j});if($.ok){let X=await $.json();if(!Array.isArray(X))J().info("\u26A0\uFE0F Unexpected tags response format (expected array)");else{J().info(`\uD83D\uDCCB Found ${X.length} tags`);let _=X.filter((Y)=>Y.name&&!Y.name.includes("-")).map((Y)=>Y.name).sort((Y,z)=>{let k=Y.replace(/^v/,""),M=z.replace(/^v/,""),V=k.split(".").map(Number),B=M.split(".").map(Number);for(let x=0;x<Math.max(V.length,B.length);x++){let H=V[x]||0,T=B[x]||0;if(H!==T)return T-H}return 0});if(_.length>0)return J().info(`\u2705 Found latest stable tag: ${_[0]}`),_[0]}}else J().info(`\u26A0\uFE0F Tags not found: ${$.status} ${$.statusText}`);return J().info(`\u274C No version found for ${E}`),null}catch(q){return J().warn(`Failed to fetch latest version for ${E}:`,q),null}}
|
|
4
4
|
export{G as we,L as xe,v as ye,R as ze,U as Ae,D as Be,b as Ce,P as De};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ea as a,Fa as b,Ga as c,Ha as d,Ia as e,Ja as f,Ka as g}from"./chunk-mcn3508w.js";import"./chunk-mg3em5qj.js";import"./chunk-7crh00m7.js";import"./chunk-1eh199jk.js";import"./chunk-jpdd59fh.js";import"./chunk-7rjrea9g.js";import"./chunk-kpqez1ht.js";import"./chunk-vckn5ate.js";import"./chunk-a3bnhq58.js";import"./chunk-8dj94fsy.js";import"./chunk-s3ksf6s5.js";export{g as runFixCi,e as latestFailurePerWorkflow,d as failsOnBaseBranch,b as extractErrorLines,c as describeFailure,a as classifyFailure,f as attemptFix};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ld as J}from"./chunk-89s9f3mf.js";import{md as Y}from"./chunk-ja3rvd6y.js";import{te as _}from"./chunk-
|
|
2
|
+
import{ld as J}from"./chunk-89s9f3mf.js";import{md as Y}from"./chunk-ja3rvd6y.js";import{te as _}from"./chunk-hyp0wfta.js";import{we as x,xe as w}from"./chunk-4hd1mryc.js";import{Pe as z,Qe as M}from"./chunk-nwrr6jas.js";import{Xe as N}from"./chunk-88j356ng.js";import{yg as L,zg as S}from"./chunk-1m5wprvm.js";import{Oh as G}from"./chunk-8dj94fsy.js";import{dl as j}from"./chunk-s3ksf6s5.js";var{Glob:D}=globalThis.Bun;import{readdir as A,readFile as U,stat as Z}from"fs/promises";import{join as R,relative as E,sep as H}from"path";async function I(q,K){try{let O=JSON.parse(K),V=[];if(O.packages){for(let Q of Object.values(O.packages))if(Q.name&&Q.version)V.push({name:Q.name,currentVersion:Q.version,type:"dependencies",file:q})}return{path:q,type:"pantry.lock",content:K,dependencies:V}}catch(O){return G().warn(`Failed to parse pantry.lock file ${q}:`,O),null}}class m{projectPath;logger;ignoreGlobs=[];constructor(q,K,O){this.projectPath=q;this.logger=K;if(O&&O.length>0)this.ignoreGlobs=O.map((V)=>new D(V)),this.logger.info(`Initialized ${this.ignoreGlobs.length} ignore patterns: ${O.join(", ")}`)}async scanProject(){this.logger.info("Scanning project for package files...");let q=Date.now(),K=[];try{let O=await this.findFiles("package.json");for(let X of O){if(this.shouldIgnorePath(X))continue;let $=await this.parsePackageJsonFile(X);if($)K.push($)}let V=await this.findDependencyFiles();for(let X of V){if(this.shouldIgnorePath(X))continue;let $=await this.parseDependencyFile(X);if($)K.push($)}let Q=await this.findLockFiles();for(let X of Q){if(this.shouldIgnorePath(X))continue;let $=await this.parseLockFile(X);if($)K.push($)}let W=await this.findComposerFiles();for(let X of W){if(this.shouldIgnorePath(X))continue;let $=await this.parseComposerFile(X);if($)K.push($)}let B=await this.findGitHubActionsFiles();for(let X of B){if(this.shouldIgnorePath(X))continue;let $=await this.parseGitHubActionsFile(X);if($)K.push($)}let C=await this.findDockerfiles();this.logger.info(`\uD83D\uDD0D Found ${C.length} Dockerfile(s): ${C.join(", ")}`);for(let X of C){if(this.shouldIgnorePath(X))continue;let $=await this.parseDockerfile(X);if($)K.push($),this.logger.info(`\uD83D\uDCE6 Parsed Dockerfile: ${X} with ${$.dependencies.length} dependencies`)}let T=await this.findZigManifests();this.logger.info(`\uD83D\uDD0D Found ${T.length} Zig manifest(s): ${T.join(", ")}`);for(let X of T){if(this.shouldIgnorePath(X))continue;let $=await this.parseZigManifestFile(X);if($)K.push($),this.logger.info(`\uD83D\uDCE6 Parsed Zig manifest: ${X} with ${$.dependencies.length} dependencies`)}let b=await this.findFiles("pantry.lock");for(let X of b){if(this.shouldIgnorePath(X))continue;let $=await this.parsePantryLockFile(X);if($)K.push($),this.logger.info(`\uD83D\uDCE6 Parsed pantry.lock: ${X} with ${$.dependencies.length} dependencies`)}let v=Date.now()-q;return this.logger.success(`Found ${K.length} package files in ${v}ms`),K}catch(O){throw this.logger.error("Failed to scan project:",O),new Y(`Failed to scan project: ${O instanceof Error?O.message:"Unknown error"}`)}}async parsePackageJsonFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8"),V=JSON.parse(O),Q=[];return this.extractDependencies(V.dependencies,"dependencies",q,Q),this.extractDependencies(V.devDependencies,"devDependencies",q,Q),this.extractDependencies(V.peerDependencies,"peerDependencies",q,Q),this.extractDependencies(V.optionalDependencies,"optionalDependencies",q,Q),Q.push(...N(V.engines,q)),{path:q,type:"package.json",content:O,dependencies:Q}}catch(K){return this.logger.warn(`Failed to parse package.json file ${q}:`,K),null}}async parseLockFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8"),V=q.split("/").pop()||"",Q;if(V==="bun.lockb")Q="bun.lockb";else if(V==="package-lock.json")Q="package-lock.json";else if(V==="yarn.lock")Q="yarn.lock";else if(V==="pnpm-lock.yaml")Q="pnpm-lock.yaml";else return null;let W=await this.extractLockFileDependencies(O,Q,q);return{path:q,type:Q,content:O,dependencies:W}}catch(K){return this.logger.warn(`Failed to parse lock file ${q}:`,K),null}}async parseDependencyFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await S(q,O)}catch(K){return this.logger.warn(`Failed to parse dependency file ${q}:`,K),null}}async findDependencyFiles(){let q=[],K=["deps.yaml","deps.yml","dependencies.yaml","dependencies.yml","pkgx.yaml","pkgx.yml",".deps.yaml",".deps.yml"];for(let Q of K){let W=await this.findFiles(Q);q.push(...W)}let O=await this.findFilesByPattern("*.yaml"),V=await this.findFilesByPattern("*.yml");for(let Q of[...O,...V])if(L(Q)&&!q.includes(Q))q.push(Q);return q}async findGitHubActionsFiles(){let q=[];try{let O=R(this.projectPath,".github","workflows");if((await Z(O).catch(()=>null))?.isDirectory()){let Q=await this.findFilesByPatternInDir("*.yaml",O),W=await this.findFilesByPatternInDir("*.yml",O);for(let B of[...Q,...W])if(x(B))q.push(B)}}catch{}return q}async findDockerfiles(){return this.findFilesMatching(z)}async findFilesMatching(q,K=this.projectPath){let O=[];try{let V=await A(K);for(let Q of V){let W=R(K,Q);try{let B=await Z(W);if(B.isFile()){if(q(Q))O.push(E(this.projectPath,W).split(H).join("/"))}else if(B.isDirectory()&&!J(Q))O.push(...await this.findFilesMatching(q,W))}catch{continue}}}catch{}return O}async parseGitHubActionsFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await w(q,O)}catch(K){return this.logger.warn(`Failed to parse GitHub Actions file ${q}:`,K),null}}async parseDockerfile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await M(q,O)}catch(K){return this.logger.warn(`Failed to parse Dockerfile ${q}:`,K),null}}async findZigManifests(){let q=[];try{let K=await this.findFiles("build.zig.zon");q.push(...K)}catch{}return q}async parseZigManifestFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await _(q,O)}catch(K){return this.logger.warn(`Failed to parse Zig manifest ${q}:`,K),null}}async findComposerFiles(){let q=[];try{let K=await this.findFiles("composer.json");q.push(...K);let O=await this.findFiles("composer.lock");q.push(...O)}catch{}return q}async parseComposerFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8"),{parseComposerFile:V}=await import("./chunk-kpdz73mc.js");return await V(q,O)}catch(K){return this.logger.warn(`Failed to parse Composer file ${q}:`,K),null}}async parsePantryLockFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await I(q,O)}catch(K){return this.logger.warn(`Failed to parse pantry.lock file ${q}:`,K),null}}extractDependencies(q,K,O,V){if(!q)return;for(let[Q,W]of Object.entries(q))V.push({name:Q,currentVersion:W,type:K,file:this.getRelativePath(O)})}async extractLockFileDependencies(q,K,O){let V=[];if(K==="package-lock.json")try{let Q=JSON.parse(q);if(Q.packages){for(let[W,B]of Object.entries(Q.packages))if(W&&W!==""&&B&&typeof B==="object"){let C=B;if(C.version){let T=W.startsWith("node_modules/")?W.replace("node_modules/",""):W;V.push({name:T,currentVersion:C.version,type:C.dev?"devDependencies":"dependencies",file:this.getRelativePath(O)})}}}}catch(Q){this.logger.warn("Failed to parse package-lock.json:",Q)}return V}async findFiles(q,K=this.projectPath){let O=[];try{let V=await A(K);for(let Q of V){let W=R(K,Q);try{let B=await Z(W);if(B.isDirectory()){if(!J(Q)){let C=await this.findFiles(q,W);O.push(...C)}}else if(B.isFile()&&Q===q){let C=E(this.projectPath,W);O.push(C.split(H).join("/"))}}catch{continue}}}catch{}return O}async findLockFiles(){let q=["bun.lock","bun.lockb","package-lock.json","yarn.lock","pnpm-lock.yaml"],K=[];for(let O of q){let V=await this.findFiles(O);K.push(...V)}return K}async findFilesByPattern(q){let K=[],O=q.replace("*.","");try{let V=await A(this.projectPath);for(let Q of V){let W=R(this.projectPath,Q),B=await Z(W);if(B.isFile()&&Q.endsWith(`.${O}`)){let C=E(this.projectPath,W);K.push(C.split(H).join("/"))}else if(B.isDirectory()&&!J(Q)){let C=await this.findFilesByPatternInDir(q,W);K.push(...C)}}}catch{}return K}async findFilesByPatternInDir(q,K){let O=[],V=q.replace("*.","");try{let Q=await A(K);for(let W of Q){let B=R(K,W),C=await Z(B);if(C.isFile()&&W.endsWith(`.${V}`)){let T=E(this.projectPath,B);O.push(T.split(H).join("/"))}else if(C.isDirectory()&&!J(W)){let T=await this.findFilesByPatternInDir(q,B);O.push(...T)}}}catch{}return O}shouldIgnorePath(q){if(this.ignoreGlobs.length===0)return!1;let K=q;if(q.startsWith("/")||q.includes(":"))K=this.getRelativePath(q);for(let O of this.ignoreGlobs)if(O.match(K))return this.logger.debug(`Ignoring path: ${K} (matched pattern)`),!0;return!1}getRelativePath(q){return E(this.projectPath,q).split(H).join("/")}async getDependencyCount(){return(await this.scanProject()).reduce((K,O)=>K+O.dependencies.length,0)}async getUniqueDependencies(){return(await this.scanProject()).flatMap((V)=>V.dependencies).filter((V,Q,W)=>Q===W.findIndex((B)=>B.name===V.name))}}
|
|
3
3
|
export{m as kd};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Zc as oX}from"./chunk-eftyxrxw.js";import{cd as sX}from"./chunk-19n3wnxq.js";import{Nh as iX}from"./chunk-f0z6kyqt.js";import{cl as n}from"./chunk-6sm15trq.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-er0ntw4q.js";import{cd as sX}from"./chunk-z24p5t3p.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(_+=`
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{of as a,pf as b,qf as c}from"./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-a3bnhq58.js";import"./chunk-8dj94fsy.js";import"./chunk-0apd8zqn.js";import"./chunk-s3ksf6s5.js";export{a as matchesGlobs,c as appendUpgradeReport,b as analyzeGroupMajors};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Aa as d,Ba as e,Ca as f,xa as a,ya as b,za as c}from"./chunk-
|
|
2
|
+
import{Aa as d,Ba as e,Ca as f,xa as a,ya as b,za as c}from"./chunk-ysgex7h7.js";import"./chunk-a3bnhq58.js";import"./chunk-8dj94fsy.js";import"./chunk-s3ksf6s5.js";export{b as productFor,f as describeEol,c as cycleFor,d as checkEol,e as EOL_WARNING_DAYS,a as EOL_PRODUCTS};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Cg as mc,Dg as nc,Eg as oc,Fg as pc,Gg as qc,Hg as rc,Ig as sc,Jg as tc,Kg as uc,Lg as vc,Mg as wc,Ng as xc,Og as yc,Pg as zc,Qg as Ac,Rg as Bc,Sg as Cc,Tg as Dc,Ug as Ec,Vg as Fc}from"./chunk-ktmgq0ja.js";import{$h as
|
|
2
|
+
import{Cg as mc,Dg as nc,Eg as oc,Fg as pc,Gg as qc,Hg as rc,Ig as sc,Jg as tc,Kg as uc,Lg as vc,Mg as wc,Ng as xc,Og as yc,Pg as zc,Qg as Ac,Rg as Bc,Sg as Cc,Tg as Dc,Ug as Ec,Vg as Fc}from"./chunk-ktmgq0ja.js";import{$h as l,$i as ka,$j as kb,$k as kc,Ai as L,Aj as La,Ak as Lb,Bi as M,Bj as Ma,Bk as Mb,Ci as N,Cj as Na,Ck as Nb,Di as O,Dj as Oa,Dk as Ob,Ei as P,Ej as Pa,Ek as Pb,Fi as Q,Fj as Qa,Fk as Qb,Gi as R,Gj as Ra,Gk as Rb,Hi as S,Hj as Sa,Hk as Sb,Ii as T,Ij as Ta,Ik as Tb,Ji as U,Jj as Ua,Jk as Ub,Ki as V,Kj as Va,Kk as Vb,Li as W,Lj as Wa,Lk as Wb,Mi as X,Mj as Xa,Mk as Xb,Ni as Y,Nj as Ya,Nk as Yb,Oi as Z,Oj as Za,Ok as Zb,Ph as a,Pi as _,Pj as _a,Pk as _b,Qh as b,Qi as $,Qj as $a,Qk as $b,Rh as c,Ri as aa,Rj as ab,Rk as ac,Si as ba,Sj as bb,Sk as bc,Th as d,Ti as ca,Tj as cb,Tk as cc,Uh as e,Ui as da,Uj as db,Uk as dc,Vh as f,Vi as ea,Vj as eb,Vk as ec,Wh as g,Wi as fa,Wj as fb,Wk as fc,Xh as h,Xi as ga,Xj as gb,Xk as gc,Yh as i,Yi as ha,Yj as hb,Yk as hc,Zh as j,Zi as ia,Zj as ib,Zk as ic,_h as k,_i as ja,_j as jb,_k as jc,ai as m,aj as la,ak as lb,al as lc,bi as n,bj as ma,bk as mb,ci as o,cj as na,ck as nb,di as p,dj as oa,dk as ob,ei as q,ej as pa,ek as pb,fi as r,fj as qa,fk as qb,gi as s,gj as ra,gk as rb,hi as t,hj as sa,hk as sb,ii as u,ij as ta,ik as tb,ji as v,jj as ua,jk as ub,ki as w,kj as va,kk as vb,li as x,lj as wa,lk as wb,mi as y,mj as xa,mk as xb,ni as z,nj as ya,nk as yb,oi as A,oj as za,ok as zb,pi as B,pj as Aa,pk as Ab,qi as C,qj as Ba,qk as Bb,ri as D,rj as Ca,rk as Cb,sj as Da,sk as Db,ti as E,tj as Ea,tk as Eb,ui as F,uj as Fa,uk as Fb,vi as G,vj as Ga,vk as Gb,wi as H,wj as Ha,wk as Hb,xi as I,xj as Ia,xk as Ib,yi as J,yj as Ja,yk as Jb,zi as K,zj as Ka,zk as Kb}from"./chunk-0apd8zqn.js";import"./chunk-s3ksf6s5.js";export{Ta as ziglangOfficialDownload,ab as zigRegistryMirror,bb as zigPurgedDevBuildHint,eb as zigOriginVersions,Wb as writeOciLayout,Xb as writeDockerArchive,Cc as withTempDirSync,Bc as withTempDir,yc as withRedis,uc as withPostgres,qc as withMysql,ic as waitForAppStoreBuilds,ac as verifyBlob,n as validatePackageSpec,Aa as validatePackage,sa as v,xc as useRedis,tc as usePostgres,pc as useMysql,zb as updatePackageVersionMap,ca as updateApp,sb as uninstallShellInit,ub as toTypeName,tb as toSafeVarName,vb as toPackageVarName,Fc as testingRuntime,mb as supportedPackages,wc as stopRedis,sc as stopPostgres,oc as stopMysql,vc as startRedis,rc as startPostgres,S as startPeriodicCleanup,nc as startMysql,Ua as sqliteOfficialDownloadUrl,va as showPackageInfo,x as shouldProceedWithGitHubRequest,R as setupCleanupHandlers,Ub as serializeConfig,wa as searchPackagesCommand,j as searchPackages,V as scanPantryPackages,$ as scanInstalledApps,N as saveToCacheAndOutput,w as saveRateLimitInfo,K as savePackageAsTypeScript,z as saveGitHubPackageCache,db as satisfiesInstallerConstraint,ib as retryNetworkOperation,q as resolveVersionFromMetadata,Ka as resolveVersionConstraint,h as resolveVersion,Ma as resolveTransitiveDependencies,ka as resolvePackageName,G as resolvePackageDomain,Cb as resolvePackageDependencies,Xa as resolveLatestVersion,gb as resolveInstallerConstraintFromCandidates,Oa as resolveDependencyFile,Bb as resolveDependenciesFromYaml,Ab as resolveDependencies,Mb as resolveBuildStages,qb as renderShellSnippet,dc as renderDockerfile,Ac as removeTempDir,Za as registryVersionsForPlatform,Ya as registryPlatformKey,_a as registryDownloadSource,Eb as readProjectDependencies,W as readPantryPackageInfo,pb as rcFileFor,$b as pushImage,_b as pullImage,jc as provisionMacApp,ta as pkg,o as parseVersion,la as parsePackageSpec,cb as parseInstallerConstraint,Zb as parseImageRef,Nb as parseFreezer,Lb as parseExecForm,Kb as parseDockerfile,Ia as parseDepsYamlConfig,Ha as parseDependencyFile,b as pantry,c as packages,Qa as normalizeInstallerVersion,B as logPkgxProjects,Pb as loadFreezer,xa as listPopularPackages,za as listAliases,ya as listActivePackages,g as isVersionAvailable,fa as isValidPackageName,ga as isSupportedPlatform,ha as isSupportedArchitecture,kb as isSupported,hb as isRetryableNetworkError,ra as isPackageInCategory,ea as isPackageDomain,da as isPackageAlias,_ as isNewerVersion,I as isKnownAlias,lb as isInstallable,$a as installedRegistryBinaries,rb as installShellInit,Wa as installPackages,Va as installPackage,F as guessOriginalDomain,Ra as globalBinDir,Ca as getVersionInfo,M as getValidCachedPackage,Ga as getSystemInfo,nb as getPrimaryBinary,l as getPopularPackages,f as getPhpVersionsForWorkflow,k as getPackagesByPattern,qa as getPackagesByCategory,i as getPackageInfo,H as getPackageAliases,d as getLatestVersion,Db as getInstallCommand,y as getGitHubPackageCache,J as getCanonicalDomain,Ja as getAvailableVersionsForPackage,e as getAvailableVersions,ja as getAllPackageDomains,ia as getAllPackageAliases,m as getActivePackages,kc as generateMacCertificateRequests,wb as generateIndex,yb as generateDocs,ec as generateContainerFiles,xb as generateAliases,Ea as formatSearchResults,ma as formatPackageSpec,Da as formatPackageInfo,C as formatObjectWithoutQuotedKeys,Fa as formatInstallPlan,Pa as findDependencyFiles,P as fetchPkgxProjects,X as fetchPantryPackageWithMetadata,Q as fetchPantryPackage,A as fetchPackageListFromGitHub,aa as fetchDesktopCatalogue,U as fetchAndSavePackage,T as fetchAndSaveAllPackages,bc as extractLayer,lc as exportAppleCertificateP12,hc as ensureAppStoreVersions,jb as downloadFileReliably,Sb as digestHex,Rb as digest,ob as detectShell,Sa as detectPlatform,ua as dependencies,Ib as definePantryConfig,Gb as definePackageList,Fb as defineDependencies,Na as deduplicateDependencies,Dc as createTestFile,Ec as createTestDir,zc as createTempDir,Ob as createMatcher,na as createInstallationContext,Ba as createInstallPlan,D as convertDomainToVarName,E as convertDomainToFileName,p as compareVersionsDesc,La as compareVersions,fb as compareInstallerVersionsDesc,Jb as collectBuildContext,O as cleanupBrowserResources,L as cleanStaleOutputFiles,ba as checkAppUpdates,Vb as buildManifest,Tb as buildLayerFromRootfs,cc as buildImage,fc as appStoreConnectToken,a as aliases,oa as VERSION_SPECS,Y as SYSTEM_APPS,mc as PantryService,Yb as PANTRY_REGISTRY,pa as PACKAGE_CATEGORIES,u as PACKAGE_ALIASES,Qb as MEDIA_TYPE,Z as MAS_APPS,Hb as DISTRIBUTION_CONFIG,t as DEFAULT_TIMEOUT_MS,s as DEFAULT_CACHE_EXPIRATION_MINUTES,r as DEFAULT_CACHE_DIR,gc as AppStoreConnectClient,v as ALL_KNOWN_PACKAGES};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Dh as V}from"./chunk-pxdrwhxx.js";import{Ih as M}from"./chunk-a3bnhq58.js";import{Lh as K,Oh as Q}from"./chunk-8dj94fsy.js";class X{token;apiUrl;logger;slug;constructor(j,z,A,C,F){this.token=j;this.apiUrl=(C??"https://api.bitbucket.org/2.0").replace(/\/+$/,""),this.logger=F??Q(),this.slug=`${encodeURIComponent(z)}/${encodeURIComponent(A)}`}capabilities(){return{pinIssues:!1,checkRuns:!0,inlineReviewComments:!0,reviewSuggestions:!1,nativeAutoMerge:!1,commentReactions:!1,ciLogs:!1,ciRuns:!1,reviewThreads:!1,teamReviewers:!1,draftPullRequests:!1,permissionLookup:!0,branchHousekeeping:!0,reopenPullRequests:!1,labels:!1}}async request(j,z,A,C={}){let F={Authorization:`Bearer ${this.token}`,Accept:C.raw?"text/plain":"application/json","User-Agent":"buddy"},H;if(C.form)F["Content-Type"]="application/x-www-form-urlencoded",H=new URLSearchParams(C.form).toString();else if(A)F["Content-Type"]="application/json",H=JSON.stringify(A);let G=await M(`${this.apiUrl}${z}`,{method:j,headers:F,...H?{body:H}:{}});if(!G.ok){let J=await G.text().catch(()=>"");throw Error(`Bitbucket ${j} ${z} failed: ${G.status} ${J.slice(0,200)}`)}let I=await G.text();if(C.raw)return I;return I.trim()?JSON.parse(I):void 0}async optional(j,z){try{return await this.request(j,z)}catch(A){if(String(A).includes("404"))return null;throw A}}async collect(j,z=10){let A=[],C=`${this.apiUrl}${j}`;for(let F=0;F<z&&C;F++){let H=C,G=await this.optional("GET",H.startsWith(this.apiUrl)?H.slice(this.apiUrl.length):H);if(!G)break;A.push(...G.values??[]),C=G.next}return A}async branchExists(j){return await this.optional("GET",`/repositories/${this.slug}/refs/branches/${encodeURIComponent(j)}`)!==null}async createBranch(j,z){await this.request("POST",`/repositories/${this.slug}/refs/branches`,{name:j,target:{hash:z}})}async deleteBranch(j){await this.request("DELETE",`/repositories/${this.slug}/refs/branches/${encodeURIComponent(j)}`)}async commitChanges(j,z,A,C="main"){if(A.length===0)return;let F={message:z,branch:j};for(let I of A)if(I.type==="delete")F.files=F.files?`${F.files},${I.path}`:I.path;else F[I.path]=I.content;let H=new URLSearchParams;for(let[I,J]of Object.entries(F)){if(I==="files")continue;H.append(I,J)}for(let I of A)if(I.type==="delete")H.append("files",I.path);let G=await this.headOf(C);if(G)H.append("parents",G);await this.request("POST",`/repositories/${this.slug}/src`,void 0,{form:Object.fromEntries(H.entries())})}async headOf(j){return(await this.optional("GET",`/repositories/${this.slug}/refs/branches/${encodeURIComponent(j)}`))?.target?.hash??null}async getFileContent(j,z){try{return await this.request("GET",`/repositories/${this.slug}/src/${encodeURIComponent(z)}/${j}`,void 0,{raw:!0})}catch(A){if(String(A).includes("404"))return null;throw A}}async createPullRequest(j){if(j.draft)this.logger.debug("Bitbucket has no draft pull requests; opening as ready");let z=await this.request("POST",`/repositories/${this.slug}/pullrequests`,{title:j.title,description:j.body,source:{branch:{name:j.head}},destination:{branch:{name:j.base}},close_source_branch:!0,...j.reviewers?.length?{reviewers:j.reviewers.map((A)=>({nickname:A}))}:{}});return this.toPullRequest(z)}async getPullRequests(j="open"){let A=(j==="open"?["OPEN"]:j==="closed"?["MERGED","DECLINED","SUPERSEDED"]:["OPEN","MERGED","DECLINED","SUPERSEDED"]).map((F)=>`state=${F}`).join("&");return(await this.collect(`/repositories/${this.slug}/pullrequests?${A}&pagelen=50`)).map((F)=>this.toPullRequest(F))}async updatePullRequest(j,z){let A=await this.request("PUT",`/repositories/${this.slug}/pullrequests/${j}`,{...z.title!==void 0?{title:z.title}:{},...z.body!==void 0?{description:z.body}:{},...z.base!==void 0?{destination:{branch:{name:z.base}}}:{}});return this.toPullRequest(A)}async closePullRequest(j){await this.request("POST",`/repositories/${this.slug}/pullrequests/${j}/decline`)}async reopenPullRequest(j){throw Error(`Bitbucket cannot reopen declined pull request #${j}; open a new one from the same branch.`)}async mergePullRequest(j,z="squash"){let A={merge:"merge_commit",squash:"squash",rebase:"fast_forward"};await this.request("POST",`/repositories/${this.slug}/pullrequests/${j}/merge`,{merge_strategy:A[z]??"squash",close_source_branch:!0})}async getPullRequestDiff(j){return await this.request("GET",`/repositories/${this.slug}/pullrequests/${j}/diff`,void 0,{raw:!0})}async getPullRequestHeadSha(j){return(await this.request("GET",`/repositories/${this.slug}/pullrequests/${j}`)).source?.commit?.hash??""}async createComment(j,z){await this.request("POST",`/repositories/${this.slug}/pullrequests/${j}/comments`,{content:{raw:z}})}async createIssue(j){let z=await this.request("POST",`/repositories/${this.slug}/issues`,{title:j.title,content:{raw:j.body},kind:"task"});return this.toIssue(z)}async getIssues(j="open"){let A=(await this.collect(`/repositories/${this.slug}/issues?pagelen=50`)).map((C)=>this.toIssue(C));return j==="all"?A:A.filter((C)=>C.state===j)}async updateIssue(j,z){let A=await this.request("PUT",`/repositories/${this.slug}/issues/${j}`,{...z.title!==void 0?{title:z.title}:{},...z.body!==void 0?{content:{raw:z.body}}:{}});return this.toIssue(A)}async closeIssue(j){await this.request("PUT",`/repositories/${this.slug}/issues/${j}`,{state:"closed"})}async unpinIssue(j){return!1}async getPullRequestChecksState(j){let z=await this.getPullRequestHeadSha(j);if(!z)return"none";let A=await this.collect(`/repositories/${this.slug}/commit/${z}/statuses?pagelen=50`);if(A.length===0)return"none";if(A.some((C)=>C.state==="FAILED"||C.state==="STOPPED"))return"failure";if(A.some((C)=>C.state==="INPROGRESS"))return"pending";if(A.every((C)=>C.state==="SUCCESSFUL"))return"success";return"pending"}async createReview(j,z){if(await this.createComment(j,z.body),!z.comments?.length)return{posted:!0,inlineComments:0};let A=0;for(let C of z.comments)try{await this.request("POST",`/repositories/${this.slug}/pullrequests/${j}/comments`,{content:{raw:C.body},inline:{path:C.path,...C.side==="RIGHT"?{to:C.line}:{from:C.line}}}),A++}catch(F){this.logger.debug(`Could not place a comment on ${C.path}:${C.line}: ${K(F)}`)}return{posted:!0,inlineComments:A}}async createCheckRun(j,z,A){try{await this.request("POST",`/repositories/${this.slug}/commit/${z}/statuses/build`,{key:j.replace(/[^\w-]/g,"-").slice(0,40),state:A.conclusion==="failure"?"FAILED":"SUCCESSFUL",name:A.title.slice(0,100),description:A.summary.slice(0,300),url:"https://buddy.sh"})}catch(C){this.logger.warn(`\u26A0\uFE0F Could not report build status ${j}: ${K(C)}`)}}async hasWriteAccess(j){let A=(await this.optional("GET",`/repositories/${this.slug}/permissions-config/users`))?.values?.find((C)=>C.user?.nickname===j);return A?.permission==="write"||A?.permission==="admin"}async getBuddyBranches(){return(await this.collect(`/repositories/${this.slug}/refs/branches?q=${encodeURIComponent('name ~ "buddy/"')}&pagelen=50`)).filter((z)=>V(z.name)).map((z)=>({name:z.name,sha:z.target?.hash??"",lastCommitDate:z.target?.date?new Date(z.target.date):new Date(0)}))}async getOrphanedBuddyBranches(){let[j,z]=await Promise.all([this.getBuddyBranches(),this.getPullRequests("open")]),A=new Set(z.map((C)=>C.head));return j.filter((C)=>!A.has(C.name))}async cleanupStaleBranches(j=7,z=!1){let A=new Date(Date.now()-j*24*60*60*1000),C=(await this.getOrphanedBuddyBranches()).filter((G)=>G.lastCommitDate<A);if(z)return{deleted:C.map((G)=>G.name),failed:[]};let F=[],H=[];for(let G of C)try{await this.deleteBranch(G.name),F.push(G.name)}catch{H.push(G.name)}return{deleted:F,failed:H}}toPullRequest(j){let z=j.state==="MERGED"?"merged":j.state==="OPEN"?"open":"closed";return{number:j.id,title:j.title,body:j.description??"",head:j.source?.branch?.name??"",base:j.destination?.branch?.name??"",state:z,url:j.links?.html?.href??"",createdAt:new Date(j.created_on),updatedAt:new Date(j.updated_on),...z==="merged"?{mergedAt:new Date(j.updated_on)}:{},author:j.author?.nickname??j.author?.display_name??"",reviewers:(j.reviewers??[]).map((A)=>A.nickname??A.display_name??"").filter(Boolean),assignees:[],labels:[],draft:!1}}toIssue(j){let z=["new","open","on hold"].includes(j.state);return{number:j.id,title:j.title,body:j.content?.raw??"",state:z?"open":"closed",url:j.links?.html?.href??"",createdAt:new Date(j.created_on),updatedAt:new Date(j.updated_on),...z?{}:{closedAt:new Date(j.updated_on)},author:j.reporter?.nickname??j.reporter?.display_name??"",assignees:[],labels:[]}}}
|
|
3
|
+
export{X as Ch};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Oh as F}from"./chunk-8dj94fsy.js";var R=/^(?:build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(?:\([^)]+\))?!?: .+/;function Y(M,G){let P=R.test(M.trim());return{name:"title-format",mode:G,passed:P,summary:P?"Title follows conventional commit format":"Title does not follow conventional commit format",...P?{}:{detail:"Expected something like `feat(scope): add the thing` or `fix: correct the off-by-one`."}}}function B(M,G){let P=M.trim();if(P.length<20)return{name:"description",mode:G.mode,passed:!1,summary:"Description is missing or too short",detail:"Explain what changed and why, so a reviewer does not have to reconstruct it from the diff."};let z=(G.requireSections??[]).filter((j)=>!new RegExp(`^#{1,6}\\s*${w(j)}\\b`,"im").test(P));return{name:"description",mode:G.mode,passed:z.length===0,summary:z.length===0?"Description is complete":`Description is missing ${z.length} required section(s)`,...z.length>0?{detail:`Missing: ${z.map((j)=>`\`${j}\``).join(", ")}`}:{}}}function C(M,G){let P=[];for(let z of M??[]){if(G.blockVulnerable!==!1&&z.vulnerable)P.push(`\`${z.name}@${z.version}\` has a known vulnerability`);if(G.blockDeprecated!==!1&&z.deprecated)P.push(`\`${z.name}\` is deprecated`);if(G.blockEol!==!1&&z.eol)P.push(z.eol);if(G.licenseAllowlist?.length&&z.license){if(!G.licenseAllowlist.includes(z.license))P.push(`\`${z.name}\` is licensed \`${z.license}\`, which is not on the allowlist`)}}return{name:"dependency-gate",mode:G.mode,passed:P.length===0,summary:P.length===0?"Dependencies satisfy the configured policy":`${P.length} dependency policy violation(s)`,...P.length>0?{detail:P.map((z)=>`- ${z}`).join(`
|
|
3
3
|
`)}:{}}}function q(M,G){let P=[];if(G.titleFormat&&G.titleFormat!=="off")P.push(Y(M.title,G.titleFormat));if(G.description&&G.description.mode!=="off")P.push(B(M.body,G.description));if(G.dependencyGate&&G.dependencyGate.mode!=="off")P.push(C(M.dependencies,G.dependencyGate));return P}function S(M){if(M.length===0)return{conclusion:"neutral",title:"No checks configured",summary:"No pre-merge checks are enabled."};let G=M.filter((x)=>!x.passed&&x.mode==="error"),P=M.filter((x)=>!x.passed&&x.mode==="warning"),z=M.filter((x)=>x.neutral),j=M.map((x)=>{return`${H(x)} **${x.name}** \u2014 ${x.summary}${x.detail?`
|
|
4
4
|
|
|
5
5
|
${x.detail}
|