chore(ai): add comprehensive CLI configurations for all AI assistants

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
Krypto Kajun
2025-09-14 10:09:55 -05:00
parent 2c4f663728
commit a410f637cd
34 changed files with 2391 additions and 5 deletions

288
.opencode/OPENCODE.md Normal file
View File

@@ -0,0 +1,288 @@
# OpenCode CLI Configuration
This directory contains OpenCode configuration and tools for the MEV Bot project.
## 🚀 Quick Start Commands
### Essential Build & Test Commands
```bash
# 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
```bash
# 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 coverage
- `debug-code.md` - Debug issues in the codebase
- `refactor-code.md` - Refactor existing code for better quality
- `write-tests.md` - Write comprehensive tests
- `code-review.md` - Perform code reviews
## OpenCode Settings
The `.opencode/settings.json` file contains OpenCode's configuration:
```json
{
"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
```bash
# 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:
1. **Writing and Debugging Code**
- Implementing clean, idiomatic code in Go, Solidity, and JavaScript
- Debugging complex concurrency issues
- Optimizing code for performance and readability
2. **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
3. **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
4. **Identifying and Fixing Bugs**
- Debugging race conditions and concurrency issues
- Identifying performance bottlenecks
- Fixing precision errors in mathematical calculations
5. **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 `/compact` to 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
```bash
# 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
```bash
# 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
```bash
# 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 implementation
- `fix`: Bug fix
- `perf`: Performance improvement
- `refactor`: Code restructuring without feature changes
- `test`: Adding or updating tests
- `docs`: Documentation updates
- `build`: Build system or dependency changes
- `ci`: CI/CD pipeline changes
- `contract`: Smart contract changes
- `frontend`: 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
```bash
# 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 .
```

View File

@@ -0,0 +1,70 @@
# Perform Code Review
Perform a comprehensive code review for the following changes: $ARGUMENTS
## Code Review Framework:
1. **Functional Review**: Verify code correctness and requirements implementation
2. **Quality Review**: Assess code quality, readability, and maintainability
3. **Security Review**: Identify potential security vulnerabilities
4. **Performance Review**: Evaluate performance implications
5. **Testing Review**: Check test coverage and quality
## Review Standards:
### Go Code Review
- **Error Handling**: Proper error wrapping and handling
- **Concurrency**: Correct use of goroutines, channels, and mutexes
- **Interfaces**: Appropriate interface design and usage
- **Documentation**: Clear comments and godoc compliance
- **Testing**: Adequate test coverage and quality
### Solidity Code Review
- **Security**: Reentrancy, overflow/underflow, access controls
- **Gas Optimization**: Efficient use of gas and state variables
- **Best Practices**: Follow Solidity and DeFi security best practices
- **Documentation**: Proper NatSpec comments
- **Testing**: Comprehensive test coverage
### JavaScript Code Review
- **Vue Patterns**: Proper use of Composition API and reactivity
- **State Management**: Correct Pinia usage and state handling
- **Web3 Integration**: Secure and efficient web3 interactions
- **Performance**: Optimal component rendering and data fetching
- **Testing**: Adequate Vue component and unit tests
## Review Checklist:
### General
- [ ] Code follows project style guidelines
- [ ] Naming conventions are consistent and meaningful
- [ ] Code is well-documented with comments
- [ ] No dead or commented-out code
- [ ] Dependencies are properly managed
### Security
- [ ] Input validation is implemented
- [ ] Sensitive data is handled securely
- [ ] No hardcoded secrets or credentials
- [ ] Proper access controls are in place
- [ ] Security best practices are followed
### Performance
- [ ] No obvious performance bottlenecks
- [ ] Memory usage is optimized
- [ ] Database queries are efficient
- [ ] Caching strategies are appropriate
- [ ] Concurrency patterns are efficient
### Testing
- [ ] Adequate test coverage
- [ ] Tests are well-structured and readable
- [ ] Edge cases are covered
- [ ] Mocks and stubs are used appropriately
- [ ] Performance tests are included for critical paths
## Output Requirements:
- Detailed feedback with specific line references
- Priority levels for issues (Critical/High/Medium/Low)
- Suggestions for improvements
- Approval or rejection recommendation
- Follow-up actions if needed

View File

@@ -0,0 +1,38 @@
# Debug Code Issues
Debug the following code issues: $ARGUMENTS
## Debugging Protocol:
1. **Issue Understanding**: Analyze the problem description and expected vs actual behavior
2. **Log Analysis**: Examine relevant log files and error messages
3. **Code Investigation**: Review related source code and recent changes
4. **Reproduction**: Attempt to reproduce the issue in a controlled environment
5. **Root Cause**: Identify the underlying cause and contributing factors
## Debugging Commands:
```bash
# For Go backend
go run -race ./cmd/mev-bot
LOG_LEVEL=debug ./mev-bot start
# For Solidity contracts
npx hardhat test
forge test -vvv
# For Frontend
npm run dev
npm run test:unit
```
## Investigation Areas:
- **Go Backend**: Concurrency issues, memory leaks, parsing errors
- **Solidity Contracts**: Gas issues, reentrancy, overflow/underflow
- **Frontend**: Vue component issues, state management, web3 integration
- **Integration**: API communication, contract interactions, data flow
## Output Requirements:
- Clear problem identification with code references
- Step-by-step reproduction instructions
- Root cause analysis with technical details
- Proposed solution with implementation steps
- Test plan to verify the fix

View File

@@ -0,0 +1,39 @@
# Implement Feature with Tests
Implement the following feature with comprehensive tests: $ARGUMENTS
## Implementation Framework:
1. **Requirements Analysis**: Break down the feature requirements and acceptance criteria
2. **Test Planning**: Design test cases before implementation
3. **Interface Design**: Define clean interfaces between components
4. **Implementation**: Write the code following language best practices
5. **Testing**: Create comprehensive unit, integration, and property-based tests
6. **Documentation**: Update relevant documentation and examples
## Implementation Standards:
- **Code Quality**: Follow language conventions and project coding standards
- **Error Handling**: Implement robust error handling with context
- **Logging**: Add appropriate logging with structured fields
- **Testing**: Achieve >90% test coverage for Go, >95% for Solidity
- **Performance**: Consider performance implications and add metrics
- **Security**: Validate all inputs and handle edge cases
## File Organization:
- **Go Code**: Place in appropriate `pkg/` or `internal/` subdirectory
- **Solidity Contracts**: Place in `contracts/` directory
- **Frontend Code**: Follow Vue 3 project structure
- **Tests**: Co-locate with source files (`*_test.go`, `.test.js`, etc.)
- **Documentation**: Update `docs/` and inline comments
## Integration Points:
- **Backend**: Integrate with existing Go components
- **Smart Contracts**: Ensure proper contract interaction
- **Frontend**: Connect to backend APIs and web3 providers
- **Monitoring**: Add metrics and health checks
## Deliverables:
- Working implementation with tests
- Updated documentation
- Configuration updates
- Performance benchmarks if applicable
- Migration guide for existing deployments

View File

@@ -0,0 +1,50 @@
# Refactor Code for Quality
Refactor the following code for better quality: $ARGUMENTS
## Refactoring Framework:
1. **Code Analysis**: Identify code smells, duplication, and complexity
2. **Design Review**: Evaluate architecture and design patterns
3. **Implementation**: Apply refactoring techniques
4. **Testing**: Ensure refactored code maintains functionality
5. **Documentation**: Update documentation to reflect changes
## Refactoring Standards:
- **SOLID Principles**: Apply Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion
- **DRY Principle**: Eliminate duplication
- **KISS Principle**: Keep it simple and straightforward
- **YAGNI Principle**: Don't implement unnecessary features
- **Code Readability**: Improve code clarity and maintainability
## Language-Specific Guidelines:
### Go Refactoring
- Simplify complex functions and reduce cyclomatic complexity
- Improve error handling patterns
- Optimize struct and interface design
- Enhance concurrency patterns
### Solidity Refactoring
- Optimize gas consumption
- Improve contract upgradeability
- Enhance security patterns
- Simplify complex contract interactions
### JavaScript/TypeScript Refactoring
- Apply Vue 3 Composition API patterns
- Improve component organization
- Optimize state management with Pinia
- Enhance web3 integration patterns
## Testing Requirements:
- Maintain existing test coverage
- Add tests for newly introduced patterns
- Verify no functionality regression
- Update benchmarks if performance is affected
## Deliverables:
- Refactored code with improved quality
- Updated tests
- Performance comparison (if applicable)
- Documentation updates
- Refactoring rationale and benefits

View File

@@ -0,0 +1,73 @@
# Write Comprehensive Tests
Write comprehensive tests for the following functionality: $ARGUMENTS
## Testing Framework:
1. **Test Planning**: Design test cases for all scenarios
2. **Unit Testing**: Implement unit tests with high coverage
3. **Integration Testing**: Create integration tests for component interactions
4. **Property-Based Testing**: Implement property-based tests for mathematical functions
5. **Fuzz Testing**: Add fuzz tests for edge cases
6. **Benchmark Testing**: Create benchmarks for performance-critical code
## Testing Standards:
- **Coverage Targets**: >90% for Go, >95% for Solidity, >85% for JavaScript
- **Test Organization**: Follow language-specific testing conventions
- **Test Data**: Use realistic test data and edge cases
- **Test Documentation**: Document test scenarios and expected outcomes
## Language-Specific Testing:
### Go Testing
```go
// Unit tests with table-driven approach
func TestFunctionName(t *testing.T) {
tests := []struct {
name string
input InputType
expected OutputType
wantErr bool
}{
// Test cases
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Test implementation
})
}
}
```
### Solidity Testing
```solidity
// Property-based testing with Foundry
function testFuzz_ValidInputs_AlwaysWork(uint256 amount) public {
vm.assume(amount > 0 && amount < type(uint128).max);
// Test implementation
}
```
### JavaScript Testing
```javascript
// Vue component testing with Vitest
describe('ComponentName', () => {
it('should render correctly', () => {
// Test implementation
})
})
```
## Test Categories:
- **Happy Path**: Tests for expected normal operation
- **Edge Cases**: Tests for boundary conditions
- **Error Conditions**: Tests for error handling
- **Security**: Tests for potential vulnerabilities
- **Performance**: Benchmarks for critical functions
## Deliverables:
- Comprehensive test suite with high coverage
- Property-based tests for mathematical functions
- Fuzz tests for edge cases
- Benchmark tests for performance-critical code
- Test documentation and scenarios

38
.opencode/scripts/test-all.sh Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
# test-all.sh - Run comprehensive tests for OpenCode
echo "Running comprehensive tests for OpenCode..."
# Create results directory if it doesn't exist
mkdir -p .opencode/results
# Run Go unit tests
echo "Running Go unit tests..."
go test -v ./... | tee .opencode/results/go-unit-tests.log
# Run Go integration tests
echo "Running Go integration tests..."
go test -v ./test/integration/... | tee .opencode/results/go-integration-tests.log
# Run Go property-based tests
echo "Running Go property-based tests..."
go test -v -run=Property ./... | tee .opencode/results/go-property-tests.log
# Run Go fuzz tests (limited time)
echo "Running Go fuzz tests (60 seconds)..."
timeout 60s go test -fuzz=Fuzz ./... | tee .opencode/results/go-fuzz-tests.log
# Run Go benchmarks
echo "Running Go benchmarks..."
go test -bench=. -benchmem ./... | tee .opencode/results/go-benchmarks.log
# Check for errors
if [ $? -eq 0 ]; then
echo "All tests completed successfully!"
echo "Results saved to .opencode/results/"
else
echo "Some tests failed!"
echo "Check .opencode/results/ for details"
exit 1
fi