Add source of truth documentation for rules.json in cursor-rules-cli

- Create README.md in cursor-rules-cli to explain rules.json origin
- Enhance logging for rules.json copying process
- Clarify that rules.json is automatically managed and should not be edited directly
This commit is contained in:
sanjeed5
2025-03-03 23:26:25 +05:30
parent 587d8a5696
commit ff0eb34a2b
+15 -1
View File
@@ -743,6 +743,7 @@ def main():
logger.info("MDC generation completed successfully!")
# Copy rules.json to cursor-rules-cli folder
# This is the source of truth - the CLI package will use this during setup
cursor_rules_cli_dir = Path(SCRIPT_DIR).parent / "cursor-rules-cli"
cursor_rules_cli_dir.mkdir(exist_ok=True)
@@ -750,7 +751,20 @@ def main():
try:
shutil.copy2(rules_json_path, target_rules_json)
logger.info(f"Successfully copied rules.json to {target_rules_json}")
logger.info(f"Successfully copied rules.json (source of truth) to {target_rules_json}")
# Add a comment file to explain the source of truth
with open(cursor_rules_cli_dir / "RULES_JSON_README.md", "w") as f:
f.write("""# About rules.json
This rules.json file is automatically copied from the project root.
It is the source of truth for library detection rules.
DO NOT EDIT THIS FILE DIRECTLY.
Instead, edit the main rules.json in the project root and run the generate_mdc_files.py script.
""")
logger.info("Created RULES_JSON_README.md to document the source of truth")
except Exception as e:
logger.error(f"Failed to copy rules.json to cursor-rules-cli folder: {str(e)}")