Skip to content

Commit 37a4fb7

Browse files
Move rule-to-slash-command conversion from YAML loading to config loading (#7871)
* Move rule-to-slash-command conversion from YAML loading to config loading * Update core/config/profile/doLoadConfig.ts Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --------- Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
1 parent 13caf2a commit 37a4fb7

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

core/config/profile/doLoadConfig.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
Tool,
1919
} from "../../";
2020
import { stringifyMcpPrompt } from "../../commands/slash/mcpSlashCommand";
21+
import { convertRuleBlockToSlashCommand } from "../../commands/slash/ruleBlockSlashCommand";
2122
import { MCPManagerSingleton } from "../../context/mcp/MCPManagerSingleton";
2223
import ContinueProxyContextProvider from "../../context/providers/ContinueProxyContextProvider";
2324
import MCPContextProvider from "../../context/providers/MCPContextProvider";
@@ -155,6 +156,21 @@ export default async function doLoadConfig(options: {
155156
errors.push(...rulesErrors);
156157
newConfig.rules.unshift(...rules);
157158

159+
// Convert invokable rules to slash commands
160+
for (const rule of newConfig.rules) {
161+
if (rule.invokable) {
162+
try {
163+
const slashCommand = convertRuleBlockToSlashCommand(rule);
164+
(newConfig.slashCommands ??= []).push(slashCommand);
165+
} catch (e) {
166+
errors.push({
167+
message: `Error converting invokable rule ${rule.name} to slash command: ${e instanceof Error ? e.message : e}`,
168+
fatal: false,
169+
});
170+
}
171+
}
172+
}
173+
158174
const proxyContextProvider = newConfig.contextProviders?.find(
159175
(cp) => cp.description.title === "continue-proxy",
160176
);

core/config/yaml/loadYaml.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { modifyAnyConfigWithSharedConfig } from "../sharedConfig";
2525

2626
import { convertPromptBlockToSlashCommand } from "../../commands/slash/promptBlockSlashCommand";
2727
import { slashCommandFromPromptFile } from "../../commands/slash/promptFileSlashCommand";
28-
import { convertRuleBlockToSlashCommand } from "../../commands/slash/ruleBlockSlashCommand";
2928
import { getControlPlaneEnvSync } from "../../control-plane/env";
3029
import { PolicySingleton } from "../../control-plane/PolicySingleton";
3130
import { getBaseToolDefinitions } from "../../tools";
@@ -209,19 +208,6 @@ export async function configYamlToContinueConfig(options: {
209208
for (const rule of config.rules ?? []) {
210209
const convertedRule = convertYamlRuleToContinueRule(rule);
211210
continueConfig.rules.push(convertedRule);
212-
213-
// Convert invokable rules to slash commands
214-
if (convertedRule.invokable) {
215-
try {
216-
const slashCommand = convertRuleBlockToSlashCommand(convertedRule);
217-
continueConfig.slashCommands?.push(slashCommand);
218-
} catch (e) {
219-
localErrors.push({
220-
message: `Error converting invokable rule ${convertedRule.name} to slash command: ${e instanceof Error ? e.message : e}`,
221-
fatal: false,
222-
});
223-
}
224-
}
225211
}
226212

227213
continueConfig.data = config.data?.map((d) => ({

0 commit comments

Comments
 (0)