commit bffd1e7d4bbf77ba19d2021f17631070c523a375 Author: sanjeed5 Date: Mon Feb 17 16:52:32 2025 +0530 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c842bc --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +# Python-generated files +__pycache__/ +*.py[oc] +build/ +dist/ +wheels/ +*.egg-info + +# Virtual environments +.venv + +awesome-cursorrules/ +.env diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..2c07333 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.11 diff --git a/README.md b/README.md new file mode 100644 index 0000000..2aafa41 --- /dev/null +++ b/README.md @@ -0,0 +1,54 @@ +# Cursor Rules MDC Converter + +This script converts Cursor rules from various formats to the `.mdc` format, using LLM to intelligently process and structure the rules. + +## Setup + +1. Install dependencies using `uv`: +```bash +uv venv +source .venv/bin/activate # On Unix/macOS +.venv\Scripts\activate # On Windows +uv sync +``` + +2. Set up your environment variables: +Create a `.env` file with your LLM API key: +``` +GEMINI_API_KEY=your_api_key_here +``` + +## Usage + +The script processes files from the `awesome-cursorrules/rules` directory and: +1. Creates `.mdc` versions in the same folder as the original files +2. Creates a new folder structure in `awesome-cursor-mdc-rules` with the converted files + +### Test Mode + +By default, the script runs in test mode, which only processes 2 folders. To process all folders: + +1. Open `convert_to_mdc.py` +2. Find the line `test_mode = True` +3. Change it to `test_mode = False` + +### Running the Script + +```bash +uv run convert_to_mdc.py +``` + +## Features + +- Retries on API failures with exponential backoff +- Processes files in both original location and separate directory +- Maintains folder structure +- Detailed logging +- Test mode for initial validation + +## Error Handling + +The script includes comprehensive error handling: +- Logs errors for individual file processing +- Continues processing even if some files fail +- Retries LLM API calls on failure diff --git a/mdc-instructions.txt b/mdc-instructions.txt new file mode 100644 index 0000000..6cfafc0 --- /dev/null +++ b/mdc-instructions.txt @@ -0,0 +1,29 @@ +Project rules offers a powerful and flexible system with path specific configurations. Project rules are stored in the .cursor/rules directory and provide granular control over AI behavior in different parts of your project. + +Here’s how they work + +Semantic Descriptions: Each rule can include a description of when it should be applied +File Pattern Matching: Use glob patterns to specify which files/folders the rule applies to +Automatic Attachment: Rules can be automatically included when matching files are referenced +Reference files: Use @file in your project rules to include them as context when the rule is applied. +You can reference rule files using @file, allowing you to chain multiple rules together + +You can create a new rule using the command palette with Cmd + Shift + P > New Cursor Rule. By using project rules you also get the benefit of version control since it’s just a file + +Example use cases: + +Framework-specific rules for certain file types (e.g., SolidJS preferences for .tsx files) +Special handling for auto-generated files (e.g., .proto files) +Custom UI development patterns +Code style and architecture preferences for specific folders + + +Example rule format (remember that file name should end in .mdc): + +--- +description: Python general rules +globs: /service-1/**/*.* +--- +- Always use UV when installing depdendencies +- Always use python 3.12 +- Always use classes instead of function \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..cb2c8c7 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,7 @@ +[project] +name = "cursor-rules-mdc" +version = "0.1.0" +description = "Convert Cursor rules to MDC rules" +readme = "README.md" +requires-python = ">=3.11" +dependencies = [] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8e1a293 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +litellm>=1.30.3 +python-dotenv>=1.0.1 +tenacity>=8.2.3 +ratelimit>=2.2.1 +pydantic>=2.6.1 \ No newline at end of file diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000..f8a465e --- /dev/null +++ b/uv.lock @@ -0,0 +1,7 @@ +version = 1 +requires-python = ">=3.11" + +[[package]] +name = "cursor-rules-mdc" +version = "0.1.0" +source = { virtual = "." }