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 +110 -205
- package/bin/ai-rulez-bin +0 -0
- package/bin/ai-rulez.js +39 -0
- package/install.js +427 -390
- package/package.json +33 -20
package/README.md
CHANGED
|
@@ -1,261 +1,166 @@
|
|
|
1
1
|
# ai-rulez β‘
|
|
2
2
|
|
|
3
|
-
>
|
|
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
|
-
|
|
7
|
+
**One config to rule them all.**
|
|
6
8
|
|
|
7
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
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
|
+
[](https://go.dev)
|
|
12
|
+
[](https://www.npmjs.com/package/ai-rulez)
|
|
13
|
+
[](https://pypi.org/project/ai-rulez/)
|
|
14
|
+
[](https://github.com/Goldziher/homebrew-tap)
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
### π **[Read the Full Documentation](https://goldziher.github.io/ai-rulez/)**
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
---
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
# Global installation
|
|
23
|
-
npm install -g ai-rulez
|
|
20
|
+
## Feature Highlights
|
|
24
21
|
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
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
|
-
###
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
45
|
-
version: "
|
|
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
|
|
49
|
-
priority:
|
|
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
|
-
|
|
56
|
-
|
|
64
|
+
sections:
|
|
65
|
+
- name: "Project Structure"
|
|
66
|
+
priority: critical
|
|
57
67
|
content: |
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
78
|
+
Run `ai-rulez generate` β get all your configuration files, perfectly synchronized.
|
|
72
79
|
|
|
73
|
-
|
|
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
|
-
#
|
|
83
|
-
ai-rulez
|
|
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
|
-
#
|
|
89
|
-
ai-rulez
|
|
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
|
-
#
|
|
92
|
-
ai-rulez generate
|
|
93
|
-
|
|
94
|
-
# Show help
|
|
95
|
-
ai-rulez --help
|
|
89
|
+
# 3. Generate all AI instruction files
|
|
90
|
+
ai-rulez generate
|
|
96
91
|
```
|
|
97
92
|
|
|
98
|
-
##
|
|
93
|
+
## Installation
|
|
99
94
|
|
|
100
|
-
###
|
|
95
|
+
### Run without installing
|
|
101
96
|
|
|
102
|
-
|
|
97
|
+
For one-off executions, you can run `ai-rulez` directly without a system-wide installation.
|
|
103
98
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
144
|
+
Add the following to your `.pre-commit-config.yaml`:
|
|
246
145
|
|
|
247
|
-
|
|
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
|
-
|
|
155
|
+
---
|
|
250
156
|
|
|
251
|
-
##
|
|
157
|
+
## Documentation
|
|
252
158
|
|
|
253
|
-
- [
|
|
254
|
-
- [
|
|
255
|
-
- [
|
|
256
|
-
- [
|
|
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
|
-
|
|
166
|
+
Contributions are welcome! Please see the [Contributing Guide](CONTRIBUTING.md) to get started.
|
package/bin/ai-rulez-bin
ADDED
|
Binary file
|
package/bin/ai-rulez.js
ADDED
|
@@ -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();
|