Coverage for sources/agentsmgr/results.py: 43%

50 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-10-28 17:44 +0000

1# vim: set filetype=python fileencoding=utf-8: 

2# -*- coding: utf-8 -*- 

3 

4#============================================================================# 

5# # 

6# Licensed under the Apache License, Version 2.0 (the "License"); # 

7# you may not use this file except in compliance with the License. # 

8# You may obtain a copy of the License at # 

9# # 

10# http://www.apache.org/licenses/LICENSE-2.0 # 

11# # 

12# Unless required by applicable law or agreed to in writing, software # 

13# distributed under the License is distributed on an "AS IS" BASIS, # 

14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # 

15# See the License for the specific language governing permissions and # 

16# limitations under the License. # 

17# # 

18#============================================================================# 

19 

20 

21''' Result objects for CLI command outputs with Markdown rendering. ''' 

22 

23 

24from . import __ 

25 

26 

27class ResultBase( __.immut.DataclassObject ): 

28 ''' Base protocol for command result objects with rendering capability. ''' 

29 

30 @__.abc.abstractmethod 

31 def render_as_markdown( self ) -> tuple[ str, ... ]: 

32 ''' Renders result as Markdown lines for display. ''' 

33 raise NotImplementedError 

34 

35 

36class ConfigurationDetectionResult( ResultBase ): 

37 ''' Agent configuration detection result with formatted output. ''' 

38 

39 target: __.Path 

40 coders: tuple[ str, ... ] 

41 languages: tuple[ str, ... ] 

42 project_name: __.typx.Optional[ str ] = None 

43 

44 def render_as_markdown( self ) -> tuple[ str, ... ]: 

45 ''' Renders configuration detection as Markdown lines. ''' 

46 lines = [ '🔍 Agent Configuration Detected:' ] 

47 lines.append( f" Coders: {', '.join( self.coders )}" ) 

48 lines.append( f" Languages: {', '.join( self.languages )}" ) 

49 if self.project_name: 

50 lines.append( f" Project: {self.project_name}" ) 

51 lines.append( f" Target Directory: {self.target.resolve( )}" ) 

52 return tuple( lines ) 

53 

54 

55class ContentGenerationResult( ResultBase ): 

56 ''' Agent content generation result with formatted summary. ''' 

57 

58 source_location: __.Path 

59 target_location: __.Path 

60 coders: tuple[ str, ... ] 

61 simulated: bool 

62 items_generated: int = 0 

63 

64 def render_as_markdown( self ) -> tuple[ str, ... ]: 

65 ''' Renders content generation results as Markdown lines. ''' 

66 lines = [ f"🚀 Populating agent content (simulate={self.simulated}):" ] 

67 lines.append( f" Source: {self.source_location}" ) 

68 lines.append( f" Target: {self.target_location.resolve( )}" ) 

69 lines.append( f" Coders: {', '.join( self.coders )}" ) 

70 lines.append( '' ) 

71 lines.append( f" Generated {self.items_generated} items" ) 

72 lines.append( '' ) 

73 if self.simulated: 

74 lines.append( 

75 "✅ Simulation complete. Use --no-simulate to write." ) 

76 else: 

77 lines.append( "✅ Content generation complete." ) 

78 return tuple( lines ) 

79 

80 

81class ValidationResult( ResultBase ): 

82 ''' Template validation result with formatted summary. ''' 

83 

84 variant: str 

85 temporary_directory: __.Path 

86 items_attempted: int 

87 items_generated: int 

88 preserved: bool 

89 

90 def render_as_markdown( self ) -> tuple[ str, ... ]: 

91 ''' Renders validation results as Markdown lines. ''' 

92 lines = [ f"✅ Validation complete for '{self.variant}' variant:" ] 

93 lines.append( f" Temporary Directory: {self.temporary_directory}" ) 

94 lines.append( 

95 f" Items: {self.items_generated}/{self.items_attempted} " 

96 "generated" ) 

97 if self.preserved: 

98 lines.append( 

99 f" 📁 Files preserved for inspection at: " 

100 f"{self.temporary_directory}" ) 

101 else: 

102 lines.append( " 🗑️ Temporary files cleaned up" ) 

103 return tuple( lines )