Skip to content

Commit da27c9e

Browse files
committed
fix: Support both hook_type and hook_event_name in execute command
- Added compatibility for both field names to support different input formats - Added comprehensive test_package.py script to validate releases - All tests passing before v0.3.3 release
1 parent 4ec3680 commit da27c9e

File tree

2 files changed

+116
-2
lines changed

2 files changed

+116
-2
lines changed

src/eyelet/cli/execute.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ def execute(ctx, workflow, log_only, log_result, debug, no_logging, legacy_log):
170170
if debug:
171171
console.print(f"[yellow]Legacy logging failed: {e}[/yellow]")
172172

173-
# Extract hook information
174-
hook_type = input_data.get("hook_event_name", "unknown")
173+
# Extract hook information (support both hook_type and hook_event_name for compatibility)
174+
hook_type = input_data.get("hook_type") or input_data.get("hook_event_name", "unknown")
175175
tool_name = input_data.get("tool_name", None)
176176

177177
# Create execution record

test_package.py

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#!/usr/bin/env python3
2+
"""Test script to validate eyelet package before publishing"""
3+
4+
import json
5+
import subprocess
6+
import sys
7+
from pathlib import Path
8+
9+
def run_test(description, command, stdin=None):
10+
"""Run a test command and check if it succeeds"""
11+
print(f"Testing: {description}...")
12+
try:
13+
result = subprocess.run(
14+
command,
15+
shell=True,
16+
capture_output=True,
17+
text=True,
18+
input=stdin,
19+
timeout=5
20+
)
21+
if result.returncode == 0:
22+
print(f" ✓ {description}")
23+
return True
24+
else:
25+
print(f" ✗ {description}")
26+
print(f" Error: {result.stderr}")
27+
return False
28+
except Exception as e:
29+
print(f" ✗ {description}")
30+
print(f" Exception: {e}")
31+
return False
32+
33+
def main():
34+
"""Run all package validation tests"""
35+
tests_passed = []
36+
tests_failed = []
37+
38+
# Test 1: Import the package
39+
test_name = "Import eyelet package"
40+
if run_test(test_name, "python -c 'import eyelet; print(eyelet.__version__)'"):
41+
tests_passed.append(test_name)
42+
else:
43+
tests_failed.append(test_name)
44+
45+
# Test 2: CLI help
46+
test_name = "CLI help command"
47+
if run_test(test_name, "eyelet --help"):
48+
tests_passed.append(test_name)
49+
else:
50+
tests_failed.append(test_name)
51+
52+
# Test 3: Execute with hook_type (new format)
53+
test_name = "Execute with hook_type"
54+
test_input = json.dumps({
55+
"hook_type": "PreToolUse",
56+
"tool_name": "Bash",
57+
"input": {"command": "echo test"}
58+
})
59+
if run_test(test_name, "eyelet execute --log-only", stdin=test_input):
60+
tests_passed.append(test_name)
61+
else:
62+
tests_failed.append(test_name)
63+
64+
# Test 4: Execute with hook_event_name (Claude Code format)
65+
test_name = "Execute with hook_event_name"
66+
test_input = json.dumps({
67+
"hook_event_name": "PostToolUse",
68+
"tool_name": "Read",
69+
"output": {"content": "test"}
70+
})
71+
if run_test(test_name, "eyelet execute --log-only", stdin=test_input):
72+
tests_passed.append(test_name)
73+
else:
74+
tests_failed.append(test_name)
75+
76+
# Test 5: TUI module import
77+
test_name = "Import TUI module"
78+
if run_test(test_name, "python -c 'from eyelet.tui import app'"):
79+
tests_passed.append(test_name)
80+
else:
81+
tests_failed.append(test_name)
82+
83+
# Test 6: Recall module import
84+
test_name = "Import recall module"
85+
if run_test(test_name, "python -c 'from eyelet.recall import ConversationSearch'"):
86+
tests_passed.append(test_name)
87+
else:
88+
tests_failed.append(test_name)
89+
90+
# Test 7: Doctor command (skip since it's interactive)
91+
test_name = "Validate command"
92+
if run_test(test_name, "eyelet validate --help"):
93+
tests_passed.append(test_name)
94+
else:
95+
tests_failed.append(test_name)
96+
97+
# Print summary
98+
print("\n" + "="*50)
99+
print("TEST SUMMARY")
100+
print("="*50)
101+
print(f"✓ Passed: {len(tests_passed)}")
102+
print(f"✗ Failed: {len(tests_failed)}")
103+
104+
if tests_failed:
105+
print("\nFailed tests:")
106+
for test in tests_failed:
107+
print(f" - {test}")
108+
sys.exit(1)
109+
else:
110+
print("\n🎉 All tests passed! Package is ready for publishing.")
111+
sys.exit(0)
112+
113+
if __name__ == "__main__":
114+
main()

0 commit comments

Comments
 (0)