fix: cross-platform browser opening and hook robustness

bin/amc:
- Add cross-platform browser opening: try 'open' (macOS) first,
  fall back to 'xdg-open' (Linux) for desktop environments
- Wrap browser opening in conditional to avoid errors on headless systems

bin/amc-hook:
- Fix edge case in question extraction where tool_input.get("questions")
  could return None instead of empty list, causing TypeError
This commit is contained in:
teernisse
2026-02-25 11:21:30 -05:00
parent a9ed8f90f4
commit 0551b9fd89
2 changed files with 7 additions and 2 deletions

View File

@@ -34,7 +34,12 @@ case "$cmd" in
echo "AMC started (pid $!)"
fi
fi
open "http://127.0.0.1:$PORT"
# Open browser (platform-specific)
if command -v open &>/dev/null; then
open "http://127.0.0.1:$PORT"
elif command -v xdg-open &>/dev/null; then
xdg-open "http://127.0.0.1:$PORT"
fi
;;
stop)
if is_running; then

View File

@@ -73,7 +73,7 @@ def _extract_questions(hook):
if not isinstance(tool_input, dict):
return []
questions = tool_input.get("questions", [])
questions = tool_input.get("questions") or []
result = []
for q in questions:
entry = {