diff --git a/src/commands/serve.ts b/src/commands/serve.ts index aaa10d52e..623e26786 100644 --- a/src/commands/serve.ts +++ b/src/commands/serve.ts @@ -6,7 +6,7 @@ import { getOrganizationId, loadAuthConfig, } from "../auth/workos.js"; -import { initializeWithOnboarding } from "../onboarding.js"; +import { runNormalFlow } from "../onboarding.js"; import { saveSession } from "../session.js"; import { constructSystemMessage } from "../systemMessage.js"; import telemetryService from "../telemetry/telemetryService.js"; @@ -48,8 +48,8 @@ export async function serve(prompt?: string, options: ServeOptions = {}) { // Initialize authentication const authConfig = loadAuthConfig(); - // Initialize with onboarding - const { config, llmApi, model } = await initializeWithOnboarding( + // Initialize with normal flow (skip onboarding like headless mode) + const { config, llmApi, model } = await runNormalFlow( authConfig, options.config, options.rule @@ -382,4 +382,4 @@ async function streamChatResponseWithInterruption( // currentStreamingMessage.isStreaming = false; } } -} +} \ No newline at end of file diff --git a/src/onboarding.ts b/src/onboarding.ts index 6b5ccd076..53ff8c558 100644 --- a/src/onboarding.ts +++ b/src/onboarding.ts @@ -158,19 +158,28 @@ export async function runOnboardingFlow( } export async function runNormalFlow( - configPath: string | undefined, - authConfig: AuthConfig + authConfig: AuthConfig, + configPath?: string, + rules?: string[] ): Promise { // Step 1: Check if --config flag is provided if (configPath) { - const result = await initialize(authConfig, configPath); + let result = await initialize(authConfig, configPath); + // Inject rules into the config if provided + if (rules && rules.length > 0) { + result.config = await injectRulesIntoConfig(result.config, rules); + } return { ...result, wasOnboarded: false }; } // Step 2: If user is logged in, look for first assistant in selected org if (isAuthenticated()) { try { - const result = await initialize(authConfig, undefined); + let result = await initialize(authConfig, undefined); + // Inject rules into the config if provided + if (rules && rules.length > 0) { + result.config = await injectRulesIntoConfig(result.config, rules); + } return { ...result, wasOnboarded: false }; } catch (error) {} } @@ -178,7 +187,11 @@ export async function runNormalFlow( // Step 3: Look for local ~/.continue/config.yaml if (fs.existsSync(CONFIG_PATH)) { try { - const result = await initialize(authConfig, CONFIG_PATH); + let result = await initialize(authConfig, CONFIG_PATH); + // Inject rules into the config if provided + if (rules && rules.length > 0) { + result.config = await injectRulesIntoConfig(result.config, rules); + } return { ...result, wasOnboarded: false }; } catch (error) { console.log(chalk.yellow("⚠ Invalid config file found")); @@ -190,7 +203,11 @@ export async function runNormalFlow( console.log(chalk.blue("✓ Using ANTHROPIC_API_KEY from environment")); await createOrUpdateConfig(process.env.ANTHROPIC_API_KEY); console.log(chalk.gray(` Config saved to: ${CONFIG_PATH}`)); - const result = await initialize(authConfig, CONFIG_PATH); + let result = await initialize(authConfig, CONFIG_PATH); + // Inject rules into the config if provided + if (rules && rules.length > 0) { + result.config = await injectRulesIntoConfig(result.config, rules); + } return { ...result, wasOnboarded: false }; } @@ -280,13 +297,13 @@ export async function initializeWithOnboarding( await markOnboardingComplete(); } } else { - result = await runNormalFlow(configPath, authConfig); + result = await runNormalFlow(authConfig, configPath, rules); } - // Inject rules into the config if provided - if (rules && rules.length > 0) { + // Inject rules into the config if provided (for onboarding flow which doesn't handle rules directly) + if (rules && rules.length > 0 && !result.wasOnboarded) { result.config = await injectRulesIntoConfig(result.config, rules); } return result; -} +} \ No newline at end of file diff --git a/src/ui/MarkdownRenderer.test.tsx b/src/ui/MarkdownRenderer.test.tsx index 907bd4ef9..d9cd7abc3 100644 --- a/src/ui/MarkdownRenderer.test.tsx +++ b/src/ui/MarkdownRenderer.test.tsx @@ -61,7 +61,7 @@ describe("MarkdownRenderer", () => { expect(result.length).toBe(3); expect(result[0]).toBe("This is "); expect(React.isValidElement(result[1])).toBe(true); - expect((result[1] as any).props.color).toBe("cyan"); + expect((result[1] as any).props.color).toBe("magentaBright"); expect((result[1] as any).props.children).toBe("code"); expect(result[2]).toBe(" text"); }); diff --git a/src/ui/MarkdownRenderer.tsx b/src/ui/MarkdownRenderer.tsx index c608b816d..f85d9dae3 100644 --- a/src/ui/MarkdownRenderer.tsx +++ b/src/ui/MarkdownRenderer.tsx @@ -64,7 +64,7 @@ const MarkdownRenderer: React.FC = React.memo(({ content, { regex: /`([^`\n]+)`/g, render: (content, key) => ( - + {content} ), @@ -212,4 +212,4 @@ MarkdownRenderer.displayName = "MarkdownRenderer"; export default MarkdownRenderer; export type { SyntaxHighlighterTheme }; -export { defaultTheme }; +export { defaultTheme }; \ No newline at end of file