@buddysh/buddy 0.11.0 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +121 -0
- package/README.md +54 -43
- package/bin/cli.ts +282 -135
- package/dist/bin/cli.d.ts +5 -1
- package/dist/bin/cli.js +84 -91
- package/dist/chunk-05me15qw.js +2 -0
- package/dist/{chunk-bxfc4g2x.js → chunk-08x5b93v.js} +2 -13
- package/dist/chunk-0eg3kxb5.js +5 -0
- package/dist/chunk-0hc97k0t.js +44 -0
- package/dist/chunk-0paakbpj.js +2 -0
- package/dist/{chunk-hfvezfxh.js → chunk-0scz1dv5.js} +1 -1
- package/dist/{chunk-sp818c27.js → chunk-0w695m54.js} +5 -5
- package/dist/{chunk-vyapg8ca.js → chunk-11hdrnf6.js} +3 -3
- package/dist/{chunk-1stt2whn.js → chunk-15r904nz.js} +2 -2
- package/dist/{chunk-5k40mwd4.js → chunk-193abzy6.js} +1 -1
- package/dist/chunk-19zyq15p.js +2 -0
- package/dist/chunk-1c4690h9.js +79 -0
- package/dist/{chunk-q9n79dd3.js → chunk-1cpdz49v.js} +1 -1
- package/dist/{chunk-thaxgm5p.js → chunk-1qgr52wx.js} +1 -1
- package/dist/chunk-24c2ab29.js +2 -0
- package/dist/chunk-25sz1y7j.js +16 -0
- package/dist/chunk-2et8yavs.js +3 -0
- package/dist/chunk-2wj5xtdn.js +2 -0
- package/dist/{chunk-7mgec8kb.js → chunk-3901s7h9.js} +1 -1
- package/dist/{chunk-xvptf9jy.js → chunk-3cvng2nz.js} +2 -2
- package/dist/chunk-3fzbvs2p.js +2 -0
- package/dist/chunk-3pqra420.js +2 -0
- package/dist/{chunk-yk23nc4t.js → chunk-40znfg3x.js} +1 -1
- package/dist/chunk-428c5652.js +2 -0
- package/dist/chunk-49znmbh8.js +2 -0
- package/dist/chunk-5044y9en.js +5 -0
- package/dist/chunk-5yfaptmp.js +7 -0
- package/dist/{chunk-h7hs95wn.js → chunk-61xecp1z.js} +2 -2
- package/dist/{chunk-x0ya2r4r.js → chunk-657nbbp7.js} +2 -2
- package/dist/chunk-68fw3ma0.js +2 -0
- package/dist/{chunk-9h04nskh.js → chunk-69qyr9ef.js} +1 -1
- package/dist/chunk-6bd8ghkz.js +27 -0
- package/dist/{chunk-vh504tcv.js → chunk-6p4qz8qv.js} +2 -2
- package/dist/chunk-847g7jde.js +2 -0
- package/dist/{chunk-r3zyw8x0.js → chunk-8fw0v7bv.js} +2 -2
- package/dist/chunk-8hjvthz4.js +92 -0
- package/dist/chunk-90zmqn5k.js +2 -0
- package/dist/{chunk-3zdcekfj.js → chunk-929h6hhp.js} +2 -2
- package/dist/chunk-96ht6hwd.js +4 -0
- package/dist/chunk-97qf7mdt.js +2 -0
- package/dist/chunk-a4hzzn28.js +2 -0
- package/dist/chunk-aa277p5r.js +2 -0
- package/dist/chunk-b357cgb0.js +2 -0
- package/dist/chunk-b9escac0.js +4 -0
- package/dist/{chunk-56q4pwb5.js → chunk-be629jhq.js} +2 -2
- package/dist/chunk-bffxf4xy.js +2 -0
- package/dist/chunk-brfyymhf.js +2 -0
- package/dist/{chunk-zs3jaj0g.js → chunk-bymwaezh.js} +165 -119
- package/dist/chunk-c3es7pgf.js +2 -0
- package/dist/{chunk-9750tenz.js → chunk-c8rzx3a1.js} +1 -1
- package/dist/{chunk-tzs22es2.js → chunk-cgvt98pd.js} +1 -1
- package/dist/chunk-cwfkm7h9.js +3 -0
- package/dist/chunk-cwqhxqv7.js +2 -0
- package/dist/chunk-dgfb8k0h.js +2 -0
- package/dist/chunk-dqbk3kcj.js +104 -0
- package/dist/chunk-ds4stft2.js +2 -0
- package/dist/{chunk-1h3ey7k5.js → chunk-e68nf7cm.js} +1 -1
- package/dist/chunk-emyvrx5t.js +2 -0
- package/dist/{chunk-16yqbccr.js → chunk-eseshkd0.js} +1 -1
- package/dist/chunk-f53y8ans.js +3 -0
- package/dist/chunk-fjp3a7hp.js +26 -0
- package/dist/chunk-fpnjpgrb.js +2 -0
- package/dist/chunk-fr5c326k.js +2 -0
- package/dist/chunk-g24hav8e.js +370 -0
- package/dist/{chunk-6md7qf2g.js → chunk-g30dr44w.js} +2 -2
- package/dist/chunk-gkpd5nw2.js +2 -0
- package/dist/chunk-hbhmns7s.js +2 -0
- package/dist/chunk-hd5j9e3c.js +2 -0
- package/dist/{chunk-akffynkc.js → chunk-hfjywbbc.js} +1 -1
- package/dist/chunk-hmskwy76.js +2 -0
- package/dist/chunk-hns85dqw.js +2 -0
- package/dist/{chunk-wtjhehz9.js → chunk-hptfq3rg.js} +1 -1
- package/dist/{chunk-54sc18p8.js → chunk-hsa07n7c.js} +1 -1
- package/dist/chunk-hwxmhkxp.js +2 -0
- package/dist/{chunk-52x8mvh4.js → chunk-jnb80k2x.js} +2 -2
- package/dist/chunk-jtxcr5yw.js +4 -0
- package/dist/{chunk-tn8prpny.js → chunk-k26wnmzk.js} +7 -7
- package/dist/{chunk-2bp7tqca.js → chunk-kprtsn8c.js} +1 -1
- package/dist/chunk-m4p7cnvk.js +2 -0
- package/dist/chunk-mcwxpdg9.js +2 -0
- package/dist/chunk-mkzmjg3f.js +4 -0
- package/dist/chunk-ncrq3fvv.js +2 -0
- package/dist/chunk-ng7px8gx.js +2 -0
- package/dist/{chunk-vagxqhef.js → chunk-nrr8z2z7.js} +2 -2
- package/dist/{chunk-g0w8n555.js → chunk-p6qbqsyp.js} +2 -2
- package/dist/chunk-p8tmms5h.js +3 -0
- package/dist/{chunk-hw70wbzg.js → chunk-phfmnnne.js} +2 -2
- package/dist/{chunk-tb5y0350.js → chunk-pkr6905p.js} +1 -1
- package/dist/chunk-ppmabn5h.js +2 -0
- package/dist/chunk-pskqrv5r.js +2 -0
- package/dist/{chunk-4xsq18p3.js → chunk-q2tjkhez.js} +1 -1
- package/dist/{chunk-6g1y9yqh.js → chunk-q4t568hv.js} +1 -1
- package/dist/chunk-qd2s51gc.js +2 -0
- package/dist/chunk-r763e19p.js +6 -0
- package/dist/{chunk-74pxb991.js → chunk-rc2mk5x6.js} +2 -2
- package/dist/{chunk-zb62jhwm.js → chunk-s4zb0fcj.js} +13 -9
- package/dist/chunk-s6z3gm2s.js +5 -0
- package/dist/chunk-sc7emb71.js +2 -0
- package/dist/chunk-sw2538r0.js +49 -0
- package/dist/chunk-t25apff9.js +2 -0
- package/dist/{chunk-p4zwy518.js → chunk-tjc2vgwn.js} +2 -2
- package/dist/{chunk-gngwjf70.js → chunk-tw047td6.js} +2 -2
- package/dist/chunk-tws3npt7.js +38 -0
- package/dist/{chunk-6d9hmjt8.js → chunk-txtrpypt.js} +2 -2
- package/dist/chunk-v1wfa758.js +2 -0
- package/dist/{chunk-dfesffnr.js → chunk-vckhctmr.js} +1 -1
- package/dist/chunk-vdd1cghr.js +2 -0
- package/dist/{chunk-fvpr07dn.js → chunk-vgtmrd4c.js} +1 -1
- package/dist/chunk-vj1sdxpp.js +2 -0
- package/dist/{chunk-fm8ckj9b.js → chunk-vqa6vte3.js} +1 -1
- package/dist/{chunk-82dv4p13.js → chunk-wn6pbyzn.js} +1 -1
- package/dist/chunk-x23a6szw.js +2 -0
- package/dist/{chunk-xqx460y2.js → chunk-xs12dtf1.js} +1 -1
- package/dist/chunk-xznnmhyt.js +2 -0
- package/dist/chunk-y3dd8v85.js +2 -0
- package/dist/chunk-yk183r6z.js +2 -0
- package/dist/{chunk-1c1gznm9.js → chunk-yngahb11.js} +2 -2
- package/dist/{chunk-qyf90zz3.js → chunk-yp1tgdh3.js} +1 -1
- package/dist/chunk-ys1qqcpp.js +2 -0
- package/dist/{chunk-8rc6042h.js → chunk-ytmxd5fk.js} +2 -2
- package/dist/chunk-zgkrhymn.js +2 -0
- package/dist/chunk-zxgkp71x.js +2 -0
- package/dist/src/agent/index.d.ts +6 -1
- package/dist/src/agent/modes.d.ts +0 -8
- package/dist/src/agent/plan.d.ts +28 -0
- package/dist/src/agent/tasks.d.ts +20 -0
- package/dist/src/agent/tools/issue.d.ts +19 -0
- package/dist/src/ci/attempts.d.ts +36 -0
- package/dist/src/ci/base.d.ts +55 -0
- package/dist/src/ci/fix.d.ts +27 -18
- package/dist/src/ci/index.d.ts +5 -1
- package/dist/src/ci/run.d.ts +28 -0
- package/dist/src/commands/handlers.d.ts +3 -0
- package/dist/src/dashboard/dashboard-generator.d.ts +4 -0
- package/dist/src/events/index.d.ts +12 -0
- package/dist/src/gates/checks.d.ts +10 -0
- package/dist/src/gates/index.d.ts +1 -0
- package/dist/src/gates/post-merge.d.ts +13 -1
- package/dist/src/git/github-provider.d.ts +5 -1
- package/dist/src/git/gitlab-provider.d.ts +5 -1
- package/dist/src/git/provider.d.ts +40 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +1 -1
- package/dist/src/registry/registry-client.d.ts +1 -1
- package/dist/src/reports/index.d.ts +1 -0
- package/dist/src/reports/publish-gate.d.ts +22 -0
- package/dist/src/review/filters.d.ts +36 -0
- package/dist/src/review/index.d.ts +4 -1
- package/dist/src/review/marker.d.ts +18 -0
- package/dist/src/review/poster.d.ts +11 -1
- package/dist/src/review/resolve.d.ts +20 -0
- package/dist/src/review/run.d.ts +35 -0
- package/dist/src/rules/engine.d.ts +19 -0
- package/dist/src/scanner/package-json-extras.d.ts +34 -1
- package/dist/src/setup.d.ts +49 -17
- package/dist/src/setup.js +1 -1
- package/dist/src/templates/github-actions.d.ts +2 -0
- package/dist/src/types.d.ts +4 -1
- package/dist/src/upgrades/migrate.d.ts +3 -0
- package/dist/src/upgrades/report.d.ts +1 -0
- package/dist/src/utils/dockerfile-parser.d.ts +2 -2
- package/dist/src/utils/helpers.d.ts +10 -1
- package/dist/src/version/version-resolver.d.ts +1 -0
- package/package.json +12 -10
- package/dist/chunk-0j7z87kh.js +0 -3
- package/dist/chunk-0r8zt3d7.js +0 -2
- package/dist/chunk-1a53wj0h.js +0 -1
- package/dist/chunk-1wjnd24b.js +0 -24
- package/dist/chunk-1xe07hzm.js +0 -2
- package/dist/chunk-2dbkpfy9.js +0 -2
- package/dist/chunk-3q6czqs4.js +0 -6
- package/dist/chunk-49ey79p0.js +0 -5
- package/dist/chunk-4c9m61yd.js +0 -5
- package/dist/chunk-4efbxdjr.js +0 -4
- package/dist/chunk-4f7panqj.js +0 -21
- package/dist/chunk-4hd3rre0.js +0 -2
- package/dist/chunk-5c3qf34r.js +0 -2
- package/dist/chunk-5kt03hx5.js +0 -2
- package/dist/chunk-63ept76v.js +0 -2
- package/dist/chunk-65b3vq52.js +0 -2
- package/dist/chunk-6k653r8w.js +0 -2
- package/dist/chunk-6patq6bw.js +0 -2
- package/dist/chunk-6sgh49z1.js +0 -2
- package/dist/chunk-7tfrww3v.js +0 -2
- package/dist/chunk-7xk28xrv.js +0 -2
- package/dist/chunk-8661pvb8.js +0 -3
- package/dist/chunk-887s0w81.js +0 -2
- package/dist/chunk-978wtejw.js +0 -44
- package/dist/chunk-9eqpaxfz.js +0 -2
- package/dist/chunk-9p1xkmjy.js +0 -2
- package/dist/chunk-agdesgzv.js +0 -2
- package/dist/chunk-ar01x04a.js +0 -2
- package/dist/chunk-ay43f085.js +0 -2
- package/dist/chunk-bk9bqd5j.js +0 -2
- package/dist/chunk-bm8d40j0.js +0 -69
- package/dist/chunk-c3fczawt.js +0 -2
- package/dist/chunk-c9r9nd4t.js +0 -1
- package/dist/chunk-ctsz0ynx.js +0 -3
- package/dist/chunk-czremqk7.js +0 -2
- package/dist/chunk-da3wbh04.js +0 -2
- package/dist/chunk-dat582cg.js +0 -2
- package/dist/chunk-djntbp7a.js +0 -105
- package/dist/chunk-eagjp0dh.js +0 -3
- package/dist/chunk-eht72nnj.js +0 -2
- package/dist/chunk-f4nv5x3z.js +0 -2
- package/dist/chunk-fdfk918n.js +0 -2
- package/dist/chunk-fdj0tewy.js +0 -20
- package/dist/chunk-fqj7e6xa.js +0 -2
- package/dist/chunk-frm8zz31.js +0 -2
- package/dist/chunk-g0nv8psv.js +0 -2
- package/dist/chunk-gkmvxjbe.js +0 -2
- package/dist/chunk-j8asz4hb.js +0 -15
- package/dist/chunk-k62w2v03.js +0 -2
- package/dist/chunk-mcrfxphm.js +0 -5
- package/dist/chunk-mh3x7j6h.js +0 -2
- package/dist/chunk-naq32yx3.js +0 -86
- package/dist/chunk-nsmcjkas.js +0 -2
- package/dist/chunk-p1xm1jvz.js +0 -2
- package/dist/chunk-p3wsm8kz.js +0 -2
- package/dist/chunk-p7zgy37f.js +0 -2
- package/dist/chunk-ph1b3vbp.js +0 -315
- package/dist/chunk-pkjm2r0a.js +0 -2
- package/dist/chunk-pkkwb0n0.js +0 -4
- package/dist/chunk-pnpx1kqn.js +0 -6
- package/dist/chunk-qpz9k66h.js +0 -2
- package/dist/chunk-qvn1rtgp.js +0 -2
- package/dist/chunk-r06ce5g6.js +0 -2
- package/dist/chunk-r2sbprdb.js +0 -49
- package/dist/chunk-rqdep14r.js +0 -2
- package/dist/chunk-s1km8cyq.js +0 -2
- package/dist/chunk-s4ms8zag.js +0 -2
- package/dist/chunk-ts35hc5t.js +0 -3
- package/dist/chunk-vkctfqpm.js +0 -3
- package/dist/chunk-wdwvt7gb.js +0 -43
- package/dist/chunk-x3kragh9.js +0 -12
- package/dist/chunk-x9ctz1qc.js +0 -1
- package/dist/chunk-xakpdqaq.js +0 -3
- package/dist/chunk-yncea6ty.js +0 -2
- package/dist/chunk-yq0gxtzv.js +0 -2
- package/dist/chunk-yqhs08ky.js +0 -2
- package/dist/chunk-zve5d96e.js +0 -2
package/bin/cli.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
|
+
import type { FailureKind } from '../src/ci/classify'
|
|
3
4
|
import type { GitProvider } from '../src/git/provider'
|
|
4
5
|
import type { ReviewFinding } from '../src/review/findings'
|
|
5
6
|
import type { ReviewFormat } from '../src/review/local'
|
|
6
|
-
import type { BuddyConfig } from '../src/types'
|
|
7
|
+
import type { BuddyConfig, PullRequest } from '../src/types'
|
|
7
8
|
import fs from 'node:fs'
|
|
8
9
|
import process from 'node:process'
|
|
9
10
|
import { CLI } from '@stacksjs/clapp'
|
|
@@ -17,6 +18,7 @@ import {
|
|
|
17
18
|
parseDashboardActions,
|
|
18
19
|
uncheckDashboardActions,
|
|
19
20
|
} from '../src/dashboard/dashboard-actions'
|
|
21
|
+
import { emitEvent } from '../src/events'
|
|
20
22
|
import { manifestUpdates, parseManifest } from '../src/pr/pr-manifest'
|
|
21
23
|
import {
|
|
22
24
|
analyzeProject,
|
|
@@ -203,7 +205,7 @@ async function collectPackageContext(
|
|
|
203
205
|
}
|
|
204
206
|
}
|
|
205
207
|
|
|
206
|
-
const cli = new CLI('buddy')
|
|
208
|
+
const cli: CLI = new CLI('buddy')
|
|
207
209
|
|
|
208
210
|
cli.usage(`[command] [options]
|
|
209
211
|
|
|
@@ -289,10 +291,23 @@ interface CLIOptions {
|
|
|
289
291
|
ignore?: string
|
|
290
292
|
dryRun?: boolean
|
|
291
293
|
respectLatest?: boolean
|
|
294
|
+
/** Comma-separated reviewers `update` assigns, overriding `pullRequest.reviewers` */
|
|
295
|
+
reviewers?: string
|
|
296
|
+
/** Comma-separated assignees `update` assigns, overriding `pullRequest.assignees` */
|
|
297
|
+
assignees?: string
|
|
298
|
+
/** Comma-separated labels `update` adds, overriding `pullRequest.labels` */
|
|
299
|
+
labels?: string
|
|
300
|
+
/** Which settings pages `open-settings` should open: repo, org or both. */
|
|
301
|
+
type?: string
|
|
302
|
+
/** Set by the generated workflow: honour the `ai.review` filters. */
|
|
303
|
+
auto?: boolean
|
|
292
304
|
}
|
|
293
305
|
|
|
294
306
|
cli
|
|
295
307
|
.command('setup', '🚀 Interactive setup for automated dependency updates (recommended)')
|
|
308
|
+
// `init` is what people type first, by convention from npm, git and cargo.
|
|
309
|
+
// Setup is the command that writes the config, so the alias is honest.
|
|
310
|
+
.alias('init')
|
|
296
311
|
.option('--verbose, -v', 'Enable verbose logging')
|
|
297
312
|
.option('--non-interactive', 'Run setup without prompts (use defaults)')
|
|
298
313
|
.option('--preset <type>', 'Workflow preset: standard|high-frequency|security|minimal|testing', { default: 'standard' })
|
|
@@ -390,7 +405,12 @@ cli
|
|
|
390
405
|
}
|
|
391
406
|
}
|
|
392
407
|
else if (availablePlugins.length > 0 && options.nonInteractive) {
|
|
393
|
-
|
|
408
|
+
// The docs promise setup-completion notifications; silently skipping
|
|
409
|
+
// them made that a lie in exactly the mode CI uses.
|
|
410
|
+
console.log(`\n🔌 Found ${availablePlugins.length} integration(s) — enabled for setup notifications`)
|
|
411
|
+
for (const plugin of availablePlugins) {
|
|
412
|
+
await pluginManager.loadPlugin(plugin)
|
|
413
|
+
}
|
|
394
414
|
}
|
|
395
415
|
|
|
396
416
|
// Pre-flight checks
|
|
@@ -541,19 +561,22 @@ cli
|
|
|
541
561
|
}
|
|
542
562
|
}
|
|
543
563
|
|
|
564
|
+
// Resolved before the config file, not after: the preset decides the
|
|
565
|
+
// update strategy and auto-merge policy that file is written with.
|
|
566
|
+
const preset = getWorkflowPreset(workflowResponse.useCase)
|
|
567
|
+
|
|
544
568
|
// Step 5: Generate Configuration File
|
|
545
569
|
updateProgress(progress, 'Configuration File', true)
|
|
546
570
|
displayProgress(progress)
|
|
547
571
|
|
|
548
572
|
console.log('\n📝 Configuration File')
|
|
549
|
-
await generateConfigFile(repoInfo, tokenSetup.hasCustomToken)
|
|
573
|
+
await generateConfigFile(repoInfo, tokenSetup.hasCustomToken, preset)
|
|
550
574
|
|
|
551
575
|
// Step 6: Generate Workflows
|
|
552
576
|
updateProgress(progress, 'Workflow Generation', true)
|
|
553
577
|
displayProgress(progress)
|
|
554
578
|
|
|
555
579
|
console.log('\n🔄 Workflow Generation')
|
|
556
|
-
const preset = getWorkflowPreset(workflowResponse.useCase)
|
|
557
580
|
|
|
558
581
|
if (workflowResponse.useCase === 'custom' && !options.nonInteractive) {
|
|
559
582
|
await setupCustomWorkflow(preset, logger)
|
|
@@ -640,7 +663,7 @@ cli
|
|
|
640
663
|
.option('--verbose, -v', 'Enable verbose logging')
|
|
641
664
|
.option('--packages <names>', 'Comma-separated list of packages to check')
|
|
642
665
|
.option('--pattern <pattern>', 'Glob pattern to match packages')
|
|
643
|
-
.option('--strategy <type>', 'Update strategy: major|minor|patch|all
|
|
666
|
+
.option('--strategy <type>', 'Update strategy: major|minor|patch|all (default: packages.strategy from config, else all)')
|
|
644
667
|
.option('--ignore <names>', 'Comma-separated list of packages to ignore')
|
|
645
668
|
.option('--respect-latest', 'Respect "latest", "*", and other dynamic version indicators (default: true)')
|
|
646
669
|
.option('--no-respect-latest', 'Allow updating "latest", "*", and other dynamic version indicators')
|
|
@@ -763,6 +786,7 @@ cli
|
|
|
763
786
|
}
|
|
764
787
|
catch (error) {
|
|
765
788
|
logger.error('Scan failed:', error)
|
|
789
|
+
await emitEvent(config.notifications as Parameters<typeof emitEvent>[0], 'run.failed', { command: 'scan', error: error instanceof Error ? error.message : String(error) })
|
|
766
790
|
process.exit(1)
|
|
767
791
|
}
|
|
768
792
|
})
|
|
@@ -782,6 +806,16 @@ cli
|
|
|
782
806
|
const logger = options.verbose ? Logger.verbose() : Logger.quiet()
|
|
783
807
|
const config = await resolveConfig(options.config)
|
|
784
808
|
|
|
809
|
+
// Explicit `false` only. Unset stays on: the setting was documented as
|
|
810
|
+
// defaulting to false and was read by nothing, and enforcing that
|
|
811
|
+
// literally would switch off the dashboard for every repository that
|
|
812
|
+
// never wrote a `dashboard` block — the same trap `ai.review.enabled`
|
|
813
|
+
// set, and the same reading that avoids it.
|
|
814
|
+
if (config.dashboard?.enabled === false) {
|
|
815
|
+
logger.info('ℹ️ Dashboard is disabled by config (dashboard.enabled: false)')
|
|
816
|
+
return
|
|
817
|
+
}
|
|
818
|
+
|
|
785
819
|
try {
|
|
786
820
|
logger.info('Creating or updating dependency dashboard...')
|
|
787
821
|
|
|
@@ -813,6 +847,7 @@ cli
|
|
|
813
847
|
}
|
|
814
848
|
catch (error) {
|
|
815
849
|
logger.error('Dashboard creation failed:', error)
|
|
850
|
+
await emitEvent(config.notifications as Parameters<typeof emitEvent>[0], 'run.failed', { command: 'dashboard', error: error instanceof Error ? error.message : String(error) })
|
|
816
851
|
process.exit(1)
|
|
817
852
|
}
|
|
818
853
|
})
|
|
@@ -820,9 +855,12 @@ cli
|
|
|
820
855
|
cli
|
|
821
856
|
.command('update', 'Update dependencies and create PRs')
|
|
822
857
|
.option('--verbose, -v', 'Enable verbose logging')
|
|
823
|
-
.option('--strategy <type>', 'Update strategy: major|minor|patch|all
|
|
858
|
+
.option('--strategy <type>', 'Update strategy: major|minor|patch|all (default: packages.strategy from config, else all)')
|
|
824
859
|
.option('--ignore <names>', 'Comma-separated list of packages to ignore')
|
|
825
860
|
.option('--dry-run', 'Preview changes without making them')
|
|
861
|
+
.option('--reviewers <names>', 'Comma-separated reviewers to assign (overrides pullRequest.reviewers)')
|
|
862
|
+
.option('--assignees <names>', 'Comma-separated assignees to assign (overrides pullRequest.assignees)')
|
|
863
|
+
.option('--labels <names>', 'Comma-separated labels to add (overrides pullRequest.labels)')
|
|
826
864
|
.option('--respect-latest', 'Respect "latest", "*", and other dynamic version indicators (default: true)')
|
|
827
865
|
.option('--no-respect-latest', 'Allow updating "latest", "*", and other dynamic version indicators')
|
|
828
866
|
.example('buddy update')
|
|
@@ -843,9 +881,26 @@ cli
|
|
|
843
881
|
ignore = options.ignore.split(',').map(p => p.trim())
|
|
844
882
|
}
|
|
845
883
|
|
|
884
|
+
// Per-run PR overrides, from the flags a generated workflow passes.
|
|
885
|
+
// Folded in only when given: `pullRequest` staying unset is itself a
|
|
886
|
+
// setting, and materialising an empty block would change what runs.
|
|
887
|
+
const splitList = (value?: string): string[] | undefined =>
|
|
888
|
+
value ? value.split(',').map(part => part.trim()).filter(Boolean) : undefined
|
|
889
|
+
const reviewers = splitList(options.reviewers)
|
|
890
|
+
const assignees = splitList(options.assignees)
|
|
891
|
+
const labels = splitList(options.labels)
|
|
892
|
+
const prOverrides = {
|
|
893
|
+
...(reviewers ? { reviewers } : {}),
|
|
894
|
+
...(assignees ? { assignees } : {}),
|
|
895
|
+
...(labels ? { labels } : {}),
|
|
896
|
+
}
|
|
897
|
+
|
|
846
898
|
const finalConfig: BuddyConfig = {
|
|
847
899
|
...config,
|
|
848
900
|
verbose: options.verbose ?? config.verbose,
|
|
901
|
+
...(Object.keys(prOverrides).length
|
|
902
|
+
? { pullRequest: { ...config.pullRequest, ...prOverrides } }
|
|
903
|
+
: {}),
|
|
849
904
|
packages: {
|
|
850
905
|
...config.packages,
|
|
851
906
|
strategy: options.strategy ?? config.packages?.strategy ?? 'all',
|
|
@@ -877,6 +932,7 @@ cli
|
|
|
877
932
|
}
|
|
878
933
|
catch (error) {
|
|
879
934
|
logger.error('Update failed:', error)
|
|
935
|
+
await emitEvent(config.notifications as Parameters<typeof emitEvent>[0], 'run.failed', { command: 'update', error: error instanceof Error ? error.message : String(error) })
|
|
880
936
|
process.exit(1)
|
|
881
937
|
}
|
|
882
938
|
})
|
|
@@ -1282,6 +1338,7 @@ cli
|
|
|
1282
1338
|
}
|
|
1283
1339
|
catch (error) {
|
|
1284
1340
|
logger.error('update-check failed:', error)
|
|
1341
|
+
await emitEvent(config.notifications as Parameters<typeof emitEvent>[0], 'run.failed', { command: 'update-check', error: error instanceof Error ? error.message : String(error) })
|
|
1285
1342
|
process.exit(1)
|
|
1286
1343
|
}
|
|
1287
1344
|
})
|
|
@@ -1338,55 +1395,22 @@ cli
|
|
|
1338
1395
|
|
|
1339
1396
|
try {
|
|
1340
1397
|
const provider = await providerFor(config, 'this command', logger)
|
|
1398
|
+
const { runFixCi } = await import('../src/ci')
|
|
1341
1399
|
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
if (!log) {
|
|
1347
|
-
logger.warn('⚠️ Could not read the run logs; nothing to diagnose')
|
|
1348
|
-
return
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
const { attemptFix } = await import('../src/ci')
|
|
1352
|
-
const { createAiClient } = await import('../src/ai')
|
|
1353
|
-
|
|
1354
|
-
const outcome = await attemptFix({
|
|
1355
|
-
log,
|
|
1356
|
-
workspace: process.cwd(),
|
|
1357
|
-
baseBranch: config.repository?.baseBranch ?? 'main',
|
|
1358
|
-
ai: createAiClient(config, logger),
|
|
1400
|
+
const status = await runFixCi({
|
|
1401
|
+
config,
|
|
1402
|
+
provider,
|
|
1359
1403
|
logger,
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
// Detection keys off the manifests a lockfile is derived from, so a
|
|
1364
|
-
// repository with several ecosystems regenerates each of them.
|
|
1365
|
-
const managers = detectRequiredPackageManagers(['package.json', 'composer.json'])
|
|
1366
|
-
let regenerated = false
|
|
1367
|
-
|
|
1368
|
-
for (const manager of managers) {
|
|
1369
|
-
const result = await regenerateLockFile(manager, process.cwd())
|
|
1370
|
-
if (result.success)
|
|
1371
|
-
regenerated = true
|
|
1372
|
-
else
|
|
1373
|
-
logger.warn(`⚠️ ${result.message}`)
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1376
|
-
return regenerated
|
|
1377
|
-
},
|
|
1404
|
+
dryRun: Boolean(options.dryRun),
|
|
1405
|
+
...(options.runId ? { runId: Number.parseInt(options.runId, 10) } : {}),
|
|
1406
|
+
...(options.pr ? { prNumber: Number.parseInt(options.pr, 10) } : {}),
|
|
1378
1407
|
})
|
|
1379
1408
|
|
|
1380
|
-
logger.
|
|
1381
|
-
|
|
1382
|
-
const prNumber = options.pr ? Number.parseInt(options.pr, 10) : undefined
|
|
1383
|
-
if (prNumber && !options.dryRun)
|
|
1384
|
-
await provider.createComment(prNumber, outcome.report)
|
|
1385
|
-
|
|
1386
|
-
logger.success(`✅ ${outcome.action}${outcome.fixed ? ' (fixed)' : ''}`)
|
|
1409
|
+
logger.success(`✅ ${status}`)
|
|
1387
1410
|
}
|
|
1388
1411
|
catch (error) {
|
|
1389
1412
|
logger.error('fix-ci failed:', error)
|
|
1413
|
+
await emitEvent(config.notifications as Parameters<typeof emitEvent>[0], 'run.failed', { command: 'fix-ci', error: error instanceof Error ? error.message : String(error) })
|
|
1390
1414
|
process.exit(1)
|
|
1391
1415
|
}
|
|
1392
1416
|
})
|
|
@@ -1487,6 +1511,22 @@ cli
|
|
|
1487
1511
|
return 'Rebased.'
|
|
1488
1512
|
},
|
|
1489
1513
|
merge: async () => await new Buddy(config).mergeEligiblePullRequests(false),
|
|
1514
|
+
// `analysisOnly` because this job checks out the default branch, not
|
|
1515
|
+
// the pull request's. A lock-file rewrite or an agent edit here would
|
|
1516
|
+
// change the wrong tree; re-running a flake is an API call and still
|
|
1517
|
+
// works. The fix-ci job, which does check out the branch, repairs.
|
|
1518
|
+
fixCi: async (prNumber) => {
|
|
1519
|
+
const { runFixCi } = await import('../src/ci')
|
|
1520
|
+
return await runFixCi({ config, provider, prNumber, analysisOnly: true, logger })
|
|
1521
|
+
},
|
|
1522
|
+
plan: async (number, isPullRequest, request) => {
|
|
1523
|
+
const { runPlan } = await import('../src/agent')
|
|
1524
|
+
return await runPlan({ config, provider, number, isPullRequest, request, logger })
|
|
1525
|
+
},
|
|
1526
|
+
resolve: async (prNumber) => {
|
|
1527
|
+
const { resolveBuddyThreads } = await import('../src/review')
|
|
1528
|
+
return await resolveBuddyThreads({ provider, prNumber, logger })
|
|
1529
|
+
},
|
|
1490
1530
|
remember: async (text, context) => {
|
|
1491
1531
|
const { addLearning, createLearning, loadLearnings, serializeLearnings, DEFAULT_LEARNINGS_FILE }
|
|
1492
1532
|
= await import('../src/ai')
|
|
@@ -1553,6 +1593,7 @@ cli
|
|
|
1553
1593
|
.option('--fail-on <severity>', 'Exit non-zero when a finding at or above this severity is found')
|
|
1554
1594
|
.option('--profile <name>', 'Review profile: chill|assertive')
|
|
1555
1595
|
.option('--summary-only', 'Post only the summary, without inline findings')
|
|
1596
|
+
.option('--auto', 'Treat this as an automatic trigger, honouring the ai.review filters')
|
|
1556
1597
|
.option('--dry-run', 'Print the review instead of posting it')
|
|
1557
1598
|
.example('buddy review 42')
|
|
1558
1599
|
.example('buddy review --staged --light')
|
|
@@ -1595,36 +1636,58 @@ cli
|
|
|
1595
1636
|
process.exit(1)
|
|
1596
1637
|
}
|
|
1597
1638
|
|
|
1598
|
-
const {
|
|
1599
|
-
composeInstructions,
|
|
1600
|
-
loadGuidelines,
|
|
1601
|
-
parseReviewState,
|
|
1602
|
-
prepareReview,
|
|
1603
|
-
reviewDiff,
|
|
1604
|
-
} = await import('../src/review')
|
|
1639
|
+
const { composeInstructions, reviewDiff } = await import('../src/review')
|
|
1605
1640
|
const { collectLocalDiff, formatReview, shouldFail } = await import('../src/review/local')
|
|
1606
1641
|
const { runAnalyzers } = await import('../src/analysis')
|
|
1607
1642
|
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1643
|
+
// A pull request review goes through the shared path, which is also what
|
|
1644
|
+
// `@buddy review` uses. It used to be reimplemented here and had drifted:
|
|
1645
|
+
// this command skipped analyzers outright for a pull request and never
|
|
1646
|
+
// read learnings at all, so the automatic review the generated workflow
|
|
1647
|
+
// runs was the one path missing both.
|
|
1613
1648
|
if (prNumber) {
|
|
1614
|
-
gitProvider = await providerFor(config, 'reviewing a pull request', log)
|
|
1649
|
+
const gitProvider = await providerFor(config, 'reviewing a pull request', log)
|
|
1650
|
+
const { reviewPullRequest } = await import('../src/review/run')
|
|
1651
|
+
|
|
1652
|
+
const { status, result } = await reviewPullRequest({
|
|
1653
|
+
config,
|
|
1654
|
+
provider: gitProvider,
|
|
1655
|
+
prNumber: Number.parseInt(prNumber, 10),
|
|
1656
|
+
// `--auto` is what the generated workflow passes. Without it this is
|
|
1657
|
+
// someone at a terminal, who has already decided they want a review.
|
|
1658
|
+
trigger: options.auto ? 'automatic' : 'requested',
|
|
1659
|
+
// The workflow fires on every edited event, so without this the
|
|
1660
|
+
// same head commit would be reviewed again each time the PR body
|
|
1661
|
+
// changes. A person re-running the command still gets their review.
|
|
1662
|
+
...(options.auto ? { skipIfReviewed: true } : {}),
|
|
1663
|
+
logger: log,
|
|
1664
|
+
dryRun: Boolean(options.dryRun),
|
|
1665
|
+
...(options.summaryOnly ? { summaryOnly: true } : {}),
|
|
1666
|
+
...(options.profile ? { profile: options.profile as 'chill' | 'assertive' } : {}),
|
|
1667
|
+
})
|
|
1615
1668
|
|
|
1616
|
-
|
|
1617
|
-
|
|
1669
|
+
logger.success(`✅ ${status}`)
|
|
1670
|
+
await emitEvent(config.notifications as Parameters<typeof emitEvent>[0], 'review.completed', {
|
|
1671
|
+
number: Number.parseInt(prNumber, 10),
|
|
1672
|
+
findings: result?.findings.length ?? 0,
|
|
1673
|
+
})
|
|
1674
|
+
|
|
1675
|
+
// `--format` and `--fail-on` were accepted on this path and applied
|
|
1676
|
+
// only on the local one, so a pull request review could not be
|
|
1677
|
+
// rendered as JSON or made to fail a pipeline. The review is posted
|
|
1678
|
+
// regardless; these govern what the terminal sees and the exit code.
|
|
1679
|
+
if (result && format !== 'pretty')
|
|
1680
|
+
process.stdout.write(formatReview(result, format))
|
|
1681
|
+
|
|
1682
|
+
if (result && options.failOn && shouldFail(result.findings, options.failOn as 'critical'))
|
|
1683
|
+
process.exit(1)
|
|
1618
1684
|
|
|
1619
|
-
|
|
1620
|
-
// reports only what is new rather than repeating itself.
|
|
1621
|
-
const prs = await gitProvider.getPullRequests('open')
|
|
1622
|
-
const pr = prs.find(candidate => candidate.number === number)
|
|
1623
|
-
const state = parseReviewState(pr?.body)
|
|
1624
|
-
seenFingerprints = state?.fingerprints ?? []
|
|
1625
|
-
headSha = state?.reviewedSha ?? ''
|
|
1685
|
+
return
|
|
1626
1686
|
}
|
|
1627
|
-
|
|
1687
|
+
|
|
1688
|
+
let diff: string
|
|
1689
|
+
|
|
1690
|
+
{
|
|
1628
1691
|
const base = options.base || config.repository?.baseBranch || 'main'
|
|
1629
1692
|
const mode = options.staged ? 'staged' : options.branch ? 'branch' : 'working'
|
|
1630
1693
|
log.info(`🔍 Reviewing ${mode} changes${mode === 'branch' ? ` against ${base}` : ''}...`)
|
|
@@ -1638,10 +1701,12 @@ cli
|
|
|
1638
1701
|
}
|
|
1639
1702
|
|
|
1640
1703
|
// Analyzers run locally against the working tree, so a local review gets
|
|
1641
|
-
// the same secret scanning and linting a
|
|
1704
|
+
// the same secret scanning and linting a pull request review does — with
|
|
1705
|
+
// no token. The `|| prNumber` that used to sit in this condition is why
|
|
1706
|
+
// a pull request review got none of it.
|
|
1642
1707
|
const { parseUnifiedDiff } = await import('../src/review/diff')
|
|
1643
1708
|
const changedFiles = parseUnifiedDiff(diff).files.map(file => file.path)
|
|
1644
|
-
const analysis = config.analysis?.enabled === false
|
|
1709
|
+
const analysis = config.analysis?.enabled === false
|
|
1645
1710
|
? { findings: [], ran: [], skipped: [] }
|
|
1646
1711
|
: await runAnalyzers({
|
|
1647
1712
|
files: changedFiles,
|
|
@@ -1661,35 +1726,31 @@ cli
|
|
|
1661
1726
|
|
|
1662
1727
|
process.stdout.write(formatReview(result, format))
|
|
1663
1728
|
|
|
1729
|
+
// `--fix` was accepted here and silently ignored: the light branch
|
|
1730
|
+
// returned before the block that applies suggestions, so the flag
|
|
1731
|
+
// worked everywhere except the one mode fast enough for a hook.
|
|
1732
|
+
if (options.fix) {
|
|
1733
|
+
const applied = await applyFixes(result.findings, Boolean(options.yes), logger)
|
|
1734
|
+
logger.success(`\u{1f527} Applied ${applied} suggestion(s)`)
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1664
1737
|
if (options.failOn && shouldFail(result.findings, options.failOn as 'critical'))
|
|
1665
1738
|
process.exit(1)
|
|
1666
1739
|
return
|
|
1667
1740
|
}
|
|
1668
1741
|
|
|
1669
|
-
//
|
|
1670
|
-
//
|
|
1671
|
-
//
|
|
1672
|
-
|
|
1673
|
-
const guidelines = gitProvider
|
|
1674
|
-
? await loadGuidelines(
|
|
1675
|
-
(path, ref) => gitProvider!.getFileContent(path, ref),
|
|
1676
|
-
baseRef,
|
|
1677
|
-
config.ai?.review?.guidelineFiles,
|
|
1678
|
-
logger,
|
|
1679
|
-
)
|
|
1680
|
-
: ''
|
|
1681
|
-
|
|
1742
|
+
// A local review has no provider to read the base branch through, so it
|
|
1743
|
+
// runs without repository guidelines. Reading them from the working tree
|
|
1744
|
+
// would be a different thing: guidelines are trusted context, and the
|
|
1745
|
+
// working tree is whatever the person running this has edited.
|
|
1682
1746
|
const reviewed = await reviewDiff(ai!, {
|
|
1683
1747
|
diff,
|
|
1684
1748
|
profile: options.profile ?? config.ai?.review?.profile,
|
|
1685
1749
|
summaryOnly: options.summaryOnly ?? config.ai?.review?.summaryOnly,
|
|
1686
|
-
instructions: composeInstructions({
|
|
1687
|
-
global: config.ai?.review?.instructions,
|
|
1688
|
-
guidelines,
|
|
1689
|
-
}),
|
|
1750
|
+
instructions: composeInstructions({ global: config.ai?.review?.instructions }),
|
|
1690
1751
|
pathFilters: config.ai?.review?.pathFilters,
|
|
1691
1752
|
pathInstructions: config.ai?.review?.pathInstructions,
|
|
1692
|
-
seenFingerprints,
|
|
1753
|
+
seenFingerprints: [],
|
|
1693
1754
|
logger: log,
|
|
1694
1755
|
})
|
|
1695
1756
|
|
|
@@ -1701,39 +1762,19 @@ cli
|
|
|
1701
1762
|
omittedFiles: [...reviewed.omittedFiles, ...analysis.skipped.map(entry => `${entry.name} (${entry.reason})`)],
|
|
1702
1763
|
}
|
|
1703
1764
|
|
|
1704
|
-
|
|
1705
|
-
headSha,
|
|
1706
|
-
requestChangesOn: config.ai?.review?.requestChangesOn,
|
|
1707
|
-
seenFingerprints,
|
|
1708
|
-
})
|
|
1709
|
-
|
|
1710
|
-
if (!prNumber) {
|
|
1711
|
-
process.stdout.write(formatReview(result, format))
|
|
1712
|
-
|
|
1713
|
-
if (options.fix) {
|
|
1714
|
-
const applied = await applyFixes(result.findings, Boolean(options.yes), logger)
|
|
1715
|
-
logger.success(`🔧 Applied ${applied} suggestion(s)`)
|
|
1716
|
-
}
|
|
1765
|
+
process.stdout.write(formatReview(result, format))
|
|
1717
1766
|
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1767
|
+
if (options.fix) {
|
|
1768
|
+
const applied = await applyFixes(result.findings, Boolean(options.yes), logger)
|
|
1769
|
+
logger.success(`🔧 Applied ${applied} suggestion(s)`)
|
|
1721
1770
|
}
|
|
1722
1771
|
|
|
1723
|
-
if (options.
|
|
1724
|
-
|
|
1725
|
-
for (const comment of prepared.comments)
|
|
1726
|
-
logger.info(`${comment.path}:${comment.line}\n${comment.body}\n`)
|
|
1727
|
-
logger.success(`✅ Review complete: ${result.findings.length} finding(s)`)
|
|
1728
|
-
return
|
|
1729
|
-
}
|
|
1730
|
-
|
|
1731
|
-
assertSupports(gitProvider!, 'inlineReviewComments', 'createReview', 'posting a review')
|
|
1732
|
-
await gitProvider.createReview(Number.parseInt(prNumber, 10), prepared)
|
|
1733
|
-
logger.success(`✅ Reviewed PR #${prNumber}: ${result.findings.length} finding(s)`)
|
|
1772
|
+
if (options.failOn && shouldFail(result.findings, options.failOn as 'critical'))
|
|
1773
|
+
process.exit(1)
|
|
1734
1774
|
}
|
|
1735
1775
|
catch (error) {
|
|
1736
1776
|
logger.error('Review failed:', error)
|
|
1777
|
+
await emitEvent(config.notifications as Parameters<typeof emitEvent>[0], 'run.failed', { command: 'review', error: error instanceof Error ? error.message : String(error) })
|
|
1737
1778
|
process.exit(1)
|
|
1738
1779
|
}
|
|
1739
1780
|
})
|
|
@@ -1741,7 +1782,7 @@ cli
|
|
|
1741
1782
|
cli
|
|
1742
1783
|
.command('check <packages...>', 'Check specific packages for updates')
|
|
1743
1784
|
.option('--verbose, -v', 'Enable verbose logging')
|
|
1744
|
-
.option('--strategy <type>', 'Update strategy: major|minor|patch|all
|
|
1785
|
+
.option('--strategy <type>', 'Update strategy: major|minor|patch|all (default: packages.strategy from config, else all)')
|
|
1745
1786
|
.example('buddy check react typescript')
|
|
1746
1787
|
.example('buddy check react --verbose')
|
|
1747
1788
|
.action(async (...args: any[]) => {
|
|
@@ -1791,7 +1832,7 @@ cli
|
|
|
1791
1832
|
cli
|
|
1792
1833
|
.command('schedule', 'Run automated dependency updates on schedule')
|
|
1793
1834
|
.option('--verbose, -v', 'Enable verbose logging')
|
|
1794
|
-
.option('--strategy <type>', 'Update strategy: major|minor|patch|all
|
|
1835
|
+
.option('--strategy <type>', 'Update strategy: major|minor|patch|all (default: packages.strategy from config, else all)')
|
|
1795
1836
|
.example('buddy schedule')
|
|
1796
1837
|
.example('buddy schedule --verbose')
|
|
1797
1838
|
.example('buddy schedule --strategy patch')
|
|
@@ -1877,6 +1918,13 @@ cli
|
|
|
1877
1918
|
const logger = options.verbose ? Logger.verbose() : Logger.quiet()
|
|
1878
1919
|
const config = await resolveConfig(options.config)
|
|
1879
1920
|
|
|
1921
|
+
// Explicit `false` only, the same reading the dashboard uses: a
|
|
1922
|
+
// repository that never wrote a `workflows` block keeps the command.
|
|
1923
|
+
if (config.workflows?.enabled === false) {
|
|
1924
|
+
logger.info('\u2139\ufe0f Workflow generation is disabled by config (workflows.enabled: false)')
|
|
1925
|
+
return
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1880
1928
|
console.log('⚠️ The "generate-workflows" command is deprecated.')
|
|
1881
1929
|
console.log('💡 Use "buddy setup" for a better interactive experience.\n')
|
|
1882
1930
|
|
|
@@ -2633,10 +2681,19 @@ cli
|
|
|
2633
2681
|
|
|
2634
2682
|
cli
|
|
2635
2683
|
.command('open-settings', 'Open GitHub repository and organization settings pages')
|
|
2684
|
+
.option('--type <scope>', 'Which settings to open: repo, org or both', { default: 'both' })
|
|
2636
2685
|
.option('--verbose, -v', 'Enable verbose logging')
|
|
2637
2686
|
.example('buddy open-settings')
|
|
2638
2687
|
.action(async (options: CLIOptions) => {
|
|
2639
2688
|
const logger = options.verbose ? Logger.verbose() : Logger.quiet()
|
|
2689
|
+
|
|
2690
|
+
// Validated before any work or output, so a typo fails immediately
|
|
2691
|
+
// rather than after the repository lookup has already printed.
|
|
2692
|
+
const scope = String(options?.type ?? 'both').toLowerCase()
|
|
2693
|
+
if (!['repo', 'org', 'both'].includes(scope)) {
|
|
2694
|
+
logger.error(`Unknown --type ${scope}. Expected repo, org or both.`)
|
|
2695
|
+
process.exit(1)
|
|
2696
|
+
}
|
|
2640
2697
|
const config = await resolveConfig(options.config)
|
|
2641
2698
|
|
|
2642
2699
|
try {
|
|
@@ -2708,13 +2765,16 @@ cli
|
|
|
2708
2765
|
}
|
|
2709
2766
|
}
|
|
2710
2767
|
|
|
2711
|
-
|
|
2712
|
-
|
|
2768
|
+
if (scope !== 'org')
|
|
2769
|
+
await openUrl(repoUrl, 'repository settings')
|
|
2713
2770
|
|
|
2714
|
-
//
|
|
2771
|
+
// Organisation settings 404 on a personal account, so they are opened
|
|
2772
|
+
// only when asked for, or as the tail of the default `both`.
|
|
2715
2773
|
setTimeout(async () => {
|
|
2716
|
-
|
|
2717
|
-
|
|
2774
|
+
if (scope !== 'repo') {
|
|
2775
|
+
logger.info('\n🏢 Attempting to open organization settings...')
|
|
2776
|
+
await openUrl(orgUrl, 'organization settings')
|
|
2777
|
+
}
|
|
2718
2778
|
|
|
2719
2779
|
logger.info('\n📋 Required Settings:')
|
|
2720
2780
|
logger.info(' 1. Under "Workflow permissions":')
|
|
@@ -2771,13 +2831,16 @@ cli
|
|
|
2771
2831
|
cli
|
|
2772
2832
|
.command('touch <pr-number>', 'Run a finishing touch ticked on a pull request, as a stacked PR')
|
|
2773
2833
|
.option('--name <touch>', 'Run a specific touch rather than reading the checkboxes')
|
|
2834
|
+
.option('--offer', 'Post the checkboxes on the pull request rather than running one')
|
|
2774
2835
|
.option('--test-command <command>', 'Command that verifies the change')
|
|
2775
2836
|
.option('--dry-run', 'Report what would run without acting')
|
|
2776
2837
|
.option('--verbose, -v', 'Enable verbose logging')
|
|
2777
2838
|
.example('buddy touch 42')
|
|
2839
|
+
.example('buddy touch 42 --offer')
|
|
2778
2840
|
.example('buddy touch 42 --name unit-tests')
|
|
2779
2841
|
.action(async (prNumber: string, options: CLIOptions & {
|
|
2780
2842
|
name?: string
|
|
2843
|
+
offer?: boolean
|
|
2781
2844
|
testCommand?: string
|
|
2782
2845
|
dryRun?: boolean
|
|
2783
2846
|
}) => {
|
|
@@ -2795,7 +2858,30 @@ cli
|
|
|
2795
2858
|
process.exit(1)
|
|
2796
2859
|
}
|
|
2797
2860
|
|
|
2798
|
-
const { FINISHING_TOUCHES, getFinishingTouch, parseTouchSelections }
|
|
2861
|
+
const { FINISHING_TOUCHES, getFinishingTouch, hasTouchOffer, parseTouchSelections, withTouchOffer }
|
|
2862
|
+
= await import('../src/agent/tasks')
|
|
2863
|
+
|
|
2864
|
+
// Posting the offer is what makes the checkboxes exist. `renderTouchOffer`
|
|
2865
|
+
// had no production caller, so `buddy touch` read ticks from a body that
|
|
2866
|
+
// nothing ever wrote them into — the documented "tick a box" flow could
|
|
2867
|
+
// not start.
|
|
2868
|
+
if (options.offer) {
|
|
2869
|
+
if (hasTouchOffer(pullRequest.body)) {
|
|
2870
|
+
logger.info(`ℹ️ PR #${pullRequest.number} already carries the finishing-touch offer`)
|
|
2871
|
+
return
|
|
2872
|
+
}
|
|
2873
|
+
|
|
2874
|
+
const body = withTouchOffer(pullRequest.body)
|
|
2875
|
+
|
|
2876
|
+
if (options.dryRun) {
|
|
2877
|
+
logger.info(`🔍 [DRY RUN] Would offer finishing touches on PR #${pullRequest.number}`)
|
|
2878
|
+
return
|
|
2879
|
+
}
|
|
2880
|
+
|
|
2881
|
+
await provider.updatePullRequest(pullRequest.number, { body })
|
|
2882
|
+
logger.success(`✅ Offered finishing touches on PR #${pullRequest.number}`)
|
|
2883
|
+
return
|
|
2884
|
+
}
|
|
2799
2885
|
|
|
2800
2886
|
// The checkboxes are the request. A touch named on the command line is
|
|
2801
2887
|
// the manual path, for a maintainer who did not want to tick a box.
|
|
@@ -2935,17 +3021,36 @@ cli
|
|
|
2935
3021
|
await provider.updateIssue(issueNumber, { body: clearQuickSelection(issue.body) })
|
|
2936
3022
|
|
|
2937
3023
|
for (const action of selection.actions) {
|
|
2938
|
-
|
|
2939
|
-
|
|
3024
|
+
// The issue title and body belong to whoever opened it, which on a
|
|
3025
|
+
// public repository is anyone. They used to be concatenated into the
|
|
3026
|
+
// task string — the half of the context the model is told to trust —
|
|
3027
|
+
// and for a ticked "build" that task drives an agent holding write,
|
|
3028
|
+
// shell and git tools. Both paths now read the issue through a tool,
|
|
3029
|
+
// so the runner frames it as third-party data.
|
|
3030
|
+
if (action === 'plan') {
|
|
3031
|
+
const { runPlan } = await import('../src/agent')
|
|
3032
|
+
const plan = await runPlan({ config, provider, number: issueNumber, isPullRequest: false, logger })
|
|
3033
|
+
|
|
3034
|
+
await provider.createComment(issueNumber, plan)
|
|
3035
|
+
logger.success('✅ Ran plan')
|
|
3036
|
+
continue
|
|
3037
|
+
}
|
|
3038
|
+
|
|
3039
|
+
const { BUILTIN_TOOLS, createReadIssueTool, getFinishingTouch, runAgent } = await import('../src/agent')
|
|
3040
|
+
const touch = getFinishingTouch('autofix')
|
|
2940
3041
|
|
|
2941
3042
|
const result = await runAgent(ai, {
|
|
2942
3043
|
mode: touch.mode,
|
|
2943
|
-
task: `${touch.buildTask({
|
|
3044
|
+
task: `${touch.buildTask({ files: [] })}\n\nCall \`read_issue\` to see what was asked for.`,
|
|
3045
|
+
tools: [...BUILTIN_TOOLS, createReadIssueTool(provider, issueNumber, false)],
|
|
2944
3046
|
context: { workspace: process.cwd(), baseBranch: config.repository?.baseBranch ?? 'main' },
|
|
2945
3047
|
logger,
|
|
2946
3048
|
})
|
|
2947
3049
|
|
|
2948
|
-
await provider.createComment(
|
|
3050
|
+
await provider.createComment(
|
|
3051
|
+
issueNumber,
|
|
3052
|
+
result.output || `I could not finish that (${result.stopReason}).`,
|
|
3053
|
+
)
|
|
2949
3054
|
logger.success(`✅ Ran ${action}`)
|
|
2950
3055
|
}
|
|
2951
3056
|
|
|
@@ -2996,7 +3101,7 @@ cli
|
|
|
2996
3101
|
}
|
|
2997
3102
|
|
|
2998
3103
|
const provider = await providerFor(config, 'running gates', logger)
|
|
2999
|
-
const { findLinkedIssues, runAiGates, runGates, summarizeGates } = await import('../src/gates')
|
|
3104
|
+
const { findLinkedIssues, runAiGates, runGates, gateIcon, summarizeGates } = await import('../src/gates')
|
|
3000
3105
|
const { parseManifest } = await import('../src/pr/pr-manifest')
|
|
3001
3106
|
|
|
3002
3107
|
const prs = await provider.getPullRequests('open')
|
|
@@ -3072,9 +3177,15 @@ cli
|
|
|
3072
3177
|
const summary = summarizeGates(results)
|
|
3073
3178
|
|
|
3074
3179
|
for (const result of results)
|
|
3075
|
-
logger.info(`${result
|
|
3180
|
+
logger.info(`${gateIcon(result)} ${result.name}: ${result.summary}`)
|
|
3076
3181
|
|
|
3077
3182
|
const blocking = summary.conclusion === 'failure'
|
|
3183
|
+
if (blocking) {
|
|
3184
|
+
await emitEvent(config.notifications as Parameters<typeof emitEvent>[0], 'gate.failed', {
|
|
3185
|
+
number,
|
|
3186
|
+
checks: results.filter(result => !result.passed).map(result => result.name),
|
|
3187
|
+
})
|
|
3188
|
+
}
|
|
3078
3189
|
|
|
3079
3190
|
if (options.dryRun || !supports(provider, 'checkRuns', 'createCheckRun')) {
|
|
3080
3191
|
logger.info(summary.summary)
|
|
@@ -3125,6 +3236,13 @@ cli
|
|
|
3125
3236
|
const outcome = await runPostMerge(provider, pr, config.gates?.postMerge ?? {}, {
|
|
3126
3237
|
baseBranch: config.repository?.baseBranch ?? pr.base,
|
|
3127
3238
|
logger,
|
|
3239
|
+
// Supplied here because refreshing means a full scan, which is
|
|
3240
|
+
// `Buddy`'s job rather than the gate module's.
|
|
3241
|
+
refreshDashboard: async () => {
|
|
3242
|
+
if (config.dashboard?.enabled === false)
|
|
3243
|
+
throw new Error('dashboard.enabled is false')
|
|
3244
|
+
await new Buddy(config).createOrUpdateDashboard()
|
|
3245
|
+
},
|
|
3128
3246
|
})
|
|
3129
3247
|
|
|
3130
3248
|
for (const action of outcome.performed)
|
|
@@ -3144,6 +3262,7 @@ cli
|
|
|
3144
3262
|
.option('--format <name>', 'Output format: markdown|json', { default: 'markdown' })
|
|
3145
3263
|
.option('--prompt <focus>', 'Focus for the AI narrative, when a provider is configured')
|
|
3146
3264
|
.option('--publish', 'Publish to the repository\'s report issue')
|
|
3265
|
+
.option('--scheduled', 'This is the workflow\'s scheduled run; honour reports.enabled')
|
|
3147
3266
|
.option('--verbose, -v', 'Enable verbose logging')
|
|
3148
3267
|
.example('buddy report --period 7d')
|
|
3149
3268
|
.example('buddy report --prompt "focus on security posture" --publish')
|
|
@@ -3152,6 +3271,7 @@ cli
|
|
|
3152
3271
|
format?: string
|
|
3153
3272
|
prompt?: string
|
|
3154
3273
|
publish?: boolean
|
|
3274
|
+
scheduled?: boolean
|
|
3155
3275
|
}) => {
|
|
3156
3276
|
const quiet = options.format === 'json'
|
|
3157
3277
|
const logger = options.verbose ? Logger.verbose() : quiet ? Logger.silent() : Logger.quiet()
|
|
@@ -3171,7 +3291,9 @@ cli
|
|
|
3171
3291
|
withNarrative,
|
|
3172
3292
|
} = await import('../src/reports')
|
|
3173
3293
|
|
|
3174
|
-
|
|
3294
|
+
// The flag wins, then config, then the default. `reports.period` was
|
|
3295
|
+
// documented, defaulted and never consulted — only the flag was.
|
|
3296
|
+
const period = (options.period ?? config.reports?.period ?? '30d') as '7d' | '30d' | '90d'
|
|
3175
3297
|
if (!REPORT_PERIODS.includes(period)) {
|
|
3176
3298
|
logger.error(`❌ Unknown period '${period}'. Expected one of ${REPORT_PERIODS.join(', ')}.`)
|
|
3177
3299
|
process.exit(1)
|
|
@@ -3239,6 +3361,16 @@ cli
|
|
|
3239
3361
|
logger,
|
|
3240
3362
|
)
|
|
3241
3363
|
|
|
3364
|
+
// The generated workflow passes --scheduled, so this is where the
|
|
3365
|
+
// documented "default: false" is actually enforced. It cannot be
|
|
3366
|
+
// enforced in the workflow: a cron trigger cannot read the config.
|
|
3367
|
+
const { shouldPublishReport } = await import('../src/reports')
|
|
3368
|
+
const gate = shouldPublishReport({ scheduled: Boolean(options.scheduled), enabled: config.reports?.enabled })
|
|
3369
|
+
if (options.publish && !gate.publish) {
|
|
3370
|
+
logger.info(`ℹ️ Not publishing: ${gate.reason}`)
|
|
3371
|
+
return
|
|
3372
|
+
}
|
|
3373
|
+
|
|
3242
3374
|
if (!options.publish) {
|
|
3243
3375
|
process.stdout.write(`${report}\n`)
|
|
3244
3376
|
return
|
|
@@ -3393,9 +3525,24 @@ cli.command('version', 'Show the version of Buddy').action(() => {
|
|
|
3393
3525
|
console.log(version)
|
|
3394
3526
|
})
|
|
3395
3527
|
|
|
3528
|
+
// `--help` is a flag, but `buddy help` is what a newcomer types. Registering
|
|
3529
|
+
// it means the guess works rather than printing 'Command "help" not found'.
|
|
3530
|
+
cli.command('help', 'Show this help text').action(() => {
|
|
3531
|
+
// Without this, outputHelp() renders the matched command — `buddy help`
|
|
3532
|
+
// itself — rather than the list of commands the reader is asking for.
|
|
3533
|
+
cli.unsetMatchedCommand()
|
|
3534
|
+
cli.outputHelp()
|
|
3535
|
+
})
|
|
3536
|
+
|
|
3396
3537
|
// Available on every command: each action reads `options.config` and passes it
|
|
3397
3538
|
// to resolveConfig, which bypasses discovery when a path is given.
|
|
3398
3539
|
cli.option('--config <path>', 'Path to a buddy config file')
|
|
3399
3540
|
cli.version(version)
|
|
3400
3541
|
cli.help()
|
|
3401
|
-
|
|
3542
|
+
|
|
3543
|
+
// Exported for the in-process wiring tests: importing this module must not
|
|
3544
|
+
// parse argv or run a command — only direct execution does.
|
|
3545
|
+
export { cli }
|
|
3546
|
+
|
|
3547
|
+
if (import.meta.main)
|
|
3548
|
+
cli.parse()
|