8.0 KiB
8.0 KiB
OpenCode CLI Configuration
This directory contains OpenCode configuration and tools for the MEV Bot project.
🚀 Quick Start Commands
Essential Build & Test Commands
# Build the MEV bot binary
make build
# Run all tests
make test
# Run tests with coverage
make test-coverage
# Run unit tests
make test-unit
# Run integration tests
make test-integration
# Run end-to-end tests
make test-e2e
# Check for Go modules issues
go mod tidy && go mod verify
# Run linter
make lint
# Run security analysis
make security-audit
Development Workflow Commands
# Setup development environment
export ARBITRUM_RPC_ENDPOINT="wss://arbitrum-mainnet.core.chainstack.com/73bc682fe9c5bd23b42ef40f752fa89a"
export ARBITRUM_WS_ENDPOINT="wss://arbitrum-mainnet.core.chainstack.com/73bc682fe9c5bd23b42ef40f752fa89a"
export METRICS_ENABLED="false"
# Run with timeout for testing
timeout 30 ./mev-bot start
# Debug with verbose logging
LOG_LEVEL=debug ./mev-bot start
# Profile performance
go tool pprof http://localhost:6060/debug/pprof/profile
OpenCode Commands Directory
The .opencode/commands/ directory contains predefined commands for common development tasks:
implement-feature.md- Implement new features with test coveragedebug-code.md- Debug issues in the codebaserefactor-code.md- Refactor existing code for better qualitywrite-tests.md- Write comprehensive testscode-review.md- Perform code reviews
OpenCode Settings
The .opencode/settings.json file contains OpenCode's configuration:
{
"languages": {
"go": {
"version": "1.24+",
"testing_framework": "testing",
"linting_tools": ["golangci-lint", "go vet", "go fmt"],
"coverage_target": 90
},
"solidity": {
"version": "^0.8.24",
"testing_framework": "hardhat",
"linting_tools": ["solhint", "slither"],
"coverage_target": 95
},
"javascript": {
"version": "LTS",
"frameworks": ["vue", "vue-router", "pinia", "helia", "viem"],
"testing_framework": "vitest",
"linting_tools": ["eslint", "prettier"]
}
},
"testing": {
"unit_test_coverage": 90,
"integration_test_coverage": 80,
"property_based_testing": true,
"fuzz_testing": true,
"benchmarking": true
},
"quality": {
"linting": true,
"security_scanning": true,
"dependency_checking": true,
"documentation_required": true
}
}
📋 Development Guidelines & Code Style
Go Best Practices (1.24+)
- Error Handling: Use Go's error wrapping with context:
fmt.Errorf("failed to process transaction: %w", err) - Concurrency Safety: Use mutexes correctly to protect shared data
- Code Structure: Follow idiomatic Go patterns and conventions
- Testing: Write tests for all functions and methods with >90% coverage
- Performance: Minimize memory allocations in hot paths
Solidity Best Practices (^0.8.24)
- Security: Implement proper access controls and validation
- Gas Optimization: Optimize for minimal gas consumption
- Upgradeability: Consider upgradeable contract patterns
- Testing: Achieve >95% test coverage with property-based tests
- Documentation: Document all public functions with NatSpec
JavaScript/TypeScript Best Practices (Vue 3, Vue Router, Pinia, Helia, Viem)
- Component Design: Use Vue 3 Composition API
- State Management: Implement proper state management with Pinia
- Routing: Follow Vue Router best practices
- P2P Integration: Use Helia for decentralized data sharing
- Web3 Integration: Integrate Viem for efficient Ethereum interactions
Required Checks Before Commit
# Run all checks before committing
make test && make lint && go mod tidy
# Security scan
make security-audit
# Dependency vulnerability check
make dependency-check
OpenCode's Primary Focus Areas
As OpenCode, you're particularly skilled at:
-
Writing and Debugging Code
- Implementing clean, idiomatic code in Go, Solidity, and JavaScript
- Debugging complex concurrency issues
- Optimizing code for performance and readability
-
Implementing Test Cases and Ensuring Code Quality
- Writing comprehensive unit and integration tests
- Implementing property-based tests for mathematical functions
- Creating performance benchmarks for critical paths
-
Following Established Coding Patterns and Conventions
- Using appropriate design patterns for each language
- Following idiomatic patterns and best practices
- Implementing consistent error handling and logging
-
Identifying and Fixing Bugs
- Debugging race conditions and concurrency issues
- Identifying performance bottlenecks
- Fixing precision errors in mathematical calculations
-
Ensuring Code is Well-Structured and Readable
- Organizing code into logical packages with clear responsibilities
- Using clear, descriptive naming conventions
- Implementing proper abstraction and encapsulation
🛠 OpenCode Optimization Settings
Workflow Preferences
- Always commit changes: Use
git commit -am "descriptive message"after significant changes - Branch naming: Use hyphens (
feat-add-new-parser,fix-memory-leak) - Context management: Use
/compactto manage long conversations - Testing first: Always write tests before implementation
File Organization Preferences
- Go files: Follow standard Go layout (cmd/, internal/, pkg/)
- Solidity files: Place in
contracts/directory with separate test files - JavaScript files: Follow Vue 3 project structure with components, views, and stores
- Test files: Place alongside source files with appropriate suffixes
Quality Assurance
# Run comprehensive test suite
make test-all
# Run security audits
make security-full
# Check code quality
make quality-check
# Generate documentation
make docs
🔧 Environment Configuration
Required Environment Variables
# Arbitrum RPC Configuration
export ARBITRUM_RPC_ENDPOINT="wss://arbitrum-mainnet.core.chainstack.com/73bc682fe9c5bd23b42ef40f752fa89a"
export ARBITRUM_WS_ENDPOINT="wss://arbitrum-mainnet.core.chainstack.com/73bc682fe9c5bd23b42ef40f752fa89a"
# Application Configuration
export LOG_LEVEL="info"
export METRICS_ENABLED="false"
export METRICS_PORT="9090"
# Development Configuration
export GO_ENV="development"
export DEBUG="true"
# Frontend Configuration
export VITE_APP_RPC_ENDPOINT="wss://arbitrum-mainnet.core.chainstack.com/73bc682fe9c5bd23b42ef40f752fa89a"
Testing Environment Variables
# Test Configuration
export TEST_COVERAGE_TARGET=90
export TEST_TIMEOUT=30s
export TEST_PARALLEL=4
# Solidity Testing
export HARDHAT_NETWORK="hardhat"
export FORKING_URL="wss://arbitrum-mainnet.core.chainstack.com/73bc682fe9c5bd23b42ef40f752fa89a"
📝 Commit Message Conventions
Format
type(scope): brief description
- Detailed explanation of changes
- Why the change was needed
- Any breaking changes or migration notes
🤖 Generated with [OpenCode](https://opencode.example.com)
Co-Authored-By: OpenCode <noreply@opencode.example.com>
Types
feat: New feature implementationfix: Bug fixperf: Performance improvementrefactor: Code restructuring without feature changestest: Adding or updating testsdocs: Documentation updatesbuild: Build system or dependency changesci: CI/CD pipeline changescontract: Smart contract changesfrontend: Frontend/UI changes
🚨 Security Guidelines
Never Commit
- Private keys or wallet seeds
- API keys or secrets
- RPC endpoints with authentication
- Personal configuration files
Always Validate
- Input parameters for all functions
- Smart contract inputs and state changes
- Web3 interactions and transactions
- Memory allocations for bounds
Security Commands
# Scan for secrets
git-secrets --scan
# Security audit for Go code
gosec ./...
# Security audit for Solidity contracts
slither .
# Dependency vulnerabilities
go list -json -m all | nancy sleuth
# Check for hardcoded credentials
grep -r "password\|secret\|key" --exclude-dir=.git .