Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge upstream/master into step1
  • Loading branch information
Alanxtl committed Aug 27, 2026
commit 7193f82d59246b8720d83c5a0d4feee971bfe485
2 changes: 1 addition & 1 deletion integrations/hermes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ With Hermes installed and available on `PATH`, install or refresh the provider
from the matching PowerContext release tag:

```bash
powercontext setup hermes --source oceanbase/powercontext --ref latest
powercontext setup hermes --source oceanbase/powercontext --ref master
```

The command copies the exclusive memory provider to
Expand Down
2 changes: 1 addition & 1 deletion integrations/hermes/plugins/powercontext-command/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The companion is installed alongside
[`plugins/powercontext`](../powercontext/README.md) by:

```bash
powercontext setup hermes --source oceanbase/powercontext --ref latest
powercontext setup hermes --source oceanbase/powercontext --ref master
```

It requires Hermes Agent v0.20.4 or newer. The companion does not provide
Expand Down
2 changes: 1 addition & 1 deletion integrations/hermes/plugins/powercontext/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ provider configuration is read from `$HERMES_HOME/powercontext/config.json`.
To install or refresh the provider from a matching PowerContext release tag:

```bash
powercontext setup hermes --source oceanbase/powercontext --ref latest
powercontext setup hermes --source oceanbase/powercontext --ref master
powercontext doctor hermes
```

Expand Down
1 change: 1 addition & 0 deletions integrations/hermes/plugins/powercontext/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ def workstream_command(provider: Any, args: list[str]) -> str:
if action == "clear":
cleared = clear_scope(provider._workstream_cwd)
provider._workstream_bound_scope = ""
provider._switch_workstream_scope(provider._default_scope_id)
provider._record_trace_event("workstream_cleared", cleared=cleared)
return json.dumps({"status": "cleared" if cleared else "not_found"}, ensure_ascii=False, indent=2)
return "Usage: /pc workstream {status|bind SCOPE_ID|clear}"
Expand Down
16 changes: 9 additions & 7 deletions integrations/hermes/plugins/powercontext/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def __init__(self, config: dict[str, Any] | None = None, *, client_factory=None)
self._client_factory = client_factory or self._make_client
self._client: PowerContextClient | Any | None = None
self._scope_id = ""
self._default_scope_id = ""
self._session_id = ""
self._memory_write_queue: queue.Queue[Callable[[], None] | None] | None = None
self._memory_write_thread: threading.Thread | None = None
Expand Down Expand Up @@ -334,16 +335,17 @@ def initialize(self, session_id: str, **kwargs: Any) -> None:
True,
):
self._workstream_bound_scope = _read_workstream_scope(self._workstream_cwd) or ""
scope_template = str(configured_scope or _DEFAULT_SCOPE_TEMPLATE)
self._default_scope_id = _format_scope(
scope_template,
hermes_home=hermes_home,
agent_identity=agent_identity,
user_id=user_id,
)
if self._workstream_bound_scope:
self._scope_id = self._workstream_bound_scope
else:
scope_template = str(configured_scope or _DEFAULT_SCOPE_TEMPLATE)
self._scope_id = _format_scope(
scope_template,
hermes_home=hermes_home,
agent_identity=agent_identity,
user_id=user_id,
)
self._scope_id = self._default_scope_id
self._client = self._client_factory(merged_config)
trace_path = _config_value(
merged_config,
Expand Down
41 changes: 41 additions & 0 deletions tests/integrations/test_hermes_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,47 @@ def test_workstream_binding_is_shared_with_hermes_scope(tmp_path, hermes_modules
provider.shutdown()


def test_workstream_clear_restores_default_scope(tmp_path, hermes_modules, monkeypatch):
provider_module, _cli_module = hermes_modules
git_directory = tmp_path / ".git"
git_directory.mkdir()
workstream_module = importlib.import_module("plugins.powercontext.workstream")
monkeypatch.setattr(workstream_module, "git_value", lambda _cwd, *_args: str(git_directory))

client = FakeClient()
provider = provider_module.PowerContextMemoryProvider(
{"scope_id": "hermes:{profile}:{user_id}"},
client_factory=lambda _config: client,
)
provider.initialize(
"session-1",
hermes_home=str(tmp_path / "hermes"),
cwd=str(tmp_path),
agent_identity="coder",
user_id="user-7",
)
default_scope_id = provider._scope_id

try:
bound = json.loads(provider.handle_slash_command("workstream bind shared:scope"))
assert bound["scope_id"] == "shared:scope"
assert provider._scope_id == "shared:scope"

cleared = json.loads(provider.handle_slash_command("workstream clear"))
assert cleared["status"] == "cleared"
assert provider._scope_id == default_scope_id

status = json.loads(provider.handle_slash_command("workstream status"))
assert status["bound_scope_id"] is None
assert status["active_scope_id"] == default_scope_id

provider.handle_slash_command("search uv")
assert client.calls[-1][0] == "search_memory"
assert client.calls[-1][1][0] == default_scope_id
finally:
provider.shutdown()


def test_workstream_bind_isolates_queued_background_work(tmp_path, hermes_modules, monkeypatch):
provider_module, _cli_module = hermes_modules
git_directory = tmp_path / ".git"
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.