Skip to content

Add project-local skill discovery - #17328

Open
lonelybeanz wants to merge 1 commit into
NousResearch:mainfrom
lonelybeanz:feat/project-local-skills
Open

Add project-local skill discovery#17328
lonelybeanz wants to merge 1 commit into
NousResearch:mainfrom
lonelybeanz:feat/project-local-skills

Conversation

@lonelybeanz

Copy link
Copy Markdown

PR: Add project-local skill discovery

Title

Add project-local skill discovery

Summary

  • Discover project-local skills from the current git root before global and external skill directories.
  • Support project-scoped skill management with skill_manage(..., scope="project"), writing to <project>/.hermes/skills/.
  • Make skills_list, skill_view, and prompt skill snapshots respect project-local precedence while preserving legacy SKILLS_DIR monkeypatch compatibility.
  • Treat project-local skill roots as trusted in skill_view security checks.
  • Add regression tests for project-local discovery, prompt precedence, and project-scoped skill creation.

Motivation

Project-specific skills should live with the project that owns them instead of permanently polluting the global ~/.hermes/skills/ index and every agent prompt. This change enables repositories to carry their own .hermes/skills/ or .ai/skills/ directories, loaded only when the active working directory belongs to that project.

Implementation Notes

  • agent/skill_utils.py
    • Adds CWD resolution from explicit argument, TERMINAL_CWD, HERMES_CWD, then os.getcwd().
    • Finds the project root via git rev-parse --show-toplevel, falling back to walking parent directories for .git.
    • Adds project skill roots: <git-root>/.hermes/skills and <git-root>/.ai/skills.
    • Orders all skill directories as project-local, global, then configured external dirs.
  • tools/skills_tool.py
    • Uses get_all_skills_dirs() for discovery and view lookup.
    • Keeps a module-level SKILLS_DIR fallback for older tests/callers that monkeypatch it directly.
    • Updates trusted-root checks so active project-local directories do not trigger false security warnings.
  • tools/skill_manager_tool.py
    • Adds scope="global" | "project" for create operations.
    • Allows patch/delete/edit/write-file lookup across both project-local and global roots.
  • agent/prompt_builder.py
    • Builds skill prompt snapshots from the highest-priority active skill root instead of assuming only global/external roots.

Test Plan

Passed locally:

venv/bin/python -m pytest -n 0 tests/tools/test_skills_tool.py tests/tools/test_skill_view_path_check.py tests/tools/test_skill_view_traversal.py tests/tools/test_skill_manager_tool.py tests/agent/test_external_skills.py tests/agent/test_prompt_builder.py tests/agent/test_skill_commands.py tests/tools/test_skill_size_limits.py -q
# 331 passed, 2 skipped in 5.22s

venv/bin/python -m py_compile agent/skill_utils.py agent/prompt_builder.py tools/skills_tool.py tools/skill_manager_tool.py

Also passed a smoke test using temporary HERMES_HOME and temporary git project:

{"created": true, "project_skill_exists": true, "prompt_has_skill": true, "scope": "project", "viewed": true}

Known local note:

  • Full pytest -q in this environment hit Too many open files from the repository's broad parallel/default test behavior, so the relevant skill/prompt test surface was rerun serially with -n 0 and passed.
  • git diff --check returns status 2 with no diagnostic output under this local Git 2.50.1 setup; no whitespace issue was reported.

Commit

5113a4ad2 Add project-local skill discovery

Patch File

/Users/dujiao/.hermes/pr-prep/0001-project-local-skill-discovery.patch

Manual PR Commands

If you have a fork:

cd /Users/dujiao/.hermes/hermes-agent
git remote add fork https://github.com/<your-user>/hermes-agent.git  # if not already added
git push -u fork feat/project-local-skills

Then open:

https://github.com/NousResearch/hermes-agent/compare/main...<your-user>:hermes-agent:feat/project-local-skills?expand=1

If using GitHub CLI after login:

gh auth login
gh repo fork NousResearch/hermes-agent --remote --push --branch feat/project-local-skills
gh pr create --repo NousResearch/hermes-agent --base main --head <your-user>:feat/project-local-skills --title "Add project-local skill discovery" --body-file /Users/dujiao/.hermes/pr-prep/project-local-skills-pr.md

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint tool/skills Skills system (list, view, manage) labels Apr 29, 2026
Comment thread agent/skill_utils.py
"""
root = _find_project_root(cwd)
global_skills = get_skills_dir().resolve()
candidates = [root / ".hermes" / "skills", root / ".ai" / "skills"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
candidates = [root / ".hermes" / "skills", root / ".ai" / "skills"]
candidates = [root / ".hermes" / "skills", root / ".ai" / "skills", root / ".agents" / "skills" ]

Since this is what codex supports as well and seems reasonable

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the project-local discovery work. The feature is still absent on current main, but this branch needs a cache-aware salvage rather than a direct merge.

Problems

  • agent/skill_commands.py:331-341 still scans only the global root plus external_dirs; this PR does not modify it, so project skills will not surface as slash commands.
  • The changed skill_view() search set still reaches the duplicate rejection at tools/skills_tool.py:1182-1204; a project/global name collision is ambiguous rather than project-first.
  • Current main has newer live-profile and discovery-cache behavior in tools/skills_tool.py:692-713 (not present in this April branch), so the root resolution must be integrated without regressing those fixes.

Suggested changes

  • Route every discovery consumer through one ordered, cache-aware root resolver; cover skill_view, slash commands, and gateway menus with project/global collision tests.
  • Resolve the existing review request for .agents/skills if cross-agent interoperability is intended, and document the final root/precedence contract.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) sweeper:blast-broad Sweeper blast radius: broad — a core path most sessions hit labels Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have sweeper:blast-broad Sweeper blast radius: broad — a core path most sessions hit sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades tool/skills Skills system (list, view, manage) type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants