From fdda910ee0fbc448a476d3b4e8f46cd5f68a9800 Mon Sep 17 00:00:00 2001 From: jhauga Date: Mon, 3 Nov 2025 22:36:13 -0500 Subject: [PATCH] manual check, indent ruby-mcp, balance convert-jpa fencing --- ...-jpa-to-spring-data-cosmos.instructions.md | 107 ++++++++++-------- .../devbox-image-definition.instructions.md | 6 +- prompts/ruby-mcp-server-generator.prompt.md | 37 +++--- scripts/indent-nested-md-code.js | 8 ++ 4 files changed, 92 insertions(+), 66 deletions(-) diff --git a/instructions/convert-jpa-to-spring-data-cosmos.instructions.md b/instructions/convert-jpa-to-spring-data-cosmos.instructions.md index 7481e08..28bb92f 100644 --- a/instructions/convert-jpa-to-spring-data-cosmos.instructions.md +++ b/instructions/convert-jpa-to-spring-data-cosmos.instructions.md @@ -34,13 +34,16 @@ This generalized guide applies to any JPA to Spring Data Cosmos DB conversion pr ### Step 2 — Properties and Configuration - Create `src/main/resources/application-cosmos.properties`: + ```properties azure.cosmos.uri=${COSMOS_URI:https://localhost:8081} azure.cosmos.database=${COSMOS_DATABASE:petclinic} azure.cosmos.populate-query-metrics=false azure.cosmos.enable-multiple-write-locations=false ``` + - Update `src/main/resources/application.properties`: + ```properties spring.profiles.active=cosmos ``` @@ -48,6 +51,7 @@ This generalized guide applies to any JPA to Spring Data Cosmos DB conversion pr ### Step 3 — Configuration class with Azure Identity - Create `src/main/java//config/CosmosConfiguration.java`: + ```java @Configuration @EnableCosmosRepositories(basePackages = "") @@ -76,6 +80,7 @@ This generalized guide applies to any JPA to Spring Data Cosmos DB conversion pr } ``` + - **IMPORTANT**: Use `DefaultAzureCredentialBuilder().build()` instead of key-based authentication for production security ### Step 4 — Entity transformation @@ -103,6 +108,7 @@ This generalized guide applies to any JPA to Spring Data Cosmos DB conversion pr - **CRITICAL - Authentication Entity Pattern**: - **For User entities with Spring Security**: Store authorities as `Set` instead of `Set` objects - **Example User entity transformation**: + ```java @Container(containerName = "users") public class User { @@ -131,6 +137,7 @@ This generalized guide applies to any JPA to Spring Data Cosmos DB conversion pr } ``` + - **CRITICAL - Template Compatibility for Relationship Changes**: - **When converting relationships to ID references, preserve template access** - **Example**: If entity had `List specialties` → convert to: @@ -194,6 +201,7 @@ This generalized guide applies to any JPA to Spring Data Cosmos DB conversion pr - **CRITICAL**: Create service classes to bridge Cosmos document storage with existing template expectations - **Purpose**: Handle relationship population and maintain template compatibility - **Service pattern for each entity with relationships**: + ```java @Service public class EntityService { @@ -242,6 +250,7 @@ This generalized guide applies to any JPA to Spring Data Cosmos DB conversion pr ### Step 6.5 — **Spring Security Integration** (CRITICAL for Authentication) - **UserDetailsService Integration Pattern**: + ```java @Service @Transactional @@ -277,6 +286,7 @@ This generalized guide applies to any JPA to Spring Data Cosmos DB conversion pr } ``` + - **Key Authentication Requirements**: - User entity must be fully serializable (no `@JsonIgnore` on password/authorities) - Store authorities as `Set` for Cosmos DB compatibility @@ -329,6 +339,7 @@ private void populateRelationships(Entity entity) { ### Step 7 — Data seeding - Create `@Component` implementing `CommandLineRunner`: + ```java @Component public class DataSeeder implements CommandLineRunner { @@ -344,6 +355,7 @@ private void populateRelationships(Entity entity) { } ``` + - **CRITICAL - BigDecimal Reflection Issues with JDK 17+**: - **If using BigDecimal fields**, you may encounter reflection errors during seeding - **Error pattern**: `Unable to make field private final java.math.BigInteger java.math.BigDecimal.intVal accessible` @@ -505,7 +517,7 @@ private void populateRelationships(Entity entity) { - Service layer not populating transient relationship properties - Controllers not using service layer for relationship loading -#### **Template compatibility fixes**: +#### **Template compatibility fixes** - **If templates access relationship properties** (e.g., `entity.relatedObjects`): - Ensure transient properties exist on entities with proper getters/setters @@ -515,7 +527,7 @@ private void populateRelationships(Entity entity) { - `Property or field 'xxx' cannot be found` → Add missing transient property - `EL1008E` errors → Service layer not populating relationships -#### **Service layer verification**: +#### **Service layer verification** - **Ensure all controllers use service layer** instead of direct repository access - **Verify service methods populate relationships** before returning entities @@ -555,7 +567,7 @@ When encountering template errors: ### Step 10 — **Systematic Error Resolution Process** -#### When compilation fails: +#### When compilation fails 1. **Run `mvn compile` first** - fix main source issues before tests 2. **Run `mvn test-compile`** - systematically fix each test compilation error @@ -567,7 +579,7 @@ When encountering template errors: ### Step 10 — **Systematic Error Resolution Process** -#### When compilation fails: +#### When compilation fails 1. **Run `mvn compile` first** - fix main source issues before tests 2. **Run `mvn test-compile`** - systematically fix each test compilation error @@ -576,7 +588,8 @@ When encountering template errors: - `method X cannot be applied to given types` → Remove pagination parameters - `cannot find symbol: method Y()` → Update to new repository method names - Method signature conflicts → Rename conflicting methods -#### When runtime fails: + +#### When runtime fails 1. **Check application logs** for specific error messages 2. **Look for template/SpEL errors**: @@ -585,7 +598,7 @@ When encountering template errors: 3. **Verify service layer usage** in controllers 4. **Test navigation through all application pages** -#### Common error patterns and solutions: +#### Common error patterns and solutions - **`method findByLastNameStartingWith cannot be applied`** → Remove `Pageable` parameter - **`cannot find symbol: method findPetTypes()`** → Change to `findAllOrderByName()` @@ -712,7 +725,7 @@ If runtime fails after successful compilation: ### **Authentication Troubleshooting Guide** (CRITICAL) -#### **Common Authentication Serialization Errors**: +#### **Common Authentication Serialization Errors** 1. **`Cannot pass null or empty values to constructor`**: @@ -751,7 +764,7 @@ If runtime fails after successful compilation: - **Solution**: Update repository `findOneByLogin` method to work with Cosmos DB - **Verification**: Test repository methods independently -#### **Authentication Debugging Checklist**: +#### **Authentication Debugging Checklist** - [ ] User entity fully serializable (no `@JsonIgnore` on persisted fields) - [ ] Password field accessible and not null @@ -823,6 +836,7 @@ default List customFindMethod() { ``` 3. **Add JVM argument** (if BigDecimal must be kept): + ``` --add-opens java.base/java.math=ALL-UNNAMED ``` @@ -872,10 +886,11 @@ public Set getRelatedEntities() { .map(Optional::get) .collect(Collectors.toSet()); } +``` ### **Enhanced Error Resolution Process** -#### **Common Error Patterns and Solutions**: +#### **Common Error Patterns and Solutions** 1. **Reactive Type Casting Errors**: - **Pattern**: `cannot be cast to java.util.List` @@ -897,7 +912,8 @@ public Set getRelatedEntities() { - **Fix**: Update service methods to handle String-based entity references - **Files**: Service classes, DTOs, entity relationship methods -#### **Enhanced Validation Checklist**: +#### **Enhanced Validation Checklist** + - [ ] **Repository reactive casting handled**: No ClassCastException on collection returns - [ ] **BigDecimal compatibility resolved**: Java 17+ serialization works - [ ] **Health checks updated**: No database dependencies in health configuration @@ -912,39 +928,40 @@ public Set getRelatedEntities() { ### **Top Runtime Issues to Check** 1. **Repository Collection Casting**: - ```java - // Fix any repository methods that return collections: - default List customFindMethod() { - return StreamSupport.stream(this.findAll().spliterator(), false) - .collect(Collectors.toList()); - } - - 2. **BigDecimal Compatibility (Java 17+)**: - - ```java - // Replace BigDecimal fields with alternatives: - private Double amount; // Or String for high precision - ``` - - 3. **Health Check Configuration**: - ```yaml - # Remove database dependencies from health checks: - management: - health: - readiness: - include: 'ping,diskSpace' - ``` - - ### **Authentication Conversion Patterns** - - - **Remove `@JsonIgnore` from fields that need Cosmos DB persistence** - - **Store complex objects as simple types** (e.g., authorities as `Set`) - - **Convert between simple and complex types** in service/repository layers - - ### **Template/UI Compatibility Patterns** - - - **Add transient properties** with `@JsonIgnore` for UI access to related data - - **Use service layer** to populate transient relationships before rendering - - **Never return repository results directly** to templates without relationship population - \ No newline at end of file + ```java + // Fix any repository methods that return collections: + default List customFindMethod() { + return StreamSupport.stream(this.findAll().spliterator(), false) + .collect(Collectors.toList()); + } + +2. **BigDecimal Compatibility (Java 17+)**: + + ```java + // Replace BigDecimal fields with alternatives: + private Double amount; // Or String for high precision + + ``` + +3. **Health Check Configuration**: + + ```yaml + # Remove database dependencies from health checks: + management: + health: + readiness: + include: 'ping,diskSpace' + ``` + +### **Authentication Conversion Patterns** + +- **Remove `@JsonIgnore` from fields that need Cosmos DB persistence** +- **Store complex objects as simple types** (e.g., authorities as `Set`) +- **Convert between simple and complex types** in service/repository layers + +### **Template/UI Compatibility Patterns** + +- **Add transient properties** with `@JsonIgnore` for UI access to related data +- **Use service layer** to populate transient relationships before rendering +- **Never return repository results directly** to templates without relationship population diff --git a/instructions/devbox-image-definition.instructions.md b/instructions/devbox-image-definition.instructions.md index 4e5b90a..75c6a93 100644 --- a/instructions/devbox-image-definition.instructions.md +++ b/instructions/devbox-image-definition.instructions.md @@ -226,9 +226,9 @@ Option 2: GitHub Release Once installed, you can search for packages locally: -```cmd -winget search "Visual Studio Code" -``` + ```cmd + winget search "Visual Studio Code" + ``` This will help you find the exact package IDs (like `Microsoft.VisualStudioCode`) needed for your image definition files and understand which winget sources you will need to use. diff --git a/prompts/ruby-mcp-server-generator.prompt.md b/prompts/ruby-mcp-server-generator.prompt.md index b4a6e5a..fe81d57 100644 --- a/prompts/ruby-mcp-server-generator.prompt.md +++ b/prompts/ruby-mcp-server-generator.prompt.md @@ -386,6 +386,7 @@ end ``` Make the file executable: + ```bash chmod +x bin/mcp-server ``` @@ -622,24 +623,24 @@ Add to `claude_desktop_config.json`: ## Project Structure -``` -my-mcp-server/ -├── Gemfile # Dependencies -├── Rakefile # Build tasks -├── lib/ # Source code -│ ├── my_mcp_server.rb # Main entry point -│ └── my_mcp_server/ # Module namespace -│ ├── server.rb # Server setup -│ ├── tools/ # Tool implementations -│ ├── prompts/ # Prompt templates -│ └── resources/ # Resource handlers -├── bin/ # Executables -│ └── mcp-server # Stdio server -├── test/ # Test suite -│ ├── test_helper.rb # Test configuration -│ └── tools/ # Tool tests -└── README.md # This file -``` + ``` + my-mcp-server/ + ├── Gemfile # Dependencies + ├── Rakefile # Build tasks + ├── lib/ # Source code + │ ├── my_mcp_server.rb # Main entry point + │ └── my_mcp_server/ # Module namespace + │ ├── server.rb # Server setup + │ ├── tools/ # Tool implementations + │ ├── prompts/ # Prompt templates + │ └── resources/ # Resource handlers + ├── bin/ # Executables + │ └── mcp-server # Stdio server + ├── test/ # Test suite + │ ├── test_helper.rb # Test configuration + │ └── tools/ # Tool tests + └── README.md # This file + ``` ## License diff --git a/scripts/indent-nested-md-code.js b/scripts/indent-nested-md-code.js index 899c558..715f8bd 100644 --- a/scripts/indent-nested-md-code.js +++ b/scripts/indent-nested-md-code.js @@ -79,6 +79,14 @@ function processFile(filePath) { if (!inOuter) { // Look for start of an outer fence if (m) { + const rest = m.groups.rest || ''; + // Check if this is a single-line fence (opening and closing on same line) + const closingMatch = rest.match(new RegExp(`\`{${m.groups.ticks.length},}\\s*$`)); + if (closingMatch) { + // Single-line code block, skip it + i++; + continue; + } inOuter = true; outerIndent = m.groups.indent || ''; outerTicksLen = m.groups.ticks.length;