Skip to content

Conversation

@ezyang
Copy link
Owner

@ezyang ezyang commented Mar 16, 2025

Stack from ghstack (oldest at bottom):

Let's add support for .cursor/rules. These folders can live in any directory in a project and contain mdc files each of which have this format (triple hyphen, key-colon-values, triple hyphen, markdown payload):


```git-revs
d997f92  (Base revision)
HEAD     Add pyyaml dependency for parsing MDC files

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
ezyang added a commit that referenced this pull request Mar 16, 2025
Let's add support for .cursor/rules. These folders can live in any directory in a project and contain mdc files each of which have this format (triple hyphen, key-colon-values, triple hyphen, markdown payload).

Rule traversal in codemcp/tools/read_file.py and codemcp/tools/user_prompt.py have duplicate logic for finding rules. Refactor it into a helper function. The helper function should have an optional argument for path, and the code should be generic for when you have path and when you don't.

```git-revs
d997f92  (Base revision)
8c45e42  Add pyyaml dependency for parsing MDC files
b4247d4  Add find_git_root to git_query.py __all__ list
07b80ad  Add find_git_root function to git_query.py
1fff3b1  Remove find_git_root from common.py __all__ list
b9b5698  Remove find_git_root function from common.py
0e59276  Update import in read_file.py to import find_git_root from git_query
86585e4  Update import in user_prompt.py to import find_git_root from git_query
3ea2451  Auto-commit format changes
7a844d8  Auto-commit lint changes
7690b75  Add get_applicable_rules_content to __all__
88de103  Add get_applicable_rules_content helper function
b012162  Update imports to use new helper function
a7f147d  Update read_file.py to use new helper function
073b97e  Update imports in user_prompt.py
5824407  Update user_prompt.py to use new helper function
HEAD     Auto-commit format changes
```

ghstack-source-id: 6849418
Pull Request resolved: #77
[ghstack-poisoned]
ezyang added a commit that referenced this pull request Mar 16, 2025
Let's add support for .cursor/rules. These folders can live in any directory in a project and contain mdc files each of which have this format (triple hyphen, key-colon-values, triple hyphen, markdown payload).

Rule traversal in codemcp/tools/read_file.py and codemcp/tools/user_prompt.py have duplicate logic for finding rules. Refactor it into a helper function. The helper function should have an optional argument for path, and the code should be generic for when you have path and when you don't.

```git-revs
d997f92  (Base revision)
8c45e42  Add pyyaml dependency for parsing MDC files
b4247d4  Add find_git_root to git_query.py __all__ list
07b80ad  Add find_git_root function to git_query.py
1fff3b1  Remove find_git_root from common.py __all__ list
b9b5698  Remove find_git_root function from common.py
0e59276  Update import in read_file.py to import find_git_root from git_query
86585e4  Update import in user_prompt.py to import find_git_root from git_query
3ea2451  Auto-commit format changes
7a844d8  Auto-commit lint changes
7690b75  Add get_applicable_rules_content to __all__
88de103  Add get_applicable_rules_content helper function
b012162  Update imports to use new helper function
a7f147d  Update read_file.py to use new helper function
073b97e  Update imports in user_prompt.py
5824407  Update user_prompt.py to use new helper function
HEAD     Auto-commit format changes
```

chore: Sample Cursor rule

test: implement E2E flow in test_cursor_rules.py using stdio_client

Modify test_cursor_rules.py to actually do the E2E flow using stdio_client (look at test_write_file.py for an example).

```git-revs
a2a63a8  (Base revision)
72076d8  Implement E2E flow using stdio_client in test_cursor_rules.py
27b2b2f  Add missing subprocess import
a0351e3  Auto-commit lint changes
08a87ea  Update JavaScript file test assertions
2ae058e  Update UserPrompt test assertions
HEAD     Update Python file test assertions
```

test: run and fix failing tests

Run and fix tests

```git-revs
dabff99  (Base revision)
ab40d4e  Fix match_file_with_glob to correctly match file paths against glob patterns
0ae4c1e  Improve match_file_with_glob to handle **/*.js pattern correctly
109e663  Fix load_rule_from_file to initialize globs as an empty list instead of None
da12273  Update Rule class to have non-optional globs field
5a048cd  Manually parse frontmatter to handle unquoted glob patterns
d3c2684  Improve match_file_with_glob to handle patterns like 'src/**/*.jsx'
4d774b2  Simplify match_file_with_glob function with a more direct approach
53532e6  Auto-commit format changes
HEAD     Auto-commit lint changes
```

ghstack-source-id: 2cb3add
Pull Request resolved: #77
[ghstack-poisoned]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants