Skip to content

Commit 892adfe

Browse files
authored
fix(mcp): don't require a trigger.config.ts file to be present when installing rules (#2453)
1 parent 73e7378 commit 892adfe

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

.changeset/strong-taxis-clap.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
fix(mcp): don't require a trigger.config.ts file to be present when installing rules

packages/cli-v3/src/commands/install-rules.ts

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
import { pathExists, readFile, safeWriteFile } from "../utilities/fileSystem.js";
2626
import { printStandloneInitialBanner } from "../utilities/initialBanner.js";
2727
import { logger } from "../utilities/logger.js";
28+
import { tryCatch } from "@trigger.dev/core/utils";
2829

2930
const targets = [
3031
"claude-code",
@@ -228,9 +229,11 @@ export async function initiateRulesInstallWizard(options: InstallRulesWizardOpti
228229
}
229230

230231
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+
);
234237

235238
const currentVersion = await manifest.getCurrentVersion();
236239

@@ -244,7 +247,12 @@ async function installRules(manifest: RulesManifest, opts: InstallRulesWizardOpt
244247
const results = [];
245248

246249
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+
);
248256

249257
if (result) {
250258
results.push(result);
@@ -294,8 +302,8 @@ function handleUnsupportedTargetOnly(options: InstallRulesCommandOptions): Insta
294302
async function installRulesForTarget(
295303
targetName: ResolvedTargets,
296304
currentVersion: ManifestVersion,
297-
config: ResolvedConfig,
298-
options: InstallRulesCommandOptions
305+
options: InstallRulesCommandOptions,
306+
config?: ResolvedConfig
299307
) {
300308
if (targetName === "unsupported") {
301309
// This should not happen as unsupported targets are handled separately
@@ -306,16 +314,16 @@ async function installRulesForTarget(
306314
return;
307315
}
308316

309-
const result = await performInstallForTarget(targetName, currentVersion, config, options);
317+
const result = await performInstallForTarget(targetName, currentVersion, options, config);
310318

311319
return result;
312320
}
313321

314322
async function performInstallForTarget(
315323
targetName: (typeof targets)[number],
316324
currentVersion: ManifestVersion,
317-
config: ResolvedConfig,
318-
cmdOptions: InstallRulesCommandOptions
325+
cmdOptions: InstallRulesCommandOptions,
326+
config?: ResolvedConfig
319327
) {
320328
const options = await resolveOptionsForTarget(targetName, currentVersion, cmdOptions);
321329

@@ -330,7 +338,7 @@ async function performInstallForTarget(
330338
async function performInstallOptionsForTarget(
331339
targetName: (typeof targets)[number],
332340
options: Array<RulesManifestVersionOption>,
333-
config: ResolvedConfig
341+
config?: ResolvedConfig
334342
) {
335343
const results = [];
336344

@@ -345,7 +353,7 @@ async function performInstallOptionsForTarget(
345353
async function performInstallOptionForTarget(
346354
targetName: (typeof targets)[number],
347355
option: RulesManifestVersionOption,
348-
config: ResolvedConfig
356+
config?: ResolvedConfig
349357
) {
350358
switch (option.installStrategy) {
351359
case "default": {
@@ -363,7 +371,7 @@ async function performInstallOptionForTarget(
363371
async function performInstallDefaultOptionForTarget(
364372
targetName: (typeof targets)[number],
365373
option: RulesManifestVersionOption,
366-
config: ResolvedConfig
374+
config?: ResolvedConfig
367375
) {
368376
// Get the path to the rules file
369377
const rulesFilePath = resolveRulesFilePathForTargetOption(targetName, option);
@@ -490,7 +498,7 @@ async function resolveRulesFileMergeStrategyForTarget(targetName: (typeof target
490498
async function resolveRulesFileContentsForTarget(
491499
targetName: (typeof targets)[number],
492500
option: RulesManifestVersionOption,
493-
config: ResolvedConfig
501+
config?: ResolvedConfig
494502
) {
495503
switch (targetName) {
496504
case "cursor": {

0 commit comments

Comments
 (0)