@@ -25,6 +25,7 @@ import {
25
25
import { pathExists , readFile , safeWriteFile } from "../utilities/fileSystem.js" ;
26
26
import { printStandloneInitialBanner } from "../utilities/initialBanner.js" ;
27
27
import { logger } from "../utilities/logger.js" ;
28
+ import { tryCatch } from "@trigger.dev/core/utils" ;
28
29
29
30
const targets = [
30
31
"claude-code" ,
@@ -228,9 +229,11 @@ export async function initiateRulesInstallWizard(options: InstallRulesWizardOpti
228
229
}
229
230
230
231
async function installRules ( manifest : RulesManifest , opts : InstallRulesWizardOptions ) {
231
- const config = await loadConfig ( {
232
- cwd : process . cwd ( ) ,
233
- } ) ;
232
+ const [ _ , config ] = await tryCatch (
233
+ loadConfig ( {
234
+ cwd : process . cwd ( ) ,
235
+ } )
236
+ ) ;
234
237
235
238
const currentVersion = await manifest . getCurrentVersion ( ) ;
236
239
@@ -244,7 +247,12 @@ async function installRules(manifest: RulesManifest, opts: InstallRulesWizardOpt
244
247
const results = [ ] ;
245
248
246
249
for ( const targetName of targetNames ) {
247
- const result = await installRulesForTarget ( targetName , currentVersion , config , opts ) ;
250
+ const result = await installRulesForTarget (
251
+ targetName ,
252
+ currentVersion ,
253
+ opts ,
254
+ config ?? undefined
255
+ ) ;
248
256
249
257
if ( result ) {
250
258
results . push ( result ) ;
@@ -294,8 +302,8 @@ function handleUnsupportedTargetOnly(options: InstallRulesCommandOptions): Insta
294
302
async function installRulesForTarget (
295
303
targetName : ResolvedTargets ,
296
304
currentVersion : ManifestVersion ,
297
- config : ResolvedConfig ,
298
- options : InstallRulesCommandOptions
305
+ options : InstallRulesCommandOptions ,
306
+ config ?: ResolvedConfig
299
307
) {
300
308
if ( targetName === "unsupported" ) {
301
309
// This should not happen as unsupported targets are handled separately
@@ -306,16 +314,16 @@ async function installRulesForTarget(
306
314
return ;
307
315
}
308
316
309
- const result = await performInstallForTarget ( targetName , currentVersion , config , options ) ;
317
+ const result = await performInstallForTarget ( targetName , currentVersion , options , config ) ;
310
318
311
319
return result ;
312
320
}
313
321
314
322
async function performInstallForTarget (
315
323
targetName : ( typeof targets ) [ number ] ,
316
324
currentVersion : ManifestVersion ,
317
- config : ResolvedConfig ,
318
- cmdOptions : InstallRulesCommandOptions
325
+ cmdOptions : InstallRulesCommandOptions ,
326
+ config ?: ResolvedConfig
319
327
) {
320
328
const options = await resolveOptionsForTarget ( targetName , currentVersion , cmdOptions ) ;
321
329
@@ -330,7 +338,7 @@ async function performInstallForTarget(
330
338
async function performInstallOptionsForTarget (
331
339
targetName : ( typeof targets ) [ number ] ,
332
340
options : Array < RulesManifestVersionOption > ,
333
- config : ResolvedConfig
341
+ config ? : ResolvedConfig
334
342
) {
335
343
const results = [ ] ;
336
344
@@ -345,7 +353,7 @@ async function performInstallOptionsForTarget(
345
353
async function performInstallOptionForTarget (
346
354
targetName : ( typeof targets ) [ number ] ,
347
355
option : RulesManifestVersionOption ,
348
- config : ResolvedConfig
356
+ config ? : ResolvedConfig
349
357
) {
350
358
switch ( option . installStrategy ) {
351
359
case "default" : {
@@ -363,7 +371,7 @@ async function performInstallOptionForTarget(
363
371
async function performInstallDefaultOptionForTarget (
364
372
targetName : ( typeof targets ) [ number ] ,
365
373
option : RulesManifestVersionOption ,
366
- config : ResolvedConfig
374
+ config ? : ResolvedConfig
367
375
) {
368
376
// Get the path to the rules file
369
377
const rulesFilePath = resolveRulesFilePathForTargetOption ( targetName , option ) ;
@@ -490,7 +498,7 @@ async function resolveRulesFileMergeStrategyForTarget(targetName: (typeof target
490
498
async function resolveRulesFileContentsForTarget (
491
499
targetName : ( typeof targets ) [ number ] ,
492
500
option : RulesManifestVersionOption ,
493
- config : ResolvedConfig
501
+ config ? : ResolvedConfig
494
502
) {
495
503
switch ( targetName ) {
496
504
case "cursor" : {
0 commit comments