Skip to content

Commit 5abdc8d

Browse files
authored
Merge pull request #27 from TrueNine/dev
🚀 [release] 0.0.23
2 parents c0abfb4 + e2fc8b8 commit 5abdc8d

54 files changed

Lines changed: 2123 additions & 488 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.augment/rules/global-convention.md

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,62 +4,56 @@ type: "always_apply"
44

55
# 通用标准
66

7+
在开始实现任何功能之前,请将任务拆解为更小的模块,并逐步编写代码。每写一小部分代码后,务必进行单元测试验证,确保其正确性和稳定性。即使用户给出的需求很复杂,也请始终保持渐进式开发,逐步完成,并通过测试及时发现并解决问题。避免一次性编写大量代码,以便尽早识别潜在的错误和问题。保持代码的高质量和稳定性,逐步积累完成整个任务。
8+
79
**强制规则**
810

9-
1.
10-
在开始实现任何功能之前,请将任务拆解为更小的模块,并逐步编写代码。每写一小部分代码后,务必进行单元测试验证,确保其正确性和稳定性。即使用户给出的需求很复杂,也请始终保持渐进式开发,逐步完成,并通过测试及时发现并解决问题。避免一次性编写大量代码,以便尽早识别潜在的错误和问题。保持代码的高质量和稳定性,逐步积累完成整个任务。
11-
2. 始终使用**简体中文**回复,即使用户输入大量英文提示,也应返回简体中文
12-
3. 禁止编写任何供用户使用的示例代码,即使需要临时测试,任务完成后也必须立即删除
13-
4. 严禁通过简化问题来解决问题
14-
5. 严禁通过降级依赖版本来解决问题
15-
6. 严禁通过减少测试断言来解决问题
16-
7. 严禁忽略异常或任何隐藏异常的行为
11+
1. 始终使用**简体中文**回复,即使用户输入大量英文提示,也应返回简体中文
12+
2. 禁止编写任何供用户使用的示例代码,即使需要临时测试,任务完成后也必须立即删除
13+
3. 严禁通过简化问题来解决问题
14+
4. 严禁通过降级依赖版本来解决问题
15+
5. 严禁通过减少测试断言来解决问题
16+
6. 严禁忽略异常或任何隐藏异常的行为
17+
7. 严禁在代码中暴露 API 密钥、密码和令牌
1718
8. 应当积极按照规则来重构修复上下文中出现的代码
1819
9. 严禁在代码中暴露 API 密钥、密码和令牌
1920
10. 应积极使用日志完善记录,主动补充缺失的日志
2021
11. 允许在单元测试调试期间添加日志以协助解决问题
2122
12. 必须最大化使用 `early return` 技术来减少代码嵌套层级
2223
13. 严禁在对话或任务完成后生成总结文档文件和其他不必要的操作
2324
14. 严禁出现 `util`,`utils`,`tool` 等的让我恶心的命名方式以及命名空间
24-
15. 严禁使用 `@Suppress` 注解压制警告
25-
26-
**输出规则**
27-
28-
- **优先简洁直接的回复** - 避免冗长解释
29-
- **批量相关工具调用** - 将多个信息请求合并为单次调用
30-
- **使用高效工具序列** - 最小化冗余调用
25+
15. 严禁使用 `@Suppress`/`// @ts-ignore` 等注解压制警告
3126

3227
**注释规则**
3328

34-
- 文档注释:英文注释
35-
- 代码内部注释:英文注释,且解释"为什么"而非"做什么"
29+
- 文档注释:必须使用英文注释
30+
- 代码内部注释:必须使用中文注释
31+
- 严禁使用行尾注释
3632

37-
**TDD 约定**
33+
**TDD渐进式开发方法论**
3834

39-
1. TDD流程:失败测试→实现代码→重构
40-
2. 覆盖边界条件和异常情况
41-
3. 独立运行,无外部依赖
42-
4. 测试命名清晰表达意图
43-
5. 测试类与被测试类同名
44-
6. **嵌套测试组织**:使用合适的分组,避免根级别大量独立测试方法
45-
7. 严禁出现没有断言的测试方法,发现应该立即补全断言
35+
- 采用测试驱动开发结合渐进式开发方法
36+
- **Baby Steps开发**:每次只编写少量代码,立即进行单元测试验证
37+
- **快速反馈循环**:开发一点测试一点,绝不一次性编写大量代码
38+
- **逐个验证原则**:为多个代码编写单元测试时,一个个编写一个个验证,避免批量编写后统一验证
39+
- **风险最小化**:通过频繁的小幅度验证确保代码质量,避免错误累积
40+
- **嵌套测试组织**:使用合适的分组,避免根级别大量独立测试方法
41+
- 严禁出现没有断言的测试方法,发现应该立即补全断言
4642

4743
**测试组织最佳实践:**
4844

4945
- 每个被测试类/函数/变量/方法创建主要分组
5046
- 按场景细分:正常用例、异常用例、边界用例
51-
- 示例kotlin:`@Nested inner class CreateUser { @Test fun should_create_successfully() {} }`
47+
+ 示例kotlin:`@Nested inner class CreateUser { @Test fun should_create_successfully() {} }`
5248
- 测试方法命名使用反引号包围的中文描述:`fun \`测试用户创建成功\`()`
5349
- 禁止使用 `@DisplayName` 注解
5450

5551
# 特定语言约定
5652

5753
**SQL 标准**
5854

59-
1. 检查现有查询是否使用参数化
60-
2. 统一使用snake_case命名
61-
3. 验证无字符串拼接风险
62-
4. 应尽量使用小写来编写SQL
55+
- 检查现有查询是否使用参数化
56+
- 统一使用 snake_case 命名,即使是出现在其他语言中的字符串
6357

6458
**JVM 标准**
6559

@@ -82,10 +76,9 @@ type: "always_apply"
8276
4. 严禁使用 `println` 记录输出
8377
5. 严禁在单元测试中使用 `mockito`,而是使用 `mockk`
8478

85-
**TypeScript 和 Vue 标准**
79+
**TypeScript标准**
8680

8781
- TypeScript: 启用strict模式,避免any类型
88-
- Vue: 积极使用 vue3 新特性
8982

9083
**SCSS 标准**
9184

.cursor/rules/ai-integration.mdc

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
globs: **/ai/**/*.kt,**/*AI*.kt,**/*LangChain*.kt
3+
---
4+
5+
# AI Integration Guidelines
6+
7+
Standards for AI-related modules and LangChain4j integration.
8+
9+
## AI Module Structure
10+
- **Shared abstractions**: Use [ai/ai-shared/](mdc:ai/ai-shared/) for common interfaces
11+
- **LangChain4j integration**: Implement via [ai/ai-langchain4j/](mdc:ai/ai-langchain4j/)
12+
- **Model abstractions**: Support multiple AI providers
13+
- **Configuration**: Externalize model settings and API keys
14+
15+
## LangChain4j Integration
16+
- **Version**: Use version from [gradle/libs.versions.toml](mdc:gradle/libs.versions.toml)
17+
- **Chain building**: Use fluent API for complex workflows
18+
- **Memory management**: Implement conversation memory appropriately
19+
- **Tool integration**: Create tools for external system integration
20+
21+
## AI Service Design
22+
- **Interface-based**: Define clear service interfaces
23+
- **Async operations**: Use coroutines for long-running AI operations
24+
- **Error handling**: Graceful degradation for AI service failures
25+
- **Rate limiting**: Implement to respect API limits
26+
27+
## Model Configuration
28+
- **Multiple providers**: Support OpenAI, Ollama, local models
29+
- **Model selection**: Runtime model switching capability
30+
- **Parameter tuning**: Externalize temperature, max tokens, etc.
31+
- **Fallback models**: Implement fallback strategies
32+
33+
## Security Considerations
34+
- **API key management**: Never hardcode API keys
35+
- **Input sanitization**: Validate and sanitize user inputs
36+
- **Output filtering**: Filter potentially harmful AI responses
37+
- **Audit logging**: Log AI interactions for compliance
38+
39+
## Testing AI Components
40+
- **Mock AI responses**: Use deterministic responses for unit tests
41+
- **Integration tests**: Test with real AI services in CI/CD
42+
- **Performance tests**: Measure response times and throughput
43+
- **Accuracy tests**: Validate AI output quality
44+
45+
## Prompt Engineering
46+
- **Template management**: Centralize prompt templates
47+
- **Version control**: Track prompt changes
48+
- **A/B testing**: Support prompt experimentation
49+
- **Localization**: Support multiple languages
50+
51+
## Data Handling
52+
- **Privacy compliance**: Handle PII appropriately
53+
- **Data retention**: Implement retention policies
54+
- **Anonymization**: Remove sensitive data from training
55+
- **Consent management**: Track user consent for AI processing
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
globs: **/rds/**/*.kt,**/*Repository.kt,**/*Entity.kt,**/migration/**/*.sql
3+
---
4+
5+
# Database & Persistence Patterns
6+
7+
Standards for working with Jimmer ORM, Flyway migrations, and database operations.
8+
9+
## Jimmer ORM Conventions
10+
- **Base classes**: Extend from [rds/rds-shared/](mdc:rds/rds-shared/) base entities
11+
- **Entity definitions**: Use Jimmer annotations and Kotlin data classes
12+
- **Repository patterns**: Follow [rds/rds-crud/](mdc:rds/rds-crud/) CRUD implementations
13+
- **Query optimization**: Leverage Jimmer's compile-time query generation
14+
15+
## Database Migrations
16+
- **PostgreSQL**: Use [rds/rds-flyway-migration-postgresql/](mdc:rds/rds-flyway-migration-postgresql/)
17+
- **MySQL**: Use [rds/rds-flyway-migration-mysql8/](mdc:rds/rds-flyway-migration-mysql8/)
18+
- **Shared utilities**: Leverage [rds/rds-flyway-migration-shared/](mdc:rds/rds-flyway-migration-shared/)
19+
20+
## SQL Standards
21+
- **Use lowercase** for SQL keywords and identifiers
22+
- **snake_case naming** for tables and columns
23+
- **Parameterized queries only** - no string concatenation
24+
- **Verify no SQL injection risks** in all queries
25+
26+
## Entity Design
27+
- **Immutable entities** where possible using `val` properties
28+
- **Proper relationships** using Jimmer associations
29+
- **Validation annotations** for data integrity
30+
- **Audit fields** for tracking changes
31+
32+
## Repository Patterns
33+
- **Interface-based repositories** for testability
34+
- **Transaction boundaries** clearly defined
35+
- **Error handling** with meaningful exceptions
36+
- **Pagination support** for large datasets
37+
38+
## Testing Database Code
39+
- **Use TestContainers** for integration tests via [testtoolkit/](mdc:testtoolkit/)
40+
- **Test migrations** in isolated environments
41+
- **Verify data integrity** constraints
42+
- **Test rollback scenarios** for critical operations
43+
44+
## Performance Considerations
45+
- **Lazy loading** configuration for associations
46+
- **Query optimization** using Jimmer's features
47+
- **Connection pooling** via HikariCP
48+
- **Index strategies** for frequently queried fields
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
description: General development workflow and best practices
3+
---
4+
5+
# Development Workflow
6+
7+
General development practices and workflow guidelines based on [docs/GLOBAL_CLAUDE.md](mdc:docs/GLOBAL_CLAUDE.md).
8+
9+
## Development Process
10+
1. **Task breakdown**: Split complex tasks into smaller modules
11+
2. **Incremental development**: Write small code portions with immediate testing
12+
3. **TDD approach**: Test-driven development with red-green-refactor cycle
13+
4. **Code review**: Ensure code quality and adherence to standards
14+
15+
## Code Quality Standards
16+
- **Early return**: Maximize use to reduce nesting levels
17+
- **Meaningful names**: Avoid abbreviations, use descriptive names
18+
- **Single responsibility**: Functions and classes should have one purpose
19+
- **Immutability**: Prefer immutable data structures and `val` declarations
20+
21+
## Forbidden Practices
22+
- **No example code**: Never write user-facing example code
23+
- **No problem simplification**: Don't solve problems by reducing complexity
24+
- **No dependency downgrades**: Don't solve issues by downgrading versions
25+
- **No test assertion reduction**: Don't reduce test coverage to fix issues
26+
- **No exception hiding**: Never ignore or suppress exceptions
27+
- **No sensitive data exposure**: Never commit API keys, passwords, tokens
28+
29+
## Logging Standards
30+
- **Comprehensive logging**: Add detailed logging for debugging and monitoring
31+
- **Structured logging**: Use consistent log formats
32+
- **No println**: Use proper logging framework, never `println` or `System.out.println`
33+
- **Debug logs**: Allowed during development, remove after completion
34+
35+
## Documentation Requirements
36+
- **English comments**: Use English for all code documentation
37+
- **Explain why**: Comments should explain reasoning, not what code does
38+
- **KDoc**: Document all public APIs
39+
- **No auto-generated docs**: Don't create summary documents automatically
40+
41+
## Error Handling
42+
- **Proper exception handling**: Never ignore exceptions
43+
- **Meaningful error messages**: Provide context for debugging
44+
- **Graceful degradation**: Handle failures appropriately
45+
- **Logging errors**: Log errors with sufficient context
46+
47+
## Performance Considerations
48+
- **Lazy loading**: Use where appropriate
49+
- **Resource management**: Proper cleanup of resources
50+
- **Caching strategies**: Implement appropriate caching
51+
- **Database optimization**: Efficient queries and indexing
52+
53+
## Security Mindset
54+
- **Input validation**: Validate all external inputs
55+
- **Output encoding**: Prevent injection attacks
56+
- **Secure defaults**: Use secure configurations by default
57+
- **Regular updates**: Keep dependencies updated for security patches
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
globs: *.gradle.kts,gradle/**/*,**/build.gradle.kts
3+
---
4+
5+
# Gradle Build Conventions
6+
7+
Standards for Gradle build scripts and dependency management.
8+
9+
## Build Script Structure
10+
- **Kotlin DSL**: Use `.gradle.kts` for all build scripts
11+
- **Version Catalog**: Reference [gradle/libs.versions.toml](mdc:gradle/libs.versions.toml) for all dependencies
12+
- **Build Logic**: Custom conventions in [build-logic/](mdc:build-logic/) directory
13+
- **Type-safe accessors**: Leverage `libs.` and `projects.` accessors
14+
15+
## Dependency Management
16+
- **Version Catalog**: All versions centralized in [gradle/libs.versions.toml](mdc:gradle/libs.versions.toml)
17+
- **BOM usage**: Import [bom/](mdc:bom/) for internal dependency alignment
18+
- **No version conflicts**: Use dependency resolution strategies
19+
- **Security scanning**: OWASP dependency check enabled in root build
20+
21+
## Plugin Application
22+
- **Plugin DSL**: Use `plugins {}` block with version catalog aliases
23+
- **Custom plugins**: Apply from [gradle-plugin/](mdc:gradle-plugin/) module
24+
- **Build conventions**: Apply from [build-logic/](mdc:build-logic/) for consistency
25+
26+
## Module Configuration
27+
- **Consistent structure**: Follow patterns from existing modules
28+
- **Shared configurations**: Use build conventions for common setup
29+
- **Testing setup**: Include [testtoolkit/](mdc:testtoolkit/) for test utilities
30+
- **Publishing**: Configure for Maven Central via [gradle-plugin/](mdc:gradle-plugin/)
31+
32+
## Build Performance
33+
- **Gradle daemon**: Configured in [gradle/gradle-daemon-jvm.properties](mdc:gradle/gradle-daemon-jvm.properties)
34+
- **Parallel builds**: Enable for multi-module project
35+
- **Build cache**: Use for faster incremental builds
36+
- **Configuration cache**: Enable where possible
37+
38+
## Quality Gates
39+
- **Spotless**: Code formatting via build conventions
40+
- **Detekt**: Static analysis for Kotlin code
41+
- **Test coverage**: JaCoCo integration
42+
- **Dependency updates**: Automated via version catalog update plugin
43+
44+
## Publishing Configuration
45+
- **Maven Central**: Publishing setup in [gradle-plugin/](mdc:gradle-plugin/)
46+
- **Signing**: GPG signing for releases
47+
- **Metadata**: Complete POM information
48+
- **Staging**: Sonatype OSSRH staging process
49+
50+
## Example Module Build Script
51+
```kotlin
52+
plugins {
53+
id("buildlogic.kotlin-library-conventions")
54+
id("buildlogic.publishing-conventions")
55+
}
56+
57+
dependencies {
58+
api(projects.shared)
59+
implementation(libs.spring.boot.starter)
60+
testImplementation(projects.testtoolkit)
61+
}
62+
```

.cursor/rules/kotlin-standards.mdc

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
globs: *.kt,*.kts
3+
---
4+
5+
# Kotlin Development Standards
6+
7+
Based on [docs/GLOBAL_CLAUDE.md](mdc:docs/GLOBAL_CLAUDE.md), follow these strict Kotlin conventions:
8+
9+
## Variable Declarations
10+
- **Always prefer `val`** over `var` for immutable variables
11+
- Use descriptive names, avoid abbreviations
12+
- **Forbidden**: `util`, `utils`, `tool` in naming
13+
14+
## Null Safety
15+
- **Avoid `!!` operator** - use `?.` or `let{}` instead
16+
- Prefer safe calls and Elvis operator
17+
- Use `let`, `run`, `with`, `apply` scope functions appropriately
18+
19+
## Function Design
20+
- **Use data classes** instead of functions with many parameters
21+
- **Maximize `early return`** to reduce nesting levels
22+
- Keep functions small and focused on single responsibility
23+
24+
## Testing Standards
25+
- **Use `mockk`** instead of Mockito for mocking
26+
- **Forbidden**: `@DisplayName` annotations
27+
- Test method names use backticks with Chinese descriptions: `fun \`测试用户创建成功\`()`
28+
- **Nested test organization**: Use `@Nested inner class` for grouping
29+
- **Every test must have assertions** - no assertion-free tests allowed
30+
31+
## Logging
32+
- **Forbidden**: `println` for output - use proper logging framework
33+
- Add comprehensive logging for debugging and monitoring
34+
- Use structured logging with meaningful context
35+
36+
## Code Quality
37+
- **Forbidden**: `@Suppress` annotations to hide warnings
38+
- **Forbidden**: Exposing API keys, passwords, tokens in code
39+
- Handle exceptions properly - never ignore or hide them
40+
- Use meaningful variable and function names
41+
42+
## Spring Framework
43+
- **Use `@Resource`** instead of `@Autowired` for dependency injection
44+
- Follow Spring Boot 3.5.x conventions
45+
- Leverage Kotlin-specific Spring features
46+
47+
## Build Scripts (*.kts)
48+
- Use Kotlin DSL for Gradle build scripts
49+
- Leverage type-safe project accessors
50+
- Follow version catalog conventions from [gradle/libs.versions.toml](mdc:gradle/libs.versions.toml)

0 commit comments

Comments
 (0)