Skip to main content

vtcode_core/skills/
mod.rs

1//! # Agent Skills Integration
2//!
3//! Enhanced skills system for VT Code with progressive loading, filesystem discovery,
4//! and strict `SKILL.md` validation.
5//!
6//! ## Features
7//!
8//! - **Progressive Disclosure**: Three-level loading (metadata → instructions → resources)
9//! - **CLI Tool Bridge**: Integrate any command-line tool as a skill
10//! - **Dynamic Discovery**: Auto-discover skills and CLI tools from filesystem
11//! - **Context Management**: Memory-efficient loading with LRU eviction
12//! - **Spec Compliance**: Strict support for the core Agent Skills `SKILL.md` format,
13//!   plus the client-side `disable-model-invocation` catalog filter
14//! - **Tool Integration**: Seamless integration with VT Code's tool registry
15//!
16//! ## Architecture
17//!
18//! ### Three-Level Loading System
19//!
20//! **Level 1: Metadata** (~50 tokens)
21//! - Loaded into the startup catalog unless the skill opts out with
22//!   `disable-model-invocation`
23//! - Name, description, and basic info
24//! - Minimal context overhead
25//!
26//! **Level 2: Instructions** (variable, <5K tokens typical)
27//! - Loaded when skill is first triggered
28//! - SKILL.md body with workflows and guidance
29//! - Context-managed with automatic eviction
30//!
31//! **Level 3: Resources** (on-demand)
32//! - Scripts, templates, reference materials
33//! - Loaded only when specifically requested
34//! - No context overhead when unused
35//!
36//! ### Skill Types
37//!
38//! **Traditional Skills**: Directories with `SKILL.md` files following the Agent Skills spec
39//! **CLI Tool Skills**: Executable tools with README.md documentation
40//! **Hybrid Skills**: Skills that combine instructions with external tool execution
41//!
42//! ## Quick Start
43//!
44//! ```ignore
45//! use vtcode_core::skills::discovery::{SkillDiscovery, DiscoveryConfig};
46//! use vtcode_core::skills::context_manager::{ContextManager, ContextConfig};
47//!
48//! // Configure discovery
49//! let mut discovery = SkillDiscovery::new();
50//! let result = discovery.discover_all(workspace_root).await?;
51//!
52//! // Setup context management
53//! let context_manager = ContextManager::new();
54//!
55//! // Register discovered skills
56//! for skill in result.skills {
57//!     context_manager.register_skill_metadata(skill.manifest().clone())?;
58//! }
59//!
60//! // Load skill on demand
61//! let skill_context = context_manager.get_skill_context("my-skill");
62//! ```
63//!
64//! ## Directory Structure
65//!
66//! ### Traditional Skills
67//! ```text
68//! my-skill/
69//! ├── SKILL.md              # Metadata (YAML) + Instructions (Markdown)
70//! ├── scripts/
71//! │   └── helper.py         # Optional: Executable scripts
72//! ├── references/
73//! │   └── guide.md          # Optional: Reference materials
74//! └── assets/
75//!     └── example.json      # Optional: Static resources
76//! ```
77//!
78//! ### CLI Tool Skills
79//! ```text
80//! my-tool/
81//! ├── tool                  # Executable (any language)
82//! ├── README.md             # Tool documentation
83//! ├── tool.json             # Optional: Configuration
84//! └── schema.json           # Optional: Argument validation
85//! ```
86//!
87//! ### SKILL.md Template
88//! ```yaml
89//! ---
90//! name: my-skill
91//! description: What this skill does and when to use it
92//! ---
93//!
94//! # My Skill
95//!
96//! ## Instructions
97//! [Guidance for the agent]
98//!
99//! ## Examples
100//! - Example 1
101//! - Example 2
102//! ```
103
104pub mod authoring;
105pub mod auto_verification;
106pub mod bundle;
107pub mod cli_bridge;
108pub mod command_skills;
109pub mod container;
110pub mod container_validation;
111pub mod context_manager;
112pub mod discovery;
113pub mod document_processor;
114pub mod enhanced_harness;
115pub mod enhanced_validator;
116pub mod executor;
117pub mod file_references;
118pub mod injection;
119pub mod instructions;
120pub mod loader;
121pub mod locations;
122pub mod manager;
123pub mod manifest;
124pub mod model;
125#[expect(unsafe_code)]
126pub mod native_plugin;
127pub mod prompt_integration;
128pub mod render;
129pub mod skill_file_tracker;
130pub mod streaming;
131pub mod system;
132pub mod templates;
133pub mod types;
134pub mod validation;
135pub mod validation_report;
136pub mod versioning;
137
138pub use authoring::{
139    SkillAuthor, SkillFrontmatter, ValidationReport as AuthoringValidationReport,
140    render_skills_lean,
141};
142pub use bundle::{
143    ImportedSkillInfo, SkillStoreIndex, SkillVersionIndex, export_skill_bundle,
144    import_inline_bundle, import_skill_bundle, load_skill_index,
145};
146pub use cli_bridge::{CliToolBridge, CliToolConfig, CliToolResult, discover_cli_tools};
147pub use command_skills::{
148    BuiltInCommandExecutor, BuiltInCommandSkill, CommandSkillBackend, CommandSkillSpec,
149    built_in_command_skill, built_in_command_skill_contexts, command_skill_specs,
150    find_command_skill_by_skill_name, find_command_skill_by_slash_name,
151};
152pub use container::{
153    SkillContainer, SkillSource as ContainerSkillSource, SkillSpec, SkillType, SkillVersion,
154};
155pub use container_validation::{
156    ContainerSkillsRequirement, ContainerSkillsValidator, ContainerValidationResult,
157    IncompatibleSkillInfo,
158};
159pub use context_manager::{
160    ContextConfig, ContextLevel, ContextManager, ContextStats, PersistentContextManager,
161};
162pub use discovery::{
163    DiscoveryConfig, DiscoveryResult, DiscoveryStats, ProgressiveSkillLoader, SkillDiscovery,
164};
165pub use document_processor::{
166    DocumentMetadata, DocumentProcessor, DocumentProcessorConfig, DocumentType, ProcessedDocument,
167};
168pub use enhanced_validator::ComprehensiveSkillValidator;
169pub use executor::{execute_skill_with_sub_llm, filter_tools_for_skill};
170pub use file_references::FileReferenceValidator;
171pub use instructions::{SKILL_INSTRUCTIONS_PREFIX, SkillInstructions};
172pub use loader::{
173    EnhancedSkill, EnhancedSkillLoader, SkillLoaderConfig, SkillRoot, detect_skill_mentions,
174    discover_skill_metadata_lightweight, load_skill_resources, load_skills,
175};
176pub use native_plugin::{
177    NativePlugin, NativePluginTrait, PLUGIN_ABI_VERSION, PluginContext, PluginLoader,
178    PluginMetadata, PluginResult, validate_plugin_structure,
179};
180
181pub use injection::{SkillInjections, build_skill_injections};
182pub use locations::{
183    DiscoveredSkill, DiscoveryStats as LocationDiscoveryStats, SkillLocation, SkillLocationType,
184    SkillLocations,
185};
186pub use manager::SkillsManager;
187pub use manifest::{SkillYaml, generate_skill_template, parse_skill_content, parse_skill_file};
188pub use model::{SkillErrorInfo, SkillLoadOutcome, SkillMetadata};
189pub use prompt_integration::{
190    SkillsRenderMode, generate_skills_prompt, generate_skills_prompt_with_mode,
191};
192pub use render::render_skills_section;
193pub use streaming::{StreamEvent, StreamingConfig, StreamingExecution, StreamingSkillExecutor};
194
195pub use templates::{
196    SkillTemplate, SkillTemplateBuilder, TemplateEngine, TemplateType, TemplateVariable,
197};
198pub use types::{
199    Skill, SkillContext, SkillManifest, SkillNetworkPolicy, SkillRegistryEntry, SkillResource,
200    SkillScope,
201};
202pub use validation::{SkillValidator, ValidationConfig, ValidationReport, ValidationStatus};
203pub use validation_report::{SkillValidationReport, ValidationIssue, ValidationLevel};
204pub use versioning::{
205    ResolvedSkillRef, SkillLockfile, SkillSource, resolve_default_version, resolve_version,
206};