@buddysh/buddy 0.11.11 → 0.11.13

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.
Files changed (144) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/bin/cli.ts +5 -8
  3. package/dist/bin/cli.js +74 -74
  4. package/dist/{chunk-raj75r4h.js → chunk-01d81hn0.js} +1 -1
  5. package/dist/{chunk-z05djfac.js → chunk-028354j6.js} +7 -7
  6. package/dist/chunk-0w6jmcsh.js +2 -0
  7. package/dist/{chunk-3c114myc.js → chunk-1tdkpeva.js} +1 -1
  8. package/dist/{chunk-2e4e6zjs.js → chunk-1znpbjrv.js} +1 -1
  9. package/dist/{chunk-0g4ybxwj.js → chunk-2b07w74s.js} +1 -1
  10. package/dist/{chunk-42xvqxdw.js → chunk-2z85fqdp.js} +2 -2
  11. package/dist/{chunk-b9szrnxw.js → chunk-34vracy4.js} +1 -1
  12. package/dist/chunk-3578axtf.js +2 -0
  13. package/dist/{chunk-2jjrxgs1.js → chunk-37zd94a7.js} +2 -2
  14. package/dist/{chunk-pq115qkn.js → chunk-3a5gcj3y.js} +1 -1
  15. package/dist/{chunk-1xe0960b.js → chunk-3a63hke8.js} +1 -1
  16. package/dist/{chunk-dsnd6ndd.js → chunk-3nn2j810.js} +1 -1
  17. package/dist/chunk-3r0jb90q.js +2 -0
  18. package/dist/{chunk-ycbk7tg9.js → chunk-4fh7w98z.js} +1 -1
  19. package/dist/{chunk-sxfk3naz.js → chunk-4kyxrwxn.js} +1 -1
  20. package/dist/{chunk-vtr2vbk0.js → chunk-4qv88x27.js} +1 -1
  21. package/dist/chunk-4x1mv7qj.js +2 -0
  22. package/dist/{chunk-d9m42wym.js → chunk-54hdfa8r.js} +1 -1
  23. package/dist/{chunk-va3k91tf.js → chunk-5sh69bkj.js} +1 -1
  24. package/dist/{chunk-g0x10e1d.js → chunk-66nntsnf.js} +1 -1
  25. package/dist/chunk-6hyrj0b5.js +2 -0
  26. package/dist/{chunk-mt53v4sx.js → chunk-6np84pfr.js} +1 -1
  27. package/dist/{chunk-hc651afv.js → chunk-6prz7chv.js} +1 -1
  28. package/dist/{chunk-bsh3kp53.js → chunk-6qw89f68.js} +1 -1
  29. package/dist/{chunk-mpb1g0xk.js → chunk-7b156stw.js} +1 -1
  30. package/dist/{chunk-2z9pkk1y.js → chunk-7t8s2mcf.js} +1 -1
  31. package/dist/{chunk-25sjd6zk.js → chunk-83srz04v.js} +4 -4
  32. package/dist/chunk-86xv8x00.js +2 -0
  33. package/dist/chunk-87k997bm.js +2 -0
  34. package/dist/chunk-8jvmqdvc.js +2 -0
  35. package/dist/{chunk-gpjde0j6.js → chunk-92gh2n65.js} +1 -1
  36. package/dist/{chunk-54er1whp.js → chunk-94tnmc7j.js} +2 -2
  37. package/dist/{chunk-csqh2ca4.js → chunk-9n1kth4b.js} +1 -1
  38. package/dist/{chunk-z4btj7s0.js → chunk-a6hv92fx.js} +1 -1
  39. package/dist/{chunk-rr8apsh5.js → chunk-awjm9n45.js} +1 -1
  40. package/dist/{chunk-2hb8dan0.js → chunk-bgw39afd.js} +1 -1
  41. package/dist/{chunk-wt83nzn3.js → chunk-bstgsak0.js} +1 -1
  42. package/dist/{chunk-33h1me7n.js → chunk-c4cj24qm.js} +2 -2
  43. package/dist/chunk-c8xfj0m5.js +2 -0
  44. package/dist/{chunk-08daxhzx.js → chunk-c9266b5x.js} +1 -1
  45. package/dist/{chunk-4kr6evh6.js → chunk-ce26jarj.js} +1 -1
  46. package/dist/chunk-cj5fkyxv.js +2 -0
  47. package/dist/{chunk-7c1284fb.js → chunk-cx89kty3.js} +1 -1
  48. package/dist/chunk-d3m5kcpp.js +2 -0
  49. package/dist/{chunk-vs68hsbp.js → chunk-dg2q6egm.js} +1 -1
  50. package/dist/{chunk-8swwcx7w.js → chunk-dkhherd0.js} +1 -1
  51. package/dist/{chunk-qdr900z7.js → chunk-dq681xgx.js} +1 -1
  52. package/dist/{chunk-ktn47bq8.js → chunk-drmk6r1m.js} +1 -1
  53. package/dist/{chunk-5jvde2as.js → chunk-ebnc6980.js} +1 -1
  54. package/dist/{chunk-gweqk008.js → chunk-edm12hnb.js} +1 -1
  55. package/dist/{chunk-naz864cb.js → chunk-eh71jv8w.js} +1 -1
  56. package/dist/{chunk-40pvn33p.js → chunk-ekf183jk.js} +1 -1
  57. package/dist/{chunk-jhz202wk.js → chunk-fgec04jx.js} +1 -1
  58. package/dist/chunk-fzfgvt8s.js +2 -0
  59. package/dist/{chunk-dd895pm0.js → chunk-gcwg4b2w.js} +1 -1
  60. package/dist/{chunk-w55x2g9n.js → chunk-gjhxc6ma.js} +1 -1
  61. package/dist/{chunk-q7y8dvbz.js → chunk-hc2pdv4j.js} +1 -1
  62. package/dist/chunk-j21m6rf6.js +2 -0
  63. package/dist/{chunk-0m1z85m9.js → chunk-j6bejzk9.js} +1 -1
  64. package/dist/{chunk-vpw7adwd.js → chunk-j6geg3qt.js} +1 -1
  65. package/dist/{chunk-ry5zh9cx.js → chunk-j7qktvpg.js} +1 -1
  66. package/dist/chunk-jjwxbcfz.js +2 -0
  67. package/dist/{chunk-nkztawjh.js → chunk-jkn2sdm0.js} +1 -1
  68. package/dist/{chunk-apdrg3r7.js → chunk-jn3t9v6d.js} +1 -1
  69. package/dist/{chunk-b3s185kp.js → chunk-k907b533.js} +1 -1
  70. package/dist/{chunk-zk8zdv23.js → chunk-kjhqe26r.js} +1 -1
  71. package/dist/chunk-kkh3q0s2.js +2 -0
  72. package/dist/chunk-ksngk47a.js +2 -0
  73. package/dist/{chunk-y3w8h4sy.js → chunk-m00hfvnp.js} +1 -1
  74. package/dist/{chunk-65by8f14.js → chunk-m8brd9b5.js} +1 -1
  75. package/dist/{chunk-wjfw6rx8.js → chunk-ma01xp3y.js} +1 -1
  76. package/dist/{chunk-5pheqk23.js → chunk-mg67hhgj.js} +1 -1
  77. package/dist/{chunk-62j8q7sg.js → chunk-n5mz7csc.js} +1 -1
  78. package/dist/chunk-nd780ymh.js +2 -0
  79. package/dist/chunk-ngzrrqy2.js +2 -0
  80. package/dist/{chunk-afstgmb4.js → chunk-nn5rzwty.js} +1 -1
  81. package/dist/{chunk-esm5jjgf.js → chunk-p16pnhj3.js} +1 -1
  82. package/dist/{chunk-k3r7v3dp.js → chunk-p2h2z6d3.js} +2 -2
  83. package/dist/{chunk-yqfwvk9z.js → chunk-pg32mf9k.js} +1 -1
  84. package/dist/{chunk-5vekh5w1.js → chunk-q7709hwk.js} +1 -1
  85. package/dist/{chunk-vmt1bed1.js → chunk-q99xd3m5.js} +1 -1
  86. package/dist/{chunk-a3zgenkh.js → chunk-qcvtp2mt.js} +1 -1
  87. package/dist/{chunk-7b4jsg36.js → chunk-qjzpzd7j.js} +1 -1
  88. package/dist/{chunk-0rbxek2f.js → chunk-rwz433q2.js} +2 -2
  89. package/dist/{chunk-gzkwszsg.js → chunk-s5czyzje.js} +3 -3
  90. package/dist/{chunk-pegk4jhq.js → chunk-s609kp6h.js} +1 -1
  91. package/dist/{chunk-kbvj6qxc.js → chunk-s82adeq9.js} +1 -1
  92. package/dist/{chunk-59993g25.js → chunk-sn0qr6q7.js} +1 -1
  93. package/dist/{chunk-nbyxgt9c.js → chunk-t5hq4ke1.js} +1 -1
  94. package/dist/{chunk-77qe887p.js → chunk-t879n4ab.js} +1 -1
  95. package/dist/chunk-tmzd2p2n.js +2 -0
  96. package/dist/chunk-tqsrr90t.js +2 -0
  97. package/dist/{chunk-be7g40yf.js → chunk-v808b36p.js} +1 -1
  98. package/dist/chunk-v9avf6sc.js +2 -0
  99. package/dist/chunk-w2vsf1q0.js +2 -0
  100. package/dist/{chunk-89jytkd6.js → chunk-wf1jcxtr.js} +1 -1
  101. package/dist/chunk-wjmrh1nv.js +2 -0
  102. package/dist/{chunk-jsf2322c.js → chunk-x9qhsyp6.js} +2 -2
  103. package/dist/chunk-x9vpk4kk.js +7 -0
  104. package/dist/{chunk-h8wskvjv.js → chunk-xhn5331s.js} +1 -1
  105. package/dist/{chunk-b6a5txek.js → chunk-y1d6e0ye.js} +1 -1
  106. package/dist/{chunk-kq0n3x2e.js → chunk-ym9475ry.js} +1 -1
  107. package/dist/chunk-yrr9hqvw.js +2 -0
  108. package/dist/chunk-zcsahxe6.js +2 -0
  109. package/dist/chunk-zpgm9yzy.js +2 -0
  110. package/dist/{chunk-ddky3026.js → chunk-zrec546r.js} +1 -1
  111. package/dist/{chunk-x1w6q9tk.js → chunk-zwtx6vn3.js} +1 -1
  112. package/dist/chunk-zy49dwqk.js +44 -0
  113. package/dist/src/index.js +1 -1
  114. package/dist/src/pr/pr-manifest.d.ts +10 -0
  115. package/dist/src/setup.js +1 -1
  116. package/package.json +1 -1
  117. package/dist/chunk-0m6b7bac.js +0 -2
  118. package/dist/chunk-0sm25gee.js +0 -2
  119. package/dist/chunk-18xha279.js +0 -2
  120. package/dist/chunk-1tx3t9ke.js +0 -2
  121. package/dist/chunk-1w1h2tsf.js +0 -2
  122. package/dist/chunk-2h90wcxe.js +0 -2
  123. package/dist/chunk-64kt1w23.js +0 -2
  124. package/dist/chunk-6gdenphk.js +0 -2
  125. package/dist/chunk-6pcnvdj9.js +0 -2
  126. package/dist/chunk-7m1ab6p8.js +0 -2
  127. package/dist/chunk-83yea9pk.js +0 -2
  128. package/dist/chunk-9exbsfz5.js +0 -2
  129. package/dist/chunk-b59zbkfx.js +0 -2
  130. package/dist/chunk-ffbbc38r.js +0 -2
  131. package/dist/chunk-hmymd6m2.js +0 -2
  132. package/dist/chunk-knpdntnh.js +0 -7
  133. package/dist/chunk-m1zv8db4.js +0 -2
  134. package/dist/chunk-m63hkte2.js +0 -2
  135. package/dist/chunk-njrezpsw.js +0 -2
  136. package/dist/chunk-qxf3f6ks.js +0 -2
  137. package/dist/chunk-rphwf28s.js +0 -2
  138. package/dist/chunk-sd5xqd44.js +0 -2
  139. package/dist/chunk-tbt8btwf.js +0 -2
  140. package/dist/chunk-tjvvb919.js +0 -2
  141. package/dist/chunk-vpsvtb9v.js +0 -2
  142. package/dist/chunk-xdrvb89m.js +0 -44
  143. package/dist/chunk-xxwevpnr.js +0 -2
  144. package/dist/chunk-yf01hyxn.js +0 -2
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{ed as Z}from"./chunk-25sjd6zk.js";import{Nh as _}from"./chunk-x1w6q9tk.js";import Y from"process";class L{jobs=new Map;timers=new Map;logger;isRunning=!1;constructor(q=!1){this.logger=q?_.verbose():_.quiet()}addJob(q){this.jobs.set(q.id,q),this.scheduleJob(q),this.logger.info(`Scheduled job '${q.name}' with cron: ${q.schedule.cron}`)}removeJob(q){let C=this.timers.get(q);if(C)clearTimeout(C),this.timers.delete(q);this.jobs.delete(q),this.logger.info(`Removed scheduled job: ${q}`)}start(){if(this.isRunning){this.logger.warn("Scheduler is already running");return}this.isRunning=!0,this.logger.info("\uD83D\uDD52 Buddy Scheduler started");for(let q of this.jobs.values())if(this.scheduleJob(q),q.schedule.runOnStartup)this.logger.info(`Running startup job: ${q.name}`),setImmediate(()=>this.runJob(q));Y.on("SIGINT",()=>this.stop()),Y.on("SIGTERM",()=>this.stop())}stop(){if(!this.isRunning)return;this.isRunning=!1,this.logger.info("\uD83D\uDED1 Stopping Buddy Scheduler...");for(let q of this.timers.values())clearTimeout(q);this.timers.clear(),this.logger.success("\u2705 Buddy Scheduler stopped"),Y.exit(0)}getJobStatus(q){return this.jobs.get(q)}getAllJobs(){return Array.from(this.jobs.values())}scheduleJob(q){let C=this.timers.get(q.id);if(C)clearTimeout(C);let D=this.getNextRunTime(q.schedule.cron,q.schedule.timezone);if(q.nextRun=D||void 0,D){let G=D.getTime()-Date.now(),F=setTimeout(()=>{this.runJob(q),this.scheduleJob(q)},G);this.timers.set(q.id,F),this.logger.debug(`Job '${q.name}' scheduled for ${D.toISOString()}`)}}async runJob(q){if(q.status==="running"){this.logger.warn(`Job '${q.name}' is already running, skipping`);return}q.status="running",q.lastRun=new Date,this.logger.info(`\uD83D\uDE80 Running scheduled job: ${q.name}`);let C=Date.now(),D=q.schedule.maxRuntime||1800000;try{let G=new Promise((Q,U)=>{setTimeout(()=>U(Error("Job timeout")),D)}),F=this.executeJob(q);await Promise.race([F,G]);let J=Date.now()-C;q.status="idle",this.logger.success(`\u2705 Job '${q.name}' completed in ${J}ms`)}catch(G){q.status="error",this.logger.error(`\u274C Job '${q.name}' failed:`,G)}}async executeJob(q){let C=new Z(q.config),D=await C.scanForUpdates();if(D.updates.length===0){this.logger.info("No dependency updates found");return}if(this.logger.info(`Found ${D.updates.length} dependency updates`),q.config.repository&&q.config.pullRequest)await C.createPullRequests(D),this.logger.success(`Created pull requests for ${D.groups.length} update groups`);else this.logger.info("Repository not configured, skipping PR creation")}getNextRunTime(q,C){try{return this.parseCronExpression(q,C)}catch(D){return this.logger.error(`Invalid cron expression '${q}':`,D),null}}parseCronExpression(q,C){let D=q.trim().split(/\s+/);if(D.length!==5)throw Error("Cron expression must have 5 parts: minute hour day month dayOfWeek");let[G,F,J,Q,U]=D,K=new Date,V=C?this.timezoneOffsetMinutes(K,C):0;if(C)this.logger.debug(`Using timezone: ${C} (offset ${V} minutes)`);let X=new Date(K.getTime()+V*60*1000);X.setSeconds(0,0);let $=this.parseCronField(F,0,23),B=this.parseCronField(G,0,59);if($.length>0&&B.length>0){if(X.setHours($[0],B[0],0,0),X.getTime()-V*60*1000<=K.getTime())X.setDate(X.getDate()+1);return new Date(X.getTime()-V*60*1000)}return new Date(K.getTime()+3600000)}timezoneOffsetMinutes(q,C){try{let D=new Date(q.toLocaleString("en-US",{timeZone:C})),G=new Date(q.toLocaleString("en-US"));return Math.round((D.getTime()-G.getTime())/60000)}catch{return this.logger.warn(`\u26A0\uFE0F Unknown timezone "${C}", scheduling in host time instead`),0}}parseCronField(q,C,D){if(q==="*")return Array.from({length:D-C+1},(F,J)=>C+J);if(q.includes(","))return q.split(",").map(Number).filter((F)=>Number.isFinite(F)&&F>=C&&F<=D);if(q.includes("-")){let F=q.split("-").map(Number),J=F[0],Q=F[1];if(F.length!==2||!Number.isFinite(J)||!Number.isFinite(Q)||Q<J)return[];return Array.from({length:Q-J+1},(U,K)=>J+K).filter((U)=>U>=C&&U<=D)}if(q.includes("/")){let[F,J]=q.split("/"),Q=Number(J);if(!Number.isFinite(Q)||Q<=0)return[];if(F==="*")return Array.from({length:D-C+1},(K,V)=>C+V).filter((K,V)=>V%Q===0);let U=Number(F);return Number.isFinite(U)?[U].filter((K)=>K>=C&&K<=D):[]}let G=Number(q);return Number.isFinite(G)&&G>=C&&G<=D?[G]:[]}static createJobFromConfig(q,C="default"){let D={cron:q.schedule?.cron||"0 2 * * 1",timezone:q.schedule?.timezone,runOnStartup:!1,maxRuntime:1800000};return{id:C,name:`Buddy Dependency Updates (${C})`,schedule:D,status:"idle",config:q}}static PRESETS={DAILY:"0 2 * * *",WEEKLY:"0 2 * * 1",WEEKDAYS:"0 2 * * 1-5",TWICE_WEEKLY:"0 2 * * 1,4",MONTHLY:"0 2 1 * *",HOURLY:"0 * * * *",CUSTOM:(q,C,D="*")=>`${q} ${C} * * ${D}`}}
2
+ import{ed as Z}from"./chunk-83srz04v.js";import{Oh as _}from"./chunk-zwtx6vn3.js";import Y from"process";class L{jobs=new Map;timers=new Map;logger;isRunning=!1;constructor(q=!1){this.logger=q?_.verbose():_.quiet()}addJob(q){this.jobs.set(q.id,q),this.scheduleJob(q),this.logger.info(`Scheduled job '${q.name}' with cron: ${q.schedule.cron}`)}removeJob(q){let C=this.timers.get(q);if(C)clearTimeout(C),this.timers.delete(q);this.jobs.delete(q),this.logger.info(`Removed scheduled job: ${q}`)}start(){if(this.isRunning){this.logger.warn("Scheduler is already running");return}this.isRunning=!0,this.logger.info("\uD83D\uDD52 Buddy Scheduler started");for(let q of this.jobs.values())if(this.scheduleJob(q),q.schedule.runOnStartup)this.logger.info(`Running startup job: ${q.name}`),setImmediate(()=>this.runJob(q));Y.on("SIGINT",()=>this.stop()),Y.on("SIGTERM",()=>this.stop())}stop(){if(!this.isRunning)return;this.isRunning=!1,this.logger.info("\uD83D\uDED1 Stopping Buddy Scheduler...");for(let q of this.timers.values())clearTimeout(q);this.timers.clear(),this.logger.success("\u2705 Buddy Scheduler stopped"),Y.exit(0)}getJobStatus(q){return this.jobs.get(q)}getAllJobs(){return Array.from(this.jobs.values())}scheduleJob(q){let C=this.timers.get(q.id);if(C)clearTimeout(C);let D=this.getNextRunTime(q.schedule.cron,q.schedule.timezone);if(q.nextRun=D||void 0,D){let G=D.getTime()-Date.now(),F=setTimeout(()=>{this.runJob(q),this.scheduleJob(q)},G);this.timers.set(q.id,F),this.logger.debug(`Job '${q.name}' scheduled for ${D.toISOString()}`)}}async runJob(q){if(q.status==="running"){this.logger.warn(`Job '${q.name}' is already running, skipping`);return}q.status="running",q.lastRun=new Date,this.logger.info(`\uD83D\uDE80 Running scheduled job: ${q.name}`);let C=Date.now(),D=q.schedule.maxRuntime||1800000;try{let G=new Promise((Q,U)=>{setTimeout(()=>U(Error("Job timeout")),D)}),F=this.executeJob(q);await Promise.race([F,G]);let J=Date.now()-C;q.status="idle",this.logger.success(`\u2705 Job '${q.name}' completed in ${J}ms`)}catch(G){q.status="error",this.logger.error(`\u274C Job '${q.name}' failed:`,G)}}async executeJob(q){let C=new Z(q.config),D=await C.scanForUpdates();if(D.updates.length===0){this.logger.info("No dependency updates found");return}if(this.logger.info(`Found ${D.updates.length} dependency updates`),q.config.repository&&q.config.pullRequest)await C.createPullRequests(D),this.logger.success(`Created pull requests for ${D.groups.length} update groups`);else this.logger.info("Repository not configured, skipping PR creation")}getNextRunTime(q,C){try{return this.parseCronExpression(q,C)}catch(D){return this.logger.error(`Invalid cron expression '${q}':`,D),null}}parseCronExpression(q,C){let D=q.trim().split(/\s+/);if(D.length!==5)throw Error("Cron expression must have 5 parts: minute hour day month dayOfWeek");let[G,F,J,Q,U]=D,K=new Date,V=C?this.timezoneOffsetMinutes(K,C):0;if(C)this.logger.debug(`Using timezone: ${C} (offset ${V} minutes)`);let X=new Date(K.getTime()+V*60*1000);X.setSeconds(0,0);let $=this.parseCronField(F,0,23),B=this.parseCronField(G,0,59);if($.length>0&&B.length>0){if(X.setHours($[0],B[0],0,0),X.getTime()-V*60*1000<=K.getTime())X.setDate(X.getDate()+1);return new Date(X.getTime()-V*60*1000)}return new Date(K.getTime()+3600000)}timezoneOffsetMinutes(q,C){try{let D=new Date(q.toLocaleString("en-US",{timeZone:C})),G=new Date(q.toLocaleString("en-US"));return Math.round((D.getTime()-G.getTime())/60000)}catch{return this.logger.warn(`\u26A0\uFE0F Unknown timezone "${C}", scheduling in host time instead`),0}}parseCronField(q,C,D){if(q==="*")return Array.from({length:D-C+1},(F,J)=>C+J);if(q.includes(","))return q.split(",").map(Number).filter((F)=>Number.isFinite(F)&&F>=C&&F<=D);if(q.includes("-")){let F=q.split("-").map(Number),J=F[0],Q=F[1];if(F.length!==2||!Number.isFinite(J)||!Number.isFinite(Q)||Q<J)return[];return Array.from({length:Q-J+1},(U,K)=>J+K).filter((U)=>U>=C&&U<=D)}if(q.includes("/")){let[F,J]=q.split("/"),Q=Number(J);if(!Number.isFinite(Q)||Q<=0)return[];if(F==="*")return Array.from({length:D-C+1},(K,V)=>C+V).filter((K,V)=>V%Q===0);let U=Number(F);return Number.isFinite(U)?[U].filter((K)=>K>=C&&K<=D):[]}let G=Number(q);return Number.isFinite(G)&&G>=C&&G<=D?[G]:[]}static createJobFromConfig(q,C="default"){let D={cron:q.schedule?.cron||"0 2 * * 1",timezone:q.schedule?.timezone,runOnStartup:!1,maxRuntime:1800000};return{id:C,name:`Buddy Dependency Updates (${C})`,schedule:D,status:"idle",config:q}}static PRESETS={DAILY:"0 2 * * *",WEEKLY:"0 2 * * 1",WEEKDAYS:"0 2 * * 1-5",TWICE_WEEKLY:"0 2 * * 1,4",MONTHLY:"0 2 1 * *",HOURLY:"0 * * * *",CUSTOM:(q,C,D="*")=>`${q} ${C} * * ${D}`}}
3
3
  export{L as Da};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Cb as a,Db as b}from"./chunk-7b156stw.js";import"./chunk-q2tjkhez.js";import"./chunk-5yfaptmp.js";import"./chunk-sn0qr6q7.js";import"./chunk-5sh69bkj.js";import"./chunk-2b07w74s.js";import"./chunk-142zh7e5.js";import"./chunk-y1d6e0ye.js";import"./chunk-24xvskkf.js";import"./chunk-z18bksyr.js";import"./chunk-34vracy4.js";import"./chunk-zwtx6vn3.js";import"./chunk-s82adeq9.js";export{b as runReviewForPR,a as reviewPullRequest};
@@ -500,4 +500,4 @@ jobs:
500
500
  - name: Run buddy security
501
501
  run: bunx --bun @buddysh/buddy security
502
502
  `}}
503
- export{K as wh};
503
+ export{K as xh};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Dh as a}from"./chunk-p2h2z6d3.js";import"./chunk-j6geg3qt.js";import"./chunk-34vracy4.js";import"./chunk-zwtx6vn3.js";import"./chunk-s82adeq9.js";export{a as GitLabProvider};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{$a as e,Xa as a,Ya as b,Za as c,_a as d,ab as f,bb as g,cb as h,db as i,eb as j,fb as k,gb as l}from"./chunk-jqh7vx2n.js";import"./chunk-1pecmenc.js";import"./chunk-kbvj6qxc.js";export{k as withTouchOffer,b as unitTestsTouch,d as simplifyTouch,i as renderTouchOffer,e as planTouch,l as parseTouchSelections,j as hasTouchOffer,g as getFinishingTouch,a as docstringsTouch,c as autofixTouch,h as TOUCH_OFFER_MARKER,f as FINISHING_TOUCHES};
2
+ import{$a as e,Xa as a,Ya as b,Za as c,_a as d,ab as f,bb as g,cb as h,db as i,eb as j,fb as k,gb as l}from"./chunk-jqh7vx2n.js";import"./chunk-1pecmenc.js";import"./chunk-s82adeq9.js";export{k as withTouchOffer,b as unitTestsTouch,d as simplifyTouch,i as renderTouchOffer,e as planTouch,l as parseTouchSelections,j as hasTouchOffer,g as getFinishingTouch,a as docstringsTouch,c as autofixTouch,h as TOUCH_OFFER_MARKER,f as FINISHING_TOUCHES};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import"./chunk-kbvj6qxc.js";var $={error:"\x1B[31m",warning:"\x1B[33m",info:"\x1B[34m"},R={error:"error",warning:"warn ",info:"info "};function a(i,g={}){let l=g.color??!0,r=(n,t)=>l?`${n}${t}\x1B[0m`:t;if(i.workflows.length===0)return r("\x1B[90m","buddy security: no workflows found under .github/workflows.");if(i.findings.length===0)return r("\x1B[32m",`buddy security: ${i.workflows.length} workflow${i.workflows.length===1?"":"s"} clean.`);let e=new Map;for(let n of i.findings){if(!e.has(n.file))e.set(n.file,[]);e.get(n.file).push(n)}let s=[];for(let[n,t]of e){s.push(r("\x1B[1m",n));for(let o of t){let u=r($[o.severity],R[o.severity]),w=o.line!==void 0?r("\x1B[90m",`:${o.line}`):"",E=r("\x1B[90m",`(${o.ruleId})`);if(s.push(` ${u}${w} ${o.message} ${E}`),o.detail)s.push(r("\x1B[2m",` ${o.detail}`));if(o.fix)s.push(r("\x1B[2m",` fix: ${o.fix}`))}s.push("")}let f=i.findings.filter((n)=>n.severity==="error").length,c=i.findings.filter((n)=>n.severity==="warning").length,d=`${f} error${f===1?"":"s"}, ${c} warning${c===1?"":"s"} across ${e.size} workflow${e.size===1?"":"s"}`;return s.push(r(i.failed?"\x1B[31m":"\x1B[33m",d)),s.join(`
2
+ import"./chunk-s82adeq9.js";var $={error:"\x1B[31m",warning:"\x1B[33m",info:"\x1B[34m"},R={error:"error",warning:"warn ",info:"info "};function a(i,g={}){let l=g.color??!0,r=(n,t)=>l?`${n}${t}\x1B[0m`:t;if(i.workflows.length===0)return r("\x1B[90m","buddy security: no workflows found under .github/workflows.");if(i.findings.length===0)return r("\x1B[32m",`buddy security: ${i.workflows.length} workflow${i.workflows.length===1?"":"s"} clean.`);let e=new Map;for(let n of i.findings){if(!e.has(n.file))e.set(n.file,[]);e.get(n.file).push(n)}let s=[];for(let[n,t]of e){s.push(r("\x1B[1m",n));for(let o of t){let u=r($[o.severity],R[o.severity]),w=o.line!==void 0?r("\x1B[90m",`:${o.line}`):"",E=r("\x1B[90m",`(${o.ruleId})`);if(s.push(` ${u}${w} ${o.message} ${E}`),o.detail)s.push(r("\x1B[2m",` ${o.detail}`));if(o.fix)s.push(r("\x1B[2m",` fix: ${o.fix}`))}s.push("")}let f=i.findings.filter((n)=>n.severity==="error").length,c=i.findings.filter((n)=>n.severity==="warning").length,d=`${f} error${f===1?"":"s"}, ${c} warning${c===1?"":"s"} across ${e.size} workflow${e.size===1?"":"s"}`;return s.push(r(i.failed?"\x1B[31m":"\x1B[33m",d)),s.join(`
3
3
  `)}export{a as formatPretty};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Hb as a,Ib as b,Jb as c,Kb as d}from"./chunk-vckhctmr.js";import"./chunk-kbvj6qxc.js";export{c as findDrift,a as driftFor,d as describeDrift,b as ROOT};
2
+ import{Hb as a,Ib as b,Jb as c,Kb as d}from"./chunk-vckhctmr.js";import"./chunk-s82adeq9.js";export{c as findDrift,a as driftFor,d as describeDrift,b as ROOT};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{execSync as h}from"child_process";import{existsSync as P,mkdirSync as F,mkdtempSync as L,rmSync as V,writeFileSync as U}from"fs";import{tmpdir as G}from"os";import{join as w}from"path";var i=new Set,A=!1;function q(){if(A)return;A=!0;let a=()=>{for(let e of i)try{h(`pantry stop ${e}`,{stdio:"ignore",timeout:1e4})}catch{}i.clear()};process.on("exit",a),process.on("SIGINT",()=>{a(),process.exit(130)}),process.on("SIGTERM",()=>{a(),process.exit(143)})}function o(a,e=!1){let s={encoding:"utf-8",timeout:30000,stdio:e?"pipe":["pipe","pipe","pipe"]};return h(`pantry ${a}`,s)}function O(a){let e=a.match(/Name:\s+(\S+)/)?.[1]??"",s=/Status:\s+running/i.test(a),t=a.match(/Port:\s+(\d+)/),r=a.match(/PID:\s+(\d+)/),S=a.match(/Data Dir:\s+(.+)/);return{name:e,running:s,port:t?Number.parseInt(t[1],10):null,pid:r?Number.parseInt(r[1],10):null,dataDir:S?S[1].trim():null}}class n{config;_startedByUs=!1;constructor(a){this.config={name:a.name,port:a.port??0,readyTimeoutMs:a.readyTimeoutMs??15000,pollIntervalMs:a.pollIntervalMs??200,quiet:a.quiet??!0}}static isAvailable(){try{return h("pantry --version",{stdio:"ignore",timeout:5000}),!0}catch{return!1}}status(){try{let a=o(`inspect ${this.config.name}`,!0);return O(a)}catch{return{name:this.config.name,running:!1,port:null,pid:null,dataDir:null}}}isRunning(){return this.status().running}getPort(){return this.status().port}async start(){if(q(),this.isRunning())return this.status();return o(`start ${this.config.name}`,this.config.quiet),this._startedByUs=!0,i.add(this.config.name),await this.waitReady(),this.status()}async stop(){if(!this._startedByUs)return;try{o(`stop ${this.config.name}`,this.config.quiet)}catch{}i.delete(this.config.name),this._startedByUs=!1}async forceStop(){try{o(`stop ${this.config.name}`,this.config.quiet)}catch{}i.delete(this.config.name),this._startedByUs=!1}async ensureRunning(){if(this.isRunning())return this.status();return this.start()}async waitReady(){let a=Date.now()+this.config.readyTimeoutMs;while(Date.now()<a){if(this.isRunning())return;await new Promise((e)=>setTimeout(e,this.config.pollIntervalMs))}throw Error(`Service '${this.config.name}' did not become ready within ${this.config.readyTimeoutMs}ms`)}}var v=new n({name:"mysql"});async function c(a){let e=await v.ensureRunning();return{port:a?.port??e.port??3306,host:a?.host??"localhost",database:a?.database??"test",username:a?.username??"root"}}async function u(){await v.stop()}function I(a){let e=null;return{get connection(){if(!e)throw Error("MySQL not started. Ensure beforeAll has run.");return e},beforeAll:async()=>{e=await c(a)},afterAll:async()=>{await u(),e=null}}}async function D(a,e){let s=await c(e);try{return await a(s)}finally{if(e?.stopAfter!==!1)await u()}}var R=new n({name:"postgres"});async function p(a){let e=await R.ensureRunning();return{port:a?.port??e.port??5432,host:a?.host??"localhost",database:a?.database??"postgres",username:a?.username??process.env.USER??"postgres"}}async function g(){await R.stop()}function T(a){let e=null;return{get connection(){if(!e)throw Error("Postgres not started. Ensure beforeAll has run.");return e},beforeAll:async()=>{e=await p(a)},afterAll:async()=>{await g(),e=null}}}async function C(a,e){let s=await p(e);try{return await a(s)}finally{if(e?.stopAfter!==!1)await g()}}var M=new n({name:"redis"});async function f(a){let e=await M.ensureRunning(),s=a?.port??e.port??6379,t=a?.host??"localhost";return{port:s,host:t,url:`redis://${t}:${s}`}}async function d(){await M.stop()}function E(a){let e=null;return{get connection(){if(!e)throw Error("Redis not started. Ensure beforeAll has run.");return e},beforeAll:async()=>{e=await f(a)},afterAll:async()=>{await d(),e=null}}}async function b(a,e){let s=await f(e);try{return await a(s)}finally{if(e?.stopAfter!==!1)await d()}}var l=new Set,k=!1;function H(){if(k)return;k=!0;let a=()=>{for(let e of l)try{if(P(e))V(e,{recursive:!0,force:!0})}catch{}l.clear()};process.on("exit",a),process.on("SIGINT",()=>{a(),process.exit(130)}),process.on("SIGTERM",()=>{a(),process.exit(143)})}function m(a="pantry-test-"){H();let e=L(w(G(),a));return l.add(e),e}function y(a){l.delete(a);try{if(P(a))V(a,{recursive:!0,force:!0})}catch{}}async function N(a,e){let s=m(a);try{return await e(s)}finally{y(s)}}function x(a,e){let s=m(a);try{return e(s)}finally{y(s)}}function _(a,e,s){let t=w(a,e),r=t.substring(0,t.lastIndexOf("/"));if(r&&!P(r))F(r,{recursive:!0});return U(t,s),t}function B(a,e){let s=w(a,e);return F(s,{recursive:!0}),s}var $={createTempDir:m,createTestDir:B,createTestFile:_,PantryService:n,removeTempDir:y,startMysql:c,startPostgres:p,startRedis:f,stopMysql:u,stopPostgres:g,stopRedis:d,useMysql:I,usePostgres:T,useRedis:E,withMysql:D,withPostgres:C,withRedis:b,withTempDir:N,withTempDirSync:x};export{n as Dg,c as Eg,u as Fg,I as Gg,D as Hg,p as Ig,g as Jg,T as Kg,C as Lg,f as Mg,d as Ng,E as Og,b as Pg,m as Qg,y as Rg,N as Sg,x as Tg,_ as Ug,B as Vg,$ as Wg};
2
+ import{execSync as h}from"child_process";import{existsSync as P,mkdirSync as F,mkdtempSync as L,rmSync as V,writeFileSync as U}from"fs";import{tmpdir as G}from"os";import{join as w}from"path";var i=new Set,A=!1;function q(){if(A)return;A=!0;let a=()=>{for(let e of i)try{h(`pantry stop ${e}`,{stdio:"ignore",timeout:1e4})}catch{}i.clear()};process.on("exit",a),process.on("SIGINT",()=>{a(),process.exit(130)}),process.on("SIGTERM",()=>{a(),process.exit(143)})}function o(a,e=!1){let s={encoding:"utf-8",timeout:30000,stdio:e?"pipe":["pipe","pipe","pipe"]};return h(`pantry ${a}`,s)}function O(a){let e=a.match(/Name:\s+(\S+)/)?.[1]??"",s=/Status:\s+running/i.test(a),t=a.match(/Port:\s+(\d+)/),r=a.match(/PID:\s+(\d+)/),S=a.match(/Data Dir:\s+(.+)/);return{name:e,running:s,port:t?Number.parseInt(t[1],10):null,pid:r?Number.parseInt(r[1],10):null,dataDir:S?S[1].trim():null}}class n{config;_startedByUs=!1;constructor(a){this.config={name:a.name,port:a.port??0,readyTimeoutMs:a.readyTimeoutMs??15000,pollIntervalMs:a.pollIntervalMs??200,quiet:a.quiet??!0}}static isAvailable(){try{return h("pantry --version",{stdio:"ignore",timeout:5000}),!0}catch{return!1}}status(){try{let a=o(`inspect ${this.config.name}`,!0);return O(a)}catch{return{name:this.config.name,running:!1,port:null,pid:null,dataDir:null}}}isRunning(){return this.status().running}getPort(){return this.status().port}async start(){if(q(),this.isRunning())return this.status();return o(`start ${this.config.name}`,this.config.quiet),this._startedByUs=!0,i.add(this.config.name),await this.waitReady(),this.status()}async stop(){if(!this._startedByUs)return;try{o(`stop ${this.config.name}`,this.config.quiet)}catch{}i.delete(this.config.name),this._startedByUs=!1}async forceStop(){try{o(`stop ${this.config.name}`,this.config.quiet)}catch{}i.delete(this.config.name),this._startedByUs=!1}async ensureRunning(){if(this.isRunning())return this.status();return this.start()}async waitReady(){let a=Date.now()+this.config.readyTimeoutMs;while(Date.now()<a){if(this.isRunning())return;await new Promise((e)=>setTimeout(e,this.config.pollIntervalMs))}throw Error(`Service '${this.config.name}' did not become ready within ${this.config.readyTimeoutMs}ms`)}}var v=new n({name:"mysql"});async function c(a){let e=await v.ensureRunning();return{port:a?.port??e.port??3306,host:a?.host??"localhost",database:a?.database??"test",username:a?.username??"root"}}async function u(){await v.stop()}function I(a){let e=null;return{get connection(){if(!e)throw Error("MySQL not started. Ensure beforeAll has run.");return e},beforeAll:async()=>{e=await c(a)},afterAll:async()=>{await u(),e=null}}}async function D(a,e){let s=await c(e);try{return await a(s)}finally{if(e?.stopAfter!==!1)await u()}}var R=new n({name:"postgres"});async function p(a){let e=await R.ensureRunning();return{port:a?.port??e.port??5432,host:a?.host??"localhost",database:a?.database??"postgres",username:a?.username??process.env.USER??"postgres"}}async function g(){await R.stop()}function T(a){let e=null;return{get connection(){if(!e)throw Error("Postgres not started. Ensure beforeAll has run.");return e},beforeAll:async()=>{e=await p(a)},afterAll:async()=>{await g(),e=null}}}async function C(a,e){let s=await p(e);try{return await a(s)}finally{if(e?.stopAfter!==!1)await g()}}var M=new n({name:"redis"});async function f(a){let e=await M.ensureRunning(),s=a?.port??e.port??6379,t=a?.host??"localhost";return{port:s,host:t,url:`redis://${t}:${s}`}}async function d(){await M.stop()}function E(a){let e=null;return{get connection(){if(!e)throw Error("Redis not started. Ensure beforeAll has run.");return e},beforeAll:async()=>{e=await f(a)},afterAll:async()=>{await d(),e=null}}}async function b(a,e){let s=await f(e);try{return await a(s)}finally{if(e?.stopAfter!==!1)await d()}}var l=new Set,k=!1;function H(){if(k)return;k=!0;let a=()=>{for(let e of l)try{if(P(e))V(e,{recursive:!0,force:!0})}catch{}l.clear()};process.on("exit",a),process.on("SIGINT",()=>{a(),process.exit(130)}),process.on("SIGTERM",()=>{a(),process.exit(143)})}function m(a="pantry-test-"){H();let e=L(w(G(),a));return l.add(e),e}function y(a){l.delete(a);try{if(P(a))V(a,{recursive:!0,force:!0})}catch{}}async function N(a,e){let s=m(a);try{return await e(s)}finally{y(s)}}function x(a,e){let s=m(a);try{return e(s)}finally{y(s)}}function _(a,e,s){let t=w(a,e),r=t.substring(0,t.lastIndexOf("/"));if(r&&!P(r))F(r,{recursive:!0});return U(t,s),t}function B(a,e){let s=w(a,e);return F(s,{recursive:!0}),s}var $={createTempDir:m,createTestDir:B,createTestFile:_,PantryService:n,removeTempDir:y,startMysql:c,startPostgres:p,startRedis:f,stopMysql:u,stopPostgres:g,stopRedis:d,useMysql:I,usePostgres:T,useRedis:E,withMysql:D,withPostgres:C,withRedis:b,withTempDir:N,withTempDirSync:x};export{n as Eg,c as Fg,u as Gg,I as Hg,D as Ig,p as Jg,g as Kg,T as Lg,C as Mg,f as Ng,d as Og,E as Pg,b as Qg,m as Rg,y as Sg,N as Tg,x as Ug,_ as Vg,B as Wg,$ as Xg};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Vf as B}from"./chunk-z18bksyr.js";import{Jh as $}from"./chunk-b9szrnxw.js";import{Ph as Z}from"./chunk-x1w6q9tk.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*
2
+ import{Vf as B}from"./chunk-z18bksyr.js";import{Kh as $}from"./chunk-34vracy4.js";import{Qh as Z}from"./chunk-zwtx6vn3.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
4
  export{_ as vd,I as wd,J as xd,P as yd,U as zd,V as Ad,Y as Bd,A as Cd,R as Dd};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{md as J}from"./chunk-bnp0r4eh.js";import{nd as Y}from"./chunk-0f1xye20.js";import{ue as _}from"./chunk-wjfw6rx8.js";import{xe as x,ye as w}from"./chunk-w55x2g9n.js";import{Qe as z,Re as M}from"./chunk-1xe0960b.js";import{Ye as N}from"./chunk-j46f90n8.js";import{Ag as S,zg as L}from"./chunk-54er1whp.js";import{Ph as G}from"./chunk-x1w6q9tk.js";import{el as j}from"./chunk-kbvj6qxc.js";var{Glob:D}=globalThis.Bun;import{readdir as A,readFile as U,stat as Z}from"fs/promises";import{join as R,relative as E,sep as H}from"path";async function I(q,K){try{let O=JSON.parse(K),V=[];if(O.packages){for(let Q of Object.values(O.packages))if(Q.name&&Q.version)V.push({name:Q.name,currentVersion:Q.version,type:"dependencies",file:q})}return{path:q,type:"pantry.lock",content:K,dependencies:V}}catch(O){return G().warn(`Failed to parse pantry.lock file ${q}:`,O),null}}class m{projectPath;logger;ignoreGlobs=[];constructor(q,K,O){this.projectPath=q;this.logger=K;if(O&&O.length>0)this.ignoreGlobs=O.map((V)=>new D(V)),this.logger.info(`Initialized ${this.ignoreGlobs.length} ignore patterns: ${O.join(", ")}`)}async scanProject(){this.logger.info("Scanning project for package files...");let q=Date.now(),K=[];try{let O=await this.findFiles("package.json");for(let X of O){if(this.shouldIgnorePath(X))continue;let $=await this.parsePackageJsonFile(X);if($)K.push($)}let V=await this.findDependencyFiles();for(let X of V){if(this.shouldIgnorePath(X))continue;let $=await this.parseDependencyFile(X);if($)K.push($)}let Q=await this.findLockFiles();for(let X of Q){if(this.shouldIgnorePath(X))continue;let $=await this.parseLockFile(X);if($)K.push($)}let W=await this.findComposerFiles();for(let X of W){if(this.shouldIgnorePath(X))continue;let $=await this.parseComposerFile(X);if($)K.push($)}let B=await this.findGitHubActionsFiles();for(let X of B){if(this.shouldIgnorePath(X))continue;let $=await this.parseGitHubActionsFile(X);if($)K.push($)}let C=await this.findDockerfiles();this.logger.info(`\uD83D\uDD0D Found ${C.length} Dockerfile(s): ${C.join(", ")}`);for(let X of C){if(this.shouldIgnorePath(X))continue;let $=await this.parseDockerfile(X);if($)K.push($),this.logger.info(`\uD83D\uDCE6 Parsed Dockerfile: ${X} with ${$.dependencies.length} dependencies`)}let T=await this.findZigManifests();this.logger.info(`\uD83D\uDD0D Found ${T.length} Zig manifest(s): ${T.join(", ")}`);for(let X of T){if(this.shouldIgnorePath(X))continue;let $=await this.parseZigManifestFile(X);if($)K.push($),this.logger.info(`\uD83D\uDCE6 Parsed Zig manifest: ${X} with ${$.dependencies.length} dependencies`)}let b=await this.findFiles("pantry.lock");for(let X of b){if(this.shouldIgnorePath(X))continue;let $=await this.parsePantryLockFile(X);if($)K.push($),this.logger.info(`\uD83D\uDCE6 Parsed pantry.lock: ${X} with ${$.dependencies.length} dependencies`)}let v=Date.now()-q;return this.logger.success(`Found ${K.length} package files in ${v}ms`),K}catch(O){throw this.logger.error("Failed to scan project:",O),new Y(`Failed to scan project: ${O instanceof Error?O.message:"Unknown error"}`)}}async parsePackageJsonFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8"),V=JSON.parse(O),Q=[];return this.extractDependencies(V.dependencies,"dependencies",q,Q),this.extractDependencies(V.devDependencies,"devDependencies",q,Q),this.extractDependencies(V.peerDependencies,"peerDependencies",q,Q),this.extractDependencies(V.optionalDependencies,"optionalDependencies",q,Q),Q.push(...N(V.engines,q)),{path:q,type:"package.json",content:O,dependencies:Q}}catch(K){return this.logger.warn(`Failed to parse package.json file ${q}:`,K),null}}async parseLockFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8"),V=q.split("/").pop()||"",Q;if(V==="bun.lockb")Q="bun.lockb";else if(V==="package-lock.json")Q="package-lock.json";else if(V==="yarn.lock")Q="yarn.lock";else if(V==="pnpm-lock.yaml")Q="pnpm-lock.yaml";else return null;let W=await this.extractLockFileDependencies(O,Q,q);return{path:q,type:Q,content:O,dependencies:W}}catch(K){return this.logger.warn(`Failed to parse lock file ${q}:`,K),null}}async parseDependencyFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await S(q,O)}catch(K){return this.logger.warn(`Failed to parse dependency file ${q}:`,K),null}}async findDependencyFiles(){let q=[],K=["deps.yaml","deps.yml","dependencies.yaml","dependencies.yml","pkgx.yaml","pkgx.yml",".deps.yaml",".deps.yml"];for(let Q of K){let W=await this.findFiles(Q);q.push(...W)}let O=await this.findFilesByPattern("*.yaml"),V=await this.findFilesByPattern("*.yml");for(let Q of[...O,...V])if(L(Q)&&!q.includes(Q))q.push(Q);return q}async findGitHubActionsFiles(){let q=[];try{let O=R(this.projectPath,".github","workflows");if((await Z(O).catch(()=>null))?.isDirectory()){let Q=await this.findFilesByPatternInDir("*.yaml",O),W=await this.findFilesByPatternInDir("*.yml",O);for(let B of[...Q,...W])if(x(B))q.push(B)}}catch{}return q}async findDockerfiles(){return this.findFilesMatching(z)}async findFilesMatching(q,K=this.projectPath){let O=[];try{let V=await A(K);for(let Q of V){let W=R(K,Q);try{let B=await Z(W);if(B.isFile()){if(q(Q))O.push(E(this.projectPath,W).split(H).join("/"))}else if(B.isDirectory()&&!J(Q))O.push(...await this.findFilesMatching(q,W))}catch{continue}}}catch{}return O}async parseGitHubActionsFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await w(q,O)}catch(K){return this.logger.warn(`Failed to parse GitHub Actions file ${q}:`,K),null}}async parseDockerfile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await M(q,O)}catch(K){return this.logger.warn(`Failed to parse Dockerfile ${q}:`,K),null}}async findZigManifests(){let q=[];try{let K=await this.findFiles("build.zig.zon");q.push(...K)}catch{}return q}async parseZigManifestFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await _(q,O)}catch(K){return this.logger.warn(`Failed to parse Zig manifest ${q}:`,K),null}}async findComposerFiles(){let q=[];try{let K=await this.findFiles("composer.json");q.push(...K);let O=await this.findFiles("composer.lock");q.push(...O)}catch{}return q}async parseComposerFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8"),{parseComposerFile:V}=await import("./chunk-hc651afv.js");return await V(q,O)}catch(K){return this.logger.warn(`Failed to parse Composer file ${q}:`,K),null}}async parsePantryLockFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await I(q,O)}catch(K){return this.logger.warn(`Failed to parse pantry.lock file ${q}:`,K),null}}extractDependencies(q,K,O,V){if(!q)return;for(let[Q,W]of Object.entries(q))V.push({name:Q,currentVersion:W,type:K,file:this.getRelativePath(O)})}async extractLockFileDependencies(q,K,O){let V=[];if(K==="package-lock.json")try{let Q=JSON.parse(q);if(Q.packages){for(let[W,B]of Object.entries(Q.packages))if(W&&W!==""&&B&&typeof B==="object"){let C=B;if(C.version){let T=W.startsWith("node_modules/")?W.replace("node_modules/",""):W;V.push({name:T,currentVersion:C.version,type:C.dev?"devDependencies":"dependencies",file:this.getRelativePath(O)})}}}}catch(Q){this.logger.warn("Failed to parse package-lock.json:",Q)}return V}async findFiles(q,K=this.projectPath){let O=[];try{let V=await A(K);for(let Q of V){let W=R(K,Q);try{let B=await Z(W);if(B.isDirectory()){if(!J(Q)){let C=await this.findFiles(q,W);O.push(...C)}}else if(B.isFile()&&Q===q){let C=E(this.projectPath,W);O.push(C.split(H).join("/"))}}catch{continue}}}catch{}return O}async findLockFiles(){let q=["bun.lock","bun.lockb","package-lock.json","yarn.lock","pnpm-lock.yaml"],K=[];for(let O of q){let V=await this.findFiles(O);K.push(...V)}return K}async findFilesByPattern(q){let K=[],O=q.replace("*.","");try{let V=await A(this.projectPath);for(let Q of V){let W=R(this.projectPath,Q),B=await Z(W);if(B.isFile()&&Q.endsWith(`.${O}`)){let C=E(this.projectPath,W);K.push(C.split(H).join("/"))}else if(B.isDirectory()&&!J(Q)){let C=await this.findFilesByPatternInDir(q,W);K.push(...C)}}}catch{}return K}async findFilesByPatternInDir(q,K){let O=[],V=q.replace("*.","");try{let Q=await A(K);for(let W of Q){let B=R(K,W),C=await Z(B);if(C.isFile()&&W.endsWith(`.${V}`)){let T=E(this.projectPath,B);O.push(T.split(H).join("/"))}else if(C.isDirectory()&&!J(W)){let T=await this.findFilesByPatternInDir(q,B);O.push(...T)}}}catch{}return O}shouldIgnorePath(q){if(this.ignoreGlobs.length===0)return!1;let K=q;if(q.startsWith("/")||q.includes(":"))K=this.getRelativePath(q);for(let O of this.ignoreGlobs)if(O.match(K))return this.logger.debug(`Ignoring path: ${K} (matched pattern)`),!0;return!1}getRelativePath(q){return E(this.projectPath,q).split(H).join("/")}async getDependencyCount(){return(await this.scanProject()).reduce((K,O)=>K+O.dependencies.length,0)}async getUniqueDependencies(){return(await this.scanProject()).flatMap((V)=>V.dependencies).filter((V,Q,W)=>Q===W.findIndex((B)=>B.name===V.name))}}
2
+ import{md as J}from"./chunk-bnp0r4eh.js";import{nd as Y}from"./chunk-0f1xye20.js";import{ue as _}from"./chunk-ma01xp3y.js";import{xe as x,ye as w}from"./chunk-gjhxc6ma.js";import{Qe as z,Re as M}from"./chunk-3a63hke8.js";import{Ye as N}from"./chunk-j46f90n8.js";import{Ag as L,Bg as S}from"./chunk-94tnmc7j.js";import{Qh as G}from"./chunk-zwtx6vn3.js";import{fl as j}from"./chunk-s82adeq9.js";var{Glob:D}=globalThis.Bun;import{readdir as A,readFile as U,stat as Z}from"fs/promises";import{join as R,relative as E,sep as H}from"path";async function I(q,K){try{let O=JSON.parse(K),V=[];if(O.packages){for(let Q of Object.values(O.packages))if(Q.name&&Q.version)V.push({name:Q.name,currentVersion:Q.version,type:"dependencies",file:q})}return{path:q,type:"pantry.lock",content:K,dependencies:V}}catch(O){return G().warn(`Failed to parse pantry.lock file ${q}:`,O),null}}class m{projectPath;logger;ignoreGlobs=[];constructor(q,K,O){this.projectPath=q;this.logger=K;if(O&&O.length>0)this.ignoreGlobs=O.map((V)=>new D(V)),this.logger.info(`Initialized ${this.ignoreGlobs.length} ignore patterns: ${O.join(", ")}`)}async scanProject(){this.logger.info("Scanning project for package files...");let q=Date.now(),K=[];try{let O=await this.findFiles("package.json");for(let X of O){if(this.shouldIgnorePath(X))continue;let $=await this.parsePackageJsonFile(X);if($)K.push($)}let V=await this.findDependencyFiles();for(let X of V){if(this.shouldIgnorePath(X))continue;let $=await this.parseDependencyFile(X);if($)K.push($)}let Q=await this.findLockFiles();for(let X of Q){if(this.shouldIgnorePath(X))continue;let $=await this.parseLockFile(X);if($)K.push($)}let W=await this.findComposerFiles();for(let X of W){if(this.shouldIgnorePath(X))continue;let $=await this.parseComposerFile(X);if($)K.push($)}let B=await this.findGitHubActionsFiles();for(let X of B){if(this.shouldIgnorePath(X))continue;let $=await this.parseGitHubActionsFile(X);if($)K.push($)}let C=await this.findDockerfiles();this.logger.info(`\uD83D\uDD0D Found ${C.length} Dockerfile(s): ${C.join(", ")}`);for(let X of C){if(this.shouldIgnorePath(X))continue;let $=await this.parseDockerfile(X);if($)K.push($),this.logger.info(`\uD83D\uDCE6 Parsed Dockerfile: ${X} with ${$.dependencies.length} dependencies`)}let T=await this.findZigManifests();this.logger.info(`\uD83D\uDD0D Found ${T.length} Zig manifest(s): ${T.join(", ")}`);for(let X of T){if(this.shouldIgnorePath(X))continue;let $=await this.parseZigManifestFile(X);if($)K.push($),this.logger.info(`\uD83D\uDCE6 Parsed Zig manifest: ${X} with ${$.dependencies.length} dependencies`)}let b=await this.findFiles("pantry.lock");for(let X of b){if(this.shouldIgnorePath(X))continue;let $=await this.parsePantryLockFile(X);if($)K.push($),this.logger.info(`\uD83D\uDCE6 Parsed pantry.lock: ${X} with ${$.dependencies.length} dependencies`)}let v=Date.now()-q;return this.logger.success(`Found ${K.length} package files in ${v}ms`),K}catch(O){throw this.logger.error("Failed to scan project:",O),new Y(`Failed to scan project: ${O instanceof Error?O.message:"Unknown error"}`)}}async parsePackageJsonFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8"),V=JSON.parse(O),Q=[];return this.extractDependencies(V.dependencies,"dependencies",q,Q),this.extractDependencies(V.devDependencies,"devDependencies",q,Q),this.extractDependencies(V.peerDependencies,"peerDependencies",q,Q),this.extractDependencies(V.optionalDependencies,"optionalDependencies",q,Q),Q.push(...N(V.engines,q)),{path:q,type:"package.json",content:O,dependencies:Q}}catch(K){return this.logger.warn(`Failed to parse package.json file ${q}:`,K),null}}async parseLockFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8"),V=q.split("/").pop()||"",Q;if(V==="bun.lockb")Q="bun.lockb";else if(V==="package-lock.json")Q="package-lock.json";else if(V==="yarn.lock")Q="yarn.lock";else if(V==="pnpm-lock.yaml")Q="pnpm-lock.yaml";else return null;let W=await this.extractLockFileDependencies(O,Q,q);return{path:q,type:Q,content:O,dependencies:W}}catch(K){return this.logger.warn(`Failed to parse lock file ${q}:`,K),null}}async parseDependencyFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await S(q,O)}catch(K){return this.logger.warn(`Failed to parse dependency file ${q}:`,K),null}}async findDependencyFiles(){let q=[],K=["deps.yaml","deps.yml","dependencies.yaml","dependencies.yml","pkgx.yaml","pkgx.yml",".deps.yaml",".deps.yml"];for(let Q of K){let W=await this.findFiles(Q);q.push(...W)}let O=await this.findFilesByPattern("*.yaml"),V=await this.findFilesByPattern("*.yml");for(let Q of[...O,...V])if(L(Q)&&!q.includes(Q))q.push(Q);return q}async findGitHubActionsFiles(){let q=[];try{let O=R(this.projectPath,".github","workflows");if((await Z(O).catch(()=>null))?.isDirectory()){let Q=await this.findFilesByPatternInDir("*.yaml",O),W=await this.findFilesByPatternInDir("*.yml",O);for(let B of[...Q,...W])if(x(B))q.push(B)}}catch{}return q}async findDockerfiles(){return this.findFilesMatching(z)}async findFilesMatching(q,K=this.projectPath){let O=[];try{let V=await A(K);for(let Q of V){let W=R(K,Q);try{let B=await Z(W);if(B.isFile()){if(q(Q))O.push(E(this.projectPath,W).split(H).join("/"))}else if(B.isDirectory()&&!J(Q))O.push(...await this.findFilesMatching(q,W))}catch{continue}}}catch{}return O}async parseGitHubActionsFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await w(q,O)}catch(K){return this.logger.warn(`Failed to parse GitHub Actions file ${q}:`,K),null}}async parseDockerfile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await M(q,O)}catch(K){return this.logger.warn(`Failed to parse Dockerfile ${q}:`,K),null}}async findZigManifests(){let q=[];try{let K=await this.findFiles("build.zig.zon");q.push(...K)}catch{}return q}async parseZigManifestFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await _(q,O)}catch(K){return this.logger.warn(`Failed to parse Zig manifest ${q}:`,K),null}}async findComposerFiles(){let q=[];try{let K=await this.findFiles("composer.json");q.push(...K);let O=await this.findFiles("composer.lock");q.push(...O)}catch{}return q}async parseComposerFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8"),{parseComposerFile:V}=await import("./chunk-6prz7chv.js");return await V(q,O)}catch(K){return this.logger.warn(`Failed to parse Composer file ${q}:`,K),null}}async parsePantryLockFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await I(q,O)}catch(K){return this.logger.warn(`Failed to parse pantry.lock file ${q}:`,K),null}}extractDependencies(q,K,O,V){if(!q)return;for(let[Q,W]of Object.entries(q))V.push({name:Q,currentVersion:W,type:K,file:this.getRelativePath(O)})}async extractLockFileDependencies(q,K,O){let V=[];if(K==="package-lock.json")try{let Q=JSON.parse(q);if(Q.packages){for(let[W,B]of Object.entries(Q.packages))if(W&&W!==""&&B&&typeof B==="object"){let C=B;if(C.version){let T=W.startsWith("node_modules/")?W.replace("node_modules/",""):W;V.push({name:T,currentVersion:C.version,type:C.dev?"devDependencies":"dependencies",file:this.getRelativePath(O)})}}}}catch(Q){this.logger.warn("Failed to parse package-lock.json:",Q)}return V}async findFiles(q,K=this.projectPath){let O=[];try{let V=await A(K);for(let Q of V){let W=R(K,Q);try{let B=await Z(W);if(B.isDirectory()){if(!J(Q)){let C=await this.findFiles(q,W);O.push(...C)}}else if(B.isFile()&&Q===q){let C=E(this.projectPath,W);O.push(C.split(H).join("/"))}}catch{continue}}}catch{}return O}async findLockFiles(){let q=["bun.lock","bun.lockb","package-lock.json","yarn.lock","pnpm-lock.yaml"],K=[];for(let O of q){let V=await this.findFiles(O);K.push(...V)}return K}async findFilesByPattern(q){let K=[],O=q.replace("*.","");try{let V=await A(this.projectPath);for(let Q of V){let W=R(this.projectPath,Q),B=await Z(W);if(B.isFile()&&Q.endsWith(`.${O}`)){let C=E(this.projectPath,W);K.push(C.split(H).join("/"))}else if(B.isDirectory()&&!J(Q)){let C=await this.findFilesByPatternInDir(q,W);K.push(...C)}}}catch{}return K}async findFilesByPatternInDir(q,K){let O=[],V=q.replace("*.","");try{let Q=await A(K);for(let W of Q){let B=R(K,W),C=await Z(B);if(C.isFile()&&W.endsWith(`.${V}`)){let T=E(this.projectPath,B);O.push(T.split(H).join("/"))}else if(C.isDirectory()&&!J(W)){let T=await this.findFilesByPatternInDir(q,B);O.push(...T)}}}catch{}return O}shouldIgnorePath(q){if(this.ignoreGlobs.length===0)return!1;let K=q;if(q.startsWith("/")||q.includes(":"))K=this.getRelativePath(q);for(let O of this.ignoreGlobs)if(O.match(K))return this.logger.debug(`Ignoring path: ${K} (matched pattern)`),!0;return!1}getRelativePath(q){return E(this.projectPath,q).split(H).join("/")}async getDependencyCount(){return(await this.scanProject()).reduce((K,O)=>K+O.dependencies.length,0)}async getUniqueDependencies(){return(await this.scanProject()).flatMap((V)=>V.dependencies).filter((V,Q,W)=>Q===W.findIndex((B)=>B.name===V.name))}}
3
3
  export{m as ld};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{uf as k,yf as b}from"./chunk-pq115qkn.js";import{Af as C}from"./chunk-1pecmenc.js";import{Rf as x}from"./chunk-sxfk3naz.js";import{vg as v}from"./chunk-knpdntnh.js";import{Ph as D}from"./chunk-x1w6q9tk.js";var T={type:"object",properties:{changes:{type:"array",items:{type:"object",properties:{description:{type:"string",description:"What upstream changed"},version:{type:"string",description:"Version the change landed in"},affectedFiles:{type:"array",items:{type:"string"}},action:{type:"string",description:"What must be done in this repository"},automatable:{type:"boolean",description:"Whether the fix is mechanical"}},required:["description","affectedFiles","action","automatable"],additionalProperties:!1}},codemod:{type:"object",properties:{command:{type:"string",description:"Command that applies the official codemod"},source:{type:"string",description:"Where the codemod is documented"}},required:["command","source"],additionalProperties:!1},confidence:{type:"string",enum:["high","medium","low"]},effort:{type:"integer",description:"1 (trivial) to 5 (demanding)"},risks:{type:"array",items:{type:"string"}}},required:["changes","confidence","effort","risks"],additionalProperties:!1},f=[/^(?:bunx|npx|pnpm dlx|yarn dlx)\s+[\w@/.-]+(?:\s+[\w@/.:=-]+)*$/];function y(J){let Y=J.trim();if(/[;&|`$><\n]/.test(Y))return!1;return f.some((Q)=>Q.test(Y))}function R(J){let Y=J.usage.slice(0,100).map((Q)=>`${Q.path}:${Q.line} (${Q.kind}) ${Q.text}`).join(`
2
+ import{uf as k,yf as b}from"./chunk-3a5gcj3y.js";import{Af as C}from"./chunk-1pecmenc.js";import{Rf as x}from"./chunk-4kyxrwxn.js";import{vg as v}from"./chunk-x9vpk4kk.js";import{Qh as D}from"./chunk-zwtx6vn3.js";var T={type:"object",properties:{changes:{type:"array",items:{type:"object",properties:{description:{type:"string",description:"What upstream changed"},version:{type:"string",description:"Version the change landed in"},affectedFiles:{type:"array",items:{type:"string"}},action:{type:"string",description:"What must be done in this repository"},automatable:{type:"boolean",description:"Whether the fix is mechanical"}},required:["description","affectedFiles","action","automatable"],additionalProperties:!1}},codemod:{type:"object",properties:{command:{type:"string",description:"Command that applies the official codemod"},source:{type:"string",description:"Where the codemod is documented"}},required:["command","source"],additionalProperties:!1},confidence:{type:"string",enum:["high","medium","low"]},effort:{type:"integer",description:"1 (trivial) to 5 (demanding)"},risks:{type:"array",items:{type:"string"}}},required:["changes","confidence","effort","risks"],additionalProperties:!1},f=[/^(?:bunx|npx|pnpm dlx|yarn dlx)\s+[\w@/.-]+(?:\s+[\w@/.:=-]+)*$/];function y(J){let Y=J.trim();if(/[;&|`$><\n]/.test(Y))return!1;return f.some((Q)=>Q.test(Y))}function R(J){let Y=J.usage.slice(0,100).map((Q)=>`${Q.path}:${Q.line} (${Q.kind}) ${Q.text}`).join(`
3
3
  `);return[`Analyse upgrading \`${J.packageName}\` from ${J.fromVersion} to ${J.toVersion}.`,"","Report only breaking changes that affect THIS repository, judged against the","usage sites below. A breaking change in a feature this repository does not use","is not worth reporting, and listing it makes the real ones harder to find.","","Mark a change automatable only when the fix is a mechanical edit you could write","exactly. Anything needing judgement is not automatable.","","If the package publishes an official codemod for this upgrade, report the command.","","Set confidence honestly: high when every change is understood and mechanical,","low when the notes are unclear or the change touches something subtle. A low","confidence plan is more useful than a wrong high confidence one.","","--- Release notes across the version span ---",J.releaseNotes||"(none available)","",`--- Usage in this repository (${J.usage.length} site(s)) ---`,Y||"(no direct usage found)"].join(`
4
4
  `)}function A(J,Y){let Q=J??{},Z=new Set(Y.knownFiles),K=(Array.isArray(Q.changes)?Q.changes:[]).filter(($)=>Boolean($&&typeof $.description==="string"&&typeof $.action==="string")).map(($)=>({description:$.description,...$.version?{version:$.version}:{},affectedFiles:(Array.isArray($.affectedFiles)?$.affectedFiles:[]).filter((j)=>Z.has(j)),action:$.action,automatable:$.automatable===!0})),H=Q.codemod&&y(Q.codemod.command)?Q.codemod:void 0;return{packageName:Y.packageName,fromVersion:Y.fromVersion,toVersion:Y.toVersion,changes:K,...H?{codemod:H}:{},confidence:h(Q.confidence,K),effort:m(Q.effort),risks:(Array.isArray(Q.risks)?Q.risks:[]).filter(($)=>typeof $==="string")}}function E(J,Y="high"){let Q={low:0,medium:1,high:2};return Q[J.confidence]<Q[Y]}function h(J,Y){let Q=J==="high"||J==="medium"||J==="low"?J:"low";if(Q==="high"&&Y.some((Z)=>!Z.automatable))return"medium";return Q}function m(J){let Y=Number(J);if(!Number.isFinite(Y))return 3;return Math.min(5,Math.max(1,Math.round(Y)))}import{resolve as g}from"path";var c=/\.(?:[cm]?[jt]sx?|vue|svelte)$/,u=/(?:^|\/)(?:[\w.-]*\.config\.[cm]?[jt]s|\.?[\w-]*rc(?:\.\w+)?|tsconfig\.json|vite\.config\.[cm]?[jt]s)$/;async function N(J,Y,Q){let Z=J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),K=`${Z}(?:/[^'"\`]*)?`,H=new RegExp(`(?:^|\\s)import\\s[^'"\`]*['"\`]${K}['"\`]|from\\s*['"\`]${K}['"\`]`),$=new RegExp(`require\\s*\\(\\s*['"\`]${K}['"\`]\\s*\\)`),j=new RegExp(`import\\s*\\(\\s*['"\`]${K}['"\`]\\s*\\)`),W=new RegExp(`(?:^|[^\\w@/.-])${Z}(?![\\w/.-])`),q=[];for(let X of Y){let B=c.test(X),_=u.test(X);if(!B&&!_)continue;let U;try{let z=Bun.file(g(Q,X));if(!await z.exists())continue;U=await z.text()}catch{continue}if(!U.includes(J))continue;for(let[z,G]of U.split(`
5
5
  `).entries()){let F=null;if(H.test(G)||j.test(G))F="import";else if($.test(G))F="require";else if(_&&W.test(G))F="config";if(F)q.push({path:X,line:z+1,text:G.trim().slice(0,200),kind:F})}}return q}function V(J){let Y=new Map;for(let Q of J)Y.set(Q.path,(Y.get(Q.path)??0)+1);return[...Y.entries()].map(([Q,Z])=>({path:Q,count:Z})).sort((Q,Z)=>Z.count-Q.count)}var d={high:"\uD83D\uDFE2 high",medium:"\uD83D\uDFE1 medium",low:"\uD83D\uDD34 low"};function L(J,Y,Q=[]){let Z=`## \uD83D\uDD27 Migration report
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Ph as V}from"./chunk-x1w6q9tk.js";import{join as R}from"path";var K=/^catalog:(.*)$/;function N(X){let J;try{J=Bun.YAML.parse(X)}catch{return{entries:[],hasCatalogs:!1}}if(typeof J!=="object"||J===null)return{entries:[],hasCatalogs:!1};let B=J,z=[],$=!1,H=(M,j)=>{if(typeof M!=="object"||M===null||Array.isArray(M))return;$=!0;for(let[U,q]of Object.entries(M))if(typeof q==="string"&&q.trim())z.push({name:U,version:q.trim(),catalog:j})};if(H(B.catalog,"default"),typeof B.catalogs==="object"&&B.catalogs!==null)for(let[M,j]of Object.entries(B.catalogs))H(j,M);return{entries:z,hasCatalogs:$}}function k(X,J,B){let z=K.exec(X.trim());if(!z)return null;let $=z[1].trim()||"default";return J.find((H)=>H.name===B&&H.catalog===$)?.version??null}function w(X){return K.test(X.trim())}function S(X,J,B){let z=X.split(`
2
+ import{Qh as V}from"./chunk-zwtx6vn3.js";import{join as R}from"path";var K=/^catalog:(.*)$/;function N(X){let J;try{J=Bun.YAML.parse(X)}catch{return{entries:[],hasCatalogs:!1}}if(typeof J!=="object"||J===null)return{entries:[],hasCatalogs:!1};let B=J,z=[],$=!1,H=(M,j)=>{if(typeof M!=="object"||M===null||Array.isArray(M))return;$=!0;for(let[U,q]of Object.entries(M))if(typeof q==="string"&&q.trim())z.push({name:U,version:q.trim(),catalog:j})};if(H(B.catalog,"default"),typeof B.catalogs==="object"&&B.catalogs!==null)for(let[M,j]of Object.entries(B.catalogs))H(j,M);return{entries:z,hasCatalogs:$}}function k(X,J,B){let z=K.exec(X.trim());if(!z)return null;let $=z[1].trim()||"default";return J.find((H)=>H.name===B&&H.catalog===$)?.version??null}function w(X){return K.test(X.trim())}function S(X,J,B){let z=X.split(`
3
3
  `),$=/^(\s*)(["']?)([^"':]+)\2(\s*:\s*)(["']?)(.+?)\5(\s*(?:#.*)?)$/,H=null,M=!1,j=0;for(let U=0;U<z.length;U++){let q=z[U],Y=q.length-q.trimStart().length,Z=q.trim();if(/^catalog\s*:\s*$/.test(Z)){H="default",M=!1;continue}if(/^catalogs\s*:\s*$/.test(Z)){M=!0,j=Y,H=null;continue}if(M&&Y>j&&/^[\w@./-]+\s*:\s*$/.test(Z)){H=Z.replace(/\s*:\s*$/,"");continue}if(M&&Z&&Y<=j)M=!1,H=null;if(H!==J.catalog)continue;let D=$.exec(q);if(!D||D[3].trim()!==J.name||D[6].trim()!==J.version)continue;let[,x,F,E,P,G,,Q]=D;return z[U]=`${x}${F}${E}${F}${P}${G}${B}${G}${Q}`,z.join(`
4
4
  `)}return X}var W="pnpm-workspace.yaml",I="pnpm-workspace.yml";async function h(X,J,B={}){let z=B.logger??V(),$=new Set(B.ignore??[]);for(let H of[W,I]){let M=Bun.file(R(X,H));if(!await M.exists())continue;let{entries:j,hasCatalogs:U}=N(await M.text());if(!U)return{updates:[],entries:[],file:H};return z.debug(`\uD83D\uDCE6 ${H}: ${j.length} catalog entr(ies)`),{updates:(await Promise.all(j.map(async(Y)=>{if($.has(Y.name))return null;try{let Z=await J(Y.name);if(!Z)return null;let D=Y.version.replace(/^[\^~>=<\s]+/,"").trim();if(!D||D===Z)return null;return{name:Y.name,currentVersion:Y.version,newVersion:_(Y.version,Z),updateType:A(D,Z),dependencyType:"catalog",file:H,resolved:{catalog:Y.catalog}}}catch(Z){return z.debug(`Could not resolve catalog entry ${Y.name}: ${Z}`),null}}))).filter((Y)=>Y!==null),entries:j,file:H}}return{updates:[],entries:[]}}function _(X,J){return`${/^([\^~]|>=|<=|>|<)?/.exec(X.trim())?.[1]??""}${J}`}function A(X,J){let B=(H)=>H.split(".").map((M)=>Number.parseInt(M,10)||0),z=B(X),$=B(J);if((z[0]??0)!==($[0]??0))return"major";if((z[1]??0)!==($[1]??0))return"minor";return"patch"}function v(X,J){let B=X;for(let z of J){if(z.dependencyType!=="catalog")continue;B=S(B,{name:z.name,version:z.currentVersion,catalog:z.resolved?.catalog??"default"},z.newVersion)}return B}
5
5
  export{N as gc,k as hc,w as ic,S as jc,W as kc,I as lc,h as mc,v as nc};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ae as d,Be as e,Ce as f,De as g,Ee as h,xe as a,ye as b,ze as c}from"./chunk-w55x2g9n.js";import"./chunk-2z9pkk1y.js";import"./chunk-b9szrnxw.js";import"./chunk-x1w6q9tk.js";import"./chunk-kbvj6qxc.js";export{e as updateGitHubActionsFile,d as sameActionVersion,b as parseGitHubActionsFile,a as isGitHubActionsFile,c as isCommitSha,f as generateGitHubActionsUpdates,h as fetchLatestActionVersion,g as fetchActionTagCommit};
2
+ import{Ae as d,Be as e,Ce as f,De as g,Ee as h,xe as a,ye as b,ze as c}from"./chunk-gjhxc6ma.js";import"./chunk-7t8s2mcf.js";import"./chunk-34vracy4.js";import"./chunk-zwtx6vn3.js";import"./chunk-s82adeq9.js";export{e as updateGitHubActionsFile,d as sameActionVersion,b as parseGitHubActionsFile,a as isGitHubActionsFile,c as isCommitSha,f as generateGitHubActionsUpdates,h as fetchLatestActionVersion,g as fetchActionTagCommit};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{fd as a}from"./chunk-c9266b5x.js";import"./chunk-7t8s2mcf.js";import"./chunk-34vracy4.js";import"./chunk-zwtx6vn3.js";import"./chunk-s82adeq9.js";export{a as DeprecatedDependenciesChecker};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Aa as d,Ba as e,Ca as f,xa as a,ya as b,za as c}from"./chunk-a3zgenkh.js";import"./chunk-b9szrnxw.js";import"./chunk-x1w6q9tk.js";import"./chunk-kbvj6qxc.js";export{b as productFor,f as describeEol,c as cycleFor,d as checkEol,e as EOL_WARNING_DAYS,a as EOL_PRODUCTS};
2
+ import{Aa as d,Ba as e,Ca as f,xa as a,ya as b,za as c}from"./chunk-qcvtp2mt.js";import"./chunk-34vracy4.js";import"./chunk-zwtx6vn3.js";import"./chunk-s82adeq9.js";export{b as productFor,f as describeEol,c as cycleFor,d as checkEol,e as EOL_WARNING_DAYS,a as EOL_PRODUCTS};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{xh as W}from"./chunk-2z9pkk1y.js";import{Jh as y}from"./chunk-b9szrnxw.js";import{Ph as J}from"./chunk-x1w6q9tk.js";import{el as F}from"./chunk-kbvj6qxc.js";import S from"process";function G(E){let q=E.replace(/\\/g,"/");return q.includes(".github/workflows/")&&(q.endsWith(".yml")||q.endsWith(".yaml"))}async function L(E,q){try{if(!G(E))return null;let I=[],j=q.split(`
2
+ import{yh as W}from"./chunk-7t8s2mcf.js";import{Kh as y}from"./chunk-34vracy4.js";import{Qh as J}from"./chunk-zwtx6vn3.js";import{fl as F}from"./chunk-s82adeq9.js";import S from"process";function G(E){let q=E.replace(/\\/g,"/");return q.includes(".github/workflows/")&&(q.endsWith(".yml")||q.endsWith(".yaml"))}async function L(E,q){try{if(!G(E))return null;let I=[],j=q.split(`
3
3
  `);for(let K=0;K<j.length;K++){let Q=j[K].trim().match(/^-?\s*uses:\s*(.+)/);if(Q){let $=Q[1].trim().replace(/['"`]/g,"");if($.startsWith("./")||$.startsWith("docker://"))continue;let X=$.split("@");if(X.length===2){let[_,Y]=X;if(!_||!_.trim())continue;let[z,...k]=Y.split("#"),M=z.trim(),V={name:_.trim(),currentVersion:M,type:"github-actions",file:E};if(v(M)){let x=k.join("#").trim().split(/\s+/)[0];V.metadata=x?{pinnedSha:M,pinnedVersion:x}:{pinnedSha:M}}if(!I.find((x)=>x.name===V.name&&x.currentVersion===V.currentVersion))I.push(V)}}}return{path:E,type:"github-actions",content:q,dependencies:I}}catch(I){return J().warn(`Failed to parse GitHub Actions file ${E}:`,I),null}}function v(E){return/^[0-9a-f]{40}$/i.test(E)}function R(E,q){return E.replace(/^v/i,"")===q.replace(/^v/i,"")}async function U(E,q,I){try{if(!G(E))return q;let j=q;for(let K of I){let O=K.name.replace(/\s*\(.*\)$/,""),Z=O.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(K.resolved?.sha){let $=new RegExp(`((?:^\\s*-\\s*)?uses:\\s*["']?)(${Z})@(${K.currentVersion})(["']?)([ \\t]*#[^\\n]*)?`,"gm");j=j.replace($,`$1$2@${K.resolved.sha}$4 # ${K.newVersion}`);continue}let Q=new RegExp(`((?:^\\s*-\\s*)?uses:\\s*["']?)(${O.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})@(${K.currentVersion.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})(["']?)`,"gm");j=j.replace(Q,`$1$2@${K.newVersion}$4`)}return j}catch(j){return J().warn(`Failed to update GitHub Actions file ${E}:`,j),q}}async function D(E){let q=[],I=new Map;for(let j of E)if(G(j.file)){if(!I.has(j.file))I.set(j.file,[]);I.get(j.file).push(j)}for(let[j,K]of I)try{let O=await import("fs");if(O.existsSync(j)){let Z=O.readFileSync(j,"utf-8"),Q=await U(j,Z,K);q.push({path:j,content:Q,type:"update"})}}catch(O){J().warn(`Failed to generate updates for GitHub Actions file ${j}:`,O)}return q}async function b(E,q){let[I,j]=E.split("/");if(!I||!j)return null;let K={Accept:"application/vnd.github.v3+json","User-Agent":"buddy"},O=S.env.BUDDY_TOKEN||S.env.GITHUB_TOKEN||S.env.GH_TOKEN;if(O)K.Authorization=`Bearer ${O}`;try{let Z=await y(`${W()}/repos/${I}/${j}/commits/${encodeURIComponent(q)}`,{headers:K});if(!Z.ok)return null;let Q=await Z.json();return Q.sha&&v(Q.sha)?Q.sha:null}catch{return null}}async function P(E){try{if(!E.includes("/"))return J().info(`\u26A0\uFE0F Invalid action name format: ${E}`),null;let[q,I]=E.split("/");J().info(`\uD83D\uDD0D Fetching latest version for ${q}/${I}`);let j={Accept:"application/vnd.github.v3+json","User-Agent":"buddy"},K=S.env.BUDDY_TOKEN||S.env.GITHUB_TOKEN||S.env.GH_TOKEN;if(K)j.Authorization=`Bearer ${K}`;let O=W();J().info(`\uD83D\uDCE1 Trying latest release for ${q}/${I}`);let Z=await y(`${O}/repos/${q}/${I}/releases/latest`,{headers:j});if(Z.ok){let X=await Z.json();if(X.tag_name)return J().info(`\u2705 Found latest release: ${X.tag_name}`),X.tag_name}else J().info(`\u26A0\uFE0F Latest release not found: ${Z.status} ${Z.statusText}`);J().info(`\uD83D\uDCE1 Trying all releases for ${q}/${I}`);let Q=await y(`${O}/repos/${q}/${I}/releases?per_page=10`,{headers:j});if(Q.ok){let X=await Q.json();if(!Array.isArray(X))J().info("\u26A0\uFE0F Unexpected releases response format (expected array)");else{J().info(`\uD83D\uDCCB Found ${X.length} releases`);let _=X.filter((Y)=>Y.tag_name&&!Y.tag_name.includes("-")).sort((Y,z)=>{let k=Y.published_at?new Date(Y.published_at).getTime():0;return(z.published_at?new Date(z.published_at).getTime():0)-k});if(_.length>0)return J().info(`\u2705 Found latest stable release: ${_[0].tag_name}`),_[0].tag_name||null}}else J().info(`\u26A0\uFE0F Releases not found: ${Q.status} ${Q.statusText}`);J().info(`\uD83D\uDCE1 Trying tags for ${q}/${I}`);let $=await y(`${O}/repos/${q}/${I}/tags?per_page=10`,{headers:j});if($.ok){let X=await $.json();if(!Array.isArray(X))J().info("\u26A0\uFE0F Unexpected tags response format (expected array)");else{J().info(`\uD83D\uDCCB Found ${X.length} tags`);let _=X.filter((Y)=>Y.name&&!Y.name.includes("-")).map((Y)=>Y.name).sort((Y,z)=>{let k=Y.replace(/^v/,""),M=z.replace(/^v/,""),V=k.split(".").map(Number),B=M.split(".").map(Number);for(let x=0;x<Math.max(V.length,B.length);x++){let H=V[x]||0,T=B[x]||0;if(H!==T)return T-H}return 0});if(_.length>0)return J().info(`\u2705 Found latest stable tag: ${_[0]}`),_[0]}}else J().info(`\u26A0\uFE0F Tags not found: ${$.status} ${$.statusText}`);return J().info(`\u274C No version found for ${E}`),null}catch(q){return J().warn(`Failed to fetch latest version for ${E}:`,q),null}}
4
4
  export{G as xe,L as ye,v as ze,R as Ae,U as Be,D as Ce,b as De,P as Ee};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{La as a,Ma as b,Na as c,Oa as d,Pa as e,Qa as f,Ra as g,Sa as h,Ta as i,Ua as j}from"./chunk-42xvqxdw.js";import"./chunk-59993g25.js";import"./chunk-va3k91tf.js";import"./chunk-24xvskkf.js";import"./chunk-z18bksyr.js";import"./chunk-b9szrnxw.js";import"./chunk-x1w6q9tk.js";import"./chunk-kbvj6qxc.js";export{c as stripNonCommandContext,d as parseCommand,f as mentionsBot,e as isReadOnlyCommand,i as dispatchCommand,j as createHandlers,h as checkPermission,b as READ_ONLY_COMMANDS,g as HELP_TEXT,a as COMMAND_ALIASES};
2
+ import{La as a,Ma as b,Na as c,Oa as d,Pa as e,Qa as f,Ra as g,Sa as h,Ta as i,Ua as j}from"./chunk-2z85fqdp.js";import"./chunk-sn0qr6q7.js";import"./chunk-5sh69bkj.js";import"./chunk-24xvskkf.js";import"./chunk-z18bksyr.js";import"./chunk-34vracy4.js";import"./chunk-zwtx6vn3.js";import"./chunk-s82adeq9.js";export{c as stripNonCommandContext,d as parseCommand,f as mentionsBot,e as isReadOnlyCommand,i as dispatchCommand,j as createHandlers,h as checkPermission,b as READ_ONLY_COMMANDS,g as HELP_TEXT,a as COMMAND_ALIASES};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ag as a,Bg as b,Cg as c,Dg as d}from"./chunk-94tnmc7j.js";import"./chunk-drmk6r1m.js";import"./chunk-zwtx6vn3.js";import"./chunk-028354j6.js";import"./chunk-s82adeq9.js";export{c as updateDependencyFile,b as parseDependencyFile,a as isDependencyFile,d as generateDependencyFileUpdates};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Jh as U}from"./chunk-b9szrnxw.js";import{Ph as f}from"./chunk-x1w6q9tk.js";var{Glob:u}=globalThis.Bun;import{readdir as m}from"fs/promises";import{join as P,relative as l}from"path";import O from"process";var c=new Set(["node_modules","vendor","target",".git",".venv","venv","dist","build","__pycache__",".next",".cache"]);function W(z){return z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async function L(z,H,$=4){let X=H.map((K)=>new u(K)),Z=[];async function J(K,G){if(G>$)return;let V=await m(K,{withFileTypes:!0}).catch(()=>[]);for(let Q of V){let j=P(K,Q.name);if(Q.isDirectory()){if(!c.has(Q.name)&&!Q.name.startsWith("."))await J(j,G+1);continue}let q=l(z,j);if(X.some((Y)=>Y.match(Q.name)||Y.match(q)))Z.push(q)}}return await J(z,0),Z.sort()}async function M(z,H){let $=[],X=[];for(let Z of H){if(!await Bun.file(P(z,Z.lockfile)).exists())continue;let[J]=Z.command;if(!await E(J)){X.push(`${Z.lockfile} (needs \`${Z.command.join(" ")}\`)`);continue}if(await Bun.spawn(Z.command,{cwd:z,stdout:"ignore",stderr:"ignore",env:{PATH:O.env.PATH??"",HOME:O.env.HOME??""}}).exited===0)$.push(Z.lockfile);else X.push(`${Z.lockfile} (\`${Z.command.join(" ")}\` failed)`)}return{regenerated:$,...X.length>0?{note:`These lockfiles were not regenerated and need updating locally: ${X.join(", ")}.`}:{}}}async function E(z){try{return await Bun.spawn(["which",z],{stdout:"ignore",stderr:"ignore",env:{PATH:O.env.PATH??""}}).exited===0}catch{return!1}}function B(z,H){let $=(J)=>J.replace(/^[^\d]*/,"").split(/[.-]/).map((K)=>Number.parseInt(K,10)||0),X=$(z),Z=$(H);for(let J=0;J<Math.max(X.length,Z.length);J++){let K=(X[J]??0)-(Z[J]??0);if(K!==0)return K}return 0}function C(z,H){let $=(J)=>J.replace(/^[^\d]*/,"").split(/[.-]/).map((K)=>Number.parseInt(K,10)||0),X=$(z),Z=$(H);if((X[0]??0)!==(Z[0]??0))return"major";if((X[1]??0)!==(Z[1]??0))return"minor";return"patch"}var p=/^\s*(?:require\s+)?([\w.~-]+(?:\.[\w.~-]+)*\/[^\s]+)\s+(v[\w.+-]+)\s*(\/\/.*)?$/,R=/^v\d+\.\d+\.\d+-\d{14}-[a-f0-9]{12}$/,I={name:"go",manifestPatterns:["go.mod"],async detect(z){return L(z,this.manifestPatterns)},async parse(z,H){let $=[],X=!1;for(let Z of H.split(`
2
+ import{Kh as U}from"./chunk-34vracy4.js";import{Qh as f}from"./chunk-zwtx6vn3.js";var{Glob:u}=globalThis.Bun;import{readdir as m}from"fs/promises";import{join as P,relative as l}from"path";import O from"process";var c=new Set(["node_modules","vendor","target",".git",".venv","venv","dist","build","__pycache__",".next",".cache"]);function W(z){return z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async function L(z,H,$=4){let X=H.map((K)=>new u(K)),Z=[];async function J(K,G){if(G>$)return;let V=await m(K,{withFileTypes:!0}).catch(()=>[]);for(let Q of V){let j=P(K,Q.name);if(Q.isDirectory()){if(!c.has(Q.name)&&!Q.name.startsWith("."))await J(j,G+1);continue}let q=l(z,j);if(X.some((Y)=>Y.match(Q.name)||Y.match(q)))Z.push(q)}}return await J(z,0),Z.sort()}async function M(z,H){let $=[],X=[];for(let Z of H){if(!await Bun.file(P(z,Z.lockfile)).exists())continue;let[J]=Z.command;if(!await E(J)){X.push(`${Z.lockfile} (needs \`${Z.command.join(" ")}\`)`);continue}if(await Bun.spawn(Z.command,{cwd:z,stdout:"ignore",stderr:"ignore",env:{PATH:O.env.PATH??"",HOME:O.env.HOME??""}}).exited===0)$.push(Z.lockfile);else X.push(`${Z.lockfile} (\`${Z.command.join(" ")}\` failed)`)}return{regenerated:$,...X.length>0?{note:`These lockfiles were not regenerated and need updating locally: ${X.join(", ")}.`}:{}}}async function E(z){try{return await Bun.spawn(["which",z],{stdout:"ignore",stderr:"ignore",env:{PATH:O.env.PATH??""}}).exited===0}catch{return!1}}function B(z,H){let $=(J)=>J.replace(/^[^\d]*/,"").split(/[.-]/).map((K)=>Number.parseInt(K,10)||0),X=$(z),Z=$(H);for(let J=0;J<Math.max(X.length,Z.length);J++){let K=(X[J]??0)-(Z[J]??0);if(K!==0)return K}return 0}function C(z,H){let $=(J)=>J.replace(/^[^\d]*/,"").split(/[.-]/).map((K)=>Number.parseInt(K,10)||0),X=$(z),Z=$(H);if((X[0]??0)!==(Z[0]??0))return"major";if((X[1]??0)!==(Z[1]??0))return"minor";return"patch"}var p=/^\s*(?:require\s+)?([\w.~-]+(?:\.[\w.~-]+)*\/[^\s]+)\s+(v[\w.+-]+)\s*(\/\/.*)?$/,R=/^v\d+\.\d+\.\d+-\d{14}-[a-f0-9]{12}$/,I={name:"go",manifestPatterns:["go.mod"],async detect(z){return L(z,this.manifestPatterns)},async parse(z,H){let $=[],X=!1;for(let Z of H.split(`
3
3
  `)){let J=Z.trim();if(/^require\s*\($/.test(J)){X=!0;continue}if(X&&J===")"){X=!1;continue}if(!X&&!J.startsWith("require "))continue;let K=p.exec(Z);if(!K)continue;let[,G,V,Q]=K;if(Q?.includes("indirect"))continue;if(R.test(V))continue;$.push({name:G,currentVersion:V,section:"require",file:z})}return $},async latest(z,H={}){let $=H.registryUrl??"https://proxy.golang.org",X=z.name.replace(/[A-Z]/g,(K)=>`!${K.toLowerCase()}`),Z=await U(`${$}/${X}/@latest`,{headers:{"User-Agent":"buddy",Accept:"application/json"}}).catch(()=>null);if(!Z?.ok)return null;let J=await Z.json().catch(()=>null);if(!J?.Version)return null;if(R.test(J.Version))return null;return{latest:J.Version,...J.Time?{publishedAt:new Date(J.Time)}:{},releaseNotesUrl:`https://pkg.go.dev/${z.name}@${J.Version}`,homepage:`https://pkg.go.dev/${z.name}`}},applyUpdate(z,H){let $=W(H.name),X=W(H.currentVersion);return z.replace(new RegExp(`^(\\s*(?:require\\s+)?${$}\\s+)${X}(\\s|$)`,"gm"),`$1${H.newVersion}$2`)},async postWrite(z){return M(z,[{lockfile:"go.sum",command:["go","mod","tidy"]}])},osvEcosystem:"Go",compareVersions:B,updateType:C};var s=/^\s*v?(?:(\d+)!)?(\d+(?:\.\d+)*)((?:[-_.]?(?:a|b|c|rc|alpha|beta|pre|preview)[-_.]?\d*)?)((?:[-_.]?(?:post|rev|r)[-_.]?\d*|-\d+)?)((?:[-_.]?dev[-_.]?\d*)?)(?:\+([a-z0-9]+(?:[-_.][a-z0-9]+)*))?\s*$/i,i={a:"a",alpha:"a",b:"b",beta:"b",c:"rc",rc:"rc",pre:"rc",preview:"rc"},v={a:0,b:1,rc:2};function S(z){let H=s.exec(z);if(!H)return null;let[,$,X,Z,J,K,G]=H,V={epoch:$?Number($):0,release:X.split(".").map(Number)};if(Z){let Q=/([a-z]+)[-_.]?(\d*)/i.exec(Z);if(Q){let j=i[Q[1].toLowerCase()];if(j)V.pre=[j,Q[2]?Number(Q[2]):0]}}if(J){let Q=/(\d+)/.exec(J);V.post=Q?Number(Q[1]):0}if(K){let Q=/(\d+)/.exec(K);V.dev=Q?Number(Q[1]):0}if(G)V.local=G.toLowerCase();return V}function d(z,H){for(let $=0;$<Math.max(z.length,H.length);$++){let X=(z[$]??0)-(H[$]??0);if(X!==0)return X}return 0}function A(z,H){let $=S(z),X=S(H);if(!$||!X)return z===H?0:z<H?-1:1;if($.epoch!==X.epoch)return $.epoch-X.epoch;let Z=d($.release,X.release);if(Z!==0)return Z;let J=(Q)=>{if(Q.dev!==void 0&&Q.pre===void 0&&Q.post===void 0)return 0;if(Q.pre!==void 0)return 1;if(Q.post!==void 0)return 3;return 2},K=J($)-J(X);if(K!==0)return K;if($.pre&&X.pre){let Q=v[$.pre[0]]-v[X.pre[0]];if(Q!==0)return Q;if($.pre[1]!==X.pre[1])return $.pre[1]-X.pre[1]}if(($.post??0)!==(X.post??0))return($.post??0)-(X.post??0);let G=$.dev??Number.POSITIVE_INFINITY,V=X.dev??Number.POSITIVE_INFINITY;if(G!==V)return G<V?-1:1;return 0}function g(z){let H=S(z);return Boolean(H&&(H.pre!==void 0||H.dev!==void 0))}function D(z,H){let $=S(z),X=S(H);if(!$||!X)return"patch";if($.epoch!==X.epoch||($.release[0]??0)!==(X.release[0]??0))return"major";if(($.release[1]??0)!==(X.release[1]??0))return"minor";return"patch"}function N(z){let H=/^\s*(~=|===|==|!=|<=|>=|<|>|\^)?\s*(.*)$/.exec(z.trim());if(!H)return{operator:"",version:z.trim()};return{operator:H[1]??"",version:H[2].trim()}}var b=/^\s*([A-Z0-9][\w.-]*)\s*(\[[^\]]*\])?\s*([<>=!~^].*?)?\s*(?:;.*)?$/i,o=/^\s*(?:-|#|$)/;function r(z,H){let $=[];return H.split(`
4
4
  `).forEach((X)=>{let Z=X.split("#")[0];if(o.test(Z))return;let J=b.exec(Z);if(!J?.[1]||!J[3])return;$.push({name:J[1],currentVersion:J[3].trim(),section:"dependencies",file:z,...J[2]?{metadata:{extras:J[2]}}:{}})}),$}var a=[[/^\s*dependencies\s*=\s*\[/m,"dependencies"],[/^\s*(?:dev-dependencies|dev)\s*=\s*\[/m,"devDependencies"]];function n(z,H){let $=[],X=new Set,Z=(K,G,V)=>{let Q=`${V}:${K}`;if(!G.trim()||G.trim()==="*"||X.has(Q))return;X.add(Q),$.push({name:K,currentVersion:G.trim(),section:V,file:z})};for(let[K,G]of a){let V=K.exec(H);if(!V)continue;let Q=V.index+V[0].length,j=H.indexOf("]",Q);if(j===-1)continue;for(let q of H.slice(Q,j).matchAll(/["']([^"']+)["']/g)){let Y=b.exec(q[1]);if(Y?.[1]&&Y[3])Z(Y[1],Y[3],G)}}let J=H.matchAll(/\[tool\.poetry\.(?:group\.[\w-]+\.)?(dependencies|dev-dependencies)\]([\s\S]*?)(?=\n\[|$)/g);for(let K of J){let G=K[1]==="dependencies"?"dependencies":"devDependencies";for(let V of K[2].matchAll(/^\s*([A-Z0-9][\w.-]*)\s*=\s*(.+)$/gim)){let Q=V[1];if(Q.toLowerCase()==="python")continue;let j=V[2].trim(),q=/version\s*=\s*["']([^"']+)["']/.exec(j),Y=/^["']([^"']+)["']/.exec(j),F=q?.[1]??Y?.[1];if(F)Z(Q,F,G)}}return $}var w={name:"python",manifestPatterns:["pyproject.toml","requirements.txt","requirements-*.txt","requirements/*.txt"],async detect(z){return L(z,this.manifestPatterns)},async parse(z,H){return z.endsWith(".toml")?n(z,H):r(z,H)},async latest(z,H={}){let $=H.registryUrl??"https://pypi.org",X=await U(`${$}/pypi/${encodeURIComponent(z.name)}/json`,{headers:{"User-Agent":"buddy",Accept:"application/json"}}).catch(()=>null);if(!X?.ok)return null;let Z=await X.json().catch(()=>null);if(!Z?.info?.version)return null;let J=Z.info.version;if(H.includePrerelease&&Z.releases){let V=Object.keys(Z.releases).filter((Q)=>!Z.releases[Q]?.every((j)=>j.yanked)).sort(A);J=V[V.length-1]??J}let G=Z.releases?.[J]?.find((V)=>V.upload_time_iso_8601)?.upload_time_iso_8601;return{latest:J,...G?{publishedAt:new Date(G)}:{},...Z.info.yanked?{deprecated:!0}:{},...Z.info.project_urls?.Changelog?{releaseNotesUrl:Z.info.project_urls.Changelog}:{},...Z.info.home_page?{homepage:Z.info.home_page}:{}}},applyUpdate(z,H){let{operator:$}=N(H.currentVersion),X=W(H.name),Z=W(H.currentVersion),J=N(H.newVersion).version,K=$?`${$}${J}`:J;return z.replace(new RegExp(`(^|["'\\s])(${X})(\\[[^\\]]*\\])?\\s*${Z}`,"gim"),(G,V,Q,j)=>`${V}${Q}${j??""}${K}`).replace(new RegExp(`^(\\s*${X}\\s*=\\s*["'])${Z}(["'])`,"gim"),`$1${K}$2`).replace(new RegExp(`^(\\s*${X}\\s*=\\s*\\{[^}]*version\\s*=\\s*["'])${Z}(["'])`,"gim"),`$1${K}$2`)},async postWrite(z){return M(z,[{lockfile:"uv.lock",command:["uv","lock"]},{lockfile:"poetry.lock",command:["poetry","lock","--no-update"]}])},osvEcosystem:"PyPI",compareVersions:A,updateType:D};var t=/^\s*gem\s+["']([\w-]+)["']\s*(?:,\s*["']([^"']+)["'])?/,e=/^\s*group\s+(.+?)\s+do\s*$/,zz=/^\s*end\s*$/,x={name:"ruby",manifestPatterns:["Gemfile","*.gemspec"],async detect(z){return L(z,this.manifestPatterns)},async parse(z,H){let $=[],X=[];for(let Z of H.split(`
5
5
  `)){let J=Z.replace(/#.*$/,""),K=e.exec(J);if(K){X.push(K[1].replace(/[:'",\s]/g,"")||"default");continue}if(zz.test(J)){X.pop();continue}let G=t.exec(J);if(!G?.[1])continue;if(!G[2])continue;if(/\b(?:path|git|github|branch):/.test(J))continue;$.push({name:G[1],currentVersion:G[2],section:X.length>0?X[X.length-1]:"dependencies",file:z})}return $},async latest(z,H={}){let $=H.registryUrl??"https://rubygems.org",X=await U(`${$}/api/v1/versions/${encodeURIComponent(z.name)}.json`,{headers:{"User-Agent":"buddy",Accept:"application/json"}}).catch(()=>null);if(!X?.ok)return null;let Z=await X.json().catch(()=>null);if(!Array.isArray(Z)||Z.length===0)return null;let J=Z.filter((G)=>G.number&&!G.yanked).filter((G)=>H.includePrerelease?!0:!G.prerelease).sort((G,V)=>B(G.number,V.number)),K=J[J.length-1];if(!K?.number)return null;return{latest:K.number,...K.created_at?{publishedAt:new Date(K.created_at)}:{},homepage:`${$}/gems/${z.name}`}},applyUpdate(z,H){let $=W(H.name),X=W(H.currentVersion),Z=/^\s*(~>|>=|<=|>|<|=)?\s*/.exec(H.currentVersion)?.[1]??"",J=Z?`${Z} ${H.newVersion}`:H.newVersion;return z.replace(new RegExp(`^(\\s*gem\\s+["']${$}["']\\s*,\\s*["'])${X}(["'])`,"gm"),`$1${J}$2`)},async postWrite(z){return M(z,[{lockfile:"Gemfile.lock",command:["bundle","lock","--update"]}])},osvEcosystem:"RubyGems",compareVersions:B,updateType:C};var Hz=[[/^\[dependencies\]/m,"dependencies"],[/^\[dev-dependencies\]/m,"devDependencies"],[/^\[build-dependencies\]/m,"buildDependencies"],[/^\[workspace\.dependencies\]/m,"workspaceDependencies"]],T={name:"rust",manifestPatterns:["Cargo.toml"],async detect(z){return L(z,this.manifestPatterns)},async parse(z,H){let $=[];for(let[X,Z]of Hz){let J=X.exec(H);if(!J)continue;let K=J.index+J[0].length,G=H.slice(K).search(/\n\[/),V=G===-1?H.slice(K):H.slice(K,K+G);for(let Q of V.matchAll(/^\s*([\w-]+)\s*=\s*(.+)$/gm)){let j=Q[1],q=Q[2].trim(),Y=/version\s*=\s*["']([^"']+)["']/.exec(q),F=/^["']([^"']+)["']/.exec(q),_=Y?.[1]??F?.[1];if(!_||/\b(?:path|git)\s*=/.test(q))continue;$.push({name:j,currentVersion:_,section:Z,file:z})}}return $},async latest(z,H={}){let $=H.registryUrl??"https://crates.io",X=await U(`${$}/api/v1/crates/${encodeURIComponent(z.name)}`,{headers:{"User-Agent":"buddy (https://buddy.sh)",Accept:"application/json"}}).catch(()=>null);if(!X?.ok)return null;let Z=await X.json().catch(()=>null);if(!Z?.crate)return null;let J=H.includePrerelease?Z.crate.newest_version??Z.crate.max_stable_version:Z.crate.max_stable_version??Z.crate.newest_version;if(!J)return null;let K=Z.versions?.find((G)=>G.num===J);if(K?.yanked)return null;return{latest:J,...K?.created_at?{publishedAt:new Date(K.created_at)}:{},...Z.crate.repository?{releaseNotesUrl:`${Z.crate.repository}/releases`}:{},...Z.crate.homepage?{homepage:Z.crate.homepage}:{}}},applyUpdate(z,H){let $=W(H.name),X=W(H.currentVersion);return z.replace(new RegExp(`^(\\s*${$}\\s*=\\s*["'])${X}(["'])`,"gm"),`$1${H.newVersion}$2`).replace(new RegExp(`^(\\s*${$}\\s*=\\s*\\{[^}]*?version\\s*=\\s*["'])${X}(["'])`,"gm"),`$1${H.newVersion}$2`)},async postWrite(z){return M(z,[{lockfile:"Cargo.lock",command:["cargo","update","--workspace"]}])},osvEcosystem:"crates.io",compareVersions:B,updateType:C};import{join as Xz}from"path";async function Zz(z){let H=z.logger??f(),$=z.adapters??k,X=new Set(z.ignore??[]),Z=[],J={},K=[];return await Promise.all($.map(async(G)=>{let V;try{V=await G.detect(z.dir)}catch(Q){H.warn(`\u26A0\uFE0F ${G.name}: could not look for manifests: ${Q}`);return}if(V.length===0)return;K.push({ecosystem:G.name,files:V}),H.debug(`\uD83D\uDCE6 ${G.name}: ${V.length} manifest(s)`);for(let Q of V){let j;try{j=await G.parse(Q,await Bun.file(Xz(z.dir,Q)).text())}catch(Y){H.warn(`\u26A0\uFE0F ${G.name}: could not parse ${Q}: ${Y}`);continue}J[G.name]=(J[G.name]??0)+j.length;let q=await Promise.all(j.map(async(Y)=>{if(X.has(Y.name))return null;try{let F=await G.latest(Y,{...z.includePrerelease!==void 0?{includePrerelease:z.includePrerelease}:{},logger:H});if(!F)return null;let _=y(Y.currentVersion);if(G.compareVersions(F.latest,_)<=0)return null;return{name:Y.name,currentVersion:Y.currentVersion,newVersion:F.latest,updateType:G.updateType(_,F.latest),dependencyType:G.name,file:Q,...F.releaseNotesUrl?{releaseNotesUrl:F.releaseNotesUrl}:{},...F.homepage?{homepage:F.homepage}:{}}}catch(F){return H.debug(`${G.name}: could not resolve ${Y.name}: ${F}`),null}}));Z.push(...q.filter((Y)=>Y!==null))}})),{updates:Z,dependenciesByEcosystem:J,manifests:K}}function y(z){let H=/(\d[\w.!+-]*)/.exec(z);return H?H[1]:z.trim()}async function $z(z,H,$=k){let X=[],Z=[];for(let J of $){if(!H.includes(J.name)||!J.postWrite)continue;let K=await J.postWrite(z).catch(()=>({regenerated:[],note:void 0}));if(X.push(...K.regenerated),K.note)Z.push(K.note)}return{regenerated:X,notes:Z}}var k=[w,T,I,x];function Ez(z,H=k){let $=z.split("/").pop()??z;for(let X of H)if(X.manifestPatterns.some((Z)=>h($,Z)||h(z,Z)))return X;return null}function h(z,H){if(!H.includes("*"))return z===H;let $=H.split("*").map((X)=>X.replace(/[.+?^${}()|[\]\\]/g,"\\$&")).join("[^/]*");return new RegExp(`^${$}$`).test(z)}function Rz(z,H=k){return H.find(($)=>$.name===z)??null}
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  var k=["buddy/","buddy-bot/"];function v(g){return typeof g==="string"&&k.some((j)=>g.startsWith(j))}
3
- export{v as Eh};
3
+ export{v as Fh};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import"./chunk-kbvj6qxc.js";import{spawn as E}from"child_process";async function y(z,A){return new Promise((k,x)=>{let q=E("git",z,{stdio:"pipe",cwd:A}),C="",D="";q.stdout?.on("data",(B)=>C+=B.toString()),q.stderr?.on("data",(B)=>D+=B.toString()),q.on("close",(B)=>{if(B===0)k(C);else x(Error(D||`git exited with code ${B}`))}),q.on("error",x)})}async function H(z,A,k){for(let x of z){let q=x.path.replace(/^\.\//,"").replace(/^\/+/,"");try{if(await y(["show",`${A}:${q}`],k)!==x.content)return!0;continue}catch{}try{if(await y(["show",`origin/${A}:${q}`],k)!==x.content)return!0;continue}catch{return!0}}return!1}async function I(z,A,k){if(z.length===0)return!1;if(await y(["add","--",...z],k),!(await y(["diff","--cached","--name-only"],k)).trim())return!1;await y(["commit","-m",A],k);let q=(await y(["rev-parse","--abbrev-ref","HEAD"],k)).trim();return await y(["push","origin",`HEAD:${q}`],k),!0}export{H as hasBranchDifferences,I as commitAndPush};
2
+ import"./chunk-s82adeq9.js";import{spawn as E}from"child_process";async function y(z,A){return new Promise((k,x)=>{let q=E("git",z,{stdio:"pipe",cwd:A}),C="",D="";q.stdout?.on("data",(B)=>C+=B.toString()),q.stderr?.on("data",(B)=>D+=B.toString()),q.on("close",(B)=>{if(B===0)k(C);else x(Error(D||`git exited with code ${B}`))}),q.on("error",x)})}async function H(z,A,k){for(let x of z){let q=x.path.replace(/^\.\//,"").replace(/^\/+/,"");try{if(await y(["show",`${A}:${q}`],k)!==x.content)return!0;continue}catch{}try{if(await y(["show",`origin/${A}:${q}`],k)!==x.content)return!0;continue}catch{return!0}}return!1}async function I(z,A,k){if(z.length===0)return!1;if(await y(["add","--",...z],k),!(await y(["diff","--cached","--name-only"],k)).trim())return!1;await y(["commit","-m",A],k);let q=(await y(["rev-parse","--abbrev-ref","HEAD"],k)).trim();return await y(["push","origin",`HEAD:${q}`],k),!0}export{H as hasBranchDifferences,I as commitAndPush};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{xh as a}from"./chunk-cx89kty3.js";import"./chunk-s82adeq9.js";export{a as GitHubActionsTemplate};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{xh as M}from"./chunk-2z9pkk1y.js";import{Jh as K}from"./chunk-b9szrnxw.js";import{Ph as J}from"./chunk-x1w6q9tk.js";import"./chunk-kbvj6qxc.js";function Q(j){let q=j.match(/github\.com\/([^/]+)\/([^/]+)\/(?:archive|releases\/download)\/(?:refs\/tags\/)?v?(\d+\.\d+\.\d+(?:-[\w.]+)?)/i);if(!q)return null;return{owner:q[1],repo:q[2].replace(/\.git$/,""),version:q[3],hasVPrefix:/\/v\d/.test(j)}}async function S(j,q){let y=J();try{let B={Accept:"application/vnd.github.v3+json","User-Agent":"buddy"};if(q)B.Authorization=`Bearer ${q}`;let E=await K(`${M()}/repos/${j.owner}/${j.repo}/releases/latest`,{headers:B});if(!E.ok)return y.debug(`No latest release for ${j.owner}/${j.repo}: ${E.status}`),null;let F=await E.json();if(!F.tag_name)return null;let I=F.tag_name.replace(/^v/,"");return/^\d+\.\d+\.\d+/.test(I)?I:null}catch(B){return y.debug(`Failed to fetch latest Zig version for ${j.owner}/${j.repo}: ${B}`),null}}function X(j,q){return j.replace(/\/v?(\d+\.\d+\.\d+(?:-[\w.]+)?)/i,(y)=>y.startsWith("/v")?`/v${q}`:`/${q}`)}async function Y(){try{return await Bun.spawn(["zig","version"],{stdout:"pipe",stderr:"pipe"}).exited===0}catch{return!1}}async function _(j){let q=J();try{let y=Bun.spawn(["zig","fetch",j],{stdout:"pipe",stderr:"pipe"}),[B,E]=await Promise.all([new Response(y.stdout).text(),y.exited]);if(E!==0){let I=await new Response(y.stderr).text();return q.warn(`\u26A0\uFE0F zig fetch failed for ${j}: ${I.trim()}`),null}let F=B.trim();return F.length>0?F:null}catch(y){return q.warn(`\u26A0\uFE0F Could not run zig fetch for ${j}: ${y}`),null}}export{X as zigUrlForVersion,Q as parseZigSource,Y as isZigAvailable,_ as fetchZigHash,S as fetchLatestZigVersion};
2
+ import{yh as M}from"./chunk-7t8s2mcf.js";import{Kh as K}from"./chunk-34vracy4.js";import{Qh as J}from"./chunk-zwtx6vn3.js";import"./chunk-s82adeq9.js";function Q(j){let q=j.match(/github\.com\/([^/]+)\/([^/]+)\/(?:archive|releases\/download)\/(?:refs\/tags\/)?v?(\d+\.\d+\.\d+(?:-[\w.]+)?)/i);if(!q)return null;return{owner:q[1],repo:q[2].replace(/\.git$/,""),version:q[3],hasVPrefix:/\/v\d/.test(j)}}async function S(j,q){let y=J();try{let B={Accept:"application/vnd.github.v3+json","User-Agent":"buddy"};if(q)B.Authorization=`Bearer ${q}`;let E=await K(`${M()}/repos/${j.owner}/${j.repo}/releases/latest`,{headers:B});if(!E.ok)return y.debug(`No latest release for ${j.owner}/${j.repo}: ${E.status}`),null;let F=await E.json();if(!F.tag_name)return null;let I=F.tag_name.replace(/^v/,"");return/^\d+\.\d+\.\d+/.test(I)?I:null}catch(B){return y.debug(`Failed to fetch latest Zig version for ${j.owner}/${j.repo}: ${B}`),null}}function X(j,q){return j.replace(/\/v?(\d+\.\d+\.\d+(?:-[\w.]+)?)/i,(y)=>y.startsWith("/v")?`/v${q}`:`/${q}`)}async function Y(){try{return await Bun.spawn(["zig","version"],{stdout:"pipe",stderr:"pipe"}).exited===0}catch{return!1}}async function _(j){let q=J();try{let y=Bun.spawn(["zig","fetch",j],{stdout:"pipe",stderr:"pipe"}),[B,E]=await Promise.all([new Response(y.stdout).text(),y.exited]);if(E!==0){let I=await new Response(y.stderr).text();return q.warn(`\u26A0\uFE0F zig fetch failed for ${j}: ${I.trim()}`),null}let F=B.trim();return F.length>0?F:null}catch(y){return q.warn(`\u26A0\uFE0F Could not run zig fetch for ${j}: ${y}`),null}}export{X as zigUrlForVersion,Q as parseZigSource,Y as isZigAvailable,_ as fetchZigHash,S as fetchLatestZigVersion};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Eb as a,Fb as b,Gb as c}from"./chunk-q2tjkhez.js";import"./chunk-kbvj6qxc.js";export{b as renderDiffForReview,a as parseUnifiedDiff,c as collectGitDiff};
2
+ import{Eb as a,Fb as b,Gb as c}from"./chunk-q2tjkhez.js";import"./chunk-s82adeq9.js";export{b as renderDiffForReview,a as parseUnifiedDiff,c as collectGitDiff};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Rf as Z}from"./chunk-sxfk3naz.js";import{Ph as Y}from"./chunk-x1w6q9tk.js";import W from"process";var $=[["bun","test"],["npm","test","--silent"]];async function E(G,H){let I=H?[H]:await L(G);for(let z of I){let j=Bun.spawn(z,{cwd:G,stdout:"pipe",stderr:"pipe",env:{PATH:W.env.PATH??"",HOME:W.env.HOME??"",CI:"1"}}),[J,K,Q]=await Promise.all([new Response(j.stdout).text(),new Response(j.stderr).text(),j.exited]);return{ran:!0,passed:Q===0,output:`${J}
2
+ import{Rf as Z}from"./chunk-4kyxrwxn.js";import{Qh as Y}from"./chunk-zwtx6vn3.js";import W from"process";var $=[["bun","test"],["npm","test","--silent"]];async function E(G,H){let I=H?[H]:await L(G);for(let z of I){let j=Bun.spawn(z,{cwd:G,stdout:"pipe",stderr:"pipe",env:{PATH:W.env.PATH??"",HOME:W.env.HOME??"",CI:"1"}}),[J,K,Q]=await Promise.all([new Response(j.stdout).text(),new Response(j.stderr).text(),j.exited]);return{ran:!0,passed:Q===0,output:`${J}
3
3
  ${K}`.trim().slice(-4000)}}return{ran:!1,passed:!1,output:""}}async function L(G){let H=Bun.file(`${G}/package.json`);if(!await H.exists())return[];try{return(await H.json()).scripts?.test?$:[]}catch{return[]}}function O(G,H){return`${G.head}/buddy-${H}`}async function N(G){let H=G.logger??Y(),{provider:I,pullRequest:z,touch:j}=G;H.info(`\u2728 Running finishing touch '${j.name}' on PR #${z.number}`);let J=await Z(G.ai,{mode:j.mode,task:j.buildTask({summary:z.title,files:G.files??[]}),context:{workspace:G.workspace,baseBranch:z.base,branch:z.head},logger:H}),K=await _(G.workspace);if(K.length===0)return{mode:"none",changedFiles:[],verified:!1,comment:J.stopReason==="completed"?`**${j.description}** \u2014 nothing to change.`:`**${j.description}** \u2014 stopped before finishing (${J.stopReason}), and left nothing behind.`};let Q=J.stopReason==="completed",P=await E(G.workspace,G.testCommand);if(!(Q&&j.defaultOutput!=="suggestion"&&(P.passed||!P.ran)))return{mode:"suggestions",changedFiles:K,verified:P.passed,comment:X(j,K,P,J.stopReason)};let V=O(z,j.name);try{await I.createBranch(V,z.head),await I.commitChanges(V,`chore: ${j.description.toLowerCase()} for #${z.number}`,await x(G.workspace,K),z.head);let U=await I.createPullRequest({title:`${j.description} for #${z.number}`,body:y(j,z,K,P),head:V,base:z.head,labels:["buddy","finishing-touch"]});return{mode:"stacked-pr",pullRequest:U,changedFiles:K,verified:P.passed,comment:`**${j.description}** \u2014 opened [#${U.number}](${U.url}) targeting this branch.`+(P.ran?"":" No test script was found, so this is unverified.")}}catch(U){return H.warn(`\u26A0\uFE0F Could not open a stacked pull request: ${U}`),{mode:"suggestions",changedFiles:K,verified:P.passed,comment:X(j,K,P,J.stopReason)}}}async function _(G){let H=Bun.spawn(["git","status","--porcelain"],{cwd:G,stdout:"pipe",stderr:"ignore"}),[I,z]=await Promise.all([new Response(H.stdout).text(),H.exited]);if(z!==0)return[];let j=[];for(let J of I.split(`
4
4
  `)){if(!J.trim())continue;let K=J.slice(0,2),Q=J.slice(3).trim();if(K.includes("D"))continue;j.push(Q.includes(" -> ")?Q.split(" -> ")[1]:Q)}return j}async function x(G,H){let I=[];for(let z of H){let j=Bun.file(`${G}/${z}`);if(await j.exists())I.push({path:z,content:await j.text(),type:"update"})}return I}function y(G,H,I,z){return[`${G.description}, requested on #${H.number}.`,"",`This targets \`${H.head}\` rather than \`${H.base}\`, so merging it`,"adds these changes to that pull request.","",z.ran?z.passed?"\u2705 The repository's tests pass with these changes.":"\u26A0\uFE0F The repository's tests do **not** pass with these changes.":"\u2139\uFE0F No test script was found, so these changes are unverified.","","### Files changed","",...I.map((j)=>`- \`${j}\``)].join(`
5
5
  `)}function X(G,H,I,z){let j=[`**${G.description}**`,""];if(z&&z!=="completed")j.push(`The agent stopped before finishing (${z}), so what follows is`,"partial work rather than a complete change.","");if(I.ran&&!I.passed)j.push("The repository's tests do not pass with these changes, so no branch was","opened. Treat what follows as a starting point rather than a result.","");if(j.push("Files that would change:","",...H.map((J)=>`- \`${J}\``)),I.output)j.push("","<details><summary>Test output</summary>","","```",I.output,"```","","</details>");return j.join(`
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{aa as a,ba as b,ca as c,da as d,ea as e,fa as f,ga as g,ha as h,ia as i,ja as j}from"./chunk-69qyr9ef.js";import"./chunk-kbvj6qxc.js";export{d as similarity,j as renderQuickLinks,b as renderPackageContext,h as parseQuickSelection,a as findMentionedPackages,e as findDuplicates,c as constrainLabels,i as clearQuickSelection,f as QUICK_LINKS_MARKER,g as QUICK_ACTIONS};
2
+ import{aa as a,ba as b,ca as c,da as d,ea as e,fa as f,ga as g,ha as h,ia as i,ja as j}from"./chunk-69qyr9ef.js";import"./chunk-s82adeq9.js";export{d as similarity,j as renderQuickLinks,b as renderPackageContext,h as parseQuickSelection,a as findMentionedPackages,e as findDuplicates,c as constrainLabels,i as clearQuickSelection,f as QUICK_LINKS_MARKER,g as QUICK_ACTIONS};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Da as a}from"./chunk-ce26jarj.js";import"./chunk-83srz04v.js";import"./chunk-c9266b5x.js";import"./chunk-x9qhsyp6.js";import"./chunk-edm12hnb.js";import"./chunk-bnp0r4eh.js";import"./chunk-0f1xye20.js";import"./chunk-66nntsnf.js";import"./chunk-ebnc6980.js";import"./chunk-y1d6e0ye.js";import"./chunk-ma01xp3y.js";import"./chunk-gjhxc6ma.js";import"./chunk-3a63hke8.js";import"./chunk-92gh2n65.js";import"./chunk-j46f90n8.js";import"./chunk-eh71jv8w.js";import"./chunk-3a5gcj3y.js";import"./chunk-1pecmenc.js";import"./chunk-4kyxrwxn.js";import"./chunk-24xvskkf.js";import"./chunk-z18bksyr.js";import"./chunk-cj4d5ad7.js";import"./chunk-zy49dwqk.js";import"./chunk-x9vpk4kk.js";import"./chunk-94tnmc7j.js";import"./chunk-drmk6r1m.js";import"./chunk-7t8s2mcf.js";import"./chunk-j6geg3qt.js";import"./chunk-34vracy4.js";import"./chunk-zwtx6vn3.js";import"./chunk-028354j6.js";import"./chunk-s82adeq9.js";export{a as Scheduler};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{W as a,X as b}from"./chunk-q7709hwk.js";import"./chunk-5sh69bkj.js";import"./chunk-01d81hn0.js";import"./chunk-0f1xye20.js";import"./chunk-qjzpzd7j.js";import"./chunk-ebnc6980.js";import"./chunk-2b07w74s.js";import"./chunk-142zh7e5.js";import"./chunk-y1d6e0ye.js";import"./chunk-24xvskkf.js";import"./chunk-z18bksyr.js";import"./chunk-34vracy4.js";import"./chunk-zwtx6vn3.js";import"./chunk-s82adeq9.js";export{b as renderDoctorReport,a as diagnose};
@@ -1,2 +1,2 @@
1
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-mt53v4sx.js";import"./chunk-vpw7adwd.js";import"./chunk-x1w6q9tk.js";import"./chunk-kbvj6qxc.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};
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-6np84pfr.js";import"./chunk-j6geg3qt.js";import"./chunk-zwtx6vn3.js";import"./chunk-s82adeq9.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,2 +1,2 @@
1
1
  // @bun
2
- import{Va as t,Wa as u}from"./chunk-esm5jjgf.js";import{$a as z,Xa as v,Ya as w,Za as x,_a as y,ab as A,bb as B,cb as C,db as D,eb as E,fb as F,gb as G}from"./chunk-jqh7vx2n.js";import{hb as H,ib as I,jb as J,kb as K,lb as L}from"./chunk-b3s185kp.js";import"./chunk-59993g25.js";import"./chunk-va3k91tf.js";import{Af as b,Bf as c,Cf as d,Df as e,Ef as f,zf as a}from"./chunk-1pecmenc.js";import{Ff as g,Gf as h,Hf as i,If as j,Jf as k,Kf as l,Lf as m,Mf as n,Nf as o,Of as p,Pf as q,Qf as r,Rf as s}from"./chunk-sxfk3naz.js";import"./chunk-24xvskkf.js";import"./chunk-z18bksyr.js";import"./chunk-cj4d5ad7.js";import"./chunk-b9szrnxw.js";import"./chunk-x1w6q9tk.js";import"./chunk-kbvj6qxc.js";export{i as writeFileTool,r as wrapUntrusted,F as withTouchOffer,I as verifyChanges,w as unitTestsTouch,J as stackedBranchName,y as simplifyTouch,n as shellTool,K as runStackedTouch,u as runPlan,s as runAgent,a as reviewMode,g as resolveWorkspacePath,D as renderTouchOffer,h as readFileTool,z as planTouch,d as planMode,G as parseTouchSelections,j as listDirTool,b as implementMode,E as hasTouchOffer,B as getFinishingTouch,f as getAgentMode,k as fsTools,c as fixCiMode,v as docstringsTouch,L as detectChangedFiles,t as createReadIssueTool,m as buildShellEnv,x as autofixTouch,q as Toolbelt,o as ToolPermissionError,C as TOUCH_OFFER_MARKER,H as TEST_COMMANDS,l as SHELL_ENV_ALLOWLIST,A as FINISHING_TOUCHES,p as BUILTIN_TOOLS,e as AGENT_MODES};
2
+ import{Va as t,Wa as u}from"./chunk-p16pnhj3.js";import{$a as z,Xa as v,Ya as w,Za as x,_a as y,ab as A,bb as B,cb as C,db as D,eb as E,fb as F,gb as G}from"./chunk-jqh7vx2n.js";import{hb as H,ib as I,jb as J,kb as K,lb as L}from"./chunk-k907b533.js";import"./chunk-sn0qr6q7.js";import"./chunk-5sh69bkj.js";import{Af as b,Bf as c,Cf as d,Df as e,Ef as f,zf as a}from"./chunk-1pecmenc.js";import{Ff as g,Gf as h,Hf as i,If as j,Jf as k,Kf as l,Lf as m,Mf as n,Nf as o,Of as p,Pf as q,Qf as r,Rf as s}from"./chunk-4kyxrwxn.js";import"./chunk-24xvskkf.js";import"./chunk-z18bksyr.js";import"./chunk-cj4d5ad7.js";import"./chunk-34vracy4.js";import"./chunk-zwtx6vn3.js";import"./chunk-s82adeq9.js";export{i as writeFileTool,r as wrapUntrusted,F as withTouchOffer,I as verifyChanges,w as unitTestsTouch,J as stackedBranchName,y as simplifyTouch,n as shellTool,K as runStackedTouch,u as runPlan,s as runAgent,a as reviewMode,g as resolveWorkspacePath,D as renderTouchOffer,h as readFileTool,z as planTouch,d as planMode,G as parseTouchSelections,j as listDirTool,b as implementMode,E as hasTouchOffer,B as getFinishingTouch,f as getAgentMode,k as fsTools,c as fixCiMode,v as docstringsTouch,L as detectChangedFiles,t as createReadIssueTool,m as buildShellEnv,x as autofixTouch,q as Toolbelt,o as ToolPermissionError,C as TOUCH_OFFER_MARKER,H as TEST_COMMANDS,l as SHELL_ENV_ALLOWLIST,A as FINISHING_TOUCHES,p as BUILTIN_TOOLS,e as AGENT_MODES};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Ph as K}from"./chunk-x1w6q9tk.js";import{el as N}from"./chunk-kbvj6qxc.js";function F(q){return(q.split(/[/\\]/).pop()||"")==="build.zig.zon"}async function S(q,z){try{if(!F(q))return null;let J=[],j=z.match(/\.dependencies\s*=\s*\.?\{/);if(j){let Q=j.index+j[0].length,A=1,T=Q;while(T<z.length&&A>0){if(z[T]==="{")A++;else if(z[T]==="}")A--;T++}let G=z.slice(Q,T-1),O=/\.(\w+)\s*=\s*\.?\{/g,W=O.exec(G);while(W!==null){let b=W[1],X=W.index+W[0].length,Y=1,V=X;while(V<G.length&&Y>0){if(G[V]==="{")Y++;else if(G[V]==="}")Y--;V++}let _=G.slice(X,V-1),$=_.match(/\.url\s*=\s*"([^"]+)"/),R=_.match(/\.hash\s*=\s*"([^"]+)"/);if($){let H=$[1],v=H.match(/\/v?(\d+\.\d+\.\d+(?:-[\w.]+)?)/i),E=v?v[1]:"unknown",Z={url:H};if(R)Z.hash=R[1];J.push({name:b,currentVersion:E,type:"zig-dependencies",file:q,metadata:Z})}W=O.exec(G)}}return{path:q,type:"build.zig.zon",content:z,dependencies:J}}catch(J){return K().warn(`Failed to parse Zig manifest ${q}:`,J),null}}async function w(q,z,J){try{if(!F(q))return K().info(`\u26A0\uFE0F updateZigManifest: ${q} is not a Zig manifest file, returning original content`),z;let j=z;for(let Q of J){let A=Q.name.trim(),T=new RegExp(`(\\.${A}\\s*=\\s*\\.?\\{[^}]*\\.url\\s*=\\s*")([^"]+)("[^}]*\\})`,"s"),G=j.match(T);if(G){let[O,W,b,X]=G,Y=/\/v?(\d+\.\d+\.\d+(?:-[\w.]+)?)/i,V=b.replace(Y,(H)=>{return H.startsWith("/v")?`/v${Q.newVersion}`:`/${Q.newVersion}`}),_=Q.resolved?.hash,$=X;if(_)$=X.replace(/(\.hash\s*=\s*")([^"]+)(")/,`$1${_}$3`);else if(/\.hash\s*=/.test(X)){K().warn(`\u26A0\uFE0F No hash available for ${A}; leaving ${q} unchanged to avoid a hash mismatch`);continue}let R=`${W}${V}${$}`;j=j.replace(O,R),K().info(`\u2705 Updated ${A} from ${G[2]} to ${V}`)}else K().warn(`\u26A0\uFE0F Could not find dependency block for ${A} in ${q}`)}return j}catch(j){return K().warn(`Failed to update Zig manifest ${q}:`,j),z}}async function U(q){let z=[],J=new Map;for(let j of q)if(F(j.file)){if(!J.has(j.file))J.set(j.file,[]);J.get(j.file).push(j)}for(let[j,Q]of J)try{let A=await import("fs");if(A.existsSync(j)){let T=A.readFileSync(j,"utf-8"),G=await w(j,T,Q);if(G!==T)z.push({path:j,content:G,type:"update"}),K().info(`\u2705 Generated update for ${j} with ${Q.length} package changes`);else K().info(`\u2139\uFE0F No changes needed for ${j} - versions already up to date`)}else K().warn(`\u26A0\uFE0F Zig manifest file ${j} does not exist`)}catch(A){K().warn(`Failed to generate updates for Zig manifest ${j}:`,A)}return z}
2
+ import{Qh as K}from"./chunk-zwtx6vn3.js";import{fl as N}from"./chunk-s82adeq9.js";function F(q){return(q.split(/[/\\]/).pop()||"")==="build.zig.zon"}async function S(q,z){try{if(!F(q))return null;let J=[],j=z.match(/\.dependencies\s*=\s*\.?\{/);if(j){let Q=j.index+j[0].length,A=1,T=Q;while(T<z.length&&A>0){if(z[T]==="{")A++;else if(z[T]==="}")A--;T++}let G=z.slice(Q,T-1),O=/\.(\w+)\s*=\s*\.?\{/g,W=O.exec(G);while(W!==null){let b=W[1],X=W.index+W[0].length,Y=1,V=X;while(V<G.length&&Y>0){if(G[V]==="{")Y++;else if(G[V]==="}")Y--;V++}let _=G.slice(X,V-1),$=_.match(/\.url\s*=\s*"([^"]+)"/),R=_.match(/\.hash\s*=\s*"([^"]+)"/);if($){let H=$[1],v=H.match(/\/v?(\d+\.\d+\.\d+(?:-[\w.]+)?)/i),E=v?v[1]:"unknown",Z={url:H};if(R)Z.hash=R[1];J.push({name:b,currentVersion:E,type:"zig-dependencies",file:q,metadata:Z})}W=O.exec(G)}}return{path:q,type:"build.zig.zon",content:z,dependencies:J}}catch(J){return K().warn(`Failed to parse Zig manifest ${q}:`,J),null}}async function w(q,z,J){try{if(!F(q))return K().info(`\u26A0\uFE0F updateZigManifest: ${q} is not a Zig manifest file, returning original content`),z;let j=z;for(let Q of J){let A=Q.name.trim(),T=new RegExp(`(\\.${A}\\s*=\\s*\\.?\\{[^}]*\\.url\\s*=\\s*")([^"]+)("[^}]*\\})`,"s"),G=j.match(T);if(G){let[O,W,b,X]=G,Y=/\/v?(\d+\.\d+\.\d+(?:-[\w.]+)?)/i,V=b.replace(Y,(H)=>{return H.startsWith("/v")?`/v${Q.newVersion}`:`/${Q.newVersion}`}),_=Q.resolved?.hash,$=X;if(_)$=X.replace(/(\.hash\s*=\s*")([^"]+)(")/,`$1${_}$3`);else if(/\.hash\s*=/.test(X)){K().warn(`\u26A0\uFE0F No hash available for ${A}; leaving ${q} unchanged to avoid a hash mismatch`);continue}let R=`${W}${V}${$}`;j=j.replace(O,R),K().info(`\u2705 Updated ${A} from ${G[2]} to ${V}`)}else K().warn(`\u26A0\uFE0F Could not find dependency block for ${A} in ${q}`)}return j}catch(j){return K().warn(`Failed to update Zig manifest ${q}:`,j),z}}async function U(q){let z=[],J=new Map;for(let j of q)if(F(j.file)){if(!J.has(j.file))J.set(j.file,[]);J.get(j.file).push(j)}for(let[j,Q]of J)try{let A=await import("fs");if(A.existsSync(j)){let T=A.readFileSync(j,"utf-8"),G=await w(j,T,Q);if(G!==T)z.push({path:j,content:G,type:"update"}),K().info(`\u2705 Generated update for ${j} with ${Q.length} package changes`);else K().info(`\u2139\uFE0F No changes needed for ${j} - versions already up to date`)}else K().warn(`\u26A0\uFE0F Zig manifest file ${j} does not exist`)}catch(A){K().warn(`Failed to generate updates for Zig manifest ${j}:`,A)}return z}
3
3
  export{F as te,S as ue,w as ve,U as we};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ai as a,Bi as e,Ci as s,Di as t,Ei as c,Fi as r,Gi as P,Hi as n,Ii as o,Ji as g,Ki as l,Li as p,Mi as d,Ni as k}from"./chunk-z05djfac.js";import"./chunk-kbvj6qxc.js";export{o as startPeriodicCleanup,n as setupCleanupHandlers,p as scanPantryPackages,t as saveToCacheAndOutput,a as savePackageAsTypeScript,d as readPantryPackageInfo,s as getValidCachedPackage,r as fetchPkgxProjects,k as fetchPantryPackageWithMetadata,P as fetchPantryPackage,l as fetchAndSavePackage,g as fetchAndSaveAllPackages,c as cleanupBrowserResources,e as cleanStaleOutputFiles};
2
+ import{Bi as a,Ci as e,Di as s,Ei as t,Fi as c,Gi as r,Hi as P,Ii as n,Ji as o,Ki as g,Li as l,Mi as p,Ni as d,Oi as k}from"./chunk-028354j6.js";import"./chunk-s82adeq9.js";export{o as startPeriodicCleanup,n as setupCleanupHandlers,p as scanPantryPackages,t as saveToCacheAndOutput,a as savePackageAsTypeScript,d as readPantryPackageInfo,s as getValidCachedPackage,r as fetchPkgxProjects,k as fetchPantryPackageWithMetadata,P as fetchPantryPackage,l as fetchAndSavePackage,g as fetchAndSaveAllPackages,c as cleanupBrowserResources,e as cleanStaleOutputFiles};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ib as $}from"./chunk-vckhctmr.js";import"./chunk-kbvj6qxc.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};
2
+ import{Ib as $}from"./chunk-vckhctmr.js";import"./chunk-s82adeq9.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,2 @@
1
+ // @bun
2
+ import{te as a,ue as b,ve as c,we as d}from"./chunk-ma01xp3y.js";import"./chunk-zwtx6vn3.js";import"./chunk-s82adeq9.js";export{c as updateZigManifest,b as parseZigManifest,a as isZigManifest,d as generateZigManifestUpdates};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ed as a}from"./chunk-83srz04v.js";import"./chunk-c9266b5x.js";import"./chunk-x9qhsyp6.js";import"./chunk-edm12hnb.js";import"./chunk-bnp0r4eh.js";import"./chunk-0f1xye20.js";import"./chunk-66nntsnf.js";import"./chunk-ebnc6980.js";import"./chunk-y1d6e0ye.js";import"./chunk-ma01xp3y.js";import"./chunk-gjhxc6ma.js";import"./chunk-3a63hke8.js";import"./chunk-92gh2n65.js";import"./chunk-j46f90n8.js";import"./chunk-eh71jv8w.js";import"./chunk-3a5gcj3y.js";import"./chunk-1pecmenc.js";import"./chunk-4kyxrwxn.js";import"./chunk-24xvskkf.js";import"./chunk-z18bksyr.js";import"./chunk-cj4d5ad7.js";import"./chunk-zy49dwqk.js";import"./chunk-x9vpk4kk.js";import"./chunk-94tnmc7j.js";import"./chunk-drmk6r1m.js";import"./chunk-7t8s2mcf.js";import"./chunk-j6geg3qt.js";import"./chunk-34vracy4.js";import"./chunk-zwtx6vn3.js";import"./chunk-028354j6.js";import"./chunk-s82adeq9.js";export{a as Buddy};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Nc as v,Oc as F,Pc as B,Qc as k}from"./chunk-csqh2ca4.js";import{$f as I,_f as y,ag as W}from"./chunk-cj4d5ad7.js";import{xh as T}from"./chunk-2z9pkk1y.js";import{Eh as R}from"./chunk-vpw7adwd.js";import{Jh as U}from"./chunk-b9szrnxw.js";import{Lh as L,Mh as x,Ph as D}from"./chunk-x1w6q9tk.js";import{Buffer as S}from"buffer";import{spawn as w}from"child_process";import j from"process";var g=/\b(?:gh[pousr]_[A-Z0-9_]{20,}|github_pat_[A-Z0-9_]{20,}|[A-Z0-9]{40,})\b/gi;function N(Q){return Q==="completed"||Q==="in_progress"?Q:"queued"}function f(Q){if(typeof Q!=="string")return null;if(Q==="success"||Q==="cancelled")return Q;if(Q==="failure"||Q==="timed_out"||Q==="action_required")return"failure";return"skipped"}function d(Q,X){let Y=Q.replace(g,"[REDACTED]");if(X&&X.length>=8)Y=Y.split(X).join("[REDACTED]");return Y}class P extends Error{constructor(Q){super(Q);this.name="LockfileRegenerationError"}}function h(Q,X){let Y=`http.${Q.replace(/\/+$/,"")}/.extraheader`,Z=S.from(`x-access-token:${X}`).toString("base64");return["-c",`${Y}=`,"-c",`${Y}=AUTHORIZATION: basic ${Z}`]}class E extends Error{constructor(Q){super(Q);this.name="WorkflowPermissionError"}}function l(Q){let X=`${x(Q)} ${Q?.message??""}`;return/refusing to allow (?:a GitHub App|an OAuth App|a Personal Access Token)[^\n]*workflow/i.test(X)}function m(Q){let X=`${x(Q)} ${Q?.message??""}`;return/not permitted to create or approve pull requests/i.test(X)||Q?.status===403&&/pull/i.test(X)}class b{token;owner;repo;hasWorkflowPermissions;workflowToken;apiUrl;cache={pullRequests:new Map,issues:new Map};cacheTTL=120000;logger;constructor(Q,X,Y,Z=!1,$,J,G){this.token=Q;this.owner=X;this.repo=Y;this.hasWorkflowPermissions=Z;this.workflowToken=$;this.apiUrl=J?J.replace(/\/+$/,""):T(),this.logger=G??D()}capabilities(){return{pinIssues:!0,checkRuns:!0,inlineReviewComments:!0,reviewSuggestions:!0,nativeAutoMerge:!0,commentReactions:!0,ciLogs:!0,ciRuns:!0,reviewThreads:!0,teamReviewers:!0,draftPullRequests:!0,permissionLookup:!0,branchHousekeeping:!0,reopenPullRequests:!0,labels:!0}}isCacheValid(Q){return Date.now()-Q<this.cacheTTL}clearCache(){this.cache.pullRequests.clear(),this.cache.issues.clear()}async branchExists(Q){try{return await this.apiRequest(`GET /repos/${this.owner}/${this.repo}/git/ref/heads/${Q}`),!0}catch(X){if(X.message?.includes("404"))return!1;return this.logger.warn(`\u26A0\uFE0F Error checking branch ${Q}: ${x(X)}`),!1}}async createBranch(Q,X){try{let Z=(await this.apiRequest(`GET /repos/${this.owner}/${this.repo}/git/ref/heads/${X}`)).object.sha;await this.apiRequest(`POST /repos/${this.owner}/${this.repo}/git/refs`,{ref:`refs/heads/${Q}`,sha:Z}),this.logger.info(`\u2705 Created branch ${Q} from ${X}`)}catch(Y){throw this.logger.error(`\u274C Failed to create branch ${Q}: ${x(Y)}`),Y}}async commitChanges(Q,X,Y,Z="main"){try{await this.commitChangesWithGit(Q,X,Y,Z)}catch($){if($ instanceof P||$ instanceof y)throw $;if(l($)){let J=Y.filter((_)=>!_.path.includes(".github/workflows/")),G=Y.length-J.length;if(J.length===0)throw new E(`The token may not update workflow files (${G} in this change). Grant the GitHub App the Workflows permission, or use a PAT with the workflow scope as BUDDY_TOKEN.`);this.logger.warn(`\u26A0\uFE0F The token may not update workflow files; committing the ${J.length} other file(s) without the ${G} workflow file(s)`),await this.commitChangesWithGit(Q,X,J,Z);return}this.logger.warn(`\u26A0\uFE0F Git CLI commit failed, falling back to GitHub API: ${$}`),await this.commitChangesWithAPI(Q,X,Y,Z)}}async commitChangesWithGit(Q,X,Y,Z="main"){try{let $=Y.filter((V)=>V.path.includes(".github/workflows/")),J=Y.filter((V)=>!V.path.includes(".github/workflows/"));if($.length>0&&!this.hasWorkflowPermissions)if(this.logger.warn(`\u26A0\uFE0F Detected ${$.length} workflow file(s). These require elevated permissions.`),this.logger.warn(`\u26A0\uFE0F Workflow files: ${$.map((V)=>V.path).join(", ")}`),this.logger.warn("\u2139\uFE0F Workflow files will be skipped in this commit. BUDDY_TOKEN not detected or lacks workflow permissions."),J.length>0)this.logger.info(`\uD83D\uDCDD Committing ${J.length} non-workflow files...`),Y=J;else{this.logger.warn("\u26A0\uFE0F All files are workflow files. No files will be committed in this PR."),this.logger.warn("\uD83D\uDCA1 To update workflow files, ensure BUDDY_TOKEN is set with workflow:write permissions."),this.logger.info('\uD83D\uDCDD Creating empty commit to avoid "No commits between branches" error...');try{await this.runCommand("git",["commit","--allow-empty","-m","Workflow files require elevated permissions - no changes committed"]),this.logger.info("\u2705 Created empty commit for workflow-only PR")}catch(V){this.logger.warn(`\u26A0\uFE0F Failed to create empty commit: ${V}`);try{let C=Bun.file("README.md");if(await C.exists()){let H=`${await C.text()}
2
+ import{Nc as v,Oc as F,Pc as B,Qc as k}from"./chunk-9n1kth4b.js";import{$f as I,_f as y,ag as W}from"./chunk-cj4d5ad7.js";import{yh as T}from"./chunk-7t8s2mcf.js";import{Fh as R}from"./chunk-j6geg3qt.js";import{Kh as U}from"./chunk-34vracy4.js";import{Mh as L,Nh as x,Qh as D}from"./chunk-zwtx6vn3.js";import{Buffer as S}from"buffer";import{spawn as w}from"child_process";import j from"process";var g=/\b(?:gh[pousr]_[A-Z0-9_]{20,}|github_pat_[A-Z0-9_]{20,}|[A-Z0-9]{40,})\b/gi;function N(Q){return Q==="completed"||Q==="in_progress"?Q:"queued"}function f(Q){if(typeof Q!=="string")return null;if(Q==="success"||Q==="cancelled")return Q;if(Q==="failure"||Q==="timed_out"||Q==="action_required")return"failure";return"skipped"}function d(Q,X){let Y=Q.replace(g,"[REDACTED]");if(X&&X.length>=8)Y=Y.split(X).join("[REDACTED]");return Y}class P extends Error{constructor(Q){super(Q);this.name="LockfileRegenerationError"}}function h(Q,X){let Y=`http.${Q.replace(/\/+$/,"")}/.extraheader`,Z=S.from(`x-access-token:${X}`).toString("base64");return["-c",`${Y}=`,"-c",`${Y}=AUTHORIZATION: basic ${Z}`]}class E extends Error{constructor(Q){super(Q);this.name="WorkflowPermissionError"}}function l(Q){let X=`${x(Q)} ${Q?.message??""}`;return/refusing to allow (?:a GitHub App|an OAuth App|a Personal Access Token)[^\n]*workflow/i.test(X)}function m(Q){let X=`${x(Q)} ${Q?.message??""}`;return/not permitted to create or approve pull requests/i.test(X)||Q?.status===403&&/pull/i.test(X)}class b{token;owner;repo;hasWorkflowPermissions;workflowToken;apiUrl;cache={pullRequests:new Map,issues:new Map};cacheTTL=120000;logger;constructor(Q,X,Y,Z=!1,$,J,G){this.token=Q;this.owner=X;this.repo=Y;this.hasWorkflowPermissions=Z;this.workflowToken=$;this.apiUrl=J?J.replace(/\/+$/,""):T(),this.logger=G??D()}capabilities(){return{pinIssues:!0,checkRuns:!0,inlineReviewComments:!0,reviewSuggestions:!0,nativeAutoMerge:!0,commentReactions:!0,ciLogs:!0,ciRuns:!0,reviewThreads:!0,teamReviewers:!0,draftPullRequests:!0,permissionLookup:!0,branchHousekeeping:!0,reopenPullRequests:!0,labels:!0}}isCacheValid(Q){return Date.now()-Q<this.cacheTTL}clearCache(){this.cache.pullRequests.clear(),this.cache.issues.clear()}async branchExists(Q){try{return await this.apiRequest(`GET /repos/${this.owner}/${this.repo}/git/ref/heads/${Q}`),!0}catch(X){if(X.message?.includes("404"))return!1;return this.logger.warn(`\u26A0\uFE0F Error checking branch ${Q}: ${x(X)}`),!1}}async createBranch(Q,X){try{let Z=(await this.apiRequest(`GET /repos/${this.owner}/${this.repo}/git/ref/heads/${X}`)).object.sha;await this.apiRequest(`POST /repos/${this.owner}/${this.repo}/git/refs`,{ref:`refs/heads/${Q}`,sha:Z}),this.logger.info(`\u2705 Created branch ${Q} from ${X}`)}catch(Y){throw this.logger.error(`\u274C Failed to create branch ${Q}: ${x(Y)}`),Y}}async commitChanges(Q,X,Y,Z="main"){try{await this.commitChangesWithGit(Q,X,Y,Z)}catch($){if($ instanceof P||$ instanceof y)throw $;if(l($)){let J=Y.filter((_)=>!_.path.includes(".github/workflows/")),G=Y.length-J.length;if(J.length===0)throw new E(`The token may not update workflow files (${G} in this change). Grant the GitHub App the Workflows permission, or use a PAT with the workflow scope as BUDDY_TOKEN.`);this.logger.warn(`\u26A0\uFE0F The token may not update workflow files; committing the ${J.length} other file(s) without the ${G} workflow file(s)`),await this.commitChangesWithGit(Q,X,J,Z);return}this.logger.warn(`\u26A0\uFE0F Git CLI commit failed, falling back to GitHub API: ${$}`),await this.commitChangesWithAPI(Q,X,Y,Z)}}async commitChangesWithGit(Q,X,Y,Z="main"){try{let $=Y.filter((V)=>V.path.includes(".github/workflows/")),J=Y.filter((V)=>!V.path.includes(".github/workflows/"));if($.length>0&&!this.hasWorkflowPermissions)if(this.logger.warn(`\u26A0\uFE0F Detected ${$.length} workflow file(s). These require elevated permissions.`),this.logger.warn(`\u26A0\uFE0F Workflow files: ${$.map((V)=>V.path).join(", ")}`),this.logger.warn("\u2139\uFE0F Workflow files will be skipped in this commit. BUDDY_TOKEN not detected or lacks workflow permissions."),J.length>0)this.logger.info(`\uD83D\uDCDD Committing ${J.length} non-workflow files...`),Y=J;else{this.logger.warn("\u26A0\uFE0F All files are workflow files. No files will be committed in this PR."),this.logger.warn("\uD83D\uDCA1 To update workflow files, ensure BUDDY_TOKEN is set with workflow:write permissions."),this.logger.info('\uD83D\uDCDD Creating empty commit to avoid "No commits between branches" error...');try{await this.runCommand("git",["commit","--allow-empty","-m","Workflow files require elevated permissions - no changes committed"]),this.logger.info("\u2705 Created empty commit for workflow-only PR")}catch(V){this.logger.warn(`\u26A0\uFE0F Failed to create empty commit: ${V}`);try{let C=Bun.file("README.md");if(await C.exists()){let H=`${await C.text()}
3
3
 
4
4
  <!-- Updated by Buddy -->
5
5
  `;await Bun.write("README.md",H),await this.runCommand("git",["add","README.md"]),await this.runCommand("git",["commit","-m","Update README for workflow-only PR"]),this.logger.info("\u2705 Created README update for workflow-only PR")}}catch(K){this.logger.error(`\u274C Failed to create any commit: ${K}`)}}return}else if($.length>0)this.logger.info(`\u2705 Including ${$.length} workflow file(s) with elevated permissions`);try{await this.runCommand("git",["config","user.name","github-actions[bot]"]),await this.runCommand("git",["config","user.email","41898282+github-actions[bot]@users.noreply.github.com"]),this.logger.info("\u2705 Git identity configured for github-actions[bot]")}catch(V){this.logger.warn("\u26A0\uFE0F Failed to configure Git identity:",V)}await this.runCommand("git",["fetch","origin"]),this.logger.info(`\uD83D\uDD04 Recreating ${Q} from origin/${Z} (Renovate-style)...`);try{await this.runCommand("git",["checkout",Q])}catch{try{await this.runCommand("git",["checkout","-b",Q,`origin/${Q}`])}catch{await this.runCommand("git",["checkout","-b",Q])}}await this.runCommand("git",["reset","--hard",`origin/${Z}`]),await this.runCommand("git",["clean","-fd"]),this.logger.info(`\u2705 Reset ${Q} to origin/${Z}`),await W(Y,async(V)=>{try{return await this.runCommand("git",["cat-file","-e",`origin/${Z}:${V}`]),!0}catch{return!1}});for(let V of Y){let K=I(V.path);if(j.env.NODE_ENV==="test"||j.env.BUN_ENV==="test"){if(["package.json","bun.lock","bun.lockb","package-lock.json","yarn.lock"].includes(K)&&V.content==='{"name":"x"}'){this.logger.warn(`\u26A0\uFE0F Skipping test file write to ${K} to prevent overwriting project files`);continue}}if(V.type==="delete")try{await this.runCommand("git",["rm",K])}catch{}else await Bun.write(K,V.content),await this.runCommand("git",["add",K])}if(!(j.env.NODE_ENV==="test"||j.env.BUN_ENV==="test")){let V=Y.map((C)=>C.path.replace(/^\.\//,"").replace(/^\/+/,"")),K=B(V);if(K.length>0){this.logger.info(`\uD83D\uDD12 Regenerating lock files for: ${K.join(", ")}`);let C=j.cwd(),M=[];for(let H of K)try{let z=await F(H,C);if(z.success)for(let q of v())try{await this.runCommand("git",["add",q])}catch{}else M.push(`${H}: ${z.message}`)}catch(z){M.push(`${H}: ${z instanceof Error?z.message:String(z)}`)}for(let H of k(V,C))try{let z=await F(H.manager,`${C}/${H.dir}`);if(z.success)await this.runCommand("git",["add",H.lockFile]);else M.push(`${H.dir} (${H.manager}): ${z.message}`)}catch(z){M.push(`${H.dir} (${H.manager}): ${z instanceof Error?z.message:String(z)}`)}if(M.length>0){let H=M.map((z)=>` - ${z}`).join(`
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{fc as F}from"./chunk-va3k91tf.js";import{Cf as c}from"./chunk-1pecmenc.js";import{Of as E,Rf as A}from"./chunk-sxfk3naz.js";import{Ph as m}from"./chunk-x1w6q9tk.js";function S(T,f,r){let O=r?"pull request":"issue";return{name:"read_issue",tier:"read",description:`Read the ${O} this task is about: its title and description.`,parameters:{type:"object",properties:{}},async run(M,x){try{let e=r?(await T.getPullRequests("all")).find((h)=>h.number===f):(await T.getIssues("all")).find((h)=>h.number===f);if(!e)return{content:`Could not find ${O} #${f}.`,isError:!0};let k=(e.body??"").slice(0,20000);return x.log(`read ${O} #${f}`),{content:`# ${e.title}
2
+ import{fc as F}from"./chunk-5sh69bkj.js";import{Cf as c}from"./chunk-1pecmenc.js";import{Of as E,Rf as A}from"./chunk-4kyxrwxn.js";import{Qh as m}from"./chunk-zwtx6vn3.js";function S(T,f,r){let O=r?"pull request":"issue";return{name:"read_issue",tier:"read",description:`Read the ${O} this task is about: its title and description.`,parameters:{type:"object",properties:{}},async run(M,x){try{let e=r?(await T.getPullRequests("all")).find((h)=>h.number===f):(await T.getIssues("all")).find((h)=>h.number===f);if(!e)return{content:`Could not find ${O} #${f}.`,isError:!0};let k=(e.body??"").slice(0,20000);return x.log(`read ${O} #${f}`),{content:`# ${e.title}
3
3
 
4
4
  ${k||"(no description)"}`,untrusted:!0}}catch(e){return{content:`Could not read ${O} #${f}: ${e instanceof Error?e.message:String(e)}`,isError:!0}}}}}async function C(T){let f=T.logger??m(),r=F(T.config,f);if(!r)return"I need an AI provider configured to write a plan. See https://buddy.sh/ai/providers";let M=[`Write an implementation plan for ${T.isPullRequest?"pull request":"issue"} #${T.number} in this repository.`,"","Call `read_issue` first to see what is being asked for, then read enough of","the repository to be concrete about it.",...T.request?["","The person asking added this direction, which comes from them rather than","from the repository:",` ${T.request.replace(/\n/g," ")}`]:[],"","Produce: the files that would change and why, the order of the work, the","risks, and how the result would be verified. Prefer naming real paths you","have read over describing the change in the abstract.","","If the request is too vague to plan, say what you would need to know","instead of inventing a plan around the gap."].join(`
5
5
  `),x=await A(r,{mode:c,task:M,tools:[...E,S(T.provider,T.number,T.isPullRequest)],context:{workspace:T.workspace??process.cwd(),baseBranch:T.config.repository?.baseBranch??"main"},logger:f});if(!x.output)return x.stopReason==="completed"?"I finished researching but produced no plan. That is a bug \u2014 please open an issue.":`I could not finish the plan (${x.stopReason}). The issue may need narrowing.`;return x.output}export{S as Va,C as Wa};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Eh as V}from"./chunk-vpw7adwd.js";import{Jh as P}from"./chunk-b9szrnxw.js";import{Mh as M,Ph as Q}from"./chunk-x1w6q9tk.js";function X(z){if(z==="running")return"in_progress";if(z==="success"||z==="failed"||z==="canceled"||z==="skipped"||z==="manual")return"completed";return"queued"}function Y(z){switch(z){case"success":return"success";case"failed":return"failure";case"canceled":return"cancelled";case"skipped":case"manual":return"skipped";default:return null}}class Z{token;apiUrl;logger;projectId;constructor(z,A,F,G,H){this.token=z;this.apiUrl=(G??"https://gitlab.com/api/v4").replace(/\/+$/,""),this.logger=H??Q(),this.projectId=encodeURIComponent(`${A}/${F}`)}capabilities(){return{pinIssues:!1,checkRuns:!0,inlineReviewComments:!0,reviewSuggestions:!0,nativeAutoMerge:!0,commentReactions:!0,ciLogs:!0,ciRuns:!0,reviewThreads:!0,teamReviewers:!1,draftPullRequests:!0,permissionLookup:!0,branchHousekeeping:!0,reopenPullRequests:!0,labels:!0}}async request(z,A,F,G={}){let H=await P(`${this.apiUrl}${A}`,{method:z,headers:{"PRIVATE-TOKEN":this.token,Accept:G.raw?"text/plain":"application/json","User-Agent":"buddy",...F?{"Content-Type":"application/json"}:{}},...F?{body:JSON.stringify(F)}:{}});if(!H.ok){let K=await H.text().catch(()=>"");throw Error(`GitLab ${z} ${A} failed: ${H.status} ${K.slice(0,200)}`)}let J=await H.text();if(G.raw)return J;return J.trim()?JSON.parse(J):void 0}async optional(z,A,F={}){try{return await this.request(z,A,void 0,F)}catch(G){if(String(G).includes("404"))return null;throw G}}async branchExists(z){return await this.optional("GET",`/projects/${this.projectId}/repository/branches/${encodeURIComponent(z)}`)!==null}async createBranch(z,A){await this.request("POST",`/projects/${this.projectId}/repository/branches`,{branch:z,ref:A})}async deleteBranch(z){await this.request("DELETE",`/projects/${this.projectId}/repository/branches/${encodeURIComponent(z)}`)}async commitChanges(z,A,F,G="main"){if(F.length===0)return;if(await this.branchExists(z))await this.deleteBranch(z);await this.createBranch(z,G);let J=await Promise.all(F.map(async(K)=>{if(K.type==="delete")return{action:"delete",file_path:K.path};return{action:await this.getFileContent(K.path,G)!==null?"update":"create",file_path:K.path,content:K.content}}));await this.request("POST",`/projects/${this.projectId}/repository/commits`,{branch:z,commit_message:A,actions:J})}async getFileContent(z,A){let F=await this.optional("GET",`/projects/${this.projectId}/repository/files/${encodeURIComponent(z)}?ref=${encodeURIComponent(A)}`);if(!F?.content)return null;return F.encoding==="base64"?Buffer.from(F.content,"base64").toString("utf-8"):F.content}async createPullRequest(z){let A=await this.request("POST",`/projects/${this.projectId}/merge_requests`,{source_branch:z.head,target_branch:z.base,title:z.draft?`Draft: ${z.title}`:z.title,description:z.body,...z.labels?.length?{labels:z.labels.join(",")}:{},remove_source_branch:!0});return await this.assignPeople(A.iid,z),this.toPullRequest(A)}async assignPeople(z,A){let F=async(J=[])=>{return(await Promise.all(J.map(async(O)=>{return(await this.optional("GET",`/users?username=${encodeURIComponent(O)}`))?.[0]?.id??null}))).filter((O)=>O!==null)},[G,H]=await Promise.all([F(A.reviewers),F(A.assignees)]);if(G.length===0&&H.length===0)return;try{await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}`,{...G.length?{reviewer_ids:G}:{},...H.length?{assignee_ids:H}:{}})}catch(J){this.logger.warn(`\u26A0\uFE0F Could not assign reviewers on !${z}: ${M(J)}`)}}async getPullRequests(z="open"){let A=z==="all"?"state=all":z==="open"?"state=opened":"state=all",G=(await this.request("GET",`/projects/${this.projectId}/merge_requests?${A}&per_page=100`)).map((H)=>this.toPullRequest(H));return z==="closed"?G.filter((H)=>H.state!=="open"):G}async updatePullRequest(z,A){let F=await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}`,{...A.title!==void 0?{title:A.draft?`Draft: ${A.title}`:A.title}:{},...A.body!==void 0?{description:A.body}:{},...A.base!==void 0?{target_branch:A.base}:{},...A.labels!==void 0?{labels:A.labels.join(",")}:{}});return this.toPullRequest(F)}async closePullRequest(z){await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}`,{state_event:"close"})}async reopenPullRequest(z){await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}`,{state_event:"reopen"})}async mergePullRequest(z,A="squash"){await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}/merge`,{squash:A==="squash",should_remove_source_branch:!0})}async getPullRequestDiff(z){return((await this.request("GET",`/projects/${this.projectId}/merge_requests/${z}/changes`)).changes??[]).map((F)=>[`diff --git a/${F.old_path} b/${F.new_path}`,`--- a/${F.old_path}`,`+++ b/${F.new_path}`,F.diff.replace(/\n$/,"")].join(`
2
+ import{Fh as V}from"./chunk-j6geg3qt.js";import{Kh as P}from"./chunk-34vracy4.js";import{Nh as M,Qh as Q}from"./chunk-zwtx6vn3.js";function X(z){if(z==="running")return"in_progress";if(z==="success"||z==="failed"||z==="canceled"||z==="skipped"||z==="manual")return"completed";return"queued"}function Y(z){switch(z){case"success":return"success";case"failed":return"failure";case"canceled":return"cancelled";case"skipped":case"manual":return"skipped";default:return null}}class Z{token;apiUrl;logger;projectId;constructor(z,A,F,G,H){this.token=z;this.apiUrl=(G??"https://gitlab.com/api/v4").replace(/\/+$/,""),this.logger=H??Q(),this.projectId=encodeURIComponent(`${A}/${F}`)}capabilities(){return{pinIssues:!1,checkRuns:!0,inlineReviewComments:!0,reviewSuggestions:!0,nativeAutoMerge:!0,commentReactions:!0,ciLogs:!0,ciRuns:!0,reviewThreads:!0,teamReviewers:!1,draftPullRequests:!0,permissionLookup:!0,branchHousekeeping:!0,reopenPullRequests:!0,labels:!0}}async request(z,A,F,G={}){let H=await P(`${this.apiUrl}${A}`,{method:z,headers:{"PRIVATE-TOKEN":this.token,Accept:G.raw?"text/plain":"application/json","User-Agent":"buddy",...F?{"Content-Type":"application/json"}:{}},...F?{body:JSON.stringify(F)}:{}});if(!H.ok){let K=await H.text().catch(()=>"");throw Error(`GitLab ${z} ${A} failed: ${H.status} ${K.slice(0,200)}`)}let J=await H.text();if(G.raw)return J;return J.trim()?JSON.parse(J):void 0}async optional(z,A,F={}){try{return await this.request(z,A,void 0,F)}catch(G){if(String(G).includes("404"))return null;throw G}}async branchExists(z){return await this.optional("GET",`/projects/${this.projectId}/repository/branches/${encodeURIComponent(z)}`)!==null}async createBranch(z,A){await this.request("POST",`/projects/${this.projectId}/repository/branches`,{branch:z,ref:A})}async deleteBranch(z){await this.request("DELETE",`/projects/${this.projectId}/repository/branches/${encodeURIComponent(z)}`)}async commitChanges(z,A,F,G="main"){if(F.length===0)return;if(await this.branchExists(z))await this.deleteBranch(z);await this.createBranch(z,G);let J=await Promise.all(F.map(async(K)=>{if(K.type==="delete")return{action:"delete",file_path:K.path};return{action:await this.getFileContent(K.path,G)!==null?"update":"create",file_path:K.path,content:K.content}}));await this.request("POST",`/projects/${this.projectId}/repository/commits`,{branch:z,commit_message:A,actions:J})}async getFileContent(z,A){let F=await this.optional("GET",`/projects/${this.projectId}/repository/files/${encodeURIComponent(z)}?ref=${encodeURIComponent(A)}`);if(!F?.content)return null;return F.encoding==="base64"?Buffer.from(F.content,"base64").toString("utf-8"):F.content}async createPullRequest(z){let A=await this.request("POST",`/projects/${this.projectId}/merge_requests`,{source_branch:z.head,target_branch:z.base,title:z.draft?`Draft: ${z.title}`:z.title,description:z.body,...z.labels?.length?{labels:z.labels.join(",")}:{},remove_source_branch:!0});return await this.assignPeople(A.iid,z),this.toPullRequest(A)}async assignPeople(z,A){let F=async(J=[])=>{return(await Promise.all(J.map(async(O)=>{return(await this.optional("GET",`/users?username=${encodeURIComponent(O)}`))?.[0]?.id??null}))).filter((O)=>O!==null)},[G,H]=await Promise.all([F(A.reviewers),F(A.assignees)]);if(G.length===0&&H.length===0)return;try{await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}`,{...G.length?{reviewer_ids:G}:{},...H.length?{assignee_ids:H}:{}})}catch(J){this.logger.warn(`\u26A0\uFE0F Could not assign reviewers on !${z}: ${M(J)}`)}}async getPullRequests(z="open"){let A=z==="all"?"state=all":z==="open"?"state=opened":"state=all",G=(await this.request("GET",`/projects/${this.projectId}/merge_requests?${A}&per_page=100`)).map((H)=>this.toPullRequest(H));return z==="closed"?G.filter((H)=>H.state!=="open"):G}async updatePullRequest(z,A){let F=await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}`,{...A.title!==void 0?{title:A.draft?`Draft: ${A.title}`:A.title}:{},...A.body!==void 0?{description:A.body}:{},...A.base!==void 0?{target_branch:A.base}:{},...A.labels!==void 0?{labels:A.labels.join(",")}:{}});return this.toPullRequest(F)}async closePullRequest(z){await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}`,{state_event:"close"})}async reopenPullRequest(z){await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}`,{state_event:"reopen"})}async mergePullRequest(z,A="squash"){await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}/merge`,{squash:A==="squash",should_remove_source_branch:!0})}async getPullRequestDiff(z){return((await this.request("GET",`/projects/${this.projectId}/merge_requests/${z}/changes`)).changes??[]).map((F)=>[`diff --git a/${F.old_path} b/${F.new_path}`,`--- a/${F.old_path}`,`+++ b/${F.new_path}`,F.diff.replace(/\n$/,"")].join(`
3
3
  `)).join(`
4
4
  `)}async getPullRequestHeadSha(z){return(await this.request("GET",`/projects/${this.projectId}/merge_requests/${z}`)).sha??""}async createComment(z,A){try{await this.request("POST",`/projects/${this.projectId}/merge_requests/${z}/notes`,{body:A})}catch(F){if(!String(F).includes("404"))throw F;await this.request("POST",`/projects/${this.projectId}/issues/${z}/notes`,{body:A})}}async createIssue(z){let A=await this.request("POST",`/projects/${this.projectId}/issues`,{title:z.title,description:z.body,...z.labels?.length?{labels:z.labels.join(",")}:{}});return this.toIssue(A)}async getIssues(z="open"){let A=z==="all"?"state=all":`state=${z==="open"?"opened":"closed"}`;return(await this.request("GET",`/projects/${this.projectId}/issues?${A}&per_page=100`)).map((G)=>this.toIssue(G))}async updateIssue(z,A){let F=await this.request("PUT",`/projects/${this.projectId}/issues/${z}`,{...A.title!==void 0?{title:A.title}:{},...A.body!==void 0?{description:A.body}:{},...A.labels!==void 0?{labels:A.labels.join(",")}:{}});return this.toIssue(F)}async closeIssue(z){await this.request("PUT",`/projects/${this.projectId}/issues/${z}`,{state_event:"close"})}async unpinIssue(z){return!1}async enableAutoMerge(z,A="squash"){try{return await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}/merge`,{merge_when_pipeline_succeeds:!0,squash:A==="squash",should_remove_source_branch:!0}),!0}catch(F){return this.logger.debug(`Could not queue !${z} for auto-merge: ${M(F)}`),!1}}async getPullRequestChecksState(z){let F=(await this.optional("GET",`/projects/${this.projectId}/merge_requests/${z}/pipelines`))?.[0]?.status;if(!F)return"none";if(F==="success")return"success";if(["failed","canceled"].includes(F))return"failure";if(["running","pending","created","waiting_for_resource","preparing","scheduled"].includes(F))return"pending";return"none"}async createReview(z,A){if(await this.request("POST",`/projects/${this.projectId}/merge_requests/${z}/notes`,{body:A.body}),!A.comments?.length)return{posted:!0,inlineComments:0};let G=(await this.optional("GET",`/projects/${this.projectId}/merge_requests/${z}/versions`))?.[0];if(!G)return this.logger.warn("\u26A0\uFE0F Could not resolve diff positions; inline comments were not posted"),{posted:!0,inlineComments:0};let H=0;for(let J of A.comments)try{await this.request("POST",`/projects/${this.projectId}/merge_requests/${z}/discussions`,{body:J.body,position:{position_type:"text",base_sha:G.base_commit_sha,start_sha:G.start_commit_sha,head_sha:G.head_commit_sha,new_path:J.path,old_path:J.path,...J.side==="RIGHT"?{new_line:J.line}:{old_line:J.line}}}),H++}catch(K){this.logger.debug(`Could not place a comment on ${J.path}:${J.line}: ${M(K)}`)}return{posted:!0,inlineComments:H}}async createCheckRun(z,A,F){try{await this.request("POST",`/projects/${this.projectId}/statuses/${A}`,{state:F.conclusion==="failure"?"failed":"success",name:z,description:F.title.slice(0,140)})}catch(G){this.logger.warn(`\u26A0\uFE0F Could not report status ${z}: ${M(G)}`)}}async reactToComment(z,A){let F={eyes:"eyes","+1":"thumbsup","-1":"thumbsdown",rocket:"rocket",confused:"confused"};try{await this.request("POST",`/projects/${this.projectId}/notes/${z}/award_emoji`,{name:F[A]??"eyes"})}catch(G){this.logger.debug(`Could not react to note ${z}: ${M(G)}`)}}async hasWriteAccess(z){return(await this.optional("GET",`/projects/${this.projectId}/members/all?query=${encodeURIComponent(z)}`)??[]).some((F)=>F.username===z&&F.access_level>=30)}async getWorkflowRunLogs(z){return this.optional("GET",`/projects/${this.projectId}/jobs/${z}/trace`,{raw:!0}).catch((A)=>{return this.logger.debug(`Could not read the trace for job ${z}: ${M(A)}`),null})}async listWorkflowRuns(z,A={}){let F=A.limit??20;try{return(await this.request("GET",`/projects/${this.projectId}/jobs?per_page=${Math.min(F*5,100)}`)??[]).filter((H)=>H.ref===z).map((H)=>({id:H.id,name:H.name??"",headSha:H.commit?.id??"",headBranch:H.ref??z,status:X(H.status),conclusion:Y(H.status),createdAt:new Date(H.created_at??new Date().toISOString())})).filter((H)=>!A.status||H.status===A.status).slice(0,F)}catch(G){return this.logger.debug(`Could not list CI jobs for ${z}: ${M(G)}`),[]}}async rerunWorkflowRun(z){try{return await this.request("POST",`/projects/${this.projectId}/jobs/${z}/retry`),!0}catch(A){return this.logger.warn(`Could not retry job ${z}: ${M(A)}`),!1}}async listReviewThreads(z){try{return(await this.request("GET",`/projects/${this.projectId}/merge_requests/${z}/discussions?per_page=100`)??[]).filter((F)=>(F.notes??[]).some((G)=>G.resolvable)).map((F)=>({id:F.id,isResolved:(F.notes??[]).every((G)=>!G.resolvable||G.resolved),...F.notes?.[0]?.position?.new_path?{path:F.notes[0].position.new_path}:{},authorLogins:(F.notes??[]).map((G)=>G.author?.username).filter((G)=>typeof G==="string")}))}catch(A){return this.logger.debug(`Could not read discussions on !${z}: ${M(A)}`),[]}}async resolveReviewThread(z,A){try{return await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}/discussions/${encodeURIComponent(A)}`,{resolved:!0}),!0}catch(F){return this.logger.warn(`Could not resolve discussion ${A}: ${M(F)}`),!1}}async getBuddyBranches(){return(await this.request("GET",`/projects/${this.projectId}/repository/branches?search=buddy&per_page=100`)).filter((A)=>V(A.name)).map((A)=>({name:A.name,sha:A.commit?.id??"",lastCommitDate:A.commit?.committed_date?new Date(A.commit.committed_date):new Date(0)}))}async getOrphanedBuddyBranches(){let[z,A]=await Promise.all([this.getBuddyBranches(),this.getPullRequests("open")]),F=new Set(A.map((G)=>G.head));return z.filter((G)=>!F.has(G.name))}async cleanupStaleBranches(z=7,A=!1){let F=new Date(Date.now()-z*24*60*60*1000),G=(await this.getOrphanedBuddyBranches()).filter((K)=>K.lastCommitDate<F);if(A)return{deleted:G.map((K)=>K.name),failed:[]};let H=[],J=[];for(let K of G)try{await this.deleteBranch(K.name),H.push(K.name)}catch{J.push(K.name)}return{deleted:H,failed:J}}toPullRequest(z){let A=Boolean(z.draft??z.work_in_progress)||/^(?:draft|wip):/i.test(z.title);return{number:z.iid,title:z.title.replace(/^(?:draft|wip):\s*/i,""),body:z.description??"",head:z.source_branch,base:z.target_branch,state:z.state==="merged"?"merged":z.state==="opened"?"open":"closed",url:z.web_url,createdAt:new Date(z.created_at),updatedAt:new Date(z.updated_at),...z.merged_at?{mergedAt:new Date(z.merged_at)}:{},author:z.author?.username??"",reviewers:(z.reviewers??[]).map((F)=>F.username),assignees:(z.assignees??[]).map((F)=>F.username),labels:z.labels??[],draft:A}}toIssue(z){return{number:z.iid,title:z.title,body:z.description??"",state:z.state==="closed"?"closed":"open",url:z.web_url,createdAt:new Date(z.created_at),updatedAt:new Date(z.updated_at),...z.closed_at?{closedAt:new Date(z.closed_at)}:{},author:z.author?.username??"",assignees:(z.assignees??[]).map((A)=>A.username),labels:z.labels??[]}}}
5
- export{Z as Ch};
5
+ export{Z as Dh};