diff options
| author | sigoden <sigoden@gmail.com> | 2024-05-18 22:34:23 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-18 22:34:23 +0800 |
| commit | d16cca23acf2bcae05cecdb2f6bf85fe3b7cb1cb (patch) | |
| tree | fecae3ac64cd7a8296018a8bc1a3d37fcee85b0e /src/config | |
| parent | 665693ccf2f6c77a261b0f34c8fab7bf9e26d6c0 (diff) | |
| download | aichat-d16cca23acf2bcae05cecdb2f6bf85fe3b7cb1cb.tar.gz | |
refactor: shell detect/prompt (#519)
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/role.rs | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/src/config/role.rs b/src/config/role.rs index 27858a3..c477ee4 100644 --- a/src/config/role.rs +++ b/src/config/role.rs @@ -225,23 +225,16 @@ fn parse_structure_prompt(prompt: &str) -> (&str, Vec<(&str, &str)>) { fn shell_prompt() -> String { let os = detect_os(); - let (detected_shell, _, _) = detect_shell(); - let (shell, use_semicolon) = match (detected_shell.as_str(), os.as_str()) { - // GPT doesn’t know much about nushell - ("nushell", "windows") => ("cmd", true), - ("nushell", _) => ("bash", true), - ("powershell", _) => ("powershell", true), - ("pwsh", _) => ("powershell", false), - _ => (detected_shell.as_str(), false), - }; - let combine = if use_semicolon { + let shell = detect_shell(); + let shell = shell.name.as_str(); + let combinator = if shell == "powershell" { "\nIf multiple steps required try to combine them together using ';'.\nIf it already combined with '&&' try to replace it with ';'.".to_string() } else { "\nIf multiple steps required try to combine them together using '&&'.".to_string() }; format!( r#"Provide only {shell} commands for {os} without any description. -Ensure the output is a valid {shell} command. {combine} +Ensure the output is a valid {shell} command. {combinator} If there is a lack of details, provide most logical solution. Output plain text only, without any markdown formatting."# ) |
