Skip to content

Commit 6b8704b

Browse files
committed
add install-rules command
1 parent 62a08b4 commit 6b8704b

File tree

16 files changed

+976
-20
lines changed

16 files changed

+976
-20
lines changed

packages/cli-v3/src/cli/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { COMMAND_NAME } from "../consts.js";
1616
import { VERSION } from "../version.js";
1717
import { installExitHandler } from "./common.js";
1818
import { configureInstallMcpCommand } from "../commands/install-mcp.js";
19+
import { configureInstallRulesCommand } from "../commands/install-rules.js";
1920

2021
export const program = new Command();
2122

@@ -38,5 +39,6 @@ configurePreviewCommand(program);
3839
configureAnalyzeCommand(program);
3940
configureMcpCommand(program);
4041
configureInstallMcpCommand(program);
42+
configureInstallRulesCommand(program);
4143

4244
installExitHandler();

packages/cli-v3/src/commands/dev.ts

Lines changed: 62 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { confirm, isCancel, log } from "@clack/prompts";
2121
import { installMcpServer } from "./install-mcp.js";
2222
import { tryCatch } from "@trigger.dev/core/utils";
2323
import { VERSION } from "@trigger.dev/core";
24+
import { initiateRulesInstallWizard } from "./install-rules.js";
2425

2526
const DevCommandOptions = CommonCommandOptions.extend({
2627
debugOtel: z.boolean().default(false),
@@ -34,6 +35,10 @@ const DevCommandOptions = CommonCommandOptions.extend({
3435
mcpPort: z.coerce.number().optional().default(3333),
3536
analyze: z.boolean().default(false),
3637
disableWarnings: z.boolean().default(false),
38+
skipMCPInstall: z.boolean().default(false),
39+
skipRulesInstall: z.boolean().default(false),
40+
rulesInstallManifestPath: z.string().optional(),
41+
rulesInstallBranch: z.string().optional(),
3742
});
3843

3944
export type DevCommandOptions = z.infer<typeof DevCommandOptions>;
@@ -67,6 +72,30 @@ export function configureDevCommand(program: Command) {
6772
.addOption(
6873
new CommandOption("--analyze", "Analyze the build output and import timings").hideHelp()
6974
)
75+
.addOption(
76+
new CommandOption(
77+
"--skip-mcp-install",
78+
"Skip the Trigger.dev MCP server install wizard"
79+
).hideHelp()
80+
)
81+
.addOption(
82+
new CommandOption(
83+
"--skip-rules-install",
84+
"Skip the Trigger.dev Agent rules install wizard"
85+
).hideHelp()
86+
)
87+
.addOption(
88+
new CommandOption(
89+
"--rules-install-manifest-path <path>",
90+
"The path to the rules install manifest"
91+
).hideHelp()
92+
)
93+
.addOption(
94+
new CommandOption(
95+
"--rules-install-branch <branch>",
96+
"The branch to install the rules from"
97+
).hideHelp()
98+
)
7099
.addOption(new CommandOption("--disable-warnings", "Suppress warnings output").hideHelp())
71100
).action(async (options) => {
72101
wrapCommandAction("dev", DevCommandOptions, options, async (opts) => {
@@ -78,35 +107,49 @@ export function configureDevCommand(program: Command) {
78107
export async function devCommand(options: DevCommandOptions) {
79108
runtimeChecks();
80109

81-
const hasSeenMCPInstallPrompt = readConfigHasSeenMCPInstallPrompt();
110+
const skipMCPInstall = typeof options.skipMCPInstall === "boolean" && options.skipMCPInstall;
82111

83-
if (!hasSeenMCPInstallPrompt) {
84-
const installChoice = await confirm({
85-
message: "Would you like to install the Trigger.dev MCP server?",
86-
initialValue: true,
87-
});
112+
if (!skipMCPInstall) {
113+
const hasSeenMCPInstallPrompt = readConfigHasSeenMCPInstallPrompt();
88114

89-
writeConfigHasSeenMCPInstallPrompt(true);
115+
if (!hasSeenMCPInstallPrompt) {
116+
const installChoice = await confirm({
117+
message: "Would you like to install the Trigger.dev MCP server?",
118+
initialValue: true,
119+
});
90120

91-
const skipInstall = isCancel(installChoice) || !installChoice;
121+
writeConfigHasSeenMCPInstallPrompt(true);
92122

93-
if (!skipInstall) {
94-
log.step("Welcome to the Trigger.dev MCP server install wizard 🧙");
123+
const skipInstall = isCancel(installChoice) || !installChoice;
95124

96-
const [installError] = await tryCatch(
97-
installMcpServer({
98-
yolo: false,
99-
tag: VERSION as string,
100-
logLevel: options.logLevel,
101-
})
102-
);
125+
if (!skipInstall) {
126+
log.step("Welcome to the Trigger.dev MCP server install wizard 🧙");
103127

104-
if (installError) {
105-
log.error(`Failed to install MCP server: ${installError.message}`);
128+
const [installError] = await tryCatch(
129+
installMcpServer({
130+
yolo: false,
131+
tag: VERSION as string,
132+
logLevel: options.logLevel,
133+
})
134+
);
135+
136+
if (installError) {
137+
log.error(`Failed to install MCP server: ${installError.message}`);
138+
}
106139
}
107140
}
108141
}
109142

143+
const skipRulesInstall =
144+
typeof options.skipRulesInstall === "boolean" && options.skipRulesInstall;
145+
146+
if (!skipRulesInstall) {
147+
await initiateRulesInstallWizard({
148+
manifestPath: options.rulesInstallManifestPath,
149+
branch: options.rulesInstallBranch,
150+
});
151+
}
152+
110153
const authorization = await login({
111154
embedded: true,
112155
silent: true,

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const clients = [
3131
"openai-codex",
3232
"opencode",
3333
"amp",
34+
"ruler",
3435
] as const;
3536
const scopes = ["user", "project", "local"] as const;
3637

@@ -86,6 +87,9 @@ const clientScopes: ClientScopes = {
8687
user: "~/.config/opencode/opencode.json",
8788
project: "./opencode.json",
8889
},
90+
ruler: {
91+
project: "./.ruler/mcp.json",
92+
},
8993
};
9094

9195
const clientLabels: ClientLabels = {
@@ -100,6 +104,7 @@ const clientLabels: ClientLabels = {
100104
"openai-codex": "OpenAI Codex CLI",
101105
amp: "Sourcegraph AMP",
102106
opencode: "opencode",
107+
ruler: "Ruler",
103108
};
104109

105110
type SupportedClients = (typeof clients)[number];
@@ -455,6 +460,9 @@ function resolveMcpServerConfigJsonPath(
455460
case "opencode": {
456461
return ["mcp", "trigger"];
457462
}
463+
case "ruler": {
464+
return ["mcpServers", "trigger"];
465+
}
458466
}
459467
}
460468

@@ -550,6 +558,13 @@ function resolveMcpServerConfig(
550558
enabled: true,
551559
};
552560
}
561+
case "ruler": {
562+
return {
563+
type: "stdio",
564+
command: "npx",
565+
args,
566+
};
567+
}
553568
}
554569
}
555570

0 commit comments

Comments
 (0)