fix(refresh-marketplace): use /reload-plugins instead of /exit + restart
Claude Code's `/reload-plugins` slash command picks up newly installed plugins into the running session without forcing the user to /exit and restart Claude Code. The hook JSON `systemMessage` and `additionalContext` both now point at it. Tests updated to pin the new hint shape.
This commit is contained in:
parent
166c1c0752
commit
3aeb0f2fbd
2 changed files with 8 additions and 10 deletions
|
|
@ -383,8 +383,8 @@ def _emit_hook_message(events: dict[str, list[str]]) -> None:
|
||||||
`systemMessage` is a transient toast (often missed). `additionalContext`
|
`systemMessage` is a transient toast (often missed). `additionalContext`
|
||||||
is wrapped in a system reminder Claude reads at session start, so the
|
is wrapped in a system reminder Claude reads at session start, so the
|
||||||
model can mention the change if it's relevant to the user's first ask.
|
model can mention the change if it's relevant to the user's first ask.
|
||||||
Plugins require a Claude Code restart — they land on disk this session
|
Plugins land on disk during the hook; `/reload-plugins` loads them into
|
||||||
but only load on next session start.
|
the running session without a restart.
|
||||||
"""
|
"""
|
||||||
parts: list[str] = []
|
parts: list[str] = []
|
||||||
if events["installed"]:
|
if events["installed"]:
|
||||||
|
|
@ -399,8 +399,8 @@ def _emit_hook_message(events: dict[str, list[str]]) -> None:
|
||||||
)
|
)
|
||||||
summary = "Your Agnes stack changed: " + "; ".join(parts) + "."
|
summary = "Your Agnes stack changed: " + "; ".join(parts) + "."
|
||||||
restart_hint = (
|
restart_hint = (
|
||||||
"Run `/exit` and then `claude` again to load the changes — "
|
"Run `/reload-plugins` to load the changes into this session — "
|
||||||
"Claude Code only picks up new/updated plugins on session start."
|
"no restart needed."
|
||||||
)
|
)
|
||||||
payload = {
|
payload = {
|
||||||
"systemMessage": f"{summary} {restart_hint}",
|
"systemMessage": f"{summary} {restart_hint}",
|
||||||
|
|
|
||||||
|
|
@ -464,17 +464,15 @@ def test_quiet_emits_hook_json_when_plugin_installed(
|
||||||
assert "grpn-fin" in payload["systemMessage"]
|
assert "grpn-fin" in payload["systemMessage"]
|
||||||
assert "Agnes stack" in payload["systemMessage"]
|
assert "Agnes stack" in payload["systemMessage"]
|
||||||
assert "installed" in payload["systemMessage"]
|
assert "installed" in payload["systemMessage"]
|
||||||
# Restart hint: plugins land on disk this session but only load on
|
# Reload hint: `/reload-plugins` loads the on-disk plugins into the
|
||||||
# next session start, so the user must /exit + restart.
|
# running Claude Code session without a full restart.
|
||||||
assert "/exit" in payload["systemMessage"]
|
assert "/reload-plugins" in payload["systemMessage"]
|
||||||
assert "session start" in payload["systemMessage"].lower()
|
|
||||||
|
|
||||||
hook_specific = payload.get("hookSpecificOutput", {})
|
hook_specific = payload.get("hookSpecificOutput", {})
|
||||||
assert hook_specific.get("hookEventName") == "SessionStart"
|
assert hook_specific.get("hookEventName") == "SessionStart"
|
||||||
additional = hook_specific.get("additionalContext", "")
|
additional = hook_specific.get("additionalContext", "")
|
||||||
assert "grpn-fin" in additional
|
assert "grpn-fin" in additional
|
||||||
assert "/exit" in additional
|
assert "/reload-plugins" in additional
|
||||||
assert "session start" in additional.lower()
|
|
||||||
|
|
||||||
|
|
||||||
def test_manual_mode_prints_restart_hint_when_anything_changed(
|
def test_manual_mode_prints_restart_hint_when_anything_changed(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue