@@ -16,6 +16,7 @@ import { BackupService } from './backup.service';
1616import { DiffService } from './diff.service' ;
1717import { ErrorRecoveryService } from './error-recovery.service' ;
1818import { KiroComponentHandlerService } from './kiro-component-handler.service' ;
19+ import { KiroInstallationDetectorService } from './kiro-installation-detector.service' ;
1920import { KiroTransformerService } from './kiro-transformer.service' ;
2021import { LargeFileStreamerService } from './large-file-streamer.service' ;
2122import { PerformanceMonitorService } from './performance-monitor.service' ;
@@ -34,6 +35,7 @@ export class DeploymentService {
3435 private readonly largeFileStreamer : LargeFileStreamerService ,
3536 private readonly kiroTransformer : KiroTransformerService ,
3637 private readonly kiroComponentHandler : KiroComponentHandlerService ,
38+ private readonly kiroInstallationDetector : KiroInstallationDetectorService ,
3739 ) { }
3840
3941 async deployToClaudeCode (
@@ -309,7 +311,67 @@ export class DeploymentService {
309311 } ;
310312
311313 try {
312- // Step 1: Validate configuration for Kiro platform
314+ // Step 1: Check Kiro installation and compatibility
315+ this . performanceMonitor . recordMemoryUsage ( deploymentId , 'installation-check-start' ) ;
316+
317+ const installationInfo = await this . kiroInstallationDetector . detectKiroInstallation ( ) ;
318+
319+ if ( ! installationInfo . isInstalled ) {
320+ result . errors . push ( {
321+ message : 'Kiro IDE is not installed or not found in expected locations' ,
322+ code : 'KIRO_NOT_INSTALLED' ,
323+ severity : 'CRITICAL' ,
324+ } ) ;
325+ this . performanceMonitor . endDeploymentTiming ( deploymentId ) ;
326+ result . metadata ! . performanceReport = 'Kiro deployment failed - installation not found' ;
327+ return result ;
328+ }
329+
330+ // Add installation info to warnings for user visibility
331+ result . warnings . push ( {
332+ message : `Kiro IDE detected: v${ installationInfo . version || 'unknown' } at ${ installationInfo . installationPath } ` ,
333+ code : 'KIRO_INSTALLATION_DETECTED' ,
334+ } ) ;
335+
336+ // Check compatibility
337+ if ( ! installationInfo . isCompatible ) {
338+ const compatibilityResult = await this . kiroInstallationDetector . checkCompatibility ( installationInfo . version ) ;
339+
340+ // Add compatibility issues as warnings or errors based on severity
341+ for ( const issue of compatibilityResult . issues ) {
342+ if ( issue . severity === 'critical' ) {
343+ result . errors . push ( {
344+ message : `Compatibility issue: ${ issue . message } ` ,
345+ code : 'KIRO_COMPATIBILITY_ERROR' ,
346+ severity : 'HIGH' ,
347+ } ) ;
348+ } else {
349+ result . warnings . push ( {
350+ message : `Compatibility warning: ${ issue . message } ` ,
351+ code : 'KIRO_COMPATIBILITY_WARNING' ,
352+ } ) ;
353+ }
354+ }
355+
356+ // Stop deployment if critical compatibility issues exist
357+ if ( compatibilityResult . issues . some ( issue => issue . severity === 'critical' ) ) {
358+ this . performanceMonitor . endDeploymentTiming ( deploymentId ) ;
359+ result . metadata ! . performanceReport = 'Kiro deployment failed - compatibility issues' ;
360+ return result ;
361+ }
362+
363+ // Add recommendations
364+ for ( const recommendation of compatibilityResult . recommendations ) {
365+ result . warnings . push ( {
366+ message : `Recommendation: ${ recommendation } ` ,
367+ code : 'KIRO_RECOMMENDATION' ,
368+ } ) ;
369+ }
370+ }
371+
372+ this . performanceMonitor . recordMemoryUsage ( deploymentId , 'installation-check-end' ) ;
373+
374+ // Step 2: Validate configuration for Kiro platform
313375 this . performanceMonitor . recordMemoryUsage ( deploymentId , 'validation-start' ) ;
314376 const validationResult = await this . validatorService . validateForPlatform (
315377 context ,
@@ -337,15 +399,15 @@ export class DeploymentService {
337399 } ) ) ;
338400 }
339401
340- // Step 2 : Return early for validation-only mode
402+ // Step 3 : Return early for validation-only mode
341403 if ( options . validateOnly ) {
342404 result . success = true ;
343405 result . metadata ! . performanceReport = 'Kiro validation completed successfully' ;
344406 this . performanceMonitor . endDeploymentTiming ( deploymentId ) ;
345407 return result ;
346408 }
347409
348- // Step 3 : Security scan for Kiro components
410+ // Step 4 : Security scan for Kiro components
349411 this . performanceMonitor . recordMemoryUsage ( deploymentId , 'security-start' ) ;
350412
351413 // Transform TaptikContext to Kiro formats for security scanning
@@ -407,7 +469,7 @@ export class DeploymentService {
407469 } ) ;
408470 }
409471
410- // Step 4 : Validate transformation results
472+ // Step 5 : Validate transformation results
411473 const validation = this . kiroTransformer . validateTransformation (
412474 globalSettings ,
413475 projectTransformation . settings
@@ -433,12 +495,12 @@ export class DeploymentService {
433495 } ) ) ) ;
434496 }
435497
436- // Step 5 : Create deployment context
498+ // Step 6 : Create deployment context
437499 const homeDirectory = os . homedir ( ) ;
438500 const projectDirectory = process . cwd ( ) ;
439501 const deploymentContext = this . kiroTransformer . createDeploymentContext ( homeDirectory , projectDirectory ) ;
440502
441- // Step 6 : Apply deployment options filtering
503+ // Step 7 : Apply deployment options filtering
442504 let componentsToProcess = [ 'settings' , 'steering' , 'specs' , 'hooks' , 'agents' , 'templates' ] ;
443505 if ( options . components && options . components . length > 0 ) {
444506 componentsToProcess = options . components . filter ( c => componentsToProcess . includes ( c ) ) ;
@@ -447,7 +509,7 @@ export class DeploymentService {
447509 componentsToProcess = componentsToProcess . filter ( c => ! options . skipComponents ! . includes ( c as ComponentType ) ) ;
448510 }
449511
450- // Step 7 : Prepare deployment result with transformation data
512+ // Step 8 : Prepare deployment result with transformation data
451513 result . success = true ;
452514 result . deployedComponents = componentsToProcess ;
453515 result . summary . filesDeployed = componentsToProcess . length ; // Will be updated when actual file writing is implemented
@@ -485,7 +547,7 @@ export class DeploymentService {
485547 code : 'KIRO_TRANSFORMATION_INFO'
486548 } ) ;
487549
488- // Step 7 : Handle backup strategy
550+ // Step 9 : Handle backup strategy
489551 if ( options . conflictStrategy === 'backup' ) {
490552 try {
491553 const backupPath = await this . createKiroBackup ( ) ;
@@ -503,7 +565,7 @@ export class DeploymentService {
503565 }
504566 }
505567
506- // Step 8 : Return early for dry-run mode
568+ // Step 10 : Return early for dry-run mode
507569 if ( options . dryRun ) {
508570 result . success = true ;
509571 result . warnings . push ( {
@@ -515,7 +577,7 @@ export class DeploymentService {
515577 return result ;
516578 }
517579
518- // Step 9 : Deploy components using component handler
580+ // Step 11 : Deploy components using component handler
519581 const kiroOptions = {
520582 platform : 'kiro-ide' as const ,
521583 conflictStrategy : options . conflictStrategy ,
0 commit comments