@buddysh/buddy 0.11.19 → 0.11.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/bin/cli.ts +4 -1
- package/dist/bin/cli.js +48 -48
- package/dist/bin/entry.js +1 -1
- package/dist/bin/stacks.js +1 -1
- package/dist/{chunk-5nn5mms4.js → chunk-016ce171.js} +1 -1
- package/dist/{chunk-h9deve0y.js → chunk-038mdwdf.js} +3 -3
- package/dist/{chunk-qn1g860m.js → chunk-0668q6tf.js} +1 -1
- package/dist/{chunk-89spjk6r.js → chunk-09wkxvnt.js} +2 -2
- package/dist/{chunk-q3dg57xx.js → chunk-0cqhy9qh.js} +1 -1
- package/dist/{chunk-dmaxdw65.js → chunk-0n78c2xd.js} +1 -1
- package/dist/{chunk-ar8skamr.js → chunk-1ajy5sev.js} +1 -1
- package/dist/{chunk-3pg9420w.js → chunk-1aw736x8.js} +1 -1
- package/dist/{chunk-88jx1n4t.js → chunk-2mtwdyka.js} +1 -1
- package/dist/{chunk-tztc0r76.js → chunk-2qwk5xfp.js} +2 -2
- package/dist/chunk-3nvrjrtp.js +2 -0
- package/dist/{chunk-2v4b940m.js → chunk-3sbrd9az.js} +1 -1
- package/dist/{chunk-z0avay86.js → chunk-5qj3vteh.js} +2 -2
- package/dist/chunk-5xgq771b.js +2 -0
- package/dist/chunk-64nen17y.js +2 -0
- package/dist/{chunk-c7ja1xmh.js → chunk-64zgq7hq.js} +2 -2
- package/dist/{chunk-snya72ah.js → chunk-6evq4y1q.js} +2 -2
- package/dist/{chunk-ry21xmre.js → chunk-6jak98cy.js} +1 -1
- package/dist/{chunk-ednwgr1b.js → chunk-6njk0m4a.js} +2 -2
- package/dist/{chunk-yy8vb4yk.js → chunk-6zp71ecf.js} +1 -1
- package/dist/chunk-71mhymva.js +2 -0
- package/dist/{chunk-yx9v94q5.js → chunk-7523xqb9.js} +2 -2
- package/dist/{chunk-fcax5a60.js → chunk-75rj89c2.js} +2 -2
- package/dist/chunk-7dgdvzxn.js +2 -0
- package/dist/{chunk-rwzt9xvk.js → chunk-7h8qjayv.js} +1 -1
- package/dist/{chunk-2g8r8khw.js → chunk-7khgke9n.js} +1 -1
- package/dist/{chunk-xqcmw7d0.js → chunk-7vk0vrwm.js} +2 -2
- package/dist/{chunk-rrm4x81p.js → chunk-91gpxfta.js} +1 -1
- package/dist/chunk-9dtfray9.js +2 -0
- package/dist/{chunk-6bdrm4ab.js → chunk-9g0am1m2.js} +2 -2
- package/dist/chunk-9k79e8wa.js +2 -0
- package/dist/{chunk-5feeegzy.js → chunk-9rvapdmv.js} +2 -2
- package/dist/chunk-a1ta528t.js +2 -0
- package/dist/{chunk-ewnhhpak.js → chunk-a7r9dwmt.js} +1 -1
- package/dist/chunk-aa8gbnyc.js +2 -0
- package/dist/chunk-aw70467z.js +2 -0
- package/dist/{chunk-dev3g0n3.js → chunk-b1ng5aqx.js} +2 -2
- package/dist/chunk-b7f35wap.js +2 -0
- package/dist/{chunk-91q9x0df.js → chunk-brk9jn8q.js} +1 -1
- package/dist/chunk-cb6g7nt3.js +2 -0
- package/dist/{chunk-tqwek43e.js → chunk-cbzc9ggs.js} +1 -1
- package/dist/{chunk-dgcct70c.js → chunk-cf5czw9m.js} +2 -2
- package/dist/{chunk-ebb90mp9.js → chunk-cftyw099.js} +1 -1
- package/dist/chunk-cndn37he.js +2 -0
- package/dist/chunk-cpc1y0gs.js +2 -0
- package/dist/{chunk-qbqk1jax.js → chunk-cqh3eadc.js} +2 -2
- package/dist/chunk-csf42r3d.js +2 -0
- package/dist/{chunk-xyry3bma.js → chunk-dmqptf7k.js} +2 -2
- package/dist/chunk-dvnshk0g.js +2 -0
- package/dist/{chunk-xmk24pz9.js → chunk-dz2e81v7.js} +2 -2
- package/dist/{chunk-0pf9vk80.js → chunk-ep7hn1za.js} +1 -1
- package/dist/chunk-ezjvwa4v.js +2 -0
- package/dist/{chunk-y6292gbf.js → chunk-fanj4t6c.js} +2 -2
- package/dist/chunk-fr2rhvnt.js +2 -0
- package/dist/chunk-fr7tw9n2.js +2 -0
- package/dist/{chunk-cp3g2srn.js → chunk-g0ttytab.js} +2 -2
- package/dist/chunk-gcmx3cp6.js +2 -0
- package/dist/{chunk-73a090ce.js → chunk-gn3tjadq.js} +2 -2
- package/dist/chunk-gqqqhe3n.js +2 -0
- package/dist/{chunk-r0jmwzr3.js → chunk-gt3m1eqn.js} +1 -1
- package/dist/{chunk-6kmaj5br.js → chunk-h0bf6z4x.js} +2 -2
- package/dist/{chunk-8hstj0s3.js → chunk-jrkmj5ex.js} +1 -1
- package/dist/chunk-jzhsa1xh.js +2 -0
- package/dist/chunk-kebfqksf.js +2 -0
- package/dist/{chunk-sg7bhtb7.js → chunk-kfn6xbc6.js} +1 -1
- package/dist/{chunk-065sjjzg.js → chunk-m7v1dba6.js} +2 -2
- package/dist/{chunk-20sxtyt7.js → chunk-me7y4rd3.js} +1 -1
- package/dist/{chunk-jxmpwday.js → chunk-mpk7ypxd.js} +1 -1
- package/dist/{chunk-33ymc651.js → chunk-n1g9gs8x.js} +3 -3
- package/dist/{chunk-t7grk0az.js → chunk-n5mvfhd0.js} +2 -2
- package/dist/{chunk-m6qym0ya.js → chunk-n7hbbha7.js} +2 -2
- package/dist/{chunk-5ytyahtm.js → chunk-n8zfts91.js} +4 -4
- package/dist/{chunk-g763t4rr.js → chunk-nap5dm82.js} +2 -2
- package/dist/chunk-nekgd2v5.js +2 -0
- package/dist/{chunk-q2tjkhez.js → chunk-np5qajht.js} +1 -1
- package/dist/{chunk-dkgz8hsd.js → chunk-nqgn0drz.js} +7 -7
- package/dist/{chunk-vpz26asn.js → chunk-nrm7vjmv.js} +2 -2
- package/dist/chunk-nwj826gp.js +2 -0
- package/dist/chunk-p0s7w67s.js +2 -0
- package/dist/{chunk-nmrf0ydg.js → chunk-p59g8wwa.js} +1 -1
- package/dist/{chunk-qfm0eh6y.js → chunk-pakq6dsv.js} +2 -2
- package/dist/{chunk-eq5xb8k1.js → chunk-q31cbz9d.js} +2 -2
- package/dist/{chunk-vn4c8fxq.js → chunk-q496yz80.js} +1 -1
- package/dist/chunk-q7250hvx.js +4 -0
- package/dist/chunk-q8wzcyxj.js +2 -0
- package/dist/{chunk-jy1kbr1k.js → chunk-qeg388qq.js} +2 -2
- package/dist/{chunk-8y4szfd2.js → chunk-rad9rc2j.js} +1 -1
- package/dist/chunk-rbhz8bda.js +2 -0
- package/dist/{chunk-wm6g7y1r.js → chunk-rk5j5mcr.js} +1 -1
- package/dist/chunk-rma8b124.js +2 -0
- package/dist/{chunk-hwpv7jhw.js → chunk-s3g9x8wf.js} +2 -2
- package/dist/{chunk-f3fmewqb.js → chunk-s44q0cps.js} +2 -2
- package/dist/{chunk-z906zp4k.js → chunk-s8apaa3h.js} +5 -5
- package/dist/chunk-sa2m2y9s.js +2 -0
- package/dist/{chunk-5qxs04gf.js → chunk-skg1syjj.js} +1 -1
- package/dist/chunk-swmkkya0.js +2 -0
- package/dist/chunk-t64134ws.js +2 -0
- package/dist/{chunk-x9spxa46.js → chunk-t68hsq01.js} +2 -2
- package/dist/{chunk-539wp217.js → chunk-t81252jj.js} +2 -2
- package/dist/{chunk-58et72hc.js → chunk-tf0mb8m0.js} +2 -2
- package/dist/{chunk-6477cdgj.js → chunk-txpb6btd.js} +1 -1
- package/dist/chunk-tzz4mpz5.js +2 -0
- package/dist/{chunk-ffjp134d.js → chunk-v32q2vv7.js} +1 -1
- package/dist/chunk-v8dteyvv.js +2 -0
- package/dist/{chunk-j9pe2np4.js → chunk-vcn1gemr.js} +1 -1
- package/dist/chunk-ve9xvyez.js +2 -0
- package/dist/chunk-vtjh07ea.js +2 -0
- package/dist/chunk-wc68652g.js +2 -0
- package/dist/{chunk-5q5tm30a.js → chunk-we0x722x.js} +1 -1
- package/dist/{chunk-ng9zksy3.js → chunk-weqbnsnn.js} +1 -1
- package/dist/{chunk-agdvymzh.js → chunk-wr7scn9c.js} +1 -1
- package/dist/{chunk-wca85ahg.js → chunk-x33ryte5.js} +2 -2
- package/dist/{chunk-vxt1h0c4.js → chunk-x496v9vb.js} +1 -1
- package/dist/chunk-x7y2eh7c.js +2 -0
- package/dist/chunk-xd6sxr1m.js +3 -0
- package/dist/{chunk-ejfyc7r8.js → chunk-xdqk8fzw.js} +1 -1
- package/dist/chunk-xkhznax2.js +2 -0
- package/dist/{chunk-dh8yykbg.js → chunk-xmqv24zr.js} +1 -1
- package/dist/{chunk-47k0qdd5.js → chunk-xt0k22yx.js} +2 -2
- package/dist/{chunk-xn2xv07k.js → chunk-xx7cytzs.js} +2 -2
- package/dist/chunk-y59p36an.js +2 -0
- package/dist/{chunk-7bqy4enq.js → chunk-y5t07fny.js} +1 -1
- package/dist/{chunk-a5hevn6e.js → chunk-yknz94wd.js} +2 -2
- package/dist/{chunk-pxv58dh1.js → chunk-yzyqkwsc.js} +1 -1
- package/dist/{chunk-s6w47z4a.js → chunk-zbk3g5vf.js} +3 -3
- package/dist/{chunk-wx4qd9e9.js → chunk-ze91acnq.js} +1 -1
- package/dist/chunk-zhgwbbj9.js +2 -0
- package/dist/{chunk-xntpzagn.js → chunk-zqrgvftj.js} +1 -1
- package/dist/chunk-zza4y6dx.js +2 -0
- package/dist/src/index.js +1 -1
- package/dist/src/setup.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-05nyhkdp.js +0 -2
- package/dist/chunk-0796xk82.js +0 -2
- package/dist/chunk-11599831.js +0 -2
- package/dist/chunk-1et7ppg7.js +0 -2
- package/dist/chunk-23cjwxjk.js +0 -2
- package/dist/chunk-4gf3a9pm.js +0 -2
- package/dist/chunk-4we8d2ys.js +0 -2
- package/dist/chunk-6m03hqbw.js +0 -3
- package/dist/chunk-78pxywjv.js +0 -2
- package/dist/chunk-843907bh.js +0 -2
- package/dist/chunk-8fm0z13m.js +0 -2
- package/dist/chunk-9pt7kwmm.js +0 -2
- package/dist/chunk-b8n7zh62.js +0 -2
- package/dist/chunk-by2hfewp.js +0 -2
- package/dist/chunk-cfj98vmf.js +0 -2
- package/dist/chunk-cxbrnbcp.js +0 -2
- package/dist/chunk-e0d1n3yn.js +0 -2
- package/dist/chunk-ece98jde.js +0 -2
- package/dist/chunk-en525sf9.js +0 -2
- package/dist/chunk-f694pp35.js +0 -2
- package/dist/chunk-h65g7hd0.js +0 -2
- package/dist/chunk-hfq56cgn.js +0 -2
- package/dist/chunk-jq846den.js +0 -2
- package/dist/chunk-nezqdnp3.js +0 -2
- package/dist/chunk-q9x936wq.js +0 -2
- package/dist/chunk-rmv4ajb2.js +0 -2
- package/dist/chunk-rsvtnsmt.js +0 -2
- package/dist/chunk-sek2e857.js +0 -2
- package/dist/chunk-tes3e84x.js +0 -2
- package/dist/chunk-tgm4vbaq.js +0 -2
- package/dist/chunk-v0895nt9.js +0 -2
- package/dist/chunk-v6rrvfh4.js +0 -2
- package/dist/chunk-vyckmje5.js +0 -2
- package/dist/chunk-we1n57ze.js +0 -2
- package/dist/chunk-wnqqprmy.js +0 -2
- package/dist/chunk-wt8b3ywq.js +0 -2
- package/dist/chunk-x0mq8nn2.js +0 -2
- package/dist/chunk-xfk9a8az.js +0 -2
- package/dist/chunk-xvq8w2jm.js +0 -2
- package/dist/chunk-ye3aym4p.js +0 -2
- package/dist/chunk-yxt8294f.js +0 -2
- package/dist/chunk-zy6azdxt.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{_f as B}from"./chunk-me7y4rd3.js";import{Sh as $}from"./chunk-kfn6xbc6.js";import{Yh as Z}from"./chunk-91gpxfta.js";var _=["scan.completed","pr.created","pr.updated","pr.closed","pr.merged","security.advisories","dashboard.updated","review.completed","fixci.completed","gate.failed","run.failed"];class I{logger;sinks=[];constructor(z=Z()){this.logger=z}register(z){this.sinks.push(z)}get size(){return this.sinks.length}async emit(z,q){let j=this.sinks.filter((C)=>!C.events?.length||C.events.includes(z));if(j.length===0)return;await Promise.all(j.map(async(C)=>{try{await C.deliver(z,q),this.logger.debug(`\uD83D\uDCE3 Delivered ${z} to ${C.name}`)}catch(F){this.logger.warn(`\u26A0\uFE0F Could not deliver ${z} to ${C.name}: ${F}`)}}))}}function J(z,q){switch(z){case"scan.completed":{let j=q;return`Found ${j.total} update(s): ${j.major} major, ${j.minor} minor, ${j.patch} patch`}case"pr.created":{let j=q;return`Opened #${j.number}: ${j.title}`}case"pr.merged":{let j=q;return`Merged #${j.number}: ${j.title}`}case"security.advisories":return`${q.packages.length} dependency/dependencies with known advisories`;case"pr.updated":{let j=q;return`Updated #${j.number}: ${j.title}`}case"pr.closed":{let j=q;return`Closed #${j.number} (${j.reason}): ${j.title}`}case"dashboard.updated":return`Dashboard refreshed: #${q.number}`;case"review.completed":{let j=q;return`Reviewed #${j.number}: ${j.findings} finding(s)`}case"fixci.completed":{let j=q;return`fix-ci ${j.action}${j.fixed?" (fixed)":""}${j.number?` on #${j.number}`:""}`}case"gate.failed":{let j=q;return`Gates failed on #${j.number}: ${j.checks.join(", ")}`}case"run.failed":{let j=q;return`\`${j.command}\` failed: ${j.error}`}default:return z}}import{createHmac as K}from"crypto";import N from"process";var P=1;function U(z){if(!z)return[];let q=[],j=M(z.slack?.webhookEnv??"SLACK_WEBHOOK_URL");if(j)q.push(V(j,z.slack?.events));let C=M(z.discord?.webhookEnv??"DISCORD_WEBHOOK_URL");if(C)q.push(Y(C,z.discord?.events));for(let[F,G]of(z.webhooks??[]).entries())q.push(A(G,F));return q}function V(z,q){return{name:"slack",...q?.length?{events:q}:{},async deliver(j,C){await Q(z,{text:`Buddy: ${J(j,C)}`,blocks:[{type:"section",text:{type:"mrkdwn",text:`*Buddy*
|
|
3
3
|
${J(j,C)}`}}]})}}}function Y(z,q){return{name:"discord",...q?.length?{events:q}:{},async deliver(j,C){await Q(z,{embeds:[{title:"Buddy",description:J(j,C),color:j==="security.advisories"||j==="run.failed"?14687834:3061373,timestamp:new Date().toISOString()}]})}}}function A(z,q=0){let j=z.secretEnv?M(z.secretEnv):void 0;return{name:`webhook[${q}]`,...z.events?.length?{events:z.events}:{},async deliver(C,F){let G=JSON.stringify({version:P,event:C,payload:F,sentAt:new Date().toISOString()}),X={"Content-Type":"application/json"};if(j)X["x-buddy-signature"]=`sha256=${R(G,j)}`;await Q(z.url,G,X)}}}function R(z,q){return K("sha256",q).update(z).digest("hex")}async function Q(z,q,j={}){let C=await $(z,{method:"POST",headers:{"Content-Type":"application/json",...j},body:typeof q==="string"?q:JSON.stringify(q)});if(!C.ok){let F=await C.text().catch(()=>"");throw Error(`${C.status} ${C.statusText} ${B(F.slice(0,200))}`.trim())}}function M(z){let q=N.env[z];return q?.trim()?q.trim():void 0}
|
|
4
|
-
export{_ as
|
|
4
|
+
export{_ as Id,I as Jd,J as Kd,P as Ld,U as Md,V as Nd,Y as Od,A as Pd,R as Qd};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Hd as R}from"./chunk-9g0am1m2.js";import{ue as F,ve as A}from"./chunk-9rvapdmv.js";import{Ef as S}from"./chunk-016ce171.js";import{Uf as L}from"./chunk-fanj4t6c.js";import{Vh as K,Yh as O}from"./chunk-91gpxfta.js";import{nl as P}from"./chunk-xmqv24zr.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-txpb6btd.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-gqqqhe3n.js"),{commitAndPush:Y}=await import("./chunk-6jak98cy.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
|
-
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
|
|
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 _a,T as $a,G as ab,M as bb,_ as cb,I as db,c as eb};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Vf as D}from"./chunk-7h8qjayv.js";import{Yh as C}from"./chunk-91gpxfta.js";var O=".buddy/learnings.jsonl",R=20;function T(P){if(!P)return[];let E=[];for(let v of P.split(`
|
|
3
3
|
`)){let L=v.trim();if(!L||L.startsWith("#"))continue;try{let A=JSON.parse(L);if(typeof A.text!=="string"||!A.text.trim())continue;E.push({id:typeof A.id==="string"?A.id:_(A.text),text:A.text.trim(),...Array.isArray(A.paths)?{paths:A.paths.filter((o)=>typeof o==="string")}:{},...typeof A.kind==="string"?{kind:A.kind}:{},...A.source&&typeof A.source==="object"?{source:A.source}:{},createdAt:typeof A.createdAt==="string"?A.createdAt:new Date(0).toISOString()})}catch{continue}}return E}function M(P){return`${P.map((E)=>JSON.stringify(E)).join(`
|
|
4
4
|
`)}
|
|
5
5
|
`}function N(P,E={}){return{id:_(P),text:P.trim(),...E.paths?.length?{paths:E.paths}:{},...E.kind?{kind:E.kind}:{},...E.source?{source:E.source}:{},createdAt:new Date().toISOString()}}function Y(P,E){return[...P.filter((v)=>v.id!==E.id),E]}function q(P,E,v=R){let L=P.map((A)=>{if(!A.paths?.length)return{learning:A,score:1};let o=D(A.paths),I=E.some((V)=>o.matches(V));return{learning:A,score:I?2:0}}).filter((A)=>A.score>0);return L.sort((A,o)=>{if(A.score!==o.score)return o.score-A.score;return o.learning.createdAt.localeCompare(A.learning.createdAt)}),L.slice(0,v).map((A)=>A.learning)}function B(P){if(P.length===0)return"";return`Things this repository has told you before:
|
|
6
6
|
${P.map((v)=>{let L=v.paths?.length?` (${v.paths.join(", ")})`:"";return`- ${v.text}${L}`}).join(`
|
|
7
|
-
`)}`}async function G(P,E,v=O,L=C()){try{let A=await P(v,E),o=T(A);if(o.length>0)L.debug(`\uD83E\uDDE0 Loaded ${o.length} learning(s) from ${v} at ${E}`);return o}catch(A){return L.debug(`Could not read ${v} at ${E}: ${A}`),[]}}function _(P){let E=P.toLowerCase().replace(/\s+/g," ").trim(),v=0;for(let L=0;L<E.length;L++)v=v*31+E.charCodeAt(L)|0;return`l_${Math.abs(v).toString(36)}`}export{O as
|
|
7
|
+
`)}`}async function G(P,E,v=O,L=C()){try{let A=await P(v,E),o=T(A);if(o.length>0)L.debug(`\uD83E\uDDE0 Loaded ${o.length} learning(s) from ${v} at ${E}`);return o}catch(A){return L.debug(`Could not read ${v} at ${E}: ${A}`),[]}}function _(P){let E=P.toLowerCase().replace(/\s+/g," ").trim(),v=0;for(let L=0;L<E.length;L++)v=v*31+E.charCodeAt(L)|0;return`l_${Math.abs(v).toString(36)}`}export{O as Sb,R as Tb,T as Ub,M as Vb,N as Wb,Y as Xb,q as Yb,B as Zb,G as _b};
|
|
@@ -6,4 +6,4 @@ var V=/^diff --git a\/(.+?) b\/(.+)$/,W=/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@
|
|
|
6
6
|
${S}`),O+=S.length,B.push(z)}return{text:j.join(`
|
|
7
7
|
|
|
8
8
|
`),files:B,omitted:M}}async function Z(Q,G,J){let q=G?["diff","--no-color",`${Q}...${G}`]:["diff","--no-color",Q],v=Bun.spawn(["git",...q],{cwd:J,stdout:"pipe",stderr:"pipe"}),[B,M]=await Promise.all([new Response(v.stdout).text(),v.exited]);if(M!==0){let j=await new Response(v.stderr).text();throw Error(`git diff failed: ${j.trim()}`)}return B}
|
|
9
|
-
export{X as
|
|
9
|
+
export{X as Gb,Y as Hb,Z as Ib};
|