fix: don't try to onboard during serve
This commit is contained in:
parent
3bf6e276c6
commit
b75a96397c
4 changed files with 34 additions and 17 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -158,19 +158,28 @@ export async function runOnboardingFlow(
|
|||
}
|
||||
|
||||
export async function runNormalFlow(
|
||||
configPath: string | undefined,
|
||||
authConfig: AuthConfig
|
||||
authConfig: AuthConfig,
|
||||
configPath?: string,
|
||||
rules?: string[]
|
||||
): Promise<OnboardingResult> {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ const MarkdownRenderer: React.FC<MarkdownRendererProps> = React.memo(({ content,
|
|||
{
|
||||
regex: /`([^`\n]+)`/g,
|
||||
render: (content, key) => (
|
||||
<Text key={key} color="cyan">
|
||||
<Text key={key} color="magentaBright">
|
||||
{content}
|
||||
</Text>
|
||||
),
|
||||
|
|
@ -212,4 +212,4 @@ MarkdownRenderer.displayName = "MarkdownRenderer";
|
|||
|
||||
export default MarkdownRenderer;
|
||||
export type { SyntaxHighlighterTheme };
|
||||
export { defaultTheme };
|
||||
export { defaultTheme };
|
||||
Loading…
Add table
Reference in a new issue