fix(python): mirror Claude async rewake metadata
This commit is contained in:
1 parent
45f6ee076b
commit
fad1968c25
3 files changed
+43
-2
No files matched your search
@@ -35,7 +35,8 @@ HOOK_EVENTS = frozenset({
|
|||||||
COMMON_HANDLER_KEYS = frozenset({"if", "once", "statusMessage", "timeout"})
|
COMMON_HANDLER_KEYS = frozenset({"if", "once", "statusMessage", "timeout"})
|
||||||
HANDLER_KEYS = {
|
HANDLER_KEYS = {
|
||||||
"command": COMMON_HANDLER_KEYS | {
|
"command": COMMON_HANDLER_KEYS | {
|
||||||
"args", "async", "asyncRewake", "command", "shell", "type",
|
"args", "async", "asyncRewake", "command", "rewakeMessage",
|
||||||
|
"rewakeSummary", "shell", "type",
|
||||||
},
|
},
|
||||||
"prompt": COMMON_HANDLER_KEYS | {
|
"prompt": COMMON_HANDLER_KEYS | {
|
||||||
"continueOnBlock", "model", "prompt", "type",
|
"continueOnBlock", "model", "prompt", "type",
|
||||||
@@ -162,6 +163,14 @@ def _validate_handler(
|
|||||||
_string_array(handler["args"], "args", label)
|
_string_array(handler["args"], "args", label)
|
||||||
_optional_boolean(handler, "async", label)
|
_optional_boolean(handler, "async", label)
|
||||||
_optional_boolean(handler, "asyncRewake", label)
|
_optional_boolean(handler, "asyncRewake", label)
|
||||||
|
if "rewakeMessage" in handler:
|
||||||
|
_require_non_empty_string(
|
||||||
|
handler["rewakeMessage"], "rewakeMessage", label
|
||||||
|
)
|
||||||
|
if "rewakeSummary" in handler:
|
||||||
|
_require_non_empty_string(
|
||||||
|
handler["rewakeSummary"], "rewakeSummary", label
|
||||||
|
)
|
||||||
if "shell" in handler and handler["shell"] not in ("bash", "powershell"):
|
if "shell" in handler and handler["shell"] not in ("bash", "powershell"):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f'{label} field "shell" must be "bash" or "powershell"'
|
f'{label} field "shell" must be "bash" or "powershell"'
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import subprocess # nosec B404
|
import subprocess # nosec B404
|
||||||
|
import sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@@ -19,7 +20,18 @@ CLAUDE_BINARY = os.environ.get("ELYDORA_CLAUDE_BINARY")
|
|||||||
def test_official_claude_code_accepts_installed_settings(
|
def test_official_claude_code_accepts_installed_settings(
|
||||||
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
||||||
) -> None:
|
) -> None:
|
||||||
fixture = prepare_fixture(monkeypatch, tmp_path)
|
fixture = prepare_fixture(
|
||||||
|
monkeypatch,
|
||||||
|
tmp_path,
|
||||||
|
existing_settings={"hooks": {"Stop": [{"hooks": [{
|
||||||
|
"type": "command",
|
||||||
|
"command": sys.executable,
|
||||||
|
"args": ["--version"],
|
||||||
|
"asyncRewake": True,
|
||||||
|
"rewakeMessage": "Background validation failed",
|
||||||
|
"rewakeSummary": "Validation feedback",
|
||||||
|
}]}]}},
|
||||||
|
)
|
||||||
fixture.install()
|
fixture.install()
|
||||||
environment = {
|
environment = {
|
||||||
**os.environ,
|
**os.environ,
|
||||||
|
|||||||
@@ -75,6 +75,13 @@ def test_install_preserves_settings_and_writes_one_exact_triple(
|
|||||||
"timeout": 5,
|
"timeout": 5,
|
||||||
}],
|
}],
|
||||||
}],
|
}],
|
||||||
|
"Stop": [{"hooks": [{
|
||||||
|
"type": "command",
|
||||||
|
"command": "background-check",
|
||||||
|
"asyncRewake": True,
|
||||||
|
"rewakeMessage": "Background validation failed",
|
||||||
|
"rewakeSummary": "Validation feedback",
|
||||||
|
}]}],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
fixture = prepare_fixture(
|
fixture = prepare_fixture(
|
||||||
@@ -88,6 +95,7 @@ def test_install_preserves_settings_and_writes_one_exact_triple(
|
|||||||
assert installed["model"] == "sonnet"
|
assert installed["model"] == "sonnet"
|
||||||
assert installed["hooks"]["Notification"] == existing["hooks"]["Notification"]
|
assert installed["hooks"]["Notification"] == existing["hooks"]["Notification"]
|
||||||
assert installed["hooks"]["PreToolUse"][0] == existing["hooks"]["PreToolUse"][0]
|
assert installed["hooks"]["PreToolUse"][0] == existing["hooks"]["PreToolUse"][0]
|
||||||
|
assert installed["hooks"]["Stop"] == existing["hooks"]["Stop"]
|
||||||
assert_managed_triple(installed, fixture)
|
assert_managed_triple(installed, fixture)
|
||||||
first_source = fixture.config_path.read_text(encoding="utf-8")
|
first_source = fixture.config_path.read_text(encoding="utf-8")
|
||||||
|
|
||||||
@@ -240,6 +248,18 @@ INVALID_SETTINGS = [
|
|||||||
}]}]}}),
|
}]}]}}),
|
||||||
"positive finite number",
|
"positive finite number",
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
json.dumps({"hooks": {"Stop": [{"hooks": [{
|
||||||
|
"type": "command", "command": "x", "rewakeMessage": "",
|
||||||
|
}]}]}}),
|
||||||
|
"rewakeMessage.*non-empty string",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
json.dumps({"hooks": {"Stop": [{"hooks": [{
|
||||||
|
"type": "command", "command": "x", "rewakeSummary": "",
|
||||||
|
}]}]}}),
|
||||||
|
"rewakeSummary.*non-empty string",
|
||||||
|
),
|
||||||
(
|
(
|
||||||
json.dumps({"hooks": {"PreToolUse": [{"hooks": [{
|
json.dumps({"hooks": {"PreToolUse": [{"hooks": [{
|
||||||
"type": "http", "url": "https://example.test", "headers": {"A": 1},
|
"type": "http", "url": "https://example.test", "headers": {"A": 1},
|
||||||
|
|||||||
Reference in new issue
Block a user