chore(ai): add comprehensive CLI configurations for all AI assistants
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
70
.opencode/commands/code-review.md
Normal file
70
.opencode/commands/code-review.md
Normal 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
|
||||
38
.opencode/commands/debug-code.md
Normal file
38
.opencode/commands/debug-code.md
Normal 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
|
||||
39
.opencode/commands/implement-feature.md
Normal file
39
.opencode/commands/implement-feature.md
Normal 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
|
||||
50
.opencode/commands/refactor-code.md
Normal file
50
.opencode/commands/refactor-code.md
Normal 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
|
||||
73
.opencode/commands/write-tests.md
Normal file
73
.opencode/commands/write-tests.md
Normal 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
|
||||
Reference in New Issue
Block a user