Commit Graph

1 Commits

Author SHA1 Message Date
Teknium 81d4467052 feat: add workspace foundation and RAG retrieval system
Port and modernize PR #1324 onto current main with full profile/HERMES_HOME awareness.

New files:
- agent/workspace.py: Core workspace engine — path resolution, manifest generation,
  structural chunking (markdown heading-aware, code symbol-aware), chunk indexing
  into SQLite, hybrid retrieval (FTS5 sparse + dense embeddings via RRF), optional
  reranking (local cross-encoder, Cohere, Voyage, heuristic fallback), workspace
  roots management, turn-scoped context injection
- tools/workspace_tool.py: Model-facing workspace tool (status/index/list/search/retrieve)
- hermes_cli/workspace.py: CLI subcommands and /workspace slash command handler

Integration points:
- config.py: workspace and knowledgebase sections in DEFAULT_CONFIG, workspace/
  knowledgebase dirs in ensure_hermes_home(), config version bump to 13
- toolsets.py: workspace tool added to _HERMES_CORE_TOOLS
- model_tools.py: workspace_tool added to _discover_tools()
- commands.py: /workspace CommandDef with subcommands
- cli.py: /workspace slash command dispatch
- run_agent.py: turn-scoped workspace RAG context injection (cache-safe —
  appended to current-turn user message only, never touches system prompt)
- hermes_cli/main.py: hermes workspace subcommand tree
  (status/index/list/search/retrieve/roots)
- hermes_cli/banner.py: workspace roots visibility in welcome banner
- pyproject.toml: workspace-rag optional dependency group

Profile-aware: all paths use get_hermes_home() from hermes_constants,
never hardcoded ~/.hermes. Each profile gets its own workspace/ and
knowledgebase/ directories.

Retrieval modes: off (default), gated (heuristic trigger), always.
Embedding: local SentenceTransformers when installed, hash fallback otherwise.
Dense search: sqlite-vec acceleration when installed, Python cosine fallback.

Tests: 18 new workspace-specific tests, all passing.
Original PR: #1324 by @teknium1
2026-04-06 12:55:18 -07:00