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

@@ -1,5 +1,5 @@
# Workspace Memory
> Updated: 2026-02-02T03:53:06Z | Size: 16.9k chars
> Updated: 2026-02-04T01:34:05Z | Size: 18.9k chars
### Remember Tool Wiring
- `crates/g3-core/src/tools/memory.rs` [0..5000] - `execute_remember()`, `get_memory_path()`, `merge_memory()`
@@ -314,4 +314,49 @@ Verifies evidence in completed plan items deterministically.
- Code location file only: `src/foo.rs`
- Test reference: `tests/foo.rs::test_bar`
**Integration:** Called from `execute_plan_write()` when plan is complete and approved (line 828-833)
**Integration:** Called from `execute_plan_write()` when plan is complete and approved (line 828-833)
### Agent Skills Support
Implements the Agent Skills specification (https://agentskills.io) for portable skill packages.
- `crates/g3-core/src/skills/mod.rs` [0..42] - module exports: `Skill`, `discover_skills`, `generate_skills_prompt`
- `crates/g3-core/src/skills/parser.rs` [0..363]
- `Skill` [11..30] - parsed skill struct with name, description, metadata, body, path
- `Skill::parse()` [45..100] - parses SKILL.md content with YAML frontmatter
- `Skill::from_file()` [95..105] - loads and parses from disk
- `split_frontmatter()` [107..130] - extracts YAML between `---` delimiters
- `validate_name()` [133..175] - validates 1-64 chars, lowercase+hyphens
- `crates/g3-core/src/skills/discovery.rs` [0..268]
- `discover_skills()` [28..65] - scans global, extra, workspace dirs in priority order
- `load_skills_from_dir()` [68..100] - loads SKILL.md from subdirectories
- `expand_tilde()` [120..125] - uses shellexpand for path expansion
- `crates/g3-core/src/skills/prompt.rs` [0..140]
- `generate_skills_prompt()` [12..40] - generates `<available_skills>` XML block
- `escape_xml()` [42..48] - escapes special XML characters
- `crates/g3-config/src/lib.rs`
- `SkillsConfig` [180..200] - enabled flag, extra_paths vector
- Config.skills field [13..14]
- `crates/g3-cli/src/project_files.rs`
- `discover_and_format_skills()` [180..210] - discovers skills and generates prompt section
- `combine_project_content()` [87..110] - now includes skills_content parameter
**Skill Locations** (priority order):
1. `~/.g3/skills/` (global)
2. Config extra_paths
3. `.g3/skills/` (workspace, highest priority)
**SKILL.md Format**:
```yaml
---
name: skill-name # Required: 1-64 chars, lowercase + hyphens
description: What it does # Required: 1-1024 chars
license: Apache-2.0 # Optional
compatibility: Requires X # Optional: max 500 chars
metadata: # Optional: arbitrary key-value
author: org
allowed-tools: Bash Read # Optional/experimental
---
# Skill Title
Detailed instructions...
```