@@ -14,7 +14,6 @@ use super::error::{
1414use crate :: agent:: util:: consts:: env_var:: CLI_DATA_DIR ;
1515
1616const DATA_DIR_NAME : & str = "amazon-q" ;
17- const AWS_DIR_NAME : & str = "amazonq" ;
1817
1918type Result < T , E = UtilError > = std:: result:: Result < T , E > ;
2019
@@ -57,28 +56,50 @@ pub fn settings_schema_path(base: impl AsRef<Path>) -> PathBuf {
5756 base. as_ref ( ) . join ( "settings_schema.json" )
5857}
5958
59+ fn resolve_migrated_path ( is_global : bool , subpath : & str ) -> Result < PathBuf > {
60+ let ( kiro_base, amazonq_base) = if is_global {
61+ let home = home_dir ( ) ?;
62+ ( home. join ( ".aws/kiro" ) , home. join ( ".aws/amazonq" ) )
63+ } else {
64+ let cwd = env:: current_dir ( ) . context ( "unable to get the current directory" ) ?;
65+ ( cwd. join ( ".kiro" ) , cwd. join ( ".amazonq" ) )
66+ } ;
67+
68+ let scope = if is_global { "global" } else { "workspace" } ;
69+
70+ match ( kiro_base. exists ( ) , amazonq_base. exists ( ) ) {
71+ ( true , false ) => {
72+ warn ! ( "Using .kiro {} configuration" , scope) ;
73+ Ok ( kiro_base. join ( subpath) )
74+ } ,
75+ ( false , true ) => {
76+ warn ! ( "Migration notice: Using .amazonq {} configs" , scope) ;
77+ Ok ( amazonq_base. join ( subpath) )
78+ } ,
79+ ( true , true ) => {
80+ warn ! ( "Both .amazonq and .kiro {} configs exist, using .amazonq" , scope) ;
81+ Ok ( amazonq_base. join ( subpath) )
82+ } ,
83+ ( false , false ) => Ok ( kiro_base. join ( subpath) ) , // Default to kiro
84+ }
85+ }
86+
6087/// Path to the directory containing local agent configs.
6188pub fn local_agents_path ( ) -> Result < PathBuf > {
62- Ok ( env:: current_dir ( )
63- . context ( "unable to get the current directory" ) ?
64- . join ( format ! ( ".{AWS_DIR_NAME}" ) )
65- . join ( "cli-agents" ) )
89+ resolve_migrated_path ( false , "cli-agents" )
6690}
6791
6892/// Path to the directory containing global agent configs.
6993pub fn global_agents_path ( ) -> Result < PathBuf > {
70- Ok ( home_dir ( ) ? . join ( ".aws" ) . join ( AWS_DIR_NAME ) . join ( " cli-agents") )
94+ resolve_migrated_path ( true , " cli-agents")
7195}
7296
7397/// Legacy workspace MCP server config path
7498pub fn legacy_workspace_mcp_config_path ( ) -> Result < PathBuf > {
75- Ok ( env:: current_dir ( )
76- . context ( "unable to get the current directory" ) ?
77- . join ( format ! ( ".{AWS_DIR_NAME}" ) )
78- . join ( "mcp.json" ) )
99+ resolve_migrated_path ( false , "mcp.json" )
79100}
80101
81102/// Legacy global MCP server config path
82103pub fn legacy_global_mcp_config_path ( ) -> Result < PathBuf > {
83- Ok ( home_dir ( ) ? . join ( ".aws" ) . join ( AWS_DIR_NAME ) . join ( " mcp.json") )
104+ resolve_migrated_path ( true , " mcp.json")
84105}
0 commit comments