Elffuss BraidHub

kikocis/continue public

8eb3ae7b8d16 · 3.2 KiBRawPermalink
1import { AssistantUnrolled, ModelConfig } from "@continuedev/config-yaml";
2import { Box, Text } from "ink";
3import React, { useMemo } from "react";
4
5import { parseArgs } from "../args.js";
6import { MCPService } from "../services/MCPService.js";
7import { isModelCapable } from "../utils/modelCapability.js";
8
9import { ModelCapabilityWarning } from "./ModelCapabilityWarning.js";
10
11interface IntroMessageProps {
12 config: AssistantUnrolled;
13 model: ModelConfig;
14 mcpService: MCPService;
15}
16
17const IntroMessage: React.FC<IntroMessageProps> = ({
18 config,
19 model,
20 mcpService,
21}) => {
22 // Get MCP prompts directly (not memoized since they can change after first render)
23 const mcpPrompts = mcpService.getState().prompts ?? [];
24
25 // Memoize expensive operations to avoid running on every resize
26 const { allRules, modelCapable } = useMemo(() => {
27 // Show all rules in a single section
28 const args = parseArgs();
29 const commandLineRules = args.rules || [];
30 const configRules =
31 config.rules?.map((rule: any) =>
32 typeof rule === "string" ? rule : rule?.name || "Unknown",
33 ) || [];
34
35 const allRules = [...commandLineRules, ...configRules];
36
37 // Check if model is capable - now checking both name and model properties
38 const modelCapable = isModelCapable(
39 model.provider,
40 model.name,
41 model.model,
42 );
43
44 return { allRules, modelCapable };
45 }, [config.rules, model.provider, model.name, model.model]);
46
47 return (
48 <Box flexDirection="column" paddingX={1} paddingY={1}>
49 {/* Agent name */}
50 <Text color="blue">
51 <Text bold>Agent:</Text> <Text color="white">{config.name}</Text>
52 </Text>
53
54 {/* Model */}
55 <Text color="blue">
56 <Text bold>Model:</Text>{" "}
57 <Text color="white">{model.name.split("/").pop()}</Text>
58 </Text>
59
60 <Text> </Text>
61
62 {/* Model capability warning */}
63 {!modelCapable && (
64 <>
65 <ModelCapabilityWarning
66 modelName={model.name.split("/").pop() || model.name}
67 />
68 <Text> </Text>
69 </>
70 )}
71
72 {/* MCP prompts */}
73 {mcpPrompts.length > 0 && (
74 <>
75 {mcpPrompts.map((prompt, index) => (
76 <Text key={`mcp-${index}`}>
77 - <Text color="white">/{prompt.name}</Text>:{" "}
78 <Text color="gray">{prompt.description}</Text>
79 </Text>
80 ))}
81 <Text> </Text>
82 </>
83 )}
84
85 {/* Rules */}
86 {allRules.length > 0 && (
87 <>
88 <Text bold color="blue">
89 Rules:
90 </Text>
91 {allRules.map((rule, index) => (
92 <Text key={index}>
93 - <Text color="white">{rule}</Text>
94 </Text>
95 ))}
96 <Text> </Text>
97 </>
98 )}
99
100 {/* MCP Servers */}
101 {config.mcpServers?.length && (
102 <>
103 <Text bold color="blue">
104 MCP Servers:
105 </Text>
106 {config.mcpServers.map((server: any, index: number) => (
107 <Text key={index}>
108 - <Text color="white">{server?.name}</Text>
109 </Text>
110 ))}
111 <Text> </Text>
112 </>
113 )}
114 </Box>
115 );
116};
117
118export { IntroMessage };