ropilot 0.1.4 → 0.1.5

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/lib/setup.js +86 -16
  2. package/package.json +1 -1
package/lib/setup.js CHANGED
@@ -40,45 +40,82 @@ function isWSL() {
40
40
  }
41
41
 
42
42
  /**
43
- * Get Windows username when running in WSL
43
+ * Get Windows username when running in WSL (tries multiple methods)
44
44
  */
45
45
  function getWindowsUsername() {
46
+ const { execSync } = require('child_process');
47
+
48
+ // Method 1: cmd.exe
49
+ try {
50
+ const result = execSync('cmd.exe /c echo %USERNAME%', { encoding: 'utf-8', timeout: 5000 }).trim();
51
+ if (result && !result.includes('%')) return result;
52
+ } catch {}
53
+
54
+ // Method 2: whoami.exe (returns DOMAIN\user)
46
55
  try {
47
- const { execSync } = require('child_process');
48
- const username = execSync('cmd.exe /c echo %USERNAME%', { encoding: 'utf-8' }).trim();
49
- if (username && !username.includes('%')) {
50
- return username;
56
+ const result = execSync('/mnt/c/Windows/System32/whoami.exe', { encoding: 'utf-8', timeout: 5000 }).trim();
57
+ if (result && result.includes('\\')) {
58
+ return result.split('\\').pop();
51
59
  }
52
60
  } catch {}
61
+
62
+ // Method 3: powershell
63
+ try {
64
+ const result = execSync('powershell.exe -NoProfile -Command "$env:USERNAME"', { encoding: 'utf-8', timeout: 5000 }).trim();
65
+ if (result) return result;
66
+ } catch {}
67
+
53
68
  return null;
54
69
  }
55
70
 
71
+ /**
72
+ * Get valid Windows users from /mnt/c/Users
73
+ */
74
+ function getValidWindowsUsers() {
75
+ const usersDir = '/mnt/c/Users';
76
+ try {
77
+ return readdirSync(usersDir).filter(u =>
78
+ !['Public', 'Default', 'Default User', 'All Users', 'desktop.ini'].includes(u) &&
79
+ existsSync(join(usersDir, u, 'AppData'))
80
+ );
81
+ } catch {
82
+ return [];
83
+ }
84
+ }
85
+
56
86
  /**
57
87
  * Get Roblox plugins folder path based on OS (with WSL detection)
88
+ * Returns { path, needsPrompt, users } - needsPrompt true if user selection needed
58
89
  */
59
90
  function getPluginsFolder() {
60
91
  const os = platform();
61
92
 
62
93
  // Check for WSL first - need to use Windows path
63
94
  if (os === 'linux' && isWSL()) {
95
+ // Try to auto-detect Windows username
64
96
  const windowsUser = getWindowsUsername();
65
- if (windowsUser) {
66
- const pluginsPath = join('/mnt/c/Users', windowsUser, 'AppData', 'Local', 'Roblox', 'Plugins');
67
- if (existsSync(dirname(pluginsPath)) || existsSync('/mnt/c/Users/' + windowsUser)) {
68
- return pluginsPath;
69
- }
97
+ if (windowsUser && existsSync(join('/mnt/c/Users', windowsUser))) {
98
+ return { path: join('/mnt/c/Users', windowsUser, 'AppData', 'Local', 'Roblox', 'Plugins') };
70
99
  }
71
- console.log(' Warning: Could not detect Windows username for WSL plugin install');
72
- return null;
100
+
101
+ // Fallback: scan /mnt/c/Users
102
+ const validUsers = getValidWindowsUsers();
103
+ if (validUsers.length === 1) {
104
+ return { path: join('/mnt/c/Users', validUsers[0], 'AppData', 'Local', 'Roblox', 'Plugins') };
105
+ } else if (validUsers.length > 1) {
106
+ return { path: null, needsPrompt: true, users: validUsers };
107
+ }
108
+
109
+ return { path: null };
73
110
  }
74
111
 
75
112
  if (os === 'win32') {
76
- return join(process.env.LOCALAPPDATA || join(homedir(), 'AppData', 'Local'), 'Roblox', 'Plugins');
113
+ return { path: join(process.env.LOCALAPPDATA || join(homedir(), 'AppData', 'Local'), 'Roblox', 'Plugins') };
77
114
  } else if (os === 'darwin') {
78
- return join(homedir(), 'Documents', 'Roblox', 'Plugins');
115
+ return { path: join(homedir(), 'Documents', 'Roblox', 'Plugins') };
79
116
  } else {
80
117
  // Linux without WSL - Roblox doesn't officially support Linux
81
- return null;
118
+ return { path: null };
82
119
  }
83
120
  }
84
121
 
@@ -122,7 +159,40 @@ async function installPlugin() {
122
159
  const pluginSource = await pluginResponse.text();
123
160
 
124
161
  // Get plugins folder
125
- const pluginsFolder = getPluginsFolder();
162
+ let folderResult = getPluginsFolder();
163
+ let pluginsFolder = folderResult.path;
164
+
165
+ // If WSL detected multiple users, prompt for selection
166
+ if (folderResult.needsPrompt && folderResult.users) {
167
+ console.log(' Multiple Windows users detected:');
168
+ folderResult.users.forEach((u, i) => console.log(` ${i + 1}. ${u}`));
169
+ const choice = await prompt(` Enter number (1-${folderResult.users.length}) or username: `);
170
+
171
+ let selectedUser;
172
+ const num = parseInt(choice);
173
+ if (num >= 1 && num <= folderResult.users.length) {
174
+ selectedUser = folderResult.users[num - 1];
175
+ } else if (folderResult.users.includes(choice)) {
176
+ selectedUser = choice;
177
+ } else if (existsSync(join('/mnt/c/Users', choice, 'AppData'))) {
178
+ selectedUser = choice;
179
+ }
180
+
181
+ if (selectedUser) {
182
+ pluginsFolder = join('/mnt/c/Users', selectedUser, 'AppData', 'Local', 'Roblox', 'Plugins');
183
+ }
184
+ }
185
+
186
+ // If still no folder and running in WSL, prompt for username directly
187
+ if (!pluginsFolder && isWSL()) {
188
+ const username = await prompt(' Enter your Windows username: ');
189
+ if (username && existsSync(join('/mnt/c/Users', username))) {
190
+ pluginsFolder = join('/mnt/c/Users', username, 'AppData', 'Local', 'Roblox', 'Plugins');
191
+ } else if (username) {
192
+ // Trust user input even if path doesn't exist yet
193
+ pluginsFolder = join('/mnt/c/Users', username, 'AppData', 'Local', 'Roblox', 'Plugins');
194
+ }
195
+ }
126
196
 
127
197
  if (!pluginsFolder) {
128
198
  console.log(' Could not determine Roblox plugins folder');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ropilot",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "AI-powered Roblox development assistant - MCP CLI",
5
5
  "author": "whut",
6
6
  "license": "MIT",