Skip to content

Commit 467c7f3

Browse files
authored
feat(commands): add /issue command to chat (#990)
This command simply prompts amazon Q to use the `report_issue` tool. Any additional text beyond /issue will be provided in the prompt. Ref: #972
1 parent 5a704ba commit 467c7f3

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

crates/q_cli/src/cli/chat/command.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub enum Command {
77
Clear,
88
Help,
99
AcceptAll,
10+
Issue { prompt: Option<String> },
1011
Quit,
1112
Profile { subcommand: ProfileSubcommand },
1213
Context { subcommand: ContextSubcommand },
@@ -163,6 +164,15 @@ impl Command {
163164
"clear" => Self::Clear,
164165
"help" => Self::Help,
165166
"acceptall" => Self::AcceptAll,
167+
"issue" => {
168+
if parts.len() > 1 {
169+
Self::Issue {
170+
prompt: Some(parts[1..].join(" ")),
171+
}
172+
} else {
173+
Self::Issue { prompt: None }
174+
}
175+
},
166176
"q" | "exit" | "quit" => Self::Quit,
167177
"profile" => {
168178
if parts.len() < 2 {
@@ -443,6 +453,13 @@ mod tests {
443453
"/context clear --global",
444454
context!(ContextSubcommand::Clear { global: true }),
445455
),
456+
("/issue", Command::Issue { prompt: None }),
457+
("/issue there was an error in the chat", Command::Issue {
458+
prompt: Some("there was an error in the chat".to_string()),
459+
}),
460+
("/issue \"there was an error in the chat\"", Command::Issue {
461+
prompt: Some("\"there was an error in the chat\"".to_string()),
462+
}),
446463
];
447464

448465
for (input, parsed) in tests {

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ const WELCOME_TEXT: &str = color_print::cstr! {"
9696
• Help me understand my git status
9797
9898
<em>/acceptall</em> <black!>Toggles acceptance prompting for the session.</black!>
99+
<em>/issue</em> <black!>Report an issue or make a feature request.</black!>
99100
<em>/profile</em> <black!>(Beta) Manage profiles for the chat session</black!>
100101
<em>/context</em> <black!>(Beta) Manage context files for a profile</black!>
101102
<em>/help</em> <black!>Show the help dialogue</black!>
@@ -110,6 +111,7 @@ const HELP_TEXT: &str = color_print::cstr! {"
110111
111112
<em>/clear</em> <black!>Clear the conversation history</black!>
112113
<em>/acceptall</em> <black!>Toggles acceptance prompting for the session.</black!>
114+
<em>/issue</em> <black!>Report an issue or make a feature request.</black!>
113115
<em>/help</em> <black!>Show this help dialogue</black!>
114116
<em>/quit</em> <black!>Quit the application</black!>
115117
<em>/profile</em> <black!>Manage profiles</black!>
@@ -667,6 +669,17 @@ where
667669
skip_printing_tools: true,
668670
}
669671
},
672+
Command::Issue { prompt } => {
673+
let input = "I would like to report an issue or make a feature request";
674+
ChatState::HandleInput {
675+
input: if let Some(prompt) = prompt {
676+
format!("{input}: {prompt}")
677+
} else {
678+
input.to_string()
679+
},
680+
tool_uses: Some(tool_uses),
681+
}
682+
},
670683
Command::AcceptAll => {
671684
self.accept_all = !self.accept_all;
672685

crates/q_cli/src/cli/chat/prompt.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const COMMANDS: &[&str] = &[
3030
"/clear",
3131
"/help",
3232
"/acceptall",
33+
"/issue",
3334
"/quit",
3435
"/profile",
3536
"/profile help",

0 commit comments

Comments
 (0)