MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / execute

Method execute

crates/chat-cli/src/cli/chat/cli/context.rs:68–361  ·  view source on GitHub ↗
(self, os: &Os, session: &mut ChatSession)

Source from the content-addressed store, hash-verified

66
67impl ContextSubcommand {
68 pub async fn execute(self, os: &Os, session: &mut ChatSession) -> Result<ChatState, ChatError> {
69 let Some(context_manager) = &mut session.conversation.context_manager else {
70 execute!(
71 session.stderr,
72 StyledText::error_fg(),
73 style::Print("\nContext management is not available.\n\n"),
74 StyledText::reset(),
75 )?;
76
77 return Ok(ChatState::PromptUser {
78 skip_printing_tools: true,
79 });
80 };
81
82 match self {
83 Self::Show { expand } => {
84 // the bool signifies if the resources is temporary (i.e. is it session based as
85 // opposed to agent based)
86 let mut profile_context_files = HashSet::<(String, String, bool)>::new();
87
88 let (agent_owned_list, session_owned_list) = context_manager
89 .paths
90 .iter()
91 .partition::<Vec<_>, _>(|p| matches!(**p, ContextFilePath::Agent(_)));
92
93 execute!(
94 session.stderr,
95 style::SetAttribute(Attribute::Bold),
96 StyledText::emphasis_fg(),
97 style::Print(format!("👤 Agent ({}):\n", context_manager.current_profile)),
98 StyledText::reset_attributes(),
99 )?;
100
101 if agent_owned_list.is_empty() {
102 execute!(
103 session.stderr,
104 StyledText::secondary_fg(),
105 style::Print(" <none>\n\n"),
106 StyledText::reset(),
107 )?;
108 } else {
109 for path in &agent_owned_list {
110 execute!(session.stderr, style::Print(format!(" {} ", path.get_path_as_str())))?;
111 if let Ok(context_files) = context_manager
112 .get_context_files_by_path(os, path.get_path_as_str())
113 .await
114 {
115 execute!(
116 session.stderr,
117 StyledText::success_fg(),
118 style::Print(format!(
119 "({} match{})",
120 context_files.len(),
121 if context_files.len() == 1 { "" } else { "es" }
122 )),
123 StyledText::reset(),
124 )?;
125 profile_context_files

Callers

nothing calls this directly

Calls 14

get_path_as_strMethod · 0.80
mapMethod · 0.80
latest_summaryMethod · 0.80
terminal_widthMethod · 0.80
add_pathsMethod · 0.80
remove_pathsMethod · 0.80
is_emptyMethod · 0.45
lenMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected