1
- use std:: path:: PathBuf ;
1
+ use std:: path:: {
2
+ PathBuf ,
3
+ StripPrefixError ,
4
+ } ;
2
5
3
6
use thiserror:: Error ;
4
7
@@ -23,6 +26,8 @@ pub enum DirectoryError {
23
26
FromVecWithNul ( #[ from] std:: ffi:: FromVecWithNulError ) ,
24
27
#[ error( transparent) ]
25
28
IntoString ( #[ from] std:: ffi:: IntoStringError ) ,
29
+ #[ error( transparent) ]
30
+ StripPrefix ( #[ from] StripPrefixError ) ,
26
31
}
27
32
28
33
type Result < T , E = DirectoryError > = std:: result:: Result < T , E > ;
@@ -142,23 +147,22 @@ pub fn chat_legacy_mcp_config(os: &Os) -> Result<PathBuf> {
142
147
143
148
/// The directory to the directory containing global agents
144
149
pub fn chat_global_agent_path ( os : & Os ) -> Result < PathBuf > {
145
- Ok ( home_dir ( os) ?. join ( agent_config_dir ( ) ) )
150
+ Ok ( home_dir ( os) ?. join ( ".aws" ) . join ( "amazonq" ) . join ( "agents" ) )
146
151
}
147
152
148
153
/// The directory to the directory containing config for the `/context` feature in `q chat`.
149
154
pub fn chat_local_agent_dir ( ) -> Result < PathBuf > {
150
155
let cwd = std:: env:: current_dir ( ) ?;
151
- Ok ( cwd. join ( agent_config_dir ( ) ) )
156
+ Ok ( cwd. join ( ".amazonq" ) . join ( "agents" ) )
152
157
}
153
158
154
- /// The relative path to the agent configuration directory
159
+ /// Derives the absolute path to an agent config directory given a "workspace directory".
160
+ /// A workspace directory is a directory where q chat is to be launched
155
161
///
156
- /// This directory contains agent configuration files for Amazon Q.
157
- /// The path is relative and should be joined with either the home directory
158
- /// for global agents or the current working directory for local agents.
159
- // TODO [dingfeli]: implement Brandon's suggestion: https://github.com/aws/amazon-q-developer-cli/pull/2307#discussion_r2207989985
160
- pub fn agent_config_dir ( ) -> PathBuf {
161
- PathBuf :: from ( ".aws/amazonq/agents" )
162
+ /// For example, if the given path is /path/one, then the derived config path would be
163
+ /// `/path/one/.amazonq/agents`
164
+ pub fn agent_config_dir ( workspace_dir : PathBuf ) -> Result < PathBuf > {
165
+ Ok ( workspace_dir. join ( ".amazonq/agents" ) )
162
166
}
163
167
164
168
/// The directory to the directory containing config for the `/context` feature in `q chat`.
0 commit comments