Skip to content

fix(curator): scan nested archive subdirs in restore_skill#17951

Merged
teknium1 merged 1 commit intoNousResearch:mainfrom
0xDevNinja:fix/17942-curator-restore-nested-archive
Apr 30, 2026
Merged

fix(curator): scan nested archive subdirs in restore_skill#17951
teknium1 merged 1 commit intoNousResearch:mainfrom
0xDevNinja:fix/17942-curator-restore-nested-archive

Conversation

@0xDevNinja
Copy link
Copy Markdown
Contributor

What does this PR do?

hermes curator restore <skill> was failing with skill '<name>' not found in archive whenever the archived skill lived under a nested category subdirectory (e.g. .archive/openclaw-imports/<skill>/, .archive/hermes-agent/<skill>/). The skill directory existed on disk but was invisible to the lookup because restore_skill() walked only the top level of .archive/.

tools/skill_usage.py:389,392 used archive_root.iterdir() for both the exact-name and prefix-match candidate scans. Switching both to archive_root.rglob("*") makes the lookup descend into nested subdirs while preserving the existing is_dir() and p.name == skill_name (and prefix) filter, so the scan still picks up only matching skill directories.

Related Issue

Fixes #17942

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • tools/skill_usage.pyrestore_skill(): switched the exact-match and prefix-match candidate scans from archive_root.iterdir() to archive_root.rglob("*") so nested archive subdirectories are searched.
  • tests/tools/test_skill_usage.py — added test_restore_skill_finds_nested_archive_subdir (exact match under a nested category) and test_restore_skill_finds_nested_timestamped_prefix (timestamped-dupe prefix match under a nested category) to lock in the recursive-walk behaviour.

How to Test

  1. Place an archived skill under a nested category, e.g.:
    ~/.hermes/skills/.archive/openclaw-imports/cognitive-empathy/SKILL.md
    
  2. Run hermes curator restore cognitive-empathy — before this patch this returned "not found in archive"; after, the skill is moved back to ~/.hermes/skills/cognitive-empathy/ and its state flips to active.
  3. pytest tests/tools/test_skill_usage.py -q — 37 tests pass (35 prior + 2 new).

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 15 (Darwin 23.2)

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — N/A (no user-visible API change; the docstring on restore_skill already covers behaviour)
  • I've updated cli-config.yaml.example if I added/changed config keys — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guiderglob is pathlib-portable; tests use tmp_path and avoid OS-specific paths
  • I've updated tool descriptions/schemas if I changed tool behavior — N/A

restore_skill() in tools/skill_usage.py used archive_root.iterdir(), which
only walked the top level of .archive/. Skills archived under nested layouts
(e.g. .archive/openclaw-imports/<skill>/ from older archive paths or
external imports) were invisible to both the exact-match and prefix-match
candidate scans, surfacing as a misleading "skill '<name>' not found in
archive" error even though the directory existed on disk.

Switch both candidate scans to archive_root.rglob('*') so the lookup
descends into category subdirectories.

Fixes NousResearch#17942
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have tool/skills Skills system (list, view, manage) labels Apr 30, 2026
@teknium1 teknium1 merged commit 564a649 into NousResearch:main Apr 30, 2026
@0xDevNinja 0xDevNinja deleted the fix/17942-curator-restore-nested-archive branch May 1, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low — cosmetic, nice to have tool/skills Skills system (list, view, manage) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

curator restore: nested archive subdirs not found — restore_skill only scans top-level .archive/

3 participants