Skip to content

fix: resolving the Claude rendering issue #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion internal/formats/singlefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the ways that this function is used, I think we should allow it to still return false, but should instead change just the rendering logic for CLAUDE.md, etc. files.

I'm happy to do this myself, just lmk, but what I would recommend here is a) change the spec for rendering so that it describes the behavior we want and then b) in Continue, run the @ regenerate command, which will help you update the codebase to match the change in behavior from the spec

I've found this workflow helps keep everything pretty consistent

}

// hasFrontmatter checks if a file has frontmatter
Expand Down
95 changes: 95 additions & 0 deletions internal/formats/transform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down