feat: implement Agent Skills specification support

Implements the Agent Skills specification (https://agentskills.io) for
portable skill packages that give the agent new capabilities.

Changes:
- Add skills module with SKILL.md parser (YAML frontmatter + markdown body)
- Implement skill discovery from ~/.g3/skills/, config extra_paths, and .g3/skills/
- Generate <available_skills> XML for system prompt injection
- Add SkillsConfig to g3-config with enabled flag and extra_paths
- Wire skills discovery into CLI startup
- Add 29 unit tests for parser, discovery, and prompt generation
- Update README with Agent Skills documentation

Skill locations (priority order):
1. ~/.g3/skills/ (global)
2. Config extra_paths
3. .g3/skills/ (workspace, highest priority)

At startup, g3 scans skill directories and injects a summary into the
system prompt. When the agent needs a skill, it reads the full SKILL.md
using the read_file tool.
This commit is contained in:
Dhanji R. Prasanna
2026-02-04 12:58:57 +11:00
parent 95d9847354
commit a5f6475603
12 changed files with 1072 additions and 15 deletions

View File

@@ -0,0 +1,42 @@
//! Agent Skills support for G3.
//!
//! Implements the Agent Skills specification (https://agentskills.io)
//! for discovering and using portable skill packages.
//!
//! # Overview
//!
//! Skills are packages of instructions that give the agent new capabilities.
//! Each skill is a directory containing a `SKILL.md` file with:
//! - YAML frontmatter (name, description, metadata)
//! - Markdown body with detailed instructions
//!
//! # Directory Structure
//!
//! ```text
//! skill-name/
//! ├── SKILL.md # Required: instructions + metadata
//! ├── scripts/ # Optional: executable code
//! ├── references/ # Optional: additional documentation
//! └── assets/ # Optional: templates, data files
//! ```
//!
//! # Discovery
//!
//! Skills are discovered from:
//! 1. Global: `~/.g3/skills/` (lowest priority)
//! 2. Extra paths from config (medium priority)
//! 3. Workspace: `.g3/skills/` (highest priority, overrides others)
//!
//! # Usage
//!
//! At startup, g3 scans skill directories and injects a summary into the
//! system prompt. When the agent needs a skill, it reads the full SKILL.md
//! using the `read_file` tool.
mod parser;
mod discovery;
mod prompt;
pub use parser::Skill;
pub use discovery::discover_skills;
pub use prompt::generate_skills_prompt;