ai-rulez 2.0.0 β†’ 2.1.0

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 ADDED
@@ -0,0 +1,266 @@
1
+ # ai-rulez ⚑
2
+
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>
6
+
7
+ **One config to rule them all.**
8
+
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.
10
+
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)
15
+
16
+ ### πŸ“– **[Read the Full Documentation](https://goldziher.github.io/ai-rulez/)**
17
+
18
+ ---
19
+
20
+ ## Feature Highlights
21
+
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
+ ```
31
+
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 Integration:** Automatically configure MCP servers across CLI tools (Claude, Gemini) and generate config files for others (Cursor, VS Code). One configuration, every tool connected.
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.
37
+
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.
41
+
42
+ ## How It Works
43
+
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.
45
+
46
+ ## Example: `ai-rulez.yml`
47
+
48
+ ```yaml
49
+ $schema: https://github.com/Goldziher/ai-rulez/schema/ai-rules-v2.schema.json
50
+
51
+ metadata:
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
58
+
59
+ rules:
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."
63
+
64
+ sections:
65
+ - name: "Project Structure"
66
+ priority: critical
67
+ content: |
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."
76
+
77
+ # MCP servers for direct AI tool integration
78
+ mcp_servers:
79
+ - name: "ai-rulez"
80
+ command: "ai-rulez"
81
+ args: ["mcp"]
82
+ description: "AI-Rulez MCP server for configuration management"
83
+ ```
84
+
85
+ Run `ai-rulez generate` β†’ get all your configuration files, perfectly synchronized.
86
+
87
+ ## Quick Start
88
+
89
+ ```bash
90
+ # 1. AI-powered initialization (recommended)
91
+ ai-rulez init "My Project" --preset popular --use-agent claude
92
+
93
+ # 2. Generate all AI instruction files
94
+ ai-rulez generate
95
+
96
+ # 3. Your AI tools now have comprehensive, project-specific context!
97
+ ```
98
+
99
+ **That's it!** The AI will analyze your codebase and generate tailored rules, documentation, and specialized agents automatically.
100
+
101
+ **Prefer manual setup?**
102
+ ```bash
103
+ # Basic initialization without AI assistance
104
+ ai-rulez init "My Project" --preset popular
105
+
106
+ # Add your project-specific context
107
+ ai-rulez add rule "Tech Stack" --priority critical --content "This project uses Go and PostgreSQL."
108
+
109
+ # Generate files
110
+ ai-rulez generate
111
+ ```
112
+
113
+ ## MCP Server Integration
114
+
115
+ `ai-rulez` provides seamless **Model Context Protocol (MCP)** integration, automatically configuring both file-based and CLI-based AI tools with your MCP servers.
116
+
117
+ ### Automatic CLI Configuration
118
+
119
+ When you run `ai-rulez generate`, MCP servers are **automatically configured** for available CLI tools:
120
+
121
+ ```bash
122
+ ai-rulez generate
123
+ # βœ… Generated 3 file(s) successfully
124
+ # βœ… Configured claude MCP server: ai-rulez
125
+ # βœ… Configured gemini MCP server: database-tools
126
+ ```
127
+
128
+ **Supported CLI tools:**
129
+ - **Claude CLI**: `claude mcp add` with full env/transport support
130
+ - **Gemini CLI**: `gemini mcp add` with automatic configuration
131
+
132
+ ### Hybrid Configuration
133
+
134
+ `ai-rulez` supports both CLI and file-based configurations simultaneously:
135
+
136
+ ```yaml
137
+ mcp_servers:
138
+ - name: "database-tools"
139
+ command: "uvx"
140
+ args: ["mcp-server-postgres"]
141
+ env:
142
+ DATABASE_URL: "postgresql://localhost/mydb"
143
+ targets:
144
+ - "@claude-cli" # Configure Claude CLI
145
+ - "@gemini-cli" # Configure Gemini CLI
146
+ - ".cursor/mcp.json" # Generate Cursor config file
147
+ ```
148
+
149
+ This single configuration:
150
+ - βœ… Executes `claude mcp add` commands
151
+ - βœ… Executes `gemini mcp add` commands
152
+ - βœ… Generates `.cursor/mcp.json` file
153
+
154
+ ### Control Options
155
+
156
+ **Default behavior** (recommended):
157
+ ```bash
158
+ ai-rulez generate
159
+ # Configures all available CLI tools + generates files
160
+ ```
161
+
162
+ **Disable CLI configuration** when needed:
163
+ ```bash
164
+ ai-rulez generate --no-configure-cli-mcp
165
+ # Only generates files, skips CLI tool configuration
166
+ ```
167
+
168
+ **Target specific tools:**
169
+ ```yaml
170
+ mcp_servers:
171
+ - name: "github-integration"
172
+ command: "npx"
173
+ args: ["@modelcontextprotocol/server-github"]
174
+ targets: ["@claude-cli"] # Only configure Claude CLI
175
+ ```
176
+
177
+ ### Built-in MCP Server
178
+
179
+ `ai-rulez` includes its own MCP server for configuration management:
180
+
181
+ ```bash
182
+ # Start the ai-rulez MCP server
183
+ ai-rulez mcp
184
+
185
+ # Or configure it automatically via your ai-rulez.yaml
186
+ mcp_servers:
187
+ - name: "ai-rulez"
188
+ command: "ai-rulez"
189
+ args: ["mcp"]
190
+ description: "Configuration management server"
191
+ ```
192
+
193
+ ## Installation
194
+
195
+ ### Run without installing
196
+
197
+ For one-off executions, you can run `ai-rulez` directly without a system-wide installation.
198
+
199
+ **Go**
200
+ ```bash
201
+ go run github.com/Goldziher/ai-rulez/cmd@latest --help
202
+ ```
203
+
204
+ **Node.js (via npx)**
205
+ ```bash
206
+ # Installs and runs the latest version
207
+ npx ai-rulez@latest init
208
+ ```
209
+
210
+ **Python (via uvx)**
211
+ ```bash
212
+ # Runs ai-rulez in a temporary virtual environment
213
+ uvx ai-rulez init
214
+ ```
215
+
216
+ ### Install globally
217
+
218
+ For frequent use, a global installation is recommended.
219
+
220
+ **Go**
221
+ ```bash
222
+ go install github.com/Goldziher/ai-rulez/cmd@latest
223
+ ```
224
+
225
+ **Homebrew (macOS/Linux)**
226
+ ```bash
227
+ brew install goldziher/tap/ai-rulez
228
+ ```
229
+
230
+ **npm**
231
+ ```bash
232
+ npm install -g ai-rulez
233
+ ```
234
+
235
+ **pip**
236
+ ```bash
237
+ pip install ai-rulez
238
+ ```
239
+
240
+ ## Pre-commit Hooks
241
+
242
+ You can use `ai-rulez` with `pre-commit` to automatically validate and generate your AI configuration files.
243
+
244
+ Add the following to your `.pre-commit-config.yaml`:
245
+
246
+ ```yaml
247
+ repos:
248
+ - repo: https://github.com/Goldziher/ai-rulez
249
+ rev: v2.1.0
250
+ hooks:
251
+ - id: ai-rulez-validate
252
+ - id: ai-rulez-generate
253
+ ```
254
+
255
+ ---
256
+
257
+ ## Documentation
258
+
259
+ - **[Quick Start Guide](https://goldziher.github.io/ai-rulez/quick-start/)**
260
+ - **[Full CLI Reference](https://goldziher.github.io/ai-rulez/cli/)**
261
+ - **[Configuration Guide](https://goldziher.github.io/ai-rulez/configuration/)**
262
+ - **[Migration Guide](https://goldziher.github.io/ai-rulez/migration-guide/)** - Upgrading from v1.x to v2.0
263
+
264
+ ## Contributing
265
+
266
+ Contributions are welcome! Please see the [Contributing Guide](CONTRIBUTING.md) to get started.
package/install.js CHANGED
@@ -275,7 +275,7 @@ async function extractArchive(archivePath, extractDir, platform) {
275
275
  }
276
276
  }
277
277
 
278
- async function install() {
278
+ async function install(isPostInstall = false) {
279
279
  const DEBUG = process.env.AI_RULEZ_DEBUG === "1";
280
280
 
281
281
  try {
@@ -418,14 +418,20 @@ async function install() {
418
418
  console.error(`[install.js] Exiting with code 0`);
419
419
  }
420
420
 
421
- process.exit(0);
421
+ if (!isPostInstall) {
422
+ process.exit(0);
423
+ }
422
424
  } catch (error) {
423
425
  if (DEBUG)
424
426
  console.error(`[install.js] Installation failed: ${error.message}`);
425
427
  console.error("Failed to install ai-rulez binary:", error.message);
426
428
  console.error("You can manually download the binary from:");
427
429
  console.error(`https://github.com/${REPO_NAME}/releases`);
428
- process.exit(1);
430
+ if (!isPostInstall) {
431
+ process.exit(1);
432
+ } else {
433
+ throw error;
434
+ }
429
435
  }
430
436
  }
431
437
 
@@ -442,5 +448,5 @@ if (typeof module !== "undefined" && module.exports) {
442
448
  }
443
449
 
444
450
  if (require.main === module) {
445
- install();
451
+ install(false);
446
452
  }
package/package.json CHANGED
@@ -1,86 +1,86 @@
1
1
  {
2
- "name": "ai-rulez",
3
- "version": "2.0.0",
4
- "description": "⚑ One config to rule them all. Centralized AI assistant configuration management - generate rules for Claude, Cursor, Copilot, Windsurf and more from a single YAML file.",
5
- "keywords": [
6
- "ai",
7
- "ai-assistant",
8
- "ai-rules",
9
- "claude",
10
- "cursor",
11
- "copilot",
12
- "windsurf",
13
- "gemini",
14
- "cline",
15
- "continue-dev",
16
- "mcp",
17
- "model-context-protocol",
18
- "cli",
19
- "configuration",
20
- "config",
21
- "rules",
22
- "generator",
23
- "golang",
24
- "go",
25
- "development",
26
- "developer-tools",
27
- "automation",
28
- "workflow",
29
- "productivity",
30
- "pre-commit",
31
- "git-hooks",
32
- "code-generation",
33
- "ai-development",
34
- "assistant-configuration",
35
- "monorepo",
36
- "presets",
37
- "agents"
38
- ],
39
- "repository": {
40
- "type": "git",
41
- "url": "https://github.com/Goldziher/ai-rulez.git"
42
- },
43
- "homepage": "https://goldziher.github.io/ai-rulez/",
44
- "bugs": {
45
- "url": "https://github.com/Goldziher/ai-rulez/issues"
46
- },
47
- "funding": {
48
- "type": "github",
49
- "url": "https://github.com/sponsors/Goldziher"
50
- },
51
- "license": "MIT",
52
- "author": {
53
- "name": "Na'aman Hirschfeld",
54
- "email": "nhirschfeld@gmail.com",
55
- "url": "https://github.com/Goldziher"
56
- },
57
- "maintainers": [
58
- {
59
- "name": "Na'aman Hirschfeld",
60
- "email": "nhirschfeld@gmail.com",
61
- "url": "https://github.com/Goldziher"
62
- }
63
- ],
64
- "bin": {
65
- "ai-rulez": "./bin/ai-rulez.js"
66
- },
67
- "scripts": {},
68
- "files": [
69
- "bin/",
70
- "install.js",
71
- "../../README.md"
72
- ],
73
- "engines": {
74
- "node": ">=14.0.0"
75
- },
76
- "os": [
77
- "darwin",
78
- "linux",
79
- "win32"
80
- ],
81
- "cpu": [
82
- "x64",
83
- "arm64",
84
- "ia32"
85
- ]
2
+ "name": "ai-rulez",
3
+ "version": "2.1.0",
4
+ "description": "⚑ One config to rule them all. Centralized AI assistant configuration management - generate rules for Claude, Cursor, Copilot, Windsurf and more from a single YAML file.",
5
+ "keywords": [
6
+ "ai",
7
+ "ai-assistant",
8
+ "ai-rules",
9
+ "claude",
10
+ "cursor",
11
+ "copilot",
12
+ "windsurf",
13
+ "gemini",
14
+ "cline",
15
+ "continue-dev",
16
+ "mcp",
17
+ "model-context-protocol",
18
+ "cli",
19
+ "configuration",
20
+ "config",
21
+ "rules",
22
+ "generator",
23
+ "golang",
24
+ "go",
25
+ "development",
26
+ "developer-tools",
27
+ "automation",
28
+ "workflow",
29
+ "productivity",
30
+ "pre-commit",
31
+ "git-hooks",
32
+ "code-generation",
33
+ "ai-development",
34
+ "assistant-configuration",
35
+ "monorepo",
36
+ "presets",
37
+ "agents"
38
+ ],
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/Goldziher/ai-rulez.git"
42
+ },
43
+ "homepage": "https://goldziher.github.io/ai-rulez/",
44
+ "bugs": {
45
+ "url": "https://github.com/Goldziher/ai-rulez/issues"
46
+ },
47
+ "funding": {
48
+ "type": "github",
49
+ "url": "https://github.com/sponsors/Goldziher"
50
+ },
51
+ "license": "MIT",
52
+ "author": {
53
+ "name": "Na'aman Hirschfeld",
54
+ "email": "nhirschfeld@gmail.com",
55
+ "url": "https://github.com/Goldziher"
56
+ },
57
+ "maintainers": [
58
+ {
59
+ "name": "Na'aman Hirschfeld",
60
+ "email": "nhirschfeld@gmail.com",
61
+ "url": "https://github.com/Goldziher"
62
+ }
63
+ ],
64
+ "bin": {
65
+ "ai-rulez": "./bin/ai-rulez.js"
66
+ },
67
+ "scripts": {},
68
+ "files": [
69
+ "bin/",
70
+ "install.js",
71
+ "README.md"
72
+ ],
73
+ "engines": {
74
+ "node": ">=14.0.0"
75
+ },
76
+ "os": [
77
+ "darwin",
78
+ "linux",
79
+ "win32"
80
+ ],
81
+ "cpu": [
82
+ "x64",
83
+ "arm64",
84
+ "ia32"
85
+ ]
86
86
  }
package/bin/ai-rulez DELETED
@@ -1,193 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const path = require('path');
4
- const fs = require('fs');
5
- const { spawn } = require('child_process');
6
-
7
- // Path to the actual binary that install.js will create
8
- // The binary has a different name to avoid conflict with this wrapper script
9
- const BINARY_NAME = process.platform === 'win32' ? 'ai-rulez-bin.exe' : 'ai-rulez-bin';
10
- const BINARY_PATH = path.join(__dirname, BINARY_NAME);
11
-
12
- const REPO_URL = 'https://github.com/Goldziher/ai-rulez';
13
- const ISSUES_URL = `${REPO_URL}/issues`;
14
-
15
- function isNetworkError(error) {
16
- const networkErrors = [
17
- 'ENOTFOUND', 'ECONNREFUSED', 'ECONNRESET', 'ETIMEDOUT',
18
- 'EHOSTUNREACH', 'ENETUNREACH', 'EADDRNOTAVAIL', 'ENETDOWN'
19
- ];
20
-
21
- return networkErrors.includes(error.code) ||
22
- error.message.includes('network') ||
23
- error.message.includes('fetch') ||
24
- error.message.includes('download') ||
25
- error.message.includes('timeout');
26
- }
27
-
28
- function isPermissionError(error) {
29
- return error.code === 'EACCES' ||
30
- error.code === 'EPERM' ||
31
- error.message.includes('permission') ||
32
- error.message.includes('access denied');
33
- }
34
-
35
- async function runInstallScript() {
36
- console.error('⚑ ai-rulez binary not found. Installing...');
37
- console.error(` Looking for: ${BINARY_PATH}`);
38
-
39
- const installScript = path.join(__dirname, '..', 'install.js');
40
- console.error(` Running install script: ${installScript}`);
41
-
42
- return new Promise((resolve, reject) => {
43
- let errorOutput = '';
44
-
45
- const child = spawn('node', [installScript], {
46
- stdio: ['inherit', 'inherit', 'pipe'],
47
- cwd: path.dirname(installScript),
48
- env: { ...process.env, AI_RULEZ_DEBUG: '1' }
49
- });
50
-
51
- child.stderr.on('data', (data) => {
52
- process.stderr.write(data);
53
- errorOutput += data.toString();
54
- });
55
-
56
- child.on('exit', (code) => {
57
- console.error(` Install script exited with code: ${code}`);
58
- if (code === 0) {
59
- resolve();
60
- } else {
61
- const error = new Error(`Install script failed with code ${code}`);
62
- error.output = errorOutput;
63
- reject(error);
64
- }
65
- });
66
-
67
- child.on('error', (err) => {
68
- console.error(` Install script error: ${err.message}`);
69
- reject(err);
70
- });
71
- });
72
- }
73
-
74
- async function main() {
75
- // Check if binary exists
76
- if (!fs.existsSync(BINARY_PATH)) {
77
- try {
78
- // Run the install script if binary is missing
79
- await runInstallScript();
80
-
81
- console.error(` Checking if binary exists at: ${BINARY_PATH}`);
82
-
83
- // Double-check that binary now exists
84
- if (!fs.existsSync(BINARY_PATH)) {
85
- console.error('\n❌ Error: Binary still not found after installation attempt');
86
- console.error('\nπŸ”§ This is unexpected. Please report this issue:');
87
- console.error(` ${ISSUES_URL}`);
88
- console.error('\nInclude your platform info:');
89
- console.error(` Platform: ${process.platform}`);
90
- console.error(` Architecture: ${process.arch}`);
91
- console.error(` Node version: ${process.version}`);
92
- process.exit(1);
93
- }
94
- } catch (error) {
95
- console.error('\n❌ Installation failed');
96
-
97
- if (isNetworkError(error)) {
98
- console.error('\n🌐 Network Issue Detected');
99
- console.error(' Unable to download ai-rulez binary from GitHub releases.');
100
- console.error('\n Possible causes:');
101
- console.error(' β€’ No internet connection');
102
- console.error(' β€’ GitHub is temporarily unreachable');
103
- console.error(' β€’ Corporate firewall/proxy blocking GitHub');
104
- console.error('\n Solutions:');
105
- console.error(' 1. Check your internet connection');
106
- console.error(' 2. Try again in a few moments');
107
- console.error(' 3. If behind a proxy, configure npm proxy settings');
108
- console.error(' 4. Download the binary manually from:');
109
- console.error(` ${REPO_URL}/releases`);
110
- } else if (isPermissionError(error)) {
111
- console.error('\nπŸ”’ Permission Denied');
112
- console.error(` Cannot write to: ${path.dirname(BINARY_PATH)}`);
113
- console.error('\n Solutions:');
114
- console.error(' 1. Run with appropriate permissions');
115
- console.error(' 2. Install globally with: npm install -g ai-rulez');
116
- console.error(' 3. Check directory permissions');
117
- } else {
118
- console.error('\n⚠️ Unexpected Error');
119
- console.error(` ${error.message}`);
120
- if (error.output && error.output.trim()) {
121
- console.error('\n Details:');
122
- console.error(` ${error.output.trim().split('\n').join('\n ')}`);
123
- }
124
- console.error('\n This shouldn\'t happen. Please report this issue:');
125
- console.error(` ${ISSUES_URL}`);
126
- console.error('\n Include:');
127
- console.error(' β€’ The error message above');
128
- console.error(` β€’ Platform: ${process.platform}/${process.arch}`);
129
- console.error(` β€’ Node version: ${process.version}`);
130
- }
131
-
132
- process.exit(1);
133
- }
134
- }
135
-
136
- // Run the actual binary with all arguments
137
- const proc = spawn(BINARY_PATH, process.argv.slice(2), {
138
- stdio: 'inherit',
139
- env: process.env
140
- });
141
-
142
- proc.on('exit', (code) => {
143
- process.exit(code || 0);
144
- });
145
-
146
- proc.on('error', (err) => {
147
- console.error('\n❌ Failed to execute ai-rulez binary');
148
-
149
- if (err.code === 'ENOENT') {
150
- console.error('\nπŸ“ File Not Found');
151
- console.error(` Binary path: ${BINARY_PATH}`);
152
- console.error('\n The file exists but cannot be executed.');
153
- console.error(' Try reinstalling: npm install -g ai-rulez');
154
- } else if (err.code === 'EACCES' || err.code === 'EPERM') {
155
- console.error('\nπŸ”’ Permission Denied');
156
- console.error(` Binary path: ${BINARY_PATH}`);
157
- console.error('\n The binary is not executable.');
158
- console.error('\n Solutions:');
159
- if (process.platform !== 'win32') {
160
- console.error(` 1. Make it executable: chmod +x ${BINARY_PATH}`);
161
- console.error(' 2. Reinstall: npm install -g ai-rulez');
162
- } else {
163
- console.error(' 1. Check file permissions in Windows');
164
- console.error(' 2. Reinstall: npm install -g ai-rulez');
165
- }
166
- } else {
167
- console.error('\n⚠️ Unexpected Execution Error');
168
- console.error(` Error code: ${err.code}`);
169
- console.error(` Message: ${err.message}`);
170
- console.error('\n This shouldn\'t happen. Please report this issue:');
171
- console.error(` ${ISSUES_URL}`);
172
- console.error('\n Include:');
173
- console.error(' β€’ The error details above');
174
- console.error(` β€’ Platform: ${process.platform}/${process.arch}`);
175
- console.error(` β€’ Node version: ${process.version}`);
176
- }
177
-
178
- process.exit(1);
179
- });
180
- }
181
-
182
- main().catch(err => {
183
- console.error('\n❌ Unexpected error in wrapper script');
184
- console.error(` ${err.message}`);
185
- if (err.stack) {
186
- console.error('\n Stack trace:');
187
- console.error(` ${err.stack.split('\n').slice(1).join('\n ')}`);
188
- }
189
- console.error('\n This shouldn\'t happen. Please report this issue:');
190
- console.error(` ${ISSUES_URL}`);
191
- console.error('\n Include the full error output above.');
192
- process.exit(1);
193
- });
package/bin/ai-rulez.js DELETED
@@ -1,66 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const fs = require("node:fs");
4
- const path = require("node:path");
5
- const { spawn } = require("node:child_process");
6
-
7
- // Import the install logic from install.js
8
- const installPath = path.join(__dirname, "..", "install.js");
9
- const installer = require(installPath);
10
-
11
- const BINARY_NAME = installer.getBinaryName();
12
- const BINARY_PATH = path.join(__dirname, BINARY_NAME);
13
-
14
- async function ensureBinary() {
15
- if (fs.existsSync(BINARY_PATH)) {
16
- return true;
17
- }
18
-
19
- console.log("πŸš€ First run detected - downloading ai-rulez binary...");
20
- console.log(" This will only happen once and takes a few seconds.");
21
- console.log("");
22
- try {
23
- await installer.install();
24
- if (fs.existsSync(BINARY_PATH)) {
25
- console.log("βœ… Download complete! Running ai-rulez...");
26
- console.log("");
27
- return true;
28
- } else {
29
- throw new Error("Binary not found after installation");
30
- }
31
- } catch (error) {
32
- console.error("❌ Failed to download ai-rulez binary:", error.message);
33
- process.exit(1);
34
- }
35
- }
36
-
37
- async function main() {
38
- const hasBinary = await ensureBinary();
39
-
40
- if (!hasBinary) {
41
- console.error("Could not find or download ai-rulez binary");
42
- process.exit(1);
43
- }
44
-
45
- // Forward all arguments to the native binary
46
- const child = spawn(BINARY_PATH, process.argv.slice(2), {
47
- stdio: "inherit",
48
- cwd: process.cwd(),
49
- });
50
-
51
- child.on("exit", (code) => {
52
- process.exit(code || 0);
53
- });
54
-
55
- child.on("error", (error) => {
56
- console.error("Failed to start ai-rulez:", error.message);
57
- process.exit(1);
58
- });
59
- }
60
-
61
- if (require.main === module) {
62
- main().catch((error) => {
63
- console.error("Error:", error.message);
64
- process.exit(1);
65
- });
66
- }