Overview
QueryBox plugins are standalone executables that communicate with the host application via stdin/stdout. Plugins can be written in any language, but the SDK and examples are written in Go. This guide covers building plugins with Task, cross-compilation, and distribution strategies.Build Process
Using Task (Recommended)
The project uses Task as a build tool. To build all plugins:Taskfile.yml:64-69:
Build Script
The build script (scripts/build-plugins.sh) automatically:
- Discovers all plugin directories under
plugins/ - Skips the
templateplugin (example only) - Builds each plugin with
main.go - Outputs binaries to
bin/plugins/ - Adds
.exeextension on Windows - Makes binaries executable
scripts/build-plugins.sh:1-74:
Cross-Compilation
Building for Different Platforms
Go supports cross-compilation viaGOOS and GOARCH environment variables:
Supported Platforms
| Platform | GOOS | GOARCH | Notes |
|---|---|---|---|
| Linux x64 | linux | amd64 | Most servers |
| Linux ARM64 | linux | arm64 | Raspberry Pi, AWS Graviton |
| macOS Intel | darwin | amd64 | Pre-2020 Macs |
| macOS Apple Silicon | darwin | arm64 | M1/M2/M3 Macs |
| Windows x64 | windows | amd64 | Most Windows systems |
Docker Cross-Compilation
For complex builds or when cross-compiling with CGO:Plugin Structure
A minimal plugin requires:Minimal Example
Fromplugins/template/main.go:1-104:
Plugin Discovery
Fromdocs/features/02-plugin-system.md:109-126:
QueryBox looks for plugins in two locations:
1. User Plugin Directory
The primary location is a user-writable directory:- Linux:
$XDG_CONFIG_HOME/querybox/plugins(usually~/.config/querybox/plugins) - macOS:
~/Library/Application Support/querybox/plugins - Windows:
%APPDATA%\querybox\plugins
bin/plugins to this directory, overwriting existing files. This keeps bundled plugins up-to-date while allowing users to add custom plugins.
2. Bundled Plugin Directory
The fallback location isbin/plugins next to the executable (or inside .app bundles on macOS).
Plugin Registration
- QueryBox scans both directories at startup
- Executes
plugin info(2s timeout) for each binary - Caches metadata in memory for the process lifetime
- User directory takes precedence over bundled directory when names conflict
Manual Rescan
Plugins are not automatically reloaded. To refresh without restarting:- Click Rescan in the Plugins window (triggers synchronous re-probe)
- Or restart the application
Distribution Strategies
1. Bundle with Application
Place plugins inbin/plugins/ before packaging:
2. Standalone Distribution
Distribute plugins as separate downloads:- Build the plugin binary
- Package with installation instructions
- Users manually copy to their plugin directory
3. Plugin Repository (Future)
While not currently implemented, QueryBox could support:- Central plugin registry
- In-app plugin browser
- Automatic updates
Dependencies
Managing Go Dependencies
Plugins can use any Go module. Add dependencies to your plugin’sgo.mod:
Vendor Dependencies (Optional)
For reproducible builds:Binary Size Optimization
Build Flags
Reduce binary size with linker flags:-s: Strip symbol table-w: Strip DWARF debugging info
UPX Compression
Further compress with UPX:Versioning
Plugins should follow Semantic Versioning:- MAJOR: Incompatible API changes
- MINOR: Backward-compatible features
- PATCH: Backward-compatible bug fixes