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

Method get_context

crates/chat-cli/src/cli/chat/tools/gh_issue.rs:136–177  ·  view source on GitHub ↗
(os: &Os, context: &GhIssueContext)

Source from the content-addressed store, hash-verified

134 }
135
136 async fn get_context(os: &Os, context: &GhIssueContext) -> String {
137 let mut os_str = "[chat-context]\n".to_string();
138 let Some(os_manager) = &context.context_manager else {
139 os_str.push_str("No context available.");
140 return os_str;
141 };
142
143 os_str.push_str(&format!("current_profile={}\n", os_manager.current_profile));
144
145 if os_manager.paths.is_empty() {
146 os_str.push_str("profile_context=none\n\n");
147 } else {
148 os_str.push_str(&format!(
149 "profile_context=\n{}\n\n",
150 &os_manager
151 .paths
152 .iter()
153 .map(|p| p.get_path_as_str())
154 .collect::<Vec<_>>()
155 .join("\n")
156 ));
157 }
158
159 // Handle context files
160 match os_manager.get_context_files(os).await {
161 Ok(context_files) if !context_files.is_empty() => {
162 os_str.push_str("files=\n");
163 let total_size: usize = context_files
164 .iter()
165 .map(|(file, content)| {
166 let size = TokenCounter::count_tokens(content);
167 os_str.push_str(&format!("{}, {} tkns\n", file, size));
168 size
169 })
170 .sum();
171 os_str.push_str(&format!("total context size={total_size} tkns"));
172 },
173 _ => os_str.push_str("files=none"),
174 }
175
176 os_str
177 }
178
179 fn get_chat_settings(context: &GhIssueContext) -> String {
180 let mut result_str = "[chat-settings]\n".to_string();

Callers

nothing calls this directly

Calls 4

to_stringMethod · 0.80
get_context_filesMethod · 0.80
mapMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected