Elffuss BraidHub

kikocis/continue public

61bef27a1dcd · 3.1 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 color="blue">Rules:</Text>
89 {allRules.map((rule, index) => (
90 <Text key={index}>
91 - <Text color="white">{rule}</Text>
92 </Text>
93 ))}
94 <Text> </Text>
95 </>
96 )}
97
98 {/* MCP Servers */}
99 {config.mcpServers?.length && (
100 <>
101 <Text bold color="blue">
102 MCP Servers:
103 </Text>
104 {config.mcpServers.map((server: any, index: number) => (
105 <Text key={index}>
106 - <Text color="white">{server?.name}</Text>
107 </Text>
108 ))}
109 <Text> </Text>
110 </>
111 )}
112 </Box>
113 );
114};
115
116export { IntroMessage };