Skip to content

Commit 3837bfe

Browse files
authored
fix: Fix @ prompt syntax not working (#309)
1 parent 4be4f6a commit 3837bfe

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

crates/chat-cli/src/cli/chat/cli/prompts.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ pub enum PromptsSubcommand {
206206
/// List available prompts from a tool or show all available prompt
207207
List { search_word: Option<String> },
208208
Get {
209+
#[arg(long, hide = true)]
209210
orig_input: Option<String>,
210211
name: String,
211212
arguments: Option<Vec<String>>,

crates/chat-cli/src/cli/chat/mod.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ use crate::cli::chat::cli::model::{
119119
MODEL_OPTIONS,
120120
default_model_id,
121121
};
122-
use crate::cli::chat::cli::prompts::GetPromptError;
122+
use crate::cli::chat::cli::prompts::{
123+
GetPromptError,
124+
PromptsSubcommand,
125+
};
123126
use crate::database::settings::Setting;
124127
use crate::mcp_client::Prompt;
125128
use crate::os::Os;
@@ -1234,6 +1237,24 @@ impl ChatSession {
12341237
Ok(ChatState::PromptUser {
12351238
skip_printing_tools: false,
12361239
})
1240+
} else if let Some(command) = input.strip_prefix("@") {
1241+
let input_parts =
1242+
shlex::split(command).ok_or(ChatError::Custom("Error splitting prompt command".into()))?;
1243+
1244+
let mut iter = input_parts.into_iter();
1245+
let prompt_name = iter
1246+
.next()
1247+
.ok_or(ChatError::Custom("Prompt name needs to be specified".into()))?;
1248+
1249+
let args: Vec<String> = iter.collect();
1250+
let arguments = if args.is_empty() { None } else { Some(args) };
1251+
1252+
let subcommand = PromptsSubcommand::Get {
1253+
orig_input: Some(command.to_string()),
1254+
name: prompt_name,
1255+
arguments,
1256+
};
1257+
return subcommand.execute(self).await;
12371258
} else if let Some(command) = input.strip_prefix("!") {
12381259
// Use platform-appropriate shell
12391260
let result = if cfg!(target_os = "windows") {

0 commit comments

Comments
 (0)