Skip to content

Commit 911c5f6

Browse files
feat: pin native Hermes Context Mode integration
1 parent 65849e5 commit 911c5f6

4 files changed

Lines changed: 76 additions & 26 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ searchable without bloating the always-active Hermes skill set.
9393

9494
The in-house [Librarian MCP](https://github.com/CommanderTurtle/librarian) can delegate a focused lookup to a second model
9595
process, search disk-backed context, and return the relevant material to the
96-
calling model. [Retrieval](https://github.com/CommanderTurtle/retrieval), [Codebase Memory MCP](https://github.com/DeusData/codebase-memory-mcp), [Context Mode MCP](https://github.com/CommanderTurtle/context-mode), and the
96+
calling model. [Retrieval](https://github.com/CommanderTurtle/retrieval), [Codebase Memory MCP](https://github.com/DeusData/codebase-memory-mcp), [Context Mode's native Hermes integration](https://github.com/mksglu/context-mode/pull/1010), and the
9797
context-saving integrations are wired alongside [Hermes Workspace](https://github.com/outsourc-e/hermes-workspace) orchestration,
9898
allowing agents to work from task sheets and pursue defined background goals
9999
**without merging** the Odysseus and Hermes agents or their MCP registries.

‎config/ulysses/hermes-stack.json‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
{
1717
"id": "context-mode",
1818
"directory": "context-mode",
19-
"source": "https://github.com/CommanderTurtle/context-mode.git",
20-
"role": "Hermes context protection plugin and MCP"
19+
"source": "https://github.com/ildunari/context-mode.git",
20+
"branch": "feat/hermes-native-support",
21+
"upstream_pr": "https://github.com/mksglu/context-mode/pull/1010",
22+
"role": "Native Hermes context protection plugin and MCP"
2123
},
2224
{
2325
"id": "camofox-mcp",
@@ -53,13 +55,13 @@
5355
]
5456
},
5557
"required_plugins": [
56-
"hermes-context-mode"
58+
"context-mode"
5759
],
5860
"plugin_files": [
5961
{
60-
"id": "hermes-context-mode",
61-
"source": "context-mode/.hermes-plugin",
62-
"files": ["README.md", "__init__.py", "plugin.yaml"]
62+
"id": "context-mode",
63+
"source": "context-mode",
64+
"files": ["__init__.py", "plugin.yaml"]
6365
}
6466
],
6567
"skill_links": [

‎config/ulysses/runtime-management.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,14 @@
181181
"recommended": true,
182182
"hermes_component": "context-mode",
183183
"capability_group": "context",
184-
"role": "Hermes context and archive MCP",
184+
"role": "Native Hermes context protection and archive MCP from PR #1010",
185185
"integration": "context-mode",
186186
"root": "${ULYSSES_MICROSERVICES_ROOT}/context-mode",
187187
"package_json": "package.json",
188188
"env_files": [],
189189
"git_update": true,
190-
"source_url": "https://github.com/CommanderTurtle/context-mode.git",
191-
"source_branch": "main",
190+
"source_url": "https://github.com/ildunari/context-mode.git",
191+
"source_branch": "feat/hermes-native-support",
192192
"build_script": "build",
193193
"bun_install_mode": "frozen",
194194
"hermes_mcp": true,

‎src/diogenes_dependency_integration.py‎

Lines changed: 64 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ def _git_revision(root: Path) -> str:
115115
SOURCE_ARTIFACTS: dict[str, tuple[str, ...]] = {
116116
"context.mode.mcp": (
117117
"server.bundle.mjs",
118-
".hermes-plugin/README.md",
119-
".hermes-plugin/__init__.py",
120-
".hermes-plugin/plugin.yaml",
118+
"cli.bundle.mjs",
119+
"__init__.py",
120+
"plugin.yaml",
121121
"skills/context-mode/SKILL.md",
122122
"skills/ctx-doctor/SKILL.md",
123123
"skills/ctx-index/SKILL.md",
@@ -390,7 +390,7 @@ def _ensure_mcp(profile: str, name: str, expected: dict[str, Any]) -> None:
390390
_hermes(profile, "mcp", "test", name, timeout=240)
391391

392392

393-
def _mcp_contract(name: str) -> dict[str, Any]:
393+
def _mcp_contract(name: str, profile: str = "default") -> dict[str, Any]:
394394
services = _services_root()
395395
bun = Path.home() / ".bun" / "bin" / "bun"
396396
if not bun.is_file():
@@ -399,6 +399,10 @@ def _mcp_contract(name: str) -> dict[str, Any]:
399399
"context-mode": {
400400
"command": str(bun),
401401
"args": [str(services / "context-mode" / "server.bundle.mjs")],
402+
"env": {
403+
"CONTEXT_MODE_PLATFORM": "hermes",
404+
"HERMES_HOME": str(_profile_home(profile)),
405+
},
402406
"enabled": True,
403407
},
404408
"camofox-mcp": {
@@ -561,9 +565,8 @@ def _mcp_current(profile: str, name: str, expected: dict[str, Any]) -> bool:
561565

562566

563567
def _ensure_shared_mcp(name: str) -> None:
564-
expected = _mcp_contract(name)
565568
for profile in _shared_profiles():
566-
_ensure_mcp(profile, name, expected)
569+
_ensure_mcp(profile, name, _mcp_contract(name, profile))
567570

568571

569572
def _links_for_integration(integration: str) -> list[dict[str, Any]]:
@@ -625,10 +628,13 @@ def _ensure_skill_links(integration: str) -> None:
625628

626629

627630
def _context_plugin_current() -> bool:
628-
source_root = _services_root() / "context-mode" / ".hermes-plugin"
631+
source_root = _services_root() / "context-mode"
629632
for profile in _shared_profiles():
630-
target_root = _profile_home(profile) / "plugins" / "hermes-context-mode"
631-
for filename in ("README.md", "__init__.py", "plugin.yaml"):
633+
enabled = _read_config_value(profile, "plugins.enabled")
634+
if not isinstance(enabled, list) or "context-mode" not in enabled:
635+
return False
636+
target_root = _profile_home(profile) / "plugins" / "context-mode"
637+
for filename in ("__init__.py", "plugin.yaml"):
632638
try:
633639
if (target_root / filename).read_bytes() != (
634640
source_root / filename
@@ -639,12 +645,52 @@ def _context_plugin_current() -> bool:
639645
return True
640646

641647

648+
def _context_cli_current() -> bool:
649+
source = (_services_root() / "context-mode" / "cli.bundle.mjs").resolve()
650+
target = Path.home() / ".local" / "bin" / "context-mode"
651+
try:
652+
return bool(
653+
source.is_file()
654+
and os.access(source, os.X_OK)
655+
and target.is_symlink()
656+
and target.resolve(strict=True) == source
657+
)
658+
except OSError:
659+
return False
660+
661+
662+
def _ensure_context_cli() -> None:
663+
source = (_services_root() / "context-mode" / "cli.bundle.mjs").resolve()
664+
if not source.is_file():
665+
raise IntegrationError(f"context-mode CLI bundle is missing: {source}")
666+
source.chmod(source.stat().st_mode | 0o100)
667+
target = Path.home() / ".local" / "bin" / "context-mode"
668+
target.parent.mkdir(parents=True, exist_ok=True)
669+
if target.is_symlink():
670+
if target.resolve(strict=False) == source:
671+
return
672+
raise IntegrationError(
673+
f"context-mode CLI link belongs to another source: {target}"
674+
)
675+
if target.exists():
676+
raise IntegrationError(
677+
f"context-mode CLI target exists and is not integration-owned: {target}"
678+
)
679+
target.symlink_to(source)
680+
print(f"Context Mode CLI: linked {target} -> {source}.")
681+
682+
642683
def _ensure_context_plugin_files() -> None:
643-
source_root = _services_root() / "context-mode" / ".hermes-plugin"
684+
source_root = _services_root() / "context-mode"
644685
for profile in _shared_profiles():
645-
target_root = _profile_home(profile) / "plugins" / "hermes-context-mode"
686+
legacy_root = _profile_home(profile) / "plugins" / "hermes-context-mode"
687+
if legacy_root.is_dir():
688+
_hermes(profile, "plugins", "disable", "hermes-context-mode")
689+
_hermes(profile, "plugins", "remove", "hermes-context-mode")
690+
print(f"Hermes {profile} retired context-mode plugin: removed.")
691+
target_root = _profile_home(profile) / "plugins" / "context-mode"
646692
target_root.mkdir(parents=True, exist_ok=True)
647-
for filename in ("README.md", "__init__.py", "plugin.yaml"):
693+
for filename in ("__init__.py", "plugin.yaml"):
648694
source = source_root / filename
649695
if not source.is_file():
650696
raise IntegrationError(f"context-mode plugin file is missing: {source}")
@@ -879,14 +925,15 @@ def _integrate_retrieval() -> None:
879925

880926

881927
def _integrate_context_mode() -> None:
928+
_ensure_context_cli()
882929
_ensure_shared_mcp("context-mode")
883930
_ensure_context_plugin_files()
884931
for profile in _shared_profiles():
885932
_hermes(
886933
profile,
887934
"plugins",
888935
"enable",
889-
"hermes-context-mode",
936+
"context-mode",
890937
"--allow-tool-override",
891938
)
892939
_ensure_skill_links("context-mode")
@@ -1203,17 +1250,18 @@ def _contract_current(
12031250
"retrieval": "retrieval",
12041251
"codebase-memory": "codebase-memory-mcp",
12051252
}[integration]
1206-
expected = _mcp_contract(mcp_name)
12071253
if not all(
1208-
_mcp_current(profile, mcp_name, expected)
1254+
_mcp_current(profile, mcp_name, _mcp_contract(mcp_name, profile))
12091255
for profile in _shared_profiles()
12101256
):
12111257
return False
12121258
if integration in {"context-mode", "camofox-mcp"} and not _skill_links_current(
12131259
integration
12141260
):
12151261
return False
1216-
if integration == "context-mode" and not _context_plugin_current():
1262+
if integration == "context-mode" and not (
1263+
_context_cli_current() and _context_plugin_current()
1264+
):
12171265
return False
12181266
if integration == "retrieval" and not _retrieval_watcher_current():
12191267
return False

0 commit comments

Comments
 (0)