squad-station 0.8.18 → 0.8.21

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/bin/run.js +67 -19
  2. package/package.json +1 -1
package/bin/run.js CHANGED
@@ -45,7 +45,7 @@ function install() {
45
45
 
46
46
  function installBinary() {
47
47
  // Binary version — may differ from npm package version
48
- var VERSION = '0.8.18';
48
+ var VERSION = '0.8.21';
49
49
  var REPO = 'thientranhung/squad-station';
50
50
 
51
51
  var isWindows = process.platform === 'win32';
@@ -174,36 +174,77 @@ function findBestInstallDir() {
174
174
  return squadBin;
175
175
  }
176
176
 
177
- // Verify the installed binary is callable. If not, print PATH instructions.
177
+ // Verify the installed binary is callable. If not, auto-add to shell profile.
178
178
  function verifyInPath(destPath, installDir) {
179
179
  var isWindows = process.platform === 'win32';
180
180
  var checkCmd = isWindows ? 'where' : 'which';
181
181
  var checkResult = spawnSync(checkCmd, ['squad-station'], { encoding: 'utf8' });
182
182
 
183
183
  if (checkResult.status === 0 && checkResult.stdout && checkResult.stdout.trim()) {
184
- // Binary is found in PATH — all good
185
- return;
184
+ var foundPath = checkResult.stdout.trim();
185
+ // Ignore npx cache / node_modules wrappers — not real user PATH entries
186
+ if (!foundPath.includes('.npm/_npx') && !foundPath.includes('node_modules/.bin') && !foundPath.includes('node_modules\\.bin')) {
187
+ // Binary is found in real PATH — all good
188
+ return;
189
+ }
186
190
  }
187
191
 
188
- // Not in PATH — print instructions
189
- console.log('');
190
- console.log(' \x1b[33m⚠ squad-station is not in your PATH\x1b[0m');
191
- console.log(' The binary was installed to: \x1b[36m' + installDir + '\x1b[0m');
192
- console.log('');
193
-
194
192
  if (isWindows) {
195
- console.log(' Add to your PATH:');
193
+ // Windows: print manual instructions (modifying registry is too invasive)
196
194
  console.log('');
195
+ console.log(' \x1b[33m⚠ squad-station is not in your PATH\x1b[0m');
197
196
  console.log(' \x1b[2m# Windows (PowerShell) — run as Administrator:\x1b[0m');
198
197
  console.log(' \x1b[36m[Environment]::SetEnvironmentVariable("Path",\x1b[0m');
199
198
  console.log(' \x1b[36m [Environment]::GetEnvironmentVariable("Path", "User") + ";' + installDir + '", "User")\x1b[0m');
200
- console.log('');
201
199
  console.log(' Then restart your terminal.');
202
- } else {
203
- var shellProfile = process.platform === 'darwin' ? '~/.zshrc' : '~/.bashrc';
204
- console.log(' Add to your shell profile: \x1b[36mexport PATH="$HOME/.squad/bin:$PATH"\x1b[0m');
205
- console.log(' Then restart your terminal or run: \x1b[36msource ' + shellProfile + '\x1b[0m');
200
+ console.log('');
201
+ return;
206
202
  }
203
+
204
+ // macOS/Linux: auto-add to shell profile
205
+ var home = process.env.HOME || '';
206
+ var exportLine = 'export PATH="$HOME/.squad/bin:$PATH"';
207
+ var profileCandidates = process.platform === 'darwin'
208
+ ? ['.zshrc', '.bash_profile', '.bashrc']
209
+ : ['.bashrc', '.zshrc', '.profile'];
210
+
211
+ // Find the first existing profile, or default to the platform's primary
212
+ var profileName = profileCandidates[0];
213
+ for (var i = 0; i < profileCandidates.length; i++) {
214
+ if (fs.existsSync(path.join(home, profileCandidates[i]))) {
215
+ profileName = profileCandidates[i];
216
+ break;
217
+ }
218
+ }
219
+ var profilePath = path.join(home, profileName);
220
+
221
+ // Check if already added (idempotent)
222
+ var alreadyAdded = false;
223
+ try {
224
+ var content = fs.readFileSync(profilePath, 'utf8');
225
+ if (content.includes('.squad/bin')) {
226
+ alreadyAdded = true;
227
+ }
228
+ } catch (_) {
229
+ // File doesn't exist yet — we'll create it
230
+ }
231
+
232
+ if (!alreadyAdded) {
233
+ try {
234
+ var marker = '\n# Squad Station\n' + exportLine + '\n';
235
+ fs.appendFileSync(profilePath, marker);
236
+ console.log(' \x1b[32m✓\x1b[0m Added ~/.squad/bin to PATH in ~/' + profileName);
237
+ } catch (e) {
238
+ console.log(' \x1b[33m⚠\x1b[0m Could not update ~/' + profileName + ': ' + e.message);
239
+ console.log(' Add manually: \x1b[36m' + exportLine + '\x1b[0m');
240
+ console.log('');
241
+ return;
242
+ }
243
+ }
244
+
245
+ // Source the profile so it takes effect in the current npx process isn't needed,
246
+ // but we need the user's NEXT terminal to work. Print a note.
247
+ console.log(' \x1b[33m→\x1b[0m Run \x1b[36msource ~/' + profileName + '\x1b[0m or open a new terminal to activate.');
207
248
  console.log('');
208
249
  }
209
250
 
@@ -217,14 +258,21 @@ function checkDuplicateBinary(installedPath) {
217
258
  return; // not in PATH at all — verifyInPath already warned
218
259
  }
219
260
 
220
- var resolvedWhich = fs.realpathSync(result.stdout.trim());
261
+ var whichPath = result.stdout.trim();
262
+
263
+ // Ignore npx cache / node_modules wrappers — these are not real installs
264
+ if (whichPath.includes('.npm/_npx') || whichPath.includes('node_modules/.bin') || whichPath.includes('node_modules\\.bin')) {
265
+ return;
266
+ }
267
+
268
+ var resolvedWhich = fs.realpathSync(whichPath);
221
269
  var resolvedInstalled = fs.realpathSync(installedPath);
222
270
 
223
271
  if (resolvedWhich !== resolvedInstalled) {
224
272
  console.log('');
225
- console.log(' \x1b[33m⚠ Another squad-station found at: ' + result.stdout.trim() + '\x1b[0m');
273
+ console.log(' \x1b[33m⚠ Another squad-station found at: ' + whichPath + '\x1b[0m');
226
274
  console.log(' This version will be used instead of the one just installed.');
227
- console.log(' Remove it to avoid conflicts: \x1b[36mrm ' + result.stdout.trim() + '\x1b[0m');
275
+ console.log(' Remove it to avoid conflicts: \x1b[36mrm ' + whichPath + '\x1b[0m');
228
276
  console.log('');
229
277
  }
230
278
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squad-station",
3
- "version": "0.8.18",
3
+ "version": "0.8.21",
4
4
  "description": "Message routing and orchestration for AI agent squads",
5
5
  "repository": {
6
6
  "type": "git",