81d4467052
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
23 lines
690 B
Python
23 lines
690 B
Python
from unittest.mock import MagicMock, patch
|
|
|
|
|
|
class TestWorkspaceCLICommand:
|
|
def _make_cli(self):
|
|
from cli import HermesCLI
|
|
|
|
cli = HermesCLI.__new__(HermesCLI)
|
|
cli.config = {"quick_commands": {}}
|
|
cli.console = MagicMock()
|
|
cli.agent = None
|
|
cli.conversation_history = []
|
|
return cli
|
|
|
|
def test_process_command_dispatches_workspace_handler(self):
|
|
cli = self._make_cli()
|
|
|
|
with patch("hermes_cli.workspace.handle_workspace_slash") as handler:
|
|
result = cli.process_command("/workspace status")
|
|
|
|
assert result is True
|
|
handler.assert_called_once_with("/workspace status", console=cli.console)
|