Testing Plugins¶
The best way to test your plugin is to use it directly in Hamr. Hamr captures and displays JSON errors in the UI, making visual testing the most effective approach.
Running Hamr in Dev Mode¶
For plugin development, run Hamr in dev mode from the repository:
Dev mode:
- Stops any running production Hamr
- Runs Hamr from the current directory
- Auto-reloads when plugin files change
- Shows logs directly in the terminal
- Restores production Hamr on exit (Ctrl+C)
Use ./dev --no-restore to not restart production Hamr after exiting.
Visual Testing¶
Basic Testing Workflow¶
- Run Hamr in dev mode -
./devfrom the hamr directory - Open Hamr and type
/your-plugin-name - Interact with your plugin - type searches, select items, click actions
- Errors are shown in the UI - invalid JSON, missing fields, Python exceptions
- Edit your plugin - Hamr auto-reloads on file changes
- Check terminal for logs - errors and debug output appear in the dev terminal
Alternative: Check Logs Separately¶
If running Hamr as a systemd service instead of dev mode:
Manual Handler Testing¶
Test your handler directly from the command line:
# Test initial step
echo '{"step": "initial"}' | ./handler.py
# Test search
echo '{"step": "search", "query": "test"}' | ./handler.py
# Test action
echo '{"step": "action", "selected": {"id": "item-1"}}' | ./handler.py
# Validate JSON output
echo '{"step": "initial"}' | ./handler.py | jq .
Schema Requirements¶
Hamr validates all responses. Invalid responses show errors in the UI.
| Response Type | Required Fields |
|---|---|
results |
type, results[] with id and name |
card |
type, card.content |
execute |
type |
imageBrowser |
type, imageBrowser.directory |
gridBrowser |
type, gridBrowser.items[] with id and name |
form |
type, form.fields[] with id, type |
prompt |
type, prompt object |
error |
type, message |
noop |
type only |
Debugging Tips¶
Check Handler Output¶
# Run handler and validate JSON
echo '{"step": "initial"}' | ./handler.py | jq .
# Check specific field
echo '{"step": "initial"}' | ./handler.py | jq '.results[0].id'
Check Hamr Logs¶
# Follow logs in real-time
journalctl --user -u hamr -f
# Show recent errors
journalctl --user -u hamr --since "5 min ago" | grep -i error
Common Issues¶
| Issue | Solution |
|---|---|
| Plugin doesn't appear | Check supportedPlatforms in manifest |
| Handler errors | Check journalctl --user -u hamr -f |
| Invalid JSON | Test with echo '{"step": "initial"}' \| ./handler.py \| jq . |
| Missing fields | Check schema requirements above |