@buddysh/buddy 0.11.1 → 0.11.3
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 +122 -0
- package/README.md +54 -43
- package/bin/cli.ts +282 -135
- package/dist/bin/cli.d.ts +5 -1
- package/dist/bin/cli.js +84 -91
- package/dist/chunk-05me15qw.js +2 -0
- package/dist/{chunk-bxfc4g2x.js → chunk-08x5b93v.js} +2 -13
- package/dist/chunk-0hc97k0t.js +44 -0
- package/dist/chunk-0paakbpj.js +2 -0
- package/dist/{chunk-hfvezfxh.js → chunk-0scz1dv5.js} +1 -1
- package/dist/{chunk-sp818c27.js → chunk-0w695m54.js} +5 -5
- package/dist/{chunk-vyapg8ca.js → chunk-11hdrnf6.js} +3 -3
- package/dist/{chunk-5k40mwd4.js → chunk-193abzy6.js} +1 -1
- package/dist/chunk-19zyq15p.js +2 -0
- package/dist/{chunk-q9n79dd3.js → chunk-1cpdz49v.js} +1 -1
- package/dist/{chunk-thaxgm5p.js → chunk-1qgr52wx.js} +1 -1
- package/dist/chunk-24c2ab29.js +2 -0
- package/dist/chunk-25sz1y7j.js +16 -0
- package/dist/chunk-28y7eayr.js +2 -0
- package/dist/chunk-2et8yavs.js +3 -0
- package/dist/chunk-2wj5xtdn.js +2 -0
- package/dist/{chunk-7mgec8kb.js → chunk-3901s7h9.js} +1 -1
- package/dist/{chunk-xvptf9jy.js → chunk-3cvng2nz.js} +2 -2
- package/dist/chunk-3fzbvs2p.js +2 -0
- package/dist/chunk-3pqra420.js +2 -0
- package/dist/{chunk-yk23nc4t.js → chunk-40znfg3x.js} +1 -1
- package/dist/chunk-428c5652.js +2 -0
- package/dist/chunk-49znmbh8.js +2 -0
- package/dist/chunk-4jyw358y.js +79 -0
- package/dist/chunk-5044y9en.js +5 -0
- package/dist/chunk-5av2vnvv.js +3 -0
- package/dist/chunk-5yfaptmp.js +7 -0
- package/dist/{chunk-h7hs95wn.js → chunk-61xecp1z.js} +2 -2
- package/dist/chunk-68fw3ma0.js +2 -0
- package/dist/{chunk-9h04nskh.js → chunk-69qyr9ef.js} +1 -1
- package/dist/{chunk-vh504tcv.js → chunk-6p4qz8qv.js} +2 -2
- package/dist/chunk-86x1vsjw.js +2 -0
- package/dist/{chunk-r3zyw8x0.js → chunk-8fw0v7bv.js} +2 -2
- package/dist/chunk-8hjvthz4.js +92 -0
- package/dist/chunk-90zmqn5k.js +2 -0
- package/dist/chunk-96ht6hwd.js +4 -0
- package/dist/chunk-97qf7mdt.js +2 -0
- package/dist/chunk-a4hzzn28.js +2 -0
- package/dist/chunk-aa277p5r.js +2 -0
- package/dist/chunk-b1w41hfs.js +2 -0
- package/dist/chunk-b357cgb0.js +2 -0
- package/dist/chunk-b9escac0.js +4 -0
- package/dist/{chunk-56q4pwb5.js → chunk-be629jhq.js} +2 -2
- package/dist/chunk-bffxf4xy.js +2 -0
- package/dist/chunk-bmnx3s41.js +38 -0
- package/dist/chunk-brfyymhf.js +2 -0
- package/dist/chunk-c3es7pgf.js +2 -0
- package/dist/{chunk-9750tenz.js → chunk-c8rzx3a1.js} +1 -1
- package/dist/{chunk-tzs22es2.js → chunk-cgvt98pd.js} +1 -1
- package/dist/chunk-cs066zt9.js +5 -0
- package/dist/chunk-cwfkm7h9.js +3 -0
- package/dist/chunk-dgfb8k0h.js +2 -0
- package/dist/chunk-ds4stft2.js +2 -0
- package/dist/chunk-e0gweha1.js +2 -0
- package/dist/chunk-e2t5jq26.js +106 -0
- package/dist/{chunk-1h3ey7k5.js → chunk-e68nf7cm.js} +1 -1
- package/dist/chunk-emb5v4wv.js +2 -0
- package/dist/chunk-emyvrx5t.js +2 -0
- package/dist/{chunk-16yqbccr.js → chunk-eseshkd0.js} +1 -1
- package/dist/chunk-f53y8ans.js +3 -0
- package/dist/chunk-fjp3a7hp.js +26 -0
- package/dist/chunk-fpnjpgrb.js +2 -0
- package/dist/chunk-fr5c326k.js +2 -0
- package/dist/chunk-g24hav8e.js +370 -0
- package/dist/{chunk-6md7qf2g.js → chunk-g30dr44w.js} +2 -2
- package/dist/chunk-gkpd5nw2.js +2 -0
- package/dist/chunk-hd5j9e3c.js +2 -0
- package/dist/{chunk-akffynkc.js → chunk-hfjywbbc.js} +1 -1
- package/dist/chunk-hmskwy76.js +2 -0
- package/dist/chunk-hns85dqw.js +2 -0
- package/dist/{chunk-wtjhehz9.js → chunk-hptfq3rg.js} +1 -1
- package/dist/{chunk-54sc18p8.js → chunk-hsa07n7c.js} +1 -1
- package/dist/{chunk-52x8mvh4.js → chunk-jnb80k2x.js} +2 -2
- package/dist/chunk-jtxcr5yw.js +4 -0
- package/dist/{chunk-x0ya2r4r.js → chunk-jz5zs812.js} +2 -2
- package/dist/{chunk-tn8prpny.js → chunk-k26wnmzk.js} +7 -7
- package/dist/{chunk-2bp7tqca.js → chunk-kprtsn8c.js} +1 -1
- package/dist/chunk-m4p7cnvk.js +2 -0
- package/dist/chunk-mcwxpdg9.js +2 -0
- package/dist/chunk-mkzmjg3f.js +4 -0
- package/dist/chunk-ng7px8gx.js +2 -0
- package/dist/{chunk-vagxqhef.js → chunk-nrr8z2z7.js} +2 -2
- package/dist/{chunk-g0w8n555.js → chunk-p6qbqsyp.js} +2 -2
- package/dist/chunk-patms7t8.js +2 -0
- package/dist/{chunk-hw70wbzg.js → chunk-phfmnnne.js} +2 -2
- package/dist/{chunk-tb5y0350.js → chunk-pkr6905p.js} +1 -1
- package/dist/chunk-ppmabn5h.js +2 -0
- package/dist/chunk-pskqrv5r.js +2 -0
- package/dist/{chunk-4xsq18p3.js → chunk-q2tjkhez.js} +1 -1
- package/dist/{chunk-6g1y9yqh.js → chunk-q4t568hv.js} +1 -1
- package/dist/chunk-qd2s51gc.js +2 -0
- package/dist/chunk-r763e19p.js +6 -0
- package/dist/{chunk-3zdcekfj.js → chunk-rayxmbcx.js} +2 -2
- package/dist/{chunk-74pxb991.js → chunk-rc2mk5x6.js} +2 -2
- package/dist/chunk-rwggcfgn.js +2 -0
- package/dist/chunk-s25rb4t2.js +2 -0
- package/dist/{chunk-zb62jhwm.js → chunk-s4zb0fcj.js} +13 -9
- package/dist/chunk-s6z3gm2s.js +5 -0
- package/dist/chunk-sc7emb71.js +2 -0
- package/dist/chunk-sw2538r0.js +49 -0
- package/dist/{chunk-p4zwy518.js → chunk-tjc2vgwn.js} +2 -2
- package/dist/{chunk-1stt2whn.js → chunk-tsckfwch.js} +2 -2
- package/dist/{chunk-gngwjf70.js → chunk-tw047td6.js} +2 -2
- package/dist/{chunk-6d9hmjt8.js → chunk-txtrpypt.js} +2 -2
- package/dist/chunk-v1wfa758.js +2 -0
- package/dist/{chunk-zs3jaj0g.js → chunk-vbeeyhhe.js} +168 -121
- package/dist/{chunk-dfesffnr.js → chunk-vckhctmr.js} +1 -1
- package/dist/chunk-vdd1cghr.js +2 -0
- package/dist/{chunk-fvpr07dn.js → chunk-vgtmrd4c.js} +1 -1
- package/dist/chunk-vj1sdxpp.js +2 -0
- package/dist/{chunk-fm8ckj9b.js → chunk-vqa6vte3.js} +1 -1
- package/dist/{chunk-82dv4p13.js → chunk-wn6pbyzn.js} +1 -1
- package/dist/{chunk-xqx460y2.js → chunk-xs12dtf1.js} +1 -1
- package/dist/chunk-xznnmhyt.js +2 -0
- package/dist/chunk-yk183r6z.js +2 -0
- package/dist/{chunk-1c1gznm9.js → chunk-yngahb11.js} +2 -2
- package/dist/{chunk-qyf90zz3.js → chunk-yp1tgdh3.js} +1 -1
- package/dist/chunk-yr8eta7p.js +27 -0
- package/dist/chunk-ys1qqcpp.js +2 -0
- package/dist/{chunk-8rc6042h.js → chunk-ytmxd5fk.js} +2 -2
- package/dist/chunk-zgkrhymn.js +2 -0
- package/dist/chunk-zxgkp71x.js +2 -0
- package/dist/src/agent/index.d.ts +6 -1
- package/dist/src/agent/modes.d.ts +0 -8
- package/dist/src/agent/plan.d.ts +28 -0
- package/dist/src/agent/tasks.d.ts +20 -0
- package/dist/src/agent/tools/issue.d.ts +19 -0
- package/dist/src/ci/attempts.d.ts +36 -0
- package/dist/src/ci/base.d.ts +55 -0
- package/dist/src/ci/fix.d.ts +27 -18
- package/dist/src/ci/index.d.ts +5 -1
- package/dist/src/ci/run.d.ts +28 -0
- package/dist/src/commands/handlers.d.ts +3 -0
- package/dist/src/dashboard/dashboard-generator.d.ts +4 -0
- package/dist/src/events/index.d.ts +12 -0
- package/dist/src/gates/checks.d.ts +10 -0
- package/dist/src/gates/index.d.ts +1 -0
- package/dist/src/gates/post-merge.d.ts +13 -1
- package/dist/src/git/github-provider.d.ts +5 -1
- package/dist/src/git/gitlab-provider.d.ts +5 -1
- package/dist/src/git/provider.d.ts +40 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +1 -1
- package/dist/src/registry/registry-client.d.ts +1 -1
- package/dist/src/reports/index.d.ts +1 -0
- package/dist/src/reports/publish-gate.d.ts +22 -0
- package/dist/src/review/filters.d.ts +36 -0
- package/dist/src/review/index.d.ts +4 -1
- package/dist/src/review/marker.d.ts +18 -0
- package/dist/src/review/poster.d.ts +11 -1
- package/dist/src/review/resolve.d.ts +20 -0
- package/dist/src/review/run.d.ts +35 -0
- package/dist/src/rules/engine.d.ts +19 -0
- package/dist/src/scanner/package-json-extras.d.ts +34 -1
- package/dist/src/setup.d.ts +49 -17
- package/dist/src/setup.js +1 -1
- package/dist/src/templates/github-actions.d.ts +2 -0
- package/dist/src/types.d.ts +4 -1
- package/dist/src/upgrades/migrate.d.ts +3 -0
- package/dist/src/upgrades/report.d.ts +1 -0
- package/dist/src/utils/dockerfile-parser.d.ts +2 -2
- package/dist/src/utils/helpers.d.ts +10 -1
- package/dist/src/version/version-resolver.d.ts +1 -0
- package/package.json +18 -16
- package/dist/chunk-0j7z87kh.js +0 -3
- package/dist/chunk-0r8zt3d7.js +0 -2
- package/dist/chunk-1a53wj0h.js +0 -1
- package/dist/chunk-1wjnd24b.js +0 -24
- package/dist/chunk-1xe07hzm.js +0 -2
- package/dist/chunk-2dbkpfy9.js +0 -2
- package/dist/chunk-3q6czqs4.js +0 -6
- package/dist/chunk-49ey79p0.js +0 -5
- package/dist/chunk-4c9m61yd.js +0 -5
- package/dist/chunk-4efbxdjr.js +0 -4
- package/dist/chunk-4f7panqj.js +0 -21
- package/dist/chunk-4hd3rre0.js +0 -2
- package/dist/chunk-5c3qf34r.js +0 -2
- package/dist/chunk-5kt03hx5.js +0 -2
- package/dist/chunk-63ept76v.js +0 -2
- package/dist/chunk-65b3vq52.js +0 -2
- package/dist/chunk-6k653r8w.js +0 -2
- package/dist/chunk-6patq6bw.js +0 -2
- package/dist/chunk-6sgh49z1.js +0 -2
- package/dist/chunk-7tfrww3v.js +0 -2
- package/dist/chunk-7xk28xrv.js +0 -2
- package/dist/chunk-8661pvb8.js +0 -3
- package/dist/chunk-887s0w81.js +0 -2
- package/dist/chunk-978wtejw.js +0 -44
- package/dist/chunk-9eqpaxfz.js +0 -2
- package/dist/chunk-9p1xkmjy.js +0 -2
- package/dist/chunk-agdesgzv.js +0 -2
- package/dist/chunk-ar01x04a.js +0 -2
- package/dist/chunk-ay43f085.js +0 -2
- package/dist/chunk-bk9bqd5j.js +0 -2
- package/dist/chunk-bm8d40j0.js +0 -69
- package/dist/chunk-c3fczawt.js +0 -2
- package/dist/chunk-c9r9nd4t.js +0 -1
- package/dist/chunk-ctsz0ynx.js +0 -3
- package/dist/chunk-czremqk7.js +0 -2
- package/dist/chunk-da3wbh04.js +0 -2
- package/dist/chunk-dat582cg.js +0 -2
- package/dist/chunk-djntbp7a.js +0 -105
- package/dist/chunk-eagjp0dh.js +0 -3
- package/dist/chunk-eht72nnj.js +0 -2
- package/dist/chunk-f4nv5x3z.js +0 -2
- package/dist/chunk-fdfk918n.js +0 -2
- package/dist/chunk-fdj0tewy.js +0 -20
- package/dist/chunk-fqj7e6xa.js +0 -2
- package/dist/chunk-frm8zz31.js +0 -2
- package/dist/chunk-g0nv8psv.js +0 -2
- package/dist/chunk-gkmvxjbe.js +0 -2
- package/dist/chunk-j8asz4hb.js +0 -15
- package/dist/chunk-k62w2v03.js +0 -2
- package/dist/chunk-mcrfxphm.js +0 -5
- package/dist/chunk-mh3x7j6h.js +0 -2
- package/dist/chunk-naq32yx3.js +0 -86
- package/dist/chunk-nsmcjkas.js +0 -2
- package/dist/chunk-p1xm1jvz.js +0 -2
- package/dist/chunk-p3wsm8kz.js +0 -2
- package/dist/chunk-p7zgy37f.js +0 -2
- package/dist/chunk-ph1b3vbp.js +0 -315
- package/dist/chunk-pkjm2r0a.js +0 -2
- package/dist/chunk-pkkwb0n0.js +0 -4
- package/dist/chunk-pnpx1kqn.js +0 -6
- package/dist/chunk-qpz9k66h.js +0 -2
- package/dist/chunk-qvn1rtgp.js +0 -2
- package/dist/chunk-r06ce5g6.js +0 -2
- package/dist/chunk-r2sbprdb.js +0 -49
- package/dist/chunk-rqdep14r.js +0 -2
- package/dist/chunk-s1km8cyq.js +0 -2
- package/dist/chunk-s4ms8zag.js +0 -2
- package/dist/chunk-ts35hc5t.js +0 -3
- package/dist/chunk-vkctfqpm.js +0 -3
- package/dist/chunk-wdwvt7gb.js +0 -43
- package/dist/chunk-x3kragh9.js +0 -12
- package/dist/chunk-x9ctz1qc.js +0 -1
- package/dist/chunk-xakpdqaq.js +0 -3
- package/dist/chunk-yncea6ty.js +0 -2
- package/dist/chunk-yq0gxtzv.js +0 -2
- package/dist/chunk-yqhs08ky.js +0 -2
- package/dist/chunk-zve5d96e.js +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var{semver:B}=globalThis.Bun;function G(j){return[...j].sort((q,k)=>B.order(k,q))}function D(j,q){let k=j.trim();if(!k||k==="*"||k==="latest")return!0;if(/^(?:workspace|file|link|git|github|npm):/i.test(k)||k.includes("/"))return!0;try{return B.satisfies(q,k)}catch{return!0}}function H(j){let q=G(j.available);if(q.length===0)return null;let k=q[0],z=q.find((A)=>j.declared.every((E)=>D(E.range,A)));if(!z)return null;let C=j.declared.filter((A)=>!D(A.range,k)).filter((A)=>A.by!==I);if(B.order(j.installed,z)<0)return{name:j.name,kind:"lockfile",installed:j.installed,reachable:z,latest:k,capping:C};if(C.length>0&&B.order(z,k)<0)return{name:j.name,kind:"capped",installed:j.installed,reachable:z,latest:k,capping:C};return null}var I="root";function L(j){let q=[];for(let k of j){let z=H(k);if(z)q.push(z)}return q.sort((k,z)=>{if(k.kind!==z.kind)return k.kind==="capped"?-1:1;return B.order(z.latest,k.latest)})}function M(j){let q=`${j.name} ${j.installed} is installed, ${j.reachable} is reachable`;if(j.kind==="lockfile")return`${q}. Nothing is capping it - the lockfile is behind.`;let k=j.capping.map((z)=>`${z.by} (${z.range})`).join(", ");return j.reachable===j.latest?`${q}, and ${j.latest} exists but is capped by ${k}.`:`${q}. ${j.latest} exists but is capped by ${k}.`}
|
|
3
|
-
export{H as
|
|
3
|
+
export{H as Hb,I as Ib,L as Jb,M as Kb};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{gf as a,hf as b,if as c}from"./chunk-8hjvthz4.js";import"./chunk-yngahb11.js";import"./chunk-08x5b93v.js";import"./chunk-p6qbqsyp.js";import"./chunk-1cpdz49v.js";import"./chunk-cgvt98pd.js";import"./chunk-c8rzx3a1.js";import"./chunk-0hc97k0t.js";import"./chunk-3901s7h9.js";import"./chunk-jtxcr5yw.js";import"./chunk-qd2s51gc.js";import"./chunk-193abzy6.js";import"./chunk-e68nf7cm.js";import"./chunk-hfjywbbc.js";import"./chunk-g24hav8e.js";import"./chunk-q4t568hv.js";export{a as matchesGlobs,c as appendUpgradeReport,b as analyzeGroupMajors};
|
|
@@ -13,4 +13,4 @@ var G=["pretty","json","github","agent"];function Q(k,j){switch(k){case"staged":
|
|
|
13
13
|
`);if(j<1||j>z.length)return null;return z.splice(j-1,1,...q.split(`
|
|
14
14
|
`)),z.join(`
|
|
15
15
|
`)}function P(k,j="major"){let q=["critical","major","minor","nit"],z=q.indexOf(j);return k.some((D)=>q.indexOf(D.severity)<=z)}
|
|
16
|
-
export{G as
|
|
16
|
+
export{G as yd,Q as zd,L as Ad,X as Bd,Z as Cd,$ as Dd,B as Ed,N as Fd,O as Gd,P as Hd};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Fh as X}from"./chunk-hfjywbbc.js";import"./chunk-q4t568hv.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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Ac as m,Bc as n,Cc as o,Dc as p,Ec as q,Fc as r,Gc as s,Hc as t,Ic as u,oc as a,pc as b,qc as c,rc as d,sc as e,tc as f,uc as g,vc as h,wc as i,xc as j,yc as k,zc as l}from"./chunk-6p4qz8qv.js";import"./chunk-e68nf7cm.js";import"./chunk-hfjywbbc.js";import"./chunk-q4t568hv.js";export{t as stripOperators,l as splitConstraint,s as scanEcosystems,o as rustAdapter,n as rubyAdapter,c as regenerateWith,u as regenerateLockfiles,m as pythonAdapter,k as pep440UpdateType,h as parsePep440,f as numericUpdateType,j as isPep440Prerelease,g as goAdapter,a as escapeRegex,b as detectFiles,i as comparePep440,e as compareNumeric,d as commandAvailable,r as adapterNamed,q as adapterFor,p as BUILTIN_ADAPTERS};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{existsSync as O,readdirSync as R,statSync as A}from"fs";import{join as U,relative as L}from"path";function T(z,K){try{let V=Bun.YAML.parse(K);if(!V||typeof V!=="object")return null;return{file:z,raw:K,data:V}}catch{return null}}function B(z,K){if(!K)return;let V=z.indexOf(K);if(V<0)return;let M=1;for(let Y=0;Y<V;Y++)if(z.charCodeAt(Y)===10)M++;return M}async function W(z){let K=U(z,".github","workflows");if(!O(K))return[];let V=R(K),M=[];for(let Y of V){if(!Y.endsWith(".yml")&&!Y.endsWith(".yaml"))continue;let Q=U(K,Y);if(!A(Q).isFile())continue;let Z=await Bun.file(Q).text(),N=T(L(z,Q),Z);if(N)M.push(N)}return M}function*X(z){let K=z.data.jobs;if(!K||typeof K!=="object")return;for(let[V,M]of Object.entries(K)){if(!M||typeof M!=="object")continue;let Y=M.steps;if(!Array.isArray(Y))continue;for(let Q=0;Q<Y.length;Q++){let Z=Y[Q];if(!Z||typeof Z!=="object")continue;yield{jobId:V,job:M,stepIndex:Q,step:Z}}}}function*$(z){let K=z.data.jobs;if(!K||typeof K!=="object")return;for(let[V,M]of Object.entries(K)){if(!M||typeof M!=="object")continue;yield{jobId:V,job:M}}}var F={id:"bash-injection",defaultSeverity:"error",description:"Avoid `${{ }}` interpolation of untrusted input inside `run:` blocks.",check(z){let K=[];for(let{jobId:V,step:M,stepIndex:Y}of X(z)){let Q=typeof M.run==="string"?M.run:null;if(!Q)continue;let Z=[...Q.matchAll(/\$\{\{\s*([^}]+?)\s*\}\}/g)];for(let N of Z){let C=N[1].trim();if(I(C))continue;K.push({ruleId:this.id,severity:this.defaultSeverity,message:`Job \`${V}\`, step ${Y+1}: \`${C}\` is interpolated into a shell.`,detail:"GitHub evaluates `${{ ... }}` before the shell runs, so attacker-controlled values become part of the command line. Move the value into `env:` and reference it as a shell variable.",file:z.file,line:B(z.raw,N[0]),fix:'Put the value in `env:` and reference it with `"$NAME"` instead.'})}}return K}},_=["secrets.","vars.","runner.","env.","inputs.","matrix.","strategy.","job.","steps.","needs."],S=new Set(["github.repository","github.repository_owner","github.workflow","github.run_id","github.run_number","github.run_attempt","github.event_name","github.sha","github.ref_name","github.token","github.actor","github.actor_id","github.api_url","github.server_url","github.graphql_url","github.workspace","github.action","github.action_path","github.action_ref","github.action_repository","github.action_status","github.job","github.job_workflow_sha"]);function I(z){if(S.has(z))return!0;return _.some((K)=>z.startsWith(K))}var J={id:"dangerous-pull-request-target",defaultSeverity:"error",description:"Avoid checking out PR-author code from a `pull_request_target` workflow.",check(z){if(!x(z.data.on,"pull_request_target"))return[];let K=[];for(let{jobId:V,step:M}of X(z)){if(!(typeof M.uses==="string"?M.uses:"").startsWith("actions/checkout@"))continue;let Q=typeof M.with?.ref==="string"?M.with.ref:null;if(!Q)continue;if(Q.includes("pull_request")||Q.includes("head.sha")||Q.includes("head.ref")||Q.includes("github.head_ref"))K.push({ruleId:this.id,severity:this.defaultSeverity,message:`Job \`${V}\` checks out PR-author code under \`pull_request_target\`.`,detail:"This grants attacker-controlled code access to repository secrets and write tokens. Move the build to `pull_request` or run untrusted code in a sandboxed second workflow without secrets.",file:z.file,line:B(z.raw,Q),fix:"Either switch the trigger to `pull_request`, or split into two workflows: one privileged (no checkout of head) and one unprivileged (checkout of head, no secrets)."})}return K}};function x(z,K){if(typeof z==="string")return z===K;if(Array.isArray(z))return z.includes(K);if(z&&typeof z==="object")return K in z;return!1}var q={id:"excessive-permissions",defaultSeverity:"warning",description:"Workflows and jobs should declare a least-privilege `permissions:` block.",check(z){let K=[],V=z.data.permissions;if(V===void 0)K.push({ruleId:this.id,severity:this.defaultSeverity,message:"Workflow does not declare top-level `permissions:`.",detail:"Without an explicit `permissions:` block, jobs inherit the repository default \u2014 historically `write-all`. Add a least-privilege block at the workflow root.",file:z.file,line:1,fix:"Add `permissions:\\n contents: read` at the top of the workflow, then narrow per-job as needed."});else if(V==="write-all")K.push({ruleId:this.id,severity:"error",message:"Workflow grants `permissions: write-all`.",file:z.file,line:B(z.raw,"write-all"),fix:"Replace with explicit per-scope grants (e.g. `contents: read`, `pull-requests: write`)."});else if(V!=="read-all"&&typeof V==="object")K.push(...P(this.id,z.file,z.raw,V,"workflow"));for(let{jobId:M,job:Y}of $(z)){let Q=Y.permissions;if(Q===void 0)continue;if(Q==="write-all")K.push({ruleId:this.id,severity:"error",message:`Job \`${M}\` grants \`permissions: write-all\`.`,file:z.file,line:B(z.raw,"write-all"),fix:"Replace with explicit per-scope grants."});else if(Q!=="read-all"&&typeof Q==="object")K.push(...P(this.id,z.file,z.raw,Q,`job \`${M}\``))}return K}};function P(z,K,V,M,Y){let Q=[];if(typeof M!=="object"||M===null)return Q;for(let[Z,N]of Object.entries(M))if(N==="write"&&(Z==="actions"||Z==="id-token"))Q.push({ruleId:z,severity:"warning",message:`${Y} grants \`${Z}: write\` \u2014 verify this is required.`,detail:Z==="id-token"?"`id-token: write` is needed for OIDC federation but should never be combined with running untrusted code.":"`actions: write` allows the workflow to dispatch other workflows, increasing blast radius if compromised.",file:K,line:B(V,`${Z}: write`)});return Q}var D={id:"missing-timeout",defaultSeverity:"warning",description:"Jobs should declare an explicit `timeout-minutes` to bound runaway execution.",check(z){let K=[];for(let{jobId:V,job:M}of $(z)){let Y=M["timeout-minutes"];if(typeof Y==="number"&&Y>0)continue;K.push({ruleId:this.id,severity:this.defaultSeverity,message:`Job \`${V}\` has no \`timeout-minutes\`.`,file:z.file,line:B(z.raw,`${V}:`),fix:"Add `timeout-minutes: <n>` (15\u201360 is a reasonable default for most CI jobs)."})}return K}};var G={id:"self-hosted-exposure",defaultSeverity:"warning",description:"Self-hosted runners should be scoped with additional labels, not used bare.",check(z){let K=[];for(let{jobId:V,job:M}of $(z)){let Y=M["runs-on"];if(!Y)continue;if(typeof Y==="string"){if(Y==="self-hosted")K.push({ruleId:this.id,severity:this.defaultSeverity,message:`Job \`${V}\` uses bare \`runs-on: self-hosted\`.`,file:z.file,line:B(z.raw,"runs-on: self-hosted"),fix:"Add at least one scoping label, e.g. `runs-on: [self-hosted, my-project]`, and disable persistence on the runner."});continue}if(Array.isArray(Y)){let Q=Y.filter((Z)=>typeof Z==="string");if(Q.includes("self-hosted")&&Q.length===1)K.push({ruleId:this.id,severity:this.defaultSeverity,message:`Job \`${V}\` uses \`runs-on: [self-hosted]\` with no additional labels.`,file:z.file,line:B(z.raw,"self-hosted"),fix:"Add at least one scoping label (project name, environment) so the pool is explicit."})}}return K}};var v=/^[0-9a-f]{40}$/i,E={id:"unpinned-action",defaultSeverity:"warning",description:"Third-party actions should be pinned to a full commit SHA, not a tag or branch.",check(z){let K=[];for(let{step:V}of X(z)){let M=typeof V.uses==="string"?V.uses:null;if(!M)continue;if(M.startsWith("./")||M.startsWith("docker://"))continue;let Y=M.lastIndexOf("@");if(Y<0){K.push({ruleId:this.id,severity:this.defaultSeverity,message:`Action \`${M}\` is missing a version reference.`,file:z.file,line:B(z.raw,M),fix:`Pin to a commit SHA: \`${M}@<full-sha> # vX.Y.Z\``});continue}let Q=M.slice(0,M.indexOf("/")),Z=M.slice(Y+1);if(Q==="actions"||Q==="github")continue;if(v.test(Z))continue;K.push({ruleId:this.id,severity:this.defaultSeverity,message:`Action \`${M}\` is pinned to a mutable ref (\`${Z}\`).`,file:z.file,line:B(z.raw,M),fix:`Replace with a SHA-pinned reference: \`${M.slice(0,Y)}@<full-sha> # ${Z}\``})}return K}};var H=[E,q,J,F,D,G];async function Tz(z,K={}){let V=await W(z);return y(V,K)}function y(z,K={}){let V=(K.rules??H).filter((Q)=>{return!K.ignore?.includes(Q.id)}),M=[];for(let Q of z)for(let Z of V){let N=Z.check(Q);for(let C of N)M.push(C)}let Y=M.some((Q)=>Q.severity==="error");return{workflows:z,findings:M,failed:Y}}
|
|
3
|
-
export{Tz as
|
|
3
|
+
export{Tz as ae,y as be};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{nd as a}from"./chunk-11hdrnf6.js";import"./chunk-g30dr44w.js";import"./chunk-0hc97k0t.js";import"./chunk-3901s7h9.js";import"./chunk-jtxcr5yw.js";import"./chunk-qd2s51gc.js";import"./chunk-193abzy6.js";import"./chunk-e68nf7cm.js";import"./chunk-hfjywbbc.js";import"./chunk-g24hav8e.js";import"./chunk-q4t568hv.js";export{a as PullRequestGenerator};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{W as
|
|
2
|
+
import{Jf as K}from"./chunk-1cpdz49v.js";import{cg as D}from"./chunk-0hc97k0t.js";var F=[[0,59],[0,23],[1,31],[1,12],[0,6]];function I(j,J){let[U,B]=F[J],H=new Set;for(let Q of j.split(",")){let[X,Z]=Q.split("/"),q=Z===void 0?1:Number(Z);if(!Number.isInteger(q)||q<1)return null;let $,G;if(X==="*")$=U,G=B;else if(X.includes("-")){let[Y,_]=X.split("-").map(Number);if(!Number.isInteger(Y)||!Number.isInteger(_))return null;$=Y,G=_}else{let Y=Number(X);if(!Number.isInteger(Y))return null;$=Y,G=Y}if($<U||G>B||$>G)return null;for(let Y=$;Y<=G;Y+=q)H.add(Y)}return H.size>0?H:null}function L(j){let J=j.trim().split(/\s+/);if(J.length!==5)return null;let U=J.map((Z,q)=>I(Z,q));if(U.some((Z)=>Z===null))return null;let[,B,H,Q,X]=U;return{hours:B,daysOfMonth:H,months:Q,daysOfWeek:X}}function N(j,J){if(!J)return{hour:j.getHours(),day:j.getDate(),month:j.getMonth()+1,weekday:j.getDay()};let U=new Intl.DateTimeFormat("en-US",{timeZone:J,hour:"numeric",hour12:!1,day:"numeric",month:"numeric",weekday:"short"}),B=Object.fromEntries(U.formatToParts(j).map((Q)=>[Q.type,Q.value])),H=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return{hour:Number(B.hour)%24,day:Number(B.day),month:Number(B.month),weekday:Math.max(0,H.indexOf(B.weekday))}}function C(j,J=new Date,U){let B=L(j);if(!B)return!1;let{hour:H,day:Q,month:X,weekday:Z}=N(J,U);if(!B.hours.has(H)||!B.months.has(X))return!1;let q=B.daysOfMonth.size<31,$=B.daysOfWeek.size<7;if(q&&$)return B.daysOfMonth.has(Q)||B.daysOfWeek.has(Z);return B.daysOfMonth.has(Q)&&B.daysOfWeek.has(Z)}function W(j){if(j.dependencyType==="github-actions")return"github-actions";if(j.dependencyType==="docker-image")return"docker";if(j.dependencyType==="zig-dependencies")return"zig";if(j.dependencyType==="python"||j.dependencyType==="rust"||j.dependencyType==="go"||j.dependencyType==="ruby")return j.dependencyType;if(j.file.endsWith("composer.json")||j.file.endsWith("composer.lock"))return"composer";if(j.file.endsWith("package.json"))return"npm";return"pkgx"}function A(j,J,U=new Date){if(j.matchPackages?.length){if(!K(j.matchPackages).matches(J.name))return!1}if(j.matchEcosystems?.length&&!j.matchEcosystems.includes(W(J)))return!1;if(j.matchDepTypes?.length&&!j.matchDepTypes.includes(J.dependencyType))return!1;if(j.matchUpdateTypes?.length&&!j.matchUpdateTypes.includes(J.updateType))return!1;if(j.matchFiles?.length){if(!K(j.matchFiles).matches(J.file))return!1}if(j.matchCurrentVersion&&!E(J.currentVersion,j.matchCurrentVersion))return!1;if(j.schedule&&!C(j.schedule,U,j.scheduleTimezone))return!1;return!0}function E(j,J){let U=j.replace(/^[\^~>=<\s]+/,"").trim();return U?D(U,J):!1}function S(j,J=[],U=new Date){let B={enabled:!0,labels:[],reviewers:[],assignees:[],prPriority:0};for(let H of J){if(!A(H,j,U))continue;if(H.enabled!==void 0)B.enabled=H.enabled;if(H.strategy!==void 0)B.strategy=H.strategy;if(H.groupName!==void 0)B.groupName=H.groupName;if(H.autoMerge!==void 0)B.autoMerge=H.autoMerge;if(H.minimumReleaseAge!==void 0)B.minimumReleaseAge=H.minimumReleaseAge;if(H.prPriority!==void 0)B.prPriority=H.prPriority;if(H.autoMigrate!==void 0)B.autoMigrate=H.autoMigrate;for(let Q of H.labels??[])if(!B.labels.includes(Q))B.labels.push(Q);for(let Q of H.reviewers??[])if(!B.reviewers.includes(Q))B.reviewers.push(Q);for(let Q of H.assignees??[])if(!B.assignees.includes(Q))B.assignees.push(Q)}return B}function k(j,J=[],U=new Date){let B=[];for(let H of j){let Q=S(H,J,U);if(!Q.enabled)continue;if(Q.strategy&&!V(Q.strategy,H.updateType))continue;B.push({update:H,effects:Q})}return B}function T(j){let J=new Set,U=new Set,B=new Set,H=0;for(let Q of j)Q.labels.forEach((X)=>J.add(X)),Q.reviewers.forEach((X)=>U.add(X)),Q.assignees.forEach((X)=>B.add(X)),H=Math.max(H,Q.prPriority);return{labels:[...J],reviewers:[...U],assignees:[...B],autoMerge:j.length>0&&j.every((Q)=>Q.autoMerge===!0),prPriority:H,autoMigrate:j.some((Q)=>Q.autoMigrate===!0)}}function V(j,J){switch(j){case"all":return!0;case"major":return J==="major";case"minor":return J==="minor"||J==="patch";case"patch":return J==="patch"}}function b(j=[]){return j.map((J)=>({matchPackages:J.patterns,groupName:J.name,...J.strategy?{strategy:J.strategy}:{}}))}
|
|
3
|
+
export{W as jf,A as kf,S as lf,k as mf,T as nf,V as of,b as pf};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Ib as $}from"./chunk-vckhctmr.js";import"./chunk-q4t568hv.js";import{readdir as Z}from"fs/promises";import{join as W}from"path";var w=["dependencies","peerDependencies","optionalDependencies"];async function x(U,V,M,Q){let J=await G(M,Q);if(J.length===0)return[];let H=new Map,z=(q,v,E)=>{let X=H.get(q),Y={by:v,range:E};if(X)X.push(Y);else H.set(q,[Y])};for(let q of U)for(let v of q.dependencies)z(v.name,$,v.currentVersion);for(let q of J)for(let[v,E]of Object.entries(q.ranges))z(v,q.name,E);let D=[];for(let q of J){let v=H.get(q.name);if(!v||v.length===0)continue;try{let E=await V.getPackageMetadata(q.name);if(!E?.versions?.length)continue;D.push({name:q.name,installed:q.version,available:E.versions,declared:v})}catch(E){Q.debug(`Skipping drift analysis for ${q.name}: ${E}`)}}return D}async function G(U,V){let M=W(U,"node_modules"),Q=[],J;try{J=await Z(M)}catch{return V.debug("No node_modules directory, skipping resolution drift analysis"),[]}let H=[];for(let z of J){if(z.startsWith("."))continue;if(z.startsWith("@")){try{let D=await Z(W(M,z));H.push(...D.map((q)=>`${z}/${q}`))}catch{continue}continue}H.push(z)}return await Promise.all(H.map(async(z)=>{try{let D=await Bun.file(W(M,z,"package.json")).json();if(!D.name||!D.version)return;let q={};for(let v of w)Object.assign(q,D[v]??{});Q.push({name:D.name,version:D.version,ranges:q})}catch{}})),Q}export{x as collectDriftInputs};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{od as A}from"./chunk-cwfkm7h9.js";import{le as G,me as q}from"./chunk-5av2vnvv.js";import{sf as T}from"./chunk-08x5b93v.js";import{If as S}from"./chunk-p6qbqsyp.js";import{Ch as K,Fh as O}from"./chunk-hfjywbbc.js";import{Wk as I}from"./chunk-q4t568hv.js";var w=[{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
|
+
`);for(let z of w){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:P(H)}}function P(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 X(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 b=3;async function _(x,H,z,J){let V=J??O();try{let Q=await x.listWorkflowRuns(H,{status:"completed",limit:20});for(let Y of F(Q).slice(0,b)){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 F(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 m(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 M(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,m(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 S(x.ai,{mode:T,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 ${X(z)}`,"","Relevant log lines:",z.evidence.join(`
|
|
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
|
+
`),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
|
|
6
|
+
|
|
7
|
+
**Diagnosis:** ${X(x)}
|
|
8
|
+
|
|
9
|
+
${H}
|
|
10
|
+
`;if(x.evidence.length>0)z+=`
|
|
11
|
+
<details><summary>Relevant log lines</summary>
|
|
12
|
+
|
|
13
|
+
\`\`\`
|
|
14
|
+
${x.evidence.slice(0,20).join(`
|
|
15
|
+
`)}
|
|
16
|
+
\`\`\`
|
|
17
|
+
|
|
18
|
+
</details>
|
|
19
|
+
`;return z}var L=/<!--\s*buddy:fix-ci\s+v(\d+)\s*([\s\S]*?)-->/;function B(x){if(!x)return null;let H=x.match(L);if(!H)return null;try{let z=JSON.parse(H[2].trim()),J=Number(z.attempts);if(!Number.isFinite(J)||J<0)return null;return{attempts:Math.floor(J),lastAttemptAt:typeof z.lastAttemptAt==="string"?z.lastAttemptAt:new Date(0).toISOString()}}catch{return null}}function E(x,H,z=new Date){let J={attempts:H,lastAttemptAt:z.toISOString()},V=`<!-- buddy:fix-ci v1
|
|
20
|
+
${JSON.stringify(J)}
|
|
21
|
+
-->`;return`${(x??"").replace(L,"").trimEnd()}
|
|
22
|
+
|
|
23
|
+
${V}`}async function f(x,H,z){if(!G(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 F(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();q(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 f(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 j=B(Q?.body)?.attempts??0,U=z.repository?.baseBranch??"main",R=G(J,"ciRuns","listWorkflowRuns"),y=G(J,"ciRuns","rerunWorkflowRun"),{createAiClient:k}=await import("./chunk-hsa07n7c.js"),C=await M({log:Z,priorAttempts:j,workspace:V,baseBranch:U,ai:x.analysisOnly?null:k(z,H),logger:H,dryRun:Boolean(x.dryRun),analysisOnly:Boolean(x.analysisOnly),...R?{checkBase:(D)=>_({listWorkflowRuns:(W,v)=>J.listWorkflowRuns(W,v),getWorkflowRunLogs:(W)=>J.getWorkflowRunLogs(W)},U,D,H)}:{},...y?{rerun:()=>J.rerunWorkflowRun(Y)}:{},...x.analysisOnly?{}:{regenerateLockfile:()=>g(V,H)}});if(H.info(`
|
|
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:E(Q.body,j+1)})}catch(D){H.warn(`Could not record the fix attempt on PR #${x.prNumber}: ${K(D)}`)}}return await A(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}=await import("./chunk-ng7px8gx.js"),{commitAndPush:Q}=await import("./chunk-aa277p5r.js"),Y=J(["package.json","composer.json"]),Z=!1;for(let j of Y){let U=await z(j,x);if(U.success)Z=!0;else H.warn(`\u26A0\uFE0F ${U.message}`)}if(!Z)return{regenerated:!1,pushed:!1};try{return{regenerated:!0,pushed:await Q(V(),`fix(deps): regenerate the lock file
|
|
26
|
+
|
|
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,P as Fa,X as Ga,_ as Ha,F as Ia,M as Ja,c as Ka};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{De as a,Ee as b,Fe as c,Ge as d,He as e,Ie as f}from"./chunk-b9escac0.js";import"./chunk-e68nf7cm.js";import"./chunk-hfjywbbc.js";import"./chunk-q4t568hv.js";export{e as updateDockerfile,d as resolveDockerDigest,b as parseDockerfile,a as isDockerfile,f as generateDockerfileUpdates,c as fetchLatestDockerImageVersion};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{oh as H}from"./chunk-193abzy6.js";import{zh as M}from"./chunk-e68nf7cm.js";import{Fh as E}from"./chunk-hfjywbbc.js";import{Wk as T}from"./chunk-q4t568hv.js";import W from"process";function v(J){let q=J.replace(/\\/g,"/");return q.includes(".github/workflows/")&&(q.endsWith(".yml")||q.endsWith(".yaml"))}async function N(J,q){try{if(!v(J))return null;let I=[],j=q.split(`
|
|
3
3
|
`);for(let Q=0;Q<j.length;Q++){let Z=j[Q].trim().match(/^-?\s*uses:\s*(.+)/);if(Z){let _=Z[1].trim().replace(/['"`]/g,"");if(_.startsWith("./")||_.startsWith("docker://"))continue;let K=_.split("@");if(K.length===2){let[X,O]=K;if(!X||!X.trim())continue;let x=O.split("#")[0].trim(),$={name:X.trim(),currentVersion:x,type:"github-actions",file:J};if(!I.find((S)=>S.name===$.name&&S.currentVersion===$.currentVersion))I.push($)}}}return{path:J,type:"github-actions",content:q,dependencies:I}}catch(I){return E().warn(`Failed to parse GitHub Actions file ${J}:`,I),null}}async function A(J,q,I){try{if(!v(J))return q;let j=q;for(let Q of I){let V=Q.name.replace(/\s*\(.*\)$/,""),Y=new RegExp(`((?:^\\s*-\\s*)?uses:\\s*["']?)(${V.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})@(${Q.currentVersion.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})(["']?)`,"gm");j=j.replace(Y,`$1$2@${Q.newVersion}$4`)}return j}catch(j){return E().warn(`Failed to update GitHub Actions file ${J}:`,j),q}}async function L(J){let q=[],I=new Map;for(let j of J)if(v(j.file)){if(!I.has(j.file))I.set(j.file,[]);I.get(j.file).push(j)}for(let[j,Q]of I)try{let V=await import("fs");if(V.existsSync(j)){let Y=V.readFileSync(j,"utf-8"),Z=await A(j,Y,Q);q.push({path:j,content:Z,type:"update"})}}catch(V){E().warn(`Failed to generate updates for GitHub Actions file ${j}:`,V)}return q}async function R(J){try{if(!J.includes("/"))return E().info(`\u26A0\uFE0F Invalid action name format: ${J}`),null;let[q,I]=J.split("/");E().info(`\uD83D\uDD0D Fetching latest version for ${q}/${I}`);let j={Accept:"application/vnd.github.v3+json","User-Agent":"buddy"},Q=W.env.BUDDY_TOKEN||W.env.GITHUB_TOKEN||W.env.GH_TOKEN;if(Q)j.Authorization=`Bearer ${Q}`;let V=H();E().info(`\uD83D\uDCE1 Trying latest release for ${q}/${I}`);let Y=await M(`${V}/repos/${q}/${I}/releases/latest`,{headers:j});if(Y.ok){let K=await Y.json();if(K.tag_name)return E().info(`\u2705 Found latest release: ${K.tag_name}`),K.tag_name}else E().info(`\u26A0\uFE0F Latest release not found: ${Y.status} ${Y.statusText}`);E().info(`\uD83D\uDCE1 Trying all releases for ${q}/${I}`);let Z=await M(`${V}/repos/${q}/${I}/releases?per_page=10`,{headers:j});if(Z.ok){let K=await Z.json();if(!Array.isArray(K))E().info("\u26A0\uFE0F Unexpected releases response format (expected array)");else{E().info(`\uD83D\uDCCB Found ${K.length} releases`);let X=K.filter((O)=>O.tag_name&&!O.tag_name.includes("-")).sort((O,x)=>{let $=O.published_at?new Date(O.published_at).getTime():0;return(x.published_at?new Date(x.published_at).getTime():0)-$});if(X.length>0)return E().info(`\u2705 Found latest stable release: ${X[0].tag_name}`),X[0].tag_name||null}}else E().info(`\u26A0\uFE0F Releases not found: ${Z.status} ${Z.statusText}`);E().info(`\uD83D\uDCE1 Trying tags for ${q}/${I}`);let _=await M(`${V}/repos/${q}/${I}/tags?per_page=10`,{headers:j});if(_.ok){let K=await _.json();if(!Array.isArray(K))E().info("\u26A0\uFE0F Unexpected tags response format (expected array)");else{E().info(`\uD83D\uDCCB Found ${K.length} tags`);let X=K.filter((O)=>O.name&&!O.name.includes("-")).map((O)=>O.name).sort((O,x)=>{let $=O.replace(/^v/,""),z=x.replace(/^v/,""),S=$.split(".").map(Number),y=z.split(".").map(Number);for(let k=0;k<Math.max(S.length,y.length);k++){let B=S[k]||0,G=y[k]||0;if(B!==G)return G-B}return 0});if(X.length>0)return E().info(`\u2705 Found latest stable tag: ${X[0]}`),X[0]}}else E().info(`\u26A0\uFE0F Tags not found: ${_.status} ${_.statusText}`);return E().info(`\u274C No version found for ${J}`),null}catch(q){return E().warn(`Failed to fetch latest version for ${J}:`,q),null}}
|
|
4
|
-
export{v as
|
|
4
|
+
export{v as ne,N as oe,A as pe,L as qe,R as re};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{I as a,J as b,K as c,L as d,M as e,N as f,O as g,P as h,Q as i,R as j,S as k,T as l,U as m,V as n}from"./chunk-0w695m54.js";import"./chunk-hfjywbbc.js";import"./chunk-q4t568hv.js";export{m as withNarrative,n as shouldPublishReport,l as renderReport,c as parseHistory,f as loadHistory,e as findPrevious,i as computeMetrics,j as computeDeltas,d as appendHistory,g as REPORT_PERIODS,k as REPORT_MARKER,h as PERIOD_DAYS,a as HISTORY_PATH,b as HISTORY_LIMIT};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type { RunPlanOptions } from './plan';
|
|
1
2
|
export type { FinishingTouch, TouchOutput } from './tasks';
|
|
2
3
|
export type { AgentRunOptions } from './runner';
|
|
3
4
|
export type {
|
|
@@ -16,9 +17,9 @@ export {
|
|
|
16
17
|
getAgentMode,
|
|
17
18
|
implementMode,
|
|
18
19
|
planMode,
|
|
19
|
-
restrictedMode,
|
|
20
20
|
reviewMode,
|
|
21
21
|
} from './modes';
|
|
22
|
+
export { runPlan } from './plan';
|
|
22
23
|
export { runAgent, wrapUntrusted } from './runner';
|
|
23
24
|
export {
|
|
24
25
|
autofixTouch,
|
|
@@ -28,6 +29,9 @@ export {
|
|
|
28
29
|
parseTouchSelections,
|
|
29
30
|
planTouch,
|
|
30
31
|
renderTouchOffer,
|
|
32
|
+
TOUCH_OFFER_MARKER,
|
|
33
|
+
hasTouchOffer,
|
|
34
|
+
withTouchOffer,
|
|
31
35
|
simplifyTouch,
|
|
32
36
|
unitTestsTouch,
|
|
33
37
|
} from './tasks';
|
|
@@ -42,3 +46,4 @@ export {
|
|
|
42
46
|
TEST_COMMANDS,
|
|
43
47
|
verifyChanges,
|
|
44
48
|
} from './stacked';
|
|
49
|
+
export { createReadIssueTool } from './tools/issue';
|
|
@@ -21,13 +21,5 @@ export declare const implementMode: AgentMode;
|
|
|
21
21
|
export declare const fixCiMode: AgentMode;
|
|
22
22
|
/** Research and planning, with no ability to change anything. */
|
|
23
23
|
export declare const planMode: AgentMode;
|
|
24
|
-
/**
|
|
25
|
-
* The tier every non-collaborator gets.
|
|
26
|
-
*
|
|
27
|
-
* Public repositories accept input from anyone, so a run triggered by someone
|
|
28
|
-
* without write access is capped at reading — the same reasoning as
|
|
29
|
-
* review-mode's tier list, applied to the actor rather than the task.
|
|
30
|
-
*/
|
|
31
|
-
export declare const restrictedMode: AgentMode;
|
|
32
24
|
/** Every built-in mode, by name. */
|
|
33
25
|
export declare const AGENT_MODES: Record<string, AgentMode>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { BuddyConfig } from '../types';
|
|
2
|
+
import type { GitProvider } from '../git/provider';
|
|
3
|
+
import type { Logger } from '../utils/logger';
|
|
4
|
+
/**
|
|
5
|
+
* Research the repository and write an implementation plan.
|
|
6
|
+
*
|
|
7
|
+
* Runs in `planMode`, whose tier list is the guarantee rather than the
|
|
8
|
+
* instruction: a planning run is offered read tools only, so no wording in an
|
|
9
|
+
* issue body can talk it into changing the repository it is describing.
|
|
10
|
+
*
|
|
11
|
+
* @param options - Repository context and what to plan
|
|
12
|
+
* @returns The plan, ready to post as a comment
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const plan = await runPlan({ config, provider, number: 42, isPullRequest: false })
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function runPlan(options: RunPlanOptions): Promise<string>;
|
|
19
|
+
/** Inputs to a planning run. */
|
|
20
|
+
export declare interface RunPlanOptions {
|
|
21
|
+
config: BuddyConfig
|
|
22
|
+
provider: GitProvider
|
|
23
|
+
number: number
|
|
24
|
+
isPullRequest: boolean
|
|
25
|
+
request?: string
|
|
26
|
+
workspace?: string
|
|
27
|
+
logger?: Logger
|
|
28
|
+
}
|
|
@@ -15,6 +15,24 @@ export declare function getFinishingTouch(name: string): FinishingTouch;
|
|
|
15
15
|
* @param names - Touches to offer
|
|
16
16
|
*/
|
|
17
17
|
export declare function renderTouchOffer(names?: string[]): string;
|
|
18
|
+
/**
|
|
19
|
+
* Whether a pull request body already carries the offer.
|
|
20
|
+
*
|
|
21
|
+
* Checked before appending, because the job that posts it runs on more than
|
|
22
|
+
* one event and a body that accumulated the block twice would show a second
|
|
23
|
+
* set of boxes that tick independently of the first.
|
|
24
|
+
*
|
|
25
|
+
* @param body - Pull request body
|
|
26
|
+
*/
|
|
27
|
+
export declare function hasTouchOffer(body: string | null | undefined): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Append the offer to a pull request body, once.
|
|
30
|
+
*
|
|
31
|
+
* @param body - Current body
|
|
32
|
+
* @param names - Touches to offer
|
|
33
|
+
* @returns The body with the offer, or unchanged when it already has one
|
|
34
|
+
*/
|
|
35
|
+
export declare function withTouchOffer(body: string | null | undefined, names?: string[]): string;
|
|
18
36
|
/** Parse which touches a maintainer ticked. */
|
|
19
37
|
export declare function parseTouchSelections(body: string | null | undefined): string[];
|
|
20
38
|
/** Generate missing documentation comments for changed public APIs. */
|
|
@@ -29,6 +47,8 @@ export declare const simplifyTouch: FinishingTouch;
|
|
|
29
47
|
export declare const planTouch: FinishingTouch;
|
|
30
48
|
/** Every built-in finishing touch, by name. */
|
|
31
49
|
export declare const FINISHING_TOUCHES: Record<string, FinishingTouch>;
|
|
50
|
+
/** Opens the offer block, so it can be found and replaced rather than repeated. */
|
|
51
|
+
export declare const TOUCH_OFFER_MARKER: '<!-- buddy:touches -->';
|
|
32
52
|
/** A named, repeatable agent task. */
|
|
33
53
|
export declare interface FinishingTouch {
|
|
34
54
|
name: string
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AgentTool } from '../types';
|
|
2
|
+
import type { GitProvider } from '../../git/provider';
|
|
3
|
+
/**
|
|
4
|
+
* Build a tool that reads one specific issue or pull request.
|
|
5
|
+
*
|
|
6
|
+
* Scoped to a single number on purpose. A plan needs the thing it is planning,
|
|
7
|
+
* and a tool that could fetch any issue in the repository would widen what a
|
|
8
|
+
* comment from a stranger can make the agent go and read.
|
|
9
|
+
*
|
|
10
|
+
* @param provider - Provider to read from
|
|
11
|
+
* @param number - Issue or pull request number
|
|
12
|
+
* @param isPullRequest - Whether the number is a pull request
|
|
13
|
+
* @returns A read-tier tool returning the title and body as untrusted data
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const tools = [...BUILTIN_TOOLS, createReadIssueTool(provider, 42, false)]
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function createReadIssueTool(provider: GitProvider, number: number, isPullRequest: boolean): AgentTool;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read the attempt count out of a pull request body.
|
|
3
|
+
*
|
|
4
|
+
* A missing or unreadable marker reads as zero attempts rather than as an
|
|
5
|
+
* error: the guard exists to stop a loop, and refusing to act because the
|
|
6
|
+
* bookkeeping is unparseable would be a worse failure than one extra try.
|
|
7
|
+
*
|
|
8
|
+
* @param body - Pull request body, possibly null
|
|
9
|
+
* @returns The recorded state, or `null` when absent or unreadable
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseFixAttempts(body: string | null | undefined): FixAttemptState | null;
|
|
12
|
+
/**
|
|
13
|
+
* Record an attempt on a pull request body.
|
|
14
|
+
*
|
|
15
|
+
* Counted per pull request rather than per commit, deliberately. Buddy's own
|
|
16
|
+
* repair pushes a commit, so keying the count to the head sha would reset it
|
|
17
|
+
* every time a fix landed and defeat the guard it exists to provide.
|
|
18
|
+
*
|
|
19
|
+
* @param body - Current pull request body
|
|
20
|
+
* @param attempts - Total attempts including the one just made
|
|
21
|
+
* @param now - Timestamp to record
|
|
22
|
+
* @returns The body with exactly one, current, marker
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const attempts = (parseFixAttempts(pr.body)?.attempts ?? 0) + 1
|
|
26
|
+
* await provider.updatePullRequest(number, { body: upsertFixAttempts(pr.body, attempts) })
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function upsertFixAttempts(body: string | null | undefined, attempts: number, now?: Date): string;
|
|
30
|
+
/** Schema version emitted by this build. */
|
|
31
|
+
export declare const FIX_ATTEMPTS_VERSION: 1;
|
|
32
|
+
/** Attempt bookkeeping for one pull request. */
|
|
33
|
+
export declare interface FixAttemptState {
|
|
34
|
+
attempts: number
|
|
35
|
+
lastAttemptAt: string
|
|
36
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { FailureKind } from './classify';
|
|
2
|
+
import type { ListWorkflowRunsOptions, WorkflowRun } from '../git/provider';
|
|
3
|
+
import type { Logger } from '../utils/logger';
|
|
4
|
+
/**
|
|
5
|
+
* Whether the base branch is already failing the same way.
|
|
6
|
+
*
|
|
7
|
+
* Not "is the base red" but "is the base red *in the same way*". A pull
|
|
8
|
+
* request that adds a test to a repository whose lint is broken should still
|
|
9
|
+
* have its own test failure diagnosed, and a bot that downed tools whenever
|
|
10
|
+
* the base was red would be useless on exactly the repositories that need it.
|
|
11
|
+
*
|
|
12
|
+
* Comparing classifications is an approximation, and the direction it errs in
|
|
13
|
+
* is deliberate. Two unrelated type errors both classify as `type-error`, so a
|
|
14
|
+
* genuine regression on a base branch that already fails to type-check reads
|
|
15
|
+
* as inherited — Buddy declines and says why, rather than committing a guess
|
|
16
|
+
* about code it has already been told is broken.
|
|
17
|
+
*
|
|
18
|
+
* @param reader - Provider slice that can list runs and read their logs
|
|
19
|
+
* @param baseBranch - Branch the pull request targets
|
|
20
|
+
* @param kind - Failure classified from the pull request's own run
|
|
21
|
+
* @param logger - Optional logger
|
|
22
|
+
* @returns Whether the base branch fails the same way
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const inherited = await failsOnBaseBranch(provider, 'main', failure.kind)
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function failsOnBaseBranch(reader: RunHistoryReader, baseBranch: string, kind: FailureKind, logger?: Logger): Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* Reduce a run list to the newest failure of each distinct workflow.
|
|
31
|
+
*
|
|
32
|
+
* Providers interleave runs from every workflow, so the newest run overall
|
|
33
|
+
* often belongs to something unrelated. Taking the newest *per workflow*
|
|
34
|
+
* answers the question actually being asked — is this workflow red on base
|
|
35
|
+
* right now — and drops a workflow whose latest run has since gone green.
|
|
36
|
+
*
|
|
37
|
+
* Also used to pick *which* run a comment is asking about: the same
|
|
38
|
+
* interleaving that makes a base-branch check ambiguous makes "the run that
|
|
39
|
+
* failed on this pull request" ambiguous too.
|
|
40
|
+
*
|
|
41
|
+
* @param runs - Runs, most recent first
|
|
42
|
+
* @returns The newest run of each workflow, kept only where it failed
|
|
43
|
+
*/
|
|
44
|
+
export declare function latestFailurePerWorkflow(runs: WorkflowRun[]): WorkflowRun[];
|
|
45
|
+
/**
|
|
46
|
+
* The slice of a provider this check needs.
|
|
47
|
+
*
|
|
48
|
+
* Narrow on purpose: the check is pure reasoning over two reads, and taking a
|
|
49
|
+
* whole `GitProvider` would make it awkward to test something that deserves
|
|
50
|
+
* direct tests.
|
|
51
|
+
*/
|
|
52
|
+
export declare interface RunHistoryReader {
|
|
53
|
+
listWorkflowRuns: (branch: string, options?: ListWorkflowRunsOptions) => Promise<WorkflowRun[]>
|
|
54
|
+
getWorkflowRunLogs: (runId: number) => Promise<string | null>
|
|
55
|
+
}
|
package/dist/src/ci/fix.d.ts
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
import type { AiClient } from '../ai/types';
|
|
2
|
-
import type { ClassifiedFailure } from './classify';
|
|
2
|
+
import type { ClassifiedFailure, FailureKind } from './classify';
|
|
3
3
|
import type { Logger } from '../utils/logger';
|
|
4
|
-
/**
|
|
5
|
-
* Diagnose a failing CI run and repair it when the fix is clear.
|
|
6
|
-
*
|
|
7
|
-
* Ordered cheapest-first: a failure that also happens on the base branch is
|
|
8
|
-
* not this change's to fix, a known-mechanical failure is fixed without a
|
|
9
|
-
* model, and only what remains reaches the agent. This is also why fix-ci is
|
|
10
|
-
* useful with no AI configured at all.
|
|
11
|
-
*
|
|
12
|
-
* @param options - Log, repository context and repair hooks
|
|
13
|
-
* @returns What was done and a report ready to post
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* const outcome = await attemptFix({ log, workspace, baseBranch: 'main' })
|
|
17
|
-
* await provider.createComment(pr, outcome.report)
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
4
|
export declare function attemptFix(options: FixOptions): Promise<FixOutcome>;
|
|
21
5
|
/** Render a failure and its outcome as a comment body. */
|
|
22
6
|
declare function report(failure: ClassifiedFailure, conclusion: string): string;
|
|
@@ -31,12 +15,37 @@ export declare interface FixOutcome {
|
|
|
31
15
|
export declare interface FixOptions {
|
|
32
16
|
log: string
|
|
33
17
|
failsOnBase?: boolean
|
|
18
|
+
checkBase?: (kind: FailureKind) => Promise<boolean>
|
|
34
19
|
workspace: string
|
|
35
20
|
branch?: string
|
|
36
21
|
baseBranch: string
|
|
37
22
|
priorAttempts?: number
|
|
38
23
|
maxAttempts?: number
|
|
39
24
|
ai?: AiClient | null
|
|
40
|
-
regenerateLockfile?: () => Promise<
|
|
25
|
+
regenerateLockfile?: () => Promise<LockfileRepair>
|
|
26
|
+
rerun?: () => Promise<boolean>
|
|
27
|
+
dryRun?: boolean
|
|
28
|
+
analysisOnly?: boolean
|
|
41
29
|
logger?: Logger
|
|
42
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Diagnose a failing CI run and repair it when the fix is clear.
|
|
33
|
+
*
|
|
34
|
+
* Ordered cheapest-first: a failure that also happens on the base branch is
|
|
35
|
+
* not this change's to fix, a known-mechanical failure is fixed without a
|
|
36
|
+
* model, and only what remains reaches the agent. This is also why fix-ci is
|
|
37
|
+
* useful with no AI configured at all.
|
|
38
|
+
*
|
|
39
|
+
* @param options - Log, repository context and repair hooks
|
|
40
|
+
* @returns What was done and a report ready to post
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const outcome = await attemptFix({ log, workspace, baseBranch: 'main' })
|
|
44
|
+
* await provider.createComment(pr, outcome.report)
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
/** What the mechanical lock-file repair managed to do. */
|
|
48
|
+
export declare interface LockfileRepair {
|
|
49
|
+
regenerated: boolean
|
|
50
|
+
pushed: boolean
|
|
51
|
+
}
|
package/dist/src/ci/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
export type { RunHistoryReader } from './base';
|
|
1
2
|
export type { ClassifiedFailure, FailureKind } from './classify';
|
|
2
|
-
export type {
|
|
3
|
+
export type { RunFixCiOptions } from './run';
|
|
4
|
+
export type { FixOptions, FixOutcome, LockfileRepair } from './fix';
|
|
5
|
+
export { failsOnBaseBranch, latestFailurePerWorkflow } from './base';
|
|
3
6
|
export {
|
|
4
7
|
classifyFailure,
|
|
5
8
|
describeFailure,
|
|
6
9
|
extractErrorLines,
|
|
7
10
|
} from './classify';
|
|
8
11
|
export { attemptFix } from './fix';
|
|
12
|
+
export { runFixCi } from './run';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { BuddyConfig } from '../types';
|
|
2
|
+
import type { GitProvider } from '../git/provider';
|
|
3
|
+
import type { Logger } from '../utils/logger';
|
|
4
|
+
/**
|
|
5
|
+
* Diagnose a failing run and repair it when the fix is clear.
|
|
6
|
+
*
|
|
7
|
+
* Shared by `buddy fix-ci` and the `@buddy fix-ci` comment so both resolve the
|
|
8
|
+
* run, apply the anti-loop guard and report the same way.
|
|
9
|
+
*
|
|
10
|
+
* @param options - Repository context and repair settings
|
|
11
|
+
* @returns A short status line describing what happened
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const status = await runFixCi({ config, provider, prNumber: 128 })
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function runFixCi(options: RunFixCiOptions): Promise<string>;
|
|
18
|
+
/** Inputs to a repair run. */
|
|
19
|
+
export declare interface RunFixCiOptions {
|
|
20
|
+
config: BuddyConfig
|
|
21
|
+
provider: GitProvider
|
|
22
|
+
runId?: number
|
|
23
|
+
prNumber?: number
|
|
24
|
+
dryRun?: boolean
|
|
25
|
+
analysisOnly?: boolean
|
|
26
|
+
workspace?: string
|
|
27
|
+
logger?: Logger
|
|
28
|
+
}
|
|
@@ -19,5 +19,8 @@ export declare interface HandlerDeps {
|
|
|
19
19
|
review: (prNumber: number, options: { full?: boolean, summaryOnly?: boolean }) => Promise<string>
|
|
20
20
|
rebase: (prNumber: number) => Promise<string>
|
|
21
21
|
merge: () => Promise<number[]>
|
|
22
|
+
fixCi: (prNumber: number) => Promise<string>
|
|
23
|
+
plan: (number: number, isPullRequest: boolean, request: string) => Promise<string>
|
|
24
|
+
resolve: (prNumber: number) => Promise<string>
|
|
22
25
|
remember: (text: string, context: CommandContext) => Promise<string>
|
|
23
26
|
}
|
|
@@ -5,6 +5,10 @@ export declare class DashboardGenerator {
|
|
|
5
5
|
showDetectedDependencies?: boolean
|
|
6
6
|
showDeprecatedDependencies?: boolean
|
|
7
7
|
showVulnerableDependencies?: boolean
|
|
8
|
+
/** Per-ecosystem toggles within the detected-dependencies section */
|
|
9
|
+
includePackageJson?: boolean
|
|
10
|
+
includeDependencyFiles?: boolean
|
|
11
|
+
includeGitHubActions?: boolean
|
|
8
12
|
bodyTemplate?: string
|
|
9
13
|
}): { title: string, body: string };
|
|
10
14
|
}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
+
import { createSinks } from './sinks';
|
|
2
|
+
import { EventBus } from './bus';
|
|
3
|
+
import type { BuddyEvents } from './bus';
|
|
4
|
+
import type { NotificationConfig } from './sinks';
|
|
1
5
|
export type { BuddyEvents, EventSink } from './bus';
|
|
2
6
|
export type { NotificationConfig } from './sinks';
|
|
7
|
+
/**
|
|
8
|
+
* Fire one event through a bus built from the given notification config.
|
|
9
|
+
*
|
|
10
|
+
* For call sites that do not hold a `Buddy` instance — CLI actions, the
|
|
11
|
+
* review and CI paths. Sinks are built per call, which is cheap and only
|
|
12
|
+
* happens when notifications are configured at all.
|
|
13
|
+
*/
|
|
14
|
+
export declare function emitEvent<K extends keyof BuddyEvents>(notifications: NotificationConfig | undefined, event: K, payload: BuddyEvents[K]): Promise<void>;
|
|
3
15
|
export { describeEvent, EVENT_NAMES, EventBus } from './bus';
|
|
4
16
|
export {
|
|
5
17
|
createDiscordSink,
|
|
@@ -46,11 +46,21 @@ export declare function summarizeGates(results: GateResult[]): {
|
|
|
46
46
|
title: string
|
|
47
47
|
summary: string
|
|
48
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* The icon a gate result renders with.
|
|
51
|
+
*
|
|
52
|
+
* Shared with the CLI so a skipped gate looks the same in a terminal as in
|
|
53
|
+
* the check run.
|
|
54
|
+
*
|
|
55
|
+
* @param result - A gate result
|
|
56
|
+
*/
|
|
57
|
+
export declare function gateIcon(result: GateResult): string;
|
|
49
58
|
/** The result of one check. */
|
|
50
59
|
export declare interface GateResult {
|
|
51
60
|
name: string
|
|
52
61
|
mode: GateMode
|
|
53
62
|
passed: boolean
|
|
63
|
+
neutral?: boolean
|
|
54
64
|
summary: string
|
|
55
65
|
detail?: string
|
|
56
66
|
}
|