Primary Language: Go 1.22+
Build System: Just (task runner) + Go modules
just install # Download and verify Go dependencies
just bootstrap # Install system dependencies (for container)
just build # Build the webexec binaryjust test # Run all tests with race detector
just test-single TestName # Run a specific test (e.g., TestAuth)
just test-integration # Run integration testsjust run # Run webexec in debug mode (foreground)
just lint # Format code and run static analysis
just generate # Generate version informationjust init # Initialize webexec configuration
just start # Start webexec agent (background)
just stop # Stop webexec agent
just restart # Restart webexec agent
just status # Show agent statusjust build-release # Build release binaries with goreleaser
just clean # Remove build artifactsjust build-sandbox # Build the sandbox container for Asimi
just clean-sandbox # Remove the sandbox containerNote: The sandbox container image name is configured in .agents/asimi.conf under [run_in_shell] section as image_name = "localhost/asimi-sandbox-daonb-webexec:latest".
- Order: standard library → third-party → local packages
- Use
goimportsorgo fmtto organize automatically - Group imports with blank lines between categories
- Use
go fmtfor all code (enforced byjust lint) - Tabs for indentation (Go standard)
- Line length: aim for 100 characters, but not strict
- Prefer explicit types for public APIs
- Use type aliases for clarity:
type AddressType string - Export struct fields when needed for JSON/TOML marshaling
- Use pointer receivers for methods that modify state
- Unexported: camelCase (e.g.,
handleResize) - Exported: PascalCase (e.g.,
StartHTTPServer) - Interfaces: Single-method interfaces end in
-er(e.g.,AuthBackend) - Acronyms: All caps (e.g.,
HTTPServer,FPfor fingerprint,ID) - Constants: PascalCase for exported, camelCase for unexported
- Always check errors; never ignore with
_ - Wrap errors with context:
fmt.Errorf("failed to connect: %w", err) - Use
Logger.Errorf()for logging in long-running processes - Return errors to callers; avoid panic except in init/main
- Use
cli.Exit()for CLI command errors with appropriate exit codes
- Use
testify/requirefor assertions (preferred) ortestify/assert - Test files:
*_test.goin the same package - Integration tests:
integration_test.gowith build tags if needed - Use helper functions like
initTest(t)for common setup - Table-driven tests for multiple similar cases
- Use the global
Logger(zap.SugaredLogger) - Levels:
Debug,Info,Warn,Error - Include context: peer FP, connection ID, function name
- Format:
Logger.Infof("message with %s", context) - Structured logging for important events
- Public APIs must have doc comments
- Doc comments start with the name:
// StartHTTPServer starts... - Explain "why" not "what" for complex logic
- Use
TODO:with issue links for future work
- WebRTC: Peer connections managed via
peerspackage - Configuration: TOML format (see
conf.go) - IPC: Unix socket at
~/.webexec/webexec.sock - Daemon: PID file for process management
- Signaling: HTTP server on port 7777 (default)
webexec.go- Main CLI and daemon logicpeers/- WebRTC peer and pane managementhttpserver/- HTTP signaling serverauth.go- Authentication backendconf.go- Configuration managementkey.go- Certificate generation and management
- Default config:
~/.webexec/ - Certificate:
~/.webexec/certnkey.pem - Config file:
~/.webexec/webexec.conf - Logs:
~/.webexec/webexec.log
- TCP 7777: Signaling server (configurable)
- UDP 60000-61000: WebRTC data channels (configurable)
- Use
initTest(t)for test initialization - Mock WebRTC connections when needed
- Test both success and error paths
- Clean up resources in
deferstatements
- WebRTC:
github.com/pion/webrtc/v3 - CLI:
github.com/urfave/cli/v2 - Logging:
go.uber.org/zap - Config:
github.com/pelletier/go-toml - DI:
go.uber.org/fx
- Define command in
webexec.gounderapp.Commands - Implement handler function with signature
func(c *cli.Context) error - Add flags if needed
- Update this guide with the new command
- Define message type in
peers/peer.go - Add handler in
handleCTRLMsg()inwebexec.go - Implement handler function:
handleXxx(peer, msg, raw) - Send ACK/NACK responses
- Use
just runto run in foreground with console output - Check logs:
~/.webexec/webexec.log - Check errors:
~/.webexec/webexec.err - Use
just statusto check agent state
- Update
CHANGELOG.md - Tag version:
git tag vX.Y.Z - Push tag:
git push origin vX.Y.Z - GitHub Actions runs goreleaser
- Draft release is created automatically