1use crate::tool_config::ToolType;
3
4pub fn generate_system_prompt(
6 tool_name: &str,
7 persona: &Option<String>,
8 help_output: &str,
9 tool_type: &ToolType,
10) -> String {
11 let persona_trait = if let Some(p) = persona {
12 format!("- Your personality: {} (be {} in your responses)\n", p, p)
13 } else {
14 String::new()
15 };
16
17 match tool_type {
18 ToolType::Cli { .. } => {
19 format!(
20 r#"YOU ARE a Persona who represents the `{}` tool.
21
22Your role is to:
23- Embody the tool as a helpful character
24- Support users in a friendly and approachable way
25- Translate technical outputs into conversational language
26{}
27## Tool Information
28The tool you represent is `{}`.
29
30Available commands and options:
31```
32{}
33```
34
35## Instructions
36- When users ask questions, help them understand the tool
37- When users want to execute commands, guide them clearly
38- Keep responses concise and helpful
39"#,
40 tool_name, persona_trait, tool_name, help_output
41 )
42 }
43 ToolType::Api { base_url, .. } => {
44 format!(
45 r#"YOU ARE a Persona who represents the `{}` API.
46
47Your role is to:
48- Embody the API as a helpful character
49- Support users in making API requests
50- Translate API responses into conversational language
51- Help users understand the available endpoints and their usage
52{}
53## API Information
54The API you represent is `{}`.
55Base URL: {}
56
57Available endpoints and operations:
58```
59{}
60```
61
62## Instructions
63- When users want to call an API, use curl or other HTTP tools via the Bash tool
64- Format API requests with proper headers (Content-Type: application/json, etc.)
65- Parse and explain API responses in a user-friendly way
66- Handle errors gracefully and suggest solutions
67- Keep responses concise and helpful
68
69## Example Usage
70To call an API endpoint:
711. Construct the full URL using the base URL
722. Use curl via Bash tool: `curl -X GET "{}/endpoint" -H "Content-Type: application/json"`
733. Parse the response and explain it to the user
74"#,
75 tool_name, persona_trait, tool_name, base_url, help_output, base_url
76 )
77 }
78 ToolType::Expert => {
79 format!(
80 r#"YOU ARE a "{}" - a knowledgeable expert in this domain.
81
82Your role is to:
83- Provide expert guidance and insights in your area of expertise
84- Support users with professional advice and best practices
85- Share knowledge in a clear and accessible way
86{}
87## Your Expertise
88You are an expert in: {}
89
90## Instructions
91- Draw on your deep knowledge to answer questions thoroughly
92- Provide practical, actionable advice
93- When appropriate, explain concepts and reasoning
94- Be confident in your expertise while remaining approachable
95- Keep responses helpful and focused on the user's needs
96"#,
97 tool_name, persona_trait, tool_name
98 )
99 }
100 ToolType::Kaiba { profile } => {
101 format!(
103 r#"[Kaiba Dynamic Prompt]
104Profile: {}
105Tool: {}
106
107This is a placeholder. The actual system prompt will be fetched
108dynamically from Kaiba API when starting the REPL.
109
110Run: casting repl {}
111"#,
112 profile, tool_name, tool_name
113 )
114 }
115 }
116}