Skip to content

feat: prefix folder path for colocated rules #6394

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

Merged
merged 5 commits into from
Jul 10, 2025

Conversation

uinstinct
Copy link
Contributor

@uinstinct uinstinct commented Jul 2, 2025

Description

Prepend the folder path in the glob match for the corresponding rules.md file. We want to apply the particular rule for the specific folder only.

  • added a getGlobPattern method for modifying the frontmatter globs
  • added tests for the new glob pattern

Resolves CON-2516

Checklist

  • [] I've read the contributing guide
  • [] The relevant docs, if any, have been updated or created
  • [] The relevant tests, if any, have been updated or created

Screenshots

image

Tests

[ What tests were added or updated to ensure the changes work as expected? ]


Summary by cubic

Updated rule glob patterns to automatically include the folder path of each colocated rules.md file, so rules only apply to files in their specific folder.

  • Refactors
    • Added a helper to prepend the folder path to glob patterns.
    • Updated tests to check the new glob behavior.

@uinstinct uinstinct requested a review from a team as a code owner July 2, 2025 05:49
@uinstinct uinstinct requested review from RomneyDa and removed request for a team July 2, 2025 05:49
Copy link

netlify bot commented Jul 2, 2025

👷 Deploy request for continuedev pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 4d54232

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 2, 2025
sestinj
sestinj previously requested changes Jul 2, 2025
@@ -69,6 +70,30 @@ export function getRuleName(
return displayName;
}

function getGlobPattern(
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't prepend the directory if the rule is inside of .continue/rules

const dir = path.dirname(id.filePath);
const prependDirAndApplyGlobstar = (glob: string) => {
// skip if glob is a directory
if (glob.includes("/")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think would still want to prepend the dir and globstar if it is a directory pattern. For example subdir/ should become path/to/subdir/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes. We can prepend ** in that case as well which would become path/to/**/subdir (thus matching path/to/subdir and also path/to/my/nested/subdir)

Implemented!

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Jul 2, 2025
Copy link
Collaborator

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

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

@uinstinct I'm not sure path.join will work on systems that use backward slash paths, since globs only use forward slash, but path.join might add backwards slashes. is this tested?

@uinstinct
Copy link
Contributor Author

@uinstinct I'm not sure path.join will work on systems that use backward slash paths, since globs only use forward slash, but path.join might add backwards slashes. is this tested?

Yes, path.join would handle this for windows platforms.
I haven't tested this explicitly on windows yet.

@RomneyDa
Copy link
Collaborator

RomneyDa commented Jul 10, 2025

@uinstinct what I mean is path.join will "work" in windows but would result in e.g. path\to\file which will not work with globs, even in windows Node.js

@uinstinct uinstinct requested a review from RomneyDa July 10, 2025 03:19
@uinstinct
Copy link
Contributor Author

@uinstinct what I mean is path.join will "work" in windows but would result in e.g. path\to\file which will not work with globs, even in windows Node.js

Makes sense. Implemented!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 10, 2025
@RomneyDa RomneyDa dismissed sestinj’s stale review July 10, 2025 17:15

feedback has been addressed

@RomneyDa RomneyDa merged commit 2702fb2 into continuedev:main Jul 10, 2025
38 of 39 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Issues and PRs Jul 10, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jul 10, 2025
@uinstinct uinstinct deleted the prefix-folder branch July 11, 2025 03:01
@sestinj
Copy link
Contributor

sestinj commented Jul 22, 2025

🎉 This PR is included in version 1.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm This PR has been approved by a maintainer released size:L This PR changes 100-499 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants