Skip to content

Commit a9d6b0d

Browse files
authored
Merge pull request #116 from lmnr-ai/cursorrules
cursor rules cli
2 parents 56befe7 + 68d1ac4 commit a9d6b0d

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
[project]
88
name = "lmnr"
9-
version = "0.6.5"
9+
version = "0.6.6"
1010
description = "Python SDK for Laminar"
1111
authors = [
1212
{ name = "lmnr.ai", email = "[email protected]" }

src/lmnr/cli.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import os
55
import re
66
import sys
7+
import urllib.request
8+
import urllib.error
9+
from pathlib import Path
710

811
from lmnr.sdk.evaluations import Evaluation
912

@@ -16,6 +19,39 @@
1619
EVAL_DIR = "evals"
1720

1821

22+
def add_cursor_rules():
23+
"""Download laminar.mdc file from a hardcoded public URL and save it to .cursor/rules/laminar.mdc"""
24+
# Hardcoded URL for the laminar.mdc file
25+
url = "https://raw.githubusercontent.com/lmnr-ai/lmnr/dev/rules/laminar.mdc"
26+
27+
# Create .cursor/rules directory if it doesn't exist
28+
rules_dir = Path(".cursor/rules")
29+
rules_dir.mkdir(parents=True, exist_ok=True)
30+
31+
# Define the target file path
32+
target_file = rules_dir / "laminar.mdc"
33+
34+
try:
35+
LOG.info(f"Downloading laminar.mdc from {url}")
36+
37+
# Download the file
38+
with urllib.request.urlopen(url) as response:
39+
content = response.read()
40+
41+
# Write the content to the target file (this will overwrite if it exists)
42+
with open(target_file, 'wb') as f:
43+
f.write(content)
44+
45+
LOG.info(f"Successfully downloaded laminar.mdc to {target_file}")
46+
47+
except urllib.error.URLError as e:
48+
LOG.error(f"Failed to download file from {url}: {e}")
49+
sys.exit(1)
50+
except Exception as e:
51+
LOG.error(f"Unexpected error: {e}")
52+
sys.exit(1)
53+
54+
1955
async def run_evaluation(args):
2056
sys.path.append(os.getcwd())
2157

@@ -103,8 +139,16 @@ def cli():
103139
help="Fail on error",
104140
)
105141

142+
parser_download = subparsers.add_parser(
143+
"add-cursor-rules",
144+
description="Download laminar.mdc file and add it to .cursor/rules",
145+
help="Download laminar.mdc file and add it to .cursor/rules",
146+
)
147+
106148
parsed = parser.parse_args()
107149
if parsed.subcommand == "eval":
108150
asyncio.run(run_evaluation(parsed))
151+
elif parsed.subcommand == "add-cursor-rules":
152+
add_cursor_rules()
109153
else:
110154
parser.print_help()

src/lmnr/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from packaging import version
44

55

6-
__version__ = "0.6.5"
6+
__version__ = "0.6.6"
77
PYTHON_VERSION = f"{sys.version_info.major}.{sys.version_info.minor}"
88

99

0 commit comments

Comments
 (0)