feat: 优化运行时判定

This commit is contained in:
richarjiang
2026-09-24 14:27:07 +08:00
parent dfd3998399
commit f0ac603f27
25 changed files with 2368 additions and 58 deletions

View File

@@ -43,6 +43,21 @@ def test_claude_merge_is_idempotent_and_keeps_existing_hooks(tmp_path):
for item in group["hooks"]
]
assert commands == [f'"{tmp_path / "runtime" / ".venv" / "bin" / "laya-hook"}" --client claude']
for event, matcher in (
("PreToolUse", "Bash|Edit|Write|MultiEdit|apply_patch"),
("PostToolUse", "Bash|Edit|Write|MultiEdit|apply_patch|Read|Grep|Glob"),
):
ours = [
group
for group in saved["hooks"][event]
if any("laya-hook" in item.get("command", "") for item in group.get("hooks", []))
]
assert ours[-1]["matcher"] == matcher
assert any(
"laya-hook" in item.get("command", "")
for group in saved["hooks"]["Stop"]
for item in group["hooks"]
)
assert list(path.parent.glob("settings.json.bak-*"))
assert client.uninstall() is True