fix: skills module audit cleanup (#173)

* fix: skills module audit cleanup — deduplicate loading, async gating, pre-compute scoring fields

Address 7 issues from the skills module audit (#157–#163):

- Extract shared `load_and_validate_skill` helper, eliminating ~90 lines
  of duplication between `load_skill_md` and `load_skill_md_standalone`
- Wrap blocking gating subprocess calls (`which`/`where`) in
  `tokio::task::spawn_blocking` to avoid blocking the async runtime
- Remove dead `SkillParseError::FileTooLarge` and `SkillSource::Registry`
- Replace `HashMap<String, ()>` with `HashSet<String>` in discovery
- Fix misleading doc comment and unnecessary `ref` clone pattern
- Use `CARGO_PKG_VERSION` for catalog HTTP user-agent instead of
  hardcoded "0.1"
- Pre-compute lowercased keywords/tags at load time to avoid
  per-message allocation in the scoring hot path
- Add tests for flat SKILL.md layout, mixed layouts, and lowercased
  field population

Closes #157, closes #158, closes #159, closes #160, closes #161,
closes #162, closes #163

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix: address PR #173 review feedback

- Distinguish cancel vs panic in spawn_blocking JoinError and include
  error details in the gating failure message (Copilot review)
- Restore lowercased_keywords/lowercased_tags to `pub` for consistency
  with other LoadedSkill fields (Copilot review)

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>
This commit is contained in:
Illia Polosukhin
2026-02-18 05:56:00 +00:00
committed by GitHub
co-authored by Claude Opus 4.6
parent a1b0e34b3b
commit c1926c83d9
7 changed files with 176 additions and 147 deletions
-3
View File
@@ -19,9 +19,6 @@ pub enum SkillParseError {
#[error("Invalid skill name '{name}': must match [a-zA-Z0-9][a-zA-Z0-9._-]{{0,63}}")]
InvalidName { name: String },
#[error("SKILL.md too large: {size} bytes (max {max} bytes)")]
FileTooLarge { size: u64, max: u64 },
}
/// Result of parsing a SKILL.md file.