4runr-os 2.1.30 → 2.1.33

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 (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/setup.js +122 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "4runr-os",
3
- "version": "2.1.30",
3
+ "version": "2.1.33",
4
4
  "type": "module",
5
5
  "description": "4Runr AI Agent OS - Interactive terminal for managing AI agents",
6
6
  "main": "dist/index.js",
package/scripts/setup.js CHANGED
@@ -9,6 +9,7 @@ import * as fs from 'fs';
9
9
  import * as path from 'path';
10
10
  import { fileURLToPath } from 'url';
11
11
  import { dirname } from 'path';
12
+ import * as readline from 'readline';
12
13
 
13
14
  const __filename = fileURLToPath(import.meta.url);
14
15
  const __dirname = dirname(__filename);
@@ -110,21 +111,63 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
110
111
  'C:\\mingw64\\bin',
111
112
  'C:\\msys64\\mingw64\\bin',
112
113
  'C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin',
113
- path.join(process.env.ProgramFiles || 'C:\\Program Files', 'mingw-w64', 'x86_64-*-*-*-*-*', 'mingw64', 'bin'),
114
114
  ];
115
115
 
116
- for (const testPath of commonPaths) {
117
- const dlltoolPath = path.join(testPath, 'dlltool.exe');
118
- if (fs.existsSync(dlltoolPath)) {
116
+ // Check if MSYS2 exists and might have MinGW
117
+ const msys2MingwPath = 'C:\\msys64\\mingw64\\bin';
118
+ const msys2Bash = 'C:\\msys64\\usr\\bin\\bash.exe';
119
+
120
+ // First check if MSYS2 exists - if so, check/install MinGW automatically
121
+ if (fs.existsSync(msys2Bash)) {
122
+ console.log(' ✅ MSYS2 found - checking for MinGW...');
123
+ if (fs.existsSync(path.join(msys2MingwPath, 'dlltool.exe'))) {
119
124
  mingwInstalled = true;
120
- mingwPath = testPath;
121
- console.log('✅ MinGW found at:', mingwPath);
122
- console.log(' Adding to PATH for this session...');
123
- process.env.PATH = process.env.PATH ? `${mingwPath};${process.env.PATH}` : mingwPath;
124
- break;
125
+ mingwPath = msys2MingwPath;
126
+ console.log(' ✅ MinGW found in MSYS2');
127
+ } else {
128
+ // MSYS2 exists but MinGW not installed - install it automatically
129
+ console.log(' 🔨 Installing MinGW toolchain in MSYS2 (this may take a few minutes)...');
130
+ try {
131
+ execSync(`"${msys2Bash}" -lc "pacman -S mingw-w64-x86_64-toolchain --noconfirm"`, {
132
+ stdio: 'inherit',
133
+ timeout: 300000 // 5 minutes
134
+ });
135
+
136
+ if (fs.existsSync(path.join(msys2MingwPath, 'dlltool.exe'))) {
137
+ mingwInstalled = true;
138
+ mingwPath = msys2MingwPath;
139
+ console.log(' ✅ MinGW toolchain installed successfully');
140
+ } else {
141
+ console.warn(' ⚠️ Installation completed but MinGW not found');
142
+ console.warn(' Please restart terminal and run 4runr-setup again');
143
+ }
144
+ } catch (installError) {
145
+ console.warn(' ⚠️ Failed to install MinGW automatically');
146
+ console.warn(' Please run manually in MSYS2 terminal: pacman -S mingw-w64-x86_64-toolchain --noconfirm');
147
+ }
125
148
  }
126
149
  }
127
150
 
151
+ // Check other common paths if MSYS2 didn't work
152
+ if (!mingwInstalled) {
153
+ for (const testPath of commonPaths) {
154
+ if (fs.existsSync(testPath)) {
155
+ const dlltoolPath = path.join(testPath, 'dlltool.exe');
156
+ if (fs.existsSync(dlltoolPath)) {
157
+ mingwInstalled = true;
158
+ mingwPath = testPath;
159
+ console.log(' ✅ MinGW found at:', mingwPath);
160
+ break;
161
+ }
162
+ }
163
+ }
164
+ }
165
+
166
+ if (mingwInstalled && mingwPath) {
167
+ console.log(' Adding to PATH for this session...');
168
+ process.env.PATH = process.env.PATH ? `${mingwPath};${process.env.PATH}` : mingwPath;
169
+ }
170
+
128
171
  if (!mingwInstalled) {
129
172
  console.log(' Installing MinGW-w64...');
130
173
 
@@ -148,14 +191,77 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
148
191
  installed = true;
149
192
  console.log(` ✅ Installed via winget: ${pkg}`);
150
193
 
151
- // If MSYS2 was installed, need to install MinGW inside it
194
+ // If MSYS2 was installed, automatically install MinGW toolchain
152
195
  if (pkg === 'msys2.msys2') {
153
- console.log('\n ⚠️ MSYS2 installed. You need to:');
154
- console.log(' 1. Open MSYS2 terminal (search for "MSYS2 MSYS" in Start menu)');
155
- console.log(' 2. Run: pacman -S mingw-w64-x86_64-toolchain --noconfirm');
156
- console.log(' 3. Add C:\\msys64\\mingw64\\bin to your PATH');
157
- console.log(' 4. Restart terminal and run: 4runr-setup\n');
158
- process.exit(0);
196
+ const msys2MingwPath = 'C:\\msys64\\mingw64\\bin';
197
+ const msys2Bash = 'C:\\msys64\\usr\\bin\\bash.exe';
198
+
199
+ // Check if MinGW is already installed
200
+ if (fs.existsSync(path.join(msys2MingwPath, 'dlltool.exe'))) {
201
+ console.log(`\n ✅ MinGW already installed in MSYS2`);
202
+ mingwInstalled = true;
203
+ mingwPath = msys2MingwPath;
204
+ } else {
205
+ // Automatically install MinGW toolchain via MSYS2
206
+ console.log('\n 🔨 Installing MinGW toolchain in MSYS2 (this may take a few minutes)...');
207
+ try {
208
+ execSync(`"${msys2Bash}" -lc "pacman -S mingw-w64-x86_64-toolchain --noconfirm"`, {
209
+ stdio: 'inherit',
210
+ timeout: 300000 // 5 minutes for installation
211
+ });
212
+
213
+ // Verify installation
214
+ if (fs.existsSync(path.join(msys2MingwPath, 'dlltool.exe'))) {
215
+ console.log(' ✅ MinGW toolchain installed successfully');
216
+ mingwInstalled = true;
217
+ mingwPath = msys2MingwPath;
218
+ } else {
219
+ console.warn(' ⚠️ Installation completed but MinGW not found. Please restart terminal and run 4runr-setup again.');
220
+ process.exit(0);
221
+ }
222
+ } catch (installError) {
223
+ console.error(' ❌ Failed to install MinGW automatically');
224
+ console.error(' Please install manually:');
225
+ console.error(' 1. Open MSYS2 terminal');
226
+ console.error(' 2. Run: pacman -S mingw-w64-x86_64-toolchain --noconfirm');
227
+ console.error(' 3. Restart terminal and run: 4runr-setup\n');
228
+ process.exit(1);
229
+ }
230
+ }
231
+
232
+ // Add to PATH for current session
233
+ if (mingwInstalled && mingwPath) {
234
+ console.log(` ✅ Adding ${mingwPath} to PATH for this session...`);
235
+ process.env.PATH = process.env.PATH ? `${mingwPath};${process.env.PATH}` : mingwPath;
236
+
237
+ // Try to add to permanent PATH (may require admin)
238
+ try {
239
+ const currentPath = execSync('powershell -Command "[Environment]::GetEnvironmentVariable(\'Path\', \'User\')"', { encoding: 'utf-8' }).trim();
240
+ if (!currentPath.includes(mingwPath)) {
241
+ // Use synchronous readline for simpler flow
242
+ process.stdout.write('\n Add MinGW to PATH permanently? (recommended) [Y/n]: ');
243
+ const rl = readline.createInterface({
244
+ input: process.stdin,
245
+ output: process.stdout
246
+ });
247
+
248
+ rl.on('line', (answer) => {
249
+ rl.close();
250
+ if (!answer || answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
251
+ try {
252
+ execSync(`powershell -Command "[Environment]::SetEnvironmentVariable('Path', [Environment]::GetEnvironmentVariable('Path', 'User') + ';${mingwPath}', 'User')"`, { stdio: 'pipe' });
253
+ console.log(' ✅ Added to PATH permanently');
254
+ } catch {
255
+ console.log(' ⚠️ Could not add to PATH permanently. Please add manually:');
256
+ console.log(` ${mingwPath}`);
257
+ }
258
+ }
259
+ });
260
+ }
261
+ } catch {
262
+ // Ignore - PATH update failed, user can add manually
263
+ }
264
+ }
159
265
  }
160
266
  break;
161
267
  } catch (err) {