Skip to content

Commit afbf6da

Browse files
Copilotiloveitaly
andauthored
Create airules Python CLI to replace standalone scripts with download functionality (#5)
* Initial plan * Initial analysis and plan for migrating scripts to llm-rules CLI Co-authored-by: iloveitaly <150855+iloveitaly@users.noreply.github.com> * Implement llm-rules CLI with explode, implode, and MCP subcommands Co-authored-by: iloveitaly <150855+iloveitaly@users.noreply.github.com> * Update documentation and add deprecation notices to old scripts Co-authored-by: iloveitaly <150855+iloveitaly@users.noreply.github.com> * Rename Python package directory from src/llm_rules to src/airules Co-authored-by: iloveitaly <150855+iloveitaly@users.noreply.github.com> * Add download subcommand and update project name to airules Co-authored-by: iloveitaly <150855+iloveitaly@users.noreply.github.com> * Use uvx instead of pip for primary CLI installation method Co-authored-by: iloveitaly <150855+iloveitaly@users.noreply.github.com> * Remove obvious CLI wrapper commands from Justfile and delete old scripts Co-authored-by: iloveitaly <150855+iloveitaly@users.noreply.github.com> * Address PR review comments: remove empty init, use keys for defaults, replace print with typer.echo, remove MCP command, convert constants to JSON with CLI override Co-authored-by: iloveitaly <150855+iloveitaly@users.noreply.github.com> * Add comprehensive tests for all core commands (explode, implode, download) and fix CLI structure Co-authored-by: iloveitaly <150855+iloveitaly@users.noreply.github.com> * Address PR review comments: remove constants test, rename sections.json, enable python -m airules support Co-authored-by: iloveitaly <150855+iloveitaly@users.noreply.github.com> * Move source from src/airules to airules/ and remove --help file Co-authored-by: iloveitaly <150855+iloveitaly@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: iloveitaly <150855+iloveitaly@users.noreply.github.com>
1 parent ce5ae98 commit afbf6da

17 files changed

Lines changed: 1480 additions & 159 deletions

Justfile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,23 @@
33

44
# Set up the Python environment
55
setup:
6-
uv venv && uv sync
6+
uv sync
77
@echo "activate: source ./.venv/bin/activate"
88

9-
# Start docker services
10-
up:
11-
docker compose up -d --wait
9+
# Build the package
10+
build:
11+
uv build
12+
13+
14+
15+
test:
16+
pytest
17+
18+
1219

1320
# Clean build artifacts and cache
1421
clean:
15-
rm -rf *.egg-info .venv
22+
rm -rf *.egg-info .venv dist/
1623
find . -type d -name "__pycache__" -prune -exec rm -rf {} \; 2>/dev/null || true
1724

1825
# Update copier template

README.md

Lines changed: 79 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,99 @@ Additionally, it becomes challenging to copy these prompts into various projects
88

99
Some of the glob assumptions in this repo are specific to how I've chosen to organize python and typescript [in the python starter template](https://github.com/iloveitaly/python-starter-template) and what tooling (fastapi, etc) that I've chosen to use.
1010

11+
## Installation
12+
13+
You can run the `airules` CLI tool using uvx:
14+
15+
```sh
16+
uvx airules
17+
```
18+
19+
Or install from the repository:
20+
21+
```sh
22+
uv tool install git+https://github.com/iloveitaly/llm-ide-prompts.git
23+
```
24+
25+
```sh
26+
git clone https://github.com/iloveitaly/llm-ide-prompts.git
27+
cd llm-ide-prompts
28+
uv sync
29+
source .venv/bin/activate
30+
```
31+
1132
## Usage
1233

13-
You can then download the rules into your project:
34+
### CLI Commands
35+
36+
The `airules` CLI provides commands to manage LLM IDE prompts and rules:
1437

1538
```sh
16-
# Download .cursor rules
17-
curl -sSL https://raw.githubusercontent.com/iloveitaly/llm-ide-prompts/master/download.sh | sh -s cursor
39+
# Convert instruction file to separate rule files
40+
uvx airules explode [input_file]
41+
42+
# Bundle rule files back into a single instruction file
43+
uvx airules implode cursor [output_file] # Bundle Cursor rules
44+
uvx airules implode github [output_file] # Bundle GitHub/Copilot instructions
45+
46+
# Download instruction files from repositories
47+
uvx airules download [instruction_types] # Download everything by default
48+
uvx airules download cursor github # Download specific types
49+
uvx airules download --repo other/repo # Download from different repo
1850

19-
# Download .github rules
20-
curl -sSL https://raw.githubusercontent.com/iloveitaly/llm-ide-prompts/master/download.sh | sh -s github
2151

22-
# Download AGENT.md (for Amp)
23-
curl -sSL https://raw.githubusercontent.com/iloveitaly/llm-ide-prompts/master/AGENT.md > AGENT.md
52+
```
53+
54+
### Examples
55+
56+
```sh
57+
# Explode instructions.md into .cursor/rules/ and .github/instructions/
58+
uvx airules explode instructions.md
59+
60+
# Bundle Cursor rules back into a single file
61+
uvx airules implode cursor bundled-instructions.md
62+
63+
# Bundle GitHub instructions with verbose logging
64+
uvx airules implode github --verbose instructions.md
65+
66+
# Download everything from default repository
67+
uvx airules download
68+
69+
# Download only specific instruction types
70+
uvx airules download cursor github
71+
72+
# Download from a different repository
73+
uvx airules download --repo other-user/other-repo --target ./my-project
2474
```
2575

2676
## Development
2777

28-
All instructions in [instructions.md](instructions.md) are exploded out into the various files with default rules applied.
78+
### Using the CLI for Development
79+
80+
The CLI replaces the old standalone scripts. Use the CLI commands in your development workflow:
2981

3082
```shell
31-
just build
83+
# Setup the environment
84+
uv sync
85+
86+
# Explode instructions into separate rule files
87+
uvx airules explode
88+
89+
# Bundle rules back into instructions
90+
uvx airules implode cursor instructions.md
91+
```
92+
93+
### Building and Testing
94+
95+
```shell
96+
# Build the package
97+
uv build
98+
99+
# Run tests
100+
pytest
32101
```
33102

34-
Executes this explosion process.
103+
35104

36105

37106
## Extracting Changes

airules/__init__.py

100755100644
Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
1-
import logging
2-
import os
1+
"""LLM Rules CLI package for managing IDE prompts and rules."""
32

4-
logging.basicConfig(
5-
level=os.environ.get("LOG_LEVEL", "INFO").upper(),
3+
import typer
4+
from typing_extensions import Annotated
5+
6+
from airules.commands.explode import explode_main
7+
from airules.commands.implode import cursor, github
8+
from airules.commands.download import download_main
9+
10+
__version__ = "0.1.0"
11+
12+
app = typer.Typer(
13+
name="airules",
14+
help="CLI tool for managing LLM IDE prompts and rules",
15+
no_args_is_help=True,
616
)
717

8-
logger = logging.getLogger(__name__)
18+
# Add commands directly
19+
app.command("explode", help="Convert instruction file to separate rule files")(explode_main)
20+
app.command("download", help="Download LLM instruction files from GitHub repositories")(download_main)
921

22+
# Create implode sub-typer
23+
implode_app = typer.Typer(help="Bundle rule files into a single instruction file")
24+
implode_app.command("cursor", help="Bundle Cursor rules into a single file")(cursor)
25+
implode_app.command("github", help="Bundle GitHub/Copilot instructions into a single file")(github)
26+
app.add_typer(implode_app, name="implode")
1027

1128
def main():
12-
logger.info("Hello, Logs!")
29+
"""Main entry point for the CLI."""
30+
app()
31+
32+
if __name__ == "__main__":
33+
main()

airules/__main__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"""Entry point for running airules with python -m airules."""
2+
3+
from airules import main
4+
5+
if __name__ == "__main__":
6+
main()

0 commit comments

Comments
 (0)