From 8b17294a1bec2fa2487096679155f0c3bc54b0c2 Mon Sep 17 00:00:00 2001 From: Brian 'bdougie' Douglas Date: Wed, 25 Jun 2025 20:45:23 -0700 Subject: [PATCH] resolving the Claude rendering issue --- internal/formats/singlefile.go | 4 +- internal/formats/transform_test.go | 95 ++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) diff --git a/internal/formats/singlefile.go b/internal/formats/singlefile.go index c79d4e7..07f3719 100644 --- a/internal/formats/singlefile.go +++ b/internal/formats/singlefile.go @@ -104,7 +104,9 @@ func isAlwaysApply(content []byte) bool { } } - return false + // If alwaysApply is not explicitly set, default to true + // This ensures rules without the alwaysApply field are included in single-file formats + return true } // hasFrontmatter checks if a file has frontmatter diff --git a/internal/formats/transform_test.go b/internal/formats/transform_test.go index 5bb6beb..8a98ecb 100644 --- a/internal/formats/transform_test.go +++ b/internal/formats/transform_test.go @@ -284,6 +284,101 @@ Test content.` } } +func TestIsAlwaysApply(t *testing.T) { + tests := []struct { + name string + content string + expected bool + }{ + { + name: "No frontmatter should return true", + content: `# Test Rule + +This is a test rule without frontmatter.`, + expected: true, + }, + { + name: "Frontmatter with alwaysApply: true should return true", + content: `--- +alwaysApply: true +description: "Test rule" +--- + +# Test Rule + +Test content.`, + expected: true, + }, + { + name: "Frontmatter with alwaysApply: false should return false", + content: `--- +alwaysApply: false +description: "Test rule" +--- + +# Test Rule + +Test content.`, + expected: false, + }, + { + name: "Frontmatter with alwaysApply: 'true' (string) should return true", + content: `--- +alwaysApply: "true" +description: "Test rule" +--- + +# Test Rule + +Test content.`, + expected: true, + }, + { + name: "Frontmatter with alwaysApply: 'false' (string) should return false", + content: `--- +alwaysApply: "false" +description: "Test rule" +--- + +# Test Rule + +Test content.`, + expected: false, + }, + { + name: "Frontmatter without alwaysApply field should return true (default behavior)", + content: `--- +name: "Next.js + Common Libraries" +description: "Test rule" +--- + +# Test Rule + +Test content.`, + expected: true, + }, + { + name: "Empty frontmatter should return true", + content: `--- +--- + +# Test Rule + +Test content.`, + expected: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + result := isAlwaysApply([]byte(tt.content)) + if result != tt.expected { + t.Errorf("isAlwaysApply() = %v, expected %v for content:\n%s", result, tt.expected, tt.content) + } + }) + } +} + func TestTransformRuleContent_CursorFallback(t *testing.T) { tests := []struct { name string