Coverage for /home/admin/Documents/AI/applications/lexigram-dev/lexigram/experimental/ai/lexigram-ai-skills/src/lexigram/ai/skills/config.py: 100%
28 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-25 07:19 +0800
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-25 07:19 +0800
1"""Configuration for the lexigram-ai-skills package."""
3from __future__ import annotations
5from typing import ClassVar, cast
7from lexigram.ai.skills import constants as const
8from lexigram.config.base import BaseConfig
9from lexigram.validation import ConfigDict, Field
11ENV_PREFIX: str = const.ENV_PREFIX
14class SkillsConfig(BaseConfig):
15 """Configuration for the skills subsystem.
17 Controls execution defaults, caching behaviour, permission enforcement,
18 auto-discovery settings, and which built-in skills are enabled.
20 Attributes:
21 name: Logical name used for DI registration keys.
22 default_timeout_seconds: Default execution timeout per skill.
23 max_retries: Default maximum retry attempts for skill execution.
24 max_concurrent_executions: Semaphore cap on concurrent executions.
25 cache_enabled: Whether result caching is globally enabled.
26 cache_ttl_seconds: Default TTL for cached skill results.
27 cache_backend: Which cache backend to use (``in_memory``, ``cache``).
28 enforce_permissions: Whether permission checks are enforced.
29 auto_discover: Whether to auto-scan packages on boot.
30 scan_packages: Fully-qualified package names to scan for skills.
31 enable_builtin: Whether built-in skills are registered on boot.
32 builtin_skills: Names of built-in skills to register.
33 """
35 config_section: ClassVar[str] = "ai_skills"
37 model_config: ClassVar[ConfigDict] = cast(
38 "ConfigDict",
39 {
40 "env_prefix": const.ENV_PREFIX,
41 "env_nested_delimiter": const.ENV_NESTED_DELIMITER,
42 "extra": "ignore",
43 },
44 )
46 name: str = Field(
47 default="ai-skills", description="Logical name used for DI registration keys"
48 )
50 # Execution
51 default_timeout_seconds: float = Field(
52 default=const.DEFAULT_TIMEOUT_S,
53 gt=0.0,
54 description="Default execution timeout per skill (seconds)",
55 )
56 max_retries: int = Field(
57 default=const.DEFAULT_MAX_RETRIES,
58 ge=0,
59 description="Default maximum retry attempts for skill execution",
60 )
61 max_concurrent_executions: int = Field(
62 default=const.DEFAULT_MAX_CONCURRENT,
63 ge=1,
64 description="Semaphore cap on concurrent skill executions",
65 )
67 # Caching
68 cache_enabled: bool = Field(
69 default=const.DEFAULT_CACHE_ENABLED,
70 description="Whether result caching is globally enabled",
71 )
72 cache_ttl_seconds: int = Field(
73 default=const.DEFAULT_CACHE_TTL_S,
74 ge=1,
75 description="Default TTL for cached skill results (seconds)",
76 )
77 cache_backend: str = Field(
78 default=const.DEFAULT_CACHE_BACKEND,
79 description="Which cache backend to use (in_memory, cache)",
80 )
82 # Permissions
83 enforce_permissions: bool = Field(
84 default=const.DEFAULT_ENFORCE_PERMISSIONS,
85 description="Whether permission checks are enforced",
86 )
88 # Discovery
89 auto_discover: bool = Field(
90 default=const.DEFAULT_AUTO_DISCOVER,
91 description="Whether to auto-scan packages for skills on boot",
92 )
93 scan_packages: list[str] = Field(
94 default_factory=list,
95 description="Fully-qualified package names to scan for skills",
96 )
98 # Built-in skills
99 enable_builtin: bool = Field(
100 default=const.DEFAULT_ENABLE_BUILTIN,
101 description="Whether built-in skills are registered on boot",
102 )
103 builtin_skills: list[str] = Field(
104 default_factory=lambda: list(const.DEFAULT_BUILTIN_SKILLS),
105 description="Names of built-in skills to register",
106 )
108 # --- Skill Sources (SKILL.md, .mdc, etc.) ---
109 enable_skill_sources: bool = Field(
110 default=True,
111 description="Whether to scan for external skill sources on boot",
112 )
113 skill_paths: list[str] = Field(
114 default_factory=lambda: list(const.DEFAULT_SKILL_PATHS),
115 description="Paths to scan for skills (SKILL.md folders)",
116 )
117 enabled_directories: list[str] = Field(
118 default_factory=lambda: list(const.DEFAULT_SKILL_DIRECTORIES.keys()),
119 description="Which skill directories to enable (claude_code, opencode, cursor, etc.)",
120 )
122 # --- Script Execution ---
123 script_timeout_seconds: int = Field(
124 default=const.DEFAULT_SCRIPT_TIMEOUT_SECONDS,
125 gt=0,
126 description="Timeout for skill script execution (seconds)",
127 )
128 allowed_script_types: list[str] = Field(
129 default_factory=lambda: list(const.DEFAULT_ALLOWED_SCRIPT_TYPES),
130 description="Allowed script types (py, sh, js)",
131 )
133 # --- Progressive Disclosure ---
134 lazy_load_context: bool = Field(
135 default=const.DEFAULT_LAZY_LOAD_CONTEXT,
136 description="Whether to lazily load skill context files",
137 )
140__all__ = ["ENV_PREFIX", "SkillsConfig"]