Skip to content

feat(agent): .hermes.md per-repository project config#1200

Closed
ch3ronsa wants to merge 1 commit intoNousResearch:mainfrom
ch3ronsa:feat/hermes-md-config
Closed

feat(agent): .hermes.md per-repository project config#1200
ch3ronsa wants to merge 1 commit intoNousResearch:mainfrom
ch3ronsa:feat/hermes-md-config

Conversation

@ch3ronsa
Copy link
Contributor

Summary

Adds .hermes.md / HERMES.md per-repository project configuration — the #1 most requested UX pattern from the competitor analysis in #681. Every major AI coding agent has this (Claude Code's CLAUDE.md, Cursor's .cursorrules, Windsurf's .windsurfrules). Hermes now has it too.

When the agent starts a session, it discovers the nearest .hermes.md and injects its contents into the system prompt as project context — eliminating the need to re-explain project conventions every session.

How it works

my-project/
  .git/
  .hermes.md          ← discovered and loaded
  src/
    components/       ← agent started here, walks up to git root

Example .hermes.md:

---
model: claude-sonnet-4-20250514
tools:
  disabled: [tts]
---

# My Project

## Code Style
- Use TypeScript strict mode
- Prefer functional components with hooks

## Testing
- Run tests with `npm test`
- Minimum 80% coverage for new code

Changes

Modified: agent/prompt_builder.py — 3 new helper functions + integration into build_context_files_prompt()

Function Purpose
_find_hermes_md(cwd) Walk CWD → git root, return nearest .hermes.md or HERMES.md
_find_git_root(start) Locate repo boundary (stops parent-dir walking)
_strip_yaml_frontmatter(content) Remove --- delimited YAML block (structured config for future PR)

Modified: tests/agent/test_prompt_builder.py — 22 new tests

Design decisions

  • Extends existing build_context_files_prompt() — same pattern as AGENTS.md and .cursorrules discovery. No new code paths.
  • .hermes.md preferred over HERMES.md — dotfile convention (hidden by default), uppercase as fallback
  • Nearest-first discovery — walks CWD → parent dirs → stops at git root. Subdirectory configs shadow parent configs.
  • YAML frontmatter stripped — body-only injection into system prompt. Structured config (model/tools overrides) deferred to Phase 2.
  • Injection scanner applied — same _scan_context_content() protection as all other context files
  • 20K char truncation — same _truncate_content() limit as AGENTS.md

Scope (Phase 1)

This PR covers discovery & injection only. Future PRs can add:

  • Frontmatter parsing for model/tool overrides
  • .hermesignore for file/dir exclusion
  • /project slash command to view/reload config
  • Nested config merging (subdirectory extends parent)

Test plan

  • 22 new tests (all passing), covering:
    • .hermes.md and HERMES.md discovery
    • Lowercase priority over uppercase
    • Parent directory walking up to git root
    • Stops at git root boundary (no leaking)
    • YAML frontmatter stripping
    • Injection blocking (prompt injection patterns)
    • Coexistence with AGENTS.md, .cursorrules, SOUL.md
    • Helper functions: _find_hermes_md, _find_git_root, _strip_yaml_frontmatter
  • All 52 existing + new tests pass
  • Manual: create .hermes.md in a repo, run hermes chat, verify rules appear in context

Closes #681 (Phase 1)

Add support for `.hermes.md` / `HERMES.md` project configuration files
that define per-repository rules and context for the agent — similar to
CLAUDE.md in Claude Code and .cursorrules in Cursor.

Discovery walks from CWD up to the git root, loading the nearest match.
YAML frontmatter is stripped (body only is injected into the system
prompt). Content passes through the existing injection scanner.

New helpers:
- _find_hermes_md() — nearest-first upward discovery
- _find_git_root() — locate repo boundary
- _strip_yaml_frontmatter() — remove structured config block

22 new tests covering discovery, priority, parent walking, git root
boundary, frontmatter stripping, injection blocking, and coexistence
with AGENTS.md/.cursorrules/SOUL.md.

Closes NousResearch#681 (Phase 1 — discovery & injection)
@teknium1
Copy link
Contributor

Merged via PR #1712. Your .hermes.md discovery implementation was cherry-picked onto current main with authorship preserved — all 22 tests pass cleanly. Great work on the design (nearest-first discovery, git root boundary, YAML frontmatter stripping, injection scanning). Phase 2 (frontmatter parsing for model/tool overrides) can follow up separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: .hermes.md Project Config — Per-Repository Agent Rules & Context

2 participants