@@ -22,9 +22,9 @@ pub struct CredentialSyncServiceState(pub Option<Arc<CredentialSyncService>>);
2222
2323/// 展开路径中的 ~ 为用户主目录
2424fn expand_tilde ( path : & str ) -> String {
25- if path. starts_with ( "~/" ) {
25+ if let Some ( stripped ) = path. strip_prefix ( "~/" ) {
2626 if let Some ( home) = dirs:: home_dir ( ) {
27- return home. join ( & path [ 2 .. ] ) . to_string_lossy ( ) . to_string ( ) ;
27+ return home. join ( stripped ) . to_string_lossy ( ) . to_string ( ) ;
2828 }
2929 }
3030 path. to_string ( )
@@ -82,8 +82,7 @@ fn copy_and_rename_credential_file(
8282
8383 // 对于 Kiro 凭证,需要合并 clientIdHash 文件中的 client_id/client_secret
8484 if provider_type == "kiro" {
85- let content =
86- fs:: read_to_string ( & source) . map_err ( |e| format ! ( "读取凭证文件失败: {}" , e) ) ?;
85+ let content = fs:: read_to_string ( source) . map_err ( |e| format ! ( "读取凭证文件失败: {}" , e) ) ?;
8786 let mut creds: serde_json:: Value =
8887 serde_json:: from_str ( & content) . map_err ( |e| format ! ( "解析凭证文件失败: {}" , e) ) ?;
8988
@@ -200,9 +199,9 @@ fn copy_and_rename_credential_file(
200199 tracing:: error!(
201200 "[KIRO] IdC 认证方式缺少 clientId/clientSecret,无法创建有效的凭证副本"
202201 ) ;
203- return Err ( format ! (
204- "IdC 认证凭证不完整:缺少 clientId/clientSecret。\n \n 💡 解决方案:\n 1. 确保 ~/.aws/sso/cache/ 目录下有对应的 clientIdHash 文件\n 2. 如果使用 AWS IAM Identity Center,请确保已完成完整的 SSO 登录流程\n 3. 或者尝试使用 Social 认证方式的凭证"
205- ) ) ;
202+ return Err (
203+ "IdC 认证凭证不完整:缺少 clientId/clientSecret。\n \n 💡 解决方案:\n 1. 确保 ~/.aws/sso/cache/ 目录下有对应的 clientIdHash 文件\n 2. 如果使用 AWS IAM Identity Center,请确保已完成完整的 SSO 登录流程\n 3. 或者尝试使用 Social 认证方式的凭证" . to_string ( )
204+ ) ;
206205 } else {
207206 tracing:: warn!( "[KIRO] 未找到 client_id/client_secret,将使用 social 认证方式" ) ;
208207 }
@@ -214,7 +213,7 @@ fn copy_and_rename_credential_file(
214213 fs:: write ( & target_path, merged_content) . map_err ( |e| format ! ( "写入凭证文件失败: {}" , e) ) ?;
215214 } else {
216215 // 其他类型直接复制
217- fs:: copy ( & source, & target_path) . map_err ( |e| format ! ( "复制凭证文件失败: {}" , e) ) ?;
216+ fs:: copy ( source, & target_path) . map_err ( |e| format ! ( "复制凭证文件失败: {}" , e) ) ?;
218217 }
219218
220219 // 返回新的文件路径
@@ -1117,7 +1116,7 @@ pub async fn get_antigravity_auth_url_and_wait(
11171116 ) ;
11181117
11191118 // 从凭证中获取 project_id
1120- let project_id = result. credentials . projectId . clone ( ) ;
1119+ let project_id = result. credentials . project_id . clone ( ) ;
11211120
11221121 // 添加到凭证池
11231122 let credential = pool_service. 0 . add_credential (
@@ -1165,7 +1164,7 @@ pub async fn start_antigravity_oauth_login(
11651164 ) ;
11661165
11671166 // 从凭证中获取 project_id
1168- let project_id = result. credentials . projectId . clone ( ) ;
1167+ let project_id = result. credentials . project_id . clone ( ) ;
11691168
11701169 // 添加到凭证池
11711170 let credential = pool_service. 0 . add_credential (
0 commit comments