Skip to content

Commit 08cd20a

Browse files
committed
clients -> targets in the install-rules command
1 parent 8f34277 commit 08cd20a

File tree

1 file changed

+71
-71
lines changed

1 file changed

+71
-71
lines changed

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

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { pathExists, readFile, safeWriteFile } from "../utilities/fileSystem.js"
2626
import { printStandloneInitialBanner } from "../utilities/initialBanner.js";
2727
import { logger } from "../utilities/logger.js";
2828

29-
const clients = [
29+
const targets = [
3030
"claude-code",
3131
"cursor",
3232
"vscode",
@@ -39,11 +39,11 @@ const clients = [
3939
"ruler",
4040
] as const;
4141

42-
type ClientLabels = {
43-
[key in (typeof clients)[number]]: string;
42+
type TargetLabels = {
43+
[key in (typeof targets)[number]]: string;
4444
};
4545

46-
const clientLabels: ClientLabels = {
46+
const targetLabels: TargetLabels = {
4747
"claude-code": "Claude Code",
4848
cursor: "Cursor",
4949
vscode: "VSCode",
@@ -56,11 +56,11 @@ const clientLabels: ClientLabels = {
5656
ruler: "Ruler",
5757
};
5858

59-
type SupportedClients = (typeof clients)[number];
60-
type ResolvedClients = SupportedClients | "unsupported";
59+
type SupportedTargets = (typeof targets)[number];
60+
type ResolvedTargets = SupportedTargets | "unsupported";
6161

6262
const InstallRulesCommandOptions = z.object({
63-
client: z.enum(clients).array().optional(),
63+
target: z.enum(targets).array().optional(),
6464
manifestPath: z.string().optional(),
6565
branch: z.string().optional(),
6666
logLevel: z.enum(["debug", "info", "log", "warn", "error", "none"]).optional(),
@@ -74,9 +74,9 @@ export function configureInstallRulesCommand(program: Command) {
7474
.command("install-rules")
7575
.description("Install the Trigger.dev Agent rules files")
7676
.option(
77-
"--client <clients...>",
78-
"Choose the client (or clients) to install the MCP server into. We currently support: " +
79-
clients.join(", ")
77+
"--target <targets...>",
78+
"Choose the target (or targets) to install the Trigger.dev rules into. We currently support: " +
79+
targets.join(", ")
8080
)
8181
.option(
8282
"-l, --log-level <level>",
@@ -128,7 +128,7 @@ async function _installRulesCommand(options: InstallRulesCommandOptions) {
128128
return;
129129
}
130130

131-
intro("Welcome to the Trigger.dev Agent rules install wizard 🧙");
131+
intro("Welcome to the Trigger.dev Agent rules install wizard ");
132132

133133
const manifestLoader = options.manifestPath
134134
? new LocalRulesManifestLoader(options.manifestPath)
@@ -141,18 +141,18 @@ async function _installRulesCommand(options: InstallRulesCommandOptions) {
141141

142142
await installRules(manifest, options);
143143

144-
outro("You're all set! 🎉");
144+
outro("You're all set! ");
145145
}
146146

147147
type InstallRulesResults = Array<InstallRulesResult>;
148148

149149
type InstallRulesResult = {
150150
configPath: string;
151-
clientName: (typeof clients)[number];
151+
targetName: (typeof targets)[number];
152152
};
153153

154154
export type InstallRulesWizardOptions = {
155-
clients?: Array<(typeof clients)[number]>;
155+
targets?: Array<(typeof targets)[number]>;
156156
manifestPath?: string;
157157
branch?: string;
158158
};
@@ -234,17 +234,17 @@ async function installRules(manifest: RulesManifest, opts: InstallRulesWizardOpt
234234

235235
const currentVersion = await manifest.getCurrentVersion();
236236

237-
const clientNames = await resolveClients(opts);
237+
const targetNames = await resolveTargets(opts);
238238

239-
if (clientNames.length === 1 && clientNames.includes("unsupported")) {
240-
handleUnsupportedClientOnly(opts);
239+
if (targetNames.length === 1 && targetNames.includes("unsupported")) {
240+
handleUnsupportedTargetOnly(opts);
241241
return;
242242
}
243243

244244
const results = [];
245245

246-
for (const clientName of clientNames) {
247-
const result = await installRulesForClient(clientName, currentVersion, config, opts);
246+
for (const targetName of targetNames) {
247+
const result = await installRulesForTarget(targetName, currentVersion, config, opts);
248248

249249
if (result) {
250250
results.push(result);
@@ -283,92 +283,92 @@ async function installRules(manifest: RulesManifest, opts: InstallRulesWizardOpt
283283
}
284284
}
285285

286-
function handleUnsupportedClientOnly(options: InstallRulesCommandOptions): InstallRulesResults {
286+
function handleUnsupportedTargetOnly(options: InstallRulesCommandOptions): InstallRulesResults {
287287
log.info(
288288
`${cliLink("Install the rules manually", "https://trigger.dev/docs/agents/rules/overview")}`
289289
);
290290

291291
return [];
292292
}
293293

294-
async function installRulesForClient(
295-
clientName: ResolvedClients,
294+
async function installRulesForTarget(
295+
targetName: ResolvedTargets,
296296
currentVersion: ManifestVersion,
297297
config: ResolvedConfig,
298298
options: InstallRulesCommandOptions
299299
) {
300-
if (clientName === "unsupported") {
301-
// This should not happen as unsupported clients are handled separately
300+
if (targetName === "unsupported") {
301+
// This should not happen as unsupported targets are handled separately
302302
// but if it does, provide helpful output
303303
log.message(
304-
`${chalk.yellow("⚠")} Skipping unsupported client - see manual configuration above`
304+
`${chalk.yellow("⚠")} Skipping unsupported target - see manual configuration above`
305305
);
306306
return;
307307
}
308308

309-
const result = await performInstallForClient(clientName, currentVersion, config, options);
309+
const result = await performInstallForTarget(targetName, currentVersion, config, options);
310310

311311
return result;
312312
}
313313

314-
async function performInstallForClient(
315-
clientName: (typeof clients)[number],
314+
async function performInstallForTarget(
315+
targetName: (typeof targets)[number],
316316
currentVersion: ManifestVersion,
317317
config: ResolvedConfig,
318318
cmdOptions: InstallRulesCommandOptions
319319
) {
320-
const options = await resolveOptionsForClient(clientName, currentVersion, cmdOptions);
320+
const options = await resolveOptionsForTarget(targetName, currentVersion, cmdOptions);
321321

322-
const installations = await performInstallOptionsForClient(clientName, options, config);
322+
const installations = await performInstallOptionsForTarget(targetName, options, config);
323323

324324
return {
325-
clientName,
325+
targetName,
326326
installations,
327327
};
328328
}
329329

330-
async function performInstallOptionsForClient(
331-
clientName: (typeof clients)[number],
330+
async function performInstallOptionsForTarget(
331+
targetName: (typeof targets)[number],
332332
options: Array<RulesManifestVersionOption>,
333333
config: ResolvedConfig
334334
) {
335335
const results = [];
336336

337337
for (const option of options) {
338-
const result = await performInstallOptionForClient(clientName, option, config);
338+
const result = await performInstallOptionForTarget(targetName, option, config);
339339
results.push(result);
340340
}
341341

342342
return results;
343343
}
344344

345-
async function performInstallOptionForClient(
346-
clientName: (typeof clients)[number],
345+
async function performInstallOptionForTarget(
346+
targetName: (typeof targets)[number],
347347
option: RulesManifestVersionOption,
348348
config: ResolvedConfig
349349
) {
350350
switch (option.installStrategy) {
351351
case "default": {
352-
return performInstallDefaultOptionForClient(clientName, option, config);
352+
return performInstallDefaultOptionForTarget(targetName, option, config);
353353
}
354354
case "claude-code-subagent": {
355-
return performInstallClaudeCodeSubagentOptionForClient(option);
355+
return performInstallClaudeCodeSubagentOptionForTarget(option);
356356
}
357357
default: {
358358
throw new Error(`Unknown install strategy: ${option.installStrategy}`);
359359
}
360360
}
361361
}
362362

363-
async function performInstallDefaultOptionForClient(
364-
clientName: (typeof clients)[number],
363+
async function performInstallDefaultOptionForTarget(
364+
targetName: (typeof targets)[number],
365365
option: RulesManifestVersionOption,
366366
config: ResolvedConfig
367367
) {
368368
// Get the path to the rules file
369-
const rulesFilePath = resolveRulesFilePathForClientOption(clientName, option);
370-
const rulesFileContents = await resolveRulesFileContentsForClient(clientName, option, config);
371-
const mergeStrategy = await resolveRulesFileMergeStrategyForClient(clientName);
369+
const rulesFilePath = resolveRulesFilePathForTargetOption(targetName, option);
370+
const rulesFileContents = await resolveRulesFileContentsForTarget(targetName, option, config);
371+
const mergeStrategy = await resolveRulesFileMergeStrategyForTarget(targetName);
372372

373373
// Try and read the existing rules file
374374
const rulesFileAbsolutePath = join(process.cwd(), rulesFilePath);
@@ -419,7 +419,7 @@ async function writeToFile(
419419
}
420420
}
421421

422-
async function performInstallClaudeCodeSubagentOptionForClient(option: RulesManifestVersionOption) {
422+
async function performInstallClaudeCodeSubagentOptionForTarget(option: RulesManifestVersionOption) {
423423
const rulesFilePath = ".claude/agents/trigger-dev-task-writer.md";
424424
const rulesFileContents = option.contents;
425425

@@ -428,15 +428,15 @@ async function performInstallClaudeCodeSubagentOptionForClient(option: RulesMani
428428
return { option, location: rulesFilePath };
429429
}
430430

431-
function resolveRulesFilePathForClientOption(
432-
clientName: (typeof clients)[number],
431+
function resolveRulesFilePathForTargetOption(
432+
targetName: (typeof targets)[number],
433433
option: RulesManifestVersionOption
434434
): string {
435435
if (option.installStrategy === "claude-code-subagent") {
436436
return ".claude/agents/trigger-dev-task-writer.md";
437437
}
438438

439-
switch (clientName) {
439+
switch (targetName) {
440440
case "claude-code": {
441441
return "CLAUDE.md";
442442
}
@@ -468,13 +468,13 @@ function resolveRulesFilePathForClientOption(
468468
return `.ruler/trigger-${option.name}.md`;
469469
}
470470
default: {
471-
throw new Error(`Unknown client: ${clientName}`);
471+
throw new Error(`Unknown target: ${targetName}`);
472472
}
473473
}
474474
}
475475

476-
async function resolveRulesFileMergeStrategyForClient(clientName: (typeof clients)[number]) {
477-
switch (clientName) {
476+
async function resolveRulesFileMergeStrategyForTarget(targetName: (typeof targets)[number]) {
477+
switch (targetName) {
478478
case "amp":
479479
case "agents.md":
480480
case "gemini-cli":
@@ -487,12 +487,12 @@ async function resolveRulesFileMergeStrategyForClient(clientName: (typeof client
487487
}
488488
}
489489

490-
async function resolveRulesFileContentsForClient(
491-
clientName: (typeof clients)[number],
490+
async function resolveRulesFileContentsForTarget(
491+
targetName: (typeof targets)[number],
492492
option: RulesManifestVersionOption,
493493
config: ResolvedConfig
494494
) {
495-
switch (clientName) {
495+
switch (targetName) {
496496
case "cursor": {
497497
return $output(
498498
frontmatter({
@@ -537,17 +537,17 @@ function $output(...strings: string[]) {
537537
return strings.map((s) => s).join("\n");
538538
}
539539

540-
async function resolveOptionsForClient(
541-
clientName: (typeof clients)[number],
540+
async function resolveOptionsForTarget(
541+
targetName: (typeof targets)[number],
542542
currentVersion: ManifestVersion,
543543
cmdOptions: InstallRulesCommandOptions
544544
) {
545545
const possibleOptions = currentVersion.options.filter(
546-
(option) => !option.client || option.client === clientName
546+
(option) => !option.client || option.client === targetName
547547
);
548548

549549
const selectedOptions = await multiselect({
550-
message: `Choose the rules you want to install for ${clientLabels[clientName]}`,
550+
message: `Choose the rules you want to install for ${targetLabels[targetName]}`,
551551
options: possibleOptions.map((option) => ({
552552
value: option,
553553
label: option.title,
@@ -563,41 +563,41 @@ async function resolveOptionsForClient(
563563
return selectedOptions;
564564
}
565565

566-
async function resolveClients(options: InstallRulesCommandOptions): Promise<ResolvedClients[]> {
567-
if (options.client) {
568-
return options.client;
566+
async function resolveTargets(options: InstallRulesCommandOptions): Promise<ResolvedTargets[]> {
567+
if (options.target) {
568+
return options.target;
569569
}
570570

571571
const selectOptions: Array<{
572572
value: string;
573573
label: string;
574574
hint?: string;
575-
}> = clients.map((client) => ({
576-
value: client,
577-
label: clientLabels[client],
575+
}> = targets.map((target) => ({
576+
value: target,
577+
label: targetLabels[target],
578578
}));
579579

580580
selectOptions.push({
581581
value: "unsupported",
582-
label: "Unsupported client",
583-
hint: "We don't support this client yet, but you can still install the rules manually.",
582+
label: "Unsupported target",
583+
hint: "We don't support this target yet, but you can still install the rules manually.",
584584
});
585585

586586
const $selectOptions = selectOptions as Array<{
587-
value: ResolvedClients;
587+
value: ResolvedTargets;
588588
label: string;
589589
hint?: string;
590590
}>;
591591

592-
const selectedClients = await multiselect({
593-
message: "Select one or more clients to install the rules into",
592+
const selectedTargets = await multiselect({
593+
message: "Select one or more targets to install the rules into",
594594
options: $selectOptions,
595595
required: true,
596596
});
597597

598-
if (isCancel(selectedClients)) {
599-
throw new OutroCommandError("No clients selected");
598+
if (isCancel(selectedTargets)) {
599+
throw new OutroCommandError("No targets selected");
600600
}
601601

602-
return selectedClients;
602+
return selectedTargets;
603603
}

0 commit comments

Comments
 (0)