ai-rulez 1.0.0-rc10

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.
Files changed (3) hide show
  1. package/README.md +61 -0
  2. package/install.js +140 -0
  3. package/package.json +30 -0
package/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # ai-rulez
2
+
3
+ CLI tool for managing AI assistant rules across Claude, Cursor, Windsurf and other AI-powered development environments.
4
+
5
+ This npm package provides the `ai-rulez` command-line tool, which is written in Go for optimal performance and distributed as platform-specific binaries.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install -g ai-rulez
11
+ ```
12
+
13
+ The package will automatically download the appropriate binary for your platform during installation.
14
+
15
+ ## Usage
16
+
17
+ Create an `ai_rules.yaml` configuration file in your project:
18
+
19
+ ```yaml
20
+ metadata:
21
+ name: my-project
22
+ version: 1.0.0
23
+
24
+ rules:
25
+ - name: code-style
26
+ content: Follow the project's established coding conventions
27
+ - name: testing
28
+ content: Write comprehensive tests for all new features
29
+
30
+ outputs:
31
+ - file: .cursorrules
32
+ - file: CLAUDE.md
33
+ ```
34
+
35
+ Then generate your AI assistant configuration files:
36
+
37
+ ```bash
38
+ # Generate files
39
+ ai-rulez generate
40
+
41
+ # Validate configuration
42
+ ai-rulez validate
43
+
44
+ # Initialize a new configuration
45
+ ai-rulez init
46
+ ```
47
+
48
+ ## Platform Support
49
+
50
+ Pre-built binaries are available for:
51
+ - macOS (Intel and Apple Silicon)
52
+ - Linux (x64, ARM64, and x86)
53
+ - Windows (x64 and x86)
54
+
55
+ ## Documentation
56
+
57
+ For complete documentation, examples, and source code, visit the [GitHub repository](https://github.com/Goldziher/ai-rulez).
58
+
59
+ ## License
60
+
61
+ MIT
package/install.js ADDED
@@ -0,0 +1,140 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const https = require('https');
4
+ const { exec } = require('child_process');
5
+ const { promisify } = require('util');
6
+
7
+ const execAsync = promisify(exec);
8
+
9
+ const REPO_NAME = 'Goldziher/ai-rulez';
10
+
11
+ function getPlatform() {
12
+ const platform = process.platform;
13
+ const arch = process.arch;
14
+
15
+ const platformMap = {
16
+ 'darwin': 'darwin',
17
+ 'linux': 'linux',
18
+ 'win32': 'windows'
19
+ };
20
+
21
+ const archMap = {
22
+ 'x64': 'amd64',
23
+ 'arm64': 'arm64',
24
+ 'ia32': '386',
25
+ 'x32': '386'
26
+ };
27
+
28
+ const mappedPlatform = platformMap[platform];
29
+ const mappedArch = archMap[arch];
30
+
31
+ if (!mappedPlatform || !mappedArch) {
32
+ throw new Error(`Unsupported platform: ${platform} ${arch}`);
33
+ }
34
+
35
+ // Windows ARM64 is not supported in our builds
36
+ if (mappedPlatform === 'windows' && mappedArch === 'arm64') {
37
+ throw new Error('Windows ARM64 is not supported');
38
+ }
39
+
40
+ return {
41
+ os: mappedPlatform,
42
+ arch: mappedArch
43
+ };
44
+ }
45
+
46
+ function getBinaryName(platform) {
47
+ return platform === 'windows' ? 'ai-rulez.exe' : 'ai-rulez';
48
+ }
49
+
50
+ async function downloadBinary(url, dest) {
51
+ return new Promise((resolve, reject) => {
52
+ const file = fs.createWriteStream(dest);
53
+
54
+ https.get(url, (response) => {
55
+ if (response.statusCode === 302 || response.statusCode === 301) {
56
+ // Handle redirect
57
+ https.get(response.headers.location, (redirectResponse) => {
58
+ redirectResponse.pipe(file);
59
+ file.on('finish', () => {
60
+ file.close();
61
+ resolve();
62
+ });
63
+ }).on('error', reject);
64
+ } else if (response.statusCode === 200) {
65
+ response.pipe(file);
66
+ file.on('finish', () => {
67
+ file.close();
68
+ resolve();
69
+ });
70
+ } else {
71
+ reject(new Error(`Failed to download: ${response.statusCode}`));
72
+ }
73
+ }).on('error', reject);
74
+ });
75
+ }
76
+
77
+ async function extractArchive(archivePath, extractDir, platform) {
78
+ if (platform === 'windows') {
79
+ // Use PowerShell to extract zip on Windows
80
+ await execAsync(`powershell -command "Expand-Archive -Path '${archivePath}' -DestinationPath '${extractDir}' -Force"`);
81
+ } else {
82
+ // Use tar for Unix-like systems
83
+ await execAsync(`tar -xzf "${archivePath}" -C "${extractDir}"`);
84
+ }
85
+ }
86
+
87
+ async function install() {
88
+ try {
89
+ const { os, arch } = getPlatform();
90
+ const binaryName = getBinaryName(os);
91
+
92
+ // Get version from package.json
93
+ const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'));
94
+ const version = packageJson.version;
95
+
96
+ // Construct download URL
97
+ const archiveExt = os === 'windows' ? 'zip' : 'tar.gz';
98
+ const archiveName = `ai-rulez_${version}_${os}_${arch}.${archiveExt}`;
99
+ const downloadUrl = `https://github.com/${REPO_NAME}/releases/download/v${version}/${archiveName}`;
100
+
101
+ console.log(`Downloading ai-rulez ${version} for ${os}/${arch}...`);
102
+ console.log(`URL: ${downloadUrl}`);
103
+
104
+ // Create bin directory
105
+ const binDir = path.join(__dirname, 'bin');
106
+ if (!fs.existsSync(binDir)) {
107
+ fs.mkdirSync(binDir, { recursive: true });
108
+ }
109
+
110
+ // Download archive
111
+ const archivePath = path.join(__dirname, archiveName);
112
+ await downloadBinary(downloadUrl, archivePath);
113
+
114
+ // Extract archive
115
+ console.log('Extracting binary...');
116
+ await extractArchive(archivePath, binDir, os);
117
+
118
+ // Make binary executable on Unix-like systems
119
+ if (os !== 'windows') {
120
+ const binaryPath = path.join(binDir, binaryName);
121
+ fs.chmodSync(binaryPath, 0o755);
122
+ }
123
+
124
+ // Clean up archive
125
+ fs.unlinkSync(archivePath);
126
+
127
+ console.log(`✅ ai-rulez ${version} installed successfully for ${os}/${arch}!`);
128
+
129
+ } catch (error) {
130
+ console.error('Failed to install ai-rulez binary:', error.message);
131
+ console.error('You can manually download the binary from:');
132
+ console.error(`https://github.com/${REPO_NAME}/releases`);
133
+ process.exit(1);
134
+ }
135
+ }
136
+
137
+ // Only run install during postinstall
138
+ if (require.main === module) {
139
+ install();
140
+ }
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "ai-rulez",
3
+ "version": "1.0.0-rc10",
4
+ "description": "CLI tool for managing AI assistant rules - generate configuration files for Claude, Cursor, Windsurf and more",
5
+ "keywords": ["ai", "rules", "configuration", "claude", "cursor", "windsurf", "cli", "assistant", "copilot", "generator"],
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/Goldziher/ai-rulez"
9
+ },
10
+ "homepage": "https://github.com/Goldziher/ai-rulez",
11
+ "bugs": {
12
+ "url": "https://github.com/Goldziher/ai-rulez/issues"
13
+ },
14
+ "license": "MIT",
15
+ "author": "Na'aman Hirschfeld <nhirschfeld@gmail.com>",
16
+ "bin": {
17
+ "ai-rulez": "./bin/ai-rulez"
18
+ },
19
+ "scripts": {
20
+ "postinstall": "node install.js"
21
+ },
22
+ "files": [
23
+ "bin",
24
+ "install.js",
25
+ "README.md"
26
+ ],
27
+ "engines": {
28
+ "node": ">=14.0.0"
29
+ }
30
+ }