4runr-os 2.1.32 → 2.1.34

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 +108 -74
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "4runr-os",
3
- "version": "2.1.32",
3
+ "version": "2.1.34",
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
@@ -17,6 +17,8 @@ const __dirname = dirname(__filename);
17
17
  const platform = process.platform;
18
18
  const isWindows = platform === 'win32';
19
19
 
20
+ // Main setup function (async for delays)
21
+ async function runSetup() {
20
22
  console.log('šŸ” Checking 4runr-os setup...\n');
21
23
 
22
24
  // Check Node.js
@@ -97,48 +99,94 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
97
99
  let mingwInstalled = false;
98
100
  let mingwPath = '';
99
101
 
100
- try {
101
- const dlltoolPath = execSync('where dlltool.exe', { encoding: 'utf-8', stdio: 'pipe' }).trim();
102
- mingwInstalled = true;
103
- mingwPath = path.dirname(dlltoolPath);
104
- console.log('āœ… MinGW found at:', mingwPath);
105
- } catch {
106
- console.log('āš ļø MinGW not found in PATH - required for GNU toolchain');
107
- console.log(' Checking common installation locations...');
108
-
109
- // Check common MinGW locations
110
- const commonPaths = [
111
- 'C:\\mingw64\\bin',
112
- 'C:\\msys64\\mingw64\\bin',
113
- 'C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin',
114
- path.join(process.env.ProgramFiles || 'C:\\Program Files', 'mingw-w64', 'x86_64-*-*-*-*-*', 'mingw64', 'bin'),
115
- ];
116
-
117
- for (const testPath of commonPaths) {
118
- const dlltoolPath = path.join(testPath, 'dlltool.exe');
119
- if (fs.existsSync(dlltoolPath)) {
120
- mingwInstalled = true;
121
- mingwPath = testPath;
122
- console.log('āœ… MinGW found at:', mingwPath);
123
- console.log(' Adding to PATH for this session...');
124
- process.env.PATH = process.env.PATH ? `${mingwPath};${process.env.PATH}` : mingwPath;
125
- break;
102
+ // PRIORITY 1: Check if MSYS2 exists FIRST (most reliable)
103
+ const msys2MingwPath = 'C:\\msys64\\mingw64\\bin';
104
+ const msys2Bash = 'C:\\msys64\\usr\\bin\\bash.exe';
105
+
106
+ if (fs.existsSync(msys2Bash)) {
107
+ console.log(' āœ… MSYS2 found - checking for MinGW...');
108
+ if (fs.existsSync(path.join(msys2MingwPath, 'dlltool.exe'))) {
109
+ mingwInstalled = true;
110
+ mingwPath = msys2MingwPath;
111
+ console.log(' āœ… MinGW found in MSYS2');
112
+ } else {
113
+ // MSYS2 exists but MinGW not installed - install it automatically
114
+ console.log(' šŸ”Ø Installing MinGW toolchain in MSYS2 (this may take 2-3 minutes)...');
115
+ try {
116
+ execSync(`"${msys2Bash}" -lc "pacman -S mingw-w64-x86_64-toolchain --noconfirm"`, {
117
+ stdio: 'inherit',
118
+ timeout: 300000 // 5 minutes
119
+ });
120
+
121
+ if (fs.existsSync(path.join(msys2MingwPath, 'dlltool.exe'))) {
122
+ mingwInstalled = true;
123
+ mingwPath = msys2MingwPath;
124
+ console.log(' āœ… MinGW toolchain installed successfully');
125
+ } else {
126
+ console.warn(' āš ļø Installation completed but MinGW not found');
127
+ console.warn(' Please restart terminal and run 4runr-setup again');
128
+ process.exit(0);
129
+ }
130
+ } catch (installError) {
131
+ console.error(' āŒ Failed to install MinGW automatically');
132
+ console.error(' Quick fix - run this command:');
133
+ console.error(` "${msys2Bash}" -lc "pacman -S mingw-w64-x86_64-toolchain --noconfirm"`);
134
+ console.error(' Then restart terminal and run: 4runr-setup\n');
135
+ process.exit(1);
126
136
  }
127
137
  }
128
138
 
129
- if (!mingwInstalled) {
130
- console.log(' Installing MinGW-w64...');
131
-
132
- // Try multiple installation methods
133
- let installed = false;
134
-
135
- // Try winget - MSYS2 is more reliable and includes MinGW
136
- const wingetPackages = [
137
- 'msys2.msys2', // MSYS2 (includes MinGW, most reliable)
138
- 'mingw-w64.mingw-w64', // Direct MinGW package
139
- 'mingw-w64', // Alternative MinGW package name
139
+ // Add to PATH for current session
140
+ if (mingwInstalled && mingwPath) {
141
+ console.log(` āœ… Adding ${mingwPath} to PATH for this session...`);
142
+ process.env.PATH = process.env.PATH ? `${mingwPath};${process.env.PATH}` : mingwPath;
143
+ }
144
+ }
145
+
146
+ // PRIORITY 2: Check PATH if MSYS2 didn't work
147
+ if (!mingwInstalled) {
148
+ try {
149
+ const dlltoolPath = execSync('where dlltool.exe', { encoding: 'utf-8', stdio: 'pipe' }).trim();
150
+ mingwInstalled = true;
151
+ mingwPath = path.dirname(dlltoolPath);
152
+ console.log(' āœ… MinGW found in PATH at:', mingwPath);
153
+ } catch {
154
+ // Check other common paths
155
+ console.log(' Checking common installation locations...');
156
+ const commonPaths = [
157
+ 'C:\\mingw64\\bin',
158
+ 'C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin',
140
159
  ];
141
160
 
161
+ for (const testPath of commonPaths) {
162
+ if (fs.existsSync(testPath)) {
163
+ const dlltoolPath = path.join(testPath, 'dlltool.exe');
164
+ if (fs.existsSync(dlltoolPath)) {
165
+ mingwInstalled = true;
166
+ mingwPath = testPath;
167
+ console.log(' āœ… MinGW found at:', mingwPath);
168
+ process.env.PATH = process.env.PATH ? `${mingwPath};${process.env.PATH}` : mingwPath;
169
+ break;
170
+ }
171
+ }
172
+ }
173
+ }
174
+ }
175
+
176
+ // PRIORITY 3: Only if still not found, try winget installation
177
+ if (!mingwInstalled) {
178
+ console.log(' Installing MinGW-w64 via winget...');
179
+
180
+ // Try multiple installation methods
181
+ let installed = false;
182
+
183
+ // Try winget - MSYS2 is more reliable and includes MinGW
184
+ const wingetPackages = [
185
+ 'msys2.msys2', // MSYS2 (includes MinGW, most reliable)
186
+ 'mingw-w64.mingw-w64', // Direct MinGW package
187
+ 'mingw-w64', // Alternative MinGW package name
188
+ ];
189
+
142
190
  for (const pkg of wingetPackages) {
143
191
  try {
144
192
  console.log(` Trying: winget install ${pkg}...`);
@@ -149,19 +197,21 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
149
197
  installed = true;
150
198
  console.log(` āœ… Installed via winget: ${pkg}`);
151
199
 
152
- // If MSYS2 was installed, automatically install MinGW toolchain
200
+ // If MSYS2 was just installed via winget, install MinGW inside it
153
201
  if (pkg === 'msys2.msys2') {
154
- const msys2MingwPath = 'C:\\msys64\\mingw64\\bin';
155
- const msys2Bash = 'C:\\msys64\\usr\\bin\\bash.exe';
202
+ // Wait a moment for MSYS2 installation to complete
203
+ console.log(' Waiting for MSYS2 installation to complete...');
204
+ const { setTimeout } = await import('timers/promises');
205
+ await setTimeout(5000);
156
206
 
157
207
  // Check if MinGW is already installed
158
208
  if (fs.existsSync(path.join(msys2MingwPath, 'dlltool.exe'))) {
159
- console.log(`\n āœ… MinGW already installed in MSYS2`);
209
+ console.log(` āœ… MinGW already installed in MSYS2`);
160
210
  mingwInstalled = true;
161
211
  mingwPath = msys2MingwPath;
162
212
  } else {
163
213
  // Automatically install MinGW toolchain via MSYS2
164
- console.log('\n šŸ”Ø Installing MinGW toolchain in MSYS2 (this may take a few minutes)...');
214
+ console.log(' šŸ”Ø Installing MinGW toolchain in MSYS2 (this may take 2-3 minutes)...');
165
215
  try {
166
216
  execSync(`"${msys2Bash}" -lc "pacman -S mingw-w64-x86_64-toolchain --noconfirm"`, {
167
217
  stdio: 'inherit',
@@ -179,10 +229,9 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
179
229
  }
180
230
  } catch (installError) {
181
231
  console.error(' āŒ Failed to install MinGW automatically');
182
- console.error(' Please install manually:');
183
- console.error(' 1. Open MSYS2 terminal');
184
- console.error(' 2. Run: pacman -S mingw-w64-x86_64-toolchain --noconfirm');
185
- console.error(' 3. Restart terminal and run: 4runr-setup\n');
232
+ console.error(' Quick fix - run this command:');
233
+ console.error(` "${msys2Bash}" -lc "pacman -S mingw-w64-x86_64-toolchain --noconfirm"`);
234
+ console.error(' Then restart terminal and run: 4runr-setup\n');
186
235
  process.exit(1);
187
236
  }
188
237
  }
@@ -191,34 +240,18 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
191
240
  if (mingwInstalled && mingwPath) {
192
241
  console.log(` āœ… Adding ${mingwPath} to PATH for this session...`);
193
242
  process.env.PATH = process.env.PATH ? `${mingwPath};${process.env.PATH}` : mingwPath;
194
-
195
- // Try to add to permanent PATH (may require admin)
196
- try {
197
- const currentPath = execSync('powershell -Command "[Environment]::GetEnvironmentVariable(\'Path\', \'User\')"', { encoding: 'utf-8' }).trim();
198
- if (!currentPath.includes(mingwPath)) {
199
- // Use synchronous readline for simpler flow
200
- process.stdout.write('\n Add MinGW to PATH permanently? (recommended) [Y/n]: ');
201
- const rl = readline.createInterface({
202
- input: process.stdin,
203
- output: process.stdout
204
- });
205
-
206
- rl.on('line', (answer) => {
207
- rl.close();
208
- if (!answer || answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
209
- try {
210
- execSync(`powershell -Command "[Environment]::SetEnvironmentVariable('Path', [Environment]::GetEnvironmentVariable('Path', 'User') + ';${mingwPath}', 'User')"`, { stdio: 'pipe' });
211
- console.log(' āœ… Added to PATH permanently');
212
- } catch {
213
- console.log(' āš ļø Could not add to PATH permanently. Please add manually:');
214
- console.log(` ${mingwPath}`);
215
- }
216
- }
217
- });
218
- }
219
- } catch {
220
- // Ignore - PATH update failed, user can add manually
221
- }
243
+ }
244
+ } else {
245
+ // Direct MinGW package - wait and check PATH
246
+ const { setTimeout } = await import('timers/promises');
247
+ await setTimeout(2000);
248
+ try {
249
+ const dlltoolPath = execSync('where dlltool.exe', { encoding: 'utf-8', stdio: 'pipe' }).trim();
250
+ mingwInstalled = true;
251
+ mingwPath = path.dirname(dlltoolPath);
252
+ } catch {
253
+ // Not in PATH yet - user will need to restart terminal
254
+ console.warn(' āš ļø Installed but not in PATH - please restart terminal');
222
255
  }
223
256
  }
224
257
  break;
@@ -340,4 +373,5 @@ if (mk3Dir && fs.existsSync(mk3Dir)) {
340
373
  }
341
374
 
342
375
  console.log('\nāœ… Setup complete! You can now run: 4r\n');
376
+ })();
343
377