Skip to content

Commit 6d8966e

Browse files
authored
Add cursor rule to run pre-commit, update devcontainer for recipes to install cursor-agent (#1311)
Signed-off-by: Peter St. John <[email protected]>
1 parent 541b254 commit 6d8966e

File tree

5 files changed

+49
-3
lines changed

5 files changed

+49
-3
lines changed

.cursorrules

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Cursor Rules for BioNeMo Framework
2+
3+
## Pre-commit and Linting
4+
5+
1. **Always run pre-commit hooks after making changes:**
6+
- After editing any file, run `pre-commit run --all-files` or `pre-commit run` to check modified files
7+
- If pre-commit hooks fail, fix the issues before considering the task complete
8+
- Pre-commit hooks include:
9+
- Ruff linting and formatting (with auto-fix)
10+
- Markdown formatting
11+
- License header checks
12+
- Trailing whitespace and end-of-file fixes
13+
- YAML validation
14+
- Secret detection
15+
16+
2. **Fix linter errors immediately:**
17+
- When making code changes, check for linter errors using `read_lints` tool
18+
- Fix all linter errors before completing the task
19+
- The project uses:
20+
- Ruff for Python linting and formatting (configured in pyproject.toml)
21+
- Pyright for type checking (configured in pyproject.toml)
22+
- Ruff will auto-fix many issues, but you should verify all fixes are appropriate
23+
24+
3. **Code quality standards:**
25+
- Follow the project's ruff configuration (line-length: 119, specific ignores)
26+
- Ensure all Python files follow Google-style docstrings (pydocstyle convention)
27+
- Import sorting follows isort configuration (2 lines after imports)
28+
- Test files and `__init__.py` files have relaxed linting rules as configured
29+
30+
4. **Workflow:**
31+
- Make code changes
32+
- Check for linter errors with `read_lints`
33+
- Fix any linter errors
34+
- Run pre-commit: `pre-commit run --all-files` or `pre-commit run` for changed files
35+
- If pre-commit fails, fix the issues and re-run until all checks pass
36+
- Only mark a task as complete when all linter errors are resolved and pre-commit passes
37+
38+
5. **Exceptions:**
39+
- If a linting rule genuinely conflicts with the required change or is a false positive, document why in comments
40+
- Some files may have per-file ignores configured in pyproject.toml - respect those configurations

.devcontainer/recipes/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ RUN --mount=type=cache,target=/root/.cache/pip \
44
PIP_CONSTRAINT= pip install -r /workspace/requirements.txt
55

66
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/
7+
USER ubuntu
8+
RUN curl https://cursor.com/install -fsS | bash # Install cursor-agent CLI tool
9+
RUN uv tool install pre-commit --with pre-commit-uv --force-reinstall

.devcontainer/recipes/devcontainer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
"source=${localEnv:HOME}/.netrc,target=/home/ubuntu/.netrc,type=bind,consistency=cached",
1111
"source=${localEnv:HOME}/.bash_history_devcontainer,target=/home/ubuntu/.bash_history,type=bind,consistency=cached",
1212
"source=${localEnv:HOME}/.ssh,target=/home/ubuntu/.ssh,readonly,type=bind,consistency=cached",
13-
"source=${localEnv:HOME}/.gnupg,target=/home/ubuntu/.gnupg,type=bind,consistency=cached"
13+
"source=${localEnv:HOME}/.gnupg,target=/home/ubuntu/.gnupg,type=bind,consistency=cached",
14+
"source=${localEnv:HOME}/.config,target=/home/ubuntu/.config,type=bind,consistency=cached",
15+
"source=${localEnv:HOME}/.cursor,target=/home/ubuntu/.cursor,type=bind,consistency=cached"
1416
],
1517
"postCreateCommand": ".devcontainer/recipes/postCreateCommand.sh",
1618
"initializeCommand": ".devcontainer/recipes/initializeCommand.sh",
@@ -20,7 +22,7 @@
2022
"--shm-size=4g"
2123
],
2224
"containerEnv": {
23-
"PRE_COMMIT_HOME": "/home/ubuntu/.cache/pre-commit-devcontainer"
25+
"PRE_COMMIT_HOME": "/home/ubuntu/.cache/pre-commit-devcontainer",
2426
},
2527
"customizations": {
2628
"vscode": {

.devcontainer/recipes/initializeCommand.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ mkdir -p ~/.devcontainer_cache
55
mkdir -p ~/.ssh
66
mkdir -p ~/.cache/pre-commit-devcontainer
77
mkdir -p ~/.gnupg
8+
mkdir -p ~/.config
9+
mkdir -p ~/.cursor
810
[ ! -f ~/.netrc ] && touch ~/.netrc
911

1012
# Create the ~/.bash_history_devcontainer file if it doesn't exist

.devcontainer/recipes/postCreateCommand.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
3-
uv tool install pre-commit --with pre-commit-uv --force-reinstall
43
# Run via uv to avoid relying on updated PATH in this shell
54
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
65
uvx pre-commit install

0 commit comments

Comments
 (0)