cn serve intro message and move version t rght
This commit is contained in:
parent
d93c14011f
commit
e933c56f7c
4 changed files with 58 additions and 11 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import chalk from "chalk";
|
||||
import { getVersion } from "./version.js";
|
||||
|
||||
const b = chalk.bold.magenta;
|
||||
const d = chalk.dim;
|
||||
|
|
@ -8,7 +9,8 @@ export const CONTINUE_ASCII_ART = `
|
|||
${b("/ ___/")}${d(" __ \\")}${b("/ |/ /")}${d("_ __/ _/ |/ / / / / __/")}
|
||||
${b("/ /__")}${d("/ /_/ ")}${b("/ /")}${d(" / / _/ // / /_/ / _/ ")}
|
||||
${b("\\___/")}${d("\\____")}${b("/_/|_/")}${d(" /_/ /___/_/|_/\\____/___/")}
|
||||
`;
|
||||
|
||||
${d("v" + getVersion())}`;
|
||||
// export const CONTINUE_ASCII_ART = `
|
||||
// _________ _ _____________ ____ ______
|
||||
// / ___/ __ \\/ |/ /_ __/ _/ |/ / / / / __/
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ import chalk from "chalk";
|
|||
import { ChatCompletionMessageParam } from "openai/resources.mjs";
|
||||
import * as readlineSync from "readline-sync";
|
||||
import { CONTINUE_ASCII_ART } from "../asciiArt.js";
|
||||
import { loadAuthConfig } from "../auth/workos.js";
|
||||
import { configureLogger } from "../logger.js";
|
||||
import * as logging from "../logging.js";
|
||||
import { initializeWithOnboarding } from "../onboarding.js";
|
||||
import { initializeServices } from "../services/index.js";
|
||||
import { serviceContainer } from "../services/ServiceContainer.js";
|
||||
import { ModelServiceState, SERVICE_NAMES } from "../services/types.js";
|
||||
|
|
@ -15,7 +17,6 @@ import { startTUIChat } from "../ui/index.js";
|
|||
import { safeStdout } from "../util/consoleOverride.js";
|
||||
import { formatError } from "../util/formatError.js";
|
||||
import logger from "../util/logger.js";
|
||||
import { getVersion } from "../version.js";
|
||||
|
||||
export interface ChatOptions {
|
||||
headless?: boolean;
|
||||
|
|
@ -152,18 +153,29 @@ export async function chat(prompt?: string, options: ChatOptions = {}) {
|
|||
// Start active time tracking
|
||||
telemetryService.startActiveTime();
|
||||
|
||||
// If not in headless mode, start the TUI chat (default)
|
||||
// If not in headless mode, check for onboarding first
|
||||
if (!options.headless) {
|
||||
// Show ASCII art and version for TUI mode
|
||||
console.log(chalk.white(CONTINUE_ASCII_ART));
|
||||
console.info(
|
||||
chalk.gray(
|
||||
`${" ".repeat(
|
||||
CONTINUE_ASCII_ART.trimEnd().split("\n").pop()!.length
|
||||
)}v${getVersion()}\n`
|
||||
)
|
||||
// Load auth config to check for onboarding
|
||||
const authConfig = loadAuthConfig();
|
||||
|
||||
// Run onboarding check - this will handle first-time setup
|
||||
const onboardingResult = await initializeWithOnboarding(
|
||||
authConfig,
|
||||
options.config,
|
||||
options.rule
|
||||
);
|
||||
|
||||
// If onboarding was completed (user just went through setup), exit gracefully
|
||||
if (onboardingResult.wasOnboarded) {
|
||||
console.log(
|
||||
chalk.green("✓ Setup complete! Run 'cn' again to start chatting.")
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Show ASCII art and version for TUI mode
|
||||
console.log(CONTINUE_ASCII_ART);
|
||||
|
||||
// Start TUI immediately - it will handle service loading
|
||||
await startTUIChat(prompt, options.resume, options.config, options.rule);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import path from "path";
|
|||
import { promisify } from "util";
|
||||
import {
|
||||
ensureOrganization,
|
||||
getAssistantSlug,
|
||||
getOrganizationId,
|
||||
loadAuthConfig,
|
||||
} from "../auth/workos.js";
|
||||
|
|
@ -71,6 +72,18 @@ export async function serve(prompt?: string, options: ServeOptions = {}) {
|
|||
}
|
||||
}
|
||||
|
||||
// Log configuration information
|
||||
const organizationId = getOrganizationId(finalAuthConfig || authConfig) || 'personal';
|
||||
const assistantName = config.name;
|
||||
const assistantSlug = getAssistantSlug(finalAuthConfig || authConfig);
|
||||
const modelProvider = model.provider;
|
||||
const modelName = model.model;
|
||||
|
||||
console.log(chalk.blue(`\nConfiguration:`));
|
||||
console.log(chalk.dim(` Organization: ${organizationId}`));
|
||||
console.log(chalk.dim(` Assistant: ${assistantName}${assistantSlug ? ` (${assistantSlug})` : ''}`));
|
||||
console.log(chalk.dim(` Model: ${modelProvider}/${modelName}`));
|
||||
|
||||
// Initialize chat history
|
||||
let chatHistory: ChatCompletionMessageParam[] = [];
|
||||
const systemMessage = await constructSystemMessage("", options.rule);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { Box, Text } from "ink";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { introMessage } from "../intro.js";
|
||||
import { useServices } from "../hooks/useService.js";
|
||||
import {
|
||||
ApiClientServiceState,
|
||||
|
|
@ -76,6 +77,25 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
});
|
||||
}, []);
|
||||
|
||||
// Display intro message when services are ready (only in non-remote mode)
|
||||
useEffect(() => {
|
||||
if (
|
||||
!isRemoteMode &&
|
||||
allServicesReady &&
|
||||
services.config?.config &&
|
||||
services.model?.model &&
|
||||
services.mcp?.mcpService
|
||||
) {
|
||||
introMessage(
|
||||
services.config.config,
|
||||
services.model.model,
|
||||
services.mcp.mcpService
|
||||
).catch((error) => {
|
||||
console.error("Failed to display intro message:", error);
|
||||
});
|
||||
}
|
||||
}, [isRemoteMode, allServicesReady, services.config?.config, services.model?.model, services.mcp?.mcpService]);
|
||||
|
||||
// Custom login prompt handler for TUI
|
||||
const handleLoginPrompt = (promptText: string): Promise<string> => {
|
||||
return new Promise((resolve) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue