Skip to content

Commit 8e659dc

Browse files
Fix command refactor bugs and improve user experience (#310)
* add extra help * fix /mcp & hooks * revise help * Update crates/chat-cli/src/cli/chat/cli/hooks.rs Co-authored-by: Chay Nabors <[email protected]> * handle img * delete /help check --------- Co-authored-by: Chay Nabors <[email protected]>
1 parent 3837bfe commit 8e659dc

File tree

4 files changed

+36
-18
lines changed

4 files changed

+36
-18
lines changed

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ impl HooksArgs {
461461
session.stderr,
462462
style::Print(format!(
463463
"\nUse {} to manage hooks.\n\n",
464-
"/context hooks help".to_string().dark_green()
464+
"/hooks help".to_string().dark_green()
465465
)),
466466
)?;
467467

@@ -671,19 +671,12 @@ impl HooksSubcommand {
671671
style::SetAttribute(Attribute::Reset),
672672
)?;
673673

674-
queue!(
675-
session.stderr,
676-
style::SetAttribute(Attribute::Bold),
677-
style::SetForegroundColor(Color::DarkYellow),
678-
style::Print("\n 🔧 Hooks:\n")
679-
)?;
680674
print_hook_section(
681675
&mut session.stderr,
682676
&context_manager.global_config.hooks,
683677
HookTrigger::ConversationStart,
684678
)
685679
.map_err(map_chat_error)?;
686-
687680
print_hook_section(
688681
&mut session.stderr,
689682
&context_manager.global_config.hooks,
@@ -700,12 +693,6 @@ impl HooksSubcommand {
700693
style::SetAttribute(Attribute::Reset),
701694
)?;
702695

703-
queue!(
704-
session.stderr,
705-
style::SetAttribute(Attribute::Bold),
706-
style::SetForegroundColor(Color::DarkYellow),
707-
style::Print(" 🔧 Hooks:\n")
708-
)?;
709696
print_hook_section(
710697
&mut session.stderr,
711698
&context_manager.profile_config.hooks,

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ use crate::cli::chat::{
3333
ChatError,
3434
ChatSession,
3535
ChatState,
36+
EXTRA_HELP,
3637
};
3738
use crate::cli::issue;
3839
use crate::os::Os;
3940

4041
/// q (Amazon Q Chat)
4142
#[derive(Debug, PartialEq, Parser)]
42-
#[command(color = clap::ColorChoice::Always)]
43+
#[command(color = clap::ColorChoice::Always, after_long_help = EXTRA_HELP)]
4344
pub enum SlashCommand {
4445
/// Quit the application
4546
#[command(aliases = ["q", "exit"])]
@@ -49,7 +50,7 @@ pub enum SlashCommand {
4950
/// Manage profiles
5051
#[command(subcommand)]
5152
Profile(ProfileSubcommand),
52-
/// Manage context files and hooks for the chat session
53+
/// Manage context files for the chat session
5354
#[command(subcommand)]
5455
Context(ContextSubcommand),
5556
/// Manage knowledge base for persistent context storage
@@ -62,7 +63,7 @@ pub enum SlashCommand {
6263
Compact(CompactArgs),
6364
/// View and manage tools and permissions
6465
Tools(ToolsArgs),
65-
/// Create a new Github issue
66+
/// Create a new Github issue or make a feature request
6667
Issue(issue::IssueArgs),
6768
/// View and retrieve prompts
6869
Prompts(PromptsArgs),

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mod error_formatter;
66
mod input_source;
77
mod message;
88
mod parse;
9+
use std::path::MAIN_SEPARATOR;
910
mod parser;
1011
mod prompt;
1112
mod prompt_parser;
@@ -137,6 +138,18 @@ const LIMIT_REACHED_TEXT: &str = color_print::cstr! { "You've used all your free
137138
1. Upgrade to a paid subscription for increased limits. See our Pricing page for what's included> <blue!>https://aws.amazon.com/q/developer/pricing/</blue!>
138139
2. Wait until next month when your limit automatically resets." };
139140

141+
pub const EXTRA_HELP: &str = color_print::cstr! {"
142+
<cyan,em>MCP:</cyan,em>
143+
<black!>You can now configure the Amazon Q CLI to use MCP servers. \nLearn how: https://docs.aws.amazon.com/en_us/amazonq/latest/qdeveloper-ug/command-line-mcp.html</black!>
144+
145+
<cyan,em>Tips:</cyan,em>
146+
<em>!{command}</em> <black!>Quickly execute a command in your current session</black!>
147+
<em>Ctrl(^) + j</em> <black!>Insert new-line to provide multi-line prompt. Alternatively, [Alt(⌥) + Enter(⏎)]</black!>
148+
<em>Ctrl(^) + s</em> <black!>Fuzzy search commands and context files. Use Tab to select multiple items.</black!>
149+
<black!>Change the keybind to ctrl+x with: q settings chat.skimCommandKey x (where x is any key)</black!>
150+
<em>chat.editMode</em> <black!>Set editing mode (vim or emacs) using: q settings chat.editMode vi/emacs</black!>
151+
"};
152+
140153
#[derive(Debug, Clone, PartialEq, Eq, Default, Args)]
141154
pub struct ChatArgs {
142155
/// Resumes the previous conversation from this directory.
@@ -1210,6 +1223,22 @@ impl ChatSession {
12101223
queue!(self.stderr, style::Print('\n'))?;
12111224

12121225
let input = user_input.trim();
1226+
1227+
// handle image path
1228+
if input.starts_with('/') {
1229+
if let Some(after_slash) = input.strip_prefix('/') {
1230+
let looks_like_path = after_slash.contains(MAIN_SEPARATOR)
1231+
|| after_slash.contains('/')
1232+
|| after_slash.contains('\\')
1233+
|| after_slash.contains('.');
1234+
1235+
if looks_like_path {
1236+
return Ok(ChatState::HandleInput {
1237+
input: after_slash.to_string(),
1238+
});
1239+
}
1240+
}
1241+
}
12131242
if let Some(mut args) = input.strip_prefix("/").and_then(shlex::split) {
12141243
args.insert(0, "q".to_owned());
12151244
match SlashCommand::try_parse_from(args) {
@@ -1230,7 +1259,7 @@ impl ChatSession {
12301259
writeln!(self.stderr)?;
12311260
},
12321261
Err(err) => {
1233-
writeln!(self.stderr, "{}", err)?;
1262+
writeln!(self.stderr, "{}", err.render().ansi())?;
12341263
},
12351264
}
12361265

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub const COMMANDS: &[&str] = &[
5252
"/tools untrust",
5353
"/tools trustall",
5454
"/tools reset",
55+
"/mcp",
5556
"/model",
5657
"/profile",
5758
"/profile help",

0 commit comments

Comments
 (0)