@@ -61,12 +61,6 @@ pub mod workspace {
6161 ] ;
6262}
6363
64- pub mod global {
65- //! User-level paths (relative to home directory)
66- pub const SHADOW_REPO_DIR : & str = ".aws/amazonq/cli-checkouts" ;
67- pub const CLI_BASH_HISTORY : & str = ".aws/amazonq/.cli_bash_history" ;
68- }
69-
7064type Result < T , E = DirectoryError > = std:: result:: Result < T , E > ;
7165
7266/// Trait for filesystem operations needed by migration logic
@@ -88,79 +82,101 @@ fn resolve_migrated_path_with_fs(
8882 home_dir : & std:: path:: Path ,
8983 current_dir : & std:: path:: Path ,
9084 is_global : bool ,
91- subpath : & str ,
85+ amazonq_subpath : & str ,
86+ kiro_subpath : & str ,
9287) -> std:: path:: PathBuf {
9388 let ( kiro_base, amazonq_base) = if is_global {
94- ( home_dir. join ( ".aws/ kiro" ) , home_dir. join ( ".aws/amazonq" ) )
89+ ( home_dir. join ( ".kiro" ) , home_dir. join ( ".aws/amazonq" ) )
9590 } else {
9691 ( current_dir. join ( ".kiro" ) , current_dir. join ( ".amazonq" ) )
9792 } ;
9893
9994 let scope = if is_global { "global" } else { "workspace" } ;
10095
10196 debug ! (
102- "Checking migration paths for {} {}: kiro={}, amazonq={}" ,
97+ "Checking migration paths for {} kiro_subpath={} amazonq_subpath= {}: kiro={}, amazonq={}" ,
10398 scope,
104- subpath,
99+ kiro_subpath,
100+ amazonq_subpath,
105101 kiro_base. display( ) ,
106102 amazonq_base. display( )
107103 ) ;
108104
109105 let ( kiro_exists, amazonq_exists) = ( fs. exists ( & kiro_base) , fs. exists ( & amazonq_base) ) ;
110106 debug ! (
111- "Path existence check for {} {}: kiro_exists={}, amazonq_exists={}" ,
112- scope, subpath , kiro_exists, amazonq_exists
107+ "Path existence check for {} kiro_subpath={} amazonq_subpath= {}: kiro_exists={}, amazonq_exists={}" ,
108+ scope, kiro_subpath , amazonq_subpath , kiro_exists, amazonq_exists
113109 ) ;
114110
115111 let result_path = match ( kiro_exists, amazonq_exists) {
116112 ( true , false ) => {
117113 info ! ( "Using .kiro {} configuration at: {}" , scope, kiro_base. display( ) ) ;
118- kiro_base. join ( subpath )
114+ kiro_base. join ( kiro_subpath )
119115 } ,
120116 ( false , true ) => {
121117 warn ! (
122118 "Migration notice: Using .amazonq {} configs at: {}" ,
123119 scope,
124120 amazonq_base. display( )
125121 ) ;
126- amazonq_base. join ( subpath )
122+ amazonq_base. join ( amazonq_subpath )
127123 } ,
128124 ( true , true ) => {
129125 warn ! (
130126 "Config conflict: Both .amazonq and .kiro {} configs exist, using .kiro at: {}" ,
131127 scope,
132128 kiro_base. display( )
133129 ) ;
134- kiro_base. join ( subpath )
130+ kiro_base. join ( kiro_subpath )
135131 } ,
136132 ( false , false ) => {
137133 debug ! (
138134 "No existing configs found, defaulting to .kiro {} at: {}" ,
139135 scope,
140136 kiro_base. display( )
141137 ) ;
142- kiro_base. join ( subpath )
138+ kiro_base. join ( kiro_subpath )
143139 } ,
144140 } ;
145141
146- debug ! ( "Resolved {} {} path: {}" , scope, subpath, result_path. display( ) ) ;
142+ debug ! (
143+ "Resolved {} kiro_subpath={} amazonq_subpath={} path: {}" ,
144+ scope,
145+ kiro_subpath,
146+ amazonq_subpath,
147+ result_path. display( )
148+ ) ;
147149 result_path
148150}
149151
150- fn resolve_global_migrated_path ( os : & Os , subpath : & str ) -> Result < PathBuf > {
152+ fn resolve_global_migrated_path ( os : & Os , amazonq_subpath : & str , kiro_subpath : & str ) -> Result < PathBuf > {
151153 let fs = RealFileSystem ;
152154 let home = home_dir ( os) ?;
153155 let current = os. env . current_dir ( ) ?;
154156
155- Ok ( resolve_migrated_path_with_fs ( & fs, & home, & current, true , subpath) )
157+ Ok ( resolve_migrated_path_with_fs (
158+ & fs,
159+ & home,
160+ & current,
161+ true ,
162+ amazonq_subpath,
163+ kiro_subpath,
164+ ) )
156165}
157166
158- fn resolve_local_migrated_path ( os : & Os , subpath : & str ) -> Result < PathBuf > {
167+ fn resolve_local_migrated_path ( os : & Os , amazonq_subpath : & str , kiro_subpath : & str ) -> Result < PathBuf > {
159168 let fs = RealFileSystem ;
160169 let home = home_dir ( os) ?;
161170 let current = os. env . current_dir ( ) ?;
162171
163- Ok ( resolve_migrated_path_with_fs ( & fs, & home, & current, false , subpath) )
172+ Ok ( resolve_migrated_path_with_fs (
173+ & fs,
174+ & home,
175+ & current,
176+ false ,
177+ amazonq_subpath,
178+ kiro_subpath,
179+ ) )
164180}
165181
166182/// The directory of the users home
@@ -325,19 +341,19 @@ pub struct WorkspacePaths<'a> {
325341
326342impl < ' a > WorkspacePaths < ' a > {
327343 pub fn agents_dir ( & self ) -> Result < PathBuf > {
328- resolve_local_migrated_path ( self . os , "cli-agents" )
344+ resolve_local_migrated_path ( self . os , "cli-agents" , "agents" )
329345 }
330346
331347 pub fn prompts_dir ( & self ) -> Result < PathBuf > {
332- resolve_local_migrated_path ( self . os , "prompts" )
348+ resolve_local_migrated_path ( self . os , "prompts" , "prompts" )
333349 }
334350
335351 pub fn mcp_config ( & self ) -> Result < PathBuf > {
336- resolve_local_migrated_path ( self . os , "mcp.json" )
352+ resolve_local_migrated_path ( self . os , "mcp.json" , "settings/mcp.json" )
337353 }
338354
339355 pub fn rules_dir ( & self ) -> Result < PathBuf > {
340- resolve_local_migrated_path ( self . os , "rules" )
356+ resolve_local_migrated_path ( self . os , "rules" , "rules" )
341357 }
342358
343359 pub fn todo_lists_dir ( & self ) -> Result < PathBuf > {
@@ -364,35 +380,35 @@ pub struct GlobalPaths<'a> {
364380
365381impl < ' a > GlobalPaths < ' a > {
366382 pub fn agents_dir ( & self ) -> Result < PathBuf > {
367- resolve_global_migrated_path ( self . os , "cli-agents" )
383+ resolve_global_migrated_path ( self . os , "cli-agents" , "agents" )
368384 }
369385
370386 pub fn prompts_dir ( & self ) -> Result < PathBuf > {
371- resolve_global_migrated_path ( self . os , "prompts" )
387+ resolve_global_migrated_path ( self . os , "prompts" , "prompts" )
372388 }
373389
374390 pub fn mcp_config ( & self ) -> Result < PathBuf > {
375- resolve_global_migrated_path ( self . os , "mcp.json" )
391+ resolve_global_migrated_path ( self . os , "mcp.json" , "settings/mcp.json" )
376392 }
377393
378394 pub fn profiles_dir ( & self ) -> Result < PathBuf > {
379- resolve_global_migrated_path ( self . os , "profiles" )
395+ resolve_global_migrated_path ( self . os , "profiles" , "profiles" )
380396 }
381397
382398 pub fn shadow_repo_dir ( & self ) -> Result < PathBuf > {
383- Ok ( home_dir ( self . os ) ? . join ( global :: SHADOW_REPO_DIR ) )
399+ resolve_global_migrated_path ( self . os , "cli-checkouts" , "cli/cli-checkouts" )
384400 }
385401
386402 pub fn cli_bash_history ( & self ) -> Result < PathBuf > {
387- Ok ( home_dir ( self . os ) ? . join ( global :: CLI_BASH_HISTORY ) )
403+ resolve_global_migrated_path ( self . os , ".cli_bash_history" , ".cli_bash_history" )
388404 }
389405
390406 pub fn global_context ( & self ) -> Result < PathBuf > {
391- resolve_global_migrated_path ( self . os , "global_context.json" )
407+ resolve_global_migrated_path ( self . os , "global_context.json" , "global_context.json" )
392408 }
393409
394410 pub fn knowledge_bases_dir ( & self ) -> Result < PathBuf > {
395- resolve_global_migrated_path ( self . os , "knowledge_bases" )
411+ resolve_global_migrated_path ( self . os , "knowledge_bases" , "cli/knowledge_bases" )
396412 }
397413
398414 pub async fn ensure_agents_dir ( & self ) -> Result < PathBuf > {
@@ -419,7 +435,7 @@ impl<'a> GlobalPaths<'a> {
419435 pub fn database_path_static ( ) -> Result < PathBuf > {
420436 Ok ( dirs:: data_local_dir ( )
421437 . ok_or ( DirectoryError :: NoHomeDirectory ) ?
422- . join ( "amazon-q " )
438+ . join ( "kiro-cli " )
423439 . join ( "data.sqlite3" ) )
424440 }
425441}
@@ -465,8 +481,8 @@ mod migration_tests {
465481 let home = Path :: new ( "/home/user" ) ;
466482 let current = Path :: new ( "/current" ) ;
467483
468- let path = resolve_migrated_path_with_fs ( & fs, home, current, false , "cli-agents" ) ;
469- assert_eq ! ( path, Path :: new( "/current/.kiro/cli- agents" ) ) ;
484+ let path = resolve_migrated_path_with_fs ( & fs, home, current, false , "cli-agents" , "agents" ) ;
485+ assert_eq ! ( path, Path :: new( "/current/.kiro/agents" ) ) ;
470486 }
471487
472488 #[ test]
@@ -477,7 +493,7 @@ mod migration_tests {
477493 let home = Path :: new ( "/home/user" ) ;
478494 let current = Path :: new ( "/current" ) ;
479495
480- let path = resolve_migrated_path_with_fs ( & fs, home, current, false , "cli-agents" ) ;
496+ let path = resolve_migrated_path_with_fs ( & fs, home, current, false , "cli-agents" , "agents" ) ;
481497 assert_eq ! ( path, Path :: new( "/current/.amazonq/cli-agents" ) ) ;
482498 }
483499
@@ -490,9 +506,9 @@ mod migration_tests {
490506 let home = Path :: new ( "/home/user" ) ;
491507 let current = Path :: new ( "/current" ) ;
492508
493- let path = resolve_migrated_path_with_fs ( & fs, home, current, false , "cli-agents" ) ;
509+ let path = resolve_migrated_path_with_fs ( & fs, home, current, false , "cli-agents" , "agents" ) ;
494510 // Should prefer .kiro when both exist
495- assert_eq ! ( path, Path :: new( "/current/.kiro/cli- agents" ) ) ;
511+ assert_eq ! ( path, Path :: new( "/current/.kiro/agents" ) ) ;
496512 }
497513
498514 #[ test]
@@ -502,21 +518,21 @@ mod migration_tests {
502518 let home = Path :: new ( "/home/user" ) ;
503519 let current = Path :: new ( "/current" ) ;
504520
505- let path = resolve_migrated_path_with_fs ( & fs, home, current, false , "cli-agents" ) ;
521+ let path = resolve_migrated_path_with_fs ( & fs, home, current, false , "cli-agents" , "agents" ) ;
506522 // Should default to .kiro when neither exists
507- assert_eq ! ( path, Path :: new( "/current/.kiro/cli- agents" ) ) ;
523+ assert_eq ! ( path, Path :: new( "/current/.kiro/agents" ) ) ;
508524 }
509525
510526 #[ test]
511527 fn test_kiro_only_global ( ) {
512528 let mut fs = TestFileSystem :: new ( ) ;
513- fs. add_path ( "/home/user/.aws/ kiro" ) ;
529+ fs. add_path ( "/home/user/.kiro" ) ;
514530
515531 let home = Path :: new ( "/home/user" ) ;
516532 let current = Path :: new ( "/current" ) ;
517533
518- let path = resolve_migrated_path_with_fs ( & fs, home, current, true , "cli-agents" ) ;
519- assert_eq ! ( path, Path :: new( "/home/user/.aws/ kiro/cli- agents" ) ) ;
534+ let path = resolve_migrated_path_with_fs ( & fs, home, current, true , "cli-agents" , "agents" ) ;
535+ assert_eq ! ( path, Path :: new( "/home/user/.kiro/agents" ) ) ;
520536 }
521537
522538 #[ test]
@@ -527,22 +543,22 @@ mod migration_tests {
527543 let home = Path :: new ( "/home/user" ) ;
528544 let current = Path :: new ( "/current" ) ;
529545
530- let path = resolve_migrated_path_with_fs ( & fs, home, current, true , "cli-agents" ) ;
546+ let path = resolve_migrated_path_with_fs ( & fs, home, current, true , "cli-agents" , "agents" ) ;
531547 assert_eq ! ( path, Path :: new( "/home/user/.aws/amazonq/cli-agents" ) ) ;
532548 }
533549
534550 #[ test]
535551 fn test_both_exist_global ( ) {
536552 let mut fs = TestFileSystem :: new ( ) ;
537- fs. add_path ( "/home/user/.aws/ kiro" ) ;
553+ fs. add_path ( "/home/user/.kiro" ) ;
538554 fs. add_path ( "/home/user/.aws/amazonq" ) ;
539555
540556 let home = Path :: new ( "/home/user" ) ;
541557 let current = Path :: new ( "/current" ) ;
542558
543- let path = resolve_migrated_path_with_fs ( & fs, home, current, true , "cli-agents" ) ;
559+ let path = resolve_migrated_path_with_fs ( & fs, home, current, true , "cli-agents" , "agents" ) ;
544560 // Should prefer .kiro when both exist
545- assert_eq ! ( path, Path :: new( "/home/user/.aws/ kiro/cli- agents" ) ) ;
561+ assert_eq ! ( path, Path :: new( "/home/user/.kiro/agents" ) ) ;
546562 }
547563
548564 #[ test]
@@ -552,9 +568,9 @@ mod migration_tests {
552568 let home = Path :: new ( "/home/user" ) ;
553569 let current = Path :: new ( "/current" ) ;
554570
555- let path = resolve_migrated_path_with_fs ( & fs, home, current, true , "cli-agents" ) ;
571+ let path = resolve_migrated_path_with_fs ( & fs, home, current, true , "cli-agents" , "agents" ) ;
556572 // Should default to .kiro when neither exists
557- assert_eq ! ( path, Path :: new( "/home/user/.aws/ kiro/cli- agents" ) ) ;
573+ assert_eq ! ( path, Path :: new( "/home/user/.kiro/agents" ) ) ;
558574 }
559575
560576 #[ test]
@@ -565,9 +581,9 @@ mod migration_tests {
565581 let home = Path :: new ( "/home/user" ) ;
566582 let current = Path :: new ( "/current" ) ;
567583
568- let agents_path = resolve_migrated_path_with_fs ( & fs, home, current, false , "cli-agents" ) ;
569- let prompts_path = resolve_migrated_path_with_fs ( & fs, home, current, false , "prompts" ) ;
570- let mcp_path = resolve_migrated_path_with_fs ( & fs, home, current, false , "mcp.json" ) ;
584+ let agents_path = resolve_migrated_path_with_fs ( & fs, home, current, false , "cli-agents" , "agents" ) ;
585+ let prompts_path = resolve_migrated_path_with_fs ( & fs, home, current, false , "prompts" , "prompts" ) ;
586+ let mcp_path = resolve_migrated_path_with_fs ( & fs, home, current, false , "mcp.json" , "settings/mcp.json" ) ;
571587
572588 assert_eq ! ( agents_path, Path :: new( "/current/.amazonq/cli-agents" ) ) ;
573589 assert_eq ! ( prompts_path, Path :: new( "/current/.amazonq/prompts" ) ) ;
@@ -577,13 +593,14 @@ mod migration_tests {
577593 #[ test]
578594 fn test_global_context_migration ( ) {
579595 let mut fs = TestFileSystem :: new ( ) ;
580- fs. add_path ( "/home/user/.aws/ kiro" ) ;
596+ fs. add_path ( "/home/user/.kiro" ) ;
581597
582598 let home = Path :: new ( "/home/user" ) ;
583599 let current = Path :: new ( "/current" ) ;
584600
585- let path = resolve_migrated_path_with_fs ( & fs, home, current, true , "global_context.json" ) ;
586- assert_eq ! ( path, Path :: new( "/home/user/.aws/kiro/global_context.json" ) ) ;
601+ let path =
602+ resolve_migrated_path_with_fs ( & fs, home, current, true , "global_context.json" , "global_context.json" ) ;
603+ assert_eq ! ( path, Path :: new( "/home/user/.kiro/global_context.json" ) ) ;
587604 }
588605
589606 #[ test]
@@ -594,7 +611,7 @@ mod migration_tests {
594611 let home = Path :: new ( "/home/user" ) ;
595612 let current = Path :: new ( "/current" ) ;
596613
597- let path = resolve_migrated_path_with_fs ( & fs, home, current, true , "knowledge_bases" ) ;
614+ let path = resolve_migrated_path_with_fs ( & fs, home, current, true , "knowledge_bases" , "cli/knowledge_bases" ) ;
598615 assert_eq ! ( path, Path :: new( "/home/user/.aws/amazonq/knowledge_bases" ) ) ;
599616 }
600617
@@ -606,7 +623,7 @@ mod migration_tests {
606623 let home = Path :: new ( "/home/user" ) ;
607624 let current = Path :: new ( "/current" ) ;
608625
609- let path = resolve_migrated_path_with_fs ( & fs, home, current, false , "rules" ) ;
626+ let path = resolve_migrated_path_with_fs ( & fs, home, current, false , "rules" , "rules" ) ;
610627 assert_eq ! ( path, Path :: new( "/current/.kiro/rules" ) ) ;
611628 }
612629}
0 commit comments