Skip to main content

A powerful CLI toolkit for extending and enhancing AI capabilities through customizable rules and commands.

Project description

ai-rules [WIP]

🛠️ A powerful CLI toolkit for extending and enhancing AI capabilities through customizable rules and commands.

Transform your AI assistants (Cursor, Windsurf, Cline) into more capable development companions by crafting specialized instruction sets and custom commands.

Inspiration

This project is inspired by devin.cursorrules and the blog post Turning $20 into $500 - Transforming Cursor into Devin in One Hour. We extend these ideas by providing a systematic way to manage and enhance AI rules across different platforms.

Key Features

  • 🧠 Extend AI capabilities through custom rules and commands
  • 🔌 Plugin system for adding new AI functionalities
  • 🌍 Support multiple AI platforms (Cursor, Windsurf, Cline)
  • 🤖 LLM-powered tools (search, translation, etc.)
  • 📝 Global and workspace-specific rule management
  • ⚡ Command extension system for AI enhancement

Installation

pip install ai-rules

Quick Start

Initialize AI Assistant Rules

# Initialize rules for Windsurf
uvx ai-rules init windsurf

# Initialize rules for Cursor
uvx ai-rules init cursor

# Initialize rules for CLI
uvx ai-rules init cli

Use Built-in Plugins

# Search the web
uvx ai-rules plugin search "Python best practices" --limit 5

# Translate text
uvx ai-rules plugin translate "Hello World" --target-lang zh

Plugin Development Guide

Creating a Custom Plugin

  1. Create a new Python file in one of these locations:

    • Built-in plugins: src/ai_rules/plugins/
    • User plugins: ~/.ai-rules/plugins/
    • Virtual environment plugins: venv/lib/ai-rules/plugins/
  2. Implement your plugin by inheriting from the Plugin base class:

from ai_rules.core.plugin import Plugin
import click

class MyCustomPlugin(Plugin):
    """Your custom plugin description."""
    
    name = "my_plugin"  # Command name
    description = "Description of what your plugin does"
    
    def get_command_spec(self) -> dict:
        """Define command line parameters."""
        return {
            "params": [
                {
                    "name": "input_text",
                    "type": click.STRING,
                    "required": True,
                    "help": "Input text to process"
                },
                {
                    "name": "option1",
                    "type": click.INT,
                    "required": False,
                    "default": 42,
                    "help": "An optional parameter"
                }
            ]
        }
    
    def execute(self, input_text: str, option1: int = 42) -> Any:
        """Execute plugin functionality.
        
        Args match the parameters defined in get_command_spec().
        """
        # Your plugin logic here
        result = f"Processed {input_text} with option {option1}"
        return result

Plugin Requirements

  1. Base Class: Must inherit from Plugin
  2. Required Attributes:
    • name: Plugin command name
    • description: Plugin description
  3. Required Methods:
    • get_command_spec(): Define command parameters
    • execute(): Implement plugin logic

Parameter Types

The following Click types are supported:

  • click.STRING: Text input
  • click.INT: Integer numbers
  • click.FLOAT: Floating point numbers
  • click.BOOL: Boolean flags
  • click.Choice(['a', 'b']): Choice from options
  • More types in Click documentation

Example Plugins

Check out our example plugins for reference:

  1. Search Plugin: Web search functionality
  2. Translate Plugin: Text translation
  3. Weather Plugin: Weather information

Using Your Plugin

Once installed, your plugin will be automatically discovered and registered:

# List available plugins
uvx ai-rules plugin --help

# Run your plugin
uvx ai-rules plugin my_plugin "input text" --option1 123

Documentation

Command Structure

  1. Initialize Rules
uvx ai-rules init <assistant-type>
  • assistant-type: windsurf, cursor, or cli
  • Creates configuration files in the current directory
  1. Use Plugins
uvx ai-rules plugin <plugin-name> [arguments]

Development

Project Structure

src/ai_rules/
├── core/
│   ├── plugin.py     # Plugin system
│   ├── template.py   # Template conversion
│   └── __init__.py
├── plugins/          # Built-in plugins
├── templates/        # Rule templates
├── cli.py           # CLI implementation
└── __init__.py

Contributing

Contributions are welcome! Please read our Contributing Guidelines first.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_rules-0.1.1.tar.gz (73.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_rules-0.1.1-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file ai_rules-0.1.1.tar.gz.

File metadata

  • Download URL: ai_rules-0.1.1.tar.gz
  • Upload date:
  • Size: 73.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for ai_rules-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1047b06920b57ecc028a82a5c63936e37087315cbaceea9a87c285fadb9d03f9
MD5 c62b4813f917a20e7c44d056da8830b9
BLAKE2b-256 60a38d9463f0396939046d5366c264524bf26d53aae7f5276b32ffede963aff3

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_rules-0.1.1.tar.gz:

Publisher: python-publish.yml on loonghao/ai-rules

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ai_rules-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ai_rules-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for ai_rules-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b911e7b49fd25a79cdb71b2f604f73b9db975722d362442a9e703444e3de4064
MD5 2054b51aa28e58e6f49b3ee4e907dfa3
BLAKE2b-256 8ccf612c513404d6e71353cd564e559c0034a4eee4c1f25f08e45023a6a900bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_rules-0.1.1-py3-none-any.whl:

Publisher: python-publish.yml on loonghao/ai-rules

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page