ai-rulez 1.6.1 β†’ 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,261 +1,166 @@
1
1
  # ai-rulez ⚑
2
2
 
3
- > **Lightning-fast CLI tool (written in Go) for managing AI assistant rules**
3
+ <p align="center">
4
+ <img src="https://raw.githubusercontent.com/Goldziher/ai-rulez/main/docs/assets/logo.png" alt="ai-rulez logo" width="200" style="border-radius: 15%; overflow: hidden;">
5
+ </p>
4
6
 
5
- Generate configuration files for Claude, Cursor, Windsurf, and other AI assistants from a single, centralized configuration.
7
+ **One config to rule them all.**
6
8
 
7
- ## πŸš€ Features
9
+ Tired of manually managing rule files, subagents, and custom commands across different AI tools? `ai-rulez` gives you one `ai-rulez.yml` file to generate them all. Keep your AI context in sync, and even launch MCP servers for direct integration.
8
10
 
9
- - ⚑ **Blazing Fast**: Written in Go for maximum performance
10
- - πŸ”§ **Multi-Assistant Support**: Generate configs for Claude (CLAUDE.md), Cursor (.cursorrules), Windsurf (.windsurfrules), and more
11
- - πŸ“ **Single Source of Truth**: Maintain all your AI rules in one YAML configuration
12
- - 🎯 **Smart Templates**: Built-in templates with custom template support
13
- - πŸ” **Validation**: Comprehensive configuration validation
14
- - πŸ”„ **Git Integration**: Perfect for pre-commit hooks and CI/CD
15
- - πŸ“¦ **Node.js Integration**: Easy installation via npm
11
+ [![Go Version](https://img.shields.io/badge/Go-1.24%2B-00ADD8)](https://go.dev)
12
+ [![NPM Version](https://img.shields.io/npm/v/ai-rulez)](https://www.npmjs.com/package/ai-rulez)
13
+ [![PyPI Version](https://img.shields.io/pypi/v/ai-rulez)](https://pypi.org/project/ai-rulez/)
14
+ [![Homebrew](https://img.shields.io/badge/Homebrew-tap-orange)](https://github.com/Goldziher/homebrew-tap)
16
15
 
17
- ## πŸ“¦ Installation
16
+ ### πŸ“– **[Read the Full Documentation](https://goldziher.github.io/ai-rulez/)**
18
17
 
19
- ### npm (Recommended)
18
+ ---
20
19
 
21
- ```bash
22
- # Global installation
23
- npm install -g ai-rulez
20
+ ## Feature Highlights
24
21
 
25
- # Local project installation
26
- npm install --save-dev ai-rulez
27
- ```
22
+ `ai-rulez` is a progressive tool-box, designed to offer a centralized way to manage AI tooling for a repository.
23
+
24
+ ### Centralized Configuration
25
+ - **Centralized Definitions:** Use a single `ai-rulez.yml` as the source of truth to define rules, file structures, and documentation for all your AI tools.
26
+ - **Nested Configs & Monorepo Support:** Scale your configurations with `extends` and `includes`. Manage complex projects and monorepos with ease by using the `--recursive` flag to combine configurations from multiple files.
27
+ ```bash
28
+ # Generate rules for all projects in a monorepo
29
+ ai-rulez generate --recursive
30
+ ```
28
31
 
29
- The npm package automatically downloads and manages the Go binary for your platform.
32
+ ### Powerful Tooling
33
+ - **Custom Commands:** Define custom commands that your AI assistant can execute, enabling powerful, interactive workflows.
34
+ - **Specialized AI Agents:** Create specialized "sub-agents" with their own system prompts and tools, perfect for complex tasks like code reviews or database queries.
35
+ - **MCP Servers:** Launch a Model Context Protocol (MCP) server to allow AI assistants to programmatically interact with your configuration.
36
+ - **Full-Featured CLI:** Manage your entire configuration from the command line. Add rules, update agents, and generate files without ever opening a YAML file.
30
37
 
31
- ### Other Installation Methods
38
+ ### Flexible Integrations
39
+ - **Multi-Tool Support:** Use presets to instantly generate configurations for popular AI tools like Claude, Cursor, Copilot, Gemini, and more.
40
+ - **Custom Tool Integration:** Don't see your favorite tool on the list? Use the `outputs` key to generate a configuration file for any tool, in any format.
32
41
 
33
- - **pip**: `pip install ai-rulez`
34
- - **Go**: `go install github.com/Goldziher/ai-rulez@latest`
35
- - **Homebrew**: `brew install goldziher/tap/ai-rulez` *(coming soon)*
36
- - **Direct Download**: Download from [GitHub Releases](https://github.com/Goldziher/ai-rulez/releases)
42
+ ## How It Works
37
43
 
38
- ## 🎯 Quick Start
44
+ `ai-rulez` takes your `ai-rulez.yml` file and uses it as a single source of truth to generate native configuration files for all your AI tools. Think of it as a build system for AI contextβ€”you write the source once, and it compiles to whatever format each tool needs.
39
45
 
40
- 1. **Create a configuration file** (`ai-rulez.yaml`):
46
+ ## Example: `ai-rulez.yml`
41
47
 
42
48
  ```yaml
49
+ $schema: https://github.com/Goldziher/ai-rulez/schema/ai-rules-v2.schema.json
50
+
43
51
  metadata:
44
- name: "My AI Rules"
45
- version: "1.0.0"
52
+ name: "My SaaS Platform"
53
+ version: "2.0.0"
54
+
55
+ # Use presets for common configurations
56
+ presets:
57
+ - "popular" # Includes Claude, Cursor, Windsurf, and Copilot
46
58
 
47
59
  rules:
48
- - name: "Code Style"
49
- priority: 10
50
- content: |
51
- - Use TypeScript strict mode
52
- - Prefer functional components
53
- - Use meaningful variable names
60
+ - name: "Go Code Standards"
61
+ priority: high
62
+ content: "Follow standard Go project layout (cmd/, internal/, pkg/). Use meaningful package names and export only what is necessary."
54
63
 
55
- - name: "Testing"
56
- priority: 5
64
+ sections:
65
+ - name: "Project Structure"
66
+ priority: critical
57
67
  content: |
58
- - Write unit tests for all functions
59
- - Use describe/it pattern
60
- - Aim for 80% code coverage
61
-
62
- outputs:
63
- - file: "CLAUDE.md"
64
- template: "claude"
65
- - file: ".cursorrules"
66
- template: "cursor"
67
- - file: ".windsurfrules"
68
- template: "windsurf"
68
+ - `cmd/`: Main application entry point
69
+ - `internal/`: Private application code (business logic, data access)
70
+ - `pkg/`: Public-facing libraries
71
+
72
+ agents:
73
+ - name: "go-developer"
74
+ description: "Go language expert for core development"
75
+ system_prompt: "You are an expert Go developer. Your key responsibilities include writing idiomatic Go, using proper error handling, and creating comprehensive tests."
69
76
  ```
70
77
 
71
- 2. **Generate configuration files**:
78
+ Run `ai-rulez generate` β†’ get all your configuration files, perfectly synchronized.
72
79
 
73
- ```bash
74
- ai-rulez generate
75
- ```
76
-
77
- This creates `CLAUDE.md`, `.cursorrules`, and `.windsurfrules` with your rules properly formatted for each AI assistant.
78
-
79
- ## πŸ› οΈ Commands
80
+ ## Quick Start
80
81
 
81
82
  ```bash
82
- # Generate all configuration files
83
- ai-rulez generate
84
-
85
- # Validate configuration
86
- ai-rulez validate
83
+ # 1. Initialize your project with a preset (recommended)
84
+ ai-rulez init "My Project" --preset popular
87
85
 
88
- # Generate recursively in subdirectories
89
- ai-rulez generate --recursive
86
+ # 2. Add your project-specific context
87
+ ai-rulez add rule "Tech Stack" --priority critical --content "This project uses Go and PostgreSQL."
90
88
 
91
- # Preview output without writing files
92
- ai-rulez generate --dry-run
93
-
94
- # Show help
95
- ai-rulez --help
89
+ # 3. Generate all AI instruction files
90
+ ai-rulez generate
96
91
  ```
97
92
 
98
- ## πŸ”„ Git Integration
93
+ ## Installation
99
94
 
100
- ### Pre-commit Hook
95
+ ### Run without installing
101
96
 
102
- Add to your `.pre-commit-config.yaml`:
97
+ For one-off executions, you can run `ai-rulez` directly without a system-wide installation.
103
98
 
104
- ```yaml
105
- repos:
106
- - repo: https://github.com/Goldziher/ai-rulez
107
- rev: v1.0.0
108
- hooks:
109
- - id: ai-rulez-generate
99
+ **Go**
100
+ ```bash
101
+ go run github.com/Goldziher/ai-rulez/cmd@latest --help
110
102
  ```
111
103
 
112
- ### Lefthook
113
-
114
- Add to your `lefthook.yml`:
115
-
116
- ```yaml
117
- pre-commit:
118
- commands:
119
- ai-rulez:
120
- run: ai-rulez generate
121
- files: git diff --cached --name-only
122
- glob: "*.{ai-rulez,ai_rulez}.{yml,yaml}"
104
+ **Node.js (via npx)**
105
+ ```bash
106
+ # Installs and runs the latest version
107
+ npx ai-rulez@latest init
123
108
  ```
124
109
 
125
- ### npm Scripts
126
-
127
- Add to your `package.json`:
128
-
129
- ```json
130
- {
131
- "scripts": {
132
- "ai-rulez": "ai-rulez generate",
133
- "ai-rulez:validate": "ai-rulez validate",
134
- "ai-rulez:watch": "ai-rulez generate --recursive"
135
- }
136
- }
110
+ **Python (via uvx)**
111
+ ```bash
112
+ # Runs ai-rulez in a temporary virtual environment
113
+ uvx ai-rulez init
137
114
  ```
138
115
 
139
- ## πŸ“š Configuration
140
-
141
- The tool looks for configuration files in this order:
142
- - `.ai-rulez.yaml`
143
- - `ai-rulez.yaml`
144
- - `.ai_rulez.yaml`
145
- - `ai_rulez.yaml`
146
-
147
- ### User Rules vs. Coding Rules
148
-
149
- When creating AI rules, distinguish between two types of instructions:
116
+ ### Install globally
150
117
 
151
- - **Coding Rules**: Technical guidelines about code quality, architecture, testing, etc.
152
- - Examples: "Use TypeScript strict mode", "Write unit tests", "Follow REST conventions"
153
- - Should be in the main configuration file committed to version control
118
+ For frequent use, a global installation is recommended.
154
119
 
155
- - **User Rules**: Personal preferences about communication style and interaction
156
- - Examples: "Be concise in responses", "Use casual tone", "Address me as 'Chief'", "Always explain your reasoning"
157
- - Perfect for `.local.yaml` files (e.g., `ai-rulez.local.yaml`) as they're personal and shouldn't affect the whole team
158
- - Allow individual developers to customize AI behavior without impacting others
159
-
160
- **Example local config** (`ai-rulez.local.yaml`):
161
- ```yaml
162
- rules:
163
- - name: "Communication Style"
164
- content: "Be concise and direct. Address me as 'Boss'. Always ask for clarification before making assumptions."
165
- - name: "Response Format"
166
- content: "Provide code examples for every suggestion. Use bullet points for lists."
120
+ **Go**
121
+ ```bash
122
+ go install github.com/Goldziher/ai-rulez/cmd@latest
167
123
  ```
168
124
 
169
- ### Configuration Schema
170
-
171
- ```yaml
172
- metadata:
173
- name: string # Required: Project name
174
- version: string # Required: Version
175
- description: string # Optional: Description
176
-
177
- rules:
178
- - name: string # Required: Rule name
179
- priority: number # Required: Priority (1-10)
180
- content: string # Required: Rule content
181
-
182
- sections: # Optional: Organize rules into sections
183
- - title: string # Required: Section title
184
- priority: number # Required: Section priority
185
- content: string # Required: Section content
186
-
187
- outputs: # Required: At least one output
188
- - file: string # Required: Output filename
189
- template: string # Required: Template name or path
190
-
191
- includes: # Optional: Include other config files
192
- - path/to/other.yaml
125
+ **Homebrew (macOS/Linux)**
126
+ ```bash
127
+ brew install goldziher/tap/ai-rulez
193
128
  ```
194
129
 
195
- ## 🎨 Templates
196
-
197
- Built-in templates:
198
- - `claude` - CLAUDE.md format
199
- - `cursor` - .cursorrules format
200
- - `windsurf` - .windsurfrules format
201
- - `default` - Generic format
202
-
203
- Custom templates use Go template syntax with access to `.Rules`, `.Sections`, `.Metadata`, etc.
204
-
205
- ## πŸ”§ Advanced Usage
206
-
207
- ### Environment Variables
208
-
209
- - `AI_RULEZ_CONFIG` - Override config file path
210
- - `AI_RULEZ_DEBUG` - Enable debug output
211
-
212
- ### Node.js API
213
-
214
- ```javascript
215
- const { execSync } = require('child_process');
216
-
217
- // Run ai-rulez programmatically
218
- try {
219
- const output = execSync('ai-rulez generate --dry-run', { encoding: 'utf8' });
220
- console.log(output);
221
- } catch (error) {
222
- console.error('ai-rulez failed:', error.message);
223
- }
130
+ **npm**
131
+ ```bash
132
+ npm install -g ai-rulez
224
133
  ```
225
134
 
226
- ### npm Scripts Integration
227
-
228
- ```json
229
- {
230
- "scripts": {
231
- "precommit": "ai-rulez generate",
232
- "lint": "eslint . && ai-rulez validate",
233
- "build": "npm run ai-rulez && npm run compile"
234
- },
235
- "husky": {
236
- "hooks": {
237
- "pre-commit": "ai-rulez generate"
238
- }
239
- }
240
- }
135
+ **pip**
136
+ ```bash
137
+ pip install ai-rulez
241
138
  ```
242
139
 
243
- ## 🀝 Contributing
140
+ ## Pre-commit Hooks
141
+
142
+ You can use `ai-rulez` with `pre-commit` to automatically validate and generate your AI configuration files.
244
143
 
245
- Contributions are welcome! Please see our [Contributing Guide](https://github.com/Goldziher/ai-rulez/blob/main/CONTRIBUTING.md).
144
+ Add the following to your `.pre-commit-config.yaml`:
246
145
 
247
- ## πŸ“„ License
146
+ ```yaml
147
+ repos:
148
+ - repo: https://github.com/Goldziher/ai-rulez
149
+ rev: v2.0.0
150
+ hooks:
151
+ - id: ai-rulez-validate
152
+ - id: ai-rulez-generate
153
+ ```
248
154
 
249
- MIT License - see [LICENSE](https://github.com/Goldziher/ai-rulez/blob/main/LICENSE)
155
+ ---
250
156
 
251
- ## πŸ”— Links
157
+ ## Documentation
252
158
 
253
- - [GitHub Repository](https://github.com/Goldziher/ai-rulez)
254
- - [Documentation](https://github.com/Goldziher/ai-rulez#readme)
255
- - [Issues](https://github.com/Goldziher/ai-rulez/issues)
256
- - [Releases](https://github.com/Goldziher/ai-rulez/releases)
257
- - [PyPI Package](https://pypi.org/project/ai-rulez/)
159
+ - **[Quick Start Guide](https://goldziher.github.io/ai-rulez/quick-start/)**
160
+ - **[Full CLI Reference](https://goldziher.github.io/ai-rulez/cli/)**
161
+ - **[Configuration Guide](https://goldziher.github.io/ai-rulez/configuration/)**
162
+ - **[Migration Guide](https://goldziher.github.io/ai-rulez/migration-guide/)** - Upgrading from v1.x to v2.0
258
163
 
259
- ---
164
+ ## Contributing
260
165
 
261
- **Note**: This npm package is a wrapper around the Go binary. The actual tool is written in Go for maximum performance and cross-platform compatibility.
166
+ Contributions are welcome! Please see the [Contributing Guide](CONTRIBUTING.md) to get started.
Binary file
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require("node:child_process");
4
+ const path = require("node:path");
5
+ const fs = require("node:fs");
6
+ const { getPlatform, getBinaryName } = require("../install");
7
+
8
+ const binaryName = getBinaryName(getPlatform().os);
9
+ const binaryPath = path.join(__dirname, "..", "bin", binaryName);
10
+
11
+ function runBinary(args) {
12
+ const child = spawn(binaryPath, args, {
13
+ stdio: "inherit",
14
+ });
15
+
16
+ child.on("close", (code) => {
17
+ process.exit(code);
18
+ });
19
+ }
20
+
21
+ async function main() {
22
+ if (fs.existsSync(binaryPath)) {
23
+ runBinary(process.argv.slice(2));
24
+ } else {
25
+ console.log(
26
+ "πŸš€ First run detected - downloading ai-rulez binary...\n This will only happen once and takes a few seconds.\n",
27
+ );
28
+ const { install } = require("../install");
29
+ try {
30
+ await install(true); // Pass a flag to indicate this is a post-install step
31
+ runBinary(process.argv.slice(2));
32
+ } catch (error) {
33
+ console.error("Failed to install or run ai-rulez:", error);
34
+ process.exit(1);
35
+ }
36
+ }
37
+ }
38
+
39
+ main();