@buddysh/buddy 0.11.10 → 0.11.11
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/dist/bin/cli.js +19 -19
- package/dist/{chunk-p9z0hzej.js → chunk-08daxhzx.js} +2 -2
- package/dist/{chunk-ja3rvd6y.js → chunk-0f1xye20.js} +1 -1
- package/dist/{chunk-be059ncv.js → chunk-0g4ybxwj.js} +2 -2
- package/dist/{chunk-2m0134q8.js → chunk-0m1z85m9.js} +1 -1
- package/dist/chunk-0m6b7bac.js +2 -0
- package/dist/{chunk-6xzzs109.js → chunk-0rbxek2f.js} +2 -2
- package/dist/chunk-0sm25gee.js +2 -0
- package/dist/{chunk-xny4kgcc.js → chunk-142zh7e5.js} +1 -1
- package/dist/chunk-18xha279.js +2 -0
- package/dist/{chunk-jpdd59fh.js → chunk-1pecmenc.js} +1 -1
- package/dist/chunk-1tx3t9ke.js +2 -0
- package/dist/chunk-1w1h2tsf.js +2 -0
- package/dist/{chunk-nwrr6jas.js → chunk-1xe0960b.js} +2 -2
- package/dist/{chunk-emygmh7r.js → chunk-24xvskkf.js} +1 -1
- package/dist/{chunk-785rgtn5.js → chunk-25sjd6zk.js} +5 -5
- package/dist/{chunk-6wxwewbh.js → chunk-2e4e6zjs.js} +1 -1
- package/dist/chunk-2h90wcxe.js +2 -0
- package/dist/{chunk-7bctsv0x.js → chunk-2hb8dan0.js} +1 -1
- package/dist/{chunk-z21tw4fz.js → chunk-2jjrxgs1.js} +2 -2
- package/dist/{chunk-6k6dgwmy.js → chunk-2z9pkk1y.js} +1 -1
- package/dist/{chunk-9m0epv44.js → chunk-33h1me7n.js} +2 -2
- package/dist/{chunk-khn11t39.js → chunk-3c114myc.js} +1 -1
- package/dist/{chunk-rg996jqw.js → chunk-40pvn33p.js} +1 -1
- package/dist/{chunk-k3x0mabj.js → chunk-42xvqxdw.js} +2 -2
- package/dist/{chunk-6w8vxy7s.js → chunk-4kr6evh6.js} +1 -1
- package/dist/{chunk-1m5wprvm.js → chunk-54er1whp.js} +2 -2
- package/dist/{chunk-y7z0br2x.js → chunk-59993g25.js} +1 -1
- package/dist/{chunk-7crh00m7.js → chunk-5jvde2as.js} +2 -2
- package/dist/{chunk-y9senfb6.js → chunk-5pheqk23.js} +1 -1
- package/dist/{chunk-db9rffcf.js → chunk-5vekh5w1.js} +1 -1
- package/dist/{chunk-drkzf2gz.js → chunk-62j8q7sg.js} +1 -1
- package/dist/chunk-64kt1w23.js +2 -0
- package/dist/{chunk-4akhxmfk.js → chunk-65by8f14.js} +1 -1
- package/dist/chunk-6gdenphk.js +2 -0
- package/dist/chunk-6pcnvdj9.js +2 -0
- package/dist/{chunk-mdbf728w.js → chunk-77qe887p.js} +1 -1
- package/dist/{chunk-mg3em5qj.js → chunk-7b4jsg36.js} +2 -2
- package/dist/{chunk-hkb714k3.js → chunk-7c1284fb.js} +1 -1
- package/dist/chunk-7m1ab6p8.js +2 -0
- package/dist/{chunk-bggpgbdx.js → chunk-7m3pzkcj.js} +1 -1
- package/dist/chunk-83yea9pk.js +2 -0
- package/dist/{chunk-04qvf24t.js → chunk-89jytkd6.js} +1 -1
- package/dist/{chunk-bjymeq7e.js → chunk-8swwcx7w.js} +1 -1
- package/dist/chunk-9exbsfz5.js +2 -0
- package/dist/{chunk-ysgex7h7.js → chunk-a3zgenkh.js} +1 -1
- package/dist/{chunk-xffrrs85.js → chunk-afstgmb4.js} +11 -11
- package/dist/{chunk-7ds5q6j3.js → chunk-apdrg3r7.js} +1 -1
- package/dist/{chunk-88xaexj1.js → chunk-b3s185kp.js} +1 -1
- package/dist/chunk-b59zbkfx.js +2 -0
- package/dist/{chunk-34rmja4x.js → chunk-b6a5txek.js} +2 -2
- package/dist/{chunk-a3bnhq58.js → chunk-b9szrnxw.js} +1 -1
- package/dist/{chunk-fpzgxg8a.js → chunk-be7g40yf.js} +1 -1
- package/dist/{chunk-89s9f3mf.js → chunk-bnp0r4eh.js} +1 -1
- package/dist/{chunk-se4g70q2.js → chunk-bsh3kp53.js} +1 -1
- package/dist/{chunk-vckn5ate.js → chunk-cj4d5ad7.js} +1 -1
- package/dist/chunk-csqh2ca4.js +3 -0
- package/dist/{chunk-gzjxhd7a.js → chunk-d9m42wym.js} +2 -2
- package/dist/{chunk-61gfjcqt.js → chunk-dd895pm0.js} +1 -1
- package/dist/{chunk-h8e796qs.js → chunk-ddky3026.js} +1 -1
- package/dist/{chunk-rrnvxj90.js → chunk-dsnd6ndd.js} +1 -1
- package/dist/{chunk-pmszvhja.js → chunk-esm5jjgf.js} +1 -1
- package/dist/chunk-ffbbc38r.js +2 -0
- package/dist/{chunk-yxb1jwxp.js → chunk-g0x10e1d.js} +2 -2
- package/dist/{chunk-kh6v93yb.js → chunk-gpjde0j6.js} +2 -2
- package/dist/{chunk-4wbbbcs2.js → chunk-gweqk008.js} +2 -2
- package/dist/{chunk-a34szd4r.js → chunk-gzkwszsg.js} +3 -3
- package/dist/{chunk-jxd64dzs.js → chunk-h8wskvjv.js} +1 -1
- package/dist/{chunk-kpdz73mc.js → chunk-hc651afv.js} +1 -1
- package/dist/chunk-hmymd6m2.js +2 -0
- package/dist/{chunk-88j356ng.js → chunk-j46f90n8.js} +1 -1
- package/dist/chunk-jhz202wk.js +2 -0
- package/dist/{chunk-1szfwcst.js → chunk-jqh7vx2n.js} +1 -1
- package/dist/{chunk-amj037yy.js → chunk-jsf2322c.js} +3 -3
- package/dist/{chunk-qdmr84mc.js → chunk-k3r7v3dp.js} +2 -2
- package/dist/{chunk-s3ksf6s5.js → chunk-kbvj6qxc.js} +1 -1
- package/dist/{chunk-gvnsr72j.js → chunk-knpdntnh.js} +1 -1
- package/dist/chunk-kq0n3x2e.js +2 -0
- package/dist/{chunk-ktmgq0ja.js → chunk-ktn47bq8.js} +1 -1
- package/dist/chunk-m1zv8db4.js +2 -0
- package/dist/chunk-m63hkte2.js +2 -0
- package/dist/{chunk-s3q7g2hy.js → chunk-mpb1g0xk.js} +1 -1
- package/dist/{chunk-d7jpbw1z.js → chunk-mt53v4sx.js} +1 -1
- package/dist/{chunk-3waqfh3y.js → chunk-naz864cb.js} +2 -2
- package/dist/{chunk-90q6r1j7.js → chunk-nbyxgt9c.js} +1 -1
- package/dist/chunk-njrezpsw.js +2 -0
- package/dist/{chunk-gyf7psxg.js → chunk-nkztawjh.js} +1 -1
- package/dist/chunk-pegk4jhq.js +2 -0
- package/dist/{chunk-k7x9af5r.js → chunk-pq115qkn.js} +2 -2
- package/dist/{chunk-q90s02qc.js → chunk-q7y8dvbz.js} +1 -1
- package/dist/{chunk-wjmp2hsj.js → chunk-qdr900z7.js} +1 -1
- package/dist/chunk-qxf3f6ks.js +2 -0
- package/dist/{chunk-tx9m7y1z.js → chunk-raj75r4h.js} +2 -2
- package/dist/chunk-rphwf28s.js +2 -0
- package/dist/chunk-rr8apsh5.js +2 -0
- package/dist/{chunk-jj1gjkb7.js → chunk-ry5zh9cx.js} +1 -1
- package/dist/chunk-sd5xqd44.js +2 -0
- package/dist/{chunk-7rjrea9g.js → chunk-sxfk3naz.js} +2 -2
- package/dist/chunk-tbt8btwf.js +2 -0
- package/dist/chunk-tjvvb919.js +2 -0
- package/dist/{chunk-ggzjv4s0.js → chunk-va3k91tf.js} +1 -1
- package/dist/{chunk-hdqmcp3n.js → chunk-vmt1bed1.js} +1 -1
- package/dist/chunk-vpsvtb9v.js +2 -0
- package/dist/{chunk-pxdrwhxx.js → chunk-vpw7adwd.js} +1 -1
- package/dist/{chunk-8tsw3cjk.js → chunk-vs68hsbp.js} +1 -1
- package/dist/{chunk-2145m12g.js → chunk-vtr2vbk0.js} +1 -1
- package/dist/{chunk-4hd1mryc.js → chunk-w55x2g9n.js} +2 -2
- package/dist/{chunk-hyp0wfta.js → chunk-wjfw6rx8.js} +2 -2
- package/dist/chunk-wt83nzn3.js +2 -0
- package/dist/{chunk-8dj94fsy.js → chunk-x1w6q9tk.js} +1 -1
- package/dist/{chunk-wreexgkb.js → chunk-xdrvb89m.js} +3 -3
- package/dist/chunk-xxwevpnr.js +2 -0
- package/dist/{chunk-wd8w0vjs.js → chunk-y3w8h4sy.js} +1 -1
- package/dist/{chunk-4c3dws2k.js → chunk-ycbk7tg9.js} +1 -1
- package/dist/chunk-yf01hyxn.js +2 -0
- package/dist/{chunk-srz5kgyg.js → chunk-yqfwvk9z.js} +1 -1
- package/dist/{chunk-0apd8zqn.js → chunk-z05djfac.js} +7 -7
- package/dist/{chunk-kpqez1ht.js → chunk-z18bksyr.js} +1 -1
- package/dist/chunk-z4btj7s0.js +2 -0
- package/dist/{chunk-1tg7dfq5.js → chunk-zk8zdv23.js} +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/setup.js +1 -1
- package/dist/src/utils/lock-file.d.ts +19 -0
- package/package.json +1 -1
- package/dist/chunk-00vbhh0z.js +0 -2
- package/dist/chunk-0y706m2d.js +0 -2
- package/dist/chunk-1aee33aa.js +0 -2
- package/dist/chunk-1vhqtq6m.js +0 -2
- package/dist/chunk-2fx0tbc0.js +0 -2
- package/dist/chunk-3ggd7z2f.js +0 -2
- package/dist/chunk-3xbx315d.js +0 -2
- package/dist/chunk-4k9f9vn2.js +0 -2
- package/dist/chunk-4zvjzesh.js +0 -2
- package/dist/chunk-5dw0q5ng.js +0 -2
- package/dist/chunk-5qtdc2mb.js +0 -2
- package/dist/chunk-6gttmvww.js +0 -2
- package/dist/chunk-7f6mpphq.js +0 -2
- package/dist/chunk-7mmdxbcm.js +0 -2
- package/dist/chunk-7ze1qrmt.js +0 -2
- package/dist/chunk-9634xcvq.js +0 -2
- package/dist/chunk-97csq21c.js +0 -2
- package/dist/chunk-ea6rtyvy.js +0 -2
- package/dist/chunk-gs5b2ssa.js +0 -2
- package/dist/chunk-gw69sjx2.js +0 -2
- package/dist/chunk-j0fcqty9.js +0 -2
- package/dist/chunk-kszbmpw1.js +0 -2
- package/dist/chunk-mzb7cg8a.js +0 -2
- package/dist/chunk-pjq0qxst.js +0 -2
- package/dist/chunk-pksrcdh6.js +0 -2
- package/dist/chunk-tf9nqr0p.js +0 -2
- package/dist/chunk-tq1w2wwa.js +0 -2
- package/dist/chunk-w93akf6h.js +0 -2
- package/dist/chunk-x5jfh372.js +0 -2
- package/dist/chunk-ydt2sn0j.js +0 -2
- package/dist/chunk-z0qbkvyz.js +0 -2
- package/dist/chunk-zefqbamj.js +0 -2
- package/dist/chunk-zrg5ss0x.js +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Ph as z}from"./chunk-x1w6q9tk.js";function Y(q,F,M=""){if(typeof F!=="object"||F===null)return[];let C=F,Q=M||"(root)",N=[];if(typeof C.type==="string"){let K=D(q);if(!(C.type==="integer"?Number.isInteger(q):K===C.type||C.type==="number"&&K==="integer"))return N.push({path:Q,message:`expected ${C.type}, got ${K}`}),N}if(Array.isArray(C.enum)&&!C.enum.includes(q))N.push({path:Q,message:`expected one of ${C.enum.map((K)=>JSON.stringify(K)).join(", ")}`});if(Array.isArray(C.required)&&typeof q==="object"&&q!==null){for(let K of C.required)if(!(String(K)in q))N.push({path:M?`${M}.${K}`:String(K),message:"is required but missing"})}if(typeof C.properties==="object"&&C.properties!==null&&typeof q==="object"&&q!==null)for(let[K,V]of Object.entries(C.properties)){let X=q[K];if(X!==void 0)N.push(...Y(X,V,M?`${M}.${K}`:K))}if(C.items!==void 0&&Array.isArray(q))q.forEach((K,V)=>{N.push(...Y(K,C.items,`${M}[${V}]`))});return N}function D(q){if(q===null)return"null";if(Array.isArray(q))return"array";if(Number.isInteger(q))return"integer";return typeof q}async function B(q){let F=q.logger??z(),M=q.maxRetries??2,C=q.system??"You are running as a pipeline step. Answer the request directly and completely. There is no interactive user to ask follow-up questions of.",Q="";for(let N=1;N<=M+1;N++){let K=N===1?q.prompt:`${q.prompt}
|
|
3
3
|
|
|
4
4
|
Your previous answer did not satisfy the required schema:
|
|
5
5
|
${Q}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{fc as F}from"./chunk-
|
|
2
|
+
import{fc as F}from"./chunk-va3k91tf.js";import{Cf as c}from"./chunk-1pecmenc.js";import{Of as E,Rf as A}from"./chunk-sxfk3naz.js";import{Ph as m}from"./chunk-x1w6q9tk.js";function S(T,f,r){let O=r?"pull request":"issue";return{name:"read_issue",tier:"read",description:`Read the ${O} this task is about: its title and description.`,parameters:{type:"object",properties:{}},async run(M,x){try{let e=r?(await T.getPullRequests("all")).find((h)=>h.number===f):(await T.getIssues("all")).find((h)=>h.number===f);if(!e)return{content:`Could not find ${O} #${f}.`,isError:!0};let k=(e.body??"").slice(0,20000);return x.log(`read ${O} #${f}`),{content:`# ${e.title}
|
|
3
3
|
|
|
4
4
|
${k||"(no description)"}`,untrusted:!0}}catch(e){return{content:`Could not read ${O} #${f}: ${e instanceof Error?e.message:String(e)}`,isError:!0}}}}}async function C(T){let f=T.logger??m(),r=F(T.config,f);if(!r)return"I need an AI provider configured to write a plan. See https://buddy.sh/ai/providers";let M=[`Write an implementation plan for ${T.isPullRequest?"pull request":"issue"} #${T.number} in this repository.`,"","Call `read_issue` first to see what is being asked for, then read enough of","the repository to be concrete about it.",...T.request?["","The person asking added this direction, which comes from them rather than","from the repository:",` ${T.request.replace(/\n/g," ")}`]:[],"","Produce: the files that would change and why, the order of the work, the","risks, and how the result would be verified. Prefer naming real paths you","have read over describing the change in the abstract.","","If the request is too vague to plan, say what you would need to know","instead of inventing a plan around the gap."].join(`
|
|
5
5
|
`),x=await A(r,{mode:c,task:M,tools:[...E,S(T.provider,T.number,T.isPullRequest)],context:{workspace:T.workspace??process.cwd(),baseBranch:T.config.repository?.baseBranch??"main"},logger:f});if(!x.output)return x.stopReason==="completed"?"I finished researching but produced no plan. That is a bug \u2014 please open an issue.":`I could not finish the plan (${x.stopReason}). The issue may need narrowing.`;return x.output}export{S as Va,C as Wa};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{We as c}from"./chunk-gpjde0j6.js";import{bg as l,kg as A}from"./chunk-xdrvb89m.js";import{sg as y}from"./chunk-knpdntnh.js";import{yh as k}from"./chunk-2z9pkk1y.js";import{Ph as i}from"./chunk-x1w6q9tk.js";import u from"process";var d=/\{([a-z_]+)\}/gi,b={title:"title",message:"message",group:"group",count:"count",strategy:"strategy",update_type:"updateType",updateType:"updateType",packages:"packages",updates_table:"updatesTable",release_notes:"releaseNotes",footer:"footer",package_count:"packageCount"};function h(W,$){return W.replace(d,(Y,R)=>{let K=b[R]??b[R.toLowerCase()];if(!K)return Y;let H=$[K];return H===void 0?Y:String(H)})}function f(W,$={},Y){return{...$,group:W.name,count:W.updates.length,packageCount:W.updates.length,updateType:W.updateType,packages:W.updates.map((R)=>R.name).join(", "),...Y?{strategy:Y}:{}}}class p{config;releaseNotesFetcher=new c;verbose=!1;logger;constructor(W,$){this.config=W;this.verbose=W?.verbose||u.env.BUDDY_VERBOSE==="true",this.logger=$??i()}get releaseNotesSettings(){let W=this.config?.releaseNotes;return{enabled:W?.enabled??!0,maxReleases:W?.maxReleases??3,maxBodyLength:W?.maxBodyLength??1000,includeCompareLinks:W?.includeCompareLinks??!0}}repositoryFileUrl(W){let $=k(this.config),{owner:Y,name:R,baseBranch:K}=this.config?.repository??{};return`${$}/${Y}/${R}/blob/${K||"main"}/${W}`}log(W,$){if(this.verbose){let Y=new Date().toISOString();if(this.logger.info(`[${Y}] PR-GEN: ${W}`),$)this.logger.info(JSON.stringify($,null,2))}}async generatePullRequests(W){let $=[];for(let Y of W){let R=this.generateTitle(Y),K=await this.generateBody(Y),H={number:0,title:R,body:K,head:`buddy/update-${Y.name.toLowerCase().replace(/\s+/g,"-")}`,base:"main",state:"open",url:"",createdAt:new Date,updatedAt:new Date,author:"github-actions[bot]",reviewers:[],assignees:[],labels:this.generateLabels(Y),draft:!1};$.push(H)}return $}generateLabels(W){let $=["dependencies"];if(W.updateType==="major")$.push("major");else if(W.updateType==="minor")$.push("minor");else if(W.updateType==="patch")$.push("patch");let Y=W.updates.filter((D)=>D.file==="package.json"||D.file.endsWith("/package.json")||D.file.endsWith("\\package.json")).length,R=W.updates.filter((D)=>D.file.endsWith("composer.json")||D.file.endsWith("composer.lock")).length,K=W.updates.filter((D)=>D.file.endsWith("build.zig.zon")).length,H=W.updates.filter((D)=>(D.file.includes(".yaml")||D.file.includes(".yml"))&&!D.file.includes(".github/workflows/")).length,Z=W.updates.filter((D)=>D.file.includes(".github/workflows/")).length;if(Y>0)$.push("npm");if(R>0)$.push("composer");if(K>0)$.push("zig");if(H>0)$.push("system");if(Z>0)$.push("github-actions");if(W.updates.length===1){let D=W.updates[0];$.push(D.name)}if(W.updates.length>=5)$.push("bulk-update");return $}generateTitle(W){let $=this.config?.pullRequest?.titleFormat;if($)return h($,f(W,{title:this.defaultTitle(W)},this.config?.packages?.strategy));return this.defaultTitle(W)}defaultTitle(W){if(W.updates.length===1){let R=W.updates[0];return`chore(deps): update dependency ${R.name} to v${R.newVersion}`}let $=W.updates.filter((R)=>R.updateType==="major").length,Y=W.updates.filter((R)=>R.updateType==="minor").length;if($>0)return`chore(deps): update ${W.updates.length} dependencies (major)`;else if(Y>0)return`chore(deps): update ${W.updates.length} dependencies (minor)`;else return`chore(deps): update ${W.updates.length} dependencies (patch)`}async generateBody(W){if(this.log("\uD83D\uDE80 Starting PR body generation",{groupName:W.name,totalUpdates:W.updates.length,updates:W.updates.map((Q)=>({name:Q.name,file:Q.file,dependencyType:Q.dependencyType,currentVersion:Q.currentVersion,newVersion:Q.newVersion,updateType:Q.updateType}))}),W.updates.length===0)this.log("\u26A0\uFE0F WARNING: No updates in group - this will result in sparse PR body",{groupName:W.name,groupTitle:W.title});let $=W.updates.filter((Q)=>Q.file==="package.json"||Q.file.endsWith("/package.json")||Q.file.endsWith("\\package.json")).length,Y=W.updates.filter((Q)=>(Q.file.includes(".yaml")||Q.file.includes(".yml"))&&!Q.file.includes(".github/workflows/")).length,R=W.updates.filter((Q)=>Q.file.includes(".github/workflows/")).length,K=W.updates.filter((Q)=>Q.file.endsWith("composer.json")||Q.file.endsWith("composer.lock")).length,H=W.updates.filter((Q)=>Q.file.endsWith("build.zig.zon")).length;if(this.log("\uD83D\uDCCA Package type counts",{packageJsonCount:$,dependencyFileCount:Y,githubActionsCount:R,composerCount:K,total:W.updates.length}),W.updates.length>0)this.log("\uD83D\uDD0D File path analysis",{files:W.updates.map((Q)=>({name:Q.name,file:Q.file,isExactMatch:Q.file==="package.json",endsWithSlash:Q.file.endsWith("/package.json"),endsWithBackslash:Q.file.endsWith("\\package.json"),matchesAny:Q.file==="package.json"||Q.file.endsWith("/package.json")||Q.file.endsWith("\\package.json")}))});let Z=`This PR contains the following updates:
|
|
3
3
|
|
|
4
4
|
`;Z+=l(W.updates);let D=W.updates.length>1;if(D){if(Z+=`## Package Updates Summary
|
|
5
5
|
|
|
@@ -187,4 +187,4 @@ import{Ve as c}from"./chunk-kh6v93yb.js";import{ag as l,jg as A}from"./chunk-wre
|
|
|
187
187
|
`).trim();$=this.sanitizeMentions($),$=this.sanitizeGitHubReferences($);let Y=this.config?.releaseNotes?.maxBodyLength??1000;if($.length>Y)$=`${$.substring(0,Y)}...
|
|
188
188
|
|
|
189
189
|
*[View full release notes]*`;return $}sanitizeMentions(W){let $=[],Y=[],R=W.replace(/```[\s\S]*?```/g,(K)=>{return $.push(K),`__FENCE_PLACEHOLDER_${$.length-1}__`});return R=R.replace(/`[^`\n]+`/g,(K)=>{return Y.push(K),`__INLINE_CODE_PLACEHOLDER_${Y.length-1}__`}),R=R.replace(/(?<![\w./])@([A-Z0-9-]+)(?![A-Z0-9-])/gi,(K,H)=>{return`[${H}](https://github.com/${H})`}),R=R.replace(/__INLINE_CODE_PLACEHOLDER_(\d+)__/g,(K,H)=>Y[Number(H)]),R=R.replace(/__FENCE_PLACEHOLDER_(\d+)__/g,(K,H)=>$[Number(H)]),R}sanitizeGitHubReferences(W){if(this.config?.releaseNotes?.sanitizeReferences===!1)return W;let $=[],Y=[],R=W.replace(/```[\s\S]*?```/g,(K)=>{return $.push(K),`__FENCE_PLACEHOLDER_${$.length-1}__`});return R=R.replace(/`[^`\n]+`/g,(K)=>{return Y.push(K),`__INLINE_CODE_PLACEHOLDER_${Y.length-1}__`}),R=R.replace(/https?:\/\/github\.com\/([^/]+)\/([^/]+)\/(?:pull|issues)\/(\d+)/g,(K,H,Z,D)=>`\`${H}/${Z}#${D}\``),R=R.replace(/(?<![`\w])#(\d+)(?!\d)/g,"`#$1`"),R=R.replace(/__INLINE_CODE_PLACEHOLDER_(\d+)__/g,(K,H)=>Y[Number(H)]),R=R.replace(/__FENCE_PLACEHOLDER_(\d+)__/g,(K,H)=>$[Number(H)]),R}generateCustomTemplate(W,$,Y={}){let R=$,H={...{"{title}":this.generateTitle(W),"{package_count}":W.updates.length.toString(),"{update_type}":W.updateType,"{packages}":W.updates.map((Z)=>Z.name).join(", "),"{date}":new Date().toISOString().split("T")[0]},...Y};for(let[Z,D]of Object.entries(H))R=R.replace(new RegExp(Z,"g"),D);return R}formatVersionChange(W,$){let Y=W.match(/^(\D+)/),R=Y?Y[1]:"";if(R){let K=W.replace(/^\D+/,""),H=$.replace(/^\D+/,"");return`\`${R}${K}\` \u2192 \`${R}${H}\``}return`\`${W}\` \u2192 \`${$}\``}getVersionChangeDescription(W,$,Y){return{major:"\uD83D\uDD34 Breaking changes possible",minor:"\uD83D\uDFE1 New features added",patch:"\uD83D\uDFE2 Bug fixes & patches"}[Y]}}
|
|
190
|
-
export{h as
|
|
190
|
+
export{h as rd,f as sd,p as td};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ah as
|
|
2
|
+
import{Ah as R,Bh as S,xh as G}from"./chunk-2z9pkk1y.js";import{Jh as x}from"./chunk-b9szrnxw.js";import{Ph as K}from"./chunk-x1w6q9tk.js";var{semver:H}=globalThis.Bun;import F from"process";class P{userAgent="Buddy/1.0.0 (https://github.com/stacksjs/buddy)";logger;constructor(B){this.logger=B??K()}githubHeaders(){let B={"User-Agent":this.userAgent,Accept:"application/vnd.github.v3+json"},J=F.env.BUDDY_TOKEN||F.env.GITHUB_TOKEN||F.env.GH_TOKEN;if(J)B.Authorization=`Bearer ${J}`;return B}async fetchPackageInfo(B,J,Y){if(F.env.APP_ENV==="test"){let X={stripe:{owner:"stripe",repo:"stripe-node"},typescript:{owner:"microsoft",repo:"TypeScript"},react:{owner:"facebook",repo:"react"}}[B]||{owner:"example",repo:B};return{packageInfo:{name:B,description:`Package ${B} description`,repository:{type:"git",url:`https://github.com/${X.owner}/${X.repo}`}},releaseNotes:[],changelog:[],compareUrl:this.generateCompareUrl(X.owner,X.repo,J,Y)}}try{let q=await this.fetchNpmPackageInfo(B),X=[],Z=[],Q;if(q.repository?.url){let O=this.parseGitHubUrl(q.repository.url);if(O)X=await this.fetchGitHubReleases(O.owner,O.repo,J,Y),Q=this.generateCompareUrl(O.owner,O.repo,J,Y),Z=await this.fetchChangelog(O.owner,O.repo)}return{packageInfo:q,releaseNotes:X,changelog:Z,compareUrl:Q}}catch(q){return this.logger.error(`\u274C Failed to fetch package info for ${B}:`,q),{packageInfo:{name:B,description:`Package ${B} - see npm for details`,repository:{type:"git",url:`https://github.com/search?q=${encodeURIComponent(B)}&type=repositories`}},releaseNotes:[],changelog:[]}}}async fetchNpmPackageInfo(B){try{let J=R(B),Y=await x(`${J}/${encodeURIComponent(B).replace("%40","@")}`,{headers:{"User-Agent":this.userAgent}});if(!Y.ok)throw Error(`NPM registry responded with ${Y.status}`);let q=await Y.json(),X=q["dist-tags"]?.latest,Z;try{let L=await x(`https://api.npmjs.org/downloads/point/last-week/${encodeURIComponent(B)}`,{headers:{"User-Agent":this.userAgent}});if(L.ok)Z=(await L.json()).downloads}catch{}let Q=typeof q.repository==="string"?{type:"git",url:q.repository}:q.repository?.url?{type:q.repository.type??"git",url:q.repository.url}:void 0,O=q.author,_=typeof O==="string"?O:O&&typeof O==="object"&&("name"in O)&&typeof O.name==="string"?O:void 0,$=Array.isArray(q.maintainers)?q.maintainers.filter((L)=>!!L&&typeof L==="object"&&("name"in L)&&typeof L.name==="string"):void 0;return{name:B,description:q.description,homepage:q.homepage,repository:Q,license:q.license,author:_,keywords:q.keywords,weeklyDownloads:Z,lastPublish:X?q.time?.[X]:void 0,maintainers:$}}catch(J){return this.logger.warn(`\u26A0\uFE0F Failed to fetch npm info for ${B}:`,J),{name:B,description:`NPM package ${B}`,homepage:`https://www.npmjs.com/package/${encodeURIComponent(B)}`}}}async fetchSpanReleases(B,J,Y,q=5){let X=await this.fetchNpmPackageInfo(B).catch(()=>null),Z=X?.repository?.url?this.parseGitHubUrl(X.repository.url):null;if(!Z)return this.logger.debug(`No GitHub repository for ${B}; no span notes available`),[];let Q=[];for(let O=1;O<=q;O++){let _=await x(`${G()}/repos/${Z.owner}/${Z.repo}/releases?per_page=100&page=${O}`,{headers:this.githubHeaders()}).catch(()=>null);if(!_?.ok)break;let $=await _.json().catch(()=>null);if(!Array.isArray($)||$.length===0)break;for(let j of $)Q.push({version:j.tag_name,date:j.published_at,title:j.name??j.tag_name,body:j.body??"",htmlUrl:j.html_url,isPrerelease:j.prerelease});if($.some((j)=>this.isVersionBetween(j.tag_name.replace(/^v/,""),"0.0.0",J))||$.length<100)break}return Q.filter((O)=>this.isVersionBetween(O.version.replace(/^v/,""),J,Y))}parseGitHubUrl(B){try{let J=B.replace(/^git\+/,"").replace(/\.git$/,"").replace(/^git:\/\//,"https://").replace(/^ssh:\/\/git@/,"https://").replace(/^git@github\.com:/,"https://github.com/"),Y=new URL(J);if(Y.hostname!=="github.com")return null;let q=Y.pathname.split("/").filter(Boolean);if(q.length>=2)return{owner:q[0],repo:q[1]};return null}catch{return null}}async fetchGitHubReleases(B,J,Y,q){try{let X=await x(`${G()}/repos/${B}/${J}/releases?per_page=50`,{headers:this.githubHeaders()});if(!X.ok)return[];return(await X.json()).filter((Q)=>{let O=Q.tag_name.replace(/^v/,"");return this.isVersionBetween(O,Y,q)}).map((Q)=>({version:Q.tag_name,date:Q.published_at,title:Q.name??Q.tag_name,body:Q.body??"",htmlUrl:Q.html_url,compareUrl:this.generateCompareUrl(B,J,Y,Q.tag_name),author:Q.author?.login,isPrerelease:Q.prerelease,assets:Q.assets?.map((O)=>({name:O.name,downloadUrl:O.browser_download_url,size:O.size,contentType:O.content_type}))??[]}))}catch(X){return this.logger.warn(`Failed to fetch GitHub releases for ${B}/${J}:`,X),[]}}async fetchChangelog(B,J){let Y=["CHANGELOG.md","CHANGELOG.rst","HISTORY.md","RELEASES.md"];for(let q of Y)try{let X=await x(`${G()}/repos/${B}/${J}/contents/${q}`,{headers:this.githubHeaders()});if(X.ok){let Z=await X.json();if(Z.content){let Q=atob(Z.content);return this.parseChangelog(Q)}}}catch{}return[]}parseChangelog(B){let J=[],Y=B.split(`
|
|
3
3
|
`),q=null,X=null;for(let Z of Y){let Q=Z.match(/^##\s*\[?([^\]]+)\]?\s*-?\s*(.*)/);if(Q){if(q)J.push(q);q={version:Q[1],date:Q[2].trim(),changes:{}},X=null;continue}let O=Z.match(/^###\s*(.+)/);if(O&&q){X=O[1].toLowerCase();continue}let _=Z.match(/^[-*]\s*(.+)/);if(_&&q&&X){if(!q.changes)q.changes={};let $=X;if(!q.changes[$])q.changes[$]=[];q.changes[$].push(_[1])}}if(q)J.push(q);return J.slice(0,10)}generateCompareUrl(B,J,Y,q){let X=this.getComparableVersion(Y),Z=this.getComparableVersion(q);if(!X||!Z)return;return`https://github.com/${B}/${J}/compare/${encodeURIComponent(`v${X}`)}...${encodeURIComponent(`v${Z}`)}`}isVersionBetween(B,J,Y){let q=this.getComparableVersion(B),X=this.getComparableVersion(J),Z=this.getComparableVersion(Y);if(!q||!X||!Z)return!1;try{return H.order(q,X)>0&&H.order(q,Z)<=0}catch{return q>X&&q<=Z}}getComparableVersion(B){let J=B.split("||").flatMap((Y)=>{let q=Y.trim();if(q.startsWith("<"))return[];let X=q.match(/^(?:[~^]|>=?|=)?\s*v?(\d+(?:\.\d+){0,2}(?:-[0-9A-Z.-]+)?)/i);if(!X)return[];let[Z,Q]=X[1].split("-",2),O=Z.split(".");while(O.length<3)O.push("0");return[`${O.join(".")}${Q?`-${Q}`:""}`]});if(J.length===0)return null;return J.reduce((Y,q)=>{try{return H.order(q,Y)>0?q:Y}catch{return q>Y?q:Y}})}generatePackageBadges(B,J,Y){let q=encodeURIComponent(B.name),X=this.normalizeVersionForBadges(J),Z=this.normalizeVersionForBadges(Y),Q=encodeURIComponent(X),O=encodeURIComponent(Z);return{age:`[](https://docs.renovatebot.com/merge-confidence/)`,adoption:`[](https://docs.renovatebot.com/merge-confidence/)`,passing:`[](https://docs.renovatebot.com/merge-confidence/)`,confidence:`[](https://docs.renovatebot.com/merge-confidence/)`}}async fetchComposerPackageInfo(B){if(F.env.APP_ENV==="test")return{name:B,description:`PHP package ${B} description`,homepage:`https://packagist.org/packages/${B}`,repository:{type:"git",url:`https://github.com/example/${B}`},license:"MIT"};try{let J=await x(`${S()}/packages/${encodeURIComponent(B)}.json`,{headers:{"User-Agent":this.userAgent}});if(!J.ok)throw Error(`Packagist responded with ${J.status}`);let q=(await J.json()).package;if(!q?.versions)return{name:B};let X=Object.keys(q.versions),Z=X.find((L)=>!L.includes("dev")&&!L.includes("alpha")&&!L.includes("beta"))??X[0],Q=(Z?q.versions[Z]:void 0)??{},O=Array.isArray(Q.license)?Q.license[0]:Q.license,_=Q.authors?.[0],$=_&&typeof _==="object"&&"name"in _&&typeof _.name==="string"?_:void 0;return{name:q.name??B,description:Q.description,homepage:Q.homepage,repository:Q.source?.url?{type:"git",url:Q.source.url}:void 0,license:O,author:$,keywords:Q.keywords,lastPublish:Q.time}}catch(J){return this.logger.warn(`Failed to fetch Packagist info for ${B}:`,J),{name:B}}}generateComposerBadges(B,J,Y){let q=encodeURIComponent(B.name),X=this.normalizeVersionForBadges(J),Z=this.normalizeVersionForBadges(Y),Q=encodeURIComponent(X),O=encodeURIComponent(Z);return{age:`[](https://docs.renovatebot.com/merge-confidence/)`,adoption:`[](https://docs.renovatebot.com/merge-confidence/)`,passing:`[](https://docs.renovatebot.com/merge-confidence/)`,confidence:`[](https://docs.renovatebot.com/merge-confidence/)`}}normalizeVersionForBadges(B){let J=B.replace(/^v/,"");if(J.split(".").length===2)J=`${J}.0`;return J}}
|
|
4
|
-
export{P as
|
|
4
|
+
export{P as We};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{m as
|
|
2
|
+
import{md as J}from"./chunk-bnp0r4eh.js";import{nd as Y}from"./chunk-0f1xye20.js";import{ue as _}from"./chunk-wjfw6rx8.js";import{xe as x,ye as w}from"./chunk-w55x2g9n.js";import{Qe as z,Re as M}from"./chunk-1xe0960b.js";import{Ye as N}from"./chunk-j46f90n8.js";import{Ag as S,zg as L}from"./chunk-54er1whp.js";import{Ph as G}from"./chunk-x1w6q9tk.js";import{el as j}from"./chunk-kbvj6qxc.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-hc651afv.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
|
+
export{m as ld};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{ud as R}from"./chunk-7b4jsg36.js";import{re as F,se as A}from"./chunk-b6a5txek.js";import{Bf as S}from"./chunk-1pecmenc.js";import{Rf as L}from"./chunk-sxfk3naz.js";import{Mh as K,Ph as O}from"./chunk-x1w6q9tk.js";import{el as P}from"./chunk-kbvj6qxc.js";var b=[{kind:"lockfile-drift",mechanical:!0,patterns:[/lockfile had changes, but lockfile is frozen/i,/your lockfile does not satisfy your workspace/i,/the lockfile (?:is|was) out of date/i,/npm ci can only install packages when your package\.json and package-lock\.json .* are in sync/i,/composer\.lock is not up to date/i]},{kind:"flake",mechanical:!0,patterns:[/\bECONNRESET\b|\bETIMEDOUT\b|\bENOTFOUND\b|\bEAI_AGAIN\b/,/socket hang up/i,/502 Bad Gateway|503 Service Unavailable|504 Gateway Time-?out/i,/rate limit exceeded/i,/the runner has received a shutdown signal/i]},{kind:"install",mechanical:!1,patterns:[/could not resolve (?:dependency|host)/i,/no matching version found for/i,/unable to resolve dependency tree/i,/peer dep(?:endency)? .* conflict/i]},{kind:"type-error",mechanical:!1,patterns:[/error TS\d{4}:/,/\berror\[E\d+\]:/,/Type '.*' is not assignable to type/]},{kind:"test-failure",mechanical:!1,patterns:[/\d+ (?:tests? )?fail(?:ed|ing)\b/i,/\(fail\)/,/AssertionError|expect\(received\)/,/\u25CF .* \u203A /]},{kind:"lint",mechanical:!1,patterns:[/\b\d+ problems? \(\d+ errors?/i,/eslint|pickier|biome|oxlint/i]}];function N(x){if(!x.trim())return{kind:"unknown",mechanical:!1,evidence:[]};let H=x.split(`
|
|
3
3
|
`);for(let z of b){let J=[];for(let V of H)if(z.patterns.some((Q)=>Q.test(V))){if(J.push(V.trim()),J.length>=5)break}if(J.length>0)return{kind:z.kind,mechanical:z.mechanical,evidence:J}}return{kind:"unknown",mechanical:!1,evidence:T(H)}}function T(x,H=40){let z=x.filter((J)=>/\b(?:error|failed|failure|exception|panic|fatal)\b/i.test(J)&&!/^\s*(?:at\s|\s*\.\.\.)/.test(J));return(z.length>0?z:x.slice(-H)).slice(-H).map((J)=>J.trim()).filter(Boolean)}function G(x){switch(x.kind){case"lockfile-drift":return"The lock file is out of step with its manifest.";case"flake":return"A network or runner problem, unrelated to the change.";case"install":return"Dependencies could not be resolved.";case"type-error":return"The change does not type-check.";case"test-failure":return"One or more tests failed.";case"lint":return"Lint or formatting checks failed.";default:return"The failure could not be classified automatically."}}var w=3;async function M(x,H,z,J){let V=J??O();try{let Q=await x.listWorkflowRuns(H,{status:"completed",limit:20});for(let Y of _(Q).slice(0,w)){let Z=await x.getWorkflowRunLogs(Y.id);if(!Z)continue;if(N(Z).kind===z)return V.info(`\uD83E\uDDED ${H} already fails the same way (run ${Y.id}) \u2014 not this pull request's to fix`),!0}return!1}catch(Q){return V.debug(`Could not check ${H} for a pre-existing failure: ${K(Q)}`),!1}}function _(x){let H=new Map;for(let z of x)if(!H.has(z.name))H.set(z.name,z);return[...H.values()].filter((z)=>z.conclusion==="failure")}function h(x,H){if(!x)return"Tried to regenerate the lock file, but the install did not succeed.";if(!H)return"Regenerated the lock file, but could not push it to the branch. The change is in the workspace only, so the run will still be red until someone commits it.";return"Regenerated the lock file and pushed the result. No model was needed."}function f(x){let H="Repairs run on the pull request's branch, and answering a comment runs on the default branch, so anything I changed here would land on the wrong tree. ";if(x.kind==="lockfile-drift")return`Regenerating the lock file would fix this, and no model would be needed. ${H}The \`fix-ci\` job will do it on the next failing run, or you can run \`buddy fix-ci --run-id <id> --pr <number>\` yourself.`;return`${H}The \`fix-ci\` job runs on the failing run itself and can repair this; this reply is the diagnosis it would start from.`}async function I(x){let H=x.logger??O(),z=N(x.log),J=x.maxAttempts??3;if(H.info(`\uD83E\uDE7A CI failure classified as ${z.kind}`),x.failsOnBase??(x.checkBase?await x.checkBase(z.kind):!1))return{failure:z,action:"skipped",fixed:!1,report:$(z,"This failure also occurs on the base branch, so it is not caused by this change. Fixing it here would only mask it.")};if((x.priorAttempts??0)>=J)return{failure:z,action:"skipped",fixed:!1,report:$(z,`Already attempted ${x.priorAttempts} time(s); stopping rather than looping.`)};if(x.analysisOnly&&z.kind!=="flake")return{failure:z,action:"reported",fixed:!1,report:$(z,f(z))};if(z.kind==="lockfile-drift"&&x.regenerateLockfile){if(x.dryRun)return{failure:z,action:"mechanical-fix",fixed:!1,report:$(z,"Regenerating the lock file would fix this. No model would be needed. Nothing was changed, because this was a dry run.")};H.info("\uD83D\uDD27 Regenerating the lock file");let{regenerated:Y,pushed:Z}=await x.regenerateLockfile();return{failure:z,action:"mechanical-fix",fixed:Z,report:$(z,h(Y,Z))}}if(z.kind==="flake"){if(x.dryRun)return{failure:z,action:"retry",fixed:!1,report:$(z,"This looks transient, and re-running the failed jobs would likely clear it. Nothing was changed, because this was a dry run.")};if(!x.rerun)return{failure:z,action:"retry",fixed:!1,report:$(z,"This looks transient. Re-running the failed job is likely to clear it.")};H.info("\uD83D\uDD01 Re-running the failed jobs");let Y=await x.rerun();return{failure:z,action:"retry",fixed:!1,report:$(z,Y?"This looks transient, so I re-ran the failed jobs. No model was needed.":"This looks transient, but I could not re-run the failed jobs \u2014 `actions: write` is the usual reason. "+"Re-running them from the Actions tab is likely to clear it.")}}if(!x.ai)return{failure:z,action:"reported",fixed:!1,report:$(z,"No AI provider is configured, so this needs a human. See https://buddy.sh/ai/providers to enable automatic repair.")};let Q=await L(x.ai,{mode:S,task:["A CI job on this branch is failing. Diagnose the root cause and fix it if the fix is clear.","",`Classification: ${z.kind} \u2014 ${G(z)}`,"","Relevant log lines:",z.evidence.join(`
|
|
4
4
|
`),"","Verify your fix by running the project's tests or build before reporting it done.","If the fix is not clear, explain what you found rather than guessing."].join(`
|
|
5
5
|
`),context:{workspace:x.workspace,baseBranch:x.baseBranch,...x.branch?{branch:x.branch}:{}},logger:H});return{failure:z,action:"agent-fix",fixed:Q.stopReason==="completed",report:$(z,Q.output||"The repair run ended without a conclusion.")}}function $(x,H){let z=`## \uD83E\uDE7A CI failure analysis
|
|
@@ -20,8 +20,8 @@ ${x.evidence.slice(0,20).join(`
|
|
|
20
20
|
${JSON.stringify(J)}
|
|
21
21
|
-->`;return`${(x??"").replace(B,"").trimEnd()}
|
|
22
22
|
|
|
23
|
-
${V}`}async function m(x,H,z){if(!F(x,"ciRuns","listWorkflowRuns"))return null;try{let J=await x.getPullRequestHeadSha(H.number),V=await x.listWorkflowRuns(H.head,{status:"completed",limit:30}),Q=J?V.filter((Y)=>Y.headSha===J):V;return _(Q)[0]?.id??null}catch(J){return z.debug(`Could not resolve the failing run for #${H.number}: ${K(J)}`),null}}async function c(x){let H=x.logger??O(),{config:z,provider:J}=x,V=x.workspace??process.cwd();A(J,"ciLogs","getWorkflowRunLogs","reading CI logs");let Q;if(x.prNumber){if(Q=(await J.getPullRequests("open")).find((W)=>W.number===x.prNumber),!Q)return`Could not find open pull request #${x.prNumber}.`}let Y=x.runId??(Q?await m(J,Q,H):null);if(!Y)return Q?"Nothing is failing at the head of this pull request, so there is nothing to diagnose.":"No run to diagnose. Pass --run-id, or --pr so I can find the failing run myself.";let Z=await J.getWorkflowRunLogs(Y);if(!Z)return H.warn(`\u26A0\uFE0F Could not read the logs for run ${Y}; nothing to diagnose`),`Could not read the logs for run ${Y}. They may have expired.`;let U=E(Q?.body)?.attempts??0,j=z.repository?.baseBranch??"main",D=F(J,"ciRuns","listWorkflowRuns"),y=F(J,"ciRuns","rerunWorkflowRun"),{createAiClient:v}=await import("./chunk-
|
|
23
|
+
${V}`}async function m(x,H,z){if(!F(x,"ciRuns","listWorkflowRuns"))return null;try{let J=await x.getPullRequestHeadSha(H.number),V=await x.listWorkflowRuns(H.head,{status:"completed",limit:30}),Q=J?V.filter((Y)=>Y.headSha===J):V;return _(Q)[0]?.id??null}catch(J){return z.debug(`Could not resolve the failing run for #${H.number}: ${K(J)}`),null}}async function c(x){let H=x.logger??O(),{config:z,provider:J}=x,V=x.workspace??process.cwd();A(J,"ciLogs","getWorkflowRunLogs","reading CI logs");let Q;if(x.prNumber){if(Q=(await J.getPullRequests("open")).find((W)=>W.number===x.prNumber),!Q)return`Could not find open pull request #${x.prNumber}.`}let Y=x.runId??(Q?await m(J,Q,H):null);if(!Y)return Q?"Nothing is failing at the head of this pull request, so there is nothing to diagnose.":"No run to diagnose. Pass --run-id, or --pr so I can find the failing run myself.";let Z=await J.getWorkflowRunLogs(Y);if(!Z)return H.warn(`\u26A0\uFE0F Could not read the logs for run ${Y}; nothing to diagnose`),`Could not read the logs for run ${Y}. They may have expired.`;let U=E(Q?.body)?.attempts??0,j=z.repository?.baseBranch??"main",D=F(J,"ciRuns","listWorkflowRuns"),y=F(J,"ciRuns","rerunWorkflowRun"),{createAiClient:v}=await import("./chunk-vtr2vbk0.js"),C=await I({log:Z,priorAttempts:U,workspace:V,baseBranch:j,ai:x.analysisOnly?null:v(z,H),logger:H,dryRun:Boolean(x.dryRun),analysisOnly:Boolean(x.analysisOnly),...D?{checkBase:(X)=>M({listWorkflowRuns:(W,k)=>J.listWorkflowRuns(W,k),getWorkflowRunLogs:(W)=>J.getWorkflowRunLogs(W)},j,X,H)}:{},...y?{rerun:()=>J.rerunWorkflowRun(Y)}:{},...x.analysisOnly?{}:{regenerateLockfile:()=>g(V,H)}});if(H.info(`
|
|
24
24
|
${C.report}
|
|
25
|
-
`),x.prNumber&&!x.dryRun){if(await J.createComment(x.prNumber,C.report),C.action!=="skipped"&&Q)try{await J.updatePullRequest(x.prNumber,{body:q(Q.body,U+1)})}catch(X){H.warn(`Could not record the fix attempt on PR #${x.prNumber}: ${K(X)}`)}}return await R(z.notifications,"fixci.completed",{...x.prNumber?{number:x.prNumber}:{},action:C.action,fixed:C.fixed}),`${C.action}${C.fixed?" (fixed)":""}`}async function g(x,H){let{regenerateLockFile:z,detectRequiredPackageManagers:J,getAllLockFilePaths:V,hasLockFile:Q}=await import("./chunk-
|
|
25
|
+
`),x.prNumber&&!x.dryRun){if(await J.createComment(x.prNumber,C.report),C.action!=="skipped"&&Q)try{await J.updatePullRequest(x.prNumber,{body:q(Q.body,U+1)})}catch(X){H.warn(`Could not record the fix attempt on PR #${x.prNumber}: ${K(X)}`)}}return await R(z.notifications,"fixci.completed",{...x.prNumber?{number:x.prNumber}:{},action:C.action,fixed:C.fixed}),`${C.action}${C.fixed?" (fixed)":""}`}async function g(x,H){let{regenerateLockFile:z,detectRequiredPackageManagers:J,getAllLockFilePaths:V,hasLockFile:Q}=await import("./chunk-hmymd6m2.js"),{commitAndPush:Y}=await import("./chunk-ry5zh9cx.js"),Z=J(["package.json","composer.json"],x).filter((j)=>Q(j,x)),U=!1;for(let j of Z){let D=await z(j,x);if(D.success)U=!0;else H.warn(`\u26A0\uFE0F ${D.message}`)}if(!U)return{regenerated:!1,pushed:!1};try{return{regenerated:!0,pushed:await Y(V(),`fix(deps): regenerate the lock file
|
|
26
26
|
|
|
27
27
|
The lock file had drifted from the manifest, which failed CI.`,x)}}catch(j){return H.warn(`\u26A0\uFE0F Could not push the regenerated lock file: ${K(j)}`),{regenerated:!0,pushed:!1}}}export{N as Ea,T as Fa,G as Ga,M as Ha,_ as Ia,I as Ja,c as Ka};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{mb as w}from"./chunk-
|
|
2
|
+
import{mb as w}from"./chunk-be7g40yf.js";import{Ab as u,Bb as v,Cb as x,Db as y,nb as d,ob as e,pb as f,qb as g,rb as h,sb as i,tb as j,ub as k,vb as l,wb as q,xb as r,yb as s,zb as t}from"./chunk-mpb1g0xk.js";import{Eb as a,Fb as b,Gb as c}from"./chunk-q2tjkhez.js";import{Lb as m,Mb as n,Nb as o,Pb as p}from"./chunk-5yfaptmp.js";import"./chunk-59993g25.js";import"./chunk-va3k91tf.js";import{Ed as z,Fd as A,Gd as B,Hd as C,Id as D,Jd as E,Kd as F,Ld as G,Md as H,Nd as I}from"./chunk-7m3pzkcj.js";import"./chunk-0g4ybxwj.js";import"./chunk-142zh7e5.js";import"./chunk-b6a5txek.js";import"./chunk-24xvskkf.js";import"./chunk-z18bksyr.js";import"./chunk-b9szrnxw.js";import"./chunk-x1w6q9tk.js";import"./chunk-kbvj6qxc.js";export{g as validateFindings,I as shouldFail,n as serializeReviewState,y as runReviewForPR,x as reviewPullRequest,j as reviewDiff,w as resolveBuddyThreads,u as renderFinding,b as renderDiffForReview,v as prepareReview,a as parseUnifiedDiff,o as parseReviewState,p as needsReview,s as loadGuidelines,G as formatReview,C as formatPretty,D as formatGithub,E as formatAgent,f as fingerprint,A as diffArgsFor,l as defaultIncludePath,h as dedupeFindings,F as countBySeverity,t as composeInstructions,B as collectLocalDiff,c as collectGitDiff,H as applySuggestion,k as anchorMap,d as SEVERITY_ORDER,m as REVIEW_STATE_VERSION,e as REVIEW_SCHEMA,z as REVIEW_FORMATS,r as MAX_GUIDELINE_CHARS,q as DEFAULT_GUIDELINE_FILES,i as DEFAULT_EXCLUDED_PATHS};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Ph as X}from"./chunk-x1w6q9tk.js";import"./chunk-kbvj6qxc.js";import{readFileSync as _}from"fs";function L(q){let z=q.split("/").pop()||"";return z==="composer.json"||z==="composer.lock"}async function R(q,z){try{let j=JSON.parse(z),A=[];if(j.require)J(j.require,"require",q,A);if(j["require-dev"])J(j["require-dev"],"require-dev",q,A);return{path:q,type:"composer.json",content:z,dependencies:A}}catch(j){return X().warn(`Failed to parse composer.json file ${q}:`,j),null}}async function S(q,z){try{let j=JSON.parse(z),A=[];if(j.packages){for(let b of j.packages)if(b.name&&b.version)A.push({name:b.name,currentVersion:b.version,type:"require",file:q})}if(j["packages-dev"]){for(let b of j["packages-dev"])if(b.name&&b.version)A.push({name:b.name,currentVersion:b.version,type:"require-dev",file:q})}return{path:q,type:"composer.lock",content:z,dependencies:A}}catch(j){return X().warn(`Failed to parse composer.lock file ${q}:`,j),null}}async function v(q,z){let j=q.split("/").pop()||"";if(j==="composer.json")return R(q,z);if(j==="composer.lock")return S(q,z);return null}function J(q,z,j,A){for(let[b,Z]of Object.entries(q)){if(b==="php"||b.startsWith("ext-"))continue;if(b.includes("/"))A.push({name:b,currentVersion:Z,type:z,file:j})}}async function U(q){let z=[],j=q.filter((b)=>b.file.endsWith("composer.json"));if(j.length===0)return z;let A=new Map;for(let b of j){if(!A.has(b.file))A.set(b.file,[]);A.get(b.file).push({name:b.name,newVersion:b.newVersion})}for(let[b,Z]of A)try{let K=_(b,"utf-8"),T=JSON.parse(K);for(let E of Z){let Y=!1;if(T.require&&T.require[E.name]){let H=T.require[E.name],O;if(H.includes(",")){let G=H.match(/\d+\.\d+(?:\.\d+)?/),Q=G?G[0]:null;O=H.replace(/\d+\.\d+(?:\.\d+)?/g,(W)=>{return Q!==null&&W===Q?E.newVersion:W})}else{let G=H.match(/^(\D*)/);O=`${G?G[1]:""}${E.newVersion}`}let $=new RegExp(`("${E.name.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}"\\s*:\\s*")([^"]+)(")`,"g");K=K.replace($,`$1${O}$3`),Y=!0}if(!Y&&T["require-dev"]&&T["require-dev"][E.name]){let H=T["require-dev"][E.name],O;if(H.includes(",")){let G=H.match(/\d+\.\d+(?:\.\d+)?/),Q=G?G[0]:null;O=H.replace(/\d+\.\d+(?:\.\d+)?/g,(W)=>{return Q!==null&&W===Q?E.newVersion:W})}else{let G=H.match(/^(\D*)/);O=`${G?G[1]:""}${E.newVersion}`}let $=new RegExp(`("${E.name.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}"\\s*:\\s*")([^"]+)(")`,"g");K=K.replace($,`$1${O}$3`),Y=!0}if(!Y)X().warn(`Package ${E.name} not found in ${b}`)}z.push({path:b,content:K,type:"update"})}catch(K){X().error(`Failed to update ${b}:`,K)}return z}export{S as parseComposerLock,R as parseComposerJson,v as parseComposerFile,L as isComposerFile,U as generateComposerUpdates};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Nc as a,Oc as b,Pc as c,Qc as d,Rc as e,Sc as f,Tc as g}from"./chunk-csqh2ca4.js";import"./chunk-xdrvb89m.js";import"./chunk-knpdntnh.js";import"./chunk-54er1whp.js";import"./chunk-ktn47bq8.js";import"./chunk-2z9pkk1y.js";import"./chunk-b9szrnxw.js";import"./chunk-x1w6q9tk.js";import"./chunk-z05djfac.js";import"./chunk-kbvj6qxc.js";export{b as regenerateLockFile,d as nestedLockProjects,f as missingLockFiles,e as lockFileFor,g as hasLockFile,a as getAllLockFilePaths,c as detectRequiredPackageManagers};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var Y={node:{registry:"github",source:"nodejs/node"},bun:{registry:"npm",source:"bun"},npm:{registry:"npm",source:"npm"},pnpm:{registry:"npm",source:"pnpm"},yarn:{registry:"npm",source:"yarn"},deno:{registry:"github",source:"denoland/deno"}};function Z(A,F){if(typeof A!=="object"||A===null||Array.isArray(A))return[];let z=[];for(let[B,J]of Object.entries(A)){if(typeof J!=="string"||!J.trim())continue;if(!Y[B])continue;z.push({name:B,currentVersion:J.trim(),type:"engines",file:F,metadata:{engine:"true",source:Y[B].source}})}return z}function $(A){if(typeof A!=="object"||A===null)return[];let F=A,z=[],B=(J,L)=>{if(typeof J!=="object"||J===null||Array.isArray(J))return;for(let[U,H]of Object.entries(J)){if(typeof H==="string"&&H.trim()){z.push({name:U,version:H.trim(),field:L});continue}if(typeof H==="object"&&H!==null){let M=H;if(typeof M["."]==="string")z.push({name:U,version:M["."].trim(),field:L});B(H,L)}}};return B(F.overrides,"overrides"),B(F.resolutions,"resolutions"),B(F.pnpm?.overrides,"pnpm.overrides"),z}function q(A,F){let z=A.version.trim();try{if(/^[\^~><=]/.test(z))return!Bun.semver.satisfies(F,z)}catch{return!0}return z!==F}async function C(A,F){let z=Y[A];if(!z)return null;let B=z.registry==="npm"?await F.npm(z.source):await F.github(z.source);return B?B.replace(/^v/,""):null}function R(A,F){let z=/^\s*(>=|\^|~|>|=)?\s*v?(\d+(?:\.\d+)*)\s*$/.exec(A);if(!z)return null;let[,B="",J]=z,L=J.split(".").map(Number),H=F.split(".").map(Number).slice(0,L.length),M=!1;for(let Q=0;Q<H.length;Q++){let X=H[Q]-(L[Q]??0);if(X!==0){M=X>0;break}}if(!M)return null;return`${B}${H.join(".")}`}function T(A,F){let z=(L)=>(/(\d+(?:\.\d+)*)/.exec(L)?.[1]??"0").split(".").map(Number),B=z(A),J=z(F);if((J[0]??0)!==(B[0]??0))return"major";if((J[1]??0)!==(B[1]??0))return"minor";return"patch"}function P(A,F){let z=/("engines"\s*:\s*\{)([\s\S]*?)(\})/.exec(A);if(!z)return A;let[B,J,L,U]=z,H=L;for(let M of F){if(M.dependencyType!=="engines")continue;let Q=M.name.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),X=M.currentVersion.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");H=H.replace(new RegExp(`("${Q}"\\s*:\\s*")${X}(")`),`$1${M.newVersion}$2`)}return H===L?A:A.replace(B,`${J}${H}${U}`)}
|
|
3
|
-
export{Y as
|
|
3
|
+
export{Y as Xe,Z as Ye,$ as Ze,q as _e,C as $e,R as af,T as bf,P as cf};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ae as d,Be as e,Ce as f,De as g,Ee as h,xe as a,ye as b,ze as c}from"./chunk-w55x2g9n.js";import"./chunk-2z9pkk1y.js";import"./chunk-b9szrnxw.js";import"./chunk-x1w6q9tk.js";import"./chunk-kbvj6qxc.js";export{e as updateGitHubActionsFile,d as sameActionVersion,b as parseGitHubActionsFile,a as isGitHubActionsFile,c as isCommitSha,f as generateGitHubActionsUpdates,h as fetchLatestActionVersion,g as fetchActionTagCommit};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Af as J,zf as Q}from"./chunk-1pecmenc.js";var L=`Verify your work before reporting it done: run the project's
|
|
3
3
|
tests or build if one exists. If verification fails, report what failed rather
|
|
4
4
|
than claiming success \u2014 a change that looks right and breaks the build costs
|
|
5
5
|
more than no change at all.`,X={name:"docstrings",description:"Add missing doc comments to changed public APIs",mode:J,defaultOutput:"commit",buildTask:({files:j})=>["Add missing documentation comments to the public APIs changed on this branch.","","Follow the documentation style already used in the surrounding code \u2014 match its","density and conventions rather than importing a different house style.","Document what a caller needs: parameters, return value, thrown errors, and any","constraint the signature does not already show. Do not restate what the code says.","","Do not document code that was not changed, and do not modify behaviour.",j?.length?`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{md as h}from"./chunk-bnp0r4eh.js";import{od as B}from"./chunk-0f1xye20.js";import{kg as E}from"./chunk-xdrvb89m.js";import{Ah as w,Bh as f,xh as y}from"./chunk-2z9pkk1y.js";import{Jh as A,Kh as V}from"./chunk-b9szrnxw.js";import{el as v}from"./chunk-kbvj6qxc.js";import{spawn as N}from"child_process";import q from"fs";import F from"path";import T from"process";var P=8;async function M(X,Z,$=8){if(X.length===0)return[];let K=Math.max(1,Math.min($,X.length)),Y=Array.from({length:X.length}),H=0;async function Q(){while(!0){let z=H++;if(z>=X.length)return;Y[z]=await Z(X[z],z)}}return await Promise.all(Array.from({length:K},Q)),Y}function m(X,Z){let $=Math.max(1,Z),K=[];for(let Y=0;Y<X.length;Y+=$)K.push(X.slice(Y,Y+$));return K}class J{entries=new Map;async get(X,Z){let $=this.entries.get(X);if($)return $;let K=Z().catch((Y)=>{throw this.entries.delete(X),Y});return this.entries.set(X,K),K}clear(){this.entries.clear()}get size(){return this.entries.size}}var d=/^[\w.@/*+-]+$/;function C(X,Z){if(!d.test(X))throw new B(`Refusing to pass untrusted ${Z} to bun: ${JSON.stringify(X)}`)}function g(X){let Z={Accept:"application/vnd.github.v3+json","User-Agent":"buddy"},$=X?.repository?.token||T.env.BUDDY_TOKEN||T.env.GITHUB_TOKEN||T.env.GH_TOKEN;if($)Z.Authorization=`Bearer ${$}`;return Z}function R(X){if(typeof X==="string")return X.trim();if(X&&typeof X==="object"&&"version"in X){let Z=X.version;if(typeof Z==="string")return Z.trim()}return""}class k{projectPath;logger;config;concurrency;packumentCache=new J;composerCache=new J;constructor(X,Z,$=void 0,K=P){this.projectPath=X;this.logger=Z;this.config=$;this.concurrency=K}clearCache(){this.packumentCache.clear(),this.composerCache.clear()}async fetchPackument(X){return this.packumentCache.get(X,async()=>{let $=`${w(X,this.config,this.projectPath)}/${encodeURIComponent(X).replace("%40","@")}`;try{let K=await A($,{headers:{"User-Agent":"buddy"},onRetry:({delayMs:Y,reason:H})=>this.logger.debug(`Retrying ${X} in ${Math.round(Y/1000)}s (${H})`)});if(!K.ok)return(K.status===404?this.logger.debug:this.logger.warn).call(this.logger,`No registry data for ${X}: HTTP ${K.status}`),null;return await K.json()}catch(K){return this.logger.warn(`Failed to fetch registry data for ${X}:`,K),null}})}async fetchComposerPackage(X){return this.composerCache.get(X,async()=>{let Z=f(this.config);try{let $=await A(`${Z}/packages/${X}.json`,{headers:{"User-Agent":"buddy"}});if(!$.ok)return null;return await $.json()}catch($){return this.logger.warn(`Failed to get Composer metadata for ${X}:`,$),null}})}shouldRespectVersion(X){if(!(this.config?.packages?.respectLatest??!0))return!1;let $=["latest","*","main","master","develop","dev"],K=X.toLowerCase().trim();return $.includes(K)}async getOutdatedPackages(X){this.logger.info("Checking for outdated packages...");try{let Z=await this.runBunOutdated(X),$=await this.getWorkspaceOutdatedPackages(),K=await this.getPackageJsonOutdated(X),Y=new Map;for(let G of Z)Y.set(G.name,G);for(let G of $)if(!Y.has(G.name))Y.set(G.name,G);for(let G of K)if(!Y.get(G.name))Y.set(G.name,G);let H=[...Y.values()].filter((G)=>{if(this.shouldRespectVersion(G.current))return this.logger.debug(`Skipping ${G.name} - version "${G.current}" should be respected`),!1;return!0}),Q=await M(H,async(G)=>{let[_,I]=await Promise.all([this.getPackageMetadata(G.name),this.findPackageLocation(G.name)]);return{name:G.name,currentVersion:G.current,newVersion:G.latest,updateType:E(G.current,G.latest),dependencyType:"dependencies",file:I||"package.json",metadata:_,releaseNotesUrl:this.getReleaseNotesUrl(G.name,_),changelogUrl:this.getChangelogUrl(G.name,_),homepage:_?.homepage}},this.concurrency),z=F.join(this.projectPath,"composer.json");if(q.existsSync(z))try{let G=await this.getComposerOutdatedPackages();Q.push(...G)}catch(G){this.logger.warn("Failed to check Composer packages:",G)}return this.logger.success(`Found ${Q.length} package updates`),Q}catch(Z){throw this.logger.error("Failed to check for outdated packages:",Z),new B(`Failed to check for outdated packages: ${Z instanceof Error?Z.message:"Unknown error"}`)}}async getUpdatesForPackages(X){let Z=X.join(" ");return this.getOutdatedPackages(Z)}async getUpdatesWithPattern(X){return this.getOutdatedPackages(X)}async getPackageMetadata(X){try{C(X,"package name");let Z=await this.fetchPackument(X);if(!Z)return;let $=Object.keys(Z.versions??{}),K=Z["dist-tags"]?.latest??$[$.length-1]??"",Y=Z.versions?.[K]??{},H=Y.repository??Z.repository,Q=Y.license??Z.license,z=Y.author??Z.author;return{name:Y.name??Z.name??X,description:Y.description??Z.description,repository:typeof H==="string"?H:H?.url,homepage:Y.homepage??Z.homepage,license:typeof Q==="string"?Q:Q?.type,author:typeof z==="string"?z:z?.name,keywords:Y.keywords??Z.keywords,latestVersion:K,versions:$,weeklyDownloads:void 0,dependencies:Y.dependencies,devDependencies:Y.devDependencies,peerDependencies:Y.peerDependencies}}catch(Z){this.logger.warn(`Failed to get metadata for ${X}:`,Z);return}}async packageExists(X){try{return C(X,"package name"),await this.fetchPackument(X)!==null}catch{return!1}}async getLatestVersion(X){try{return await this.getLatestVersionFromNpm(X)}catch{return null}}async getLatestVersionFromNpm(X){let Z=await this.fetchPackument(X);if(!Z)return null;let $=Object.keys(Z.versions??{});if($.length===0)return null;let K=this.config?.packages?.includePrerelease??!1,Y=Z["dist-tags"]?.latest;if(Y&&(K||!this.isPrerelease(Y)))return Y;let H=K?$:$.filter((z)=>!this.isPrerelease(z));if(H.length===0)return null;return[...H].sort((z,G)=>{try{return Bun.semver.order(G,z)}catch{return 0}})[0]||null}isPrerelease(X){return/-(?:alpha|beta|rc|dev|canary|next|experimental|snapshot|nightly)/i.test(X)}async runBunOutdated(X){let Z=[];if(X)for(let $ of X.split(/\s+/).filter(Boolean))C($,"package filter"),Z.push($);try{let $=await this.runCommand("bun",["outdated","--json",...Z]),K=this.parseBunOutdatedJson($);if(K)return K;this.logger.debug("bun outdated --json produced unrecognized output, falling back to table parsing")}catch($){this.logger.debug("bun outdated --json unavailable, falling back to table parsing:",$)}try{let $=await this.runCommand("bun",["outdated",...Z]);return this.parseBunOutdatedOutput($)}catch($){this.logger.error("Failed to run bun outdated:",$);let K=$ instanceof Error?$.message:String($);throw new B(`bun outdated command failed: ${K}`)}}parseBunOutdatedJson(X){let Z=X.trim();if(!Z||!Z.startsWith("[")&&!Z.startsWith("{"))return null;let $;try{$=JSON.parse(Z)}catch{return null}let K=Array.isArray($)?$:Object.entries($).map(([H,Q])=>({name:H,...Q&&typeof Q==="object"?Q:{}})),Y=[];for(let H of K){let Q=typeof H.name==="string"?H.name:void 0,z=R(H.current),G=R(H.latest);if(!Q||!z||!G)continue;let _={name:Q,current:z,update:R(H.update)||G,latest:G},I=typeof H.workspace==="string"?H.workspace:void 0;if(I)_.workspace=I;Y.push(_)}return Y}parseBunOutdatedOutput(X){let Z=[],$=`${String.fromCharCode(27)}[`,Y=X.replace(new RegExp(`${$}[0-9;]*m`,"g"),"").split(`
|
|
3
3
|
`).filter((Q)=>Q.trim()),H=!1;for(let Q of Y){if(Q.includes("Package")&&Q.includes("Current")&&Q.includes("Update")){H=!0;continue}if(!H||!Q.trim())continue;if(Q.match(/^[\u2502\u251C\u2500\u253C\u2524\u2514\u2534\u2518\u250C\u252C\u2510|\-\s]+$/))continue;let z;if(Q.includes("\u2502"))z=Q.split("\u2502").map((G)=>G.trim());else z=Q.split("|").map((G)=>G.trim());if(z.length>=4){let G=z[1]?.trim()||"",_=z[2]?.trim()||"",I=z[3]?.trim()||"",W=z[4]?.trim()||"",L=z.length>=6?z[5]?.trim():void 0;if(G=G.replace(/\s*\(dev\)$/,"").replace(/\s*\(peer\)$/,"").replace(/\s*\(optional\)$/,""),G&&_&&W&&G!=="Package"){let O={name:G,current:_,update:I,latest:W};if(L&&L!=="Workspace")O.workspace=L;Z.push(O)}}}return Z}async getPackageJsonOutdated(X){try{let Z=F.join(this.projectPath,"package.json");if(!q.existsSync(Z))return[];let $;try{let I=q.readFileSync(Z,"utf-8"),W=JSON.parse(I);if(W===null||typeof W!=="object"||Array.isArray(W))throw new B(`package.json at ${Z} is not a JSON object`);$=W}catch(I){if(I instanceof B)throw I;let W=I instanceof Error?I.message:String(I);throw new B(`Failed to parse ${Z}: ${W}`)}let K=(I)=>{let W=$[I];return W&&typeof W==="object"&&!Array.isArray(W)?W:{}},Y={...K("dependencies"),...K("devDependencies"),...K("peerDependencies")},H=Object.keys(Y),Q=this.config?.packages?.ignore||[],z=this.config?.packages?.excludeMajor??!1,G=(X?H.filter((I)=>X.split(" ").some((W)=>I.includes(W))):H).flatMap((I)=>{if(!Y[I]||Q.includes(I))return[];let W=this.cleanVersionRange(Y[I]);return W?[{packageName:I,cleanVersion:W}]:[]});return(await M(G,async({packageName:I,cleanVersion:W})=>{let L=await this.getLatestVersion(I);if(!L)return null;if(Bun.semver.order(W,L)>=0)return null;if(z&&E(W,L)==="major")return null;return{name:I,current:W,update:L,latest:L}},this.concurrency)).filter((I)=>I!==null)}catch(Z){return this.logger.warn("Failed to check package.json versions:",Z),[]}}cleanVersionRange(X){if(X.startsWith("workspace:"))return null;return X.replace(/^[\^~>=<]/,"").trim()}async runCommand(X,Z){return new Promise(($,K)=>{let Y=N(X,Z,{cwd:this.projectPath,stdio:"pipe"}),H="",Q="";Y.stdout?.on("data",(z)=>{H+=z.toString()}),Y.stderr?.on("data",(z)=>{Q+=z.toString()}),Y.on("close",(z)=>{if(z===0)$(H);else K(Error(`Command failed with code ${z}: ${Q}`))}),Y.on("error",(z)=>{K(z)})})}getReleaseNotesUrl(X,Z){if(!Z?.repository)return;let $=Z.repository.match(/github\.com[/:]([^/]+\/[^/]+)/);if($)return`https://github.com/${$[1].replace(".git","")}/releases`;return}getChangelogUrl(X,Z){if(!Z?.repository)return;let $=Z.repository.match(/github\.com[/:]([^/]+\/[^/]+)/);if($)return`https://github.com/${$[1].replace(".git","")}/blob/main/CHANGELOG.md`;return}async getUpdatesForWorkspace(X){try{C(X,"workspace name");let Z=["outdated","--filter",X],$=await this.runCommand("bun",Z),K=this.parseBunOutdatedOutput($),Y=[];for(let H of K){let Q=E(H.current,H.latest),z=await this.getPackageMetadata(H.name);Y.push({name:H.name,currentVersion:H.current,newVersion:H.latest,updateType:Q,dependencyType:"dependencies",file:`${X}/package.json`,metadata:z,releaseNotesUrl:this.getReleaseNotesUrl(H.name,z),changelogUrl:this.getChangelogUrl(H.name,z),homepage:z?.homepage})}return Y}catch(Z){return this.logger.warn(`Failed to get updates for workspace ${X}:`,Z),[]}}async searchPackages(X,Z=10){try{let $=encodeURIComponent(X),Y=`${w(void 0,this.config,this.projectPath)}/-/v1/search?text=${$}&size=${Z}`,H=await A(Y,{headers:{"User-Agent":"buddy"}});if(!H.ok)throw Error(`HTTP ${H.status}: ${H.statusText}`);return(await H.json()).objects?.map((z)=>({name:z.package.name,version:z.package.version,description:z.package.description,keywords:z.package.keywords}))??[]}catch($){return this.logger.warn("Failed to search packages via registry API:",$),[]}}async getComposerOutdatedPackages(){this.logger.info("Checking for outdated Composer packages...");let X=[];try{this.logger.info("\uD83D\uDD0D Checking Composer availability...");try{let Q=await this.runCommand("composer",["--version"]);this.logger.info("\u2705 Composer version:",Q.split(`
|
|
4
4
|
`)[0])}catch(Q){return this.logger.info("\u274C Composer not available:",Q),this.logger.warn("Composer not found, skipping Composer package updates"),[]}let Z=F.join(this.projectPath,"composer.json");if(this.logger.info(`\uD83D\uDD0D Reading composer.json from: ${Z}`),!q.existsSync(Z))return this.logger.info("\u274C composer.json not found"),[];let $=q.readFileSync(Z,"utf8"),K=JSON.parse($);this.logger.info("\uD83D\uDCE6 composer.json require packages:",Object.keys(K.require||{})),this.logger.info("\uD83D\uDCE6 composer.json require-dev packages:",Object.keys(K["require-dev"]||{})),this.logger.info("\uD83D\uDD0D Running composer outdated (including dev dependencies)...");let Y=await this.runCommand("composer",["outdated","--format=json"]);this.logger.info("\uD83D\uDCCA Raw composer outdated output length:",Y.length);let H;try{H=JSON.parse(Y),this.logger.info(`\uD83D\uDCCB Composer outdated found ${H.installed?.length||0} packages`)}catch(Q){return this.logger.info("\u274C Failed to parse composer outdated JSON:",Q),this.logger.info("Raw output:",Y.substring(0,500)),[]}if(H.installed){this.logger.info("\uD83D\uDD04 Processing outdated packages...");for(let Q of H.installed)if(this.logger.info(`
|
|
5
|
-
\uD83D\uDCE6 Processing package: ${Q.name}`),this.logger.info(` Current version: ${Q.version}`),this.logger.info(` Latest version: ${Q.latest}`),Q.name&&Q.version&&Q.latest){let z=K.require?.[Q.name],G=K["require-dev"]?.[Q.name],_=z||G;if(this.logger.info(` Constraint: ${_||"NOT FOUND"}`),!_){this.logger.info(` \u26A0\uFE0F Skipping ${Q.name} - not found in composer.json`);continue}if((this.config?.packages?.ignore||[]).includes(Q.name)){this.logger.info(` \u26A0\uFE0F Skipping ${Q.name} - in ignore list`);continue}let W="require";if(K["require-dev"]&&K["require-dev"][Q.name])W="require-dev";this.logger.info(` Dependency type: ${W}`);let L=await this.getComposerPackageMetadata(Q.name),O=this.extractConstraintBaseVersion(_);if(this.logger.info(` Constraint base version: ${O}`),!O){this.logger.warn(`\u274C Could not extract base version from constraint "${_}" for ${Q.name}`);continue}let S=O,b=Q.latest;this.logger.info(` Using current version: ${S} (from constraint)`),this.logger.info(` Target latest version: ${b}`);let j=[];try{this.logger.info(` \uD83D\uDD0D Getting available versions for ${Q.name}...`);let x=await this.runCommand("composer",["show",Q.name,"--available","--format=json"]),U=JSON.parse(x);if(U.versions)j=U.versions,this.logger.info(` \uD83D\uDCCB Found ${j.length} available versions`)}catch(x){this.logger.warn(`\u274C Failed to get available versions for ${Q.name}, using latest only:`,x),j=[b]}this.logger.info(" \uD83C\uDFAF Finding best constraint updates...");let D=await this.findBestConstraintUpdates(_,j,S);this.logger.info(` \uD83D\uDCCA Found ${D.length} update candidates`);for(let x of D){let U=E(S,x.version);if(this.logger.info(` \uD83D\uDCC8 Update candidate: ${S} \u2192 ${x.version} (${U})`),(this.config?.packages?.excludeMajor??!1)&&U==="major"){this.logger.info(` \u26A0\uFE0F Skipping major update for ${Q.name} - excludeMajor is true`);continue}this.logger.info(` \u2705 Adding update: ${Q.name} ${S} \u2192 ${x.version}`),X.push({name:Q.name,currentVersion:S,newVersion:x.version,updateType:U,dependencyType:W,file:"composer.json",metadata:L,releaseNotesUrl:this.getComposerReleaseNotesUrl(Q.name,L),changelogUrl:this.getComposerChangelogUrl(Q.name,L),homepage:L?.homepage})}}}return this.logger.info(`\u2705 Final result: Found ${X.length} Composer package updates`),this.logger.success(`Found ${X.length} Composer package updates`),X}catch(Z){return this.logger.warn("Failed to check for outdated Composer packages:",Z),[]}}parseVersion(X){let $=X.replace(/^v/,"").split("-")[0].split("+")[0].split(".").map((K)=>Number.parseInt(K,10));if($.length<2||$.some((K)=>Number.isNaN(K)))return null;return{major:$[0]||0,minor:$[1]||0,patch:$[2]||0}}compareVersions(X,Z){let $=this.parseVersion(X),K=this.parseVersion(Z);if(!$||!K)return 0;if($.major!==K.major)return $.major-K.major;if($.minor!==K.minor)return $.minor-K.minor;return $.patch-K.patch}async getComposerPackageMetadata(X){try{let $=(await this.fetchComposerPackage(X))?.package;if(!$?.versions)return;let K=Object.keys($.versions),Y=K.find((Q)=>!Q.includes("dev")&&!Q.includes("alpha")&&!Q.includes("beta"))??K[0],H=(Y?$.versions[Y]:void 0)??{};return{name:$.name??X,description:H.description,repository:H.source?.url??H.homepage,homepage:H.homepage,license:Array.isArray(H.license)?H.license.join(", "):H.license,author:H.authors?.[0]?.name,keywords:H.keywords,latestVersion:Y,versions:K,weeklyDownloads:$.downloads?.monthly,dependencies:H.require,devDependencies:H["require-dev"]}}catch(Z){this.logger.warn(`Failed to get Composer metadata for ${X}:`,Z);return}}async composerPackageExists(X){try{return await this.fetchComposerPackage(X)!==null}catch{return!1}}async getComposerLatestVersion(X){try{let $=(await this.fetchComposerPackage(X))?.package;if(!$?.versions)return null;let K=Object.keys($.versions),Y=K.filter((Q)=>!Q.includes("dev")&&!Q.includes("alpha")&&!Q.includes("beta")&&!Q.includes("rc"));if(Y.length===0)return K[0]||null;let H=Y.sort((Q,z)=>{try{if(typeof Bun<"u"&&Bun.semver)return Bun.semver.order(Q,z);return Q.localeCompare(z,void 0,{numeric:!0})}catch{return Q.localeCompare(z)}});return H[H.length-1]||null}catch(Z){return this.logger.warn(`Failed to get latest Composer version for ${X}:`,Z),null}}getComposerReleaseNotesUrl(X,Z){if(!Z?.repository)return;let $=Z.repository.match(/github\.com[/:]([^/]+\/[^/]+)/);if($)return`https://github.com/${$[1].replace(".git","")}/releases`;return}getComposerChangelogUrl(X,Z){if(!Z?.repository)return;let $=Z.repository.match(/github\.com[/:]([^/]+\/[^/]+)/);if($)return`https://github.com/${$[1].replace(".git","")}/blob/main/CHANGELOG.md`;return}extractConstraintBaseVersion(X){let Z=X.match(/^[\^~>=<]*([\d.]+)/);if(Z)return Z[1];return null}async findBestConstraintUpdates(X,Z,$){let{getUpdateType:K}=await import("./chunk-
|
|
6
|
-
export{P as
|
|
5
|
+
\uD83D\uDCE6 Processing package: ${Q.name}`),this.logger.info(` Current version: ${Q.version}`),this.logger.info(` Latest version: ${Q.latest}`),Q.name&&Q.version&&Q.latest){let z=K.require?.[Q.name],G=K["require-dev"]?.[Q.name],_=z||G;if(this.logger.info(` Constraint: ${_||"NOT FOUND"}`),!_){this.logger.info(` \u26A0\uFE0F Skipping ${Q.name} - not found in composer.json`);continue}if((this.config?.packages?.ignore||[]).includes(Q.name)){this.logger.info(` \u26A0\uFE0F Skipping ${Q.name} - in ignore list`);continue}let W="require";if(K["require-dev"]&&K["require-dev"][Q.name])W="require-dev";this.logger.info(` Dependency type: ${W}`);let L=await this.getComposerPackageMetadata(Q.name),O=this.extractConstraintBaseVersion(_);if(this.logger.info(` Constraint base version: ${O}`),!O){this.logger.warn(`\u274C Could not extract base version from constraint "${_}" for ${Q.name}`);continue}let S=O,b=Q.latest;this.logger.info(` Using current version: ${S} (from constraint)`),this.logger.info(` Target latest version: ${b}`);let j=[];try{this.logger.info(` \uD83D\uDD0D Getting available versions for ${Q.name}...`);let x=await this.runCommand("composer",["show",Q.name,"--available","--format=json"]),U=JSON.parse(x);if(U.versions)j=U.versions,this.logger.info(` \uD83D\uDCCB Found ${j.length} available versions`)}catch(x){this.logger.warn(`\u274C Failed to get available versions for ${Q.name}, using latest only:`,x),j=[b]}this.logger.info(" \uD83C\uDFAF Finding best constraint updates...");let D=await this.findBestConstraintUpdates(_,j,S);this.logger.info(` \uD83D\uDCCA Found ${D.length} update candidates`);for(let x of D){let U=E(S,x.version);if(this.logger.info(` \uD83D\uDCC8 Update candidate: ${S} \u2192 ${x.version} (${U})`),(this.config?.packages?.excludeMajor??!1)&&U==="major"){this.logger.info(` \u26A0\uFE0F Skipping major update for ${Q.name} - excludeMajor is true`);continue}this.logger.info(` \u2705 Adding update: ${Q.name} ${S} \u2192 ${x.version}`),X.push({name:Q.name,currentVersion:S,newVersion:x.version,updateType:U,dependencyType:W,file:"composer.json",metadata:L,releaseNotesUrl:this.getComposerReleaseNotesUrl(Q.name,L),changelogUrl:this.getComposerChangelogUrl(Q.name,L),homepage:L?.homepage})}}}return this.logger.info(`\u2705 Final result: Found ${X.length} Composer package updates`),this.logger.success(`Found ${X.length} Composer package updates`),X}catch(Z){return this.logger.warn("Failed to check for outdated Composer packages:",Z),[]}}parseVersion(X){let $=X.replace(/^v/,"").split("-")[0].split("+")[0].split(".").map((K)=>Number.parseInt(K,10));if($.length<2||$.some((K)=>Number.isNaN(K)))return null;return{major:$[0]||0,minor:$[1]||0,patch:$[2]||0}}compareVersions(X,Z){let $=this.parseVersion(X),K=this.parseVersion(Z);if(!$||!K)return 0;if($.major!==K.major)return $.major-K.major;if($.minor!==K.minor)return $.minor-K.minor;return $.patch-K.patch}async getComposerPackageMetadata(X){try{let $=(await this.fetchComposerPackage(X))?.package;if(!$?.versions)return;let K=Object.keys($.versions),Y=K.find((Q)=>!Q.includes("dev")&&!Q.includes("alpha")&&!Q.includes("beta"))??K[0],H=(Y?$.versions[Y]:void 0)??{};return{name:$.name??X,description:H.description,repository:H.source?.url??H.homepage,homepage:H.homepage,license:Array.isArray(H.license)?H.license.join(", "):H.license,author:H.authors?.[0]?.name,keywords:H.keywords,latestVersion:Y,versions:K,weeklyDownloads:$.downloads?.monthly,dependencies:H.require,devDependencies:H["require-dev"]}}catch(Z){this.logger.warn(`Failed to get Composer metadata for ${X}:`,Z);return}}async composerPackageExists(X){try{return await this.fetchComposerPackage(X)!==null}catch{return!1}}async getComposerLatestVersion(X){try{let $=(await this.fetchComposerPackage(X))?.package;if(!$?.versions)return null;let K=Object.keys($.versions),Y=K.filter((Q)=>!Q.includes("dev")&&!Q.includes("alpha")&&!Q.includes("beta")&&!Q.includes("rc"));if(Y.length===0)return K[0]||null;let H=Y.sort((Q,z)=>{try{if(typeof Bun<"u"&&Bun.semver)return Bun.semver.order(Q,z);return Q.localeCompare(z,void 0,{numeric:!0})}catch{return Q.localeCompare(z)}});return H[H.length-1]||null}catch(Z){return this.logger.warn(`Failed to get latest Composer version for ${X}:`,Z),null}}getComposerReleaseNotesUrl(X,Z){if(!Z?.repository)return;let $=Z.repository.match(/github\.com[/:]([^/]+\/[^/]+)/);if($)return`https://github.com/${$[1].replace(".git","")}/releases`;return}getComposerChangelogUrl(X,Z){if(!Z?.repository)return;let $=Z.repository.match(/github\.com[/:]([^/]+\/[^/]+)/);if($)return`https://github.com/${$[1].replace(".git","")}/blob/main/CHANGELOG.md`;return}extractConstraintBaseVersion(X){let Z=X.match(/^[\^~>=<]*([\d.]+)/);if(Z)return Z[1];return null}async findBestConstraintUpdates(X,Z,$){let{getUpdateType:K}=await import("./chunk-z4btj7s0.js"),Y=[],H=this.parseVersion($);if(!H)return[];let Q=null,z=null,G=null;for(let _ of Z){if(_.includes("dev")||_.includes("alpha")||_.includes("beta")||_.includes("RC"))continue;let I=this.parseVersion(_);if(!I)continue;if(this.compareVersions(_,$)<=0)continue;let L=K($,_);if(L==="patch"&&I.major===H.major&&I.minor===H.minor){if(!Q||this.compareVersions(_,Q)>0)Q=_}else if(L==="minor"&&I.major===H.major){if(!z||this.compareVersions(_,z)>0)z=_}else if(L==="major"){if(!G||this.compareVersions(_,G)>0)G=_}}if(Q)Y.push({version:Q,type:"patch"});if(z)Y.push({version:z,type:"minor"});if(G)Y.push({version:G,type:"major"});return Y}async getWorkspaceOutdatedPackages(){try{let X=await this.getWorkspaceNames(),Z=await this.findPackageJsonFiles(),$=[];this.logger.info(`Found ${X.length} workspace packages to check`);for(let K of X)try{let Y=await this.runBunOutdatedForWorkspace(K);$.push(...Y)}catch(Y){this.logger.warn(`Failed to check workspace ${K}:`,Y)}this.logger.info(`Checking ${Z.length} package.json files directly`);for(let K of Z){if(K==="package.json")continue;try{let Y=F.join(this.projectPath,K),H=q.readFileSync(Y,"utf-8"),Q=JSON.parse(H),z={...Q.dependencies,...Q.devDependencies,...Q.peerDependencies,...Q.optionalDependencies};for(let[G,_]of Object.entries(z)){if(typeof _!=="string"||_.startsWith("workspace:"))continue;if($.some((I)=>I.name===G))continue;try{let I=await this.getLatestVersion(G);if(I){let W=this.cleanVersionRange(_);if(W&&Bun.semver.order(W,I)<0)$.push({name:G,current:W,update:I,latest:I,file:K})}}catch{continue}}}catch(Y){this.logger.warn(`Failed to check packages in ${K}:`,Y)}}return this.logger.info(`Found ${$.length} outdated packages across workspaces`),$}catch(X){return this.logger.warn("Failed to check workspace packages:",X),[]}}async getWorkspaceNames(){let X=[],Z=await this.findPackageJsonFiles();for(let $ of Z)try{let K=F.join(this.projectPath,$),Y=q.readFileSync(K,"utf-8"),H=JSON.parse(Y);if(H.name&&$!=="package.json")X.push(H.name)}catch(K){this.logger.warn(`Failed to parse package.json ${$}:`,K)}return X}async findPackageJsonFiles(){let X=[],Z=async($,K="")=>{try{let Y=await q.promises.readdir($);for(let H of Y){let Q=F.join($,H),z=K?F.join(K,H):H,G=await q.promises.stat(Q);if(G.isDirectory()){if(!this.shouldSkipDirectory(H))await Z(Q,z)}else if(G.isFile()&&H==="package.json")X.push(z)}}catch{}};return await Z(this.projectPath),X}shouldSkipDirectory(X){return h(X)}async findPackageLocation(X){let Z=await this.findPackageJsonFiles();for(let $ of Z)try{let K=F.join(this.projectPath,$),Y=q.readFileSync(K,"utf-8"),H=JSON.parse(Y);if({...H.dependencies,...H.devDependencies,...H.peerDependencies,...H.optionalDependencies}[X])return $}catch{continue}return null}async getPackageVersionReleaseDate(X,Z){try{let K=(await this.fetchPackument(X))?.time?.[Z];if(!K)return null;let Y=new Date(K);return Number.isNaN(Y.getTime())?null:Y}catch($){return this.logger.debug(`Failed to get release date for ${X}@${Z}:`,$),null}}async getGitHubActionReleaseDate(X,Z){try{let[$,K]=X.split("/");if(!$||!K)return null;let Y=`${y(this.config)}/repos/${$}/${K}/releases/tags/${encodeURIComponent(Z)}`,H=await V(Y,{headers:g(this.config)});if(!H?.published_at)return null;let Q=new Date(H.published_at);return Number.isNaN(Q.getTime())?null:Q}catch($){return this.logger.debug(`Failed to get GitHub Action release date for ${X}@${Z}:`,$),null}}async getComposerPackageReleaseDate(X,Z){try{let K=(await this.fetchComposerPackage(X))?.package?.versions?.[Z]?.time;if(!K)return null;let Y=new Date(K);return Number.isNaN(Y.getTime())?null:Y}catch($){return this.logger.debug(`Failed to get Composer package release date for ${X}@${Z}:`,$),null}}async getDockerImageReleaseDate(X,Z){try{return this.logger.debug(`Docker image release date checking not fully implemented for ${X}:${Z}`),null}catch($){return this.logger.debug(`Failed to get Docker image release date for ${X}:${Z}:`,$),null}}async meetsMinimumReleaseAge(X,Z,$,K){let Y=K??this.config?.packages?.minimumReleaseAge??0,H=this.config?.packages?.minimumReleaseAgeExclude??[];if(Y===0)return!0;if(H.includes(X))return this.logger.debug(`Package ${X} is excluded from minimum release age requirement`),!0;let Q=null;switch($){case"github-actions":Q=await this.getGitHubActionReleaseDate(X,Z);break;case"require":case"require-dev":Q=await this.getComposerPackageReleaseDate(X,Z);break;case"docker-image":Q=await this.getDockerImageReleaseDate(X,Z);break;default:Q=await this.getPackageVersionReleaseDate(X,Z);break}if(!Q)return this.logger.warn(`Could not determine release date for ${X}@${Z} (${$||"unknown type"}), allowing update`),!0;let G=(new Date().getTime()-Q.getTime())/60000,_=G>=Y;if(!_)this.logger.info(`Package ${X}@${Z} (${$||"unknown type"}) is too new (${Math.round(G)} minutes old, minimum: ${Y} minutes)`);return _}async runBunOutdatedForWorkspace(X){try{C(X,"workspace name");let Z=await this.runCommand("bun",["outdated","--filter",X]);return this.parseBunOutdatedOutput(Z).map((K)=>({...K,workspace:X}))}catch(Z){return this.logger.warn(`Failed to run bun outdated for workspace ${X}:`,Z),[]}}}
|
|
6
|
+
export{P as gd,M as hd,m as id,J as jd,k as kd};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Eh as V}from"./chunk-vpw7adwd.js";import{Jh as P}from"./chunk-b9szrnxw.js";import{Mh as M,Ph as Q}from"./chunk-x1w6q9tk.js";function X(z){if(z==="running")return"in_progress";if(z==="success"||z==="failed"||z==="canceled"||z==="skipped"||z==="manual")return"completed";return"queued"}function Y(z){switch(z){case"success":return"success";case"failed":return"failure";case"canceled":return"cancelled";case"skipped":case"manual":return"skipped";default:return null}}class Z{token;apiUrl;logger;projectId;constructor(z,A,F,G,H){this.token=z;this.apiUrl=(G??"https://gitlab.com/api/v4").replace(/\/+$/,""),this.logger=H??Q(),this.projectId=encodeURIComponent(`${A}/${F}`)}capabilities(){return{pinIssues:!1,checkRuns:!0,inlineReviewComments:!0,reviewSuggestions:!0,nativeAutoMerge:!0,commentReactions:!0,ciLogs:!0,ciRuns:!0,reviewThreads:!0,teamReviewers:!1,draftPullRequests:!0,permissionLookup:!0,branchHousekeeping:!0,reopenPullRequests:!0,labels:!0}}async request(z,A,F,G={}){let H=await P(`${this.apiUrl}${A}`,{method:z,headers:{"PRIVATE-TOKEN":this.token,Accept:G.raw?"text/plain":"application/json","User-Agent":"buddy",...F?{"Content-Type":"application/json"}:{}},...F?{body:JSON.stringify(F)}:{}});if(!H.ok){let K=await H.text().catch(()=>"");throw Error(`GitLab ${z} ${A} failed: ${H.status} ${K.slice(0,200)}`)}let J=await H.text();if(G.raw)return J;return J.trim()?JSON.parse(J):void 0}async optional(z,A,F={}){try{return await this.request(z,A,void 0,F)}catch(G){if(String(G).includes("404"))return null;throw G}}async branchExists(z){return await this.optional("GET",`/projects/${this.projectId}/repository/branches/${encodeURIComponent(z)}`)!==null}async createBranch(z,A){await this.request("POST",`/projects/${this.projectId}/repository/branches`,{branch:z,ref:A})}async deleteBranch(z){await this.request("DELETE",`/projects/${this.projectId}/repository/branches/${encodeURIComponent(z)}`)}async commitChanges(z,A,F,G="main"){if(F.length===0)return;if(await this.branchExists(z))await this.deleteBranch(z);await this.createBranch(z,G);let J=await Promise.all(F.map(async(K)=>{if(K.type==="delete")return{action:"delete",file_path:K.path};return{action:await this.getFileContent(K.path,G)!==null?"update":"create",file_path:K.path,content:K.content}}));await this.request("POST",`/projects/${this.projectId}/repository/commits`,{branch:z,commit_message:A,actions:J})}async getFileContent(z,A){let F=await this.optional("GET",`/projects/${this.projectId}/repository/files/${encodeURIComponent(z)}?ref=${encodeURIComponent(A)}`);if(!F?.content)return null;return F.encoding==="base64"?Buffer.from(F.content,"base64").toString("utf-8"):F.content}async createPullRequest(z){let A=await this.request("POST",`/projects/${this.projectId}/merge_requests`,{source_branch:z.head,target_branch:z.base,title:z.draft?`Draft: ${z.title}`:z.title,description:z.body,...z.labels?.length?{labels:z.labels.join(",")}:{},remove_source_branch:!0});return await this.assignPeople(A.iid,z),this.toPullRequest(A)}async assignPeople(z,A){let F=async(J=[])=>{return(await Promise.all(J.map(async(O)=>{return(await this.optional("GET",`/users?username=${encodeURIComponent(O)}`))?.[0]?.id??null}))).filter((O)=>O!==null)},[G,H]=await Promise.all([F(A.reviewers),F(A.assignees)]);if(G.length===0&&H.length===0)return;try{await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}`,{...G.length?{reviewer_ids:G}:{},...H.length?{assignee_ids:H}:{}})}catch(J){this.logger.warn(`\u26A0\uFE0F Could not assign reviewers on !${z}: ${M(J)}`)}}async getPullRequests(z="open"){let A=z==="all"?"state=all":z==="open"?"state=opened":"state=all",G=(await this.request("GET",`/projects/${this.projectId}/merge_requests?${A}&per_page=100`)).map((H)=>this.toPullRequest(H));return z==="closed"?G.filter((H)=>H.state!=="open"):G}async updatePullRequest(z,A){let F=await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}`,{...A.title!==void 0?{title:A.draft?`Draft: ${A.title}`:A.title}:{},...A.body!==void 0?{description:A.body}:{},...A.base!==void 0?{target_branch:A.base}:{},...A.labels!==void 0?{labels:A.labels.join(",")}:{}});return this.toPullRequest(F)}async closePullRequest(z){await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}`,{state_event:"close"})}async reopenPullRequest(z){await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}`,{state_event:"reopen"})}async mergePullRequest(z,A="squash"){await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}/merge`,{squash:A==="squash",should_remove_source_branch:!0})}async getPullRequestDiff(z){return((await this.request("GET",`/projects/${this.projectId}/merge_requests/${z}/changes`)).changes??[]).map((F)=>[`diff --git a/${F.old_path} b/${F.new_path}`,`--- a/${F.old_path}`,`+++ b/${F.new_path}`,F.diff.replace(/\n$/,"")].join(`
|
|
3
3
|
`)).join(`
|
|
4
4
|
`)}async getPullRequestHeadSha(z){return(await this.request("GET",`/projects/${this.projectId}/merge_requests/${z}`)).sha??""}async createComment(z,A){try{await this.request("POST",`/projects/${this.projectId}/merge_requests/${z}/notes`,{body:A})}catch(F){if(!String(F).includes("404"))throw F;await this.request("POST",`/projects/${this.projectId}/issues/${z}/notes`,{body:A})}}async createIssue(z){let A=await this.request("POST",`/projects/${this.projectId}/issues`,{title:z.title,description:z.body,...z.labels?.length?{labels:z.labels.join(",")}:{}});return this.toIssue(A)}async getIssues(z="open"){let A=z==="all"?"state=all":`state=${z==="open"?"opened":"closed"}`;return(await this.request("GET",`/projects/${this.projectId}/issues?${A}&per_page=100`)).map((G)=>this.toIssue(G))}async updateIssue(z,A){let F=await this.request("PUT",`/projects/${this.projectId}/issues/${z}`,{...A.title!==void 0?{title:A.title}:{},...A.body!==void 0?{description:A.body}:{},...A.labels!==void 0?{labels:A.labels.join(",")}:{}});return this.toIssue(F)}async closeIssue(z){await this.request("PUT",`/projects/${this.projectId}/issues/${z}`,{state_event:"close"})}async unpinIssue(z){return!1}async enableAutoMerge(z,A="squash"){try{return await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}/merge`,{merge_when_pipeline_succeeds:!0,squash:A==="squash",should_remove_source_branch:!0}),!0}catch(F){return this.logger.debug(`Could not queue !${z} for auto-merge: ${M(F)}`),!1}}async getPullRequestChecksState(z){let F=(await this.optional("GET",`/projects/${this.projectId}/merge_requests/${z}/pipelines`))?.[0]?.status;if(!F)return"none";if(F==="success")return"success";if(["failed","canceled"].includes(F))return"failure";if(["running","pending","created","waiting_for_resource","preparing","scheduled"].includes(F))return"pending";return"none"}async createReview(z,A){if(await this.request("POST",`/projects/${this.projectId}/merge_requests/${z}/notes`,{body:A.body}),!A.comments?.length)return{posted:!0,inlineComments:0};let G=(await this.optional("GET",`/projects/${this.projectId}/merge_requests/${z}/versions`))?.[0];if(!G)return this.logger.warn("\u26A0\uFE0F Could not resolve diff positions; inline comments were not posted"),{posted:!0,inlineComments:0};let H=0;for(let J of A.comments)try{await this.request("POST",`/projects/${this.projectId}/merge_requests/${z}/discussions`,{body:J.body,position:{position_type:"text",base_sha:G.base_commit_sha,start_sha:G.start_commit_sha,head_sha:G.head_commit_sha,new_path:J.path,old_path:J.path,...J.side==="RIGHT"?{new_line:J.line}:{old_line:J.line}}}),H++}catch(K){this.logger.debug(`Could not place a comment on ${J.path}:${J.line}: ${M(K)}`)}return{posted:!0,inlineComments:H}}async createCheckRun(z,A,F){try{await this.request("POST",`/projects/${this.projectId}/statuses/${A}`,{state:F.conclusion==="failure"?"failed":"success",name:z,description:F.title.slice(0,140)})}catch(G){this.logger.warn(`\u26A0\uFE0F Could not report status ${z}: ${M(G)}`)}}async reactToComment(z,A){let F={eyes:"eyes","+1":"thumbsup","-1":"thumbsdown",rocket:"rocket",confused:"confused"};try{await this.request("POST",`/projects/${this.projectId}/notes/${z}/award_emoji`,{name:F[A]??"eyes"})}catch(G){this.logger.debug(`Could not react to note ${z}: ${M(G)}`)}}async hasWriteAccess(z){return(await this.optional("GET",`/projects/${this.projectId}/members/all?query=${encodeURIComponent(z)}`)??[]).some((F)=>F.username===z&&F.access_level>=30)}async getWorkflowRunLogs(z){return this.optional("GET",`/projects/${this.projectId}/jobs/${z}/trace`,{raw:!0}).catch((A)=>{return this.logger.debug(`Could not read the trace for job ${z}: ${M(A)}`),null})}async listWorkflowRuns(z,A={}){let F=A.limit??20;try{return(await this.request("GET",`/projects/${this.projectId}/jobs?per_page=${Math.min(F*5,100)}`)??[]).filter((H)=>H.ref===z).map((H)=>({id:H.id,name:H.name??"",headSha:H.commit?.id??"",headBranch:H.ref??z,status:X(H.status),conclusion:Y(H.status),createdAt:new Date(H.created_at??new Date().toISOString())})).filter((H)=>!A.status||H.status===A.status).slice(0,F)}catch(G){return this.logger.debug(`Could not list CI jobs for ${z}: ${M(G)}`),[]}}async rerunWorkflowRun(z){try{return await this.request("POST",`/projects/${this.projectId}/jobs/${z}/retry`),!0}catch(A){return this.logger.warn(`Could not retry job ${z}: ${M(A)}`),!1}}async listReviewThreads(z){try{return(await this.request("GET",`/projects/${this.projectId}/merge_requests/${z}/discussions?per_page=100`)??[]).filter((F)=>(F.notes??[]).some((G)=>G.resolvable)).map((F)=>({id:F.id,isResolved:(F.notes??[]).every((G)=>!G.resolvable||G.resolved),...F.notes?.[0]?.position?.new_path?{path:F.notes[0].position.new_path}:{},authorLogins:(F.notes??[]).map((G)=>G.author?.username).filter((G)=>typeof G==="string")}))}catch(A){return this.logger.debug(`Could not read discussions on !${z}: ${M(A)}`),[]}}async resolveReviewThread(z,A){try{return await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}/discussions/${encodeURIComponent(A)}`,{resolved:!0}),!0}catch(F){return this.logger.warn(`Could not resolve discussion ${A}: ${M(F)}`),!1}}async getBuddyBranches(){return(await this.request("GET",`/projects/${this.projectId}/repository/branches?search=buddy&per_page=100`)).filter((A)=>V(A.name)).map((A)=>({name:A.name,sha:A.commit?.id??"",lastCommitDate:A.commit?.committed_date?new Date(A.commit.committed_date):new Date(0)}))}async getOrphanedBuddyBranches(){let[z,A]=await Promise.all([this.getBuddyBranches(),this.getPullRequests("open")]),F=new Set(A.map((G)=>G.head));return z.filter((G)=>!F.has(G.name))}async cleanupStaleBranches(z=7,A=!1){let F=new Date(Date.now()-z*24*60*60*1000),G=(await this.getOrphanedBuddyBranches()).filter((K)=>K.lastCommitDate<F);if(A)return{deleted:G.map((K)=>K.name),failed:[]};let H=[],J=[];for(let K of G)try{await this.deleteBranch(K.name),H.push(K.name)}catch{J.push(K.name)}return{deleted:H,failed:J}}toPullRequest(z){let A=Boolean(z.draft??z.work_in_progress)||/^(?:draft|wip):/i.test(z.title);return{number:z.iid,title:z.title.replace(/^(?:draft|wip):\s*/i,""),body:z.description??"",head:z.source_branch,base:z.target_branch,state:z.state==="merged"?"merged":z.state==="opened"?"open":"closed",url:z.web_url,createdAt:new Date(z.created_at),updatedAt:new Date(z.updated_at),...z.merged_at?{mergedAt:new Date(z.merged_at)}:{},author:z.author?.username??"",reviewers:(z.reviewers??[]).map((F)=>F.username),assignees:(z.assignees??[]).map((F)=>F.username),labels:z.labels??[],draft:A}}toIssue(z){return{number:z.iid,title:z.title,body:z.description??"",state:z.state==="closed"?"closed":"open",url:z.web_url,createdAt:new Date(z.created_at),updatedAt:new Date(z.updated_at),...z.closed_at?{closedAt:new Date(z.closed_at)}:{},author:z.author?.username??"",assignees:(z.assignees??[]).map((A)=>A.username),labels:z.labels??[]}}}
|
|
5
|
-
export{Z as
|
|
5
|
+
export{Z as Ch};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var j=Object.create;var{getPrototypeOf:k,defineProperty:i,getOwnPropertyNames:l}=Object;var m=Object.prototype.hasOwnProperty;function n(a){return this[a]}var o,p,q=(a,b,d)=>{var f=a!=null&&typeof a==="object";if(f){var g=b?o??=new WeakMap:p??=new WeakMap,h=g.get(a);if(h)return h}d=a!=null?j(k(a)):{};let c=b||!a||!a.__esModule?i(d,"default",{value:a,enumerable:!0}):d;for(let e of l(a))if(!m.call(c,e))i(c,e,{get:n.bind(a,e),enumerable:!0});if(f)g.set(a,c);return c};var r=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var s=import.meta.require;
|
|
3
|
-
export{q as
|
|
3
|
+
export{q as cl,r as dl,s as el};
|
|
@@ -4,4 +4,4 @@ var A=1,F=30000,K=/<!--\s*buddy:manifest\s+v(\d+)\s*([\s\S]*?)-->/;function Y(j)
|
|
|
4
4
|
<!-- buddy:manifest v1
|
|
5
5
|
${JSON.stringify(j)}
|
|
6
6
|
-->`}function G(j,q={}){return L(j.updates,{group:j.name,...q})}function Z(j){if(!j)return null;let q=j.match(K);if(!q)return null;try{let w=JSON.parse(q[2].trim());if(!D(w))return null;return{...w,schemaVersion:Number(w.schemaVersion)||Number(q[1])||1,updates:w.updates.filter(z)}}catch{return null}}function I(j){return Z(j)!==null}function $(j){return j.replace(K,"").trimEnd()}function N(j,q,w={}){return $(j)+L(q,w)}function P(j){return j.updates.map((q)=>({name:q.name,currentVersion:q.current,newVersion:q.target}))}function R(j){return[...new Set(j.updates.map((q)=>q.file).filter(Boolean))]}function D(j){if(typeof j!=="object"||j===null)return!1;return Array.isArray(j.updates)}function z(j){if(typeof j!=="object"||j===null)return!1;let q=j;return typeof q.name==="string"&&typeof q.current==="string"&&typeof q.target==="string"}
|
|
7
|
-
export{A as
|
|
7
|
+
export{A as pg,F as qg,L as rg,G as sg,Z as tg,I as ug,$ as vg,N as wg,P as xg,R as yg};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import"./chunk-rb1fh9vd.js";import{$d as n,Od as a,Pd as b,Qd as c,Rd as d,Sd as e,Td as f,Ud as g,Vd as h,Wd as i,Xd as j,Yd as k,Zd as l,_d as m,ae as o,be as p,ce as q,de as r,ee as s,fe as t}from"./chunk-0g4ybxwj.js";import"./chunk-142zh7e5.js";import"./chunk-24xvskkf.js";import"./chunk-x1w6q9tk.js";import"./chunk-kbvj6qxc.js";export{r as syntaxAnalyzer,q as shellcheckAnalyzer,p as secretsAnalyzer,b as runTool,t as runAnalyzers,e as relativize,d as parseToolJson,j as offsetToLine,n as markdownlintAnalyzer,c as mapSeverity,m as linterAnalyzer,i as hadolintAnalyzer,h as githubActionsAnalyzer,l as detectLinter,f as commandExists,g as actionlintAnalyzer,a as TOOL_TIMEOUT_MS,o as SECRET_RULES,k as LINTER_SPECS,s as BUILTIN_ANALYZERS};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{execSync as h}from"child_process";import{existsSync as P,mkdirSync as F,mkdtempSync as L,rmSync as V,writeFileSync as U}from"fs";import{tmpdir as G}from"os";import{join as w}from"path";var i=new Set,A=!1;function q(){if(A)return;A=!0;let a=()=>{for(let e of i)try{h(`pantry stop ${e}`,{stdio:"ignore",timeout:1e4})}catch{}i.clear()};process.on("exit",a),process.on("SIGINT",()=>{a(),process.exit(130)}),process.on("SIGTERM",()=>{a(),process.exit(143)})}function o(a,e=!1){let s={encoding:"utf-8",timeout:30000,stdio:e?"pipe":["pipe","pipe","pipe"]};return h(`pantry ${a}`,s)}function O(a){let e=a.match(/Name:\s+(\S+)/)?.[1]??"",s=/Status:\s+running/i.test(a),t=a.match(/Port:\s+(\d+)/),r=a.match(/PID:\s+(\d+)/),S=a.match(/Data Dir:\s+(.+)/);return{name:e,running:s,port:t?Number.parseInt(t[1],10):null,pid:r?Number.parseInt(r[1],10):null,dataDir:S?S[1].trim():null}}class n{config;_startedByUs=!1;constructor(a){this.config={name:a.name,port:a.port??0,readyTimeoutMs:a.readyTimeoutMs??15000,pollIntervalMs:a.pollIntervalMs??200,quiet:a.quiet??!0}}static isAvailable(){try{return h("pantry --version",{stdio:"ignore",timeout:5000}),!0}catch{return!1}}status(){try{let a=o(`inspect ${this.config.name}`,!0);return O(a)}catch{return{name:this.config.name,running:!1,port:null,pid:null,dataDir:null}}}isRunning(){return this.status().running}getPort(){return this.status().port}async start(){if(q(),this.isRunning())return this.status();return o(`start ${this.config.name}`,this.config.quiet),this._startedByUs=!0,i.add(this.config.name),await this.waitReady(),this.status()}async stop(){if(!this._startedByUs)return;try{o(`stop ${this.config.name}`,this.config.quiet)}catch{}i.delete(this.config.name),this._startedByUs=!1}async forceStop(){try{o(`stop ${this.config.name}`,this.config.quiet)}catch{}i.delete(this.config.name),this._startedByUs=!1}async ensureRunning(){if(this.isRunning())return this.status();return this.start()}async waitReady(){let a=Date.now()+this.config.readyTimeoutMs;while(Date.now()<a){if(this.isRunning())return;await new Promise((e)=>setTimeout(e,this.config.pollIntervalMs))}throw Error(`Service '${this.config.name}' did not become ready within ${this.config.readyTimeoutMs}ms`)}}var v=new n({name:"mysql"});async function c(a){let e=await v.ensureRunning();return{port:a?.port??e.port??3306,host:a?.host??"localhost",database:a?.database??"test",username:a?.username??"root"}}async function u(){await v.stop()}function I(a){let e=null;return{get connection(){if(!e)throw Error("MySQL not started. Ensure beforeAll has run.");return e},beforeAll:async()=>{e=await c(a)},afterAll:async()=>{await u(),e=null}}}async function D(a,e){let s=await c(e);try{return await a(s)}finally{if(e?.stopAfter!==!1)await u()}}var R=new n({name:"postgres"});async function p(a){let e=await R.ensureRunning();return{port:a?.port??e.port??5432,host:a?.host??"localhost",database:a?.database??"postgres",username:a?.username??process.env.USER??"postgres"}}async function g(){await R.stop()}function T(a){let e=null;return{get connection(){if(!e)throw Error("Postgres not started. Ensure beforeAll has run.");return e},beforeAll:async()=>{e=await p(a)},afterAll:async()=>{await g(),e=null}}}async function C(a,e){let s=await p(e);try{return await a(s)}finally{if(e?.stopAfter!==!1)await g()}}var M=new n({name:"redis"});async function f(a){let e=await M.ensureRunning(),s=a?.port??e.port??6379,t=a?.host??"localhost";return{port:s,host:t,url:`redis://${t}:${s}`}}async function d(){await M.stop()}function E(a){let e=null;return{get connection(){if(!e)throw Error("Redis not started. Ensure beforeAll has run.");return e},beforeAll:async()=>{e=await f(a)},afterAll:async()=>{await d(),e=null}}}async function b(a,e){let s=await f(e);try{return await a(s)}finally{if(e?.stopAfter!==!1)await d()}}var l=new Set,k=!1;function H(){if(k)return;k=!0;let a=()=>{for(let e of l)try{if(P(e))V(e,{recursive:!0,force:!0})}catch{}l.clear()};process.on("exit",a),process.on("SIGINT",()=>{a(),process.exit(130)}),process.on("SIGTERM",()=>{a(),process.exit(143)})}function m(a="pantry-test-"){H();let e=L(w(G(),a));return l.add(e),e}function y(a){l.delete(a);try{if(P(a))V(a,{recursive:!0,force:!0})}catch{}}async function N(a,e){let s=m(a);try{return await e(s)}finally{y(s)}}function x(a,e){let s=m(a);try{return e(s)}finally{y(s)}}function _(a,e,s){let t=w(a,e),r=t.substring(0,t.lastIndexOf("/"));if(r&&!P(r))F(r,{recursive:!0});return U(t,s),t}function B(a,e){let s=w(a,e);return F(s,{recursive:!0}),s}var $={createTempDir:m,createTestDir:B,createTestFile:_,PantryService:n,removeTempDir:y,startMysql:c,startPostgres:p,startRedis:f,stopMysql:u,stopPostgres:g,stopRedis:d,useMysql:I,usePostgres:T,useRedis:E,withMysql:D,withPostgres:C,withRedis:b,withTempDir:N,withTempDirSync:x};export{n as
|
|
2
|
+
import{execSync as h}from"child_process";import{existsSync as P,mkdirSync as F,mkdtempSync as L,rmSync as V,writeFileSync as U}from"fs";import{tmpdir as G}from"os";import{join as w}from"path";var i=new Set,A=!1;function q(){if(A)return;A=!0;let a=()=>{for(let e of i)try{h(`pantry stop ${e}`,{stdio:"ignore",timeout:1e4})}catch{}i.clear()};process.on("exit",a),process.on("SIGINT",()=>{a(),process.exit(130)}),process.on("SIGTERM",()=>{a(),process.exit(143)})}function o(a,e=!1){let s={encoding:"utf-8",timeout:30000,stdio:e?"pipe":["pipe","pipe","pipe"]};return h(`pantry ${a}`,s)}function O(a){let e=a.match(/Name:\s+(\S+)/)?.[1]??"",s=/Status:\s+running/i.test(a),t=a.match(/Port:\s+(\d+)/),r=a.match(/PID:\s+(\d+)/),S=a.match(/Data Dir:\s+(.+)/);return{name:e,running:s,port:t?Number.parseInt(t[1],10):null,pid:r?Number.parseInt(r[1],10):null,dataDir:S?S[1].trim():null}}class n{config;_startedByUs=!1;constructor(a){this.config={name:a.name,port:a.port??0,readyTimeoutMs:a.readyTimeoutMs??15000,pollIntervalMs:a.pollIntervalMs??200,quiet:a.quiet??!0}}static isAvailable(){try{return h("pantry --version",{stdio:"ignore",timeout:5000}),!0}catch{return!1}}status(){try{let a=o(`inspect ${this.config.name}`,!0);return O(a)}catch{return{name:this.config.name,running:!1,port:null,pid:null,dataDir:null}}}isRunning(){return this.status().running}getPort(){return this.status().port}async start(){if(q(),this.isRunning())return this.status();return o(`start ${this.config.name}`,this.config.quiet),this._startedByUs=!0,i.add(this.config.name),await this.waitReady(),this.status()}async stop(){if(!this._startedByUs)return;try{o(`stop ${this.config.name}`,this.config.quiet)}catch{}i.delete(this.config.name),this._startedByUs=!1}async forceStop(){try{o(`stop ${this.config.name}`,this.config.quiet)}catch{}i.delete(this.config.name),this._startedByUs=!1}async ensureRunning(){if(this.isRunning())return this.status();return this.start()}async waitReady(){let a=Date.now()+this.config.readyTimeoutMs;while(Date.now()<a){if(this.isRunning())return;await new Promise((e)=>setTimeout(e,this.config.pollIntervalMs))}throw Error(`Service '${this.config.name}' did not become ready within ${this.config.readyTimeoutMs}ms`)}}var v=new n({name:"mysql"});async function c(a){let e=await v.ensureRunning();return{port:a?.port??e.port??3306,host:a?.host??"localhost",database:a?.database??"test",username:a?.username??"root"}}async function u(){await v.stop()}function I(a){let e=null;return{get connection(){if(!e)throw Error("MySQL not started. Ensure beforeAll has run.");return e},beforeAll:async()=>{e=await c(a)},afterAll:async()=>{await u(),e=null}}}async function D(a,e){let s=await c(e);try{return await a(s)}finally{if(e?.stopAfter!==!1)await u()}}var R=new n({name:"postgres"});async function p(a){let e=await R.ensureRunning();return{port:a?.port??e.port??5432,host:a?.host??"localhost",database:a?.database??"postgres",username:a?.username??process.env.USER??"postgres"}}async function g(){await R.stop()}function T(a){let e=null;return{get connection(){if(!e)throw Error("Postgres not started. Ensure beforeAll has run.");return e},beforeAll:async()=>{e=await p(a)},afterAll:async()=>{await g(),e=null}}}async function C(a,e){let s=await p(e);try{return await a(s)}finally{if(e?.stopAfter!==!1)await g()}}var M=new n({name:"redis"});async function f(a){let e=await M.ensureRunning(),s=a?.port??e.port??6379,t=a?.host??"localhost";return{port:s,host:t,url:`redis://${t}:${s}`}}async function d(){await M.stop()}function E(a){let e=null;return{get connection(){if(!e)throw Error("Redis not started. Ensure beforeAll has run.");return e},beforeAll:async()=>{e=await f(a)},afterAll:async()=>{await d(),e=null}}}async function b(a,e){let s=await f(e);try{return await a(s)}finally{if(e?.stopAfter!==!1)await d()}}var l=new Set,k=!1;function H(){if(k)return;k=!0;let a=()=>{for(let e of l)try{if(P(e))V(e,{recursive:!0,force:!0})}catch{}l.clear()};process.on("exit",a),process.on("SIGINT",()=>{a(),process.exit(130)}),process.on("SIGTERM",()=>{a(),process.exit(143)})}function m(a="pantry-test-"){H();let e=L(w(G(),a));return l.add(e),e}function y(a){l.delete(a);try{if(P(a))V(a,{recursive:!0,force:!0})}catch{}}async function N(a,e){let s=m(a);try{return await e(s)}finally{y(s)}}function x(a,e){let s=m(a);try{return e(s)}finally{y(s)}}function _(a,e,s){let t=w(a,e),r=t.substring(0,t.lastIndexOf("/"));if(r&&!P(r))F(r,{recursive:!0});return U(t,s),t}function B(a,e){let s=w(a,e);return F(s,{recursive:!0}),s}var $={createTempDir:m,createTestDir:B,createTestFile:_,PantryService:n,removeTempDir:y,startMysql:c,startPostgres:p,startRedis:f,stopMysql:u,stopPostgres:g,stopRedis:d,useMysql:I,usePostgres:T,useRedis:E,withMysql:D,withPostgres:C,withRedis:b,withTempDir:N,withTempDirSync:x};export{n as Dg,c as Eg,u as Fg,I as Gg,D as Hg,p as Ig,g as Jg,T as Kg,C as Lg,f as Mg,d as Ng,E as Og,b as Pg,m as Qg,y as Rg,N as Sg,x as Tg,_ as Ug,B as Vg,$ as Wg};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{kd as a}from"./chunk-jsf2322c.js";import"./chunk-bnp0r4eh.js";import"./chunk-0f1xye20.js";import"./chunk-xdrvb89m.js";import"./chunk-knpdntnh.js";import"./chunk-54er1whp.js";import"./chunk-ktn47bq8.js";import"./chunk-2z9pkk1y.js";import"./chunk-b9szrnxw.js";import"./chunk-x1w6q9tk.js";import"./chunk-z05djfac.js";import"./chunk-kbvj6qxc.js";export{a as RegistryClient};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Eb as _,Fb as y}from"./chunk-q2tjkhez.js";import{Mb as g,Nb as r,Ob as e,Pb as jj}from"./chunk-5yfaptmp.js";import{Wb as n,Xb as o,Yb as t}from"./chunk-
|
|
2
|
+
import{Eb as _,Fb as y}from"./chunk-q2tjkhez.js";import{Mb as g,Nb as r,Ob as e,Pb as jj}from"./chunk-5yfaptmp.js";import{Wb as n,Xb as o,Yb as t}from"./chunk-59993g25.js";import{fc as s}from"./chunk-va3k91tf.js";import{fe as i}from"./chunk-0g4ybxwj.js";import{se as S}from"./chunk-b6a5txek.js";import{Sf as b,Tf as m}from"./chunk-24xvskkf.js";import{Ph as Y}from"./chunk-x1w6q9tk.js";var C=["critical","major","minor","nit"],w={type:"object",properties:{summary:{type:"string",description:"One paragraph on what this change does"},effort:{type:"integer",description:"Reviewer effort, 1 (trivial) to 5 (demanding)"},walkthrough:{type:"array",items:{type:"object",properties:{path:{type:"string"},description:{type:"string"}},required:["path","description"],additionalProperties:!1}},findings:{type:"array",items:{type:"object",properties:{path:{type:"string",description:"Repository-relative path"},line:{type:"integer",description:"Line number on the new side of the diff"},severity:{type:"string",enum:C},category:{type:"string",description:"Short slug, e.g. correctness or security"},message:{type:"string",description:"What is wrong and why it matters"},suggestion:{type:"string",description:"Replacement code, only when the fix is mechanical"}},required:["path","line","severity","category","message"],additionalProperties:!1}}},required:["summary","effort","walkthrough","findings"],additionalProperties:!1};function I(J){let j=J.message.toLowerCase().replace(/\s+/g," ").trim().slice(0,120);return`${J.path}:${J.category}:${j}`}function N(J,j){let Q=[],Z=[];for(let $ of J)if(j.get($.path)?.has($.line))Q.push($);else Z.push($);return Q.sort(($,X)=>C.indexOf($.severity)-C.indexOf(X.severity)),{valid:Q,dropped:Z}}function v(J,j){let Q=[],Z=new Set;for(let $ of J){let X=I($);if(j.has(X)||Z.has(X))continue;Z.add(X),Q.push($)}return Q}var Jj=[/(?:^|\/)(?:bun\.lockb?|package-lock\.json|yarn\.lock|pnpm-lock\.yaml|composer\.lock|pantry\.lock)$/,/(?:^|\/)(?:dist|build|out|coverage|node_modules|vendor)\//,/\.min\.(?:js|css)$/,/(?:^|\/)(?:.*\.snap)$/],Qj=`You are reviewing a pull request diff.
|
|
3
3
|
|
|
4
4
|
Report only defects you can point at in the diff. A review that invents
|
|
5
5
|
findings to look thorough is worse than one that reports nothing, so say
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Eh as Z}from"./chunk-vpw7adwd.js";import{Ph as K}from"./chunk-x1w6q9tk.js";var R=".buddy/reports.jsonl",U=52;function X(M){if(!M?.trim())return[];let E=[];for(let j of M.split(`
|
|
3
3
|
`)){if(!j.trim())continue;try{let N=JSON.parse(j);if(N?.period&&N.generatedAt&&N.health&&N.activity)E.push(N)}catch{continue}}return E}function x(M,E){return`${[...M,E].slice(-U).map((N)=>JSON.stringify(N)).join(`
|
|
4
4
|
`)}
|
|
5
5
|
`}function W(M,E){for(let j=M.length-1;j>=0;j--)if(M[j].period===E)return M[j];return null}async function _(M,E,j=K()){try{return X(await M.getFileContent(R,E))}catch(N){return j.debug(`No report history at ${R}: ${N}`),[]}}var k=["7d","30d","90d"],O={"7d":7,"30d":30,"90d":90};function A(M){let E=new Date(M.now.getTime()-O[M.period]*24*60*60*1000),j=M.pullRequests.filter((q)=>M.branchPrefix?q.head.startsWith(M.branchPrefix):Z(q.head)),N=j.filter((q)=>q.createdAt>=E),C=j.filter((q)=>q.mergedAt!==void 0&&q.mergedAt>=E),z=j.filter((q)=>q.state==="closed"&&q.mergedAt===void 0&&q.updatedAt>=E),F=C.map((q)=>(q.mergedAt.getTime()-q.createdAt.getTime())/3600000).sort((q,Q)=>q-Q),H=Object.values(M.dependenciesByEcosystem).reduce((q,Q)=>q+Q,0),J=M.updates.length;return{period:M.period,generatedAt:M.now.toISOString(),health:{byEcosystem:{...M.dependenciesByEcosystem},total:H,outdated:J,outdatedPercent:H>0?Math.round(J/H*100):0,majorBehind:M.updates.filter((q)=>q.updateType==="major").length,vulnerable:M.updates.filter((q)=>(q.securityAdvisories?.length??0)>0).length,deprecated:M.deprecated??0,drifted:M.drifted??0},activity:{opened:N.length,merged:C.length,closed:z.length,open:j.filter((q)=>q.state==="open").length,medianHoursToMerge:L(F),mergeRate:N.length>0?Math.round(C.length/N.length*100):0}}}function L(M){if(M.length===0)return null;let E=Math.floor(M.length/2),j=M.length%2===0?(M[E-1]+M[E])/2:M[E];return Math.round(j*10)/10}function S(M,E){if(!E)return{};let j=new Set(["merged","mergeRate"]),N=[["outdated",M.health.outdated,E.health.outdated],["majorBehind",M.health.majorBehind,E.health.majorBehind],["vulnerable",M.health.vulnerable,E.health.vulnerable],["deprecated",M.health.deprecated,E.health.deprecated],["opened",M.activity.opened,E.activity.opened],["merged",M.activity.merged,E.activity.merged],["mergeRate",M.activity.mergeRate,E.activity.mergeRate]],C={};for(let[z,F,H]of N){let J=F-H;C[z]={current:F,previous:H,change:J,improved:j.has(z)?J>=0:J<=0}}return C}var $="<!-- buddy:report -->";function G(M){if(!M||M.change===0)return"\u2014";let E=M.change>0?"\u25B2":"\u25BC",j=M.change>0?"+":"";return`${E} ${j}${M.change}${M.improved?"":" \u26A0\uFE0F"}`}function T(M,E={}){let j=O[M.period],N=[$,"",`## Dependency report \u2014 last ${j} days`,"",`Generated ${M.generatedAt.slice(0,10)}.`,"","### Dependency health","","| Metric | Value | Change |","| --- | --- | --- |",`| Total dependencies | ${M.health.total} | |`,`| Outdated | ${M.health.outdated} (${M.health.outdatedPercent}%) | ${G(E.outdated)} |`,`| A major behind | ${M.health.majorBehind} | ${G(E.majorBehind)} |`,`| With known advisories | ${M.health.vulnerable} | ${G(E.vulnerable)} |`,`| Deprecated | ${M.health.deprecated} | ${G(E.deprecated)} |`];if(M.health.drifted>0)N.push(`| Held back by a dependant | ${M.health.drifted} | |`);N.push("","### By ecosystem","");let C=Object.entries(M.health.byEcosystem).filter(([,z])=>z>0).sort(([,z],[,F])=>F-z);if(C.length===0)N.push("No dependencies detected.");else{N.push("| Ecosystem | Dependencies |","| --- | --- |");for(let[z,F]of C)N.push(`| ${z} | ${F} |`)}if(N.push("","### Bot activity","","| Metric | Value | Change |","| --- | --- | --- |",`| Pull requests opened | ${M.activity.opened} | ${G(E.opened)} |`,`| Merged | ${M.activity.merged} | ${G(E.merged)} |`,`| Closed without merging | ${M.activity.closed} | |`,`| Currently open | ${M.activity.open} | |`),M.activity.medianHoursToMerge!==null)N.push(`| Median time to merge | ${w(M.activity.medianHoursToMerge)} | |`);if(N.push(`| Merged vs opened | ${M.activity.mergeRate}% | ${G(E.mergeRate)} |`),N.push("",`_"Merged vs opened" compares both counts within the same ${j}-day window, so`,"recently opened pull requests depress it by definition._"),Object.keys(E).length===0)N.push("","_No previous report to compare against; this is the baseline._");return N.join(`
|