Elffuss BraidHub

kikocis/continue public

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>
Changeset5e2a247f97eb88e4db243f825f638769d3531a42800231f55860718a7de1868f
AuthorNate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-09-22 16:36 -07:00
CommitterGitHub <noreply@github.com> · 2025-09-22 16:36 -07:00
Parentsf447b1445b80

Browse the files at this changeset

2 files changed

modified core/config/profile/doLoadConfig.ts +16 −0
@@ -18,6 +18,7 @@
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 @@
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 );
modified core/config/yaml/loadYaml.ts +0 −14
@@ -25,7 +25,6 @@
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 @@
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) => ({