Coverage for src/lexigram/ai/cli/contributor.py: 100%

20 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-25 07:19 +0800

1"""AI CLI contributor definitions.""" 

2 

3from __future__ import annotations 

4 

5from lexigram.contracts.cli.contributions import ( 

6 CommandContribution, 

7 DoctorCheckContribution, 

8 HealthCheckContribution, 

9 ShellContextContribution, 

10) 

11from lexigram.contracts.cli.types import GeneratorDefinition 

12 

13 

14class AICliContributor: 

15 """CLI contributor for the lexigram-ai package.""" 

16 

17 @property 

18 def contributor_id(self) -> str: 

19 """Return the contributor identifier.""" 

20 return "ai" 

21 

22 def get_generators(self) -> list[GeneratorDefinition]: 

23 """Return no generator definitions.""" 

24 return [] 

25 

26 def get_commands(self) -> list[CommandContribution]: 

27 """Return the contributed `ai` command group.""" 

28 return [ 

29 CommandContribution( 

30 name="ai", 

31 help="AI subsystem management commands", 

32 app_factory_path="lexigram.ai.cli.commands:create_ai_app", 

33 contributor="ai", 

34 category="ai", 

35 requires_app_context=True, 

36 ), 

37 ] 

38 

39 def get_health_checks(self) -> list[HealthCheckContribution]: 

40 """Return AI provider and subsystem health checks.""" 

41 return [ 

42 HealthCheckContribution( 

43 name="ai_llm_provider", 

44 description="Check that an LLM provider is reachable", 

45 check_path="lexigram.ai.cli.checks:check_llm_provider", 

46 contributor="ai", 

47 category="ai", 

48 timeout=15.0, 

49 ), 

50 HealthCheckContribution( 

51 name="ai_subsystem_discovery", 

52 description="Check that AI subsystems are discoverable via entry points", 

53 check_path="lexigram.ai.cli.checks:check_subsystem_discovery", 

54 contributor="ai", 

55 category="ai", 

56 timeout=5.0, 

57 ), 

58 ] 

59 

60 def get_doctor_checks(self) -> list[DoctorCheckContribution]: 

61 """Return AI API key doctor checks.""" 

62 return [ 

63 DoctorCheckContribution( 

64 name="ai_api_keys_configured", 

65 description="Check that at least one AI API key is configured", 

66 check_path="lexigram.ai.cli.doctor:check_ai_api_keys", 

67 contributor="ai", 

68 category="ai", 

69 ), 

70 ] 

71 

72 def get_shell_context(self) -> list[ShellContextContribution]: 

73 """Return AI client shell context.""" 

74 return [ 

75 ShellContextContribution( 

76 name="ai", 

77 description="AI client for interactive AI exploration", 

78 factory_path="lexigram.ai.cli.shell:provide_ai_client", 

79 contributor="ai", 

80 ), 

81 ] 

82 

83 def get_hooks(self) -> list: 

84 """Return no hook contributions.""" 

85 return [] 

86 

87 

88__all__ = ["AICliContributor"]