diff --git a/core/config/profile/doLoadConfig.ts b/core/config/profile/doLoadConfig.ts index 693fde2a297..c213bcb6663 100644 --- a/core/config/profile/doLoadConfig.ts +++ b/core/config/profile/doLoadConfig.ts @@ -18,6 +18,7 @@ import { Tool, } from "../../"; import { stringifyMcpPrompt } from "../../commands/slash/mcpSlashCommand"; +import { convertRuleBlockToSlashCommand } from "../../commands/slash/ruleBlockSlashCommand"; import { MCPManagerSingleton } from "../../context/mcp/MCPManagerSingleton"; import ContinueProxyContextProvider from "../../context/providers/ContinueProxyContextProvider"; import MCPContextProvider from "../../context/providers/MCPContextProvider"; @@ -155,6 +156,21 @@ export default async function doLoadConfig(options: { errors.push(...rulesErrors); newConfig.rules.unshift(...rules); + // Convert invokable rules to slash commands + for (const rule of newConfig.rules) { + if (rule.invokable) { + try { + const slashCommand = convertRuleBlockToSlashCommand(rule); + (newConfig.slashCommands ??= []).push(slashCommand); + } catch (e) { + errors.push({ + message: `Error converting invokable rule ${rule.name} to slash command: ${e instanceof Error ? e.message : e}`, + fatal: false, + }); + } + } + } + const proxyContextProvider = newConfig.contextProviders?.find( (cp) => cp.description.title === "continue-proxy", ); diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 915eb74f78d..1cfdb712035 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -25,7 +25,6 @@ import { modifyAnyConfigWithSharedConfig } from "../sharedConfig"; import { convertPromptBlockToSlashCommand } from "../../commands/slash/promptBlockSlashCommand"; import { slashCommandFromPromptFile } from "../../commands/slash/promptFileSlashCommand"; -import { convertRuleBlockToSlashCommand } from "../../commands/slash/ruleBlockSlashCommand"; import { getControlPlaneEnvSync } from "../../control-plane/env"; import { PolicySingleton } from "../../control-plane/PolicySingleton"; import { getBaseToolDefinitions } from "../../tools"; @@ -209,19 +208,6 @@ export async function configYamlToContinueConfig(options: { for (const rule of config.rules ?? []) { const convertedRule = convertYamlRuleToContinueRule(rule); continueConfig.rules.push(convertedRule); - - // Convert invokable rules to slash commands - if (convertedRule.invokable) { - try { - const slashCommand = convertRuleBlockToSlashCommand(convertedRule); - continueConfig.slashCommands?.push(slashCommand); - } catch (e) { - localErrors.push({ - message: `Error converting invokable rule ${convertedRule.name} to slash command: ${e instanceof Error ? e.message : e}`, - fatal: false, - }); - } - } } continueConfig.data = config.data?.map((d) => ({